From 939a4a20b7c947bd1cce8f9e17964ef649966fb7 Mon Sep 17 00:00:00 2001 From: jpandre Date: Tue, 9 Sep 2008 15:40:57 +0000 Subject: [PATCH] Relocated the setting of the Windows read-only flag --- libntfs-3g/security.c | 12 ++++++++++++ src/ntfs-3g.c | 16 ++-------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/libntfs-3g/security.c b/libntfs-3g/security.c index 818a4380..1e5d6a2d 100644 --- a/libntfs-3g/security.c +++ b/libntfs-3g/security.c @@ -2454,7 +2454,14 @@ int ntfs_set_inherited_posix(struct SECURITY_CONTEXT *scx, newattr = ntfs_build_descr_posix(scx->mapping, pxdesc, isdir, usid, gsid); if (newattr) { + /* Adjust Windows read-only flag */ res = update_secur_descr(scx->vol, newattr, ni); + if (!res) { + if (mode & S_IWUSR) + ni->flags &= ~FILE_ATTR_READONLY; + else + ni->flags |= FILE_ATTR_READONLY; + } #if CACHE_LEGACY_SIZE /* also invalidate legacy cache */ if (isdir && !ni->security_id) { @@ -2637,6 +2644,11 @@ int ntfs_set_owner_mode(struct SECURITY_CONTEXT *scx, ntfs_inode *ni, if (newattr) { res = update_secur_descr(scx->vol, newattr, ni); if (!res) { + /* adjust Windows read-only flag */ + if (mode & S_IWUSR) + ni->flags &= ~FILE_ATTR_READONLY; + else + ni->flags |= FILE_ATTR_READONLY; /* update cache, for subsequent use */ if (test_nino_flag(ni, v3_Extensions)) { wanted.securid = ni->security_id; diff --git a/src/ntfs-3g.c b/src/ntfs-3g.c index a5adb423..9e35c735 100644 --- a/src/ntfs-3g.c +++ b/src/ntfs-3g.c @@ -970,13 +970,8 @@ static int ntfs_fuse_chmod(const char *path, else { if (ntfs_set_mode(&security,path,ni,mode)) res = -errno; - else { - if (mode & S_IWUSR) - ni->flags &= ~FILE_ATTR_READONLY; - else - ni->flags |= FILE_ATTR_READONLY; + else ntfs_fuse_update_times(ni, NTFS_UPDATE_CTIME); - } NInoSetDirty(ni); if (ntfs_inode_close(ni)) set_fuse_error(&res); @@ -1193,14 +1188,7 @@ static int ntfs_fuse_create(const char *org_path, dev_t typemode, dev_t dev, security.uid, security.gid, perm) < 0) set_fuse_error(&res); #endif - else { - /* Adjust read-only (for Windows) */ - if (perm & S_IWUSR) - ni->flags &= ~FILE_ATTR_READONLY; - else - ni->flags |= FILE_ATTR_READONLY; - } - } + } NInoSetDirty(ni); if (ntfs_inode_close(ni)) set_fuse_error(&res);