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