volume.h 6.1 KB

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