From 19dda5be837e54c8b5bfcf61741b772baa6e3ced Mon Sep 17 00:00:00 2001 From: jpandre Date: Mon, 2 Mar 2009 20:20:24 +0000 Subject: [PATCH] Allowed setting/clearing compression flag for a directory --- libntfs-3g/security.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/libntfs-3g/security.c b/libntfs-3g/security.c index 16d624af..c0cbe8b9 100644 --- a/libntfs-3g/security.c +++ b/libntfs-3g/security.c @@ -3876,6 +3876,7 @@ int ntfs_set_ntfs_attrib(const char *path __attribute__((unused)), ntfs_inode *ni) { u32 attrib; + u32 settable; int res; res = -1; @@ -3883,8 +3884,11 @@ int ntfs_set_ntfs_attrib(const char *path __attribute__((unused)), if (!(flags & XATTR_CREATE)) { /* copy to avoid alignment problems */ memcpy(&attrib,value,sizeof(FILE_ATTR_FLAGS)); - ni->flags = (ni->flags & ~FILE_ATTR_SETTABLE) - | (cpu_to_le32(attrib) & FILE_ATTR_SETTABLE); + settable = FILE_ATTR_SETTABLE; + if (ni->mrec->flags & MFT_RECORD_IS_DIRECTORY) + settable |= FILE_ATTR_COMPRESSED; + ni->flags = (ni->flags & ~settable) + | (cpu_to_le32(attrib) & settable); NInoSetDirty(ni); res = 0; } else @@ -4456,14 +4460,18 @@ BOOL ntfs_set_file_attributes(struct SECURITY_API *scapi, const char *path, s32 attrib) { ntfs_inode *ni; + le32 settable; int res; res = 0; /* default return */ if (scapi && (scapi->magic == MAGIC_API) && path) { ni = ntfs_pathname_to_inode(scapi->security.vol, NULL, path); if (ni) { - ni->flags = (ni->flags & ~FILE_ATTR_SETTABLE) - | (cpu_to_le32(attrib) & FILE_ATTR_SETTABLE); + settable = FILE_ATTR_SETTABLE; + if (ni->mrec->flags & MFT_RECORD_IS_DIRECTORY) + settable |= FILE_ATTR_COMPRESSED; + ni->flags = (ni->flags & ~settable) + | (cpu_to_le32(attrib) & settable); NInoSetDirty(ni); if (!ntfs_inode_close(ni)) res = -1;