Loading...
1/*
2 * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it would be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write the Free Software Foundation,
15 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17#ifndef __XFS_ITABLE_H__
18#define __XFS_ITABLE_H__
19
20/*
21 * xfs_bulkstat() is used to fill in xfs_bstat structures as well as dm_stat
22 * structures (by the dmi library). This is a pointer to a formatter function
23 * that will iget the inode and fill in the appropriate structure.
24 * see xfs_bulkstat_one() and xfs_dm_bulkstat_one() in dmapi_xfs.c
25 */
26typedef int (*bulkstat_one_pf)(struct xfs_mount *mp,
27 xfs_ino_t ino,
28 void __user *buffer,
29 int ubsize,
30 int *ubused,
31 int *stat);
32
33/*
34 * Values for stat return value.
35 */
36#define BULKSTAT_RV_NOTHING 0
37#define BULKSTAT_RV_DIDONE 1
38#define BULKSTAT_RV_GIVEUP 2
39
40/*
41 * Return stat information in bulk (by-inode) for the filesystem.
42 */
43int /* error status */
44xfs_bulkstat(
45 xfs_mount_t *mp, /* mount point for filesystem */
46 xfs_ino_t *lastino, /* last inode returned */
47 int *count, /* size of buffer/count returned */
48 bulkstat_one_pf formatter, /* func that'd fill a single buf */
49 size_t statstruct_size,/* sizeof struct that we're filling */
50 char __user *ubuffer,/* buffer with inode stats */
51 int *done); /* 1 if there are more stats to get */
52
53int
54xfs_bulkstat_single(
55 xfs_mount_t *mp,
56 xfs_ino_t *lastinop,
57 char __user *buffer,
58 int *done);
59
60typedef int (*bulkstat_one_fmt_pf)( /* used size in bytes or negative error */
61 void __user *ubuffer, /* buffer to write to */
62 int ubsize, /* remaining user buffer sz */
63 int *ubused, /* bytes used by formatter */
64 const xfs_bstat_t *buffer); /* buffer to read from */
65
66int
67xfs_bulkstat_one_int(
68 xfs_mount_t *mp,
69 xfs_ino_t ino,
70 void __user *buffer,
71 int ubsize,
72 bulkstat_one_fmt_pf formatter,
73 int *ubused,
74 int *stat);
75
76int
77xfs_bulkstat_one(
78 xfs_mount_t *mp,
79 xfs_ino_t ino,
80 void __user *buffer,
81 int ubsize,
82 int *ubused,
83 int *stat);
84
85typedef int (*inumbers_fmt_pf)(
86 void __user *ubuffer, /* buffer to write to */
87 const xfs_inogrp_t *buffer, /* buffer to read from */
88 long count, /* # of elements to read */
89 long *written); /* # of bytes written */
90
91int
92xfs_inumbers_fmt(
93 void __user *ubuffer, /* buffer to write to */
94 const xfs_inogrp_t *buffer, /* buffer to read from */
95 long count, /* # of elements to read */
96 long *written); /* # of bytes written */
97
98int /* error status */
99xfs_inumbers(
100 xfs_mount_t *mp, /* mount point for filesystem */
101 xfs_ino_t *last, /* last inode returned */
102 int *count, /* size of buffer/count returned */
103 void __user *buffer, /* buffer with inode info */
104 inumbers_fmt_pf formatter);
105
106#endif /* __XFS_ITABLE_H__ */
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved.
4 */
5#ifndef __XFS_ITABLE_H__
6#define __XFS_ITABLE_H__
7
8/* In-memory representation of a userspace request for batch inode data. */
9struct xfs_ibulk {
10 struct xfs_mount *mp;
11 struct mnt_idmap *idmap;
12 void __user *ubuffer; /* user output buffer */
13 xfs_ino_t startino; /* start with this inode */
14 unsigned int icount; /* number of elements in ubuffer */
15 unsigned int ocount; /* number of records returned */
16 unsigned int flags; /* see XFS_IBULK_FLAG_* */
17};
18
19/* Only iterate within the same AG as startino */
20#define XFS_IBULK_SAME_AG (1U << 0)
21
22/* Fill out the bs_extents64 field if set. */
23#define XFS_IBULK_NREXT64 (1U << 1)
24
25/*
26 * Advance the user buffer pointer by one record of the given size. If the
27 * buffer is now full, return the appropriate error code.
28 */
29static inline int
30xfs_ibulk_advance(
31 struct xfs_ibulk *breq,
32 size_t bytes)
33{
34 char __user *b = breq->ubuffer;
35
36 breq->ubuffer = b + bytes;
37 breq->ocount++;
38 return breq->ocount == breq->icount ? -ECANCELED : 0;
39}
40
41/*
42 * Return stat information in bulk (by-inode) for the filesystem.
43 */
44
45/*
46 * Return codes for the formatter function are 0 to continue iterating, and
47 * non-zero to stop iterating. Any non-zero value will be passed up to the
48 * bulkstat/inumbers caller. The special value -ECANCELED can be used to stop
49 * iteration, as neither bulkstat nor inumbers will ever generate that error
50 * code on their own.
51 */
52
53typedef int (*bulkstat_one_fmt_pf)(struct xfs_ibulk *breq,
54 const struct xfs_bulkstat *bstat);
55
56int xfs_bulkstat_one(struct xfs_ibulk *breq, bulkstat_one_fmt_pf formatter);
57int xfs_bulkstat(struct xfs_ibulk *breq, bulkstat_one_fmt_pf formatter);
58void xfs_bulkstat_to_bstat(struct xfs_mount *mp, struct xfs_bstat *bs1,
59 const struct xfs_bulkstat *bstat);
60
61typedef int (*inumbers_fmt_pf)(struct xfs_ibulk *breq,
62 const struct xfs_inumbers *igrp);
63
64int xfs_inumbers(struct xfs_ibulk *breq, inumbers_fmt_pf formatter);
65void xfs_inumbers_to_inogrp(struct xfs_inogrp *ig1,
66 const struct xfs_inumbers *ig);
67
68#endif /* __XFS_ITABLE_H__ */