diff --git a/libntfs-3g/attrib.c b/libntfs-3g/attrib.c index 48276277..331d40c3 100644 --- a/libntfs-3g/attrib.c +++ b/libntfs-3g/attrib.c @@ -480,7 +480,7 @@ ntfs_attr *ntfs_attr_open(ntfs_inode *ni, const ATTR_TYPES type, /* a file may be sparse though its unnamed data is not (cf $UsnJrnl) */ if (le32_eq(na->type, AT_DATA) && na->name == AT_UNNAMED && ((!le16_andz(a->flags, ATTR_IS_SPARSE) && !NAttrSparse(na)) || - (!(a->flags & ATTR_IS_ENCRYPTED) != !NAttrEncrypted(na)))) { + (le16_andz(a->flags, ATTR_IS_ENCRYPTED) != !NAttrEncrypted(na)))) { errno = EIO; ntfs_log_perror("Inode %lld has corrupt attribute flags " "(0x%x <> 0x%x)",(unsigned long long)ni->mft_no, @@ -5446,7 +5446,7 @@ static int ntfs_attr_update_meta(ATTR_RECORD *a, ntfs_attr *na, MFT_RECORD *m, /* Check whether attribute becomes sparse, unless check is delayed. */ if ((holes != HOLES_DELAY) && sparse - && !(a->flags & (ATTR_IS_SPARSE | ATTR_IS_COMPRESSED))) { + && le16_andz(a->flags, ATTR_IS_SPARSE | ATTR_IS_COMPRESSED)) { /* * Move attribute to another mft record, if attribute is too * small to add compressed_size field to it and we have no @@ -5495,7 +5495,7 @@ static int ntfs_attr_update_meta(ATTR_RECORD *a, ntfs_attr *na, MFT_RECORD *m, /* Attribute no longer sparse. */ if (!sparse && !le16_andz(a->flags, ATTR_IS_SPARSE) && - !(a->flags & ATTR_IS_COMPRESSED)) { + le16_andz(a->flags, ATTR_IS_COMPRESSED)) { NAttrClearSparse(na); a->flags &= ~ATTR_IS_SPARSE; @@ -5586,10 +5586,10 @@ retry: */ if ((holes != HOLES_DELAY) && (!NAttrFullyMapped(na) || from_vcn) - && !(na->data_flags & ATTR_IS_COMPRESSED)) { + && le16_andz(na->data_flags, ATTR_IS_COMPRESSED)) { BOOL changed; - if (!(na->data_flags & ATTR_IS_SPARSE)) { + if (le16_andz(na->data_flags, ATTR_IS_SPARSE)) { int sparse = 0; runlist_element *xrl; @@ -6109,7 +6109,7 @@ static int ntfs_non_resident_attr_shrink(ntfs_attr *na, const s64 newsize) /* If the attribute now has zero size, make it resident. */ if (!newsize) { - if (!(na->data_flags & ATTR_IS_ENCRYPTED) + if (le16_andz(na->data_flags, ATTR_IS_ENCRYPTED) && ntfs_attr_make_resident(na, ctx)) { /* If couldn't make resident, just continue. */ if (errno != EPERM) diff --git a/libntfs-3g/dir.c b/libntfs-3g/dir.c index 47451544..6de349de 100644 --- a/libntfs-3g/dir.c +++ b/libntfs-3g/dir.c @@ -352,7 +352,7 @@ u64 ntfs_inode_lookup_by_name(ntfs_inode *dir_ni, * ENOENT, unless we have got the mft reference of a matching name * cached in mref in which case return mref. */ - if (!(ie->ie_flags & INDEX_ENTRY_NODE)) { + if (le16_andz(ie->ie_flags, INDEX_ENTRY_NODE)) { ntfs_attr_put_search_ctx(ctx); if (mref) return mref; @@ -1132,7 +1132,7 @@ int ntfs_readdir(ntfs_inode *dir_ni, s64 *pos, return -1; } - if (!(dir_ni->mrec->flags & MFT_RECORD_IS_DIRECTORY)) { + if (le16_andz(dir_ni->mrec->flags, MFT_RECORD_IS_DIRECTORY)) { errno = ENOTDIR; return -1; } @@ -1791,7 +1791,7 @@ int ntfs_check_empty_dir(ntfs_inode *ni) ntfs_attr *na; int ret = 0; - if (!(ni->mrec->flags & MFT_RECORD_IS_DIRECTORY)) + if (le16_andz(ni->mrec->flags, MFT_RECORD_IS_DIRECTORY)) return 0; na = ntfs_attr_open(ni, AT_INDEX_ROOT, NTFS_INDEX_I30, 4); diff --git a/libntfs-3g/efs.c b/libntfs-3g/efs.c index 7957005b..7663a16e 100644 --- a/libntfs-3g/efs.c +++ b/libntfs-3g/efs.c @@ -164,7 +164,7 @@ static int fixup_loop(ntfs_inode *ni) ntfs_log_error("can't open DATA Attribute\n"); res = -1; } - if (na && !(ctx->attr->flags & ATTR_IS_ENCRYPTED)) { + if (na && le16_andz(ctx->attr->flags, ATTR_IS_ENCRYPTED)) { if (!NAttrNonResident(na) && ntfs_attr_make_non_resident(na, ctx)) { /* @@ -290,7 +290,7 @@ int ntfs_set_efs_info(ntfs_inode *ni, const char *value, size_t size, } if (!res) { /* Don't handle AT_DATA Attribute(s) if inode is a directory */ - if (!(ni->mrec->flags & MFT_RECORD_IS_DIRECTORY)) { + if (le16_andz(ni->mrec->flags, MFT_RECORD_IS_DIRECTORY)) { /* iterate over AT_DATA attributes */ /* set encrypted flag, truncate attribute to match padding bytes */ diff --git a/libntfs-3g/index.c b/libntfs-3g/index.c index d372c3e1..32b6d902 100644 --- a/libntfs-3g/index.c +++ b/libntfs-3g/index.c @@ -552,7 +552,7 @@ static int ntfs_ie_lookup(const void *key, const int key_len, * presence of a child node and if not present return with errno ENOENT, * otherwise we will keep searching in another index block. */ - if (!(ie->ie_flags & INDEX_ENTRY_NODE)) { + if (le16_andz(ie->ie_flags, INDEX_ENTRY_NODE)) { ntfs_log_debug("Index entry wasn't found.\n"); *ie_out = ie; errno = ENOENT; @@ -1302,7 +1302,7 @@ static int ntfs_ih_insert(INDEX_HEADER *ih, INDEX_ENTRY *orig_ie, VCN new_vcn, if (!ie) return STATUS_ERROR; - if (!(ie->ie_flags & INDEX_ENTRY_NODE)) + if (le16_andz(ie->ie_flags, INDEX_ENTRY_NODE)) if (ntfs_ie_add_vcn(&ie)) goto out; @@ -1344,7 +1344,7 @@ static int ntfs_ir_insert_median(ntfs_index_context *icx, INDEX_ENTRY *median, new_size = le32_to_cpu(icx->ir->index.index_length) + le16_to_cpu(median->length); - if (!(median->ie_flags & INDEX_ENTRY_NODE)) + if (le16_andz(median->ie_flags, INDEX_ENTRY_NODE)) new_size += sizeof(VCN); ret = ntfs_ir_make_space(icx, new_size); diff --git a/libntfs-3g/inode.c b/libntfs-3g/inode.c index b1c5f739..fefccc37 100644 --- a/libntfs-3g/inode.c +++ b/libntfs-3g/inode.c @@ -175,7 +175,7 @@ static ntfs_inode *ntfs_inode_real_open(ntfs_volume *vol, const MFT_REF mref) goto out; if (ntfs_file_record_read(vol, mref, &ni->mrec, NULL)) goto err_out; - if (!(ni->mrec->flags & MFT_RECORD_IN_USE)) { + if (le16_andz(ni->mrec->flags, MFT_RECORD_IN_USE)) { errno = ENOENT; goto err_out; } @@ -512,7 +512,7 @@ int ntfs_inode_close(ntfs_inode *ni) if (ni->vol && ni->vol->nidata_cache && ((ni->mft_no == FILE_root) || ((ni->mft_no >= FILE_first_user) - && !(ni->mrec->flags & MFT_RECORD_IS_4)))) { + && le16_andz(ni->mrec->flags, MFT_RECORD_IS_4)))) { /* If we have dirty metadata, write it out. */ dirty = NInoDirty(ni) || NInoAttrListDirty(ni); if (dirty) { diff --git a/libntfs-3g/logfile.c b/libntfs-3g/logfile.c index af47d7c8..897f880b 100644 --- a/libntfs-3g/logfile.c +++ b/libntfs-3g/logfile.c @@ -682,7 +682,7 @@ BOOL ntfs_is_logfile_clean(ntfs_attr *log_na, RESTART_PAGE_HEADER *rp) * we assume there was an unclean shutdown. */ if (!le16_eq(ra->client_in_use_list, LOGFILE_NO_CLIENT) && - !(ra->flags & RESTART_VOLUME_IS_CLEAN)) { + le16_andz(ra->flags, RESTART_VOLUME_IS_CLEAN)) { ntfs_log_error("The disk contains an unclean file system (%d, " "%d).\n", le16_to_cpu(ra->client_in_use_list), le16_to_cpu(ra->flags)); diff --git a/libntfs-3g/reparse.c b/libntfs-3g/reparse.c index d4111ab5..b0f7c9b4 100644 --- a/libntfs-3g/reparse.c +++ b/libntfs-3g/reparse.c @@ -450,7 +450,7 @@ static BOOL valid_reparse_data(ntfs_inode *ni, offs = le16_to_cpu(mount_point_data->subst_name_offset); lth = le16_to_cpu(mount_point_data->subst_name_length); /* consistency checks */ - if (!(ni->mrec->flags & MFT_RECORD_IS_DIRECTORY) + if (le16_andz(ni->mrec->flags, MFT_RECORD_IS_DIRECTORY) || ((size_t)((sizeof(REPARSE_POINT) + sizeof(struct MOUNT_POINT_REPARSE_DATA) + offs + lth)) > size)) diff --git a/libntfs-3g/security.c b/libntfs-3g/security.c index c49ee9c1..143376c0 100644 --- a/libntfs-3g/security.c +++ b/libntfs-3g/security.c @@ -725,7 +725,7 @@ static le32 entersecurityattr(ntfs_volume *vol, psii = (struct SII*)entry; } if (psii - && !(psii->flags & INDEX_ENTRY_END)) { + && le16_andz(psii->flags, INDEX_ENTRY_END)) { /* save first key and */ /* available position */ keyid = psii->keysecurid; @@ -4927,10 +4927,10 @@ int ntfs_set_file_security(struct SECURITY_API *scapi, /* if selected, owner and group must be present or defaulted */ missing = ((selection & OWNER_SECURITY_INFORMATION) && le32_cmpz(phead->owner) - && !(phead->control & SE_OWNER_DEFAULTED)) + && le16_andz(phead->control, SE_OWNER_DEFAULTED)) || ((selection & GROUP_SECURITY_INFORMATION) && le32_cmpz(phead->group) - && !(phead->control & SE_GROUP_DEFAULTED)); + && le16_andz(phead->control, SE_GROUP_DEFAULTED)); if (!missing && !le16_andz(phead->control, SE_SELF_RELATIVE) && ntfs_valid_descr(attr, attrsz)) { diff --git a/ntfsprogs/mkntfs.c b/ntfsprogs/mkntfs.c index e0305f98..89a0c922 100644 --- a/ntfsprogs/mkntfs.c +++ b/ntfsprogs/mkntfs.c @@ -2506,7 +2506,7 @@ static int upgrade_to_large_index(MFT_RECORD *m, const char *name, ia_val->index.allocated_size = cpu_to_le32(index_block_size - (sizeof(INDEX_ALLOCATION) - sizeof(INDEX_HEADER))); /* Find the last entry in the index root and save it in re. */ - while ((char*)re < re_end && !(re->ie_flags & INDEX_ENTRY_END)) { + while ((char*)re < re_end && le16_andz(re->ie_flags, INDEX_ENTRY_END)) { /* Next entry in index root. */ re = (INDEX_ENTRY*)((char*)re + le16_to_cpu(re->length)); } @@ -2742,7 +2742,7 @@ static int insert_index_entry_in_res_dir_index(INDEX_ENTRY *idx, u32 idx_size, */ if (le32_eq(type, AT_FILE_NAME)) { while (((u8*)idx_entry < (u8*)idx_end) && - !(idx_entry->ie_flags & INDEX_ENTRY_END)) { + le16_andz(idx_entry->ie_flags, INDEX_ENTRY_END)) { /* i = ntfs_file_values_compare(&idx->key.file_name, &idx_entry->key.file_name, 1, @@ -2787,7 +2787,7 @@ do_next: } } else if (le32_eq(type, AT_UNUSED)) { /* case view */ while (((u8*)idx_entry < (u8*)idx_end) && - !(idx_entry->ie_flags & INDEX_ENTRY_END)) { + le16_andz(idx_entry->ie_flags, INDEX_ENTRY_END)) { i = ntfs_index_keys_compare((u8*)idx + 0x10, (u8*)idx_entry + 0x10, le16_to_cpu(idx->key_length), @@ -3036,7 +3036,7 @@ static int insert_file_link_in_dir_index(INDEX_BLOCK *idx, leMFT_REF file_ref, * Loop until we exceed valid memory (corruption case) or until we * reach the last entry. */ - while ((char*)ie < index_end && !(ie->ie_flags & INDEX_ENTRY_END)) { + while ((char*)ie < index_end && le16_andz(ie->ie_flags, INDEX_ENTRY_END)) { #if 0 #ifdef DEBUG ntfs_log_debug("file_name_attr1->file_name_length = %i\n", diff --git a/ntfsprogs/ntfsclone.c b/ntfsprogs/ntfsclone.c index e236634c..850623f6 100644 --- a/ntfsprogs/ntfsclone.c +++ b/ntfsprogs/ntfsclone.c @@ -1086,7 +1086,7 @@ static void wipe_index_entry_timestams(INDEX_ENTRY *e) le64 timestamp = timespec2ntfs(zero_time); /* FIXME: can fall into infinite loop if corrupted */ - while (!(e->ie_flags & INDEX_ENTRY_END)) { + while (le16_andz(e->ie_flags, INDEX_ENTRY_END)) { e->key.file_name.creation_time = timestamp; e->key.file_name.last_data_change_time = timestamp; @@ -1202,7 +1202,7 @@ static void wipe_index_root_timestamps(ATTR_RECORD *attr, le64 timestamp) entry = (INDEX_ENTRY *)((u8 *)iroot + le32_to_cpu(iroot->index.entries_offset) + 0x10); - while (!(entry->ie_flags & INDEX_ENTRY_END)) { + while (le16_andz(entry->ie_flags, INDEX_ENTRY_END)) { if (le32_eq(iroot->type, AT_FILE_NAME)) { @@ -1385,7 +1385,7 @@ static void wipe_mft(char *mrec, u32 mrecsz, u64 mft_no) image.ni = ∋ ntfs_mst_post_read_fixup_warn((NTFS_RECORD*)mrec,mrecsz,FALSE); wipe_unused_mft_data(&ni); - if (!(((MFT_RECORD*)mrec)->flags & MFT_RECORD_IN_USE)) { + if (le16_andz(((MFT_RECORD*)mrec)->flags, MFT_RECORD_IN_USE)) { wipe_unused_mft(&ni); } else { /* ctx with no ntfs_inode prevents from searching external attrs */ @@ -1955,7 +1955,7 @@ static int walk_clusters(ntfs_volume *volume, struct ntfs_walk_cluster *walk) continue; } - deleted_inode = !(ni->mrec->flags & MFT_RECORD_IN_USE); + deleted_inode = le16_andz(ni->mrec->flags, MFT_RECORD_IN_USE); if (deleted_inode && !opt.metadata_image) { diff --git a/ntfsprogs/ntfscp.c b/ntfsprogs/ntfscp.c index a8a875b8..a0ada8ab 100644 --- a/ntfsprogs/ntfscp.c +++ b/ntfsprogs/ntfscp.c @@ -930,7 +930,7 @@ int main(int argc, char *argv[]) dir_ni = ntfs_inode_open(vol, FILE_root); } if (dir_ni) { - if (!(dir_ni->mrec->flags & MFT_RECORD_IS_DIRECTORY)) { + if (le16_andz(dir_ni->mrec->flags, MFT_RECORD_IS_DIRECTORY)) { /* Remove the last '/' for estetic reasons. */ dirname_last_whack[0] = 0; ntfs_log_error("The file '%s' already exists " diff --git a/ntfsprogs/ntfsdecrypt.c b/ntfsprogs/ntfsdecrypt.c index 1de81596..098138ef 100644 --- a/ntfsprogs/ntfsdecrypt.c +++ b/ntfsprogs/ntfsdecrypt.c @@ -1448,7 +1448,7 @@ static int ntfs_feed_encrypt(ntfs_inode *inode, ntfs_fek *fek) } total = 0; - if (!(attr->data_flags & ATTR_IS_ENCRYPTED)) { + if (le16_andz(attr->data_flags, ATTR_IS_ENCRYPTED)) { ntfs_log_error("The data stream was not encrypted\n"); goto rejected; } diff --git a/ntfsprogs/ntfsfix.c b/ntfsprogs/ntfsfix.c index 5954f80c..58edd430 100644 --- a/ntfsprogs/ntfsfix.c +++ b/ntfsprogs/ntfsfix.c @@ -236,7 +236,7 @@ static int OLD_ntfs_volume_set_flags(ntfs_volume *vol, const le16 flags) return -1; } /* Sanity check */ - if (!(m->flags & MFT_RECORD_IN_USE)) { + if (le16_andz(m->flags, MFT_RECORD_IN_USE)) { ntfs_log_error("$Volume has been deleted. Cannot handle this " "yet. Run chkdsk to fix this.\n"); errno = EIO; @@ -516,7 +516,7 @@ static int fix_mftmirr(ntfs_volume *vol) goto error_exit; } /* $MFT is corrupt but $MFTMirr is ok, use $MFTMirr. */ - if (!(mrec->flags & MFT_RECORD_IN_USE) && + if (le16_andz(mrec->flags, MFT_RECORD_IN_USE) && !ntfs_is_mft_record(mrec->magic)) use_mirr = TRUE; } diff --git a/ntfsprogs/ntfsmove.c b/ntfsprogs/ntfsmove.c index 571808fd..06bd262b 100644 --- a/ntfsprogs/ntfsmove.c +++ b/ntfsprogs/ntfsmove.c @@ -901,7 +901,7 @@ int main(int argc, char *argv[]) * This means that the dirty flag is possibly not set, but * should be set. So we explicitly set it with a call to * ntfs_volume_write_flags. */ - if(!(vol->flags & VOLUME_IS_DIRTY) && ntfs_volume_write_flags( + if(le16_andz(vol->flags, VOLUME_IS_DIRTY) && ntfs_volume_write_flags( vol, vol->flags | VOLUME_IS_DIRTY)) { ntfs_log_error("Error: Failed to set volume dirty " "flag (%d (%s))!\n", errno, strerror(errno)); diff --git a/ntfsprogs/ntfsresize.c b/ntfsprogs/ntfsresize.c index 36365dc9..57798fdf 100644 --- a/ntfsprogs/ntfsresize.c +++ b/ntfsprogs/ntfsresize.c @@ -2022,7 +2022,7 @@ static void relocate_inode(ntfs_resize_t *resize, MFT_REF mref, int do_mftdata) perr_exit("ntfs_file_record_record"); } - if (!(resize->mrec->flags & MFT_RECORD_IN_USE)) + if (le16_andz(resize->mrec->flags, MFT_RECORD_IN_USE)) return; resize->mref = mref; diff --git a/ntfsprogs/ntfsundelete.c b/ntfsprogs/ntfsundelete.c index 483c3a7b..443b2a72 100644 --- a/ntfsprogs/ntfsundelete.c +++ b/ntfsprogs/ntfsundelete.c @@ -955,7 +955,7 @@ static FILE_NAME_ATTR* verify_parent(struct filename* name, MFT_RECORD* rec) if (!name || !rec) return NULL; - if (!(rec->flags & MFT_RECORD_IS_DIRECTORY)) { + if (le16_andz(rec->flags, MFT_RECORD_IS_DIRECTORY)) { return NULL; } diff --git a/src/lowntfs-3g.c b/src/lowntfs-3g.c index f5bc98f4..c6cf2fb3 100644 --- a/src/lowntfs-3g.c +++ b/src/lowntfs-3g.c @@ -1271,7 +1271,7 @@ static void ntfs_fuse_open(fuse_req_t req, fuse_ino_t ino, #ifdef HAVE_SETXATTR /* extended attributes interface required */ /* mark a future need to fixup encrypted inode */ if (ctx->efs_raw - && !(na->data_flags & ATTR_IS_ENCRYPTED) + && le16_andz(na->data_flags, ATTR_IS_ENCRYPTED) && (ni->flags & FILE_ATTR_ENCRYPTED)) state |= CLOSE_ENCRYPTED; #endif /* HAVE_SETXATTR */ diff --git a/src/ntfs-3g.c b/src/ntfs-3g.c index 9c591f72..b82fe843 100644 --- a/src/ntfs-3g.c +++ b/src/ntfs-3g.c @@ -1208,7 +1208,7 @@ static int ntfs_fuse_open(const char *org_path, #ifdef HAVE_SETXATTR /* extended attributes interface required */ /* mark a future need to fixup encrypted inode */ if (ctx->efs_raw - && !(na->data_flags & ATTR_IS_ENCRYPTED) + && le16_andz(na->data_flags, ATTR_IS_ENCRYPTED) && (ni->flags & FILE_ATTR_ENCRYPTED)) fi->fh |= CLOSE_ENCRYPTED; #endif /* HAVE_SETXATTR */