xfs_types.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. /*
  2. * Copyright (c) 2000-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_TYPES_H__
  19. #define __XFS_TYPES_H__
  20. #ifdef __KERNEL__
  21. /*
  22. * POSIX Extensions
  23. */
  24. typedef unsigned char uchar_t;
  25. typedef unsigned short ushort_t;
  26. typedef unsigned int uint_t;
  27. typedef unsigned long ulong_t;
  28. /*
  29. * Additional type declarations for XFS
  30. */
  31. typedef signed char __int8_t;
  32. typedef unsigned char __uint8_t;
  33. typedef signed short int __int16_t;
  34. typedef unsigned short int __uint16_t;
  35. typedef signed int __int32_t;
  36. typedef unsigned int __uint32_t;
  37. typedef signed long long int __int64_t;
  38. typedef unsigned long long int __uint64_t;
  39. typedef enum { B_FALSE,B_TRUE } boolean_t;
  40. typedef __uint32_t prid_t; /* project ID */
  41. typedef __uint32_t inst_t; /* an instruction */
  42. typedef __s64 xfs_off_t; /* <file offset> type */
  43. typedef __u64 xfs_ino_t; /* <inode> type */
  44. typedef __s64 xfs_daddr_t; /* <disk address> type */
  45. typedef char * xfs_caddr_t; /* <core address> type */
  46. typedef __u32 xfs_dev_t;
  47. typedef __u32 xfs_nlink_t;
  48. /* __psint_t is the same size as a pointer */
  49. #if (BITS_PER_LONG == 32)
  50. typedef __int32_t __psint_t;
  51. typedef __uint32_t __psunsigned_t;
  52. #elif (BITS_PER_LONG == 64)
  53. typedef __int64_t __psint_t;
  54. typedef __uint64_t __psunsigned_t;
  55. #else
  56. #error BITS_PER_LONG must be 32 or 64
  57. #endif
  58. #endif /* __KERNEL__ */
  59. typedef __uint32_t xfs_agblock_t; /* blockno in alloc. group */
  60. typedef __uint32_t xfs_extlen_t; /* extent length in blocks */
  61. typedef __uint32_t xfs_agnumber_t; /* allocation group number */
  62. typedef __int32_t xfs_extnum_t; /* # of extents in a file */
  63. typedef __int16_t xfs_aextnum_t; /* # extents in an attribute fork */
  64. typedef __int64_t xfs_fsize_t; /* bytes in a file */
  65. typedef __uint64_t xfs_ufsize_t; /* unsigned bytes in a file */
  66. typedef __int32_t xfs_suminfo_t; /* type of bitmap summary info */
  67. typedef __int32_t xfs_rtword_t; /* word type for bitmap manipulations */
  68. typedef __int64_t xfs_lsn_t; /* log sequence number */
  69. typedef __int32_t xfs_tid_t; /* transaction identifier */
  70. typedef __uint32_t xfs_dablk_t; /* dir/attr block number (in file) */
  71. typedef __uint32_t xfs_dahash_t; /* dir/attr hash value */
  72. typedef __uint16_t xfs_prid_t; /* prid_t truncated to 16bits in XFS */
  73. /*
  74. * These types are 64 bits on disk but are either 32 or 64 bits in memory.
  75. * Disk based types:
  76. */
  77. typedef __uint64_t xfs_dfsbno_t; /* blockno in filesystem (agno|agbno) */
  78. typedef __uint64_t xfs_drfsbno_t; /* blockno in filesystem (raw) */
  79. typedef __uint64_t xfs_drtbno_t; /* extent (block) in realtime area */
  80. typedef __uint64_t xfs_dfiloff_t; /* block number in a file */
  81. typedef __uint64_t xfs_dfilblks_t; /* number of blocks in a file */
  82. /*
  83. * Memory based types are conditional.
  84. */
  85. #if XFS_BIG_BLKNOS
  86. typedef __uint64_t xfs_fsblock_t; /* blockno in filesystem (agno|agbno) */
  87. typedef __uint64_t xfs_rfsblock_t; /* blockno in filesystem (raw) */
  88. typedef __uint64_t xfs_rtblock_t; /* extent (block) in realtime area */
  89. typedef __int64_t xfs_srtblock_t; /* signed version of xfs_rtblock_t */
  90. #else
  91. typedef __uint32_t xfs_fsblock_t; /* blockno in filesystem (agno|agbno) */
  92. typedef __uint32_t xfs_rfsblock_t; /* blockno in filesystem (raw) */
  93. typedef __uint32_t xfs_rtblock_t; /* extent (block) in realtime area */
  94. typedef __int32_t xfs_srtblock_t; /* signed version of xfs_rtblock_t */
  95. #endif
  96. typedef __uint64_t xfs_fileoff_t; /* block number in a file */
  97. typedef __int64_t xfs_sfiloff_t; /* signed block number in a file */
  98. typedef __uint64_t xfs_filblks_t; /* number of blocks in a file */
  99. typedef __uint8_t xfs_arch_t; /* architecture of an xfs fs */
  100. /*
  101. * Null values for the types.
  102. */
  103. #define NULLDFSBNO ((xfs_dfsbno_t)-1)
  104. #define NULLDRFSBNO ((xfs_drfsbno_t)-1)
  105. #define NULLDRTBNO ((xfs_drtbno_t)-1)
  106. #define NULLDFILOFF ((xfs_dfiloff_t)-1)
  107. #define NULLFSBLOCK ((xfs_fsblock_t)-1)
  108. #define NULLRFSBLOCK ((xfs_rfsblock_t)-1)
  109. #define NULLRTBLOCK ((xfs_rtblock_t)-1)
  110. #define NULLFILEOFF ((xfs_fileoff_t)-1)
  111. #define NULLAGBLOCK ((xfs_agblock_t)-1)
  112. #define NULLAGNUMBER ((xfs_agnumber_t)-1)
  113. #define NULLEXTNUM ((xfs_extnum_t)-1)
  114. #define NULLCOMMITLSN ((xfs_lsn_t)-1)
  115. /*
  116. * Max values for extlen, extnum, aextnum.
  117. */
  118. #define MAXEXTLEN ((xfs_extlen_t)0x001fffff) /* 21 bits */
  119. #define MAXEXTNUM ((xfs_extnum_t)0x7fffffff) /* signed int */
  120. #define MAXAEXTNUM ((xfs_aextnum_t)0x7fff) /* signed short */
  121. /*
  122. * Min numbers of data/attr fork btree root pointers.
  123. */
  124. #define MINDBTPTRS 3
  125. #define MINABTPTRS 2
  126. /*
  127. * MAXNAMELEN is the length (including the terminating null) of
  128. * the longest permissible file (component) name.
  129. */
  130. #define MAXNAMELEN 256
  131. typedef struct xfs_dirent { /* data from readdir() */
  132. xfs_ino_t d_ino; /* inode number of entry */
  133. xfs_off_t d_off; /* offset of disk directory entry */
  134. unsigned short d_reclen; /* length of this record */
  135. char d_name[1]; /* name of file */
  136. } xfs_dirent_t;
  137. #define DIRENTBASESIZE (((xfs_dirent_t *)0)->d_name - (char *)0)
  138. #define DIRENTSIZE(namelen) \
  139. ((DIRENTBASESIZE + (namelen) + \
  140. sizeof(xfs_off_t)) & ~(sizeof(xfs_off_t) - 1))
  141. typedef enum {
  142. XFS_LOOKUP_EQi, XFS_LOOKUP_LEi, XFS_LOOKUP_GEi
  143. } xfs_lookup_t;
  144. typedef enum {
  145. XFS_BTNUM_BNOi, XFS_BTNUM_CNTi, XFS_BTNUM_BMAPi, XFS_BTNUM_INOi,
  146. XFS_BTNUM_MAX
  147. } xfs_btnum_t;
  148. #endif /* __XFS_TYPES_H__ */