Replace all le32 usage of the '==' operation with "le32_eq(...)".

edge.strict_endians
Erik Larsson 2016-01-28 08:28:26 +01:00
parent 59a05b5c34
commit 011a9e9e5e
18 changed files with 133 additions and 131 deletions

View File

@ -298,4 +298,6 @@
#define le16_eq(a, b) ((a) == (b))
#define le32_eq(a, b) ((a) == (b))
#endif /* defined _NTFS_ENDIANS_H */

View File

@ -244,27 +244,27 @@ static int is_world_sid(const SID * usid)
((usid->sub_authority_count == 1)
&& (usid->identifier_authority.high_part == const_cpu_to_be16(0))
&& (usid->identifier_authority.low_part == const_cpu_to_be32(1))
&& (usid->sub_authority[0] == const_cpu_to_le32(0)))
&& le32_eq(usid->sub_authority[0], const_cpu_to_le32(0)))
/* check whether S-1-5-32-545 : local user */
|| ((usid->sub_authority_count == 2)
&& (usid->identifier_authority.high_part == const_cpu_to_be16(0))
&& (usid->identifier_authority.low_part == const_cpu_to_be32(5))
&& (usid->sub_authority[0] == const_cpu_to_le32(32))
&& (usid->sub_authority[1] == const_cpu_to_le32(545)))
&& le32_eq(usid->sub_authority[0], const_cpu_to_le32(32))
&& le32_eq(usid->sub_authority[1], const_cpu_to_le32(545)))
/* check whether S-1-5-11 : authenticated user */
|| ((usid->sub_authority_count == 1)
&& (usid->identifier_authority.high_part == const_cpu_to_be16(0))
&& (usid->identifier_authority.low_part == const_cpu_to_be32(5))
&& (usid->sub_authority[0] == const_cpu_to_le32(11)))
&& le32_eq(usid->sub_authority[0], const_cpu_to_le32(11)))
#if !POSIXACLS
/* check whether S-1-5-4 : interactive user */
|| ((usid->sub_authority_count == 1)
&& (usid->identifier_authority.high_part == const_cpu_to_be16(0))
&& (usid->identifier_authority.low_part == const_cpu_to_be32(5))
&& (usid->sub_authority[0] == const_cpu_to_le32(4)))
&& le32_eq(usid->sub_authority[0], const_cpu_to_le32(4)))
#endif /* !POSIXACLS */
);
}
@ -280,7 +280,7 @@ BOOL ntfs_is_user_sid(const SID *usid)
return ((usid->sub_authority_count == 5)
&& (usid->identifier_authority.high_part == const_cpu_to_be16(0))
&& (usid->identifier_authority.low_part == const_cpu_to_be32(5))
&& (usid->sub_authority[0] == const_cpu_to_le32(21)));
&& le32_eq(usid->sub_authority[0], const_cpu_to_le32(21)));
}
/*

View File

@ -85,14 +85,14 @@ ntfschar TXF_DATA[] = { const_cpu_to_le16('$'),
static int NAttrFlag(ntfs_attr *na, FILE_ATTR_FLAGS flag)
{
if (na->type == AT_DATA && na->name == AT_UNNAMED)
if (le32_eq(na->type, AT_DATA) && na->name == AT_UNNAMED)
return (na->ni->flags & flag);
return 0;
}
static void NAttrSetFlag(ntfs_attr *na, FILE_ATTR_FLAGS flag)
{
if (na->type == AT_DATA && na->name == AT_UNNAMED)
if (le32_eq(na->type, AT_DATA) && na->name == AT_UNNAMED)
na->ni->flags |= flag;
else
ntfs_log_trace("Denied setting flag %d for not unnamed data "
@ -101,7 +101,7 @@ static void NAttrSetFlag(ntfs_attr *na, FILE_ATTR_FLAGS flag)
static void NAttrClearFlag(ntfs_attr *na, FILE_ATTR_FLAGS flag)
{
if (na->type == AT_DATA && na->name == AT_UNNAMED)
if (le32_eq(na->type, AT_DATA) && na->name == AT_UNNAMED)
na->ni->flags &= ~flag;
}
@ -451,10 +451,10 @@ ntfs_attr *ntfs_attr_open(ntfs_inode *ni, const ATTR_TYPES type,
* attribute. Windows does not complain about invalid flags and chkdsk
* does not detect or fix them so we need to cope with it, too.
*/
if (type == AT_ATTRIBUTE_LIST)
if (le32_eq(type, AT_ATTRIBUTE_LIST))
a->flags = 0;
if ((type == AT_DATA)
if (le32_eq(type, AT_DATA)
&& (a->non_resident ? !a->initialized_size : !a->value_length)) {
/*
* Define/redefine the compression state if stream is
@ -478,7 +478,7 @@ ntfs_attr *ntfs_attr_open(ntfs_inode *ni, const ATTR_TYPES type,
cs = a->flags & (ATTR_IS_COMPRESSED | ATTR_IS_SPARSE);
/* a file may be sparse though its unnamed data is not (cf $UsnJrnl) */
if (na->type == AT_DATA && na->name == AT_UNNAMED &&
if (le32_eq(na->type, AT_DATA) && na->name == AT_UNNAMED &&
(((a->flags & ATTR_IS_SPARSE) && !NAttrSparse(na)) ||
(!(a->flags & ATTR_IS_ENCRYPTED) != !NAttrEncrypted(na)))) {
errno = EIO;
@ -1827,7 +1827,7 @@ s64 ntfs_attr_pwrite(ntfs_attr *na, const s64 pos, s64 count, const void *b)
* file. This will make recursive calls
*/
if (compressed
&& (na->type == AT_DATA)
&& le32_eq(na->type, AT_DATA)
&& (pos > na->initialized_size)
&& stuff_hole(na,pos))
goto errno_set;
@ -1852,7 +1852,7 @@ s64 ntfs_attr_pwrite(ntfs_attr *na, const s64 pos, s64 count, const void *b)
/* If the write reaches beyond the end, extend the attribute. */
old_data_size = na->data_size;
/* identify whether this is appending to a non resident data attribute */
if ((na->type == AT_DATA) && (pos >= old_data_size)
if (le32_eq(na->type, AT_DATA) && (pos >= old_data_size)
&& NAttrNonResident(na))
NAttrSetDataAppending(na);
if (pos + count > na->data_size) {
@ -2024,8 +2024,8 @@ s64 ntfs_attr_pwrite(ntfs_attr *na, const s64 pos, s64 count, const void *b)
na->initialized_size = pos + count;
#if CACHE_NIDATA_SIZE
if (na->ni->mrec->flags & MFT_RECORD_IS_DIRECTORY
? na->type == AT_INDEX_ROOT && na->name == NTFS_INDEX_I30
: na->type == AT_DATA && na->name == AT_UNNAMED) {
? le32_eq(na->type, AT_INDEX_ROOT) && na->name == NTFS_INDEX_I30
: le32_eq(na->type, AT_DATA) && na->name == AT_UNNAMED) {
na->ni->data_size = na->data_size;
if ((compressed || NAttrSparse(na))
&& NAttrNonResident(na))
@ -2480,8 +2480,8 @@ retry:
failed = ntfs_compressed_close(na, rl, ofs, &update_from);
#if CACHE_NIDATA_SIZE
if (na->ni->mrec->flags & MFT_RECORD_IS_DIRECTORY
? na->type == AT_INDEX_ROOT && na->name == NTFS_INDEX_I30
: na->type == AT_DATA && na->name == AT_UNNAMED) {
? le32_eq(na->type, AT_INDEX_ROOT) && na->name == NTFS_INDEX_I30
: le32_eq(na->type, AT_DATA) && na->name == AT_UNNAMED) {
na->ni->data_size = na->data_size;
na->ni->allocated_size = na->compressed_size;
set_nino_flag(na->ni,KnownSize);
@ -2775,14 +2775,14 @@ static int ntfs_attr_find(const ATTR_TYPES type, const ntfschar *name,
ctx->attr = a;
if (((type != AT_UNUSED) && (le32_to_cpu(a->type) >
le32_to_cpu(type))) ||
(a->type == AT_END)) {
le32_eq(a->type, AT_END)) {
errno = ENOENT;
return -1;
}
if (!a->length)
break;
/* If this is an enumeration return this attribute. */
if (type == AT_UNUSED)
if (le32_eq(type, AT_UNUSED))
return 0;
if (a->type != type)
continue;
@ -2975,7 +2975,7 @@ static int ntfs_external_attr_find(ATTR_TYPES type, const ntfschar *name,
}
if (ni == base_ni)
ctx->base_attr = ctx->attr;
if (type == AT_END)
if (le32_eq(type, AT_END))
goto not_found;
vol = base_ni->vol;
al_start = base_ni->attr_list;
@ -2996,7 +2996,7 @@ static int ntfs_external_attr_find(ATTR_TYPES type, const ntfschar *name,
* the attribute list itself, need to return the attribute list
* attribute.
*/
if ((type == AT_UNUSED) && is_first_search &&
if (le32_eq(type, AT_UNUSED) && is_first_search &&
le32_to_cpu(al_entry->type) >
le32_to_cpu(AT_ATTRIBUTE_LIST))
goto find_attr_list_attr;
@ -3009,7 +3009,7 @@ static int ntfs_external_attr_find(ATTR_TYPES type, const ntfschar *name,
* attribute list attribute from the base mft record as it is
* not listed in the attribute list itself.
*/
if ((type == AT_UNUSED) && le32_to_cpu(ctx->al_entry->type) <
if (le32_eq(type, AT_UNUSED) && le32_to_cpu(ctx->al_entry->type) <
le32_to_cpu(AT_ATTRIBUTE_LIST) &&
le32_to_cpu(al_entry->type) >
le32_to_cpu(AT_ATTRIBUTE_LIST)) {
@ -3084,7 +3084,7 @@ find_attr_list_attr:
* If !@type we want the attribute represented by this
* attribute list entry.
*/
if (type == AT_UNUSED)
if (le32_eq(type, AT_UNUSED))
goto is_enumeration;
/*
* If @name is AT_UNNAMED we want an unnamed attribute.
@ -3123,7 +3123,7 @@ find_attr_list_attr:
next_al_entry->length) <= al_end &&
sle64_to_cpu(next_al_entry->lowest_vcn) <=
lowest_vcn &&
next_al_entry->type == al_entry->type &&
le32_eq(next_al_entry->type, al_entry->type) &&
next_al_entry->name_length == al_name_len &&
ntfs_names_are_equal((ntfschar*)((char*)
next_al_entry +
@ -3180,7 +3180,7 @@ do_next_attr_loop:
if ((char*)a < (char*)ctx->mrec || (char*)a > (char*)ctx->mrec +
le32_to_cpu(ctx->mrec->bytes_allocated))
break;
if (a->type == AT_END)
if (le32_eq(a->type, AT_END))
continue;
if (!a->length)
break;
@ -3205,7 +3205,7 @@ do_next_attr_loop:
* have found it! Also, if !@type, it is an enumeration, so we
* want the current attribute.
*/
if ((type == AT_UNUSED) || !val || (!a->non_resident &&
if (le32_eq(type, AT_UNUSED) || !val || (!a->non_resident &&
le32_to_cpu(a->value_length) == val_len &&
!memcmp((char*)a + le16_to_cpu(a->value_offset),
val, val_len))) {
@ -3230,7 +3230,7 @@ not_found:
* end, we reset the search context @ctx and use ntfs_attr_find() to
* seek to the end of the base mft record.
*/
if (type == AT_UNUSED || type == AT_END) {
if (le32_eq(type, AT_UNUSED) || le32_eq(type, AT_END)) {
ntfs_attr_reinit_search_ctx(ctx);
return ntfs_attr_find(AT_END, name, name_len, ic, val, val_len,
ctx);
@ -3364,7 +3364,7 @@ int ntfs_attr_lookup(const ATTR_TYPES type, const ntfschar *name,
base_ni = ctx->base_ntfs_ino;
else
base_ni = ctx->ntfs_ino;
if (!base_ni || !NInoAttrList(base_ni) || type == AT_ATTRIBUTE_LIST)
if (!base_ni || !NInoAttrList(base_ni) || le32_eq(type, AT_ATTRIBUTE_LIST))
ret = ntfs_attr_find(type, name, name_len, ic, val, val_len, ctx);
else
ret = ntfs_external_attr_find(type, name, name_len, ic,
@ -3396,7 +3396,7 @@ int ntfs_attr_position(const ATTR_TYPES type, ntfs_attr_search_ctx *ctx)
if (ntfs_attr_lookup(type, NULL, 0, CASE_SENSITIVE, 0, NULL, 0, ctx)) {
if (errno != ENOENT)
return -1;
if (ctx->attr->type == AT_END) {
if (le32_eq(ctx->attr->type, AT_END)) {
errno = ENOSPC;
return -1;
}
@ -3527,7 +3527,7 @@ ATTR_DEF *ntfs_attr_find_in_attrdef(const ntfs_volume *vol,
if (le32_to_cpu(ad->type) < le32_to_cpu(type))
continue;
/* We found the attribute; return it. */
if (ad->type == type)
if (le32_eq(ad->type, type))
return ad;
/* We have gone too far already. No point in continuing. */
break;
@ -3569,7 +3569,7 @@ int ntfs_attr_size_bounds_check(const ntfs_volume *vol, const ATTR_TYPES type,
* $ATTRIBUTE_LIST shouldn't be greater than 0x40000, otherwise
* Windows would crash. This is not listed in the AttrDef.
*/
if (type == AT_ATTRIBUTE_LIST && size > 0x40000) {
if (le32_eq(type, AT_ATTRIBUTE_LIST) && size > 0x40000) {
errno = ERANGE;
ntfs_log_perror("Too large attrlist (%lld)", (long long)size);
return -1;
@ -3587,7 +3587,7 @@ int ntfs_attr_size_bounds_check(const ntfs_volume *vol, const ATTR_TYPES type,
* clearing the volume name. If we want to be able to clear the volume
* name we must also accept 0 as min_size, despite the $AttrDef
* definition. */
if(type == AT_VOLUME_NAME)
if(le32_eq(type, AT_VOLUME_NAME))
min_size = 0;
if ((min_size && (size < min_size)) ||
@ -3634,7 +3634,7 @@ static int ntfs_attr_can_be_non_resident(const ntfs_volume *vol, const ATTR_TYPE
* causes Windows Vista and later to see the volume as a RAW volume and
* thus cannot mount it at all.
*/
if ((type == AT_LOGGED_UTILITY_STREAM)
if (le32_eq(type, AT_LOGGED_UTILITY_STREAM)
&& name
&& ntfs_names_are_equal(TXF_DATA, 9, name, name_len,
CASE_SENSITIVE, vol->upcase, vol->upcase_len))
@ -3838,7 +3838,7 @@ int ntfs_resident_attr_record_add(ntfs_inode *ni, ATTR_TYPES type,
memcpy((u8*)a + le16_to_cpu(a->value_offset), val, size);
else
memset((u8*)a + le16_to_cpu(a->value_offset), 0, size);
if (type == AT_FILE_NAME)
if (le32_eq(type, AT_FILE_NAME))
a->resident_flags = RESIDENT_ATTR_IS_INDEXED;
else
a->resident_flags = 0;
@ -3861,8 +3861,8 @@ int ntfs_resident_attr_record_add(ntfs_inode *ni, ATTR_TYPES type,
}
}
if (ni->mrec->flags & MFT_RECORD_IS_DIRECTORY
? type == AT_INDEX_ROOT && name == NTFS_INDEX_I30
: type == AT_DATA && name == AT_UNNAMED) {
? le32_eq(type, AT_INDEX_ROOT) && name == NTFS_INDEX_I30
: le32_eq(type, AT_DATA) && name == AT_UNNAMED) {
ni->data_size = size;
ni->allocated_size = (size + 7) & ~7;
set_nino_flag(ni,KnownSize);
@ -4079,7 +4079,7 @@ int ntfs_attr_record_rm(ntfs_attr_search_ctx *ctx)
}
/* Post $ATTRIBUTE_LIST delete setup. */
if (type == AT_ATTRIBUTE_LIST) {
if (le32_eq(type, AT_ATTRIBUTE_LIST)) {
if (NInoAttrList(base_ni) && base_ni->attr_list)
free(base_ni->attr_list);
base_ni->attr_list = NULL;
@ -4101,7 +4101,7 @@ int ntfs_attr_record_rm(ntfs_attr_search_ctx *ctx)
return 0;
}
if (type == AT_ATTRIBUTE_LIST || !NInoAttrList(base_ni))
if (le32_eq(type, AT_ATTRIBUTE_LIST) || !NInoAttrList(base_ni))
return 0;
/* Remove attribute list if we don't need it any more. */
@ -4188,7 +4188,7 @@ int ntfs_attr_add(ntfs_inode *ni, ATTR_TYPES type,
ntfs_attr *na;
ATTR_FLAGS data_flags;
if (!ni || size < 0 || type == AT_ATTRIBUTE_LIST) {
if (!ni || size < 0 || le32_eq(type, AT_ATTRIBUTE_LIST)) {
errno = EINVAL;
ntfs_log_perror("%s: ni=%p size=%lld", __FUNCTION__, ni,
(long long)size);
@ -4300,8 +4300,8 @@ add_attr_record:
&& (ni->vol->major_ver >= 3)
&& NVolCompression(ni->vol)
&& (ni->vol->cluster_size <= MAX_COMPRESSION_CLUSTER_SIZE)
&& ((type == AT_DATA)
|| ((type == AT_INDEX_ROOT) && (name == NTFS_INDEX_I30))))
&& (le32_eq(type, AT_DATA)
|| (le32_eq(type, AT_INDEX_ROOT) && (name == NTFS_INDEX_I30))))
data_flags = ATTR_IS_COMPRESSED;
else
data_flags = const_cpu_to_le16(0);
@ -4499,7 +4499,7 @@ int ntfs_attr_record_resize(MFT_RECORD *m, ATTR_RECORD *a, u32 new_size)
return -1;
}
if (a->type == AT_INDEX_ROOT && new_size > attr_size &&
if (le32_eq(a->type, AT_INDEX_ROOT) && new_size > attr_size &&
new_muse + 120 > alloc_size && old_size + 120 <= alloc_size) {
errno = ENOSPC;
ntfs_log_trace("Too big INDEX_ROOT (%u > %u)\n",
@ -5001,8 +5001,8 @@ static int ntfs_resident_attr_resize_i(ntfs_attr *na, const s64 newsize,
|| NAttrSparse(na))
na->compressed_size = na->allocated_size;
if (na->ni->mrec->flags & MFT_RECORD_IS_DIRECTORY
? na->type == AT_INDEX_ROOT && na->name == NTFS_INDEX_I30
: na->type == AT_DATA && na->name == AT_UNNAMED) {
? le32_eq(na->type, AT_INDEX_ROOT) && na->name == NTFS_INDEX_I30
: le32_eq(na->type, AT_DATA) && na->name == AT_UNNAMED) {
na->ni->data_size = na->data_size;
if (((na->data_flags & ATTR_COMPRESSION_MASK)
|| NAttrSparse(na))
@ -5013,7 +5013,7 @@ static int ntfs_resident_attr_resize_i(ntfs_attr *na, const s64 newsize,
na->ni->allocated_size
= na->allocated_size;
set_nino_flag(na->ni,KnownSize);
if (na->type == AT_DATA)
if (le32_eq(na->type, AT_DATA))
NInoFileNameSetDirty(na->ni);
}
goto resize_done;
@ -5083,7 +5083,7 @@ static int ntfs_resident_attr_resize_i(ntfs_attr *na, const s64 newsize,
ntfs_attr_close(tna);
continue;
}
if ((tna->type == AT_DATA) && !tna->name_len) {
if (le32_eq(tna->type, AT_DATA) && !tna->name_len) {
/*
* If we had to make the unnamed data attribute
* non-resident, propagate its new allocated size
@ -5115,7 +5115,7 @@ static int ntfs_resident_attr_resize_i(ntfs_attr *na, const s64 newsize,
* The standard information and attribute list attributes can't be
* moved out from the base MFT record, so try to move out others.
*/
if (na->type==AT_STANDARD_INFORMATION || na->type==AT_ATTRIBUTE_LIST) {
if (le32_eq(na->type, AT_STANDARD_INFORMATION) || le32_eq(na->type, AT_ATTRIBUTE_LIST)) {
ntfs_attr_put_search_ctx(ctx);
if (ntfs_inode_free_space(na->ni, offsetof(ATTR_RECORD,
non_resident_end) + 8)) {
@ -5282,7 +5282,7 @@ static int ntfs_attr_make_resident(ntfs_attr *na, ntfs_attr_search_ctx *ctx)
}
/* Make sure this is not $MFT/$BITMAP or Windows will not boot! */
if (na->type == AT_BITMAP && na->ni->mft_no == FILE_MFT) {
if (le32_eq(na->type, AT_BITMAP) && na->ni->mft_no == FILE_MFT) {
errno = EPERM;
return -1;
}
@ -5345,7 +5345,7 @@ static int ntfs_attr_make_resident(ntfs_attr *na, ntfs_attr_search_ctx *ctx)
* to current state of compression flag
*/
if (!na->data_size
&& (na->type == AT_DATA)
&& le32_eq(na->type, AT_DATA)
&& (na->ni->vol->major_ver >= 3)
&& NVolCompression(na->ni->vol)
&& (na->ni->vol->cluster_size <= MAX_COMPRESSION_CLUSTER_SIZE)
@ -5358,7 +5358,7 @@ static int ntfs_attr_make_resident(ntfs_attr *na, ntfs_attr_search_ctx *ctx)
* but at least it serves as a reminder that there may be attributes
* for which we do need to set this flag. (AIA)
*/
if (a->type == AT_FILE_NAME)
if (le32_eq(a->type, AT_FILE_NAME))
a->resident_flags = RESIDENT_ATTR_IS_INDEXED;
else
a->resident_flags = 0;
@ -5529,7 +5529,7 @@ static int ntfs_attr_update_meta(ATTR_RECORD *a, ntfs_attr *na, MFT_RECORD *m,
* Set FILE_NAME dirty flag, to update sparse bit and
* allocated size in the index.
*/
if (na->type == AT_DATA && na->name == AT_UNNAMED) {
if (le32_eq(na->type, AT_DATA) && na->name == AT_UNNAMED) {
if (sparse || (na->data_flags & ATTR_COMPRESSION_MASK))
na->ni->allocated_size = na->compressed_size;
else
@ -5731,7 +5731,7 @@ retry:
* in the base mft record. Try to move out other
* attributes and try again.
*/
if (na->type == AT_ATTRIBUTE_LIST) {
if (le32_eq(na->type, AT_ATTRIBUTE_LIST)) {
ntfs_attr_put_search_ctx(ctx);
if (ntfs_inode_free_space(na->ni, mp_size -
cur_max_mp_size)) {
@ -5821,7 +5821,7 @@ retry:
& (ATTR_IS_COMPRESSED | ATTR_IS_SPARSE);
if (spcomp)
a->compressed_size = cpu_to_sle64(na->compressed_size);
if ((na->type == AT_DATA) && (na->name == AT_UNNAMED)) {
if (le32_eq(na->type, AT_DATA) && (na->name == AT_UNNAMED)) {
na->ni->allocated_size
= (spcomp
? na->compressed_size
@ -5873,7 +5873,7 @@ retry:
/* Allocate new mft record, with special case for mft itself */
if (!na->ni->mft_no)
ni = ntfs_mft_rec_alloc(na->ni->vol,
na->type == AT_DATA);
le32_eq(na->type, AT_DATA));
else
ni = ntfs_mft_record_alloc(na->ni->vol, base_ni);
if (!ni) {
@ -6095,13 +6095,13 @@ static int ntfs_non_resident_attr_shrink(ntfs_attr *na, const s64 newsize)
}
/* Update data size in the index. */
if (na->ni->mrec->flags & MFT_RECORD_IS_DIRECTORY) {
if (na->type == AT_INDEX_ROOT && na->name == NTFS_INDEX_I30) {
if (le32_eq(na->type, AT_INDEX_ROOT) && na->name == NTFS_INDEX_I30) {
na->ni->data_size = na->data_size;
na->ni->allocated_size = na->allocated_size;
set_nino_flag(na->ni,KnownSize);
}
} else {
if (na->type == AT_DATA && na->name == AT_UNNAMED) {
if (le32_eq(na->type, AT_DATA) && na->name == AT_UNNAMED) {
na->ni->data_size = na->data_size;
NInoFileNameSetDirty(na->ni);
}
@ -6171,7 +6171,7 @@ static int ntfs_non_resident_attr_expand_i(ntfs_attr *na, const s64 newsize,
return -1;
}
if (na->type == AT_DATA)
if (le32_eq(na->type, AT_DATA))
NAttrSetDataAppending(na);
/* Save for future use. */
org_alloc_size = na->allocated_size;
@ -6208,7 +6208,7 @@ static int ntfs_non_resident_attr_expand_i(ntfs_attr *na, const s64 newsize,
* If we extend $DATA attribute on NTFS 3+ volume, we can add
* sparse runs instead of real allocation of clusters.
*/
if ((na->type == AT_DATA) && (vol->major_ver >= 3)
if (le32_eq(na->type, AT_DATA) && (vol->major_ver >= 3)
&& (holes != HOLES_NO)) {
rl = ntfs_malloc(0x1000);
if (!rl)
@ -6327,13 +6327,13 @@ static int ntfs_non_resident_attr_expand_i(ntfs_attr *na, const s64 newsize,
ctx->attr->data_size = cpu_to_sle64(newsize);
/* Update data size in the index. */
if (na->ni->mrec->flags & MFT_RECORD_IS_DIRECTORY) {
if (na->type == AT_INDEX_ROOT && na->name == NTFS_INDEX_I30) {
if (le32_eq(na->type, AT_INDEX_ROOT) && na->name == NTFS_INDEX_I30) {
na->ni->data_size = na->data_size;
na->ni->allocated_size = na->allocated_size;
set_nino_flag(na->ni,KnownSize);
}
} else {
if (na->type == AT_DATA && na->name == AT_UNNAMED) {
if (le32_eq(na->type, AT_DATA) && na->name == AT_UNNAMED) {
na->ni->data_size = na->data_size;
NInoFileNameSetDirty(na->ni);
}
@ -6419,7 +6419,7 @@ static int ntfs_attr_truncate_i(ntfs_attr *na, const s64 newsize,
BOOL compressed;
if (!na || newsize < 0 ||
(na->ni->mft_no == FILE_MFT && na->type == AT_DATA)) {
(na->ni->mft_no == FILE_MFT && le32_eq(na->type, AT_DATA))) {
ntfs_log_trace("Invalid arguments passed.\n");
errno = EINVAL;
return STATUS_ERROR;

View File

@ -1138,7 +1138,7 @@ int ntfs_inode_add_attrlist(ntfs_inode *ni)
int ale_size;
if (ctx->attr->type == AT_ATTRIBUTE_LIST) {
if (le32_eq(ctx->attr->type, AT_ATTRIBUTE_LIST)) {
err = EIO;
ntfs_log_perror("Attribute list already present");
goto put_err_out;
@ -1332,10 +1332,10 @@ retry:
}
if (ntfs_inode_base(ctx->ntfs_ino)->mft_no == FILE_MFT &&
ctx->attr->type == AT_DATA)
le32_eq(ctx->attr->type, AT_DATA))
goto retry;
if (ctx->attr->type == AT_INDEX_ROOT)
if (le32_eq(ctx->attr->type, AT_INDEX_ROOT))
goto retry;
record_size = le32_to_cpu(ctx->attr->length);

View File

@ -884,7 +884,7 @@ static le32 setsecurityattr(ntfs_volume *vol,
else size = 0;
/* if hash is not the same, the key is not present */
if (psdh && (size > 0)
&& (psdh->keyhash == hash)) {
&& (le32_eq(psdh->keyhash, hash))) {
/* if hash is the same */
/* check the whole record */
realign.parts.dataoffsh = psdh->dataoffsh;

View File

@ -1235,14 +1235,14 @@ static int mkntfs_attr_find(const ATTR_TYPES type, const ntfschar *name,
ctx->attr = a;
if (((type != AT_UNUSED) && (le32_to_cpu(a->type) >
le32_to_cpu(type))) ||
(a->type == AT_END)) {
le32_eq(a->type, AT_END)) {
errno = ENOENT;
return -1;
}
if (!a->length)
break;
/* If this is an enumeration return this attribute. */
if (type == AT_UNUSED)
if (le32_eq(type, AT_UNUSED))
return 0;
if (a->type != type)
continue;
@ -1409,7 +1409,7 @@ static int mkntfs_attr_lookup(const ATTR_TYPES type, const ntfschar *name,
base_ni = ctx->base_ntfs_ino;
else
base_ni = ctx->ntfs_ino;
if (!base_ni || !NInoAttrList(base_ni) || type == AT_ATTRIBUTE_LIST)
if (!base_ni || !NInoAttrList(base_ni) || le32_eq(type, AT_ATTRIBUTE_LIST))
return mkntfs_attr_find(type, name, name_len, ic, val, val_len,
ctx);
errno = EOPNOTSUPP;
@ -1577,9 +1577,9 @@ static int insert_positioned_attr_in_mft_record(MFT_RECORD *m,
err = -EOPNOTSUPP;
} else {
a->compression_unit = 0;
if ((type == AT_DATA)
&& (m->mft_record_number
== const_cpu_to_le32(FILE_LogFile)))
if (le32_eq(type, AT_DATA)
&& le32_eq(m->mft_record_number,
const_cpu_to_le32(FILE_LogFile)))
bw = ntfs_rlwrite(g_vol->dev, rl, val, val_len,
&inited_size, WRITE_LOGFILE);
else
@ -1884,7 +1884,7 @@ static int insert_resident_attr_in_mft_record(MFT_RECORD *m,
a->length = cpu_to_le32(asize);
a->non_resident = 0;
a->name_length = name_len;
if (type == AT_OBJECT_ID)
if (le32_eq(type, AT_OBJECT_ID))
a->name_offset = const_cpu_to_le16(0);
else
a->name_offset = const_cpu_to_le16(24);
@ -2276,9 +2276,9 @@ static int add_attr_index_root(MFT_RECORD *m, const char *name,
r = ntfs_malloc(val_len);
if (!r)
return -errno;
r->type = (indexed_attr_type == AT_FILE_NAME)
r->type = le32_eq(indexed_attr_type, AT_FILE_NAME)
? AT_FILE_NAME : const_cpu_to_le32(0);
if (indexed_attr_type == AT_FILE_NAME &&
if (le32_eq(indexed_attr_type, AT_FILE_NAME) &&
collation_rule != COLLATION_FILE_NAME) {
free(r);
ntfs_log_error("add_attr_index_root: indexed attribute is $FILE_NAME "
@ -2630,7 +2630,7 @@ static int ntfs_index_keys_compare(u8 *key1, u8 *key2, int key1_length,
u32 u1, u2;
int i;
if (collation_rule == COLLATION_NTOFS_ULONG) {
if (le32_eq(collation_rule, COLLATION_NTOFS_ULONG)) {
/* i.e. $SII or $QUOTA-$Q */
u1 = le32_to_cpup((const le32*)key1);
u2 = le32_to_cpup((const le32*)key2);
@ -2641,7 +2641,7 @@ static int ntfs_index_keys_compare(u8 *key1, u8 *key2, int key1_length,
/* u1 == u2 */
return 0;
}
if (collation_rule == COLLATION_NTOFS_ULONGS) {
if (le32_eq(collation_rule, COLLATION_NTOFS_ULONGS)) {
/* i.e $OBJID-$O */
i = 0;
while (i < min(key1_length, key2_length)) {
@ -2660,7 +2660,7 @@ static int ntfs_index_keys_compare(u8 *key1, u8 *key2, int key1_length,
return 1;
return 0;
}
if (collation_rule == COLLATION_NTOFS_SECURITY_HASH) {
if (le32_eq(collation_rule, COLLATION_NTOFS_SECURITY_HASH)) {
/* i.e. $SDH */
u1 = le32_to_cpu(((SDH_INDEX_KEY*)key1)->hash);
u2 = le32_to_cpu(((SDH_INDEX_KEY*)key2)->hash);
@ -2677,7 +2677,7 @@ static int ntfs_index_keys_compare(u8 *key1, u8 *key2, int key1_length,
return 1;
return 0;
}
if (collation_rule == COLLATION_NTOFS_SID) {
if (le32_eq(collation_rule, COLLATION_NTOFS_SID)) {
/* i.e. $QUOTA-O */
i = memcmp(key1, key2, min(key1_length, key2_length));
if (!i) {
@ -2740,7 +2740,7 @@ static int insert_index_entry_in_res_dir_index(INDEX_ENTRY *idx, u32 idx_size,
* Loop until we exceed valid memory (corruption case) or until we
* reach the last entry.
*/
if (type == AT_FILE_NAME) {
if (le32_eq(type, AT_FILE_NAME)) {
while (((u8*)idx_entry < (u8*)idx_end) &&
!(idx_entry->ie_flags & INDEX_ENTRY_END)) {
/*
@ -2785,7 +2785,7 @@ do_next:
idx_entry = (INDEX_ENTRY*)((u8*)idx_entry +
le16_to_cpu(idx_entry->length));
}
} else if (type == AT_UNUSED) { /* case view */
} else if (le32_eq(type, AT_UNUSED)) { /* case view */
while (((u8*)idx_entry < (u8*)idx_end) &&
!(idx_entry->ie_flags & INDEX_ENTRY_END)) {
i = ntfs_index_keys_compare((u8*)idx + 0x10,

View File

@ -352,9 +352,9 @@ static int cat(ntfs_volume *vol, ntfs_inode *inode, ATTR_TYPES type,
return 1;
}
if ((inode->mft_no < 2) && (attr->type == AT_DATA))
if ((inode->mft_no < 2) && le32_eq(attr->type, AT_DATA))
block_size = vol->mft_record_size;
else if (attr->type == AT_INDEX_ALLOCATION)
else if (le32_eq(attr->type, AT_INDEX_ALLOCATION))
block_size = index_get_size(inode);
else
block_size = 0;

View File

@ -281,7 +281,7 @@ static runlist *load_runlist(ntfs_volume *rawvol, s64 offset_to_file_record, u32
//printf("Attr type: 0x%x.\n", attr_rec->type);
// Check attribute record. (Only what is in the buffer)
if (attr_rec->type==AT_END) {
if (le32_eq(attr_rec->type, AT_END)) {
check_failed("Attribute 0x%x not found in file record at offset %lld (0x%llx).\n", (int)le32_to_cpu(attr_rec->type),
(long long)offset_to_file_record,
(long long)offset_to_file_record);
@ -307,7 +307,7 @@ static runlist *load_runlist(ntfs_volume *rawvol, s64 offset_to_file_record, u32
}
// todo: what ATTRIBUTE_LIST (0x20)?
if (attr_rec->type==attr_type) {
if (le32_eq(attr_rec->type, attr_type)) {
// Eurika!
// ntfs_mapping_pairs_decompress only use two values from vol. Just fake it.
@ -629,7 +629,7 @@ static BOOL check_file_record(u8 *buffer, u16 buflen)
while ((u8*)attr_rec<=buffer+buflen-4) {
// Check attribute record. (Only what is in the buffer)
if (attr_rec->type==AT_END) {
if (le32_eq(attr_rec->type, AT_END)) {
// Done.
return 0;
}

View File

@ -630,13 +630,13 @@ static s64 is_critical_metadata(ntfs_walk_clusters_ctx *image, runlist *rl)
if (inode <= LAST_METADATA_INODE) {
/* Don't save bad sectors (both $Bad and unnamed are ignored */
if (inode == FILE_BadClus && image->ctx->attr->type == AT_DATA)
if (inode == FILE_BadClus && le32_eq(image->ctx->attr->type, AT_DATA))
return 0;
if (inode != FILE_LogFile)
return rl->length;
if (image->ctx->attr->type == AT_DATA) {
if (le32_eq(image->ctx->attr->type, AT_DATA)) {
/* Save at least the first 16 KiB of FILE_LogFile */
s64 s = (s64)16384 - rl->vcn * vol->cluster_size;
@ -1204,7 +1204,7 @@ static void wipe_index_root_timestamps(ATTR_RECORD *attr, le64 timestamp)
while (!(entry->ie_flags & INDEX_ENTRY_END)) {
if (iroot->type == AT_FILE_NAME) {
if (le32_eq(iroot->type, AT_FILE_NAME)) {
entry->key.file_name.creation_time = timestamp;
entry->key.file_name.last_access_time = timestamp;
@ -1258,13 +1258,13 @@ static void wipe_timestamps(ntfs_walk_clusters_ctx *image)
ATTR_RECORD *a = image->ctx->attr;
le64 timestamp = timespec2ntfs(zero_time);
if (a->type == AT_FILE_NAME)
if (le32_eq(a->type, AT_FILE_NAME))
WIPE_TIMESTAMPS(FILE_NAME_ATTR, a, timestamp);
else if (a->type == AT_STANDARD_INFORMATION)
else if (le32_eq(a->type, AT_STANDARD_INFORMATION))
WIPE_TIMESTAMPS(STANDARD_INFORMATION, a, timestamp);
else if (a->type == AT_INDEX_ROOT)
else if (le32_eq(a->type, AT_INDEX_ROOT))
wipe_index_root_timestamps(a, timestamp);
}
@ -1394,7 +1394,7 @@ static void wipe_mft(char *mrec, u32 mrecsz, u64 mft_no)
while (!ntfs_attr_lookup(AT_UNUSED, NULL, 0, CASE_SENSITIVE, 0,
NULL, 0, ctx)) {
if (ctx->attr->type == AT_END)
if (le32_eq(ctx->attr->type, AT_END))
break;
image.ctx = ctx;
@ -1431,7 +1431,7 @@ static void wipe_indx(char *mrec, u32 mrecsz)
* The index bitmap is not checked, obsoleted records are
* wiped if they pass the safety checks
*/
if ((indexa->magic == magic_INDX)
if (le32_eq(indexa->magic, magic_INDX)
&& (le32_to_cpu(indexa->index.entries_offset) >= sizeof(INDEX_HEADER))
&& (le32_to_cpu(indexa->index.allocated_size) <= mrecsz)) {
entry = (INDEX_ENTRY *)((u8 *)mrec + le32_to_cpu(
@ -1670,7 +1670,7 @@ static void walk_runs(struct ntfs_walk_cluster *walk)
if (wipe
&& !opt.preserve_timestamps
&& walk->image->ctx->attr->type == AT_INDEX_ALLOCATION)
&& le32_eq(walk->image->ctx->attr->type, AT_INDEX_ALLOCATION))
wipe_index_allocation_timestamps(walk->image->ni, a);
if (!(rl = ntfs_mapping_pairs_decompress(vol, a, NULL)))
@ -1679,8 +1679,8 @@ static void walk_runs(struct ntfs_walk_cluster *walk)
/* special wipings for MFT records and directory indexes */
mft_data = ((walk->image->ni->mft_no == FILE_MFT)
|| (walk->image->ni->mft_no == FILE_MFTMirr))
&& (a->type == AT_DATA);
index_i30 = (walk->image->ctx->attr->type == AT_INDEX_ALLOCATION)
&& le32_eq(a->type, AT_DATA);
index_i30 = le32_eq(walk->image->ctx->attr->type, AT_INDEX_ALLOCATION)
&& (a->name_length == 4)
&& !memcmp((char*)a + le16_to_cpu(a->name_offset),
NTFS_INDEX_I30,8);
@ -1720,7 +1720,7 @@ static void walk_runs(struct ntfs_walk_cluster *walk)
*/
if (!wipe && opt.metadata_image) {
if ((walk->image->ni->mft_no == FILE_LogFile)
&& (walk->image->ctx->attr->type == AT_DATA)) {
&& le32_eq(walk->image->ctx->attr->type, AT_DATA)) {
/* 16 KiB of FILE_LogFile */
walk->image->inuse
+= is_critical_metadata(walk->image,rl);
@ -1775,7 +1775,7 @@ static void walk_runs(struct ntfs_walk_cluster *walk)
if (opt.metadata
&& (opt.metadata_image || !wipe)
&& (walk->image->ni->mft_no == FILE_LogFile)
&& (walk->image->ctx->attr->type == AT_DATA))
&& le32_eq(walk->image->ctx->attr->type, AT_DATA))
clone_logfile_parts(walk->image, rl);
free(rl);
@ -1790,7 +1790,7 @@ static void walk_attributes(struct ntfs_walk_cluster *walk)
perr_exit("ntfs_get_attr_search_ctx");
while (!ntfs_attrs_walk(ctx)) {
if (ctx->attr->type == AT_END)
if (le32_eq(ctx->attr->type, AT_END))
break;
walk->image->ctx = ctx;

View File

@ -423,7 +423,7 @@ static char *get_attr_name(u64 mft_no,
char *name = NULL;
int name_len;
if (atype == AT_END)
if (le32_eq(atype, AT_END))
return NULL;
name_len = ntfs_ucstombs(uname, uname_len, &name, 0);
@ -707,7 +707,7 @@ static void cmp_attribute(ntfs_attr_search_ctx *ctx1,
goto close_attribs;
}
if (na1->type == AT_INDEX_ALLOCATION)
if (le32_eq(na1->type, AT_INDEX_ALLOCATION))
cmp_index_allocation(na1, na2);
else
cmp_attribute_data(na1, na2);

View File

@ -615,7 +615,7 @@ static int set_sizes(struct ALLOC_CONTEXT *alctx, ntfs_attr_search_ctx *ctx)
if (na->data_flags & ATTR_IS_SPARSE)
attr->compressed_size = cpu_to_le64(na->compressed_size);
/* Copy the unnamed data attribute sizes to inode */
if ((opts.attribute == AT_DATA) && !na->name_len) {
if (le32_eq(opts.attribute, AT_DATA) && !na->name_len) {
ni = na->ni;
ni->data_size = na->data_size;
if (na->data_flags & ATTR_IS_SPARSE) {

View File

@ -1091,7 +1091,7 @@ static ntfs_fek *ntfs_fek_import_from_raw(u8 *fek_buf, unsigned fek_size)
wanted_key_size = 8;
gcry_algo = GCRY_CIPHER_DES;
gcry_mode = GCRY_CIPHER_MODE_CBC;
if (fek->alg_id == CALG_DES)
if (le32_eq(fek->alg_id, CALG_DES))
ntfs_log_error("DES is not supported at present\n");
else
ntfs_log_error("Unknown crypto algorithm 0x%x\n",
@ -1120,7 +1120,7 @@ static ntfs_fek *ntfs_fek_import_from_raw(u8 *fek_buf, unsigned fek_size)
err = EINVAL;
goto out;
}
if (fek->alg_id == CALG_DESX) {
if (le32_eq(fek->alg_id, CALG_DESX)) {
err = ntfs_desx_key_expand(fek->key_data, (u32*)ctx->des_key,
&ctx->out_whitening, &ctx->in_whitening);
if (err == GPG_ERR_NO_ERROR)
@ -1287,7 +1287,7 @@ static int ntfs_fek_decrypt_sector(ntfs_fek *fek, u8 *data, const u64 offset)
* that gcry_cipher_setiv() wants an iv of length 8 bytes but we give
* it a length of 16 for AES256 so it does not like it.
*/
if (fek->alg_id == CALG_DESX) {
if (le32_eq(fek->alg_id, CALG_DESX)) {
int k;
for (k=0; k<512; k+=8) {
@ -1300,7 +1300,7 @@ static int ntfs_fek_decrypt_sector(ntfs_fek *fek, u8 *data, const u64 offset)
return -1;
}
/* Apply the IV. */
if (fek->alg_id == CALG_AES_256) {
if (le32_eq(fek->alg_id, CALG_AES_256)) {
((le64*)data)[0] ^= cpu_to_le64(0x5816657be9161312ULL + offset);
((le64*)data)[1] ^= cpu_to_le64(0x1989adbe44918961ULL + offset);
} else {
@ -1330,14 +1330,14 @@ static int ntfs_fek_encrypt_sector(ntfs_fek *fek, u8 *data, const u64 offset)
* it a length of 16 for AES256 so it does not like it.
*/
/* Apply the IV. */
if (fek->alg_id == CALG_AES_256) {
if (le32_eq(fek->alg_id, CALG_AES_256)) {
((le64*)data)[0] ^= cpu_to_le64(0x5816657be9161312ULL + offset);
((le64*)data)[1] ^= cpu_to_le64(0x1989adbe44918961ULL + offset);
} else {
/* All other algos (Des, 3Des, DesX) use the same IV. */
((le64*)data)[0] ^= cpu_to_le64(0x169119629891ad13ULL + offset);
}
if (fek->alg_id == CALG_DESX) {
if (le32_eq(fek->alg_id, CALG_DESX)) {
int k;
for (k=0; k<512; k+=8) {

View File

@ -713,7 +713,7 @@ static int ntfs_full_allocation(ntfs_attr *na, ntfs_attr_search_ctx *ctx,
attr->compressed_size
= cpu_to_le64(na->compressed_size);
/* Copy the unnamed data attribute sizes to inode */
if ((attr_type == AT_DATA) && !attr_name_len) {
if (le32_eq(attr_type, AT_DATA) && !attr_name_len) {
ni = na->ni;
ni->data_size = na->data_size;
if (na->data_flags & ATTR_IS_SPARSE) {

View File

@ -869,7 +869,7 @@ static BOOL attrlist_selfloc_condition(struct MFT_SELF_LOCATED *selfloc)
}
if ((length > 0)
&& al->length
&& (al->type == AT_DATA)
&& le32_eq(al->type, AT_DATA)
&& !al->name_length
&& ((leVCN)al->lowest_vcn == levcn)
&& (MREF_LE(al->mft_reference) >= SELFLOC_LIMIT)) {

View File

@ -572,7 +572,7 @@ static void ntfs_dump_flags(const char *indent, ATTR_TYPES type, le32 flags)
}
/* We know that FILE_ATTR_I30_INDEX_PRESENT only exists on $FILE_NAME,
and in case we are wrong, let it appear as UNKNOWN */
if (type == AT_FILE_NAME) {
if (le32_eq(type, AT_FILE_NAME)) {
if (flags & FILE_ATTR_I30_INDEX_PRESENT) {
printf(" I30_INDEX");
flags &= ~FILE_ATTR_I30_INDEX_PRESENT;
@ -1690,7 +1690,7 @@ static INDEX_ATTR_TYPE get_index_attr_type(ntfs_inode *ni, ATTR_RECORD *attr,
return INDEX_ATTR_UNKNOWN;
if (index_root->type) {
if (index_root->type == AT_FILE_NAME)
if (le32_eq(index_root->type, AT_FILE_NAME))
return INDEX_ATTR_DIRECTORY_I30;
else
/* weird, this should be illegal */
@ -2254,7 +2254,7 @@ static void ntfs_dump_file_attributes(ntfs_inode *inode)
ctx = ntfs_attr_get_search_ctx(inode, NULL);
while (!ntfs_attr_lookup(AT_UNUSED, NULL, 0, CASE_SENSITIVE,
0, NULL, 0, ctx)) {
if (ctx->attr->type == AT_END || ctx->attr->type == AT_UNUSED) {
if (le32_eq(ctx->attr->type, AT_END) || le32_eq(ctx->attr->type, AT_UNUSED)) {
printf("Weird: %s attribute type was found, please "
"report this.\n",
get_attribute_type_name(

View File

@ -256,7 +256,7 @@ static void dump_mft_record(MFT_RECORD *m)
a = (ATTR_RECORD*)((char*)m + le16_to_cpu(m->attrs_offset));
ntfs_log_info("-- Beginning dump of attributes within mft record. --\n");
while ((char*)a < (char*)m + le32_to_cpu(m->bytes_in_use)) {
if (a->type == AT_END)
if (le32_eq(a->type, AT_END))
break;
a = (ATTR_RECORD*)((char*)a + le32_to_cpu(a->length));
};

View File

@ -724,7 +724,7 @@ static void collect_resize_constraints(ntfs_resize_t *resize, runlist *rl)
if (inode == FILE_Bitmap) {
llcn = &resize->last_lcn;
if (atype == AT_DATA && NInoAttrList(resize->ni))
if (le32_eq(atype, AT_DATA) && NInoAttrList(resize->ni))
err_exit("Highly fragmented $Bitmap isn't supported yet.");
supported = 1;
@ -748,7 +748,7 @@ static void collect_resize_constraints(ntfs_resize_t *resize, runlist *rl)
supported = 1;
/* Fragmented $MFTMirr DATA attribute isn't supported yet */
if (atype == AT_DATA)
if (le32_eq(atype, AT_DATA))
if (rl[1].length != 0 || rl->vcn)
supported = 0;
} else {
@ -782,7 +782,7 @@ static void collect_relocation_info(ntfs_resize_t *resize, runlist *rl)
if (lcn + lcn_length <= new_vol_size)
return;
if (inode == FILE_Bitmap && resize->ctx->attr->type == AT_DATA)
if (inode == FILE_Bitmap && le32_eq(resize->ctx->attr->type, AT_DATA))
return;
start = lcn;
@ -911,7 +911,7 @@ static int walk_attributes(ntfs_volume *vol, ntfsck_t *fsck)
return -1;
while (!ntfs_attrs_walk(fsck->ctx)) {
if (fsck->ctx->attr->type == AT_END)
if (le32_eq(fsck->ctx->attr->type, AT_END))
break;
build_lcn_usage_bitmap(vol, fsck);
}
@ -1128,7 +1128,7 @@ static void resize_constraints_by_attributes(ntfs_resize_t *resize)
exit(1);
while (!ntfs_attrs_walk(resize->ctx)) {
if (resize->ctx->attr->type == AT_END)
if (le32_eq(resize->ctx->attr->type, AT_END))
break;
build_resize_constraints(resize);
}
@ -1751,7 +1751,7 @@ static void copy_clusters(ntfs_resize_t *resize, s64 dest, s64 src, s64 len)
static void relocate_clusters(ntfs_resize_t *r, runlist *dest_rl, s64 src_lcn)
{
/* collect_shrink_constraints() ensured $MFTMir DATA is one run */
if (r->mref == FILE_MFTMirr && r->ctx->attr->type == AT_DATA) {
if (r->mref == FILE_MFTMirr && le32_eq(r->ctx->attr->type, AT_DATA)) {
if (!r->mftmir_old) {
r->mftmir_rl.lcn = dest_rl->lcn;
r->mftmir_rl.length = dest_rl->length;
@ -1849,7 +1849,7 @@ static void relocate_run(ntfs_resize_t *resize, runlist **rl, int run)
hint = (resize->mref == FILE_MFTMirr) ? 1 : 0;
if ((resize->mref == FILE_MFT)
&& (resize->ctx->attr->type == AT_DATA)
&& le32_eq(resize->ctx->attr->type, AT_DATA)
&& !run
&& resize->new_mft_start) {
relocate_rl = resize->new_mft_start;
@ -1988,7 +1988,7 @@ static void relocate_attributes(ntfs_resize_t *resize, int do_mftdata)
exit(1);
while (!ntfs_attrs_walk(resize->ctx)) {
if (resize->ctx->attr->type == AT_END)
if (le32_eq(resize->ctx->attr->type, AT_END))
break;
if (handle_mftdata(resize, do_mftdata) == 0)
@ -2001,7 +2001,7 @@ static void relocate_attributes(ntfs_resize_t *resize, int do_mftdata)
continue;
if (resize->mref == FILE_Bitmap &&
resize->ctx->attr->type == AT_DATA)
le32_eq(resize->ctx->attr->type, AT_DATA))
continue;
relocate_attribute(resize);
@ -2102,7 +2102,7 @@ static void relocate_inodes(ntfs_resize_t *resize)
}
while (!ntfs_attrs_walk(resize->ctx)
&& (resize->ctx->attr->type != AT_DATA)) { }
if (resize->ctx->attr->type == AT_DATA) {
if (le32_eq(resize->ctx->attr->type, AT_DATA)) {
le64 high_le;
high_le = resize->ctx->attr->highest_vcn;
@ -3006,7 +3006,7 @@ static ATTR_RECORD *get_unnamed_attr(expand_t *expand, ATTR_TYPES type,
got = ntfs_mst_pread(vol->dev, pos, 1, vol->mft_record_size, mrec);
if ((got == 1) && (mrec->flags & MFT_RECORD_IN_USE)) {
a = find_attr(expand->mrec, type, NULL, 0);
found = a && (a->type == type) && !a->name_length;
found = a && le32_eq(a->type, type) && !a->name_length;
}
/* not finding the attribute list is not an error */
if (!found && (type != AT_ATTRIBUTE_LIST)) {
@ -3970,7 +3970,7 @@ static runlist_element *rebase_runlists_meta(expand_t *expand, s64 inum)
res = -1;
}
/* relocated unnamed data (not $BadClus) */
if ((a->type == AT_DATA)
if (le32_eq(a->type, AT_DATA)
&& !a->name_length
&& (inum != FILE_BadClus)) {
old_rl = rl;
@ -3991,7 +3991,7 @@ static runlist_element *rebase_runlists_meta(expand_t *expand, s64 inum)
a->highest_vcn = cpu_to_le64(lth - 1);
}
/* expand the named data for $BadClus */
if ((a->type == AT_DATA)
if (le32_eq(a->type, AT_DATA)
&& a->name_length
&& (inum == FILE_BadClus)) {
old_rl = rl;

View File

@ -534,7 +534,7 @@ static void dump_attr_record(MFT_RECORD *m, ATTR_RECORD *a)
printf("-- Beginning dump of attribute record at offset 0x%x. --\n",
(unsigned)((u8*)a - (u8*)m));
if (a->type == AT_END) {
if (le32_eq(a->type, AT_END)) {
printf("Attribute type = 0x%x ($END)\n",
(unsigned int)le32_to_cpu(AT_END));
u = le32_to_cpu(a->length);
@ -665,9 +665,9 @@ static void dump_mft_record(MFT_RECORD *m)
a = (ATTR_RECORD*)((char*)m + le16_to_cpu(m->attrs_offset));
printf("-- Beginning dump of attributes within mft record. --\n");
while ((char*)a < (char*)m + le32_to_cpu(m->bytes_in_use)) {
if (a->type == cpu_to_le32(attr_type))
if (le32_eq(a->type, cpu_to_le32(attr_type)))
dump_attr_record(m, a);
if (a->type == AT_END)
if (le32_eq(a->type, AT_END))
break;
a = (ATTR_RECORD*)((char*)a + le32_to_cpu(a->length));
};