aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2008-05-14 13:22:03 -0400
committerSteve French <sfrench@us.ibm.com>2008-05-14 14:45:30 -0400
commit35fc37d5175091c36d034a28c057da0f9594ee7e (patch)
treed28ee6f3000fd0c3a03fc95f044544b1d6413c08
parente10f7b551d2a79b113d5ce66b5dc9f3657035445 (diff)
add function to convert access flags to legacy open mode
SMBLegacyOpen always opens a file as r/w. This could be problematic for files with ATTR_READONLY set. Have it interpret the access_mode into a sane open mode. Signed-off-by: Steve French <sfrench@us.ibm.com>
-rw-r--r--fs/cifs/cifssmb.c22
-rw-r--r--fs/cifs/inode.c3
2 files changed, 16 insertions, 9 deletions
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index 3c05c2de50e1..9c04ad404553 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -1166,6 +1166,20 @@ static __u16 convert_disposition(int disposition)
1166 return ofun; 1166 return ofun;
1167} 1167}
1168 1168
1169static int
1170access_flags_to_smbopen_mode(const int access_flags)
1171{
1172 int masked_flags = access_flags & (GENERIC_READ | GENERIC_WRITE);
1173
1174 if (masked_flags == GENERIC_READ)
1175 return SMBOPEN_READ;
1176 else if (masked_flags == GENERIC_WRITE)
1177 return SMBOPEN_WRITE;
1178
1179 /* just go for read/write */
1180 return SMBOPEN_READWRITE;
1181}
1182
1169int 1183int
1170SMBLegacyOpen(const int xid, struct cifsTconInfo *tcon, 1184SMBLegacyOpen(const int xid, struct cifsTconInfo *tcon,
1171 const char *fileName, const int openDisposition, 1185 const char *fileName, const int openDisposition,
@@ -1207,13 +1221,7 @@ OldOpenRetry:
1207 pSMB->OpenFlags = cpu_to_le16(REQ_BATCHOPLOCK); 1221 pSMB->OpenFlags = cpu_to_le16(REQ_BATCHOPLOCK);
1208 1222
1209 pSMB->OpenFlags |= cpu_to_le16(REQ_MORE_INFO); 1223 pSMB->OpenFlags |= cpu_to_le16(REQ_MORE_INFO);
1210 /* BB fixme add conversion for access_flags to bits 0 - 2 of mode */ 1224 pSMB->Mode = cpu_to_le16(access_flags_to_smbopen_mode(access_flags));
1211 /* 0 = read
1212 1 = write
1213 2 = rw
1214 3 = execute
1215 */
1216 pSMB->Mode = cpu_to_le16(2);
1217 pSMB->Mode |= cpu_to_le16(0x40); /* deny none */ 1225 pSMB->Mode |= cpu_to_le16(0x40); /* deny none */
1218 /* set file as system file if special file such 1226 /* set file as system file if special file such
1219 as fifo and server expecting SFU style and 1227 as fifo and server expecting SFU style and
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index fcbdbb6ad7bf..2d53b436d511 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -1502,8 +1502,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
1502 int oplock = 0; 1502 int oplock = 0;
1503 1503
1504 rc = SMBLegacyOpen(xid, pTcon, full_path, 1504 rc = SMBLegacyOpen(xid, pTcon, full_path,
1505 FILE_OPEN, 1505 FILE_OPEN, GENERIC_WRITE,
1506 SYNCHRONIZE | FILE_WRITE_ATTRIBUTES,
1507 CREATE_NOT_DIR, &netfid, &oplock, 1506 CREATE_NOT_DIR, &netfid, &oplock,
1508 NULL, cifs_sb->local_nls, 1507 NULL, cifs_sb->local_nls,
1509 cifs_sb->mnt_cifs_flags & 1508 cifs_sb->mnt_cifs_flags &