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