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>
This commit is contained in:
parent
e10f7b551d
commit
35fc37d517
@ -1166,6 +1166,20 @@ static __u16 convert_disposition(int disposition)
|
|||||||
return ofun;
|
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
|
int
|
||||||
SMBLegacyOpen(const int xid, struct cifsTconInfo *tcon,
|
SMBLegacyOpen(const int xid, struct cifsTconInfo *tcon,
|
||||||
const char *fileName, const int openDisposition,
|
const char *fileName, const int openDisposition,
|
||||||
@ -1207,13 +1221,7 @@ OldOpenRetry:
|
|||||||
pSMB->OpenFlags = cpu_to_le16(REQ_BATCHOPLOCK);
|
pSMB->OpenFlags = cpu_to_le16(REQ_BATCHOPLOCK);
|
||||||
|
|
||||||
pSMB->OpenFlags |= cpu_to_le16(REQ_MORE_INFO);
|
pSMB->OpenFlags |= cpu_to_le16(REQ_MORE_INFO);
|
||||||
/* BB fixme add conversion for access_flags to bits 0 - 2 of mode */
|
pSMB->Mode = cpu_to_le16(access_flags_to_smbopen_mode(access_flags));
|
||||||
/* 0 = read
|
|
||||||
1 = write
|
|
||||||
2 = rw
|
|
||||||
3 = execute
|
|
||||||
*/
|
|
||||||
pSMB->Mode = cpu_to_le16(2);
|
|
||||||
pSMB->Mode |= cpu_to_le16(0x40); /* deny none */
|
pSMB->Mode |= cpu_to_le16(0x40); /* deny none */
|
||||||
/* set file as system file if special file such
|
/* set file as system file if special file such
|
||||||
as fifo and server expecting SFU style and
|
as fifo and server expecting SFU style and
|
||||||
|
@ -1502,8 +1502,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
|
|||||||
int oplock = 0;
|
int oplock = 0;
|
||||||
|
|
||||||
rc = SMBLegacyOpen(xid, pTcon, full_path,
|
rc = SMBLegacyOpen(xid, pTcon, full_path,
|
||||||
FILE_OPEN,
|
FILE_OPEN, GENERIC_WRITE,
|
||||||
SYNCHRONIZE | FILE_WRITE_ATTRIBUTES,
|
|
||||||
CREATE_NOT_DIR, &netfid, &oplock,
|
CREATE_NOT_DIR, &netfid, &oplock,
|
||||||
NULL, cifs_sb->local_nls,
|
NULL, cifs_sb->local_nls,
|
||||||
cifs_sb->mnt_cifs_flags &
|
cifs_sb->mnt_cifs_flags &
|
||||||
|
Loading…
Reference in New Issue
Block a user