112
115
* // with it and then just continue with the while loop.
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.
118
121
static __inline__ int ntfs_attrs_walk(ntfs_attr_search_ctx *ctx)
125
* ntfs_attr_state_bits - bits for the state field in the ntfs_attr structure
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;
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)
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)
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)
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)
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)
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)
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
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.
192
160
* @ni is the base ntfs inode of the attribute described by this structure.
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.
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.
201
169
struct _ntfs_attr {
214
182
u8 compression_block_clusters;
186
* ntfs_attr_state_bits - bits for the state field in the ntfs_attr structure
189
NA_Initialized, /* 1: structure is initialized. */
190
NA_NonResident, /* 1: Attribute is not resident. */
191
} ntfs_attr_state_bits;
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)
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)
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)
205
#define GenNAttrIno(flag) \
206
static inline int NAttr##flag(ntfs_attr *na) \
208
if (na->type == AT_DATA && na->name == AT_UNNAMED) \
209
return NIno##flag(na->ni); \
212
static inline void NAttrSet##flag(ntfs_attr *na) \
214
if (na->type == AT_DATA && na->name == AT_UNNAMED) \
215
NInoSet##flag(na->ni); \
217
Dprintf("%s(): BUG! Should be called only for " \
218
"unnamed data attribute.\n", \
221
static inline void NAttrClear##flag(ntfs_attr *na) \
223
if (na->type == AT_DATA && na->name == AT_UNNAMED) \
224
NInoClear##flag(na->ni); \
227
GenNAttrIno(Compressed)
228
GenNAttrIno(Encrypted)
218
232
* Union of all known attribute values. For convenience. Used in the attr
247
261
const u8 compression_unit);
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);
253
267
extern s64 ntfs_attr_pread(ntfs_attr *na, const s64 pos, s64 count,
255
269
extern s64 ntfs_attr_pwrite(ntfs_attr *na, const s64 pos, s64 count,
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);
290
extern int ntfs_make_room_for_attr(MFT_RECORD *m, u8 *pos, u32 size);
292
extern int ntfs_resident_attr_record_add(ntfs_inode *ni, ATTR_TYPES type,
293
ntfschar *name, u8 name_len, u8 *val, u32 size,
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,
298
extern int ntfs_attr_record_rm(ntfs_attr_search_ctx *ctx);
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);
304
extern int ntfs_attr_record_resize(MFT_RECORD *m, ATTR_RECORD *a, u32 new_size);
276
306
extern int ntfs_resident_attr_value_resize(MFT_RECORD *m, ATTR_RECORD *a,
277
307
const u32 newsize);
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);
312
extern int ntfs_attr_update_mapping_pairs(ntfs_attr *na);
279
314
extern int ntfs_attr_truncate(ntfs_attr *na, const s64 newsize);
281
316
// FIXME / TODO: Above here the file is cleaned up. (AIA)