diff options
author | Jeff Layton <jlayton@redhat.com> | 2008-05-14 10:22:03 -0700 |
---|---|---|
committer | Steve French <sfrench@us.ibm.com> | 2008-05-14 18:45:30 +0000 |
commit | 35fc37d5175091c36d034a28c057da0f9594ee7e (patch) | |
tree | d28ee6f3000fd0c3a03fc95f044544b1d6413c08 /fs/cifs/cifssmb.c | |
parent | e10f7b551d2a79b113d5ce66b5dc9f3657035445 (diff) | |
download | linux-35fc37d5175091c36d034a28c057da0f9594ee7e.tar.gz linux-35fc37d5175091c36d034a28c057da0f9594ee7e.tar.bz2 linux-35fc37d5175091c36d034a28c057da0f9594ee7e.zip |
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>
Diffstat (limited to 'fs/cifs/cifssmb.c')
-rw-r--r-- | fs/cifs/cifssmb.c | 22 |
1 files changed, 15 insertions, 7 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) return ofun; } +static int +access_flags_to_smbopen_mode(const int access_flags) +{ + int masked_flags = access_flags & (GENERIC_READ | GENERIC_WRITE); + + if (masked_flags == GENERIC_READ) + return SMBOPEN_READ; + else if (masked_flags == GENERIC_WRITE) + return SMBOPEN_WRITE; + + /* just go for read/write */ + return SMBOPEN_READWRITE; +} + int SMBLegacyOpen(const int xid, struct cifsTconInfo *tcon, const char *fileName, const int openDisposition, @@ -1207,13 +1221,7 @@ OldOpenRetry: pSMB->OpenFlags = cpu_to_le16(REQ_BATCHOPLOCK); pSMB->OpenFlags |= cpu_to_le16(REQ_MORE_INFO); - /* BB fixme add conversion for access_flags to bits 0 - 2 of mode */ - /* 0 = read - 1 = write - 2 = rw - 3 = execute - */ - pSMB->Mode = cpu_to_le16(2); + pSMB->Mode = cpu_to_le16(access_flags_to_smbopen_mode(access_flags)); pSMB->Mode |= cpu_to_le16(0x40); /* deny none */ /* set file as system file if special file such as fifo and server expecting SFU style and |