volume.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /*
  2. * volume.h - Defines for volume structures in NTFS Linux kernel driver. Part
  3. * of the Linux-NTFS project.
  4. *
  5. * Copyright (c) 2001-2006 Anton Altaparmakov
  6. * Copyright (c) 2002 Richard Russon
  7. *
  8. * This program/include file is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as published
  10. * by the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program/include file is distributed in the hope that it will be
  14. * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
  15. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program (in the main directory of the Linux-NTFS
  20. * distribution in the file COPYING); if not, write to the Free Software
  21. * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  22. */
  23. #ifndef _LINUX_NTFS_VOLUME_H
  24. #define _LINUX_NTFS_VOLUME_H
  25. #include <linux/rwsem.h>
  26. #include "types.h"
  27. #include "layout.h"
  28. /*
  29. * The NTFS in memory super block structure.
  30. */
  31. typedef struct {
  32. /*
  33. * FIXME: Reorder to have commonly used together element within the
  34. * same cache line, aiming at a cache line size of 32 bytes. Aim for
  35. * 64 bytes for less commonly used together elements. Put most commonly
  36. * used elements to front of structure. Obviously do this only when the
  37. * structure has stabilized... (AIA)
  38. */
  39. /* Device specifics. */
  40. struct super_block *sb; /* Pointer back to the super_block. */
  41. LCN nr_blocks; /* Number of sb->s_blocksize bytes
  42. sized blocks on the device. */
  43. /* Configuration provided by user at mount time. */
  44. unsigned long flags; /* Miscellaneous flags, see below. */
  45. uid_t uid; /* uid that files will be mounted as. */
  46. gid_t gid; /* gid that files will be mounted as. */
  47. mode_t fmask; /* The mask for file permissions. */
  48. mode_t dmask; /* The mask for directory
  49. permissions. */
  50. u8 mft_zone_multiplier; /* Initial mft zone multiplier. */
  51. u8 on_errors; /* What to do on filesystem errors. */
  52. /* NTFS bootsector provided information. */
  53. u16 sector_size; /* in bytes */
  54. u8 sector_size_bits; /* log2(sector_size) */
  55. u32 cluster_size; /* in bytes */
  56. u32 cluster_size_mask; /* cluster_size - 1 */
  57. u8 cluster_size_bits; /* log2(cluster_size) */
  58. u32 mft_record_size; /* in bytes */
  59. u32 mft_record_size_mask; /* mft_record_size - 1 */
  60. u8 mft_record_size_bits; /* log2(mft_record_size) */
  61. u32 index_record_size; /* in bytes */
  62. u32 index_record_size_mask; /* index_record_size - 1 */
  63. u8 index_record_size_bits; /* log2(index_record_size) */
  64. LCN nr_clusters; /* Volume size in clusters == number of
  65. bits in lcn bitmap. */
  66. LCN mft_lcn; /* Cluster location of mft data. */
  67. LCN mftmirr_lcn; /* Cluster location of copy of mft. */
  68. u64 serial_no; /* The volume serial number. */
  69. /* Mount specific NTFS information. */
  70. u32 upcase_len; /* Number of entries in upcase[]. */
  71. ntfschar *upcase; /* The upcase table. */
  72. s32 attrdef_size; /* Size of the attribute definition
  73. table in bytes. */
  74. ATTR_DEF *attrdef; /* Table of attribute definitions.
  75. Obtained from FILE_AttrDef. */
  76. #ifdef NTFS_RW
  77. /* Variables used by the cluster and mft allocators. */
  78. s64 mft_data_pos; /* Mft record number at which to
  79. allocate the next mft record. */
  80. LCN mft_zone_start; /* First cluster of the mft zone. */
  81. LCN mft_zone_end; /* First cluster beyond the mft zone. */
  82. LCN mft_zone_pos; /* Current position in the mft zone. */
  83. LCN data1_zone_pos; /* Current position in the first data
  84. zone. */
  85. LCN data2_zone_pos; /* Current position in the second data
  86. zone. */
  87. #endif /* NTFS_RW */
  88. struct inode *mft_ino; /* The VFS inode of $MFT. */
  89. struct inode *mftbmp_ino; /* Attribute inode for $MFT/$BITMAP. */
  90. struct rw_semaphore mftbmp_lock; /* Lock for serializing accesses to the
  91. mft record bitmap ($MFT/$BITMAP). */
  92. #ifdef NTFS_RW
  93. struct inode *mftmirr_ino; /* The VFS inode of $MFTMirr. */
  94. int mftmirr_size; /* Size of mft mirror in mft records. */
  95. struct inode *logfile_ino; /* The VFS inode of $LogFile. */
  96. #endif /* NTFS_RW */
  97. struct inode *lcnbmp_ino; /* The VFS inode of $Bitmap. */
  98. struct rw_semaphore lcnbmp_lock; /* Lock for serializing accesses to the
  99. cluster bitmap ($Bitmap/$DATA). */
  100. struct inode *vol_ino; /* The VFS inode of $Volume. */
  101. VOLUME_FLAGS vol_flags; /* Volume flags. */
  102. u8 major_ver; /* Ntfs major version of volume. */
  103. u8 minor_ver; /* Ntfs minor version of volume. */
  104. struct inode *root_ino; /* The VFS inode of the root
  105. directory. */
  106. struct inode *secure_ino; /* The VFS inode of $Secure (NTFS3.0+
  107. only, otherwise NULL). */
  108. struct inode *extend_ino; /* The VFS inode of $Extend (NTFS3.0+
  109. only, otherwise NULL). */
  110. #ifdef NTFS_RW
  111. /* $Quota stuff is NTFS3.0+ specific. Unused/NULL otherwise. */
  112. struct inode *quota_ino; /* The VFS inode of $Quota. */
  113. struct inode *quota_q_ino; /* Attribute inode for $Quota/$Q. */
  114. /* $UsnJrnl stuff is NTFS3.0+ specific. Unused/NULL otherwise. */
  115. struct inode *usnjrnl_ino; /* The VFS inode of $UsnJrnl. */
  116. struct inode *usnjrnl_max_ino; /* Attribute inode for $UsnJrnl/$Max. */
  117. struct inode *usnjrnl_j_ino; /* Attribute inode for $UsnJrnl/$J. */
  118. #endif /* NTFS_RW */
  119. struct nls_table *nls_map;
  120. } ntfs_volume;
  121. /*
  122. * Defined bits for the flags field in the ntfs_volume structure.
  123. */
  124. typedef enum {
  125. NV_Errors, /* 1: Volume has errors, prevent remount rw. */
  126. NV_ShowSystemFiles, /* 1: Return system files in ntfs_readdir(). */
  127. NV_CaseSensitive, /* 1: Treat file names as case sensitive and
  128. create filenames in the POSIX namespace.
  129. Otherwise be case insensitive but still
  130. create file names in POSIX namespace. */
  131. NV_LogFileEmpty, /* 1: $LogFile journal is empty. */
  132. NV_QuotaOutOfDate, /* 1: $Quota is out of date. */
  133. NV_UsnJrnlStamped, /* 1: $UsnJrnl has been stamped. */
  134. NV_SparseEnabled, /* 1: May create sparse files. */
  135. } ntfs_volume_flags;
  136. /*
  137. * Macro tricks to expand the NVolFoo(), NVolSetFoo(), and NVolClearFoo()
  138. * functions.
  139. */
  140. #define DEFINE_NVOL_BIT_OPS(flag) \
  141. static inline int NVol##flag(ntfs_volume *vol) \
  142. { \
  143. return test_bit(NV_##flag, &(vol)->flags); \
  144. } \
  145. static inline void NVolSet##flag(ntfs_volume *vol) \
  146. { \
  147. set_bit(NV_##flag, &(vol)->flags); \
  148. } \
  149. static inline void NVolClear##flag(ntfs_volume *vol) \
  150. { \
  151. clear_bit(NV_##flag, &(vol)->flags); \
  152. }
  153. /* Emit the ntfs volume bitops functions. */
  154. DEFINE_NVOL_BIT_OPS(Errors)
  155. DEFINE_NVOL_BIT_OPS(ShowSystemFiles)
  156. DEFINE_NVOL_BIT_OPS(CaseSensitive)
  157. DEFINE_NVOL_BIT_OPS(LogFileEmpty)
  158. DEFINE_NVOL_BIT_OPS(QuotaOutOfDate)
  159. DEFINE_NVOL_BIT_OPS(UsnJrnlStamped)
  160. DEFINE_NVOL_BIT_OPS(SparseEnabled)
  161. #endif /* _LINUX_NTFS_VOLUME_H */