xfs_inum.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
  3. * All Rights Reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it would be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write the Free Software Foundation,
  16. * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #ifndef __XFS_INUM_H__
  19. #define __XFS_INUM_H__
  20. /*
  21. * Inode number format:
  22. * low inopblog bits - offset in block
  23. * next agblklog bits - block number in ag
  24. * next agno_log bits - ag number
  25. * high agno_log-agblklog-inopblog bits - 0
  26. */
  27. typedef __uint32_t xfs_agino_t; /* within allocation grp inode number */
  28. /*
  29. * Useful inode bits for this kernel.
  30. * Used in some places where having 64-bits in the 32-bit kernels
  31. * costs too much.
  32. */
  33. #if XFS_BIG_INUMS
  34. typedef xfs_ino_t xfs_intino_t;
  35. #else
  36. typedef __uint32_t xfs_intino_t;
  37. #endif
  38. #define NULLFSINO ((xfs_ino_t)-1)
  39. #define NULLAGINO ((xfs_agino_t)-1)
  40. struct xfs_mount;
  41. #define XFS_INO_MASK(k) (__uint32_t)((1ULL << (k)) - 1)
  42. #define XFS_INO_OFFSET_BITS(mp) (mp)->m_sb.sb_inopblog
  43. #define XFS_INO_AGBNO_BITS(mp) (mp)->m_sb.sb_agblklog
  44. #define XFS_INO_AGINO_BITS(mp) (mp)->m_agino_log
  45. #define XFS_INO_AGNO_BITS(mp) (mp)->m_agno_log
  46. #define XFS_INO_BITS(mp) \
  47. XFS_INO_AGNO_BITS(mp) + XFS_INO_AGINO_BITS(mp)
  48. #define XFS_INO_TO_AGNO(mp,i) \
  49. ((xfs_agnumber_t)((i) >> XFS_INO_AGINO_BITS(mp)))
  50. #define XFS_INO_TO_AGINO(mp,i) \
  51. ((xfs_agino_t)(i) & XFS_INO_MASK(XFS_INO_AGINO_BITS(mp)))
  52. #define XFS_INO_TO_AGBNO(mp,i) \
  53. (((xfs_agblock_t)(i) >> XFS_INO_OFFSET_BITS(mp)) & \
  54. XFS_INO_MASK(XFS_INO_AGBNO_BITS(mp)))
  55. #define XFS_INO_TO_OFFSET(mp,i) \
  56. ((int)(i) & XFS_INO_MASK(XFS_INO_OFFSET_BITS(mp)))
  57. #define XFS_INO_TO_FSB(mp,i) \
  58. XFS_AGB_TO_FSB(mp, XFS_INO_TO_AGNO(mp,i), XFS_INO_TO_AGBNO(mp,i))
  59. #define XFS_AGINO_TO_INO(mp,a,i) \
  60. (((xfs_ino_t)(a) << XFS_INO_AGINO_BITS(mp)) | (i))
  61. #define XFS_AGINO_TO_AGBNO(mp,i) ((i) >> XFS_INO_OFFSET_BITS(mp))
  62. #define XFS_AGINO_TO_OFFSET(mp,i) \
  63. ((i) & XFS_INO_MASK(XFS_INO_OFFSET_BITS(mp)))
  64. #define XFS_OFFBNO_TO_AGINO(mp,b,o) \
  65. ((xfs_agino_t)(((b) << XFS_INO_OFFSET_BITS(mp)) | (o)))
  66. #if XFS_BIG_INUMS
  67. #define XFS_MAXINUMBER ((xfs_ino_t)((1ULL << 56) - 1ULL))
  68. #define XFS_INO64_OFFSET ((xfs_ino_t)(1ULL << 32))
  69. #else
  70. #define XFS_MAXINUMBER ((xfs_ino_t)((1ULL << 32) - 1ULL))
  71. #endif
  72. #define XFS_MAXINUMBER_32 ((xfs_ino_t)((1ULL << 32) - 1ULL))
  73. #endif /* __XFS_INUM_H__ */