2 * inode.h - Defines for NTFS inode handling. Part of the Linux-NTFS project.
4 * Copyright (c) 2001,2002 Anton Altaparmakov
6 * This program/include file is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as published
8 * by the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program/include file is distributed in the hope that it will be
12 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program (in the main directory of the Linux-NTFS
18 * distribution in the file COPYING); if not, write to the Free Software
19 * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 /* Forward declaration */
26 typedef struct _ntfs_inode ntfs_inode;
33 * Defined bits for the state field in the ntfs_inode structure.
34 * (f) = files only, (d) = directories only
37 NI_Dirty, /* 1: Mft record needs to be written to disk. */
39 /* The NI_AttrList* tests only make sense for base inodes. */
40 NI_AttrList, /* 1: Mft record contains an attribute list. */
41 NI_AttrListNonResident, /* 1: Attribute list is non-resident. Implies
42 NI_AttrList is set. */
43 NI_AttrListDirty, /* 1: Attribute list needs to be written to the
44 mft record and then to disk. */
45 } ntfs_inode_state_bits;
47 #define test_nino_flag(ni, flag) test_bit(NI_##flag, (ni)->state)
48 #define set_nino_flag(ni, flag) set_bit(NI_##flag, (ni)->state)
49 #define clear_nino_flag(ni, flag) clear_bit(NI_##flag, (ni)->state)
51 #define test_and_set_nino_flag(ni, flag) \
52 test_and_set_bit(NI_##flag, (ni)->state)
53 #define test_and_clear_nino_flag(ni, flag) \
54 test_and_clear_bit(NI_##flag, (ni)->state)
56 #define NInoDirty(ni) test_nino_flag(ni, Dirty)
57 #define NInoSetDirty(ni) set_nino_flag(ni, Dirty)
58 #define NInoClearDirty(ni) clear_nino_flag(ni, Dirty)
59 #define NInoTestAndSetDirty(ni) test_and_set_nino_flag(ni, Dirty)
60 #define NInoTestAndClearDirty(ni) test_and_clear_nino_flag(ni, Dirty)
62 #define NInoAttrList(ni) test_nino_flag(ni, AttrList)
63 #define NInoSetAttrList(ni) set_nino_flag(ni, AttrList)
64 #define NInoClearAttrList(ni) clear_nino_flag(ni, AttrList)
67 #define test_nino_al_flag(ni, flag) test_nino_flag(ni, AttrList##flag)
68 #define set_nino_al_flag(ni, flag) set_nino_flag(ni, AttrList##flag)
69 #define clear_nino_al_flag(ni, flag) clear_nino_flag(ni, AttrList##flag)
71 #define NInoAttrListNonResident(ni) test_nino_al_flag(ni, NonResident)
72 #define NInoSetAttrListNonResident(ni) set_nino_al_flag(ni, NonResident)
73 #define NInoClearAttrListNonResident(ni) clear_nino_al_flag(ni, NonResident)
75 #define NInoAttrListDirty(ni) test_nino_al_flag(ni, Dirty)
76 #define NInoAttrListSetDirty(ni) set_nino_al_flag(ni, Dirty)
77 #define NInoAttrListClearDirty(ni) clear_nino_al_flag(ni, Dirty)
80 * The NTFS in-memory inode structure. It is just used as an extension to the
81 * fields already provided in the VFS inode.
84 u64 mft_no; /* Inode / mft record number. */
85 MFT_RECORD *mrec; /* The actual mft record of the inode. */
86 ntfs_volume *vol; /* Pointer to the ntfs volume of this inode. */
87 unsigned long state; /* NTFS specific flags describing this inode.
88 See ntfs_inode_state_bits above. */
90 * Attribute list support (for use by the attribute lookup functions).
91 * Setup during ntfs_open_inode() for all inodes with attribute lists.
92 * Only valid if NI_AttrList is set in state, further attr_list_rl is
93 * only valid if NI_AttrListNonResident is set.
95 u32 attr_list_size; /* Length of attribute list value in bytes. */
96 u8 *attr_list; /* Attribute list value itself. */
97 runlist *attr_list_rl; /* Run list for the attribute list value. */
98 /* Below fields are always valid. */
99 s32 nr_extents; /* For a base mft record, the number of
100 attached extent inodes (0 if none), for
101 extent records this is -1. */
102 union { /* This union is only used if nr_extents != 0. */
103 ntfs_inode **extent_nis;/* For nr_extents > 0, array of the
104 ntfs inodes of the extent mft
105 records belonging to this base
106 inode which have been loaded. */
107 ntfs_inode *base_ni; /* For nr_extents == -1, the ntfs
108 inode of the base mft record. */
112 extern ntfs_inode *ntfs_inode_open(ntfs_volume *vol, const MFT_REF mref);
114 extern int ntfs_inode_close(ntfs_inode *ni);
116 extern ntfs_inode *ntfs_extent_inode_open(ntfs_inode *base_ni,
120 * ntfs_inode_mark_dirty - set the inode (and its base inode if it exists) dirty
121 * @ni: ntfs inode to set dirty
123 * Set the inode @ni dirty so it is written out later (at the latest at
124 * ntfs_inode_close() time). If @ni is an extent inode, set the base inode
127 * This function cannot fail.
129 static __inline__ void ntfs_inode_mark_dirty(ntfs_inode *ni) {
131 if (ni->nr_extents == -1)
132 NInoSetDirty(ni->base_ni);
135 extern int ntfs_inode_sync(ntfs_inode *ni);
137 #endif /* defined _NTFS_INODE_H */