xfs_itable.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. /* In-memory representation of a userspace request for batch inode data. */
  8. struct xfs_ibulk {
  9. struct xfs_mount *mp;
  10. struct user_namespace *mnt_userns;
  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. /* Only iterate within the same AG as startino */
  18. #define XFS_IBULK_SAME_AG (1U << 0)
  19. /* Fill out the bs_extents64 field if set. */
  20. #define XFS_IBULK_NREXT64 (1U << 1)
  21. /*
  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.
  24. */
  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. breq->ubuffer = b + bytes;
  32. breq->ocount++;
  33. return breq->ocount == breq->icount ? -ECANCELED : 0;
  34. }
  35. /*
  36. * Return stat information in bulk (by-inode) for the filesystem.
  37. */
  38. /*
  39. * Return codes for the formatter function are 0 to continue iterating, and
  40. * non-zero to stop iterating. Any non-zero value will be passed up to the
  41. * bulkstat/inumbers caller. The special value -ECANCELED can be used to stop
  42. * iteration, as neither bulkstat nor inumbers will ever generate that error
  43. * code on their own.
  44. */
  45. typedef int (*bulkstat_one_fmt_pf)(struct xfs_ibulk *breq,
  46. const struct xfs_bulkstat *bstat);
  47. int xfs_bulkstat_one(struct xfs_ibulk *breq, bulkstat_one_fmt_pf formatter);
  48. int xfs_bulkstat(struct xfs_ibulk *breq, bulkstat_one_fmt_pf formatter);
  49. void xfs_bulkstat_to_bstat(struct xfs_mount *mp, struct xfs_bstat *bs1,
  50. const struct xfs_bulkstat *bstat);
  51. typedef int (*inumbers_fmt_pf)(struct xfs_ibulk *breq,
  52. const struct xfs_inumbers *igrp);
  53. int xfs_inumbers(struct xfs_ibulk *breq, inumbers_fmt_pf formatter);
  54. void xfs_inumbers_to_inogrp(struct xfs_inogrp *ig1,
  55. const struct xfs_inumbers *ig);
  56. #endif /* __XFS_ITABLE_H__ */