From bbf77b69e9a7c29537ba7a64c120b5f9be935f89 Mon Sep 17 00:00:00 2001 From: "J. Bruce Fields" Date: Mon, 15 Aug 2011 16:55:02 -0400 Subject: [PATCH] --- yaml --- r: 267103 b: refs/heads/master c: aadab6c6f4da38d639394de740602f146c88da0c h: refs/heads/master i: 267101: 98f770ccc50b5a235ca998094317a69850f2c556 267099: daf4360b2678f66ed6b7d5e6b9652f7a87acfa5c 267095: 8357033784a4d260e34fe2de58de17ec7d5d080d 267087: ebbe7cab32d8e76227b3027a760a51c4f319814d 267071: bc4d8db97b5fa0501e4eca806bf0b05499424cbb v: v3 --- [refs] | 2 +- trunk/fs/nfsd/nfs4proc.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index b21f714b66cf..eff745b198de 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 576163005de286bbd418fcb99cfd0971523a0c6d +refs/heads/master: aadab6c6f4da38d639394de740602f146c88da0c diff --git a/trunk/fs/nfsd/nfs4proc.c b/trunk/fs/nfsd/nfs4proc.c index 9bf0a6625187..d784ceb81a62 100644 --- a/trunk/fs/nfsd/nfs4proc.c +++ b/trunk/fs/nfsd/nfs4proc.c @@ -168,6 +168,24 @@ do_open_permission(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfs return status; } +static __be32 nfsd_check_obj_isreg(struct svc_fh *fh) +{ + umode_t mode = fh->fh_dentry->d_inode->i_mode; + + if (S_ISREG(mode)) + return nfs_ok; + if (S_ISDIR(mode)) + return nfserr_isdir; + /* + * Using err_symlink as our catch-all case may look odd; but + * there's no other obvious error for this case in 4.0, and we + * happen to know that it will cause the linux v4 client to do + * the right thing on attempts to open something other than a + * regular file. + */ + return nfserr_symlink; +} + static __be32 do_open_lookup(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open *open) { @@ -216,6 +234,9 @@ do_open_lookup(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_o status = nfsd_lookup(rqstp, current_fh, open->op_fname.data, open->op_fname.len, &resfh); fh_unlock(current_fh); + if (status) + goto out; + status = nfsd_check_obj_isreg(&resfh); } if (status) goto out;