~ubuntu-branches/ubuntu/warty/linux-ntfs/warty

« back to all changes in this revision

Viewing changes to include/mft.h

  • Committer: Bazaar Package Importer
  • Author(s): David Martínez Moreno
  • Date: 2004-03-12 00:03:30 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040312000330-xv94ve7yg6bwplwu
Tags: 1.9.0-1
* New upstream release:
  - Merged Debian diff with upstream.
  - Fixed mkntfs for large volumes.
  - Add relocation support to ntfsresize. This modifies the command line
    options a little as well as the returned output so applications using
    ntfsresize might need modifications before they will work with the
    updated ntfsresize.
  - Revamped the build system completely.
  - Provide always own byteswap constant versions in order to avoid the mess
    that some architectures define only some of them (read m68k, ppc,
    mips...).
  - Made the warnings on 64 bit architectures go away.
  - Fixed lots of typos in the documentation.
  - Lots of fixes in general.
* Resolved several FTBFS (Fail To Build From Source) bugs (closes: #226989,
  #234104). With this, all the architectures go in sync again.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * $Id: mft.h,v 1.24 2001/12/15 05:13:08 antona Exp $
3
 
 *
4
 
 * mft.h - Exports for MFT record handling. Part of the Linux-NTFS project.
5
 
 *
6
 
 * Copyright (c) 2000,2001 Anton Altaparmakov.
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 MFT_H
25
 
#define MFT_H
26
 
 
27
 
#include "types.h"
28
 
#include "list.h"
29
 
#include "support.h"
30
 
 
31
 
/**
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
34
 
 *
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
38
 
 * minimum size:
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!).
46
 
 */
47
 
extern __inline__ __u32 get_mft_record_data_size(const MFT_RECORD *b);
48
 
 
49
 
/* Mft entry flag bit values */
50
 
#define ME_mapped               0
51
 
#define ME_dirty                1
52
 
#define ME_error                2
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 */
57
 
 
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)
61
 
 
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)
65
 
 
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)
69
 
 
70
 
#define MftEntryIsBaseRecord(me)        test_bit(ME_is_base_record, \
71
 
                                                                (me)->m_flags)
72
 
#define SetMftEntryIsBaseRecord(me)     set_bit(ME_is_base_record, \
73
 
                                                                (me)->m_flags)
74
 
#define ClearMftEntryIsBaseRecord(me)   clear_bit(ME_is_base_record, \
75
 
                                                                (me)->m_flags)
76
 
 
77
 
#define MftEntryAttrListPresent(me)     test_bit(ME_attr_list_present, \
78
 
                                                                (me)->m_flags)
79
 
#define SetMftEntryAttrListPresent(me)  set_bit(ME_attr_list_present, \
80
 
                                                                (me)->m_flags)
81
 
#define ClearMftEntryAttrListPresent(me) clear_bit(ME_attr_list_present, \
82
 
                                                                (me)->m_flags)
83
 
 
84
 
#define MftEntryAttrListMapped(me)      test_bit(ME_attr_list_mapped, \
85
 
                                                                (me)->m_flags)
86
 
#define SetMftEntryAttrListMapped(me)   set_bit(ME_attr_list_mapped, \
87
 
                                                                (me)->m_flags)
88
 
#define ClearMftEntryAttrListMapped(me) clear_bit(ME_attr_list_mapped, \
89
 
                                                                (me)->m_flags)
90
 
 
91
 
extern int ntfs_flush_mft_entry(mft_entry *m);
92
 
 
93
 
/* Internal use only. Use ntfs_set_mft_entry_dirty() instead. */
94
 
extern void __ntfs_set_mft_entry_dirty(mft_entry *m);
95
 
 
96
 
/**
97
 
 * ntfs_set_mft_entry_dirty - set an mft entry dirty
98
 
 * @m:          mft entry to set dirty
99
 
 *
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.
102
 
 */
103
 
static __inline__ void ntfs_set_mft_entry_dirty(mft_entry *m)
104
 
{
105
 
        if (!test_and_set_bit(ME_dirty, m->m_flags))
106
 
                __ntfs_set_mft_entry_dirty(m);
107
 
}
108
 
 
109
 
/* Internal use only. Use ntfs_map_mft_entry() instead. */
110
 
extern int __ntfs_map_mft_entry(mft_entry *m);
111
 
 
112
 
/**
113
 
 * ntfs_map_mft_entry - map an mft entry into memory
114
 
 * @m:          mft entry to map
115
 
 *
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
122
 
 * yet.
123
 
 *
124
 
 * Return 0 on success and -ERRNO on error. See __map_mft_entry() for more
125
 
 * details on the returned error codes.
126
 
 */
127
 
static __inline__ int ntfs_map_mft_entry(mft_entry *m)
128
 
{
129
 
        int err;
130
 
        
131
 
        m->m_count++;
132
 
        if (MftEntryMapped(m))
133
 
                return 0;
134
 
        if ((err = __ntfs_map_mft_entry(m)) < 0)
135
 
                m->m_count--;
136
 
        return err;
137
 
}
138
 
 
139
 
extern mft_entry *ntfs_map_file_entry(ntfs_volume *v, const MFT_REF mref);
140
 
 
141
 
/**
142
 
 * ntfs_unmap_mft_entry - unmap an mft entry
143
 
 * @m:          mft entry to unmap
144
 
 *
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.
149
 
 */
150
 
static __inline__ void ntfs_unmap_mft_entry(mft_entry *m)
151
 
{
152
 
        if (MftEntryMapped(m) && m->m_count > 1)
153
 
                m->m_count--;
154
 
}
155
 
 
156
 
/**
157
 
 * ntfs_unmap_file_entry - unmap a file mft entry
158
 
 * @m:          file mft entry to unmap
159
 
 *
160
 
 * Same as ntfs_unmap_mft_entry(), so we just wrap it.
161
 
 */
162
 
static __inline__ void ntfs_unmap_file_entry(mft_entry *m)
163
 
{
164
 
        ntfs_unmap_mft_entry(m);
165
 
}
166
 
 
167
 
extern ntfs_file *ntfs_open_by_mref(ntfs_volume *vol, const MFT_REF mref);
168
 
 
169
 
extern int ntfs_close(ntfs_file *f);
170
 
 
171
 
#endif /* defined MFT_H */
172