From 2f7110a314ab1e555c3c87a62abe2c37537416a5 Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Wed, 14 May 2008 10:22:03 -0700 Subject: [PATCH] --- yaml --- r: 97136 b: refs/heads/master c: 35fc37d5175091c36d034a28c057da0f9594ee7e h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/fs/cifs/cifssmb.c | 22 +++++++++++++++------- trunk/fs/cifs/inode.c | 3 +-- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/[refs] b/[refs] index 9aa819b53f77..8870692558d2 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: e10f7b551d2a79b113d5ce66b5dc9f3657035445 +refs/heads/master: 35fc37d5175091c36d034a28c057da0f9594ee7e diff --git a/trunk/fs/cifs/cifssmb.c b/trunk/fs/cifs/cifssmb.c index 3c05c2de50e1..9c04ad404553 100644 --- a/trunk/fs/cifs/cifssmb.c +++ b/trunk/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 @@ SMBLegacyOpen(const int xid, struct cifsTconInfo *tcon, 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 diff --git a/trunk/fs/cifs/inode.c b/trunk/fs/cifs/inode.c index fcbdbb6ad7bf..2d53b436d511 100644 --- a/trunk/fs/cifs/inode.c +++ b/trunk/fs/cifs/inode.c @@ -1502,8 +1502,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs) int oplock = 0; rc = SMBLegacyOpen(xid, pTcon, full_path, - FILE_OPEN, - SYNCHRONIZE | FILE_WRITE_ATTRIBUTES, + FILE_OPEN, GENERIC_WRITE, CREATE_NOT_DIR, &netfid, &oplock, NULL, cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &