diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /fs/ntfs/inode.h |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'fs/ntfs/inode.h')
-rw-r--r-- | fs/ntfs/inode.h | 321 |
1 files changed, 321 insertions, 0 deletions
diff --git a/fs/ntfs/inode.h b/fs/ntfs/inode.h new file mode 100644 index 000000000000..99580455f2ed --- /dev/null +++ b/fs/ntfs/inode.h | |||
@@ -0,0 +1,321 @@ | |||
1 | /* | ||
2 | * inode.h - Defines for inode structures NTFS Linux kernel driver. Part of | ||
3 | * the Linux-NTFS project. | ||
4 | * | ||
5 | * Copyright (c) 2001-2004 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 | |||
24 | #ifndef _LINUX_NTFS_INODE_H | ||
25 | #define _LINUX_NTFS_INODE_H | ||
26 | |||
27 | #include <linux/mm.h> | ||
28 | #include <linux/fs.h> | ||
29 | #include <linux/seq_file.h> | ||
30 | #include <linux/list.h> | ||
31 | #include <asm/atomic.h> | ||
32 | #include <asm/semaphore.h> | ||
33 | |||
34 | #include "layout.h" | ||
35 | #include "volume.h" | ||
36 | #include "types.h" | ||
37 | #include "runlist.h" | ||
38 | #include "debug.h" | ||
39 | |||
40 | typedef struct _ntfs_inode ntfs_inode; | ||
41 | |||
42 | /* | ||
43 | * The NTFS in-memory inode structure. It is just used as an extension to the | ||
44 | * fields already provided in the VFS inode. | ||
45 | */ | ||
46 | struct _ntfs_inode { | ||
47 | s64 initialized_size; /* Copy from the attribute record. */ | ||
48 | s64 allocated_size; /* Copy from the attribute record. */ | ||
49 | unsigned long state; /* NTFS specific flags describing this inode. | ||
50 | See ntfs_inode_state_bits below. */ | ||
51 | unsigned long mft_no; /* Number of the mft record / inode. */ | ||
52 | u16 seq_no; /* Sequence number of the mft record. */ | ||
53 | atomic_t count; /* Inode reference count for book keeping. */ | ||
54 | ntfs_volume *vol; /* Pointer to the ntfs volume of this inode. */ | ||
55 | /* | ||
56 | * If NInoAttr() is true, the below fields describe the attribute which | ||
57 | * this fake inode belongs to. The actual inode of this attribute is | ||
58 | * pointed to by base_ntfs_ino and nr_extents is always set to -1 (see | ||
59 | * below). For real inodes, we also set the type (AT_DATA for files and | ||
60 | * AT_INDEX_ALLOCATION for directories), with the name = NULL and | ||
61 | * name_len = 0 for files and name = I30 (global constant) and | ||
62 | * name_len = 4 for directories. | ||
63 | */ | ||
64 | ATTR_TYPE type; /* Attribute type of this fake inode. */ | ||
65 | ntfschar *name; /* Attribute name of this fake inode. */ | ||
66 | u32 name_len; /* Attribute name length of this fake inode. */ | ||
67 | runlist runlist; /* If state has the NI_NonResident bit set, | ||
68 | the runlist of the unnamed data attribute | ||
69 | (if a file) or of the index allocation | ||
70 | attribute (directory) or of the attribute | ||
71 | described by the fake inode (if NInoAttr()). | ||
72 | If runlist.rl is NULL, the runlist has not | ||
73 | been read in yet or has been unmapped. If | ||
74 | NI_NonResident is clear, the attribute is | ||
75 | resident (file and fake inode) or there is | ||
76 | no $I30 index allocation attribute | ||
77 | (small directory). In the latter case | ||
78 | runlist.rl is always NULL.*/ | ||
79 | /* | ||
80 | * The following fields are only valid for real inodes and extent | ||
81 | * inodes. | ||
82 | */ | ||
83 | struct semaphore mrec_lock; /* Lock for serializing access to the | ||
84 | mft record belonging to this inode. */ | ||
85 | struct page *page; /* The page containing the mft record of the | ||
86 | inode. This should only be touched by the | ||
87 | (un)map_mft_record*() functions. */ | ||
88 | int page_ofs; /* Offset into the page at which the mft record | ||
89 | begins. This should only be touched by the | ||
90 | (un)map_mft_record*() functions. */ | ||
91 | /* | ||
92 | * Attribute list support (only for use by the attribute lookup | ||
93 | * functions). Setup during read_inode for all inodes with attribute | ||
94 | * lists. Only valid if NI_AttrList is set in state, and attr_list_rl is | ||
95 | * further only valid if NI_AttrListNonResident is set. | ||
96 | */ | ||
97 | u32 attr_list_size; /* Length of attribute list value in bytes. */ | ||
98 | u8 *attr_list; /* Attribute list value itself. */ | ||
99 | runlist attr_list_rl; /* Run list for the attribute list value. */ | ||
100 | union { | ||
101 | struct { /* It is a directory, $MFT, or an index inode. */ | ||
102 | struct inode *bmp_ino; /* Attribute inode for the | ||
103 | index $BITMAP. */ | ||
104 | u32 block_size; /* Size of an index block. */ | ||
105 | u32 vcn_size; /* Size of a vcn in this | ||
106 | index. */ | ||
107 | COLLATION_RULE collation_rule; /* The collation rule | ||
108 | for the index. */ | ||
109 | u8 block_size_bits; /* Log2 of the above. */ | ||
110 | u8 vcn_size_bits; /* Log2 of the above. */ | ||
111 | } index; | ||
112 | struct { /* It is a compressed file or an attribute inode. */ | ||
113 | s64 size; /* Copy of compressed_size from | ||
114 | $DATA. */ | ||
115 | u32 block_size; /* Size of a compression block | ||
116 | (cb). */ | ||
117 | u8 block_size_bits; /* Log2 of the size of a cb. */ | ||
118 | u8 block_clusters; /* Number of clusters per cb. */ | ||
119 | } compressed; | ||
120 | } itype; | ||
121 | struct semaphore extent_lock; /* Lock for accessing/modifying the | ||
122 | below . */ | ||
123 | s32 nr_extents; /* For a base mft record, the number of attached extent | ||
124 | inodes (0 if none), for extent records and for fake | ||
125 | inodes describing an attribute this is -1. */ | ||
126 | union { /* This union is only used if nr_extents != 0. */ | ||
127 | ntfs_inode **extent_ntfs_inos; /* For nr_extents > 0, array of | ||
128 | the ntfs inodes of the extent | ||
129 | mft records belonging to | ||
130 | this base inode which have | ||
131 | been loaded. */ | ||
132 | ntfs_inode *base_ntfs_ino; /* For nr_extents == -1, the | ||
133 | ntfs inode of the base mft | ||
134 | record. For fake inodes, the | ||
135 | real (base) inode to which | ||
136 | the attribute belongs. */ | ||
137 | } ext; | ||
138 | }; | ||
139 | |||
140 | /* | ||
141 | * Defined bits for the state field in the ntfs_inode structure. | ||
142 | * (f) = files only, (d) = directories only, (a) = attributes/fake inodes only | ||
143 | */ | ||
144 | typedef enum { | ||
145 | NI_Dirty, /* 1: Mft record needs to be written to disk. */ | ||
146 | NI_AttrList, /* 1: Mft record contains an attribute list. */ | ||
147 | NI_AttrListNonResident, /* 1: Attribute list is non-resident. Implies | ||
148 | NI_AttrList is set. */ | ||
149 | |||
150 | NI_Attr, /* 1: Fake inode for attribute i/o. | ||
151 | 0: Real inode or extent inode. */ | ||
152 | |||
153 | NI_MstProtected, /* 1: Attribute is protected by MST fixups. | ||
154 | 0: Attribute is not protected by fixups. */ | ||
155 | NI_NonResident, /* 1: Unnamed data attr is non-resident (f). | ||
156 | 1: Attribute is non-resident (a). */ | ||
157 | NI_IndexAllocPresent = NI_NonResident, /* 1: $I30 index alloc attr is | ||
158 | present (d). */ | ||
159 | NI_Compressed, /* 1: Unnamed data attr is compressed (f). | ||
160 | 1: Create compressed files by default (d). | ||
161 | 1: Attribute is compressed (a). */ | ||
162 | NI_Encrypted, /* 1: Unnamed data attr is encrypted (f). | ||
163 | 1: Create encrypted files by default (d). | ||
164 | 1: Attribute is encrypted (a). */ | ||
165 | NI_Sparse, /* 1: Unnamed data attr is sparse (f). | ||
166 | 1: Create sparse files by default (d). | ||
167 | 1: Attribute is sparse (a). */ | ||
168 | NI_TruncateFailed, /* 1: Last ntfs_truncate() call failed. */ | ||
169 | } ntfs_inode_state_bits; | ||
170 | |||
171 | /* | ||
172 | * NOTE: We should be adding dirty mft records to a list somewhere and they | ||
173 | * should be independent of the (ntfs/vfs) inode structure so that an inode can | ||
174 | * be removed but the record can be left dirty for syncing later. | ||
175 | */ | ||
176 | |||
177 | /* | ||
178 | * Macro tricks to expand the NInoFoo(), NInoSetFoo(), and NInoClearFoo() | ||
179 | * functions. | ||
180 | */ | ||
181 | #define NINO_FNS(flag) \ | ||
182 | static inline int NIno##flag(ntfs_inode *ni) \ | ||
183 | { \ | ||
184 | return test_bit(NI_##flag, &(ni)->state); \ | ||
185 | } \ | ||
186 | static inline void NInoSet##flag(ntfs_inode *ni) \ | ||
187 | { \ | ||
188 | set_bit(NI_##flag, &(ni)->state); \ | ||
189 | } \ | ||
190 | static inline void NInoClear##flag(ntfs_inode *ni) \ | ||
191 | { \ | ||
192 | clear_bit(NI_##flag, &(ni)->state); \ | ||
193 | } | ||
194 | |||
195 | /* | ||
196 | * As above for NInoTestSetFoo() and NInoTestClearFoo(). | ||
197 | */ | ||
198 | #define TAS_NINO_FNS(flag) \ | ||
199 | static inline int NInoTestSet##flag(ntfs_inode *ni) \ | ||
200 | { \ | ||
201 | return test_and_set_bit(NI_##flag, &(ni)->state); \ | ||
202 | } \ | ||
203 | static inline int NInoTestClear##flag(ntfs_inode *ni) \ | ||
204 | { \ | ||
205 | return test_and_clear_bit(NI_##flag, &(ni)->state); \ | ||
206 | } | ||
207 | |||
208 | /* Emit the ntfs inode bitops functions. */ | ||
209 | NINO_FNS(Dirty) | ||
210 | TAS_NINO_FNS(Dirty) | ||
211 | NINO_FNS(AttrList) | ||
212 | NINO_FNS(AttrListNonResident) | ||
213 | NINO_FNS(Attr) | ||
214 | NINO_FNS(MstProtected) | ||
215 | NINO_FNS(NonResident) | ||
216 | NINO_FNS(IndexAllocPresent) | ||
217 | NINO_FNS(Compressed) | ||
218 | NINO_FNS(Encrypted) | ||
219 | NINO_FNS(Sparse) | ||
220 | NINO_FNS(TruncateFailed) | ||
221 | |||
222 | /* | ||
223 | * The full structure containing a ntfs_inode and a vfs struct inode. Used for | ||
224 | * all real and fake inodes but not for extent inodes which lack the vfs struct | ||
225 | * inode. | ||
226 | */ | ||
227 | typedef struct { | ||
228 | ntfs_inode ntfs_inode; | ||
229 | struct inode vfs_inode; /* The vfs inode structure. */ | ||
230 | } big_ntfs_inode; | ||
231 | |||
232 | /** | ||
233 | * NTFS_I - return the ntfs inode given a vfs inode | ||
234 | * @inode: VFS inode | ||
235 | * | ||
236 | * NTFS_I() returns the ntfs inode associated with the VFS @inode. | ||
237 | */ | ||
238 | static inline ntfs_inode *NTFS_I(struct inode *inode) | ||
239 | { | ||
240 | return (ntfs_inode *)list_entry(inode, big_ntfs_inode, vfs_inode); | ||
241 | } | ||
242 | |||
243 | static inline struct inode *VFS_I(ntfs_inode *ni) | ||
244 | { | ||
245 | return &((big_ntfs_inode *)ni)->vfs_inode; | ||
246 | } | ||
247 | |||
248 | /** | ||
249 | * ntfs_attr - ntfs in memory attribute structure | ||
250 | * @mft_no: mft record number of the base mft record of this attribute | ||
251 | * @name: Unicode name of the attribute (NULL if unnamed) | ||
252 | * @name_len: length of @name in Unicode characters (0 if unnamed) | ||
253 | * @type: attribute type (see layout.h) | ||
254 | * | ||
255 | * This structure exists only to provide a small structure for the | ||
256 | * ntfs_{attr_}iget()/ntfs_test_inode()/ntfs_init_locked_inode() mechanism. | ||
257 | * | ||
258 | * NOTE: Elements are ordered by size to make the structure as compact as | ||
259 | * possible on all architectures. | ||
260 | */ | ||
261 | typedef struct { | ||
262 | unsigned long mft_no; | ||
263 | ntfschar *name; | ||
264 | u32 name_len; | ||
265 | ATTR_TYPE type; | ||
266 | } ntfs_attr; | ||
267 | |||
268 | typedef int (*test_t)(struct inode *, void *); | ||
269 | |||
270 | extern int ntfs_test_inode(struct inode *vi, ntfs_attr *na); | ||
271 | |||
272 | extern struct inode *ntfs_iget(struct super_block *sb, unsigned long mft_no); | ||
273 | extern struct inode *ntfs_attr_iget(struct inode *base_vi, ATTR_TYPE type, | ||
274 | ntfschar *name, u32 name_len); | ||
275 | extern struct inode *ntfs_index_iget(struct inode *base_vi, ntfschar *name, | ||
276 | u32 name_len); | ||
277 | |||
278 | extern struct inode *ntfs_alloc_big_inode(struct super_block *sb); | ||
279 | extern void ntfs_destroy_big_inode(struct inode *inode); | ||
280 | extern void ntfs_clear_big_inode(struct inode *vi); | ||
281 | |||
282 | extern void __ntfs_init_inode(struct super_block *sb, ntfs_inode *ni); | ||
283 | |||
284 | static inline void ntfs_init_big_inode(struct inode *vi) | ||
285 | { | ||
286 | ntfs_inode *ni = NTFS_I(vi); | ||
287 | |||
288 | ntfs_debug("Entering."); | ||
289 | __ntfs_init_inode(vi->i_sb, ni); | ||
290 | ni->mft_no = vi->i_ino; | ||
291 | } | ||
292 | |||
293 | extern ntfs_inode *ntfs_new_extent_inode(struct super_block *sb, | ||
294 | unsigned long mft_no); | ||
295 | extern void ntfs_clear_extent_inode(ntfs_inode *ni); | ||
296 | |||
297 | extern int ntfs_read_inode_mount(struct inode *vi); | ||
298 | |||
299 | extern void ntfs_put_inode(struct inode *vi); | ||
300 | |||
301 | extern int ntfs_show_options(struct seq_file *sf, struct vfsmount *mnt); | ||
302 | |||
303 | #ifdef NTFS_RW | ||
304 | |||
305 | extern int ntfs_truncate(struct inode *vi); | ||
306 | extern void ntfs_truncate_vfs(struct inode *vi); | ||
307 | |||
308 | extern int ntfs_setattr(struct dentry *dentry, struct iattr *attr); | ||
309 | |||
310 | extern int ntfs_write_inode(struct inode *vi, int sync); | ||
311 | |||
312 | static inline void ntfs_commit_inode(struct inode *vi) | ||
313 | { | ||
314 | if (!is_bad_inode(vi)) | ||
315 | ntfs_write_inode(vi, 1); | ||
316 | return; | ||
317 | } | ||
318 | |||
319 | #endif /* NTFS_RW */ | ||
320 | |||
321 | #endif /* _LINUX_NTFS_INODE_H */ | ||