| .. | .. |
|---|
| 5 | 5 | #ifndef __XFS_ITABLE_H__ |
|---|
| 6 | 6 | #define __XFS_ITABLE_H__ |
|---|
| 7 | 7 | |
|---|
| 8 | | -/* |
|---|
| 9 | | - * xfs_bulkstat() is used to fill in xfs_bstat structures as well as dm_stat |
|---|
| 10 | | - * structures (by the dmi library). This is a pointer to a formatter function |
|---|
| 11 | | - * that will iget the inode and fill in the appropriate structure. |
|---|
| 12 | | - * see xfs_bulkstat_one() and xfs_dm_bulkstat_one() in dmapi_xfs.c |
|---|
| 13 | | - */ |
|---|
| 14 | | -typedef int (*bulkstat_one_pf)(struct xfs_mount *mp, |
|---|
| 15 | | - xfs_ino_t ino, |
|---|
| 16 | | - void __user *buffer, |
|---|
| 17 | | - int ubsize, |
|---|
| 18 | | - int *ubused, |
|---|
| 19 | | - int *stat); |
|---|
| 8 | +/* In-memory representation of a userspace request for batch inode data. */ |
|---|
| 9 | +struct xfs_ibulk { |
|---|
| 10 | + struct xfs_mount *mp; |
|---|
| 11 | + void __user *ubuffer; /* user output buffer */ |
|---|
| 12 | + xfs_ino_t startino; /* start with this inode */ |
|---|
| 13 | + unsigned int icount; /* number of elements in ubuffer */ |
|---|
| 14 | + unsigned int ocount; /* number of records returned */ |
|---|
| 15 | + unsigned int flags; /* see XFS_IBULK_FLAG_* */ |
|---|
| 16 | +}; |
|---|
| 17 | + |
|---|
| 18 | +/* Only iterate within the same AG as startino */ |
|---|
| 19 | +#define XFS_IBULK_SAME_AG (XFS_IWALK_SAME_AG) |
|---|
| 20 | 20 | |
|---|
| 21 | 21 | /* |
|---|
| 22 | | - * Values for stat return value. |
|---|
| 22 | + * Advance the user buffer pointer by one record of the given size. If the |
|---|
| 23 | + * buffer is now full, return the appropriate error code. |
|---|
| 23 | 24 | */ |
|---|
| 24 | | -#define BULKSTAT_RV_NOTHING 0 |
|---|
| 25 | | -#define BULKSTAT_RV_DIDONE 1 |
|---|
| 26 | | -#define BULKSTAT_RV_GIVEUP 2 |
|---|
| 25 | +static inline int |
|---|
| 26 | +xfs_ibulk_advance( |
|---|
| 27 | + struct xfs_ibulk *breq, |
|---|
| 28 | + size_t bytes) |
|---|
| 29 | +{ |
|---|
| 30 | + char __user *b = breq->ubuffer; |
|---|
| 31 | + |
|---|
| 32 | + breq->ubuffer = b + bytes; |
|---|
| 33 | + breq->ocount++; |
|---|
| 34 | + return breq->ocount == breq->icount ? -ECANCELED : 0; |
|---|
| 35 | +} |
|---|
| 27 | 36 | |
|---|
| 28 | 37 | /* |
|---|
| 29 | 38 | * Return stat information in bulk (by-inode) for the filesystem. |
|---|
| 30 | 39 | */ |
|---|
| 31 | | -int /* error status */ |
|---|
| 32 | | -xfs_bulkstat( |
|---|
| 33 | | - xfs_mount_t *mp, /* mount point for filesystem */ |
|---|
| 34 | | - xfs_ino_t *lastino, /* last inode returned */ |
|---|
| 35 | | - int *count, /* size of buffer/count returned */ |
|---|
| 36 | | - bulkstat_one_pf formatter, /* func that'd fill a single buf */ |
|---|
| 37 | | - size_t statstruct_size,/* sizeof struct that we're filling */ |
|---|
| 38 | | - char __user *ubuffer,/* buffer with inode stats */ |
|---|
| 39 | | - int *done); /* 1 if there are more stats to get */ |
|---|
| 40 | 40 | |
|---|
| 41 | | -typedef int (*bulkstat_one_fmt_pf)( /* used size in bytes or negative error */ |
|---|
| 42 | | - void __user *ubuffer, /* buffer to write to */ |
|---|
| 43 | | - int ubsize, /* remaining user buffer sz */ |
|---|
| 44 | | - int *ubused, /* bytes used by formatter */ |
|---|
| 45 | | - const xfs_bstat_t *buffer); /* buffer to read from */ |
|---|
| 41 | +/* |
|---|
| 42 | + * Return codes for the formatter function are 0 to continue iterating, and |
|---|
| 43 | + * non-zero to stop iterating. Any non-zero value will be passed up to the |
|---|
| 44 | + * bulkstat/inumbers caller. The special value -ECANCELED can be used to stop |
|---|
| 45 | + * iteration, as neither bulkstat nor inumbers will ever generate that error |
|---|
| 46 | + * code on their own. |
|---|
| 47 | + */ |
|---|
| 46 | 48 | |
|---|
| 47 | | -int |
|---|
| 48 | | -xfs_bulkstat_one_int( |
|---|
| 49 | | - xfs_mount_t *mp, |
|---|
| 50 | | - xfs_ino_t ino, |
|---|
| 51 | | - void __user *buffer, |
|---|
| 52 | | - int ubsize, |
|---|
| 53 | | - bulkstat_one_fmt_pf formatter, |
|---|
| 54 | | - int *ubused, |
|---|
| 55 | | - int *stat); |
|---|
| 49 | +typedef int (*bulkstat_one_fmt_pf)(struct xfs_ibulk *breq, |
|---|
| 50 | + const struct xfs_bulkstat *bstat); |
|---|
| 56 | 51 | |
|---|
| 57 | | -int |
|---|
| 58 | | -xfs_bulkstat_one( |
|---|
| 59 | | - xfs_mount_t *mp, |
|---|
| 60 | | - xfs_ino_t ino, |
|---|
| 61 | | - void __user *buffer, |
|---|
| 62 | | - int ubsize, |
|---|
| 63 | | - int *ubused, |
|---|
| 64 | | - int *stat); |
|---|
| 52 | +int xfs_bulkstat_one(struct xfs_ibulk *breq, bulkstat_one_fmt_pf formatter); |
|---|
| 53 | +int xfs_bulkstat(struct xfs_ibulk *breq, bulkstat_one_fmt_pf formatter); |
|---|
| 54 | +void xfs_bulkstat_to_bstat(struct xfs_mount *mp, struct xfs_bstat *bs1, |
|---|
| 55 | + const struct xfs_bulkstat *bstat); |
|---|
| 65 | 56 | |
|---|
| 66 | | -typedef int (*inumbers_fmt_pf)( |
|---|
| 67 | | - void __user *ubuffer, /* buffer to write to */ |
|---|
| 68 | | - const xfs_inogrp_t *buffer, /* buffer to read from */ |
|---|
| 69 | | - long count, /* # of elements to read */ |
|---|
| 70 | | - long *written); /* # of bytes written */ |
|---|
| 57 | +typedef int (*inumbers_fmt_pf)(struct xfs_ibulk *breq, |
|---|
| 58 | + const struct xfs_inumbers *igrp); |
|---|
| 71 | 59 | |
|---|
| 72 | | -int |
|---|
| 73 | | -xfs_inumbers_fmt( |
|---|
| 74 | | - void __user *ubuffer, /* buffer to write to */ |
|---|
| 75 | | - const xfs_inogrp_t *buffer, /* buffer to read from */ |
|---|
| 76 | | - long count, /* # of elements to read */ |
|---|
| 77 | | - long *written); /* # of bytes written */ |
|---|
| 78 | | - |
|---|
| 79 | | -int /* error status */ |
|---|
| 80 | | -xfs_inumbers( |
|---|
| 81 | | - xfs_mount_t *mp, /* mount point for filesystem */ |
|---|
| 82 | | - xfs_ino_t *last, /* last inode returned */ |
|---|
| 83 | | - int *count, /* size of buffer/count returned */ |
|---|
| 84 | | - void __user *buffer, /* buffer with inode info */ |
|---|
| 85 | | - inumbers_fmt_pf formatter); |
|---|
| 60 | +int xfs_inumbers(struct xfs_ibulk *breq, inumbers_fmt_pf formatter); |
|---|
| 61 | +void xfs_inumbers_to_inogrp(struct xfs_inogrp *ig1, |
|---|
| 62 | + const struct xfs_inumbers *ig); |
|---|
| 86 | 63 | |
|---|
| 87 | 64 | #endif /* __XFS_ITABLE_H__ */ |
|---|