Commit | Line | Data |
---|---|---|
0b61f8a4 | 1 | // SPDX-License-Identifier: GPL-2.0 |
1da177e4 LT |
2 | /* |
3 | * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. | |
1da177e4 LT |
4 | */ |
5 | #ifndef __XFS_ITABLE_H__ | |
6 | #define __XFS_ITABLE_H__ | |
7 | ||
2810bd68 DW |
8 | /* In-memory representation of a userspace request for batch inode data. */ |
9 | struct xfs_ibulk { | |
10 | struct xfs_mount *mp; | |
e67fe633 | 11 | struct mnt_idmap *idmap; |
2810bd68 DW |
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 */ | |
13d59a2a | 16 | unsigned int flags; /* see XFS_IBULK_FLAG_* */ |
2810bd68 DW |
17 | }; |
18 | ||
13d59a2a | 19 | /* Only iterate within the same AG as startino */ |
5b35d922 | 20 | #define XFS_IBULK_SAME_AG (1U << 0) |
13d59a2a | 21 | |
c3c4ecb5 CB |
22 | /* Fill out the bs_extents64 field if set. */ |
23 | #define XFS_IBULK_NREXT64 (1U << 1) | |
24 | ||
1da177e4 | 25 | /* |
2810bd68 DW |
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. | |
1da177e4 | 28 | */ |
2810bd68 DW |
29 | static inline int |
30 | xfs_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++; | |
e7ee96df | 38 | return breq->ocount == breq->icount ? -ECANCELED : 0; |
2810bd68 | 39 | } |
1da177e4 | 40 | |
1da177e4 LT |
41 | /* |
42 | * Return stat information in bulk (by-inode) for the filesystem. | |
43 | */ | |
faa63e95 | 44 | |
e7ee96df DW |
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 | ||
2810bd68 | 53 | typedef int (*bulkstat_one_fmt_pf)(struct xfs_ibulk *breq, |
7035f972 | 54 | const struct xfs_bulkstat *bstat); |
2ee4fa5c | 55 | |
2810bd68 DW |
56 | int xfs_bulkstat_one(struct xfs_ibulk *breq, bulkstat_one_fmt_pf formatter); |
57 | int xfs_bulkstat(struct xfs_ibulk *breq, bulkstat_one_fmt_pf formatter); | |
7035f972 DW |
58 | void xfs_bulkstat_to_bstat(struct xfs_mount *mp, struct xfs_bstat *bs1, |
59 | const struct xfs_bulkstat *bstat); | |
1da177e4 | 60 | |
677717fb | 61 | typedef int (*inumbers_fmt_pf)(struct xfs_ibulk *breq, |
5f19c7fc | 62 | const struct xfs_inumbers *igrp); |
faa63e95 | 63 | |
677717fb | 64 | int xfs_inumbers(struct xfs_ibulk *breq, inumbers_fmt_pf formatter); |
5f19c7fc DW |
65 | void xfs_inumbers_to_inogrp(struct xfs_inogrp *ig1, |
66 | const struct xfs_inumbers *ig); | |
1da177e4 LT |
67 | |
68 | #endif /* __XFS_ITABLE_H__ */ |