xfs_inum.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. #define NULLFSINO ((xfs_ino_t)-1)
  29. #define NULLAGINO ((xfs_agino_t)-1)
  30. struct xfs_mount;
  31. #define XFS_INO_MASK(k) (__uint32_t)((1ULL << (k)) - 1)
  32. #define XFS_INO_OFFSET_BITS(mp) (mp)->m_sb.sb_inopblog
  33. #define XFS_INO_AGBNO_BITS(mp) (mp)->m_sb.sb_agblklog
  34. #define XFS_INO_AGINO_BITS(mp) (mp)->m_agino_log
  35. #define XFS_INO_AGNO_BITS(mp) (mp)->m_agno_log
  36. #define XFS_INO_BITS(mp) \
  37. XFS_INO_AGNO_BITS(mp) + XFS_INO_AGINO_BITS(mp)
  38. #define XFS_INO_TO_AGNO(mp,i) \
  39. ((xfs_agnumber_t)((i) >> XFS_INO_AGINO_BITS(mp)))
  40. #define XFS_INO_TO_AGINO(mp,i) \
  41. ((xfs_agino_t)(i) & XFS_INO_MASK(XFS_INO_AGINO_BITS(mp)))
  42. #define XFS_INO_TO_AGBNO(mp,i) \
  43. (((xfs_agblock_t)(i) >> XFS_INO_OFFSET_BITS(mp)) & \
  44. XFS_INO_MASK(XFS_INO_AGBNO_BITS(mp)))
  45. #define XFS_INO_TO_OFFSET(mp,i) \
  46. ((int)(i) & XFS_INO_MASK(XFS_INO_OFFSET_BITS(mp)))
  47. #define XFS_INO_TO_FSB(mp,i) \
  48. XFS_AGB_TO_FSB(mp, XFS_INO_TO_AGNO(mp,i), XFS_INO_TO_AGBNO(mp,i))
  49. #define XFS_AGINO_TO_INO(mp,a,i) \
  50. (((xfs_ino_t)(a) << XFS_INO_AGINO_BITS(mp)) | (i))
  51. #define XFS_AGINO_TO_AGBNO(mp,i) ((i) >> XFS_INO_OFFSET_BITS(mp))
  52. #define XFS_AGINO_TO_OFFSET(mp,i) \
  53. ((i) & XFS_INO_MASK(XFS_INO_OFFSET_BITS(mp)))
  54. #define XFS_OFFBNO_TO_AGINO(mp,b,o) \
  55. ((xfs_agino_t)(((b) << XFS_INO_OFFSET_BITS(mp)) | (o)))
  56. #if XFS_BIG_INUMS
  57. #define XFS_MAXINUMBER ((xfs_ino_t)((1ULL << 56) - 1ULL))
  58. #else
  59. #define XFS_MAXINUMBER ((xfs_ino_t)((1ULL << 32) - 1ULL))
  60. #endif
  61. #define XFS_MAXINUMBER_32 ((xfs_ino_t)((1ULL << 32) - 1ULL))
  62. #endif /* __XFS_INUM_H__ */