mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
NFS: Don't compare apples to elephants to determine access bits
The NFS_ACCESS_* flags aren't a 1:1 mapping to the MAY_* flags, so checking for MAY_WHATEVER might have surprising results in nfs*_proc_access(). Let's simplify this check when determining which bits to ask for, and do it in a generic place instead of copying code for each NFS version. Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
This commit is contained in:
parent
3c1818275c
commit
1750d929b0
3 changed files with 10 additions and 37 deletions
|
@ -3889,6 +3889,7 @@ static int _nfs4_proc_access(struct inode *inode, struct nfs_access_entry *entry
|
|||
struct nfs4_accessargs args = {
|
||||
.fh = NFS_FH(inode),
|
||||
.bitmask = server->cache_consistency_bitmask,
|
||||
.access = entry->mask,
|
||||
};
|
||||
struct nfs4_accessres res = {
|
||||
.server = server,
|
||||
|
@ -3899,26 +3900,8 @@ static int _nfs4_proc_access(struct inode *inode, struct nfs_access_entry *entry
|
|||
.rpc_resp = &res,
|
||||
.rpc_cred = entry->cred,
|
||||
};
|
||||
int mode = entry->mask;
|
||||
int status = 0;
|
||||
|
||||
/*
|
||||
* Determine which access bits we want to ask for...
|
||||
*/
|
||||
if (mode & MAY_READ)
|
||||
args.access |= NFS4_ACCESS_READ;
|
||||
if (S_ISDIR(inode->i_mode)) {
|
||||
if (mode & MAY_WRITE)
|
||||
args.access |= NFS4_ACCESS_MODIFY | NFS4_ACCESS_EXTEND | NFS4_ACCESS_DELETE;
|
||||
if (mode & MAY_EXEC)
|
||||
args.access |= NFS4_ACCESS_LOOKUP;
|
||||
} else {
|
||||
if (mode & MAY_WRITE)
|
||||
args.access |= NFS4_ACCESS_MODIFY | NFS4_ACCESS_EXTEND;
|
||||
if (mode & MAY_EXEC)
|
||||
args.access |= NFS4_ACCESS_EXECUTE;
|
||||
}
|
||||
|
||||
res.fattr = nfs_alloc_fattr();
|
||||
if (res.fattr == NULL)
|
||||
return -ENOMEM;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue