From f73e9ed9ce344704e56d7b33508bc46221c0c853 Mon Sep 17 00:00:00 2001 From: jpandre Date: Tue, 20 Nov 2007 13:48:15 +0000 Subject: [PATCH] Fixed setting of read-only flag --- libntfs-3g/security.c | 4 ---- src/ntfs-3g.c | 13 +++++++------ 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/libntfs-3g/security.c b/libntfs-3g/security.c index ea09f73c..f0282ded 100644 --- a/libntfs-3g/security.c +++ b/libntfs-3g/security.c @@ -3277,10 +3277,6 @@ int ntfs_set_owner_mode(struct SECURITY_CONTEXT *scx, ntfs_inode *ni, /* quite simple, if we are lucky */ if (cached) { ni->security_id = cached->securid; - if (mode & S_IWUSR) - ni->flags &= ~FILE_ATTR_READONLY; - else - ni->flags |= FILE_ATTR_READONLY; NInoSetDirty(ni); } } else cached = (struct CACHED_SECURID*)NULL; diff --git a/src/ntfs-3g.c b/src/ntfs-3g.c index 41484261..3360f6b7 100644 --- a/src/ntfs-3g.c +++ b/src/ntfs-3g.c @@ -1067,16 +1067,17 @@ static int ntfs_fuse_create(const char *org_path, dev_t typemode, dev_t dev, * set the security attribute if a security id * could not be allocated (eg NTFS 1.x) */ - if (!securid && ctx->security.usermapping) { - if (ntfs_set_owner_mode(&security, ni, + if (ctx->security.usermapping) { + if (!securid + && ntfs_set_owner_mode(&security, ni, security.uid, security.gid, perm) < 0) set_fuse_error(&res); else { /* Adjust read-only (for Windows) */ - if (perm & S_IWUSR) - ni->flags &= ~FILE_ATTR_READONLY; - else - ni->flags |= FILE_ATTR_READONLY; + if (perm & S_IWUSR) + ni->flags &= ~FILE_ATTR_READONLY; + else + ni->flags |= FILE_ATTR_READONLY; } } NInoSetDirty(ni);