xfs_itable.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. void __user *ubuffer; /* user output buffer */
  11. xfs_ino_t startino; /* start with this inode */
  12. unsigned int icount; /* number of elements in ubuffer */
  13. unsigned int ocount; /* number of records returned */
  14. unsigned int flags; /* see XFS_IBULK_FLAG_* */
  15. };
  16. /* Only iterate within the same AG as startino */
  17. #define XFS_IBULK_SAME_AG (XFS_IWALK_SAME_AG)
  18. /*
  19. * Advance the user buffer pointer by one record of the given size. If the
  20. * buffer is now full, return the appropriate error code.
  21. */
  22. static inline int
  23. xfs_ibulk_advance(
  24. struct xfs_ibulk *breq,
  25. size_t bytes)
  26. {
  27. char __user *b = breq->ubuffer;
  28. breq->ubuffer = b + bytes;
  29. breq->ocount++;
  30. return breq->ocount == breq->icount ? -ECANCELED : 0;
  31. }
  32. /*
  33. * Return stat information in bulk (by-inode) for the filesystem.
  34. */
  35. /*
  36. * Return codes for the formatter function are 0 to continue iterating, and
  37. * non-zero to stop iterating. Any non-zero value will be passed up to the
  38. * bulkstat/inumbers caller. The special value -ECANCELED can be used to stop
  39. * iteration, as neither bulkstat nor inumbers will ever generate that error
  40. * code on their own.
  41. */
  42. typedef int (*bulkstat_one_fmt_pf)(struct xfs_ibulk *breq,
  43. const struct xfs_bulkstat *bstat);
  44. int xfs_bulkstat_one(struct xfs_ibulk *breq, bulkstat_one_fmt_pf formatter);
  45. int xfs_bulkstat(struct xfs_ibulk *breq, bulkstat_one_fmt_pf formatter);
  46. void xfs_bulkstat_to_bstat(struct xfs_mount *mp, struct xfs_bstat *bs1,
  47. const struct xfs_bulkstat *bstat);
  48. typedef int (*inumbers_fmt_pf)(struct xfs_ibulk *breq,
  49. const struct xfs_inumbers *igrp);
  50. int xfs_inumbers(struct xfs_ibulk *breq, inumbers_fmt_pf formatter);
  51. void xfs_inumbers_to_inogrp(struct xfs_inogrp *ig1,
  52. const struct xfs_inumbers *ig);
  53. #endif /* __XFS_ITABLE_H__ */