diff options
author | J. Bruce Fields <bfields@redhat.com> | 2011-08-15 17:04:19 -0400 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2011-08-26 18:22:48 -0400 |
commit | e10f9e1413576f58c18b89f6ae212a37a88b24e7 (patch) | |
tree | a943e2dea7c96c49e76a9ba4abb1521dff6ff004 /fs/nfsd | |
parent | 7d818a7b8fc8d26c24ee44ed1c5dece69455a7b6 (diff) |
nfsd: clean up nfsd_mode_check()
Add some more comments, simplify logic, do & S_IFMT just once, name
"type" more helpfully.
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd')
-rw-r--r-- | fs/nfsd/nfsfh.c | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/fs/nfsd/nfsfh.c b/fs/nfsd/nfsfh.c index 8cd49b9bf085..c763de5c1157 100644 --- a/fs/nfsd/nfsfh.c +++ b/fs/nfsd/nfsfh.c | |||
@@ -59,19 +59,25 @@ static int nfsd_acceptable(void *expv, struct dentry *dentry) | |||
59 | * the write call). | 59 | * the write call). |
60 | */ | 60 | */ |
61 | static inline __be32 | 61 | static inline __be32 |
62 | nfsd_mode_check(struct svc_rqst *rqstp, umode_t mode, int type) | 62 | nfsd_mode_check(struct svc_rqst *rqstp, umode_t mode, int requested) |
63 | { | 63 | { |
64 | if (type > 0 && (mode & S_IFMT) != type) { | 64 | mode &= S_IFMT; |
65 | if (rqstp->rq_vers == 4 && (mode & S_IFMT) == S_IFLNK) | 65 | |
66 | return nfserr_symlink; | 66 | if (requested == 0) /* the caller doesn't care */ |
67 | else if (type == S_IFDIR) | 67 | return nfs_ok; |
68 | return nfserr_notdir; | 68 | if (mode == requested) |
69 | else if ((mode & S_IFMT) == S_IFDIR) | 69 | return nfs_ok; |
70 | return nfserr_isdir; | 70 | /* |
71 | else | 71 | * v4 has an error more specific than err_notdir which we should |
72 | return nfserr_inval; | 72 | * return in preference to err_notdir: |
73 | } | 73 | */ |
74 | return 0; | 74 | if (rqstp->rq_vers == 4 && mode == S_IFLNK) |
75 | return nfserr_symlink; | ||
76 | if (requested == S_IFDIR) | ||
77 | return nfserr_notdir; | ||
78 | if (mode == S_IFDIR) | ||
79 | return nfserr_isdir; | ||
80 | return nfserr_inval; | ||
75 | } | 81 | } |
76 | 82 | ||
77 | static __be32 nfsd_setuser_and_check_port(struct svc_rqst *rqstp, | 83 | static __be32 nfsd_setuser_and_check_port(struct svc_rqst *rqstp, |