]> git.ipfire.org Git - people/ms/linux.git/blame - fs/nfsd/nfs3proc.c
nfsd: remove the unused PROC() macro in nfs3proc.c
[people/ms/linux.git] / fs / nfsd / nfs3proc.c
CommitLineData
1da177e4 1/*
1da177e4
LT
2 * Process version 3 NFS requests.
3 *
4 * Copyright (C) 1996, 1997, 1998 Olaf Kirch <okir@monad.swb.de>
5 */
6
1da177e4
LT
7#include <linux/fs.h>
8#include <linux/ext2_fs.h>
12214cb7 9#include <linux/magic.h>
1da177e4 10
9a74af21
BH
11#include "cache.h"
12#include "xdr3.h"
0a3adade 13#include "vfs.h"
1da177e4
LT
14
15#define NFSDDBG_FACILITY NFSDDBG_PROC
16
17#define RETURN_STATUS(st) { resp->status = (st); return (st); }
18
19static 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 33static __be32
1da177e4
LT
34nfsd3_proc_null(struct svc_rqst *rqstp, void *argp, void *resp)
35{
36 return nfs_ok;
37}
38
39/*
40 * Get a file's attributes
41 */
7111c66e 42static __be32
1da177e4
LT
43nfsd3_proc_getattr(struct svc_rqst *rqstp, struct nfsd_fhandle *argp,
44 struct nfsd3_attrstat *resp)
45{
c4d987ba 46 __be32 nfserr;
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);
04716e66
BF
52 nfserr = fh_verify(rqstp, &resp->fh, 0,
53 NFSD_MAY_NOP | NFSD_MAY_BYPASS_GSS_ON_ROOT);
a334de28
DS
54 if (nfserr)
55 RETURN_STATUS(nfserr);
56
3dadecce 57 nfserr = fh_getattr(&resp->fh, &resp->stat);
a334de28 58
1da177e4
LT
59 RETURN_STATUS(nfserr);
60}
61
62/*
63 * Set a file's attributes
64 */
7111c66e 65static __be32
1da177e4
LT
66nfsd3_proc_setattr(struct svc_rqst *rqstp, struct nfsd3_sattrargs *argp,
67 struct nfsd3_attrstat *resp)
68{
c4d987ba 69 __be32 nfserr;
1da177e4
LT
70
71 dprintk("nfsd: SETATTR(3) %s\n",
72 SVCFH_fmt(&argp->fh));
73
74 fh_copy(&resp->fh, &argp->fh);
75 nfserr = nfsd_setattr(rqstp, &resp->fh, &argp->attrs,
76 argp->check_guard, argp->guardtime);
77 RETURN_STATUS(nfserr);
78}
79
80/*
81 * Look up a path name component
82 */
7111c66e 83static __be32
1da177e4
LT
84nfsd3_proc_lookup(struct svc_rqst *rqstp, struct nfsd3_diropargs *argp,
85 struct nfsd3_diropres *resp)
86{
c4d987ba 87 __be32 nfserr;
1da177e4
LT
88
89 dprintk("nfsd: LOOKUP(3) %s %.*s\n",
90 SVCFH_fmt(&argp->fh),
91 argp->len,
92 argp->name);
93
94 fh_copy(&resp->dirfh, &argp->fh);
95 fh_init(&resp->fh, NFS3_FHSIZE);
96
97 nfserr = nfsd_lookup(rqstp, &resp->dirfh,
98 argp->name,
99 argp->len,
100 &resp->fh);
101 RETURN_STATUS(nfserr);
102}
103
104/*
105 * Check file access
106 */
7111c66e 107static __be32
1da177e4
LT
108nfsd3_proc_access(struct svc_rqst *rqstp, struct nfsd3_accessargs *argp,
109 struct nfsd3_accessres *resp)
110{
c4d987ba 111 __be32 nfserr;
1da177e4
LT
112
113 dprintk("nfsd: ACCESS(3) %s 0x%x\n",
114 SVCFH_fmt(&argp->fh),
115 argp->access);
116
117 fh_copy(&resp->fh, &argp->fh);
118 resp->access = argp->access;
119 nfserr = nfsd_access(rqstp, &resp->fh, &resp->access, NULL);
120 RETURN_STATUS(nfserr);
121}
122
123/*
124 * Read a symlink.
125 */
7111c66e 126static __be32
1da177e4
LT
127nfsd3_proc_readlink(struct svc_rqst *rqstp, struct nfsd3_readlinkargs *argp,
128 struct nfsd3_readlinkres *resp)
129{
c4d987ba 130 __be32 nfserr;
1da177e4
LT
131
132 dprintk("nfsd: READLINK(3) %s\n", SVCFH_fmt(&argp->fh));
133
134 /* Read the symlink. */
135 fh_copy(&resp->fh, &argp->fh);
136 resp->len = NFS3_MAXPATHLEN;
137 nfserr = nfsd_readlink(rqstp, &resp->fh, argp->buffer, &resp->len);
138 RETURN_STATUS(nfserr);
139}
140
141/*
142 * Read a portion of a file.
143 */
7111c66e 144static __be32
1da177e4
LT
145nfsd3_proc_read(struct svc_rqst *rqstp, struct nfsd3_readargs *argp,
146 struct nfsd3_readres *resp)
147{
c4d987ba 148 __be32 nfserr;
7adae489 149 u32 max_blocksize = svc_max_payload(rqstp);
ac503e4a 150 unsigned long cnt = min(argp->count, max_blocksize);
1da177e4 151
18b631f8 152 dprintk("nfsd: READ(3) %s %lu bytes at %Lu\n",
1da177e4
LT
153 SVCFH_fmt(&argp->fh),
154 (unsigned long) argp->count,
18b631f8 155 (unsigned long long) argp->offset);
1da177e4
LT
156
157 /* Obtain buffer pointer for payload.
158 * 1 (status) + 22 (post_op_attr) + 1 (count) + 1 (eof)
159 * + 1 (xdr opaque byte count) = 26
160 */
ac503e4a 161 resp->count = cnt;
cd123012 162 svc_reserve_auth(rqstp, ((1 + NFS3_POST_OP_ATTR_WORDS + 3)<<2) + resp->count +4);
1da177e4
LT
163
164 fh_copy(&resp->fh, &argp->fh);
039a87ca 165 nfserr = nfsd_read(rqstp, &resp->fh,
1da177e4 166 argp->offset,
3cc03b16 167 rqstp->rq_vec, argp->vlen,
1da177e4
LT
168 &resp->count);
169 if (nfserr == 0) {
2b0143b5 170 struct inode *inode = d_inode(resp->fh.fh_dentry);
ac503e4a
BC
171 resp->eof = nfsd_eof_on_read(cnt, resp->count, argp->offset,
172 inode->i_size);
1da177e4
LT
173 }
174
175 RETURN_STATUS(nfserr);
176}
177
178/*
179 * Write data to a file
180 */
7111c66e 181static __be32
1da177e4
LT
182nfsd3_proc_write(struct svc_rqst *rqstp, struct nfsd3_writeargs *argp,
183 struct nfsd3_writeres *resp)
184{
c4d987ba 185 __be32 nfserr;
31dec253 186 unsigned long cnt = argp->len;
1da177e4 187
18b631f8 188 dprintk("nfsd: WRITE(3) %s %d bytes at %Lu%s\n",
1da177e4
LT
189 SVCFH_fmt(&argp->fh),
190 argp->len,
18b631f8 191 (unsigned long long) argp->offset,
1da177e4
LT
192 argp->stable? " stable" : "");
193
194 fh_copy(&resp->fh, &argp->fh);
195 resp->committed = argp->stable;
52e380e0
KM
196 nfserr = nfsd_write(rqstp, &resp->fh, argp->offset,
197 rqstp->rq_vec, argp->vlen,
198 &cnt, resp->committed);
31dec253 199 resp->count = cnt;
1da177e4
LT
200 RETURN_STATUS(nfserr);
201}
202
203/*
204 * With NFSv3, CREATE processing is a lot easier than with NFSv2.
205 * At least in theory; we'll see how it fares in practice when the
206 * first reports about SunOS compatibility problems start to pour in...
207 */
7111c66e 208static __be32
1da177e4
LT
209nfsd3_proc_create(struct svc_rqst *rqstp, struct nfsd3_createargs *argp,
210 struct nfsd3_diropres *resp)
211{
212 svc_fh *dirfhp, *newfhp = NULL;
213 struct iattr *attr;
c4d987ba 214 __be32 nfserr;
1da177e4
LT
215
216 dprintk("nfsd: CREATE(3) %s %.*s\n",
217 SVCFH_fmt(&argp->fh),
218 argp->len,
219 argp->name);
220
221 dirfhp = fh_copy(&resp->dirfh, &argp->fh);
222 newfhp = fh_init(&resp->fh, NFS3_FHSIZE);
223 attr = &argp->attrs;
224
1da177e4
LT
225 /* Unfudge the mode bits */
226 attr->ia_mode &= ~S_IFMT;
227 if (!(attr->ia_valid & ATTR_MODE)) {
228 attr->ia_valid |= ATTR_MODE;
229 attr->ia_mode = S_IFREG;
230 } else {
231 attr->ia_mode = (attr->ia_mode & ~S_IFMT) | S_IFREG;
232 }
233
234 /* Now create the file and set attributes */
ac6721a1 235 nfserr = do_nfsd_create(rqstp, dirfhp, argp->name, argp->len,
1da177e4 236 attr, newfhp,
95c7a20a 237 argp->createmode, (u32 *)argp->verf, NULL, NULL);
1da177e4
LT
238
239 RETURN_STATUS(nfserr);
240}
241
242/*
243 * Make directory. This operation is not idempotent.
244 */
7111c66e 245static __be32
1da177e4
LT
246nfsd3_proc_mkdir(struct svc_rqst *rqstp, struct nfsd3_createargs *argp,
247 struct nfsd3_diropres *resp)
248{
c4d987ba 249 __be32 nfserr;
1da177e4
LT
250
251 dprintk("nfsd: MKDIR(3) %s %.*s\n",
252 SVCFH_fmt(&argp->fh),
253 argp->len,
254 argp->name);
255
256 argp->attrs.ia_valid &= ~ATTR_SIZE;
257 fh_copy(&resp->dirfh, &argp->fh);
258 fh_init(&resp->fh, NFS3_FHSIZE);
259 nfserr = nfsd_create(rqstp, &resp->dirfh, argp->name, argp->len,
260 &argp->attrs, S_IFDIR, 0, &resp->fh);
43a9aa64 261 fh_unlock(&resp->dirfh);
1da177e4
LT
262 RETURN_STATUS(nfserr);
263}
264
7111c66e 265static __be32
1da177e4
LT
266nfsd3_proc_symlink(struct svc_rqst *rqstp, struct nfsd3_symlinkargs *argp,
267 struct nfsd3_diropres *resp)
268{
c4d987ba 269 __be32 nfserr;
1da177e4
LT
270
271 dprintk("nfsd: SYMLINK(3) %s %.*s -> %.*s\n",
272 SVCFH_fmt(&argp->ffh),
273 argp->flen, argp->fname,
274 argp->tlen, argp->tname);
275
276 fh_copy(&resp->dirfh, &argp->ffh);
277 fh_init(&resp->fh, NFS3_FHSIZE);
278 nfserr = nfsd_symlink(rqstp, &resp->dirfh, argp->fname, argp->flen,
1e444f5b 279 argp->tname, &resp->fh);
1da177e4
LT
280 RETURN_STATUS(nfserr);
281}
282
283/*
284 * Make socket/fifo/device.
285 */
7111c66e 286static __be32
1da177e4
LT
287nfsd3_proc_mknod(struct svc_rqst *rqstp, struct nfsd3_mknodargs *argp,
288 struct nfsd3_diropres *resp)
289{
c4d987ba
AV
290 __be32 nfserr;
291 int type;
1da177e4
LT
292 dev_t rdev = 0;
293
294 dprintk("nfsd: MKNOD(3) %s %.*s\n",
295 SVCFH_fmt(&argp->fh),
296 argp->len,
297 argp->name);
298
299 fh_copy(&resp->dirfh, &argp->fh);
300 fh_init(&resp->fh, NFS3_FHSIZE);
301
302 if (argp->ftype == 0 || argp->ftype >= NF3BAD)
303 RETURN_STATUS(nfserr_inval);
304 if (argp->ftype == NF3CHR || argp->ftype == NF3BLK) {
305 rdev = MKDEV(argp->major, argp->minor);
306 if (MAJOR(rdev) != argp->major ||
307 MINOR(rdev) != argp->minor)
308 RETURN_STATUS(nfserr_inval);
309 } else
310 if (argp->ftype != NF3SOCK && argp->ftype != NF3FIFO)
311 RETURN_STATUS(nfserr_inval);
312
313 type = nfs3_ftypes[argp->ftype];
314 nfserr = nfsd_create(rqstp, &resp->dirfh, argp->name, argp->len,
315 &argp->attrs, type, rdev, &resp->fh);
43a9aa64 316 fh_unlock(&resp->dirfh);
1da177e4
LT
317 RETURN_STATUS(nfserr);
318}
319
320/*
321 * Remove file/fifo/socket etc.
322 */
7111c66e 323static __be32
1da177e4
LT
324nfsd3_proc_remove(struct svc_rqst *rqstp, struct nfsd3_diropargs *argp,
325 struct nfsd3_attrstat *resp)
326{
c4d987ba 327 __be32 nfserr;
1da177e4
LT
328
329 dprintk("nfsd: REMOVE(3) %s %.*s\n",
330 SVCFH_fmt(&argp->fh),
331 argp->len,
332 argp->name);
333
334 /* Unlink. -S_IFDIR means file must not be a directory */
335 fh_copy(&resp->fh, &argp->fh);
336 nfserr = nfsd_unlink(rqstp, &resp->fh, -S_IFDIR, argp->name, argp->len);
43a9aa64 337 fh_unlock(&resp->fh);
1da177e4
LT
338 RETURN_STATUS(nfserr);
339}
340
341/*
342 * Remove a directory
343 */
7111c66e 344static __be32
1da177e4
LT
345nfsd3_proc_rmdir(struct svc_rqst *rqstp, struct nfsd3_diropargs *argp,
346 struct nfsd3_attrstat *resp)
347{
c4d987ba 348 __be32 nfserr;
1da177e4
LT
349
350 dprintk("nfsd: RMDIR(3) %s %.*s\n",
351 SVCFH_fmt(&argp->fh),
352 argp->len,
353 argp->name);
354
355 fh_copy(&resp->fh, &argp->fh);
356 nfserr = nfsd_unlink(rqstp, &resp->fh, S_IFDIR, argp->name, argp->len);
43a9aa64 357 fh_unlock(&resp->fh);
1da177e4
LT
358 RETURN_STATUS(nfserr);
359}
360
7111c66e 361static __be32
1da177e4
LT
362nfsd3_proc_rename(struct svc_rqst *rqstp, struct nfsd3_renameargs *argp,
363 struct nfsd3_renameres *resp)
364{
c4d987ba 365 __be32 nfserr;
1da177e4
LT
366
367 dprintk("nfsd: RENAME(3) %s %.*s ->\n",
368 SVCFH_fmt(&argp->ffh),
369 argp->flen,
370 argp->fname);
371 dprintk("nfsd: -> %s %.*s\n",
372 SVCFH_fmt(&argp->tfh),
373 argp->tlen,
374 argp->tname);
375
376 fh_copy(&resp->ffh, &argp->ffh);
377 fh_copy(&resp->tfh, &argp->tfh);
378 nfserr = nfsd_rename(rqstp, &resp->ffh, argp->fname, argp->flen,
379 &resp->tfh, argp->tname, argp->tlen);
380 RETURN_STATUS(nfserr);
381}
382
7111c66e 383static __be32
1da177e4
LT
384nfsd3_proc_link(struct svc_rqst *rqstp, struct nfsd3_linkargs *argp,
385 struct nfsd3_linkres *resp)
386{
c4d987ba 387 __be32 nfserr;
1da177e4
LT
388
389 dprintk("nfsd: LINK(3) %s ->\n",
390 SVCFH_fmt(&argp->ffh));
391 dprintk("nfsd: -> %s %.*s\n",
392 SVCFH_fmt(&argp->tfh),
393 argp->tlen,
394 argp->tname);
395
396 fh_copy(&resp->fh, &argp->ffh);
397 fh_copy(&resp->tfh, &argp->tfh);
398 nfserr = nfsd_link(rqstp, &resp->tfh, argp->tname, argp->tlen,
399 &resp->fh);
400 RETURN_STATUS(nfserr);
401}
402
403/*
404 * Read a portion of a directory.
405 */
7111c66e 406static __be32
1da177e4
LT
407nfsd3_proc_readdir(struct svc_rqst *rqstp, struct nfsd3_readdirargs *argp,
408 struct nfsd3_readdirres *resp)
409{
c4d987ba
AV
410 __be32 nfserr;
411 int count;
1da177e4
LT
412
413 dprintk("nfsd: READDIR(3) %s %d bytes at %d\n",
414 SVCFH_fmt(&argp->fh),
415 argp->count, (u32) argp->cookie);
416
417 /* Make sure we've room for the NULL ptr & eof flag, and shrink to
418 * client read size */
419 count = (argp->count >> 2) - 2;
420
421 /* Read directory and encode entries on the fly */
422 fh_copy(&resp->fh, &argp->fh);
423
424 resp->buflen = count;
425 resp->common.err = nfs_ok;
426 resp->buffer = argp->buffer;
427 resp->rqstp = rqstp;
428 nfserr = nfsd_readdir(rqstp, &resp->fh, (loff_t*) &argp->cookie,
429 &resp->common, nfs3svc_encode_entry);
430 memcpy(resp->verf, argp->verf, 8);
431 resp->count = resp->buffer - argp->buffer;
432 if (resp->offset)
433 xdr_encode_hyper(resp->offset, argp->cookie);
434
435 RETURN_STATUS(nfserr);
436}
437
438/*
439 * Read a portion of a directory, including file handles and attrs.
440 * For now, we choose to ignore the dircount parameter.
441 */
7111c66e 442static __be32
1da177e4
LT
443nfsd3_proc_readdirplus(struct svc_rqst *rqstp, struct nfsd3_readdirargs *argp,
444 struct nfsd3_readdirres *resp)
445{
c4d987ba
AV
446 __be32 nfserr;
447 int count = 0;
1da177e4 448 loff_t offset;
afc59400 449 struct page **p;
1da177e4
LT
450 caddr_t page_addr = NULL;
451
452 dprintk("nfsd: READDIR+(3) %s %d bytes at %d\n",
453 SVCFH_fmt(&argp->fh),
454 argp->count, (u32) argp->cookie);
455
456 /* Convert byte count to number of words (i.e. >> 2),
457 * and reserve room for the NULL ptr & eof flag (-2 words) */
458 resp->count = (argp->count >> 2) - 2;
459
460 /* Read directory and encode entries on the fly */
461 fh_copy(&resp->fh, &argp->fh);
462
463 resp->common.err = nfs_ok;
464 resp->buffer = argp->buffer;
465 resp->buflen = resp->count;
466 resp->rqstp = rqstp;
467 offset = argp->cookie;
18c01ab3
RG
468
469 nfserr = fh_verify(rqstp, &resp->fh, S_IFDIR, NFSD_MAY_NOP);
470 if (nfserr)
471 RETURN_STATUS(nfserr);
472
473 if (resp->fh.fh_export->ex_flags & NFSEXP_NOREADDIRPLUS)
474 RETURN_STATUS(nfserr_notsupp);
475
1da177e4
LT
476 nfserr = nfsd_readdir(rqstp, &resp->fh,
477 &offset,
478 &resp->common,
479 nfs3svc_encode_entry_plus);
480 memcpy(resp->verf, argp->verf, 8);
afc59400
BF
481 for (p = rqstp->rq_respages + 1; p < rqstp->rq_next_page; p++) {
482 page_addr = page_address(*p);
1da177e4
LT
483
484 if (((caddr_t)resp->buffer >= page_addr) &&
485 ((caddr_t)resp->buffer < page_addr + PAGE_SIZE)) {
486 count += (caddr_t)resp->buffer - page_addr;
487 break;
488 }
489 count += PAGE_SIZE;
490 }
491 resp->count = count >> 2;
492 if (resp->offset) {
493 if (unlikely(resp->offset1)) {
494 /* we ended up with offset on a page boundary */
495 *resp->offset = htonl(offset >> 32);
496 *resp->offset1 = htonl(offset & 0xffffffff);
497 resp->offset1 = NULL;
498 } else {
499 xdr_encode_hyper(resp->offset, offset);
500 }
501 }
502
503 RETURN_STATUS(nfserr);
504}
505
506/*
507 * Get file system stats
508 */
7111c66e 509static __be32
1da177e4
LT
510nfsd3_proc_fsstat(struct svc_rqst * rqstp, struct nfsd_fhandle *argp,
511 struct nfsd3_fsstatres *resp)
512{
c4d987ba 513 __be32 nfserr;
1da177e4
LT
514
515 dprintk("nfsd: FSSTAT(3) %s\n",
516 SVCFH_fmt(&argp->fh));
517
04716e66 518 nfserr = nfsd_statfs(rqstp, &argp->fh, &resp->stats, 0);
1da177e4
LT
519 fh_put(&argp->fh);
520 RETURN_STATUS(nfserr);
521}
522
523/*
524 * Get file system info
525 */
7111c66e 526static __be32
1da177e4
LT
527nfsd3_proc_fsinfo(struct svc_rqst * rqstp, struct nfsd_fhandle *argp,
528 struct nfsd3_fsinfores *resp)
529{
c4d987ba 530 __be32 nfserr;
7adae489 531 u32 max_blocksize = svc_max_payload(rqstp);
1da177e4
LT
532
533 dprintk("nfsd: FSINFO(3) %s\n",
534 SVCFH_fmt(&argp->fh));
535
7adae489
GB
536 resp->f_rtmax = max_blocksize;
537 resp->f_rtpref = max_blocksize;
1da177e4 538 resp->f_rtmult = PAGE_SIZE;
7adae489
GB
539 resp->f_wtmax = max_blocksize;
540 resp->f_wtpref = max_blocksize;
1da177e4
LT
541 resp->f_wtmult = PAGE_SIZE;
542 resp->f_dtpref = PAGE_SIZE;
543 resp->f_maxfilesize = ~(u32) 0;
544 resp->f_properties = NFS3_FSF_DEFAULT;
545
04716e66
BF
546 nfserr = fh_verify(rqstp, &argp->fh, 0,
547 NFSD_MAY_NOP | NFSD_MAY_BYPASS_GSS_ON_ROOT);
1da177e4
LT
548
549 /* Check special features of the file system. May request
550 * different read/write sizes for file systems known to have
551 * problems with large blocks */
552 if (nfserr == 0) {
fc64005c 553 struct super_block *sb = argp->fh.fh_dentry->d_sb;
1da177e4
LT
554
555 /* Note that we don't care for remote fs's here */
12214cb7 556 if (sb->s_magic == MSDOS_SUPER_MAGIC) {
1da177e4
LT
557 resp->f_properties = NFS3_FSF_BILLYBOY;
558 }
559 resp->f_maxfilesize = sb->s_maxbytes;
560 }
561
562 fh_put(&argp->fh);
563 RETURN_STATUS(nfserr);
564}
565
566/*
567 * Get pathconf info for the specified file
568 */
7111c66e 569static __be32
1da177e4
LT
570nfsd3_proc_pathconf(struct svc_rqst * rqstp, struct nfsd_fhandle *argp,
571 struct nfsd3_pathconfres *resp)
572{
c4d987ba 573 __be32 nfserr;
1da177e4
LT
574
575 dprintk("nfsd: PATHCONF(3) %s\n",
576 SVCFH_fmt(&argp->fh));
577
578 /* Set default pathconf */
579 resp->p_link_max = 255; /* at least */
580 resp->p_name_max = 255; /* at least */
581 resp->p_no_trunc = 0;
582 resp->p_chown_restricted = 1;
583 resp->p_case_insensitive = 0;
584 resp->p_case_preserving = 1;
585
8837abca 586 nfserr = fh_verify(rqstp, &argp->fh, 0, NFSD_MAY_NOP);
1da177e4
LT
587
588 if (nfserr == 0) {
fc64005c 589 struct super_block *sb = argp->fh.fh_dentry->d_sb;
1da177e4
LT
590
591 /* Note that we don't care for remote fs's here */
592 switch (sb->s_magic) {
593 case EXT2_SUPER_MAGIC:
594 resp->p_link_max = EXT2_LINK_MAX;
595 resp->p_name_max = EXT2_NAME_LEN;
596 break;
12214cb7 597 case MSDOS_SUPER_MAGIC:
1da177e4
LT
598 resp->p_case_insensitive = 1;
599 resp->p_case_preserving = 0;
600 break;
601 }
602 }
603
604 fh_put(&argp->fh);
605 RETURN_STATUS(nfserr);
606}
607
608
609/*
610 * Commit a file (range) to stable storage.
611 */
7111c66e 612static __be32
1da177e4
LT
613nfsd3_proc_commit(struct svc_rqst * rqstp, struct nfsd3_commitargs *argp,
614 struct nfsd3_commitres *resp)
615{
c4d987ba 616 __be32 nfserr;
1da177e4
LT
617
618 dprintk("nfsd: COMMIT(3) %s %u@%Lu\n",
619 SVCFH_fmt(&argp->fh),
620 argp->count,
621 (unsigned long long) argp->offset);
622
623 if (argp->offset > NFS_OFFSET_MAX)
624 RETURN_STATUS(nfserr_inval);
625
626 fh_copy(&resp->fh, &argp->fh);
627 nfserr = nfsd_commit(rqstp, &resp->fh, argp->offset, argp->count);
628
629 RETURN_STATUS(nfserr);
630}
631
632
633/*
634 * NFSv3 Server procedures.
635 * Only the results of non-idempotent operations are cached.
636 */
1da177e4
LT
637#define nfs3svc_decode_fhandleargs nfs3svc_decode_fhandle
638#define nfs3svc_encode_attrstatres nfs3svc_encode_attrstat
639#define nfs3svc_encode_wccstatres nfs3svc_encode_wccstat
640#define nfsd3_mkdirargs nfsd3_createargs
641#define nfsd3_readdirplusargs nfsd3_readdirargs
642#define nfsd3_fhandleargs nfsd_fhandle
643#define nfsd3_fhandleres nfsd3_attrstat
644#define nfsd3_attrstatres nfsd3_attrstat
645#define nfsd3_wccstatres nfsd3_attrstat
646#define nfsd3_createres nfsd3_diropres
647#define nfsd3_voidres nfsd3_voidargs
648struct nfsd3_voidargs { int dummy; };
649
1da177e4
LT
650#define ST 1 /* status*/
651#define FH 17 /* filehandle with length */
652#define AT 21 /* attributes */
653#define pAT (1+AT) /* post attributes - conditional */
654#define WC (7+pAT) /* WCC attributes */
655
656static struct svc_procedure nfsd_procedures3[22] = {
b9081d90
YZ
657 [NFS3PROC_NULL] = {
658 .pc_func = (svc_procfunc) nfsd3_proc_null,
659 .pc_encode = (kxdrproc_t) nfs3svc_encode_voidres,
660 .pc_argsize = sizeof(struct nfsd3_voidargs),
661 .pc_ressize = sizeof(struct nfsd3_voidres),
662 .pc_cachetype = RC_NOCACHE,
663 .pc_xdrressize = ST,
664 },
665 [NFS3PROC_GETATTR] = {
666 .pc_func = (svc_procfunc) nfsd3_proc_getattr,
667 .pc_decode = (kxdrproc_t) nfs3svc_decode_fhandleargs,
668 .pc_encode = (kxdrproc_t) nfs3svc_encode_attrstatres,
669 .pc_release = (kxdrproc_t) nfs3svc_release_fhandle,
670 .pc_argsize = sizeof(struct nfsd3_fhandleargs),
671 .pc_ressize = sizeof(struct nfsd3_attrstatres),
672 .pc_cachetype = RC_NOCACHE,
673 .pc_xdrressize = ST+AT,
674 },
675 [NFS3PROC_SETATTR] = {
676 .pc_func = (svc_procfunc) nfsd3_proc_setattr,
677 .pc_decode = (kxdrproc_t) nfs3svc_decode_sattrargs,
678 .pc_encode = (kxdrproc_t) nfs3svc_encode_wccstatres,
679 .pc_release = (kxdrproc_t) nfs3svc_release_fhandle,
680 .pc_argsize = sizeof(struct nfsd3_sattrargs),
681 .pc_ressize = sizeof(struct nfsd3_wccstatres),
682 .pc_cachetype = RC_REPLBUFF,
683 .pc_xdrressize = ST+WC,
684 },
685 [NFS3PROC_LOOKUP] = {
686 .pc_func = (svc_procfunc) nfsd3_proc_lookup,
687 .pc_decode = (kxdrproc_t) nfs3svc_decode_diropargs,
688 .pc_encode = (kxdrproc_t) nfs3svc_encode_diropres,
689 .pc_release = (kxdrproc_t) nfs3svc_release_fhandle2,
690 .pc_argsize = sizeof(struct nfsd3_diropargs),
691 .pc_ressize = sizeof(struct nfsd3_diropres),
692 .pc_cachetype = RC_NOCACHE,
693 .pc_xdrressize = ST+FH+pAT+pAT,
694 },
695 [NFS3PROC_ACCESS] = {
696 .pc_func = (svc_procfunc) nfsd3_proc_access,
697 .pc_decode = (kxdrproc_t) nfs3svc_decode_accessargs,
698 .pc_encode = (kxdrproc_t) nfs3svc_encode_accessres,
699 .pc_release = (kxdrproc_t) nfs3svc_release_fhandle,
700 .pc_argsize = sizeof(struct nfsd3_accessargs),
701 .pc_ressize = sizeof(struct nfsd3_accessres),
702 .pc_cachetype = RC_NOCACHE,
703 .pc_xdrressize = ST+pAT+1,
704 },
705 [NFS3PROC_READLINK] = {
706 .pc_func = (svc_procfunc) nfsd3_proc_readlink,
707 .pc_decode = (kxdrproc_t) nfs3svc_decode_readlinkargs,
708 .pc_encode = (kxdrproc_t) nfs3svc_encode_readlinkres,
709 .pc_release = (kxdrproc_t) nfs3svc_release_fhandle,
710 .pc_argsize = sizeof(struct nfsd3_readlinkargs),
711 .pc_ressize = sizeof(struct nfsd3_readlinkres),
712 .pc_cachetype = RC_NOCACHE,
713 .pc_xdrressize = ST+pAT+1+NFS3_MAXPATHLEN/4,
714 },
715 [NFS3PROC_READ] = {
716 .pc_func = (svc_procfunc) nfsd3_proc_read,
717 .pc_decode = (kxdrproc_t) nfs3svc_decode_readargs,
718 .pc_encode = (kxdrproc_t) nfs3svc_encode_readres,
719 .pc_release = (kxdrproc_t) nfs3svc_release_fhandle,
720 .pc_argsize = sizeof(struct nfsd3_readargs),
721 .pc_ressize = sizeof(struct nfsd3_readres),
722 .pc_cachetype = RC_NOCACHE,
723 .pc_xdrressize = ST+pAT+4+NFSSVC_MAXBLKSIZE/4,
724 },
725 [NFS3PROC_WRITE] = {
726 .pc_func = (svc_procfunc) nfsd3_proc_write,
727 .pc_decode = (kxdrproc_t) nfs3svc_decode_writeargs,
728 .pc_encode = (kxdrproc_t) nfs3svc_encode_writeres,
729 .pc_release = (kxdrproc_t) nfs3svc_release_fhandle,
730 .pc_argsize = sizeof(struct nfsd3_writeargs),
731 .pc_ressize = sizeof(struct nfsd3_writeres),
732 .pc_cachetype = RC_REPLBUFF,
733 .pc_xdrressize = ST+WC+4,
734 },
735 [NFS3PROC_CREATE] = {
736 .pc_func = (svc_procfunc) nfsd3_proc_create,
737 .pc_decode = (kxdrproc_t) nfs3svc_decode_createargs,
738 .pc_encode = (kxdrproc_t) nfs3svc_encode_createres,
739 .pc_release = (kxdrproc_t) nfs3svc_release_fhandle2,
740 .pc_argsize = sizeof(struct nfsd3_createargs),
741 .pc_ressize = sizeof(struct nfsd3_createres),
742 .pc_cachetype = RC_REPLBUFF,
743 .pc_xdrressize = ST+(1+FH+pAT)+WC,
744 },
745 [NFS3PROC_MKDIR] = {
746 .pc_func = (svc_procfunc) nfsd3_proc_mkdir,
747 .pc_decode = (kxdrproc_t) nfs3svc_decode_mkdirargs,
748 .pc_encode = (kxdrproc_t) nfs3svc_encode_createres,
749 .pc_release = (kxdrproc_t) nfs3svc_release_fhandle2,
750 .pc_argsize = sizeof(struct nfsd3_mkdirargs),
751 .pc_ressize = sizeof(struct nfsd3_createres),
752 .pc_cachetype = RC_REPLBUFF,
753 .pc_xdrressize = ST+(1+FH+pAT)+WC,
754 },
755 [NFS3PROC_SYMLINK] = {
756 .pc_func = (svc_procfunc) nfsd3_proc_symlink,
757 .pc_decode = (kxdrproc_t) nfs3svc_decode_symlinkargs,
758 .pc_encode = (kxdrproc_t) nfs3svc_encode_createres,
759 .pc_release = (kxdrproc_t) nfs3svc_release_fhandle2,
760 .pc_argsize = sizeof(struct nfsd3_symlinkargs),
761 .pc_ressize = sizeof(struct nfsd3_createres),
762 .pc_cachetype = RC_REPLBUFF,
763 .pc_xdrressize = ST+(1+FH+pAT)+WC,
764 },
765 [NFS3PROC_MKNOD] = {
766 .pc_func = (svc_procfunc) nfsd3_proc_mknod,
767 .pc_decode = (kxdrproc_t) nfs3svc_decode_mknodargs,
768 .pc_encode = (kxdrproc_t) nfs3svc_encode_createres,
769 .pc_release = (kxdrproc_t) nfs3svc_release_fhandle2,
770 .pc_argsize = sizeof(struct nfsd3_mknodargs),
771 .pc_ressize = sizeof(struct nfsd3_createres),
772 .pc_cachetype = RC_REPLBUFF,
773 .pc_xdrressize = ST+(1+FH+pAT)+WC,
774 },
775 [NFS3PROC_REMOVE] = {
776 .pc_func = (svc_procfunc) nfsd3_proc_remove,
777 .pc_decode = (kxdrproc_t) nfs3svc_decode_diropargs,
778 .pc_encode = (kxdrproc_t) nfs3svc_encode_wccstatres,
779 .pc_release = (kxdrproc_t) nfs3svc_release_fhandle,
780 .pc_argsize = sizeof(struct nfsd3_diropargs),
781 .pc_ressize = sizeof(struct nfsd3_wccstatres),
782 .pc_cachetype = RC_REPLBUFF,
783 .pc_xdrressize = ST+WC,
784 },
785 [NFS3PROC_RMDIR] = {
786 .pc_func = (svc_procfunc) nfsd3_proc_rmdir,
787 .pc_decode = (kxdrproc_t) nfs3svc_decode_diropargs,
788 .pc_encode = (kxdrproc_t) nfs3svc_encode_wccstatres,
789 .pc_release = (kxdrproc_t) nfs3svc_release_fhandle,
790 .pc_argsize = sizeof(struct nfsd3_diropargs),
791 .pc_ressize = sizeof(struct nfsd3_wccstatres),
792 .pc_cachetype = RC_REPLBUFF,
793 .pc_xdrressize = ST+WC,
794 },
795 [NFS3PROC_RENAME] = {
796 .pc_func = (svc_procfunc) nfsd3_proc_rename,
797 .pc_decode = (kxdrproc_t) nfs3svc_decode_renameargs,
798 .pc_encode = (kxdrproc_t) nfs3svc_encode_renameres,
799 .pc_release = (kxdrproc_t) nfs3svc_release_fhandle2,
800 .pc_argsize = sizeof(struct nfsd3_renameargs),
801 .pc_ressize = sizeof(struct nfsd3_renameres),
802 .pc_cachetype = RC_REPLBUFF,
803 .pc_xdrressize = ST+WC+WC,
804 },
805 [NFS3PROC_LINK] = {
806 .pc_func = (svc_procfunc) nfsd3_proc_link,
807 .pc_decode = (kxdrproc_t) nfs3svc_decode_linkargs,
808 .pc_encode = (kxdrproc_t) nfs3svc_encode_linkres,
809 .pc_release = (kxdrproc_t) nfs3svc_release_fhandle2,
810 .pc_argsize = sizeof(struct nfsd3_linkargs),
811 .pc_ressize = sizeof(struct nfsd3_linkres),
812 .pc_cachetype = RC_REPLBUFF,
813 .pc_xdrressize = ST+pAT+WC,
814 },
815 [NFS3PROC_READDIR] = {
816 .pc_func = (svc_procfunc) nfsd3_proc_readdir,
817 .pc_decode = (kxdrproc_t) nfs3svc_decode_readdirargs,
818 .pc_encode = (kxdrproc_t) nfs3svc_encode_readdirres,
819 .pc_release = (kxdrproc_t) nfs3svc_release_fhandle,
820 .pc_argsize = sizeof(struct nfsd3_readdirargs),
821 .pc_ressize = sizeof(struct nfsd3_readdirres),
822 .pc_cachetype = RC_NOCACHE,
823 },
824 [NFS3PROC_READDIRPLUS] = {
825 .pc_func = (svc_procfunc) nfsd3_proc_readdirplus,
826 .pc_decode = (kxdrproc_t) nfs3svc_decode_readdirplusargs,
827 .pc_encode = (kxdrproc_t) nfs3svc_encode_readdirres,
828 .pc_release = (kxdrproc_t) nfs3svc_release_fhandle,
829 .pc_argsize = sizeof(struct nfsd3_readdirplusargs),
830 .pc_ressize = sizeof(struct nfsd3_readdirres),
831 .pc_cachetype = RC_NOCACHE,
832 },
833 [NFS3PROC_FSSTAT] = {
834 .pc_func = (svc_procfunc) nfsd3_proc_fsstat,
835 .pc_decode = (kxdrproc_t) nfs3svc_decode_fhandleargs,
836 .pc_encode = (kxdrproc_t) nfs3svc_encode_fsstatres,
837 .pc_argsize = sizeof(struct nfsd3_fhandleargs),
838 .pc_ressize = sizeof(struct nfsd3_fsstatres),
839 .pc_cachetype = RC_NOCACHE,
840 .pc_xdrressize = ST+pAT+2*6+1,
841 },
842 [NFS3PROC_FSINFO] = {
843 .pc_func = (svc_procfunc) nfsd3_proc_fsinfo,
844 .pc_decode = (kxdrproc_t) nfs3svc_decode_fhandleargs,
845 .pc_encode = (kxdrproc_t) nfs3svc_encode_fsinfores,
846 .pc_argsize = sizeof(struct nfsd3_fhandleargs),
847 .pc_ressize = sizeof(struct nfsd3_fsinfores),
848 .pc_cachetype = RC_NOCACHE,
849 .pc_xdrressize = ST+pAT+12,
850 },
851 [NFS3PROC_PATHCONF] = {
852 .pc_func = (svc_procfunc) nfsd3_proc_pathconf,
853 .pc_decode = (kxdrproc_t) nfs3svc_decode_fhandleargs,
854 .pc_encode = (kxdrproc_t) nfs3svc_encode_pathconfres,
855 .pc_argsize = sizeof(struct nfsd3_fhandleargs),
856 .pc_ressize = sizeof(struct nfsd3_pathconfres),
857 .pc_cachetype = RC_NOCACHE,
858 .pc_xdrressize = ST+pAT+6,
859 },
860 [NFS3PROC_COMMIT] = {
861 .pc_func = (svc_procfunc) nfsd3_proc_commit,
862 .pc_decode = (kxdrproc_t) nfs3svc_decode_commitargs,
863 .pc_encode = (kxdrproc_t) nfs3svc_encode_commitres,
864 .pc_release = (kxdrproc_t) nfs3svc_release_fhandle,
865 .pc_argsize = sizeof(struct nfsd3_commitargs),
866 .pc_ressize = sizeof(struct nfsd3_commitres),
867 .pc_cachetype = RC_NOCACHE,
868 .pc_xdrressize = ST+WC+2,
869 },
1da177e4
LT
870};
871
872struct svc_version nfsd_version3 = {
873 .vs_vers = 3,
874 .vs_nproc = 22,
875 .vs_proc = nfsd_procedures3,
876 .vs_dispatch = nfsd_dispatch,
877 .vs_xdrsize = NFS3_SVC_XDRSIZE,
878};