]>
Commit | Line | Data |
---|---|---|
b2441318 | 1 | // SPDX-License-Identifier: GPL-2.0 |
1da177e4 | 2 | /* |
1da177e4 LT |
3 | * Process version 3 NFS requests. |
4 | * | |
5 | * Copyright (C) 1996, 1997, 1998 Olaf Kirch <okir@monad.swb.de> | |
6 | */ | |
7 | ||
1da177e4 LT |
8 | #include <linux/fs.h> |
9 | #include <linux/ext2_fs.h> | |
12214cb7 | 10 | #include <linux/magic.h> |
df9606ab | 11 | #include <linux/namei.h> |
1da177e4 | 12 | |
9a74af21 BH |
13 | #include "cache.h" |
14 | #include "xdr3.h" | |
0a3adade | 15 | #include "vfs.h" |
1da177e4 LT |
16 | |
17 | #define NFSDDBG_FACILITY NFSDDBG_PROC | |
18 | ||
1da177e4 LT |
19 | static int nfs3_ftypes[] = { |
20 | 0, /* NF3NON */ | |
21 | S_IFREG, /* NF3REG */ | |
22 | S_IFDIR, /* NF3DIR */ | |
23 | S_IFBLK, /* NF3BLK */ | |
24 | S_IFCHR, /* NF3CHR */ | |
25 | S_IFLNK, /* NF3LNK */ | |
26 | S_IFSOCK, /* NF3SOCK */ | |
27 | S_IFIFO, /* NF3FIFO */ | |
28 | }; | |
29 | ||
30 | /* | |
31 | * NULL call. | |
32 | */ | |
7111c66e | 33 | static __be32 |
a6beb732 | 34 | nfsd3_proc_null(struct svc_rqst *rqstp) |
1da177e4 | 35 | { |
cc028a10 | 36 | return rpc_success; |
1da177e4 LT |
37 | } |
38 | ||
39 | /* | |
40 | * Get a file's attributes | |
41 | */ | |
7111c66e | 42 | static __be32 |
a6beb732 | 43 | nfsd3_proc_getattr(struct svc_rqst *rqstp) |
1da177e4 | 44 | { |
a6beb732 CH |
45 | struct nfsd_fhandle *argp = rqstp->rq_argp; |
46 | struct nfsd3_attrstat *resp = rqstp->rq_resp; | |
1da177e4 LT |
47 | |
48 | dprintk("nfsd: GETATTR(3) %s\n", | |
a334de28 | 49 | SVCFH_fmt(&argp->fh)); |
1da177e4 LT |
50 | |
51 | fh_copy(&resp->fh, &argp->fh); | |
14168d67 CL |
52 | resp->status = fh_verify(rqstp, &resp->fh, 0, |
53 | NFSD_MAY_NOP | NFSD_MAY_BYPASS_GSS_ON_ROOT); | |
54 | if (resp->status != nfs_ok) | |
55 | goto out; | |
56 | ||
57 | resp->status = fh_getattr(&resp->fh, &resp->stat); | |
58 | out: | |
cc028a10 | 59 | return rpc_success; |
1da177e4 LT |
60 | } |
61 | ||
62 | /* | |
63 | * Set a file's attributes | |
64 | */ | |
7111c66e | 65 | static __be32 |
a6beb732 | 66 | nfsd3_proc_setattr(struct svc_rqst *rqstp) |
1da177e4 | 67 | { |
a6beb732 CH |
68 | struct nfsd3_sattrargs *argp = rqstp->rq_argp; |
69 | struct nfsd3_attrstat *resp = rqstp->rq_resp; | |
7fe2a71d N |
70 | struct nfsd_attrs attrs = { |
71 | .na_iattr = &argp->attrs, | |
72 | }; | |
1da177e4 LT |
73 | |
74 | dprintk("nfsd: SETATTR(3) %s\n", | |
75 | SVCFH_fmt(&argp->fh)); | |
76 | ||
77 | fh_copy(&resp->fh, &argp->fh); | |
7fe2a71d | 78 | resp->status = nfsd_setattr(rqstp, &resp->fh, &attrs, |
14168d67 | 79 | argp->check_guard, argp->guardtime); |
cc028a10 | 80 | return rpc_success; |
1da177e4 LT |
81 | } |
82 | ||
83 | /* | |
84 | * Look up a path name component | |
85 | */ | |
7111c66e | 86 | static __be32 |
a6beb732 | 87 | nfsd3_proc_lookup(struct svc_rqst *rqstp) |
1da177e4 | 88 | { |
a6beb732 CH |
89 | struct nfsd3_diropargs *argp = rqstp->rq_argp; |
90 | struct nfsd3_diropres *resp = rqstp->rq_resp; | |
1da177e4 LT |
91 | |
92 | dprintk("nfsd: LOOKUP(3) %s %.*s\n", | |
93 | SVCFH_fmt(&argp->fh), | |
94 | argp->len, | |
95 | argp->name); | |
96 | ||
97 | fh_copy(&resp->dirfh, &argp->fh); | |
98 | fh_init(&resp->fh, NFS3_FHSIZE); | |
99 | ||
14168d67 CL |
100 | resp->status = nfsd_lookup(rqstp, &resp->dirfh, |
101 | argp->name, argp->len, | |
102 | &resp->fh); | |
cc028a10 | 103 | return rpc_success; |
1da177e4 LT |
104 | } |
105 | ||
106 | /* | |
107 | * Check file access | |
108 | */ | |
7111c66e | 109 | static __be32 |
a6beb732 | 110 | nfsd3_proc_access(struct svc_rqst *rqstp) |
1da177e4 | 111 | { |
a6beb732 CH |
112 | struct nfsd3_accessargs *argp = rqstp->rq_argp; |
113 | struct nfsd3_accessres *resp = rqstp->rq_resp; | |
1da177e4 LT |
114 | |
115 | dprintk("nfsd: ACCESS(3) %s 0x%x\n", | |
116 | SVCFH_fmt(&argp->fh), | |
117 | argp->access); | |
118 | ||
119 | fh_copy(&resp->fh, &argp->fh); | |
120 | resp->access = argp->access; | |
14168d67 | 121 | resp->status = nfsd_access(rqstp, &resp->fh, &resp->access, NULL); |
cc028a10 | 122 | return rpc_success; |
1da177e4 LT |
123 | } |
124 | ||
125 | /* | |
126 | * Read a symlink. | |
127 | */ | |
7111c66e | 128 | static __be32 |
a6beb732 | 129 | nfsd3_proc_readlink(struct svc_rqst *rqstp) |
1da177e4 | 130 | { |
224c1c89 | 131 | struct nfsd_fhandle *argp = rqstp->rq_argp; |
a6beb732 | 132 | struct nfsd3_readlinkres *resp = rqstp->rq_resp; |
1da177e4 LT |
133 | |
134 | dprintk("nfsd: READLINK(3) %s\n", SVCFH_fmt(&argp->fh)); | |
135 | ||
136 | /* Read the symlink. */ | |
137 | fh_copy(&resp->fh, &argp->fh); | |
138 | resp->len = NFS3_MAXPATHLEN; | |
9a9c8923 CL |
139 | resp->pages = rqstp->rq_next_page++; |
140 | resp->status = nfsd_readlink(rqstp, &resp->fh, | |
141 | page_address(*resp->pages), &resp->len); | |
cc028a10 | 142 | return rpc_success; |
1da177e4 LT |
143 | } |
144 | ||
145 | /* | |
146 | * Read a portion of a file. | |
147 | */ | |
7111c66e | 148 | static __be32 |
a6beb732 | 149 | nfsd3_proc_read(struct svc_rqst *rqstp) |
1da177e4 | 150 | { |
a6beb732 CH |
151 | struct nfsd3_readargs *argp = rqstp->rq_argp; |
152 | struct nfsd3_readres *resp = rqstp->rq_resp; | |
be63bd2a CL |
153 | u32 max_blocksize = svc_max_payload(rqstp); |
154 | unsigned int len; | |
155 | int v; | |
156 | ||
18b631f8 | 157 | dprintk("nfsd: READ(3) %s %lu bytes at %Lu\n", |
1da177e4 LT |
158 | SVCFH_fmt(&argp->fh), |
159 | (unsigned long) argp->count, | |
18b631f8 | 160 | (unsigned long long) argp->offset); |
1da177e4 | 161 | |
0cb4d23a CL |
162 | argp->count = min_t(u32, argp->count, max_blocksize); |
163 | if (argp->offset > (u64)OFFSET_MAX) | |
164 | argp->offset = (u64)OFFSET_MAX; | |
165 | if (argp->offset + argp->count > (u64)OFFSET_MAX) | |
166 | argp->count = (u64)OFFSET_MAX - argp->offset; | |
167 | ||
be63bd2a CL |
168 | v = 0; |
169 | len = argp->count; | |
cc9bcdad | 170 | resp->pages = rqstp->rq_next_page; |
be63bd2a CL |
171 | while (len > 0) { |
172 | struct page *page = *(rqstp->rq_next_page++); | |
173 | ||
174 | rqstp->rq_vec[v].iov_base = page_address(page); | |
175 | rqstp->rq_vec[v].iov_len = min_t(unsigned int, len, PAGE_SIZE); | |
176 | len -= rqstp->rq_vec[v].iov_len; | |
177 | v++; | |
178 | } | |
179 | ||
1da177e4 LT |
180 | /* Obtain buffer pointer for payload. |
181 | * 1 (status) + 22 (post_op_attr) + 1 (count) + 1 (eof) | |
182 | * + 1 (xdr opaque byte count) = 26 | |
183 | */ | |
be63bd2a | 184 | resp->count = argp->count; |
cd123012 | 185 | svc_reserve_auth(rqstp, ((1 + NFS3_POST_OP_ATTR_WORDS + 3)<<2) + resp->count +4); |
1da177e4 LT |
186 | |
187 | fh_copy(&resp->fh, &argp->fh); | |
14168d67 | 188 | resp->status = nfsd_read(rqstp, &resp->fh, argp->offset, |
be63bd2a | 189 | rqstp->rq_vec, v, &resp->count, &resp->eof); |
cc028a10 | 190 | return rpc_success; |
1da177e4 LT |
191 | } |
192 | ||
193 | /* | |
194 | * Write data to a file | |
195 | */ | |
7111c66e | 196 | static __be32 |
a6beb732 | 197 | nfsd3_proc_write(struct svc_rqst *rqstp) |
1da177e4 | 198 | { |
a6beb732 CH |
199 | struct nfsd3_writeargs *argp = rqstp->rq_argp; |
200 | struct nfsd3_writeres *resp = rqstp->rq_resp; | |
31dec253 | 201 | unsigned long cnt = argp->len; |
8154ef27 | 202 | unsigned int nvecs; |
1da177e4 | 203 | |
18b631f8 | 204 | dprintk("nfsd: WRITE(3) %s %d bytes at %Lu%s\n", |
1da177e4 LT |
205 | SVCFH_fmt(&argp->fh), |
206 | argp->len, | |
18b631f8 | 207 | (unsigned long long) argp->offset, |
1da177e4 LT |
208 | argp->stable? " stable" : ""); |
209 | ||
6260d9a5 CL |
210 | resp->status = nfserr_fbig; |
211 | if (argp->offset > (u64)OFFSET_MAX || | |
212 | argp->offset + argp->len > (u64)OFFSET_MAX) | |
213 | return rpc_success; | |
214 | ||
1da177e4 LT |
215 | fh_copy(&resp->fh, &argp->fh); |
216 | resp->committed = argp->stable; | |
dae9a6ca | 217 | nvecs = svc_fill_write_vector(rqstp, &argp->payload); |
6a2f7744 | 218 | |
14168d67 CL |
219 | resp->status = nfsd_write(rqstp, &resp->fh, argp->offset, |
220 | rqstp->rq_vec, nvecs, &cnt, | |
221 | resp->committed, resp->verf); | |
31dec253 | 222 | resp->count = cnt; |
cc028a10 | 223 | return rpc_success; |
1da177e4 LT |
224 | } |
225 | ||
226 | /* | |
df9606ab CL |
227 | * Implement NFSv3's unchecked, guarded, and exclusive CREATE |
228 | * semantics for regular files. Except for the created file, | |
229 | * this operation is stateless on the server. | |
230 | * | |
231 | * Upon return, caller must release @fhp and @resfhp. | |
1da177e4 | 232 | */ |
df9606ab CL |
233 | static __be32 |
234 | nfsd3_create_file(struct svc_rqst *rqstp, struct svc_fh *fhp, | |
235 | struct svc_fh *resfhp, struct nfsd3_createargs *argp) | |
236 | { | |
237 | struct iattr *iap = &argp->attrs; | |
238 | struct dentry *parent, *child; | |
7fe2a71d N |
239 | struct nfsd_attrs attrs = { |
240 | .na_iattr = iap, | |
241 | }; | |
df9606ab CL |
242 | __u32 v_mtime, v_atime; |
243 | struct inode *inode; | |
244 | __be32 status; | |
245 | int host_err; | |
246 | ||
247 | if (isdotent(argp->name, argp->len)) | |
248 | return nfserr_exist; | |
249 | if (!(iap->ia_valid & ATTR_MODE)) | |
250 | iap->ia_mode = 0; | |
251 | ||
252 | status = fh_verify(rqstp, fhp, S_IFDIR, NFSD_MAY_EXEC); | |
253 | if (status != nfs_ok) | |
254 | return status; | |
255 | ||
256 | parent = fhp->fh_dentry; | |
257 | inode = d_inode(parent); | |
258 | ||
259 | host_err = fh_want_write(fhp); | |
260 | if (host_err) | |
261 | return nfserrno(host_err); | |
262 | ||
debf16f0 | 263 | inode_lock_nested(inode, I_MUTEX_PARENT); |
df9606ab CL |
264 | |
265 | child = lookup_one_len(argp->name, parent, argp->len); | |
266 | if (IS_ERR(child)) { | |
267 | status = nfserrno(PTR_ERR(child)); | |
268 | goto out; | |
269 | } | |
270 | ||
271 | if (d_really_is_negative(child)) { | |
272 | status = fh_verify(rqstp, fhp, S_IFDIR, NFSD_MAY_CREATE); | |
273 | if (status != nfs_ok) | |
274 | goto out; | |
275 | } | |
276 | ||
277 | status = fh_compose(resfhp, fhp->fh_export, child, fhp); | |
278 | if (status != nfs_ok) | |
279 | goto out; | |
280 | ||
281 | v_mtime = 0; | |
282 | v_atime = 0; | |
283 | if (argp->createmode == NFS3_CREATE_EXCLUSIVE) { | |
284 | u32 *verifier = (u32 *)argp->verf; | |
285 | ||
286 | /* | |
287 | * Solaris 7 gets confused (bugid 4218508) if these have | |
288 | * the high bit set, as do xfs filesystems without the | |
289 | * "bigtime" feature. So just clear the high bits. | |
290 | */ | |
291 | v_mtime = verifier[0] & 0x7fffffff; | |
292 | v_atime = verifier[1] & 0x7fffffff; | |
293 | } | |
294 | ||
295 | if (d_really_is_positive(child)) { | |
296 | status = nfs_ok; | |
297 | ||
298 | switch (argp->createmode) { | |
299 | case NFS3_CREATE_UNCHECKED: | |
300 | if (!d_is_reg(child)) | |
301 | break; | |
302 | iap->ia_valid &= ATTR_SIZE; | |
303 | goto set_attr; | |
304 | case NFS3_CREATE_GUARDED: | |
305 | status = nfserr_exist; | |
306 | break; | |
307 | case NFS3_CREATE_EXCLUSIVE: | |
308 | if (d_inode(child)->i_mtime.tv_sec == v_mtime && | |
309 | d_inode(child)->i_atime.tv_sec == v_atime && | |
310 | d_inode(child)->i_size == 0) { | |
311 | break; | |
312 | } | |
313 | status = nfserr_exist; | |
314 | } | |
315 | goto out; | |
316 | } | |
317 | ||
318 | if (!IS_POSIXACL(inode)) | |
319 | iap->ia_mode &= ~current_umask(); | |
320 | ||
debf16f0 | 321 | fh_fill_pre_attrs(fhp); |
df9606ab CL |
322 | host_err = vfs_create(&init_user_ns, inode, child, iap->ia_mode, true); |
323 | if (host_err < 0) { | |
324 | status = nfserrno(host_err); | |
325 | goto out; | |
326 | } | |
debf16f0 | 327 | fh_fill_post_attrs(fhp); |
df9606ab CL |
328 | |
329 | /* A newly created file already has a file size of zero. */ | |
330 | if ((iap->ia_valid & ATTR_SIZE) && (iap->ia_size == 0)) | |
331 | iap->ia_valid &= ~ATTR_SIZE; | |
332 | if (argp->createmode == NFS3_CREATE_EXCLUSIVE) { | |
333 | iap->ia_valid = ATTR_MTIME | ATTR_ATIME | | |
334 | ATTR_MTIME_SET | ATTR_ATIME_SET; | |
335 | iap->ia_mtime.tv_sec = v_mtime; | |
336 | iap->ia_atime.tv_sec = v_atime; | |
337 | iap->ia_mtime.tv_nsec = 0; | |
338 | iap->ia_atime.tv_nsec = 0; | |
339 | } | |
340 | ||
341 | set_attr: | |
7fe2a71d | 342 | status = nfsd_create_setattr(rqstp, fhp, resfhp, &attrs); |
df9606ab CL |
343 | |
344 | out: | |
debf16f0 | 345 | inode_unlock(inode); |
df9606ab CL |
346 | if (child && !IS_ERR(child)) |
347 | dput(child); | |
348 | fh_drop_write(fhp); | |
349 | return status; | |
350 | } | |
351 | ||
7111c66e | 352 | static __be32 |
a6beb732 | 353 | nfsd3_proc_create(struct svc_rqst *rqstp) |
1da177e4 | 354 | { |
a6beb732 CH |
355 | struct nfsd3_createargs *argp = rqstp->rq_argp; |
356 | struct nfsd3_diropres *resp = rqstp->rq_resp; | |
e6156859 | 357 | svc_fh *dirfhp, *newfhp; |
1da177e4 LT |
358 | |
359 | dprintk("nfsd: CREATE(3) %s %.*s\n", | |
360 | SVCFH_fmt(&argp->fh), | |
361 | argp->len, | |
362 | argp->name); | |
363 | ||
364 | dirfhp = fh_copy(&resp->dirfh, &argp->fh); | |
365 | newfhp = fh_init(&resp->fh, NFS3_FHSIZE); | |
1da177e4 | 366 | |
df9606ab | 367 | resp->status = nfsd3_create_file(rqstp, dirfhp, newfhp, argp); |
cc028a10 | 368 | return rpc_success; |
1da177e4 LT |
369 | } |
370 | ||
371 | /* | |
372 | * Make directory. This operation is not idempotent. | |
373 | */ | |
7111c66e | 374 | static __be32 |
a6beb732 | 375 | nfsd3_proc_mkdir(struct svc_rqst *rqstp) |
1da177e4 | 376 | { |
a6beb732 CH |
377 | struct nfsd3_createargs *argp = rqstp->rq_argp; |
378 | struct nfsd3_diropres *resp = rqstp->rq_resp; | |
7fe2a71d N |
379 | struct nfsd_attrs attrs = { |
380 | .na_iattr = &argp->attrs, | |
381 | }; | |
1da177e4 LT |
382 | |
383 | dprintk("nfsd: MKDIR(3) %s %.*s\n", | |
384 | SVCFH_fmt(&argp->fh), | |
385 | argp->len, | |
386 | argp->name); | |
387 | ||
388 | argp->attrs.ia_valid &= ~ATTR_SIZE; | |
389 | fh_copy(&resp->dirfh, &argp->fh); | |
390 | fh_init(&resp->fh, NFS3_FHSIZE); | |
14168d67 | 391 | resp->status = nfsd_create(rqstp, &resp->dirfh, argp->name, argp->len, |
7fe2a71d | 392 | &attrs, S_IFDIR, 0, &resp->fh); |
cc028a10 | 393 | return rpc_success; |
1da177e4 LT |
394 | } |
395 | ||
7111c66e | 396 | static __be32 |
a6beb732 | 397 | nfsd3_proc_symlink(struct svc_rqst *rqstp) |
1da177e4 | 398 | { |
a6beb732 CH |
399 | struct nfsd3_symlinkargs *argp = rqstp->rq_argp; |
400 | struct nfsd3_diropres *resp = rqstp->rq_resp; | |
93adc1e3 N |
401 | struct nfsd_attrs attrs = { |
402 | .na_iattr = &argp->attrs, | |
403 | }; | |
1da177e4 | 404 | |
14168d67 CL |
405 | if (argp->tlen == 0) { |
406 | resp->status = nfserr_inval; | |
407 | goto out; | |
408 | } | |
409 | if (argp->tlen > NFS3_MAXPATHLEN) { | |
410 | resp->status = nfserr_nametoolong; | |
411 | goto out; | |
412 | } | |
38a70315 CL |
413 | |
414 | argp->tname = svc_fill_symlink_pathname(rqstp, &argp->first, | |
11b4d66e | 415 | page_address(rqstp->rq_arg.pages[0]), |
38a70315 | 416 | argp->tlen); |
14168d67 CL |
417 | if (IS_ERR(argp->tname)) { |
418 | resp->status = nfserrno(PTR_ERR(argp->tname)); | |
419 | goto out; | |
420 | } | |
38a70315 | 421 | |
1da177e4 LT |
422 | dprintk("nfsd: SYMLINK(3) %s %.*s -> %.*s\n", |
423 | SVCFH_fmt(&argp->ffh), | |
424 | argp->flen, argp->fname, | |
425 | argp->tlen, argp->tname); | |
426 | ||
427 | fh_copy(&resp->dirfh, &argp->ffh); | |
428 | fh_init(&resp->fh, NFS3_FHSIZE); | |
14168d67 | 429 | resp->status = nfsd_symlink(rqstp, &resp->dirfh, argp->fname, |
93adc1e3 | 430 | argp->flen, argp->tname, &attrs, &resp->fh); |
11b4d66e | 431 | kfree(argp->tname); |
14168d67 | 432 | out: |
cc028a10 | 433 | return rpc_success; |
1da177e4 LT |
434 | } |
435 | ||
436 | /* | |
437 | * Make socket/fifo/device. | |
438 | */ | |
7111c66e | 439 | static __be32 |
a6beb732 | 440 | nfsd3_proc_mknod(struct svc_rqst *rqstp) |
1da177e4 | 441 | { |
a6beb732 CH |
442 | struct nfsd3_mknodargs *argp = rqstp->rq_argp; |
443 | struct nfsd3_diropres *resp = rqstp->rq_resp; | |
7fe2a71d N |
444 | struct nfsd_attrs attrs = { |
445 | .na_iattr = &argp->attrs, | |
446 | }; | |
c4d987ba | 447 | int type; |
1da177e4 LT |
448 | dev_t rdev = 0; |
449 | ||
450 | dprintk("nfsd: MKNOD(3) %s %.*s\n", | |
451 | SVCFH_fmt(&argp->fh), | |
452 | argp->len, | |
453 | argp->name); | |
454 | ||
455 | fh_copy(&resp->dirfh, &argp->fh); | |
456 | fh_init(&resp->fh, NFS3_FHSIZE); | |
457 | ||
1da177e4 LT |
458 | if (argp->ftype == NF3CHR || argp->ftype == NF3BLK) { |
459 | rdev = MKDEV(argp->major, argp->minor); | |
460 | if (MAJOR(rdev) != argp->major || | |
14168d67 CL |
461 | MINOR(rdev) != argp->minor) { |
462 | resp->status = nfserr_inval; | |
463 | goto out; | |
464 | } | |
465 | } else if (argp->ftype != NF3SOCK && argp->ftype != NF3FIFO) { | |
66d60e3a | 466 | resp->status = nfserr_badtype; |
14168d67 CL |
467 | goto out; |
468 | } | |
1da177e4 LT |
469 | |
470 | type = nfs3_ftypes[argp->ftype]; | |
14168d67 | 471 | resp->status = nfsd_create(rqstp, &resp->dirfh, argp->name, argp->len, |
7fe2a71d | 472 | &attrs, type, rdev, &resp->fh); |
14168d67 | 473 | out: |
cc028a10 | 474 | return rpc_success; |
1da177e4 LT |
475 | } |
476 | ||
477 | /* | |
478 | * Remove file/fifo/socket etc. | |
479 | */ | |
7111c66e | 480 | static __be32 |
a6beb732 | 481 | nfsd3_proc_remove(struct svc_rqst *rqstp) |
1da177e4 | 482 | { |
a6beb732 CH |
483 | struct nfsd3_diropargs *argp = rqstp->rq_argp; |
484 | struct nfsd3_attrstat *resp = rqstp->rq_resp; | |
1da177e4 LT |
485 | |
486 | dprintk("nfsd: REMOVE(3) %s %.*s\n", | |
487 | SVCFH_fmt(&argp->fh), | |
488 | argp->len, | |
489 | argp->name); | |
490 | ||
491 | /* Unlink. -S_IFDIR means file must not be a directory */ | |
492 | fh_copy(&resp->fh, &argp->fh); | |
14168d67 CL |
493 | resp->status = nfsd_unlink(rqstp, &resp->fh, -S_IFDIR, |
494 | argp->name, argp->len); | |
cc028a10 | 495 | return rpc_success; |
1da177e4 LT |
496 | } |
497 | ||
498 | /* | |
499 | * Remove a directory | |
500 | */ | |
7111c66e | 501 | static __be32 |
a6beb732 | 502 | nfsd3_proc_rmdir(struct svc_rqst *rqstp) |
1da177e4 | 503 | { |
a6beb732 CH |
504 | struct nfsd3_diropargs *argp = rqstp->rq_argp; |
505 | struct nfsd3_attrstat *resp = rqstp->rq_resp; | |
1da177e4 LT |
506 | |
507 | dprintk("nfsd: RMDIR(3) %s %.*s\n", | |
508 | SVCFH_fmt(&argp->fh), | |
509 | argp->len, | |
510 | argp->name); | |
511 | ||
512 | fh_copy(&resp->fh, &argp->fh); | |
14168d67 CL |
513 | resp->status = nfsd_unlink(rqstp, &resp->fh, S_IFDIR, |
514 | argp->name, argp->len); | |
cc028a10 | 515 | return rpc_success; |
1da177e4 LT |
516 | } |
517 | ||
7111c66e | 518 | static __be32 |
a6beb732 | 519 | nfsd3_proc_rename(struct svc_rqst *rqstp) |
1da177e4 | 520 | { |
a6beb732 CH |
521 | struct nfsd3_renameargs *argp = rqstp->rq_argp; |
522 | struct nfsd3_renameres *resp = rqstp->rq_resp; | |
1da177e4 LT |
523 | |
524 | dprintk("nfsd: RENAME(3) %s %.*s ->\n", | |
525 | SVCFH_fmt(&argp->ffh), | |
526 | argp->flen, | |
527 | argp->fname); | |
528 | dprintk("nfsd: -> %s %.*s\n", | |
529 | SVCFH_fmt(&argp->tfh), | |
530 | argp->tlen, | |
531 | argp->tname); | |
532 | ||
533 | fh_copy(&resp->ffh, &argp->ffh); | |
534 | fh_copy(&resp->tfh, &argp->tfh); | |
14168d67 CL |
535 | resp->status = nfsd_rename(rqstp, &resp->ffh, argp->fname, argp->flen, |
536 | &resp->tfh, argp->tname, argp->tlen); | |
cc028a10 | 537 | return rpc_success; |
1da177e4 LT |
538 | } |
539 | ||
7111c66e | 540 | static __be32 |
a6beb732 | 541 | nfsd3_proc_link(struct svc_rqst *rqstp) |
1da177e4 | 542 | { |
a6beb732 CH |
543 | struct nfsd3_linkargs *argp = rqstp->rq_argp; |
544 | struct nfsd3_linkres *resp = rqstp->rq_resp; | |
1da177e4 LT |
545 | |
546 | dprintk("nfsd: LINK(3) %s ->\n", | |
547 | SVCFH_fmt(&argp->ffh)); | |
548 | dprintk("nfsd: -> %s %.*s\n", | |
549 | SVCFH_fmt(&argp->tfh), | |
550 | argp->tlen, | |
551 | argp->tname); | |
552 | ||
553 | fh_copy(&resp->fh, &argp->ffh); | |
554 | fh_copy(&resp->tfh, &argp->tfh); | |
14168d67 CL |
555 | resp->status = nfsd_link(rqstp, &resp->tfh, argp->tname, argp->tlen, |
556 | &resp->fh); | |
cc028a10 | 557 | return rpc_success; |
1da177e4 LT |
558 | } |
559 | ||
40116ebd CL |
560 | static void nfsd3_init_dirlist_pages(struct svc_rqst *rqstp, |
561 | struct nfsd3_readdirres *resp, | |
53b1119a | 562 | u32 count) |
40116ebd | 563 | { |
7f87fc2d CL |
564 | struct xdr_buf *buf = &resp->dirlist; |
565 | struct xdr_stream *xdr = &resp->xdr; | |
566 | ||
53b1119a | 567 | count = clamp(count, (u32)(XDR_UNIT * 2), svc_max_payload(rqstp)); |
40116ebd | 568 | |
7f87fc2d | 569 | memset(buf, 0, sizeof(*buf)); |
40116ebd | 570 | |
7f87fc2d CL |
571 | /* Reserve room for the NULL ptr & eof flag (-2 words) */ |
572 | buf->buflen = count - XDR_UNIT * 2; | |
573 | buf->pages = rqstp->rq_next_page; | |
53b1119a | 574 | rqstp->rq_next_page += (buf->buflen + PAGE_SIZE - 1) >> PAGE_SHIFT; |
7f87fc2d CL |
575 | |
576 | /* This is xdr_init_encode(), but it assumes that | |
577 | * the head kvec has already been consumed. */ | |
578 | xdr_set_scratch_buffer(xdr, NULL, 0); | |
579 | xdr->buf = buf; | |
580 | xdr->page_ptr = buf->pages; | |
581 | xdr->iov = NULL; | |
582 | xdr->p = page_address(*buf->pages); | |
53b1119a | 583 | xdr->end = (void *)xdr->p + min_t(u32, buf->buflen, PAGE_SIZE); |
7f87fc2d | 584 | xdr->rqst = NULL; |
40116ebd CL |
585 | } |
586 | ||
1da177e4 LT |
587 | /* |
588 | * Read a portion of a directory. | |
589 | */ | |
7111c66e | 590 | static __be32 |
a6beb732 | 591 | nfsd3_proc_readdir(struct svc_rqst *rqstp) |
1da177e4 | 592 | { |
a6beb732 CH |
593 | struct nfsd3_readdirargs *argp = rqstp->rq_argp; |
594 | struct nfsd3_readdirres *resp = rqstp->rq_resp; | |
0a8f37fb | 595 | loff_t offset; |
1da177e4 LT |
596 | |
597 | dprintk("nfsd: READDIR(3) %s %d bytes at %d\n", | |
598 | SVCFH_fmt(&argp->fh), | |
599 | argp->count, (u32) argp->cookie); | |
600 | ||
40116ebd | 601 | nfsd3_init_dirlist_pages(rqstp, resp, argp->count); |
1da177e4 | 602 | |
1da177e4 | 603 | fh_copy(&resp->fh, &argp->fh); |
1da177e4 | 604 | resp->common.err = nfs_ok; |
7f87fc2d | 605 | resp->cookie_offset = 0; |
1da177e4 | 606 | resp->rqstp = rqstp; |
0a8f37fb | 607 | offset = argp->cookie; |
0a8f37fb | 608 | resp->status = nfsd_readdir(rqstp, &resp->fh, &offset, |
7f87fc2d | 609 | &resp->common, nfs3svc_encode_entry3); |
1da177e4 | 610 | memcpy(resp->verf, argp->verf, 8); |
a161e6c7 | 611 | nfs3svc_encode_cookie3(resp, offset); |
1da177e4 | 612 | |
76ed0dd9 CL |
613 | /* Recycle only pages that were part of the reply */ |
614 | rqstp->rq_next_page = resp->xdr.page_ptr + 1; | |
615 | ||
cc028a10 | 616 | return rpc_success; |
1da177e4 LT |
617 | } |
618 | ||
619 | /* | |
620 | * Read a portion of a directory, including file handles and attrs. | |
621 | * For now, we choose to ignore the dircount parameter. | |
622 | */ | |
7111c66e | 623 | static __be32 |
a6beb732 | 624 | nfsd3_proc_readdirplus(struct svc_rqst *rqstp) |
1da177e4 | 625 | { |
a6beb732 CH |
626 | struct nfsd3_readdirargs *argp = rqstp->rq_argp; |
627 | struct nfsd3_readdirres *resp = rqstp->rq_resp; | |
1da177e4 | 628 | loff_t offset; |
1da177e4 LT |
629 | |
630 | dprintk("nfsd: READDIR+(3) %s %d bytes at %d\n", | |
631 | SVCFH_fmt(&argp->fh), | |
632 | argp->count, (u32) argp->cookie); | |
633 | ||
40116ebd | 634 | nfsd3_init_dirlist_pages(rqstp, resp, argp->count); |
1da177e4 | 635 | |
1da177e4 | 636 | fh_copy(&resp->fh, &argp->fh); |
1da177e4 | 637 | resp->common.err = nfs_ok; |
7f87fc2d | 638 | resp->cookie_offset = 0; |
1da177e4 LT |
639 | resp->rqstp = rqstp; |
640 | offset = argp->cookie; | |
18c01ab3 | 641 | |
14168d67 CL |
642 | resp->status = fh_verify(rqstp, &resp->fh, S_IFDIR, NFSD_MAY_NOP); |
643 | if (resp->status != nfs_ok) | |
644 | goto out; | |
18c01ab3 | 645 | |
14168d67 CL |
646 | if (resp->fh.fh_export->ex_flags & NFSEXP_NOREADDIRPLUS) { |
647 | resp->status = nfserr_notsupp; | |
648 | goto out; | |
649 | } | |
18c01ab3 | 650 | |
14168d67 | 651 | resp->status = nfsd_readdir(rqstp, &resp->fh, &offset, |
7f87fc2d | 652 | &resp->common, nfs3svc_encode_entryplus3); |
1da177e4 | 653 | memcpy(resp->verf, argp->verf, 8); |
a161e6c7 | 654 | nfs3svc_encode_cookie3(resp, offset); |
1da177e4 | 655 | |
76ed0dd9 CL |
656 | /* Recycle only pages that were part of the reply */ |
657 | rqstp->rq_next_page = resp->xdr.page_ptr + 1; | |
658 | ||
14168d67 | 659 | out: |
cc028a10 | 660 | return rpc_success; |
1da177e4 LT |
661 | } |
662 | ||
663 | /* | |
664 | * Get file system stats | |
665 | */ | |
7111c66e | 666 | static __be32 |
a6beb732 | 667 | nfsd3_proc_fsstat(struct svc_rqst *rqstp) |
1da177e4 | 668 | { |
a6beb732 CH |
669 | struct nfsd_fhandle *argp = rqstp->rq_argp; |
670 | struct nfsd3_fsstatres *resp = rqstp->rq_resp; | |
1da177e4 LT |
671 | |
672 | dprintk("nfsd: FSSTAT(3) %s\n", | |
673 | SVCFH_fmt(&argp->fh)); | |
674 | ||
14168d67 | 675 | resp->status = nfsd_statfs(rqstp, &argp->fh, &resp->stats, 0); |
1da177e4 | 676 | fh_put(&argp->fh); |
cc028a10 | 677 | return rpc_success; |
1da177e4 LT |
678 | } |
679 | ||
680 | /* | |
681 | * Get file system info | |
682 | */ | |
7111c66e | 683 | static __be32 |
a6beb732 | 684 | nfsd3_proc_fsinfo(struct svc_rqst *rqstp) |
1da177e4 | 685 | { |
a6beb732 CH |
686 | struct nfsd_fhandle *argp = rqstp->rq_argp; |
687 | struct nfsd3_fsinfores *resp = rqstp->rq_resp; | |
7adae489 | 688 | u32 max_blocksize = svc_max_payload(rqstp); |
1da177e4 LT |
689 | |
690 | dprintk("nfsd: FSINFO(3) %s\n", | |
691 | SVCFH_fmt(&argp->fh)); | |
692 | ||
7adae489 GB |
693 | resp->f_rtmax = max_blocksize; |
694 | resp->f_rtpref = max_blocksize; | |
1da177e4 | 695 | resp->f_rtmult = PAGE_SIZE; |
7adae489 GB |
696 | resp->f_wtmax = max_blocksize; |
697 | resp->f_wtpref = max_blocksize; | |
1da177e4 | 698 | resp->f_wtmult = PAGE_SIZE; |
f875a792 | 699 | resp->f_dtpref = max_blocksize; |
1da177e4 LT |
700 | resp->f_maxfilesize = ~(u32) 0; |
701 | resp->f_properties = NFS3_FSF_DEFAULT; | |
702 | ||
14168d67 CL |
703 | resp->status = fh_verify(rqstp, &argp->fh, 0, |
704 | NFSD_MAY_NOP | NFSD_MAY_BYPASS_GSS_ON_ROOT); | |
1da177e4 LT |
705 | |
706 | /* Check special features of the file system. May request | |
707 | * different read/write sizes for file systems known to have | |
708 | * problems with large blocks */ | |
14168d67 | 709 | if (resp->status == nfs_ok) { |
fc64005c | 710 | struct super_block *sb = argp->fh.fh_dentry->d_sb; |
1da177e4 LT |
711 | |
712 | /* Note that we don't care for remote fs's here */ | |
12214cb7 | 713 | if (sb->s_magic == MSDOS_SUPER_MAGIC) { |
1da177e4 LT |
714 | resp->f_properties = NFS3_FSF_BILLYBOY; |
715 | } | |
716 | resp->f_maxfilesize = sb->s_maxbytes; | |
717 | } | |
718 | ||
719 | fh_put(&argp->fh); | |
cc028a10 | 720 | return rpc_success; |
1da177e4 LT |
721 | } |
722 | ||
723 | /* | |
724 | * Get pathconf info for the specified file | |
725 | */ | |
7111c66e | 726 | static __be32 |
a6beb732 | 727 | nfsd3_proc_pathconf(struct svc_rqst *rqstp) |
1da177e4 | 728 | { |
a6beb732 CH |
729 | struct nfsd_fhandle *argp = rqstp->rq_argp; |
730 | struct nfsd3_pathconfres *resp = rqstp->rq_resp; | |
1da177e4 LT |
731 | |
732 | dprintk("nfsd: PATHCONF(3) %s\n", | |
733 | SVCFH_fmt(&argp->fh)); | |
734 | ||
735 | /* Set default pathconf */ | |
736 | resp->p_link_max = 255; /* at least */ | |
737 | resp->p_name_max = 255; /* at least */ | |
738 | resp->p_no_trunc = 0; | |
739 | resp->p_chown_restricted = 1; | |
740 | resp->p_case_insensitive = 0; | |
741 | resp->p_case_preserving = 1; | |
742 | ||
14168d67 | 743 | resp->status = fh_verify(rqstp, &argp->fh, 0, NFSD_MAY_NOP); |
1da177e4 | 744 | |
14168d67 | 745 | if (resp->status == nfs_ok) { |
fc64005c | 746 | struct super_block *sb = argp->fh.fh_dentry->d_sb; |
1da177e4 LT |
747 | |
748 | /* Note that we don't care for remote fs's here */ | |
749 | switch (sb->s_magic) { | |
750 | case EXT2_SUPER_MAGIC: | |
751 | resp->p_link_max = EXT2_LINK_MAX; | |
752 | resp->p_name_max = EXT2_NAME_LEN; | |
753 | break; | |
12214cb7 | 754 | case MSDOS_SUPER_MAGIC: |
1da177e4 LT |
755 | resp->p_case_insensitive = 1; |
756 | resp->p_case_preserving = 0; | |
757 | break; | |
758 | } | |
759 | } | |
760 | ||
761 | fh_put(&argp->fh); | |
cc028a10 | 762 | return rpc_success; |
1da177e4 LT |
763 | } |
764 | ||
1da177e4 LT |
765 | /* |
766 | * Commit a file (range) to stable storage. | |
767 | */ | |
7111c66e | 768 | static __be32 |
a6beb732 | 769 | nfsd3_proc_commit(struct svc_rqst *rqstp) |
1da177e4 | 770 | { |
a6beb732 CH |
771 | struct nfsd3_commitargs *argp = rqstp->rq_argp; |
772 | struct nfsd3_commitres *resp = rqstp->rq_resp; | |
1da177e4 LT |
773 | |
774 | dprintk("nfsd: COMMIT(3) %s %u@%Lu\n", | |
775 | SVCFH_fmt(&argp->fh), | |
776 | argp->count, | |
777 | (unsigned long long) argp->offset); | |
778 | ||
1da177e4 | 779 | fh_copy(&resp->fh, &argp->fh); |
14168d67 CL |
780 | resp->status = nfsd_commit(rqstp, &resp->fh, argp->offset, |
781 | argp->count, resp->verf); | |
cc028a10 | 782 | return rpc_success; |
1da177e4 LT |
783 | } |
784 | ||
785 | ||
786 | /* | |
787 | * NFSv3 Server procedures. | |
788 | * Only the results of non-idempotent operations are cached. | |
789 | */ | |
1da177e4 LT |
790 | #define nfs3svc_encode_attrstatres nfs3svc_encode_attrstat |
791 | #define nfs3svc_encode_wccstatres nfs3svc_encode_wccstat | |
792 | #define nfsd3_mkdirargs nfsd3_createargs | |
793 | #define nfsd3_readdirplusargs nfsd3_readdirargs | |
794 | #define nfsd3_fhandleargs nfsd_fhandle | |
1da177e4 LT |
795 | #define nfsd3_attrstatres nfsd3_attrstat |
796 | #define nfsd3_wccstatres nfsd3_attrstat | |
797 | #define nfsd3_createres nfsd3_diropres | |
1da177e4 | 798 | |
1da177e4 LT |
799 | #define ST 1 /* status*/ |
800 | #define FH 17 /* filehandle with length */ | |
801 | #define AT 21 /* attributes */ | |
802 | #define pAT (1+AT) /* post attributes - conditional */ | |
803 | #define WC (7+pAT) /* WCC attributes */ | |
804 | ||
860bda29 | 805 | static const struct svc_procedure nfsd_procedures3[22] = { |
b9081d90 | 806 | [NFS3PROC_NULL] = { |
a6beb732 | 807 | .pc_func = nfsd3_proc_null, |
788f7183 CL |
808 | .pc_decode = nfssvc_decode_voidarg, |
809 | .pc_encode = nfssvc_encode_voidres, | |
810 | .pc_argsize = sizeof(struct nfsd_voidargs), | |
811 | .pc_ressize = sizeof(struct nfsd_voidres), | |
b9081d90 YZ |
812 | .pc_cachetype = RC_NOCACHE, |
813 | .pc_xdrressize = ST, | |
2289e87b | 814 | .pc_name = "NULL", |
b9081d90 YZ |
815 | }, |
816 | [NFS3PROC_GETATTR] = { | |
a6beb732 | 817 | .pc_func = nfsd3_proc_getattr, |
026fec7e | 818 | .pc_decode = nfs3svc_decode_fhandleargs, |
2c42f804 | 819 | .pc_encode = nfs3svc_encode_getattrres, |
8537488b | 820 | .pc_release = nfs3svc_release_fhandle, |
9575363a | 821 | .pc_argsize = sizeof(struct nfsd_fhandle), |
b9081d90 YZ |
822 | .pc_ressize = sizeof(struct nfsd3_attrstatres), |
823 | .pc_cachetype = RC_NOCACHE, | |
824 | .pc_xdrressize = ST+AT, | |
2289e87b | 825 | .pc_name = "GETATTR", |
b9081d90 YZ |
826 | }, |
827 | [NFS3PROC_SETATTR] = { | |
a6beb732 | 828 | .pc_func = nfsd3_proc_setattr, |
026fec7e | 829 | .pc_decode = nfs3svc_decode_sattrargs, |
63f8de37 | 830 | .pc_encode = nfs3svc_encode_wccstatres, |
8537488b | 831 | .pc_release = nfs3svc_release_fhandle, |
b9081d90 YZ |
832 | .pc_argsize = sizeof(struct nfsd3_sattrargs), |
833 | .pc_ressize = sizeof(struct nfsd3_wccstatres), | |
834 | .pc_cachetype = RC_REPLBUFF, | |
835 | .pc_xdrressize = ST+WC, | |
2289e87b | 836 | .pc_name = "SETATTR", |
b9081d90 YZ |
837 | }, |
838 | [NFS3PROC_LOOKUP] = { | |
a6beb732 | 839 | .pc_func = nfsd3_proc_lookup, |
026fec7e | 840 | .pc_decode = nfs3svc_decode_diropargs, |
5cf35335 | 841 | .pc_encode = nfs3svc_encode_lookupres, |
8537488b | 842 | .pc_release = nfs3svc_release_fhandle2, |
b9081d90 YZ |
843 | .pc_argsize = sizeof(struct nfsd3_diropargs), |
844 | .pc_ressize = sizeof(struct nfsd3_diropres), | |
845 | .pc_cachetype = RC_NOCACHE, | |
846 | .pc_xdrressize = ST+FH+pAT+pAT, | |
2289e87b | 847 | .pc_name = "LOOKUP", |
b9081d90 YZ |
848 | }, |
849 | [NFS3PROC_ACCESS] = { | |
a6beb732 | 850 | .pc_func = nfsd3_proc_access, |
026fec7e | 851 | .pc_decode = nfs3svc_decode_accessargs, |
63f8de37 | 852 | .pc_encode = nfs3svc_encode_accessres, |
8537488b | 853 | .pc_release = nfs3svc_release_fhandle, |
b9081d90 YZ |
854 | .pc_argsize = sizeof(struct nfsd3_accessargs), |
855 | .pc_ressize = sizeof(struct nfsd3_accessres), | |
856 | .pc_cachetype = RC_NOCACHE, | |
857 | .pc_xdrressize = ST+pAT+1, | |
2289e87b | 858 | .pc_name = "ACCESS", |
b9081d90 YZ |
859 | }, |
860 | [NFS3PROC_READLINK] = { | |
a6beb732 | 861 | .pc_func = nfsd3_proc_readlink, |
224c1c89 | 862 | .pc_decode = nfs3svc_decode_fhandleargs, |
63f8de37 | 863 | .pc_encode = nfs3svc_encode_readlinkres, |
8537488b | 864 | .pc_release = nfs3svc_release_fhandle, |
224c1c89 | 865 | .pc_argsize = sizeof(struct nfsd_fhandle), |
b9081d90 YZ |
866 | .pc_ressize = sizeof(struct nfsd3_readlinkres), |
867 | .pc_cachetype = RC_NOCACHE, | |
868 | .pc_xdrressize = ST+pAT+1+NFS3_MAXPATHLEN/4, | |
2289e87b | 869 | .pc_name = "READLINK", |
b9081d90 YZ |
870 | }, |
871 | [NFS3PROC_READ] = { | |
a6beb732 | 872 | .pc_func = nfsd3_proc_read, |
026fec7e | 873 | .pc_decode = nfs3svc_decode_readargs, |
63f8de37 | 874 | .pc_encode = nfs3svc_encode_readres, |
8537488b | 875 | .pc_release = nfs3svc_release_fhandle, |
b9081d90 YZ |
876 | .pc_argsize = sizeof(struct nfsd3_readargs), |
877 | .pc_ressize = sizeof(struct nfsd3_readres), | |
878 | .pc_cachetype = RC_NOCACHE, | |
879 | .pc_xdrressize = ST+pAT+4+NFSSVC_MAXBLKSIZE/4, | |
2289e87b | 880 | .pc_name = "READ", |
b9081d90 YZ |
881 | }, |
882 | [NFS3PROC_WRITE] = { | |
a6beb732 | 883 | .pc_func = nfsd3_proc_write, |
026fec7e | 884 | .pc_decode = nfs3svc_decode_writeargs, |
63f8de37 | 885 | .pc_encode = nfs3svc_encode_writeres, |
8537488b | 886 | .pc_release = nfs3svc_release_fhandle, |
b9081d90 YZ |
887 | .pc_argsize = sizeof(struct nfsd3_writeargs), |
888 | .pc_ressize = sizeof(struct nfsd3_writeres), | |
889 | .pc_cachetype = RC_REPLBUFF, | |
890 | .pc_xdrressize = ST+WC+4, | |
2289e87b | 891 | .pc_name = "WRITE", |
b9081d90 YZ |
892 | }, |
893 | [NFS3PROC_CREATE] = { | |
a6beb732 | 894 | .pc_func = nfsd3_proc_create, |
026fec7e | 895 | .pc_decode = nfs3svc_decode_createargs, |
63f8de37 | 896 | .pc_encode = nfs3svc_encode_createres, |
8537488b | 897 | .pc_release = nfs3svc_release_fhandle2, |
b9081d90 YZ |
898 | .pc_argsize = sizeof(struct nfsd3_createargs), |
899 | .pc_ressize = sizeof(struct nfsd3_createres), | |
900 | .pc_cachetype = RC_REPLBUFF, | |
901 | .pc_xdrressize = ST+(1+FH+pAT)+WC, | |
2289e87b | 902 | .pc_name = "CREATE", |
b9081d90 YZ |
903 | }, |
904 | [NFS3PROC_MKDIR] = { | |
a6beb732 | 905 | .pc_func = nfsd3_proc_mkdir, |
026fec7e | 906 | .pc_decode = nfs3svc_decode_mkdirargs, |
63f8de37 | 907 | .pc_encode = nfs3svc_encode_createres, |
8537488b | 908 | .pc_release = nfs3svc_release_fhandle2, |
b9081d90 YZ |
909 | .pc_argsize = sizeof(struct nfsd3_mkdirargs), |
910 | .pc_ressize = sizeof(struct nfsd3_createres), | |
911 | .pc_cachetype = RC_REPLBUFF, | |
912 | .pc_xdrressize = ST+(1+FH+pAT)+WC, | |
2289e87b | 913 | .pc_name = "MKDIR", |
b9081d90 YZ |
914 | }, |
915 | [NFS3PROC_SYMLINK] = { | |
a6beb732 | 916 | .pc_func = nfsd3_proc_symlink, |
026fec7e | 917 | .pc_decode = nfs3svc_decode_symlinkargs, |
63f8de37 | 918 | .pc_encode = nfs3svc_encode_createres, |
8537488b | 919 | .pc_release = nfs3svc_release_fhandle2, |
b9081d90 YZ |
920 | .pc_argsize = sizeof(struct nfsd3_symlinkargs), |
921 | .pc_ressize = sizeof(struct nfsd3_createres), | |
922 | .pc_cachetype = RC_REPLBUFF, | |
923 | .pc_xdrressize = ST+(1+FH+pAT)+WC, | |
2289e87b | 924 | .pc_name = "SYMLINK", |
b9081d90 YZ |
925 | }, |
926 | [NFS3PROC_MKNOD] = { | |
a6beb732 | 927 | .pc_func = nfsd3_proc_mknod, |
026fec7e | 928 | .pc_decode = nfs3svc_decode_mknodargs, |
63f8de37 | 929 | .pc_encode = nfs3svc_encode_createres, |
8537488b | 930 | .pc_release = nfs3svc_release_fhandle2, |
b9081d90 YZ |
931 | .pc_argsize = sizeof(struct nfsd3_mknodargs), |
932 | .pc_ressize = sizeof(struct nfsd3_createres), | |
933 | .pc_cachetype = RC_REPLBUFF, | |
934 | .pc_xdrressize = ST+(1+FH+pAT)+WC, | |
2289e87b | 935 | .pc_name = "MKNOD", |
b9081d90 YZ |
936 | }, |
937 | [NFS3PROC_REMOVE] = { | |
a6beb732 | 938 | .pc_func = nfsd3_proc_remove, |
026fec7e | 939 | .pc_decode = nfs3svc_decode_diropargs, |
63f8de37 | 940 | .pc_encode = nfs3svc_encode_wccstatres, |
8537488b | 941 | .pc_release = nfs3svc_release_fhandle, |
b9081d90 YZ |
942 | .pc_argsize = sizeof(struct nfsd3_diropargs), |
943 | .pc_ressize = sizeof(struct nfsd3_wccstatres), | |
944 | .pc_cachetype = RC_REPLBUFF, | |
945 | .pc_xdrressize = ST+WC, | |
2289e87b | 946 | .pc_name = "REMOVE", |
b9081d90 YZ |
947 | }, |
948 | [NFS3PROC_RMDIR] = { | |
a6beb732 | 949 | .pc_func = nfsd3_proc_rmdir, |
026fec7e | 950 | .pc_decode = nfs3svc_decode_diropargs, |
63f8de37 | 951 | .pc_encode = nfs3svc_encode_wccstatres, |
8537488b | 952 | .pc_release = nfs3svc_release_fhandle, |
b9081d90 YZ |
953 | .pc_argsize = sizeof(struct nfsd3_diropargs), |
954 | .pc_ressize = sizeof(struct nfsd3_wccstatres), | |
955 | .pc_cachetype = RC_REPLBUFF, | |
956 | .pc_xdrressize = ST+WC, | |
2289e87b | 957 | .pc_name = "RMDIR", |
b9081d90 YZ |
958 | }, |
959 | [NFS3PROC_RENAME] = { | |
a6beb732 | 960 | .pc_func = nfsd3_proc_rename, |
026fec7e | 961 | .pc_decode = nfs3svc_decode_renameargs, |
63f8de37 | 962 | .pc_encode = nfs3svc_encode_renameres, |
8537488b | 963 | .pc_release = nfs3svc_release_fhandle2, |
b9081d90 YZ |
964 | .pc_argsize = sizeof(struct nfsd3_renameargs), |
965 | .pc_ressize = sizeof(struct nfsd3_renameres), | |
966 | .pc_cachetype = RC_REPLBUFF, | |
967 | .pc_xdrressize = ST+WC+WC, | |
2289e87b | 968 | .pc_name = "RENAME", |
b9081d90 YZ |
969 | }, |
970 | [NFS3PROC_LINK] = { | |
a6beb732 | 971 | .pc_func = nfsd3_proc_link, |
026fec7e | 972 | .pc_decode = nfs3svc_decode_linkargs, |
63f8de37 | 973 | .pc_encode = nfs3svc_encode_linkres, |
8537488b | 974 | .pc_release = nfs3svc_release_fhandle2, |
b9081d90 YZ |
975 | .pc_argsize = sizeof(struct nfsd3_linkargs), |
976 | .pc_ressize = sizeof(struct nfsd3_linkres), | |
977 | .pc_cachetype = RC_REPLBUFF, | |
978 | .pc_xdrressize = ST+pAT+WC, | |
2289e87b | 979 | .pc_name = "LINK", |
b9081d90 YZ |
980 | }, |
981 | [NFS3PROC_READDIR] = { | |
a6beb732 | 982 | .pc_func = nfsd3_proc_readdir, |
026fec7e | 983 | .pc_decode = nfs3svc_decode_readdirargs, |
63f8de37 | 984 | .pc_encode = nfs3svc_encode_readdirres, |
8537488b | 985 | .pc_release = nfs3svc_release_fhandle, |
b9081d90 YZ |
986 | .pc_argsize = sizeof(struct nfsd3_readdirargs), |
987 | .pc_ressize = sizeof(struct nfsd3_readdirres), | |
988 | .pc_cachetype = RC_NOCACHE, | |
2289e87b | 989 | .pc_name = "READDIR", |
b9081d90 YZ |
990 | }, |
991 | [NFS3PROC_READDIRPLUS] = { | |
a6beb732 | 992 | .pc_func = nfsd3_proc_readdirplus, |
026fec7e | 993 | .pc_decode = nfs3svc_decode_readdirplusargs, |
63f8de37 | 994 | .pc_encode = nfs3svc_encode_readdirres, |
8537488b | 995 | .pc_release = nfs3svc_release_fhandle, |
b9081d90 YZ |
996 | .pc_argsize = sizeof(struct nfsd3_readdirplusargs), |
997 | .pc_ressize = sizeof(struct nfsd3_readdirres), | |
998 | .pc_cachetype = RC_NOCACHE, | |
2289e87b | 999 | .pc_name = "READDIRPLUS", |
b9081d90 YZ |
1000 | }, |
1001 | [NFS3PROC_FSSTAT] = { | |
a6beb732 | 1002 | .pc_func = nfsd3_proc_fsstat, |
026fec7e | 1003 | .pc_decode = nfs3svc_decode_fhandleargs, |
63f8de37 | 1004 | .pc_encode = nfs3svc_encode_fsstatres, |
b9081d90 YZ |
1005 | .pc_argsize = sizeof(struct nfsd3_fhandleargs), |
1006 | .pc_ressize = sizeof(struct nfsd3_fsstatres), | |
1007 | .pc_cachetype = RC_NOCACHE, | |
1008 | .pc_xdrressize = ST+pAT+2*6+1, | |
2289e87b | 1009 | .pc_name = "FSSTAT", |
b9081d90 YZ |
1010 | }, |
1011 | [NFS3PROC_FSINFO] = { | |
a6beb732 | 1012 | .pc_func = nfsd3_proc_fsinfo, |
026fec7e | 1013 | .pc_decode = nfs3svc_decode_fhandleargs, |
63f8de37 | 1014 | .pc_encode = nfs3svc_encode_fsinfores, |
b9081d90 YZ |
1015 | .pc_argsize = sizeof(struct nfsd3_fhandleargs), |
1016 | .pc_ressize = sizeof(struct nfsd3_fsinfores), | |
1017 | .pc_cachetype = RC_NOCACHE, | |
1018 | .pc_xdrressize = ST+pAT+12, | |
2289e87b | 1019 | .pc_name = "FSINFO", |
b9081d90 YZ |
1020 | }, |
1021 | [NFS3PROC_PATHCONF] = { | |
a6beb732 | 1022 | .pc_func = nfsd3_proc_pathconf, |
026fec7e | 1023 | .pc_decode = nfs3svc_decode_fhandleargs, |
63f8de37 | 1024 | .pc_encode = nfs3svc_encode_pathconfres, |
b9081d90 YZ |
1025 | .pc_argsize = sizeof(struct nfsd3_fhandleargs), |
1026 | .pc_ressize = sizeof(struct nfsd3_pathconfres), | |
1027 | .pc_cachetype = RC_NOCACHE, | |
1028 | .pc_xdrressize = ST+pAT+6, | |
2289e87b | 1029 | .pc_name = "PATHCONF", |
b9081d90 YZ |
1030 | }, |
1031 | [NFS3PROC_COMMIT] = { | |
a6beb732 | 1032 | .pc_func = nfsd3_proc_commit, |
026fec7e | 1033 | .pc_decode = nfs3svc_decode_commitargs, |
63f8de37 | 1034 | .pc_encode = nfs3svc_encode_commitres, |
8537488b | 1035 | .pc_release = nfs3svc_release_fhandle, |
b9081d90 YZ |
1036 | .pc_argsize = sizeof(struct nfsd3_commitargs), |
1037 | .pc_ressize = sizeof(struct nfsd3_commitres), | |
1038 | .pc_cachetype = RC_NOCACHE, | |
1039 | .pc_xdrressize = ST+WC+2, | |
2289e87b | 1040 | .pc_name = "COMMIT", |
b9081d90 | 1041 | }, |
1da177e4 LT |
1042 | }; |
1043 | ||
7fd38af9 | 1044 | static unsigned int nfsd_count3[ARRAY_SIZE(nfsd_procedures3)]; |
e9679189 CH |
1045 | const struct svc_version nfsd_version3 = { |
1046 | .vs_vers = 3, | |
1047 | .vs_nproc = 22, | |
1048 | .vs_proc = nfsd_procedures3, | |
1049 | .vs_dispatch = nfsd_dispatch, | |
1050 | .vs_count = nfsd_count3, | |
1051 | .vs_xdrsize = NFS3_SVC_XDRSIZE, | |
1da177e4 | 1052 | }; |