diff options
author | J. Bruce Fields <bfields@redhat.com> | 2011-08-15 16:55:02 -0400 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2011-08-19 13:25:32 -0400 |
commit | aadab6c6f4da38d639394de740602f146c88da0c (patch) | |
tree | db196583b8e277dec6830a8553770e6c5d1568b3 /fs/nfsd/nfs4proc.c | |
parent | 576163005de286bbd418fcb99cfd0971523a0c6d (diff) |
nfsd4: return nfserr_symlink on v4 OPEN of non-regular file
Without this, an attempt to open a device special file without first
stat'ing it will fail.
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd/nfs4proc.c')
-rw-r--r-- | fs/nfsd/nfs4proc.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index 9bf0a6625187..d784ceb81a62 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c | |||
@@ -168,6 +168,24 @@ do_open_permission(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfs | |||
168 | return status; | 168 | return status; |
169 | } | 169 | } |
170 | 170 | ||
171 | static __be32 nfsd_check_obj_isreg(struct svc_fh *fh) | ||
172 | { | ||
173 | umode_t mode = fh->fh_dentry->d_inode->i_mode; | ||
174 | |||
175 | if (S_ISREG(mode)) | ||
176 | return nfs_ok; | ||
177 | if (S_ISDIR(mode)) | ||
178 | return nfserr_isdir; | ||
179 | /* | ||
180 | * Using err_symlink as our catch-all case may look odd; but | ||
181 | * there's no other obvious error for this case in 4.0, and we | ||
182 | * happen to know that it will cause the linux v4 client to do | ||
183 | * the right thing on attempts to open something other than a | ||
184 | * regular file. | ||
185 | */ | ||
186 | return nfserr_symlink; | ||
187 | } | ||
188 | |||
171 | static __be32 | 189 | static __be32 |
172 | do_open_lookup(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open *open) | 190 | do_open_lookup(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open *open) |
173 | { | 191 | { |
@@ -216,6 +234,9 @@ do_open_lookup(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_o | |||
216 | status = nfsd_lookup(rqstp, current_fh, | 234 | status = nfsd_lookup(rqstp, current_fh, |
217 | open->op_fname.data, open->op_fname.len, &resfh); | 235 | open->op_fname.data, open->op_fname.len, &resfh); |
218 | fh_unlock(current_fh); | 236 | fh_unlock(current_fh); |
237 | if (status) | ||
238 | goto out; | ||
239 | status = nfsd_check_obj_isreg(&resfh); | ||
219 | } | 240 | } |
220 | if (status) | 241 | if (status) |
221 | goto out; | 242 | goto out; |