Replace all le32 non-zero "and" test conditions with !le32_andz(...).

edge.strict_endians
Erik Larsson 2016-01-28 08:28:48 +01:00
parent 1b7bfaa133
commit 9f5ad52e5f
14 changed files with 119 additions and 117 deletions

View File

@ -322,4 +322,6 @@
#define le16_andz(a, b) (!((a) & (b))) #define le16_andz(a, b) (!((a) & (b)))
#define le32_andz(a, b) (!((a) & (b)))
#endif /* defined _NTFS_ENDIANS_H */ #endif /* defined _NTFS_ENDIANS_H */

View File

@ -766,15 +766,15 @@ int ntfs_inherit_acl(const ACL *oldacl, ACL *newacl,
if ((poldace->flags & selection) if ((poldace->flags & selection)
&& (!fordir && (!fordir
|| (poldace->flags & NO_PROPAGATE_INHERIT_ACE) || (poldace->flags & NO_PROPAGATE_INHERIT_ACE)
|| (poldace->mask & (GENERIC_ALL | GENERIC_READ || !le32_andz(poldace->mask, GENERIC_ALL | GENERIC_READ
| GENERIC_WRITE | GENERIC_EXECUTE))) | GENERIC_WRITE | GENERIC_EXECUTE))
&& !ntfs_same_sid(&poldace->sid, ownersid) && !ntfs_same_sid(&poldace->sid, ownersid)
&& !ntfs_same_sid(&poldace->sid, groupsid)) { && !ntfs_same_sid(&poldace->sid, groupsid)) {
pnewace = (ACCESS_ALLOWED_ACE*) pnewace = (ACCESS_ALLOWED_ACE*)
((char*)newacl + dst); ((char*)newacl + dst);
memcpy(pnewace,poldace,acesz); memcpy(pnewace,poldace,acesz);
/* reencode GENERIC_ALL */ /* reencode GENERIC_ALL */
if (pnewace->mask & GENERIC_ALL) { if (!le32_andz(pnewace->mask, GENERIC_ALL)) {
pnewace->mask &= ~GENERIC_ALL; pnewace->mask &= ~GENERIC_ALL;
if (fordir) if (fordir)
pnewace->mask |= OWNER_RIGHTS pnewace->mask |= OWNER_RIGHTS
@ -793,7 +793,7 @@ int ntfs_inherit_acl(const ACL *oldacl, ACL *newacl,
| const_cpu_to_le32(0x40); | const_cpu_to_le32(0x40);
} }
/* reencode GENERIC_READ (+ EXECUTE) */ /* reencode GENERIC_READ (+ EXECUTE) */
if (pnewace->mask & GENERIC_READ) { if (!le32_andz(pnewace->mask, GENERIC_READ)) {
if (fordir) if (fordir)
pnewace->mask |= OWNER_RIGHTS pnewace->mask |= OWNER_RIGHTS
| DIR_READ | DIR_READ
@ -810,7 +810,7 @@ int ntfs_inherit_acl(const ACL *oldacl, ACL *newacl,
| FILE_WRITE_ATTRIBUTES); | FILE_WRITE_ATTRIBUTES);
} }
/* reencode GENERIC_WRITE */ /* reencode GENERIC_WRITE */
if (pnewace->mask & GENERIC_WRITE) { if (!le32_andz(pnewace->mask, GENERIC_WRITE)) {
if (fordir) if (fordir)
pnewace->mask |= OWNER_RIGHTS pnewace->mask |= OWNER_RIGHTS
| DIR_WRITE; | DIR_WRITE;
@ -916,8 +916,8 @@ int ntfs_inherit_acl(const ACL *oldacl, ACL *newacl,
&& !(poldace->flags & NO_PROPAGATE_INHERIT_ACE) && !(poldace->flags & NO_PROPAGATE_INHERIT_ACE)
&& !ntfs_same_sid(&poldace->sid, ownersid) && !ntfs_same_sid(&poldace->sid, ownersid)
&& !ntfs_same_sid(&poldace->sid, groupsid)) { && !ntfs_same_sid(&poldace->sid, groupsid)) {
if ((poldace->mask & (GENERIC_ALL | GENERIC_READ if (!le32_andz(poldace->mask, GENERIC_ALL | GENERIC_READ
| GENERIC_WRITE | GENERIC_EXECUTE))) | GENERIC_WRITE | GENERIC_EXECUTE))
pnewace->flags |= INHERIT_ONLY_ACE; pnewace->flags |= INHERIT_ONLY_ACE;
else else
pnewace->flags &= ~INHERIT_ONLY_ACE; pnewace->flags &= ~INHERIT_ONLY_ACE;
@ -2938,23 +2938,23 @@ static int merge_permissions(BOOL isdir,
if (!le32_cmpz(owner)) { if (!le32_cmpz(owner)) {
if (isdir) { if (isdir) {
/* exec if any of list, traverse */ /* exec if any of list, traverse */
if (owner & DIR_GEXEC) if (!le32_andz(owner, DIR_GEXEC))
perm |= S_IXUSR; perm |= S_IXUSR;
/* write if any of addfile, adddir, delchild */ /* write if any of addfile, adddir, delchild */
if (owner & DIR_GWRITE) if (!le32_andz(owner, DIR_GWRITE))
perm |= S_IWUSR; perm |= S_IWUSR;
/* read if any of list */ /* read if any of list */
if (owner & DIR_GREAD) if (!le32_andz(owner, DIR_GREAD))
perm |= S_IRUSR; perm |= S_IRUSR;
} else { } else {
/* exec if execute or generic execute */ /* exec if execute or generic execute */
if (owner & FILE_GEXEC) if (!le32_andz(owner, FILE_GEXEC))
perm |= S_IXUSR; perm |= S_IXUSR;
/* write if any of writedata or generic write */ /* write if any of writedata or generic write */
if (owner & FILE_GWRITE) if (!le32_andz(owner, FILE_GWRITE))
perm |= S_IWUSR; perm |= S_IWUSR;
/* read if any of readdata or generic read */ /* read if any of readdata or generic read */
if (owner & FILE_GREAD) if (!le32_andz(owner, FILE_GREAD))
perm |= S_IRUSR; perm |= S_IRUSR;
} }
} }
@ -2962,23 +2962,23 @@ static int merge_permissions(BOOL isdir,
if (!le32_cmpz(group)) { if (!le32_cmpz(group)) {
if (isdir) { if (isdir) {
/* exec if any of list, traverse */ /* exec if any of list, traverse */
if (group & DIR_GEXEC) if (!le32_andz(group, DIR_GEXEC))
perm |= S_IXGRP; perm |= S_IXGRP;
/* write if any of addfile, adddir, delchild */ /* write if any of addfile, adddir, delchild */
if (group & DIR_GWRITE) if (!le32_andz(group, DIR_GWRITE))
perm |= S_IWGRP; perm |= S_IWGRP;
/* read if any of list */ /* read if any of list */
if (group & DIR_GREAD) if (!le32_andz(group, DIR_GREAD))
perm |= S_IRGRP; perm |= S_IRGRP;
} else { } else {
/* exec if execute */ /* exec if execute */
if (group & FILE_GEXEC) if (!le32_andz(group, FILE_GEXEC))
perm |= S_IXGRP; perm |= S_IXGRP;
/* write if any of writedata, appenddata */ /* write if any of writedata, appenddata */
if (group & FILE_GWRITE) if (!le32_andz(group, FILE_GWRITE))
perm |= S_IWGRP; perm |= S_IWGRP;
/* read if any of readdata */ /* read if any of readdata */
if (group & FILE_GREAD) if (!le32_andz(group, FILE_GREAD))
perm |= S_IRGRP; perm |= S_IRGRP;
} }
} }
@ -2986,33 +2986,33 @@ static int merge_permissions(BOOL isdir,
if (!le32_cmpz(world)) { if (!le32_cmpz(world)) {
if (isdir) { if (isdir) {
/* exec if any of list, traverse */ /* exec if any of list, traverse */
if (world & DIR_GEXEC) if (!le32_andz(world, DIR_GEXEC))
perm |= S_IXOTH; perm |= S_IXOTH;
/* write if any of addfile, adddir, delchild */ /* write if any of addfile, adddir, delchild */
if (world & DIR_GWRITE) if (!le32_andz(world, DIR_GWRITE))
perm |= S_IWOTH; perm |= S_IWOTH;
/* read if any of list */ /* read if any of list */
if (world & DIR_GREAD) if (!le32_andz(world, DIR_GREAD))
perm |= S_IROTH; perm |= S_IROTH;
} else { } else {
/* exec if execute */ /* exec if execute */
if (world & FILE_GEXEC) if (!le32_andz(world, FILE_GEXEC))
perm |= S_IXOTH; perm |= S_IXOTH;
/* write if any of writedata, appenddata */ /* write if any of writedata, appenddata */
if (world & FILE_GWRITE) if (!le32_andz(world, FILE_GWRITE))
perm |= S_IWOTH; perm |= S_IWOTH;
/* read if any of readdata */ /* read if any of readdata */
if (world & FILE_GREAD) if (!le32_andz(world, FILE_GREAD))
perm |= S_IROTH; perm |= S_IROTH;
} }
} }
/* build special permission flags */ /* build special permission flags */
if (!le32_cmpz(special)) { if (!le32_cmpz(special)) {
if (special & FILE_APPEND_DATA) if (!le32_andz(special, FILE_APPEND_DATA))
perm |= S_ISUID; perm |= S_ISUID;
if (special & FILE_WRITE_DATA) if (!le32_andz(special, FILE_WRITE_DATA))
perm |= S_ISGID; perm |= S_ISGID;
if (special & FILE_READ_DATA) if (!le32_andz(special, FILE_READ_DATA))
perm |= S_ISVTX; perm |= S_ISVTX;
} }
return (perm); return (perm);
@ -3306,7 +3306,7 @@ static int build_owngrp_permissions(const char *securattr,
if (!(pace->flags & INHERIT_ONLY_ACE)) { if (!(pace->flags & INHERIT_ONLY_ACE)) {
if ((ntfs_same_sid(usid, &pace->sid) if ((ntfs_same_sid(usid, &pace->sid)
|| ntfs_same_sid(ownersid, &pace->sid)) || ntfs_same_sid(ownersid, &pace->sid))
&& (pace->mask & WRITE_OWNER)) { && !le32_andz(pace->mask, WRITE_OWNER)) {
if (pace->type == ACCESS_ALLOWED_ACE_TYPE) { if (pace->type == ACCESS_ALLOWED_ACE_TYPE) {
allowown |= pace->mask; allowown |= pace->mask;
ownpresent = TRUE; ownpresent = TRUE;
@ -3497,7 +3497,7 @@ static int build_ownadmin_permissions(const char *securattr,
&& !(~pace->mask & (ROOT_OWNER_UNMARK | ROOT_GROUP_UNMARK))) { && !(~pace->mask & (ROOT_OWNER_UNMARK | ROOT_GROUP_UNMARK))) {
if ((ntfs_same_sid(usid, &pace->sid) if ((ntfs_same_sid(usid, &pace->sid)
|| ntfs_same_sid(ownersid, &pace->sid)) || ntfs_same_sid(ownersid, &pace->sid))
&& (((pace->mask & WRITE_OWNER) && firstapply))) { && ((!le32_andz(pace->mask, WRITE_OWNER) && firstapply))) {
if (pace->type == ACCESS_ALLOWED_ACE_TYPE) { if (pace->type == ACCESS_ALLOWED_ACE_TYPE) {
allowown |= pace->mask; allowown |= pace->mask;
isforeign &= ~1; isforeign &= ~1;
@ -3576,7 +3576,7 @@ const SID *ntfs_acl_owner(const char *securattr)
nace = 0; nace = 0;
do { do {
pace = (const ACCESS_ALLOWED_ACE*)&securattr[offace]; pace = (const ACCESS_ALLOWED_ACE*)&securattr[offace];
if ((pace->mask & WRITE_OWNER) if (!le32_andz(pace->mask, WRITE_OWNER)
&& (pace->type == ACCESS_ALLOWED_ACE_TYPE) && (pace->type == ACCESS_ALLOWED_ACE_TYPE)
&& ntfs_is_user_sid(&pace->sid)) && ntfs_is_user_sid(&pace->sid))
found = TRUE; found = TRUE;

View File

@ -86,7 +86,7 @@ ntfschar TXF_DATA[] = { const_cpu_to_le16('$'),
static int NAttrFlag(ntfs_attr *na, FILE_ATTR_FLAGS flag) static int NAttrFlag(ntfs_attr *na, FILE_ATTR_FLAGS flag)
{ {
if (le32_eq(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 !le32_andz(na->ni->flags, flag);
return 0; return 0;
} }
@ -468,7 +468,7 @@ ntfs_attr *ntfs_attr_open(ntfs_inode *ni, const ATTR_TYPES type,
* or cluster size > 4K or compression is disabled * or cluster size > 4K or compression is disabled
*/ */
a->flags &= ~ATTR_COMPRESSION_MASK; a->flags &= ~ATTR_COMPRESSION_MASK;
if ((ni->flags & FILE_ATTR_COMPRESSED) if (!le32_andz(ni->flags, FILE_ATTR_COMPRESSED)
&& (ni->vol->major_ver >= 3) && (ni->vol->major_ver >= 3)
&& NVolCompression(ni->vol) && NVolCompression(ni->vol)
&& (ni->vol->cluster_size <= MAX_COMPRESSION_CLUSTER_SIZE)) && (ni->vol->cluster_size <= MAX_COMPRESSION_CLUSTER_SIZE))
@ -4296,7 +4296,7 @@ int ntfs_attr_add(ntfs_inode *ni, ATTR_TYPES type,
} }
add_attr_record: add_attr_record:
if ((ni->flags & FILE_ATTR_COMPRESSED) if (!le32_andz(ni->flags, FILE_ATTR_COMPRESSED)
&& (ni->vol->major_ver >= 3) && (ni->vol->major_ver >= 3)
&& NVolCompression(ni->vol) && NVolCompression(ni->vol)
&& (ni->vol->cluster_size <= MAX_COMPRESSION_CLUSTER_SIZE) && (ni->vol->cluster_size <= MAX_COMPRESSION_CLUSTER_SIZE)
@ -4843,7 +4843,7 @@ int ntfs_attr_make_non_resident(ntfs_attr *na,
goto cluster_free_err_out; goto cluster_free_err_out;
} }
/* Calculate new offsets for the name and the mapping pairs array. */ /* Calculate new offsets for the name and the mapping pairs array. */
if (na->ni->flags & FILE_ATTR_COMPRESSED) if (!le32_andz(na->ni->flags, FILE_ATTR_COMPRESSED))
name_ofs = (sizeof(ATTR_REC) + 7) & ~7; name_ofs = (sizeof(ATTR_REC) + 7) & ~7;
else else
name_ofs = (sizeof(ATTR_REC) - sizeof(a->compressed_size) + 7) & ~7; name_ofs = (sizeof(ATTR_REC) - sizeof(a->compressed_size) + 7) & ~7;
@ -5349,7 +5349,7 @@ static int ntfs_attr_make_resident(ntfs_attr *na, ntfs_attr_search_ctx *ctx)
&& (na->ni->vol->major_ver >= 3) && (na->ni->vol->major_ver >= 3)
&& NVolCompression(na->ni->vol) && NVolCompression(na->ni->vol)
&& (na->ni->vol->cluster_size <= MAX_COMPRESSION_CLUSTER_SIZE) && (na->ni->vol->cluster_size <= MAX_COMPRESSION_CLUSTER_SIZE)
&& (na->ni->flags & FILE_ATTR_COMPRESSED)) { && !le32_andz(na->ni->flags, FILE_ATTR_COMPRESSED)) {
a->flags |= ATTR_IS_COMPRESSED; a->flags |= ATTR_IS_COMPRESSED;
na->data_flags = a->flags; na->data_flags = a->flags;
} }

View File

@ -925,16 +925,16 @@ static u32 ntfs_dir_entry_type(ntfs_inode *dir_ni, MFT_REF mref,
dt_type = NTFS_DT_UNKNOWN; dt_type = NTFS_DT_UNKNOWN;
ni = ntfs_inode_open(dir_ni->vol, mref); ni = ntfs_inode_open(dir_ni->vol, mref);
if (ni) { if (ni) {
if ((attributes & FILE_ATTR_REPARSE_POINT) if (!le32_andz(attributes, FILE_ATTR_REPARSE_POINT)
&& ntfs_possible_symlink(ni)) && ntfs_possible_symlink(ni))
dt_type = NTFS_DT_LNK; dt_type = NTFS_DT_LNK;
else else
if ((attributes & FILE_ATTR_SYSTEM) if (!le32_andz(attributes, FILE_ATTR_SYSTEM)
&& !(attributes & FILE_ATTR_I30_INDEX_PRESENT)) && !(attributes & FILE_ATTR_I30_INDEX_PRESENT))
dt_type = ntfs_interix_types(ni); dt_type = ntfs_interix_types(ni);
else else
dt_type = (attributes dt_type = (!le32_andz(attributes,
& FILE_ATTR_I30_INDEX_PRESENT FILE_ATTR_I30_INDEX_PRESENT)
? NTFS_DT_DIR : NTFS_DT_REG); ? NTFS_DT_DIR : NTFS_DT_REG);
if (ntfs_inode_close(ni)) { if (ntfs_inode_close(ni)) {
/* anything special worth doing ? */ /* anything special worth doing ? */
@ -987,13 +987,13 @@ static int ntfs_filldir(ntfs_inode *dir_ni, s64 *pos, u8 ivcn_bits,
/* Skip root directory self reference entry. */ /* Skip root directory self reference entry. */
if (MREF_LE(ie->indexed_file) == FILE_root) if (MREF_LE(ie->indexed_file) == FILE_root)
return 0; return 0;
if ((ie->key.file_name.file_attributes if (!le32_andz(ie->key.file_name.file_attributes,
& (FILE_ATTR_REPARSE_POINT | FILE_ATTR_SYSTEM)) FILE_ATTR_REPARSE_POINT | FILE_ATTR_SYSTEM)
&& !metadata) && !metadata)
dt_type = ntfs_dir_entry_type(dir_ni, mref, dt_type = ntfs_dir_entry_type(dir_ni, mref,
ie->key.file_name.file_attributes); ie->key.file_name.file_attributes);
else if (ie->key.file_name.file_attributes else if (!le32_andz(ie->key.file_name.file_attributes,
& FILE_ATTR_I30_INDEX_PRESENT) FILE_ATTR_I30_INDEX_PRESENT))
dt_type = NTFS_DT_DIR; dt_type = NTFS_DT_DIR;
else else
dt_type = NTFS_DT_REG; dt_type = NTFS_DT_REG;
@ -1500,7 +1500,7 @@ static ntfs_inode *__ntfs_create(ntfs_inode *dir_ni, le32 securid,
return NULL; return NULL;
} }
if (dir_ni->flags & FILE_ATTR_REPARSE_POINT) { if (!le32_andz(dir_ni->flags, FILE_ATTR_REPARSE_POINT)) {
errno = EOPNOTSUPP; errno = EOPNOTSUPP;
return NULL; return NULL;
} }
@ -1552,7 +1552,7 @@ static ntfs_inode *__ntfs_create(ntfs_inode *dir_ni, le32 securid,
* unless NTFS version < 3.0 or cluster size > 4K * unless NTFS version < 3.0 or cluster size > 4K
* or compression has been disabled * or compression has been disabled
*/ */
if ((dir_ni->flags & FILE_ATTR_COMPRESSED) if (!le32_andz(dir_ni->flags, FILE_ATTR_COMPRESSED)
&& (dir_ni->vol->major_ver >= 3) && (dir_ni->vol->major_ver >= 3)
&& NVolCompression(dir_ni->vol) && NVolCompression(dir_ni->vol)
&& (dir_ni->vol->cluster_size <= MAX_COMPRESSION_CLUSTER_SIZE) && (dir_ni->vol->cluster_size <= MAX_COMPRESSION_CLUSTER_SIZE)
@ -2157,7 +2157,7 @@ static int ntfs_link_i(ntfs_inode *ni, ntfs_inode *dir_ni, const ntfschar *name,
goto err_out; goto err_out;
} }
if ((ni->flags & FILE_ATTR_REPARSE_POINT) if (!le32_andz(ni->flags, FILE_ATTR_REPARSE_POINT)
&& !ntfs_possible_symlink(ni)) { && !ntfs_possible_symlink(ni)) {
err = EOPNOTSUPP; err = EOPNOTSUPP;
goto err_out; goto err_out;

View File

@ -79,7 +79,7 @@ int ntfs_get_efs_info(ntfs_inode *ni, char *value, size_t size)
s64 attr_size = 0; s64 attr_size = 0;
if (ni) { if (ni) {
if (ni->flags & FILE_ATTR_ENCRYPTED) { if (!le32_andz(ni->flags, FILE_ATTR_ENCRYPTED)) {
efs_info = (EFS_ATTR_HEADER*)ntfs_attr_readall(ni, efs_info = (EFS_ATTR_HEADER*)ntfs_attr_readall(ni,
AT_LOGGED_UTILITY_STREAM,(ntfschar*)NULL, 0, AT_LOGGED_UTILITY_STREAM,(ntfschar*)NULL, 0,
&attr_size); &attr_size);
@ -222,8 +222,8 @@ int ntfs_set_efs_info(ntfs_inode *ni, const char *value, size_t size,
res = 0; res = 0;
if (ni && value && size) { if (ni && value && size) {
if (ni->flags & (FILE_ATTR_ENCRYPTED | FILE_ATTR_COMPRESSED)) { if (!le32_andz(ni->flags, FILE_ATTR_ENCRYPTED | FILE_ATTR_COMPRESSED)) {
if (ni->flags & FILE_ATTR_ENCRYPTED) { if (!le32_andz(ni->flags, FILE_ATTR_ENCRYPTED)) {
ntfs_log_trace("Inode %lld already encrypted\n", ntfs_log_trace("Inode %lld already encrypted\n",
(long long)ni->mft_no); (long long)ni->mft_no);
errno = EEXIST; errno = EEXIST;

View File

@ -1857,7 +1857,7 @@ int ntfs_index_remove(ntfs_inode *dir_ni, ntfs_inode *ni,
if (ntfs_index_lookup(key, keylen, icx)) if (ntfs_index_lookup(key, keylen, icx))
goto err_out; goto err_out;
if ((((FILE_NAME_ATTR *)icx->data)->file_attributes & if (!le32_andz(((FILE_NAME_ATTR *)icx->data)->file_attributes,
FILE_ATTR_REPARSE_POINT) FILE_ATTR_REPARSE_POINT)
&& !ntfs_possible_symlink(ni)) { && !ntfs_possible_symlink(ni)) {
errno = EOPNOTSUPP; errno = EOPNOTSUPP;

View File

@ -807,7 +807,7 @@ static int ntfs_inode_sync_file_name(ntfs_inode *ni, ntfs_inode *dir_ni)
} }
/* Collect the reparse tag, if any */ /* Collect the reparse tag, if any */
reparse_tag = cpu_to_le32(0); reparse_tag = cpu_to_le32(0);
if (ni->flags & FILE_ATTR_REPARSE_POINT) { if (!le32_andz(ni->flags, FILE_ATTR_REPARSE_POINT)) {
if (!ntfs_attr_lookup(AT_REPARSE_POINT, NULL, if (!ntfs_attr_lookup(AT_REPARSE_POINT, NULL,
0, CASE_SENSITIVE, 0, NULL, 0, ctx)) { 0, CASE_SENSITIVE, 0, NULL, 0, ctx)) {
rpp = (REPARSE_POINT*)((u8 *)ctx->attr + rpp = (REPARSE_POINT*)((u8 *)ctx->attr +

View File

@ -257,7 +257,7 @@ static char *search_absolute(ntfs_volume *vol, ntfschar *path,
&& (start < count)); && (start < count));
if (ni if (ni
&& ((!le16_andz(ni->mrec->flags, MFT_RECORD_IS_DIRECTORY) ? isdir : !isdir) && ((!le16_andz(ni->mrec->flags, MFT_RECORD_IS_DIRECTORY) ? isdir : !isdir)
|| (ni->flags & FILE_ATTR_REPARSE_POINT))) || (!le32_andz(ni->flags, FILE_ATTR_REPARSE_POINT))))
if (ntfs_ucstombs(path, count, &target, 0) < 0) { if (ntfs_ucstombs(path, count, &target, 0) < 0) {
if (target) { if (target) {
free(target); free(target);
@ -347,7 +347,7 @@ static char *search_relative(ntfs_inode *ni, ntfschar *path, int count)
if (!curni) if (!curni)
ok = FALSE; ok = FALSE;
else { else {
if (curni->flags & FILE_ATTR_REPARSE_POINT) if (!le32_andz(curni->flags, FILE_ATTR_REPARSE_POINT))
morelinks = TRUE; morelinks = TRUE;
if (ok && ((pos + lth) < count)) { if (ok && ((pos + lth) < count)) {
path[pos + lth] = const_cpu_to_le16('/'); path[pos + lth] = const_cpu_to_le16('/');
@ -786,8 +786,8 @@ char *ntfs_make_symlink(ntfs_inode *ni, const char *mnt_point,
} }
break; break;
case ABS_TARGET : case ABS_TARGET :
if (symlink_data->flags if (!le32_andz(symlink_data->flags,
& const_cpu_to_le32(1)) { const_cpu_to_le32(1))) {
target = ntfs_get_abslink(vol, target = ntfs_get_abslink(vol,
p, lth/2, p, lth/2,
mnt_point, isdir); mnt_point, isdir);
@ -796,8 +796,8 @@ char *ntfs_make_symlink(ntfs_inode *ni, const char *mnt_point,
} }
break; break;
case REL_TARGET : case REL_TARGET :
if (symlink_data->flags if (!le32_andz(symlink_data->flags,
& const_cpu_to_le32(1)) { const_cpu_to_le32(1))) {
target = ntfs_get_rellink(ni, target = ntfs_get_rellink(ni,
p, lth/2); p, lth/2);
if (target) if (target)
@ -1081,7 +1081,7 @@ int ntfs_get_ntfs_reparse_data(ntfs_inode *ni, char *value, size_t size)
attr_size = 0; /* default to no data and no error */ attr_size = 0; /* default to no data and no error */
if (ni) { if (ni) {
if (ni->flags & FILE_ATTR_REPARSE_POINT) { if (!le32_andz(ni->flags, FILE_ATTR_REPARSE_POINT)) {
reparse_attr = (REPARSE_POINT*)ntfs_attr_readall(ni, reparse_attr = (REPARSE_POINT*)ntfs_attr_readall(ni,
AT_REPARSE_POINT,(ntfschar*)NULL, 0, &attr_size); AT_REPARSE_POINT,(ntfschar*)NULL, 0, &attr_size);
if (reparse_attr) { if (reparse_attr) {

View File

@ -4435,9 +4435,9 @@ int ntfs_set_ntfs_attrib(ntfs_inode *ni,
* and set index root accordingly * and set index root accordingly
*/ */
settable |= FILE_ATTR_COMPRESSED; settable |= FILE_ATTR_COMPRESSED;
if ((ni->flags ^ cpu_to_le32(attrib)) if (!le32_andz(ni->flags ^ cpu_to_le32(attrib),
& FILE_ATTR_COMPRESSED) { FILE_ATTR_COMPRESSED)) {
if (ni->flags & FILE_ATTR_COMPRESSED) if (!le32_andz(ni->flags, FILE_ATTR_COMPRESSED))
dirflags = const_cpu_to_le16(0); dirflags = const_cpu_to_le16(0);
else else
dirflags = ATTR_IS_COMPRESSED; dirflags = ATTR_IS_COMPRESSED;
@ -5040,9 +5040,9 @@ BOOL ntfs_set_file_attributes(struct SECURITY_API *scapi,
* and set index root accordingly * and set index root accordingly
*/ */
settable |= FILE_ATTR_COMPRESSED; settable |= FILE_ATTR_COMPRESSED;
if ((ni->flags ^ cpu_to_le32(attrib)) if (!le32_andz(ni->flags ^ cpu_to_le32(attrib),
& FILE_ATTR_COMPRESSED) { FILE_ATTR_COMPRESSED)) {
if (ni->flags & FILE_ATTR_COMPRESSED) if (!le32_andz(ni->flags, FILE_ATTR_COMPRESSED))
dirflags = const_cpu_to_le16(0); dirflags = const_cpu_to_le16(0);
else else
dirflags = ATTR_IS_COMPRESSED; dirflags = ATTR_IS_COMPRESSED;

View File

@ -514,71 +514,71 @@ static void ntfs_dump_flags(const char *indent, ATTR_TYPES type, le32 flags)
const le32 original_flags = flags; const le32 original_flags = flags;
printf("%sFile attributes:\t", indent); printf("%sFile attributes:\t", indent);
if (flags & FILE_ATTR_READONLY) { if (!le32_andz(flags, FILE_ATTR_READONLY)) {
printf(" READONLY"); printf(" READONLY");
flags &= ~FILE_ATTR_READONLY; flags &= ~FILE_ATTR_READONLY;
} }
if (flags & FILE_ATTR_HIDDEN) { if (!le32_andz(flags, FILE_ATTR_HIDDEN)) {
printf(" HIDDEN"); printf(" HIDDEN");
flags &= ~FILE_ATTR_HIDDEN; flags &= ~FILE_ATTR_HIDDEN;
} }
if (flags & FILE_ATTR_SYSTEM) { if (!le32_andz(flags, FILE_ATTR_SYSTEM)) {
printf(" SYSTEM"); printf(" SYSTEM");
flags &= ~FILE_ATTR_SYSTEM; flags &= ~FILE_ATTR_SYSTEM;
} }
if (flags & FILE_ATTR_DIRECTORY) { if (!le32_andz(flags, FILE_ATTR_DIRECTORY)) {
printf(" DIRECTORY"); printf(" DIRECTORY");
flags &= ~FILE_ATTR_DIRECTORY; flags &= ~FILE_ATTR_DIRECTORY;
} }
if (flags & FILE_ATTR_ARCHIVE) { if (!le32_andz(flags, FILE_ATTR_ARCHIVE)) {
printf(" ARCHIVE"); printf(" ARCHIVE");
flags &= ~FILE_ATTR_ARCHIVE; flags &= ~FILE_ATTR_ARCHIVE;
} }
if (flags & FILE_ATTR_DEVICE) { if (!le32_andz(flags, FILE_ATTR_DEVICE)) {
printf(" DEVICE"); printf(" DEVICE");
flags &= ~FILE_ATTR_DEVICE; flags &= ~FILE_ATTR_DEVICE;
} }
if (flags & FILE_ATTR_NORMAL) { if (!le32_andz(flags, FILE_ATTR_NORMAL)) {
printf(" NORMAL"); printf(" NORMAL");
flags &= ~FILE_ATTR_NORMAL; flags &= ~FILE_ATTR_NORMAL;
} }
if (flags & FILE_ATTR_TEMPORARY) { if (!le32_andz(flags, FILE_ATTR_TEMPORARY)) {
printf(" TEMPORARY"); printf(" TEMPORARY");
flags &= ~FILE_ATTR_TEMPORARY; flags &= ~FILE_ATTR_TEMPORARY;
} }
if (flags & FILE_ATTR_SPARSE_FILE) { if (!le32_andz(flags, FILE_ATTR_SPARSE_FILE)) {
printf(" SPARSE_FILE"); printf(" SPARSE_FILE");
flags &= ~FILE_ATTR_SPARSE_FILE; flags &= ~FILE_ATTR_SPARSE_FILE;
} }
if (flags & FILE_ATTR_REPARSE_POINT) { if (!le32_andz(flags, FILE_ATTR_REPARSE_POINT)) {
printf(" REPARSE_POINT"); printf(" REPARSE_POINT");
flags &= ~FILE_ATTR_REPARSE_POINT; flags &= ~FILE_ATTR_REPARSE_POINT;
} }
if (flags & FILE_ATTR_COMPRESSED) { if (!le32_andz(flags, FILE_ATTR_COMPRESSED)) {
printf(" COMPRESSED"); printf(" COMPRESSED");
flags &= ~FILE_ATTR_COMPRESSED; flags &= ~FILE_ATTR_COMPRESSED;
} }
if (flags & FILE_ATTR_OFFLINE) { if (!le32_andz(flags, FILE_ATTR_OFFLINE)) {
printf(" OFFLINE"); printf(" OFFLINE");
flags &= ~FILE_ATTR_OFFLINE; flags &= ~FILE_ATTR_OFFLINE;
} }
if (flags & FILE_ATTR_NOT_CONTENT_INDEXED) { if (!le32_andz(flags, FILE_ATTR_NOT_CONTENT_INDEXED)) {
printf(" NOT_CONTENT_INDEXED"); printf(" NOT_CONTENT_INDEXED");
flags &= ~FILE_ATTR_NOT_CONTENT_INDEXED; flags &= ~FILE_ATTR_NOT_CONTENT_INDEXED;
} }
if (flags & FILE_ATTR_ENCRYPTED) { if (!le32_andz(flags, FILE_ATTR_ENCRYPTED)) {
printf(" ENCRYPTED"); printf(" ENCRYPTED");
flags &= ~FILE_ATTR_ENCRYPTED; flags &= ~FILE_ATTR_ENCRYPTED;
} }
/* We know that FILE_ATTR_I30_INDEX_PRESENT only exists on $FILE_NAME, /* We know that FILE_ATTR_I30_INDEX_PRESENT only exists on $FILE_NAME,
and in case we are wrong, let it appear as UNKNOWN */ and in case we are wrong, let it appear as UNKNOWN */
if (le32_eq(type, AT_FILE_NAME)) { if (le32_eq(type, AT_FILE_NAME)) {
if (flags & FILE_ATTR_I30_INDEX_PRESENT) { if (!le32_andz(flags, FILE_ATTR_I30_INDEX_PRESENT)) {
printf(" I30_INDEX"); printf(" I30_INDEX");
flags &= ~FILE_ATTR_I30_INDEX_PRESENT; flags &= ~FILE_ATTR_I30_INDEX_PRESENT;
} }
} }
if (flags & FILE_ATTR_VIEW_INDEX_PRESENT) { if (!le32_andz(flags, FILE_ATTR_VIEW_INDEX_PRESENT)) {
printf(" VIEW_INDEX"); printf(" VIEW_INDEX");
flags &= ~FILE_ATTR_VIEW_INDEX_PRESENT; flags &= ~FILE_ATTR_VIEW_INDEX_PRESENT;
} }
@ -812,7 +812,7 @@ static void ntfs_dump_filename(const char *indent,
(unsigned)file_name_attr->file_name_length, (unsigned)file_name_attr->file_name_length,
(unsigned)file_name_attr->file_name_length); (unsigned)file_name_attr->file_name_length);
ntfs_dump_flags(indent, AT_FILE_NAME, file_name_attr->file_attributes); ntfs_dump_flags(indent, AT_FILE_NAME, file_name_attr->file_attributes);
if (file_name_attr->file_attributes & FILE_ATTR_REPARSE_POINT && if (!le32_andz(file_name_attr->file_attributes, FILE_ATTR_REPARSE_POINT) &&
!le32_cmpz(file_name_attr->reparse_point_tag)) !le32_cmpz(file_name_attr->reparse_point_tag))
printf("%sReparse point tag:\t 0x%x\n", indent, (unsigned) printf("%sReparse point tag:\t 0x%x\n", indent, (unsigned)
le32_to_cpu(file_name_attr->reparse_point_tag)); le32_to_cpu(file_name_attr->reparse_point_tag));

View File

@ -1578,17 +1578,17 @@ static void dump_record(struct ufile *file)
ntfs_log_quiet("Filename: (%d) %s\n", f->name_space, f->name); ntfs_log_quiet("Filename: (%d) %s\n", f->name_space, f->name);
ntfs_log_quiet("File Flags: "); ntfs_log_quiet("File Flags: ");
if (f->flags & FILE_ATTR_SYSTEM) if (!le32_andz(f->flags, FILE_ATTR_SYSTEM))
ntfs_log_quiet("System "); ntfs_log_quiet("System ");
if (f->flags & FILE_ATTR_DIRECTORY) if (!le32_andz(f->flags, FILE_ATTR_DIRECTORY))
ntfs_log_quiet("Directory "); ntfs_log_quiet("Directory ");
if (f->flags & FILE_ATTR_SPARSE_FILE) if (!le32_andz(f->flags, FILE_ATTR_SPARSE_FILE))
ntfs_log_quiet("Sparse "); ntfs_log_quiet("Sparse ");
if (f->flags & FILE_ATTR_REPARSE_POINT) if (!le32_andz(f->flags, FILE_ATTR_REPARSE_POINT))
ntfs_log_quiet("Reparse "); ntfs_log_quiet("Reparse ");
if (f->flags & FILE_ATTR_COMPRESSED) if (!le32_andz(f->flags, FILE_ATTR_COMPRESSED))
ntfs_log_quiet("Compressed "); ntfs_log_quiet("Compressed ");
if (f->flags & FILE_ATTR_ENCRYPTED) if (!le32_andz(f->flags, FILE_ATTR_ENCRYPTED))
ntfs_log_quiet("Encrypted "); ntfs_log_quiet("Encrypted ");
if (!(f->flags & (FILE_ATTR_SYSTEM | FILE_ATTR_DIRECTORY | if (!(f->flags & (FILE_ATTR_SYSTEM | FILE_ATTR_DIRECTORY |
FILE_ATTR_SPARSE_FILE | FILE_ATTR_REPARSE_POINT | FILE_ATTR_SPARSE_FILE | FILE_ATTR_REPARSE_POINT |

View File

@ -603,8 +603,8 @@ static int ntfs_fuse_getstat(struct SECURITY_CONTEXT *scx,
memset(stbuf, 0, sizeof(struct stat)); memset(stbuf, 0, sizeof(struct stat));
withusermapping = (scx->mapping[MAPUSERS] != (struct MAPPING*)NULL); withusermapping = (scx->mapping[MAPUSERS] != (struct MAPPING*)NULL);
if (!le16_andz(ni->mrec->flags, MFT_RECORD_IS_DIRECTORY) if (!le16_andz(ni->mrec->flags, MFT_RECORD_IS_DIRECTORY)
|| (ni->flags & FILE_ATTR_REPARSE_POINT)) { || !le32_andz(ni->flags, FILE_ATTR_REPARSE_POINT)) {
if (ni->flags & FILE_ATTR_REPARSE_POINT) { if (!le32_andz(ni->flags, FILE_ATTR_REPARSE_POINT)) {
char *target; char *target;
int attr_size; int attr_size;
@ -662,7 +662,7 @@ static int ntfs_fuse_getstat(struct SECURITY_CONTEXT *scx,
* also include 2 bytes for padding info * also include 2 bytes for padding info
*/ */
if (ctx->efs_raw if (ctx->efs_raw
&& (ni->flags & FILE_ATTR_ENCRYPTED) && !le32_andz(ni->flags, FILE_ATTR_ENCRYPTED)
&& ni->data_size) && ni->data_size)
stbuf->st_size = ((ni->data_size + 511) & ~511) + 2; stbuf->st_size = ((ni->data_size + 511) & ~511) + 2;
#endif /* HAVE_SETXATTR */ #endif /* HAVE_SETXATTR */
@ -672,7 +672,7 @@ static int ntfs_fuse_getstat(struct SECURITY_CONTEXT *scx,
*/ */
stbuf->st_blocks = (ni->allocated_size + 511) >> 9; stbuf->st_blocks = (ni->allocated_size + 511) >> 9;
stbuf->st_nlink = le16_to_cpu(ni->mrec->link_count); stbuf->st_nlink = le16_to_cpu(ni->mrec->link_count);
if (ni->flags & FILE_ATTR_SYSTEM) { if (!le32_andz(ni->flags, FILE_ATTR_SYSTEM)) {
na = ntfs_attr_open(ni, AT_DATA, AT_UNNAMED, 0); na = ntfs_attr_open(ni, AT_DATA, AT_UNNAMED, 0);
if (!na) { if (!na) {
stbuf->st_ino = ni->mft_no; stbuf->st_ino = ni->mft_no;
@ -896,7 +896,7 @@ static void ntfs_fuse_readlink(fuse_req_t req, fuse_ino_t ino)
/* /*
* Reparse point : analyze as a junction point * Reparse point : analyze as a junction point
*/ */
if (ni->flags & FILE_ATTR_REPARSE_POINT) { if (!le32_andz(ni->flags, FILE_ATTR_REPARSE_POINT)) {
int attr_size; int attr_size;
errno = 0; errno = 0;
@ -1272,7 +1272,7 @@ static void ntfs_fuse_open(fuse_req_t req, fuse_ino_t ino,
/* mark a future need to fixup encrypted inode */ /* mark a future need to fixup encrypted inode */
if (ctx->efs_raw if (ctx->efs_raw
&& le16_andz(na->data_flags, ATTR_IS_ENCRYPTED) && le16_andz(na->data_flags, ATTR_IS_ENCRYPTED)
&& (ni->flags & FILE_ATTR_ENCRYPTED)) && !le32_andz(ni->flags, FILE_ATTR_ENCRYPTED))
state |= CLOSE_ENCRYPTED; state |= CLOSE_ENCRYPTED;
#endif /* HAVE_SETXATTR */ #endif /* HAVE_SETXATTR */
/* mark a future need to update the mtime */ /* mark a future need to update the mtime */
@ -1974,14 +1974,14 @@ static int ntfs_fuse_create(fuse_req_t req, fuse_ino_t parent, const char *name,
} }
set_archive(ni); set_archive(ni);
/* mark a need to compress the end of file */ /* mark a need to compress the end of file */
if (fi && (ni->flags & FILE_ATTR_COMPRESSED)) { if (fi && !le32_andz(ni->flags, FILE_ATTR_COMPRESSED)) {
state |= CLOSE_COMPRESSED; state |= CLOSE_COMPRESSED;
} }
#ifdef HAVE_SETXATTR /* extended attributes interface required */ #ifdef HAVE_SETXATTR /* extended attributes interface required */
/* mark a future need to fixup encrypted inode */ /* mark a future need to fixup encrypted inode */
if (fi if (fi
&& ctx->efs_raw && ctx->efs_raw
&& (ni->flags & FILE_ATTR_ENCRYPTED)) && !le32_andz(ni->flags, FILE_ATTR_ENCRYPTED))
state |= CLOSE_ENCRYPTED; state |= CLOSE_ENCRYPTED;
#endif /* HAVE_SETXATTR */ #endif /* HAVE_SETXATTR */
if (fi && ctx->dmtime) if (fi && ctx->dmtime)
@ -2891,7 +2891,7 @@ static void ntfs_fuse_listxattr(fuse_req_t req, fuse_ino_t ino, size_t size)
goto out; goto out;
} }
/* Return with no result for symlinks, fifo, etc. */ /* Return with no result for symlinks, fifo, etc. */
if (ni->flags & (FILE_ATTR_SYSTEM | FILE_ATTR_REPARSE_POINT)) if (!le32_andz(ni->flags, FILE_ATTR_SYSTEM | FILE_ATTR_REPARSE_POINT))
goto exit; goto exit;
/* otherwise file must be readable */ /* otherwise file must be readable */
#if !KERNELPERMS | (POSIXACLS & !KERNELACLS) #if !KERNELPERMS | (POSIXACLS & !KERNELACLS)
@ -3040,7 +3040,7 @@ static void ntfs_fuse_getxattr(fuse_req_t req, fuse_ino_t ino, const char *name,
goto out; goto out;
} }
/* Return with no result for symlinks, fifo, etc. */ /* Return with no result for symlinks, fifo, etc. */
if (ni->flags & (FILE_ATTR_SYSTEM | FILE_ATTR_REPARSE_POINT)) { if (!le32_andz(ni->flags, FILE_ATTR_SYSTEM | FILE_ATTR_REPARSE_POINT)) {
res = -ENODATA; res = -ENODATA;
goto exit; goto exit;
} }
@ -3237,7 +3237,7 @@ static void ntfs_fuse_setxattr(fuse_req_t req, fuse_ino_t ino, const char *name,
break; break;
default : default :
/* User xattr not allowed for symlinks, fifo, etc. */ /* User xattr not allowed for symlinks, fifo, etc. */
if (ni->flags & (FILE_ATTR_SYSTEM | FILE_ATTR_REPARSE_POINT)) { if (!le32_andz(ni->flags, FILE_ATTR_SYSTEM | FILE_ATTR_REPARSE_POINT)) {
res = -EPERM; res = -EPERM;
goto exit; goto exit;
} }
@ -3306,7 +3306,7 @@ static void ntfs_fuse_setxattr(fuse_req_t req, fuse_ino_t ino, const char *name,
res = -errno; res = -errno;
else { else {
if (ctx->efs_raw if (ctx->efs_raw
&& (ni->flags & FILE_ATTR_ENCRYPTED)) { && !le32_andz(ni->flags, FILE_ATTR_ENCRYPTED)) {
if (ntfs_efs_fixup_attribute(NULL,na)) if (ntfs_efs_fixup_attribute(NULL,na))
res = -errno; res = -errno;
} }
@ -3482,7 +3482,7 @@ static void ntfs_fuse_removexattr(fuse_req_t req, fuse_ino_t ino, const char *na
break; break;
default : default :
/* User xattr not allowed for symlinks, fifo, etc. */ /* User xattr not allowed for symlinks, fifo, etc. */
if (ni->flags & (FILE_ATTR_SYSTEM | FILE_ATTR_REPARSE_POINT)) { if (!le32_andz(ni->flags, FILE_ATTR_SYSTEM | FILE_ATTR_REPARSE_POINT)) {
res = -EPERM; res = -EPERM;
goto exit; goto exit;
} }

View File

@ -697,9 +697,9 @@ static int ntfs_fuse_getattr(const char *org_path, struct stat *stbuf)
} }
#endif #endif
if ((!le16_andz(ni->mrec->flags, MFT_RECORD_IS_DIRECTORY) if ((!le16_andz(ni->mrec->flags, MFT_RECORD_IS_DIRECTORY)
|| (ni->flags & FILE_ATTR_REPARSE_POINT)) || !le32_andz(ni->flags, FILE_ATTR_REPARSE_POINT))
&& !stream_name_len) { && !stream_name_len) {
if (ni->flags & FILE_ATTR_REPARSE_POINT) { if (!le32_andz(ni->flags, FILE_ATTR_REPARSE_POINT)) {
char *target; char *target;
int attr_size; int attr_size;
@ -752,7 +752,7 @@ static int ntfs_fuse_getattr(const char *org_path, struct stat *stbuf)
* also include 2 bytes for padding info * also include 2 bytes for padding info
*/ */
if (ctx->efs_raw if (ctx->efs_raw
&& (ni->flags & FILE_ATTR_ENCRYPTED) && (!le32_andz(ni->flags, FILE_ATTR_ENCRYPTED))
&& ni->data_size) && ni->data_size)
stbuf->st_size = ((ni->data_size + 511) & ~511) + 2; stbuf->st_size = ((ni->data_size + 511) & ~511) + 2;
#endif /* HAVE_SETXATTR */ #endif /* HAVE_SETXATTR */
@ -762,7 +762,7 @@ static int ntfs_fuse_getattr(const char *org_path, struct stat *stbuf)
*/ */
stbuf->st_blocks = (ni->allocated_size + 511) >> 9; stbuf->st_blocks = (ni->allocated_size + 511) >> 9;
stbuf->st_nlink = le16_to_cpu(ni->mrec->link_count); stbuf->st_nlink = le16_to_cpu(ni->mrec->link_count);
if (ni->flags & FILE_ATTR_SYSTEM || stream_name_len) { if (!le32_andz(ni->flags, FILE_ATTR_SYSTEM) || stream_name_len) {
na = ntfs_attr_open(ni, AT_DATA, stream_name, na = ntfs_attr_open(ni, AT_DATA, stream_name,
stream_name_len); stream_name_len);
if (!na) { if (!na) {
@ -925,7 +925,7 @@ static int ntfs_fuse_readlink(const char *org_path, char *buf, size_t buf_size)
/* /*
* Reparse point : analyze as a junction point * Reparse point : analyze as a junction point
*/ */
if (ni->flags & FILE_ATTR_REPARSE_POINT) { if (!le32_andz(ni->flags, FILE_ATTR_REPARSE_POINT)) {
char *target; char *target;
int attr_size; int attr_size;
@ -1209,7 +1209,7 @@ static int ntfs_fuse_open(const char *org_path,
/* mark a future need to fixup encrypted inode */ /* mark a future need to fixup encrypted inode */
if (ctx->efs_raw if (ctx->efs_raw
&& le16_andz(na->data_flags, ATTR_IS_ENCRYPTED) && le16_andz(na->data_flags, ATTR_IS_ENCRYPTED)
&& (ni->flags & FILE_ATTR_ENCRYPTED)) && !le32_andz(ni->flags, FILE_ATTR_ENCRYPTED))
fi->fh |= CLOSE_ENCRYPTED; fi->fh |= CLOSE_ENCRYPTED;
#endif /* HAVE_SETXATTR */ #endif /* HAVE_SETXATTR */
/* mark a future need to update the mtime */ /* mark a future need to update the mtime */
@ -1768,14 +1768,14 @@ static int ntfs_fuse_create(const char *org_path, mode_t typemode, dev_t dev,
} }
set_archive(ni); set_archive(ni);
/* mark a need to compress the end of file */ /* mark a need to compress the end of file */
if (fi && (ni->flags & FILE_ATTR_COMPRESSED)) { if (fi && !le32_andz(ni->flags, FILE_ATTR_COMPRESSED)) {
fi->fh |= CLOSE_COMPRESSED; fi->fh |= CLOSE_COMPRESSED;
} }
#ifdef HAVE_SETXATTR /* extended attributes interface required */ #ifdef HAVE_SETXATTR /* extended attributes interface required */
/* mark a future need to fixup encrypted inode */ /* mark a future need to fixup encrypted inode */
if (fi if (fi
&& ctx->efs_raw && ctx->efs_raw
&& (ni->flags & FILE_ATTR_ENCRYPTED)) && !le32_andz(ni->flags, FILE_ATTR_ENCRYPTED))
fi->fh |= CLOSE_ENCRYPTED; fi->fh |= CLOSE_ENCRYPTED;
#endif /* HAVE_SETXATTR */ #endif /* HAVE_SETXATTR */
/* mark a need to update the mtime */ /* mark a need to update the mtime */
@ -1842,12 +1842,12 @@ static int ntfs_fuse_create_stream(const char *path,
&& fi && fi
&& (fi->flags & (O_WRONLY | O_RDWR))) { && (fi->flags & (O_WRONLY | O_RDWR))) {
/* mark a future need to compress the last block */ /* mark a future need to compress the last block */
if (ni->flags & FILE_ATTR_COMPRESSED) if (!le32_andz(ni->flags, FILE_ATTR_COMPRESSED))
fi->fh |= CLOSE_COMPRESSED; fi->fh |= CLOSE_COMPRESSED;
#ifdef HAVE_SETXATTR /* extended attributes interface required */ #ifdef HAVE_SETXATTR /* extended attributes interface required */
/* mark a future need to fixup encrypted inode */ /* mark a future need to fixup encrypted inode */
if (ctx->efs_raw if (ctx->efs_raw
&& (ni->flags & FILE_ATTR_ENCRYPTED)) && !le32_andz(ni->flags, FILE_ATTR_ENCRYPTED))
fi->fh |= CLOSE_ENCRYPTED; fi->fh |= CLOSE_ENCRYPTED;
#endif /* HAVE_SETXATTR */ #endif /* HAVE_SETXATTR */
if (ctx->dmtime) if (ctx->dmtime)
@ -2689,7 +2689,7 @@ static int ntfs_fuse_listxattr(const char *path, char *list, size_t size)
if (!ni) if (!ni)
return -errno; return -errno;
/* Return with no result for symlinks, fifo, etc. */ /* Return with no result for symlinks, fifo, etc. */
if (ni->flags & (FILE_ATTR_SYSTEM | FILE_ATTR_REPARSE_POINT)) if (!le32_andz(ni->flags, FILE_ATTR_SYSTEM | FILE_ATTR_REPARSE_POINT))
goto exit; goto exit;
/* otherwise file must be readable */ /* otherwise file must be readable */
#if !KERNELPERMS | (POSIXACLS & !KERNELACLS) #if !KERNELPERMS | (POSIXACLS & !KERNELACLS)
@ -2891,7 +2891,7 @@ static int ntfs_fuse_getxattr(const char *path, const char *name,
if (!ni) if (!ni)
return -errno; return -errno;
/* Return with no result for symlinks, fifo, etc. */ /* Return with no result for symlinks, fifo, etc. */
if (ni->flags & (FILE_ATTR_SYSTEM | FILE_ATTR_REPARSE_POINT)) { if (!le32_andz(ni->flags, FILE_ATTR_SYSTEM | FILE_ATTR_REPARSE_POINT)) {
res = -ENODATA; res = -ENODATA;
goto exit; goto exit;
} }
@ -3080,7 +3080,7 @@ static int ntfs_fuse_setxattr(const char *path, const char *name,
#else #else
/* User xattr not allowed for symlinks, fifo, etc. */ /* User xattr not allowed for symlinks, fifo, etc. */
if ((namespace == XATTRNS_USER) if ((namespace == XATTRNS_USER)
&& (ni->flags & (FILE_ATTR_SYSTEM | FILE_ATTR_REPARSE_POINT))) { && (!le32_andz(ni->flags, FILE_ATTR_SYSTEM | FILE_ATTR_REPARSE_POINT))) {
res = -EPERM; res = -EPERM;
goto exit; goto exit;
} }
@ -3136,7 +3136,7 @@ static int ntfs_fuse_setxattr(const char *path, const char *name,
res = -errno; res = -errno;
else { else {
if (ctx->efs_raw if (ctx->efs_raw
&& (ni->flags & FILE_ATTR_ENCRYPTED)) { && !le32_andz(ni->flags, FILE_ATTR_ENCRYPTED)) {
if (ntfs_efs_fixup_attribute(NULL,na)) if (ntfs_efs_fixup_attribute(NULL,na))
res = -errno; res = -errno;
} }
@ -3317,7 +3317,7 @@ static int ntfs_fuse_removexattr(const char *path, const char *name)
#else #else
/* User xattr not allowed for symlinks, fifo, etc. */ /* User xattr not allowed for symlinks, fifo, etc. */
if ((namespace == XATTRNS_USER) if ((namespace == XATTRNS_USER)
&& (ni->flags & (FILE_ATTR_SYSTEM | FILE_ATTR_REPARSE_POINT))) { && (!le32_andz(ni->flags, FILE_ATTR_SYSTEM | FILE_ATTR_REPARSE_POINT))) {
res = -EPERM; res = -EPERM;
goto exit; goto exit;
} }

View File

@ -736,7 +736,7 @@ int ntfs_fuse_listxattr_common(ntfs_inode *ni, ntfs_attr_search_ctx *actx,
} }
#else /* XATTR_MAPPINGS */ #else /* XATTR_MAPPINGS */
/* List efs info xattr for encrypted files */ /* List efs info xattr for encrypted files */
if (ni->vol->efs_raw && (ni->flags & FILE_ATTR_ENCRYPTED)) { if (ni->vol->efs_raw && !le32_andz(ni->flags, FILE_ATTR_ENCRYPTED)) {
ret += sizeof(nf_ns_alt_xattr_efsinfo); ret += sizeof(nf_ns_alt_xattr_efsinfo);
if ((size_t)ret <= size) { if ((size_t)ret <= size) {
memcpy(to, nf_ns_alt_xattr_efsinfo, memcpy(to, nf_ns_alt_xattr_efsinfo,