~ubuntu-branches/ubuntu/dapper/linux-ntfs/dapper

« back to all changes in this revision

Viewing changes to include/ntfs/attrib.h

  • Committer: Bazaar Package Importer
  • Author(s): David Martínez Moreno
  • Date: 2005-11-08 20:20:23 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20051108202023-dpn4lutm8o0div8g
Tags: 1.12.1-1
* New upstream release (closes: #332930):
  - Fixed lots of memory leaks in the tools.
  - ntfsmount now uses the new API, and it has several fixes.
  - Support journals which have been modified by chkdsk.
  - New API for creating hard links, index handling, high-level creation and
    deletion of files and directories.
  - New utility ntfscmp (make extra) which compares two NTFS volumes and
    tell the differences. It's used for development, debugging, testing, etc.
  - Added robustness to several tools.
  - ntfsclone: fix saving by sectors during --rescue.
  - ntfsmount: Add 'locale' option and change interface to 'ntfsmount device
    mount_point'.
  - Fixed problem with kernel 2.4 and mkntfs.
  - Change ALL utilities to display the libntfs version they are running on.
    This should make debugging easier in the case that people are running
    mismatched utilities/library.
* This new release fixes problems with libfuse 2.4.0 (closes: #336357).
* Fixed a lot of typos in the manpages, kindly submitted by A Costa. Thanks!
  (closes: #336143, #336144, #336145, #336147, #336148).
* Fixed a couple of typos by me.
* debian/control: The SONAME of libntfs was bumped. Created new package
  (libntfs8) and removed the old one.
* debian/copyright: Updated the FSF postal address.
* Added debian/ntfsprogs.links in order to ship mkfs.ntfs and
  mount.ntfs-fuse.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * attrib.h - Exports for attribute handling. Part of the Linux-NTFS project.
3
3
 *
4
4
 * Copyright (c) 2000-2004 Anton Altaparmakov
 
5
 * Copyright (c) 2004-2005 Yura Pakhuchiy
5
6
 *
6
7
 * This program/include file is free software; you can redistribute it and/or
7
8
 * modify it under the terms of the GNU General Public License as published
27
28
typedef struct _ntfs_attr_search_ctx ntfs_attr_search_ctx;
28
29
 
29
30
#include "types.h"
 
31
#include "inode.h"
30
32
#include "unistr.h"
31
33
#include "runlist.h"
32
34
#include "volume.h"
 
35
#include "debug.h"
33
36
 
34
37
extern ntfschar AT_UNNAMED[];
35
38
 
112
115
 *              // with it and then just continue with the while loop.
113
116
 *      }
114
117
 *      if (err && errno != ENOENT)
115
 
 *              // Ooops. An error occured! You should handle this case.
 
118
 *              // Ooops. An error occurred! You should handle this case.
116
119
 *      // Now finished with all attributes in the inode.
117
120
 */
118
121
static __inline__ int ntfs_attrs_walk(ntfs_attr_search_ctx *ctx)
122
125
}
123
126
 
124
127
/**
125
 
 * ntfs_attr_state_bits - bits for the state field in the ntfs_attr structure
126
 
 */
127
 
typedef enum {
128
 
        NA_Initialized,         /* 1: structure is initialized. */
129
 
        NA_NonResident,         /* 1: Attribute is not resident. */
130
 
        NA_Compressed,          /* 1: Attribute is compressed. */
131
 
        NA_Encrypted,           /* 1: Attribute is encrypted. */
132
 
        NA_Sparse,              /* 1: Attribute is sparse. */
133
 
} ntfs_attr_state_bits;
134
 
 
135
 
#define  test_nattr_flag(na, flag)       test_bit(NA_##flag, (na)->state)
136
 
#define   set_nattr_flag(na, flag)        set_bit(NA_##flag, (na)->state)
137
 
#define clear_nattr_flag(na, flag)      clear_bit(NA_##flag, (na)->state)
138
 
 
139
 
#define NAttrInitialized(na)             test_nattr_flag(na, Initialized)
140
 
#define NAttrSetInitialized(na)           set_nattr_flag(na, Initialized)
141
 
#define NAttrClearInitialized(na)       clear_nattr_flag(na, Initialized)
142
 
 
143
 
#define NAttrNonResident(na)             test_nattr_flag(na, NonResident)
144
 
#define NAttrSetNonResident(na)           set_nattr_flag(na, NonResident)
145
 
#define NAttrClearNonResident(na)       clear_nattr_flag(na, NonResident)
146
 
 
147
 
#define NAttrCompressed(na)              test_nattr_flag(na, Compressed)
148
 
#define NAttrSetCompressed(na)            set_nattr_flag(na, Compressed)
149
 
#define NAttrClearCompressed(na)        clear_nattr_flag(na, Compressed)
150
 
 
151
 
#define NAttrEncrypted(na)               test_nattr_flag(na, Encrypted)
152
 
#define NAttrSetEncrypted(na)             set_nattr_flag(na, Encrypted)
153
 
#define NAttrClearEncrypted(na)         clear_nattr_flag(na, Encrypted)
154
 
 
155
 
#define NAttrSparse(na)                  test_nattr_flag(na, Sparse)
156
 
#define NAttrSetSparse(na)                set_nattr_flag(na, Sparse)
157
 
#define NAttrClearSparse(na)            clear_nattr_flag(na, Sparse)
158
 
 
159
 
/**
160
128
 * ntfs_attr - ntfs in memory non-resident attribute structure
161
129
 * @rl:                 if not NULL, the decompressed runlist
162
130
 * @ni:                 base ntfs inode to which this attribute belongs
163
131
 * @type:               attribute type
164
132
 * @name:               Unicode name of the attribute
165
133
 * @name_len:           length of @name in Unicode characters
166
 
 * @state:              NTFS attribute specific flags descibing this attribute
 
134
 * @state:              NTFS attribute specific flags describing this attribute
167
135
 * @allocated_size:     copy from the attribute record
168
136
 * @data_size:          copy from the attribute record
169
137
 * @initialized_size:   copy from the attribute record
186
154
 *
187
155
 * @rl is the decompressed runlist of the attribute described by this
188
156
 * structure. Obviously this only makes sense if the attribute is not resident,
189
 
 * i.e. NAttrNonResident() is true. If the runlist hasn't been decomressed yet
 
157
 * i.e. NAttrNonResident() is true. If the runlist hasn't been decompressed yet
190
158
 * @rl is NULL, so be prepared to cope with @rl == NULL.
191
159
 *
192
160
 * @ni is the base ntfs inode of the attribute described by this structure.
193
161
 *
194
162
 * @type is the attribute type (see layout.h for the definition of ATTR_TYPES),
195
163
 * @name and @name_len are the little endian Unicode name and the name length
196
 
 * in Unicode characters of the attribute, respecitvely.
 
164
 * in Unicode characters of the attribute, respectively.
197
165
 *
198
 
 * @state contains NTFS attribute specific flags descibing this attribute
 
166
 * @state contains NTFS attribute specific flags describing this attribute
199
167
 * structure. See ntfs_attr_state_bits above.
200
168
 */
201
169
struct _ntfs_attr {
214
182
        u8 compression_block_clusters;
215
183
};
216
184
 
 
185
/**
 
186
 * ntfs_attr_state_bits - bits for the state field in the ntfs_attr structure
 
187
 */
 
188
typedef enum {
 
189
        NA_Initialized,         /* 1: structure is initialized. */
 
190
        NA_NonResident,         /* 1: Attribute is not resident. */
 
191
} ntfs_attr_state_bits;
 
192
 
 
193
#define  test_nattr_flag(na, flag)       test_bit(NA_##flag, (na)->state)
 
194
#define   set_nattr_flag(na, flag)        set_bit(NA_##flag, (na)->state)
 
195
#define clear_nattr_flag(na, flag)      clear_bit(NA_##flag, (na)->state)
 
196
 
 
197
#define NAttrInitialized(na)             test_nattr_flag(na, Initialized)
 
198
#define NAttrSetInitialized(na)           set_nattr_flag(na, Initialized)
 
199
#define NAttrClearInitialized(na)       clear_nattr_flag(na, Initialized)
 
200
 
 
201
#define NAttrNonResident(na)             test_nattr_flag(na, NonResident)
 
202
#define NAttrSetNonResident(na)           set_nattr_flag(na, NonResident)
 
203
#define NAttrClearNonResident(na)       clear_nattr_flag(na, NonResident)
 
204
 
 
205
#define GenNAttrIno(flag)                                       \
 
206
static inline int NAttr##flag(ntfs_attr *na)                    \
 
207
{                                                               \
 
208
        if (na->type == AT_DATA && na->name == AT_UNNAMED)      \
 
209
                return NIno##flag(na->ni);                      \
 
210
        return 0;                                               \
 
211
}                                                               \
 
212
static inline void NAttrSet##flag(ntfs_attr *na)                \
 
213
{                                                               \
 
214
        if (na->type == AT_DATA && na->name == AT_UNNAMED)      \
 
215
                NInoSet##flag(na->ni);                          \
 
216
        else                                                    \
 
217
                Dprintf("%s(): BUG! Should be called only for " \
 
218
                        "unnamed data attribute.\n",            \
 
219
                        __FUNCTION__);                          \
 
220
}                                                               \
 
221
static inline void NAttrClear##flag(ntfs_attr *na)              \
 
222
{                                                               \
 
223
        if (na->type == AT_DATA && na->name == AT_UNNAMED)      \
 
224
                NInoClear##flag(na->ni);                        \
 
225
}
 
226
 
 
227
GenNAttrIno(Compressed)
 
228
GenNAttrIno(Encrypted)
 
229
GenNAttrIno(Sparse)
 
230
 
217
231
/*
218
232
 * Union of all known attribute values. For convenience. Used in the attr
219
233
 * structure.
237
251
        EA_ATTR ea;
238
252
        PROPERTY_SET property_set;
239
253
        LOGGED_UTILITY_STREAM logged_util_stream;
240
 
        EFS_ATTR efs;
 
254
        EFS_ATTR_HEADER efs;
241
255
} attr_val;
242
256
 
243
257
extern void ntfs_attr_init(ntfs_attr *na, const BOOL non_resident,
247
261
                const u8 compression_unit);
248
262
 
249
263
extern ntfs_attr *ntfs_attr_open(ntfs_inode *ni, const ATTR_TYPES type,
250
 
                ntfschar *name, const u32 name_len);
 
264
                ntfschar *name, u32 name_len);
251
265
extern void ntfs_attr_close(ntfs_attr *na);
252
266
 
253
267
extern s64 ntfs_attr_pread(ntfs_attr *na, const s64 pos, s64 count,
254
268
                void *b);
255
269
extern s64 ntfs_attr_pwrite(ntfs_attr *na, const s64 pos, s64 count,
256
 
                void *b);
 
270
                const void *b);
257
271
 
258
272
extern s64 ntfs_attr_mst_pread(ntfs_attr *na, const s64 pos,
259
273
                const s64 bk_cnt, const u32 bk_size, void *dst);
273
287
extern int ntfs_attr_can_be_resident(const ntfs_volume *vol,
274
288
                const ATTR_TYPES type);
275
289
 
 
290
extern int ntfs_make_room_for_attr(MFT_RECORD *m, u8 *pos, u32 size);
 
291
 
 
292
extern int ntfs_resident_attr_record_add(ntfs_inode *ni, ATTR_TYPES type,
 
293
                ntfschar *name, u8 name_len, u8 *val, u32 size,
 
294
                ATTR_FLAGS flags);
 
295
extern int ntfs_non_resident_attr_record_add(ntfs_inode *ni, ATTR_TYPES type,
 
296
                ntfschar *name, u8 name_len, VCN lowest_vcn, int dataruns_size,
 
297
                ATTR_FLAGS flags);
 
298
extern int ntfs_attr_record_rm(ntfs_attr_search_ctx *ctx);
 
299
 
 
300
extern int ntfs_attr_add(ntfs_inode *ni, ATTR_TYPES type,
 
301
                ntfschar *name, u8 name_len, u8 *val, s64 size);
 
302
extern int ntfs_attr_rm(ntfs_attr *na);
 
303
 
 
304
extern int ntfs_attr_record_resize(MFT_RECORD *m, ATTR_RECORD *a, u32 new_size);
 
305
 
276
306
extern int ntfs_resident_attr_value_resize(MFT_RECORD *m, ATTR_RECORD *a,
277
307
                const u32 newsize);
278
308
 
 
309
extern int ntfs_attr_record_move_to(ntfs_attr_search_ctx *ctx, ntfs_inode *ni);
 
310
extern int ntfs_attr_record_move_away(ntfs_attr_search_ctx *ctx, int extra);
 
311
 
 
312
extern int ntfs_attr_update_mapping_pairs(ntfs_attr *na);
 
313
 
279
314
extern int ntfs_attr_truncate(ntfs_attr *na, const s64 newsize);
280
315
 
281
316
// FIXME / TODO: Above here the file is cleaned up. (AIA)