mirror of https://gitee.com/openkylin/linux.git
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>
This commit is contained in:
parent
7d818a7b8f
commit
e10f9e1413
|
@ -59,19 +59,25 @@ static int nfsd_acceptable(void *expv, struct dentry *dentry)
|
||||||
* the write call).
|
* the write call).
|
||||||
*/
|
*/
|
||||||
static inline __be32
|
static inline __be32
|
||||||
nfsd_mode_check(struct svc_rqst *rqstp, umode_t mode, int type)
|
nfsd_mode_check(struct svc_rqst *rqstp, umode_t mode, int requested)
|
||||||
{
|
{
|
||||||
if (type > 0 && (mode & S_IFMT) != type) {
|
mode &= S_IFMT;
|
||||||
if (rqstp->rq_vers == 4 && (mode & S_IFMT) == S_IFLNK)
|
|
||||||
return nfserr_symlink;
|
if (requested == 0) /* the caller doesn't care */
|
||||||
else if (type == S_IFDIR)
|
return nfs_ok;
|
||||||
return nfserr_notdir;
|
if (mode == requested)
|
||||||
else if ((mode & S_IFMT) == S_IFDIR)
|
return nfs_ok;
|
||||||
return nfserr_isdir;
|
/*
|
||||||
else
|
* v4 has an error more specific than err_notdir which we should
|
||||||
return nfserr_inval;
|
* return in preference to err_notdir:
|
||||||
}
|
*/
|
||||||
return 0;
|
if (rqstp->rq_vers == 4 && mode == S_IFLNK)
|
||||||
|
return nfserr_symlink;
|
||||||
|
if (requested == S_IFDIR)
|
||||||
|
return nfserr_notdir;
|
||||||
|
if (mode == S_IFDIR)
|
||||||
|
return nfserr_isdir;
|
||||||
|
return nfserr_inval;
|
||||||
}
|
}
|
||||||
|
|
||||||
static __be32 nfsd_setuser_and_check_port(struct svc_rqst *rqstp,
|
static __be32 nfsd_setuser_and_check_port(struct svc_rqst *rqstp,
|
||||||
|
|
Loading…
Reference in New Issue