diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2007-08-10 17:45:10 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2007-10-09 17:18:34 -0400 |
commit | af22f94ae02ab9dd4fd7fe628c8434a59cc293be (patch) | |
tree | e3794a90fc0720c33266dfa682e264a4041e7a14 /fs/nfs/dir.c | |
parent | cd3758e37ddea66fccca7d93c4b601e8a2e51926 (diff) |
NFSv4: Simplify _nfs4_do_access()
Currently, _nfs4_do_access() is just a copy of nfs_do_access() with added
conversion of the open flags into an access mask. This patch merges the
duplicate functionality.
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/dir.c')
-rw-r--r-- | fs/nfs/dir.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index b332c527d95d..2b5e611352c5 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c | |||
@@ -1815,7 +1815,7 @@ static struct nfs_access_entry *nfs_access_search_rbtree(struct inode *inode, st | |||
1815 | return NULL; | 1815 | return NULL; |
1816 | } | 1816 | } |
1817 | 1817 | ||
1818 | int nfs_access_get_cached(struct inode *inode, struct rpc_cred *cred, struct nfs_access_entry *res) | 1818 | static int nfs_access_get_cached(struct inode *inode, struct rpc_cred *cred, struct nfs_access_entry *res) |
1819 | { | 1819 | { |
1820 | struct nfs_inode *nfsi = NFS_I(inode); | 1820 | struct nfs_inode *nfsi = NFS_I(inode); |
1821 | struct nfs_access_entry *cache; | 1821 | struct nfs_access_entry *cache; |
@@ -1882,7 +1882,7 @@ found: | |||
1882 | nfs_access_free_entry(entry); | 1882 | nfs_access_free_entry(entry); |
1883 | } | 1883 | } |
1884 | 1884 | ||
1885 | void nfs_access_add_cache(struct inode *inode, struct nfs_access_entry *set) | 1885 | static void nfs_access_add_cache(struct inode *inode, struct nfs_access_entry *set) |
1886 | { | 1886 | { |
1887 | struct nfs_access_entry *cache = kmalloc(sizeof(*cache), GFP_KERNEL); | 1887 | struct nfs_access_entry *cache = kmalloc(sizeof(*cache), GFP_KERNEL); |
1888 | if (cache == NULL) | 1888 | if (cache == NULL) |
@@ -1930,6 +1930,24 @@ out: | |||
1930 | return -EACCES; | 1930 | return -EACCES; |
1931 | } | 1931 | } |
1932 | 1932 | ||
1933 | static int nfs_open_permission_mask(int openflags) | ||
1934 | { | ||
1935 | int mask = 0; | ||
1936 | |||
1937 | if (openflags & FMODE_READ) | ||
1938 | mask |= MAY_READ; | ||
1939 | if (openflags & FMODE_WRITE) | ||
1940 | mask |= MAY_WRITE; | ||
1941 | if (openflags & FMODE_EXEC) | ||
1942 | mask |= MAY_EXEC; | ||
1943 | return mask; | ||
1944 | } | ||
1945 | |||
1946 | int nfs_may_open(struct inode *inode, struct rpc_cred *cred, int openflags) | ||
1947 | { | ||
1948 | return nfs_do_access(inode, cred, nfs_open_permission_mask(openflags)); | ||
1949 | } | ||
1950 | |||
1933 | int nfs_permission(struct inode *inode, int mask, struct nameidata *nd) | 1951 | int nfs_permission(struct inode *inode, int mask, struct nameidata *nd) |
1934 | { | 1952 | { |
1935 | struct rpc_cred *cred; | 1953 | struct rpc_cred *cred; |