2
* $Id: mft.h,v 1.24 2001/12/15 05:13:08 antona Exp $
4
* mft.h - Exports for MFT record handling. Part of the Linux-NTFS project.
6
* Copyright (c) 2000,2001 Anton Altaparmakov.
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.
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.
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
32
* get_mft_record_data_size - return number of bytes used in mft record @b
33
* @b: mft record to get the data size of
35
* Takes the mft record @b and returns the number of bytes used in the record
36
* or 0 on error (i.e. b is not a valid mft record). Zero is not a valid size
37
* for an mft record as it at least has to have the MFT_RECORD, thus making the
39
* (sizeof(MFT_RECORD) + 7) & ~7 + sizeof(ATTR_TYPES) = 52 bytes
40
* Aside: The 8-byte alignment and the 4 bytes for the attribute type are needed
41
* as each mft record has to have a list of attributes even if it only contains
42
* the attribute $END which doesn't contain anything else apart from it's type.
43
* Also, you would expect every mft record to contain an update sequence array
44
* as well but that could in theory be non-existent (don't know if Windows NTFS
45
* wouldn't view this as corruption in itself though!).
47
extern __inline__ __u32 get_mft_record_data_size(const MFT_RECORD *b);
49
/* Mft entry flag bit values */
53
#define ME_is_base_record 3
54
#define ME_attr_list_present 4
55
#define ME_attr_list_mapped 5
56
/* bits 6-31 reserved for future use */
58
#define MftEntryMapped(me) test_bit(ME_mapped, (me)->m_flags)
59
#define SetMftEntryMapped(me) set_bit(ME_mapped, (me)->m_flags)
60
#define ClearMftEntryMapped(me) clear_bit(ME_mapped, (me)->m_flags)
62
#define MftEntryDirty(me) test_bit(ME_dirty, (me)->m_flags)
63
#define SetMftEntryDirty(me) set_bit(ME_dirty, (me)->m_flags)
64
#define ClearMftEntryDirty(me) clear_bit(ME_dirty, (me)->m_flags)
66
#define MftEntryError(me) test_bit(ME_error, (me)->m_flags)
67
#define SetMftEntryError(me) set_bit(ME_error, (me)->m_flags)
68
#define ClearMftEntryError(me) clear_bit(ME_error, (me)->m_flags)
70
#define MftEntryIsBaseRecord(me) test_bit(ME_is_base_record, \
72
#define SetMftEntryIsBaseRecord(me) set_bit(ME_is_base_record, \
74
#define ClearMftEntryIsBaseRecord(me) clear_bit(ME_is_base_record, \
77
#define MftEntryAttrListPresent(me) test_bit(ME_attr_list_present, \
79
#define SetMftEntryAttrListPresent(me) set_bit(ME_attr_list_present, \
81
#define ClearMftEntryAttrListPresent(me) clear_bit(ME_attr_list_present, \
84
#define MftEntryAttrListMapped(me) test_bit(ME_attr_list_mapped, \
86
#define SetMftEntryAttrListMapped(me) set_bit(ME_attr_list_mapped, \
88
#define ClearMftEntryAttrListMapped(me) clear_bit(ME_attr_list_mapped, \
91
extern int ntfs_flush_mft_entry(mft_entry *m);
93
/* Internal use only. Use ntfs_set_mft_entry_dirty() instead. */
94
extern void __ntfs_set_mft_entry_dirty(mft_entry *m);
97
* ntfs_set_mft_entry_dirty - set an mft entry dirty
98
* @m: mft entry to set dirty
100
* If the mft entry @m is not dirty it is added to the dirty_mft_entries list
101
* of the volume to which @m belongs and the dirty flag of the entry is set.
103
static __inline__ void ntfs_set_mft_entry_dirty(mft_entry *m)
105
if (!test_and_set_bit(ME_dirty, m->m_flags))
106
__ntfs_set_mft_entry_dirty(m);
109
/* Internal use only. Use ntfs_map_mft_entry() instead. */
110
extern int __ntfs_map_mft_entry(mft_entry *m);
113
* ntfs_map_mft_entry - map an mft entry into memory
114
* @m: mft entry to map
116
* Increase the use count of the entry @m and map it into memory (if it is not
117
* mapped). This function operates on an already existing mft_entry which has
118
* been inserted in a volume already. It doesn't need to be associated with a
119
* file though. Note that no setting up of the mft_entry is performed or stuff
120
* like that. If you need this kind of stuff chances are you should be using
121
* ntfs_map_file_entry() instead and your probably don't have the mft_entry
124
* Return 0 on success and -ERRNO on error. See __map_mft_entry() for more
125
* details on the returned error codes.
127
static __inline__ int ntfs_map_mft_entry(mft_entry *m)
132
if (MftEntryMapped(m))
134
if ((err = __ntfs_map_mft_entry(m)) < 0)
139
extern mft_entry *ntfs_map_file_entry(ntfs_volume *v, const MFT_REF mref);
142
* ntfs_unmap_mft_entry - unmap an mft entry
143
* @m: mft entry to unmap
145
* Decrease the use count of the mft entry (only if it is above 1). Do not
146
* actually unmap it. We always keep it cached in memory. However, when we
147
* have unmapped it and the count has reached zero, the entry can be safely
148
* unmapped if it is necessary, but that happens elsewhere.
150
static __inline__ void ntfs_unmap_mft_entry(mft_entry *m)
152
if (MftEntryMapped(m) && m->m_count > 1)
157
* ntfs_unmap_file_entry - unmap a file mft entry
158
* @m: file mft entry to unmap
160
* Same as ntfs_unmap_mft_entry(), so we just wrap it.
162
static __inline__ void ntfs_unmap_file_entry(mft_entry *m)
164
ntfs_unmap_mft_entry(m);
167
extern ntfs_file *ntfs_open_by_mref(ntfs_volume *vol, const MFT_REF mref);
169
extern int ntfs_close(ntfs_file *f);
171
#endif /* defined MFT_H */