summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorTrond Myklebust <trond.myklebust@primarydata.com>2017-07-11 17:54:32 -0400
committerAnna Schumaker <Anna.Schumaker@Netapp.com>2017-07-21 11:51:19 -0400
commit15d4b73ac2232d6f2beb61d8b2400ea66e4da606 (patch)
tree18e3f28f6b4e33aed2750283eed0ae5f2116a685 /fs
parent3ffbc1d65583394be12801655781dd2b079ce169 (diff)
downloadlinux-15d4b73ac2232d6f2beb61d8b2400ea66e4da606.tar.gz
linux-15d4b73ac2232d6f2beb61d8b2400ea66e4da606.tar.bz2
linux-15d4b73ac2232d6f2beb61d8b2400ea66e4da606.zip
NFS: Refactor NFS access to kernel access mask calculation
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/nfs/dir.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 1255891e5695..24b3a6748062 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -2375,16 +2375,31 @@ void nfs_access_add_cache(struct inode *inode, struct nfs_access_entry *set)
}
EXPORT_SYMBOL_GPL(nfs_access_add_cache);
+#define NFS_MAY_READ (NFS4_ACCESS_READ)
+#define NFS_MAY_WRITE (NFS4_ACCESS_MODIFY | \
+ NFS4_ACCESS_EXTEND | \
+ NFS4_ACCESS_DELETE)
+#define NFS_MAY_LOOKUP (NFS4_ACCESS_LOOKUP)
+#define NFS_MAY_EXECUTE (NFS4_ACCESS_EXECUTE)
+static int
+nfs_access_calc_mask(u32 access_result)
+{
+ int mask = 0;
+
+ if (access_result & NFS_MAY_READ)
+ mask |= MAY_READ;
+ if (access_result & NFS_MAY_WRITE)
+ mask |= MAY_WRITE;
+ if (access_result & NFS_MAY_LOOKUP)
+ mask |= MAY_EXEC;
+ if (access_result & NFS_MAY_EXECUTE)
+ mask |= MAY_EXEC;
+ return mask;
+}
+
void nfs_access_set_mask(struct nfs_access_entry *entry, u32 access_result)
{
- entry->mask = 0;
- if (access_result & NFS4_ACCESS_READ)
- entry->mask |= MAY_READ;
- if (access_result &
- (NFS4_ACCESS_MODIFY | NFS4_ACCESS_EXTEND | NFS4_ACCESS_DELETE))
- entry->mask |= MAY_WRITE;
- if (access_result & (NFS4_ACCESS_LOOKUP|NFS4_ACCESS_EXECUTE))
- entry->mask |= MAY_EXEC;
+ entry->mask = nfs_access_calc_mask(access_result);
}
EXPORT_SYMBOL_GPL(nfs_access_set_mask);