From: Jeff Layton <jlayton@redhat.com>
Date: Thu, 9 Jul 2009 05:46:44 +0000 (-0400)
Subject: cifs: when ATTR_READONLY is set, only clear write bits on non-directories
X-Git-Tag: firefly_0821_release~13445^2
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=d0c280d26de9422c9c943f8f486b9830cd9bea70;p=firefly-linux-kernel-4.4.55.git

cifs: when ATTR_READONLY is set, only clear write bits on non-directories

cifs: when ATTR_READONLY is set, only clear write bits on non-directories

On windows servers, ATTR_READONLY apparently either has no meaning or
serves as some sort of queue to certain applications for unrelated
behavior. This MS kbase article has details:

http://support.microsoft.com/kb/326549/

Don't clear the write bits directory mode when ATTR_READONLY is set.

Reported-by: pouchat@peewiki.net
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Steve French <sfrench@us.ibm.com>
---

diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index a807397f444e..18afe57b2461 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -419,11 +419,11 @@ cifs_all_info_to_fattr(struct cifs_fattr *fattr, FILE_ALL_INFO *info,
 	} else {
 		fattr->cf_mode = S_IFREG | cifs_sb->mnt_file_mode;
 		fattr->cf_dtype = DT_REG;
-	}
 
-	/* clear write bits if ATTR_READONLY is set */
-	if (fattr->cf_cifsattrs & ATTR_READONLY)
-		fattr->cf_mode &= ~(S_IWUGO);
+		/* clear write bits if ATTR_READONLY is set */
+		if (fattr->cf_cifsattrs & ATTR_READONLY)
+			fattr->cf_mode &= ~(S_IWUGO);
+	}
 
 	fattr->cf_nlink = le32_to_cpu(info->NumberOfLinks);