NFS: Fix NFSv4 symbolic trace point output
[linux-2.6-block.git] / fs / nfs / nfs3xdr.c
CommitLineData
b2441318 1// SPDX-License-Identifier: GPL-2.0
1da177e4
LT
2/*
3 * linux/fs/nfs/nfs3xdr.c
4 *
5 * XDR functions to encode/decode NFSv3 RPC arguments and results.
6 *
7 * Copyright (C) 1996, 1997 Olaf Kirch
8 */
9
10#include <linux/param.h>
11#include <linux/time.h>
12#include <linux/mm.h>
1da177e4
LT
13#include <linux/errno.h>
14#include <linux/string.h>
15#include <linux/in.h>
16#include <linux/pagemap.h>
17#include <linux/proc_fs.h>
18#include <linux/kdev_t.h>
19#include <linux/sunrpc/clnt.h>
20#include <linux/nfs.h>
21#include <linux/nfs3.h>
22#include <linux/nfs_fs.h>
b7fa0554 23#include <linux/nfsacl.h>
f7b422b1 24#include "internal.h"
1da177e4
LT
25
26#define NFSDBG_FACILITY NFSDBG_XDR
27
28/* Mapping from NFS error code to "errno" error code. */
29#define errno_NFSERR_IO EIO
30
1da177e4
LT
31/*
32 * Declare the space requirements for NFS arguments and replies as
33 * number of 32bit-words
34 */
35#define NFS3_fhandle_sz (1+16)
36#define NFS3_fh_sz (NFS3_fhandle_sz) /* shorthand */
37#define NFS3_sattr_sz (15)
38#define NFS3_filename_sz (1+(NFS3_MAXNAMLEN>>2))
39#define NFS3_path_sz (1+(NFS3_MAXPATHLEN>>2))
40#define NFS3_fattr_sz (21)
d9c407b1 41#define NFS3_cookieverf_sz (NFS3_COOKIEVERFSIZE>>2)
f5fc3c50 42#define NFS3_wcc_attr_sz (6)
1da177e4
LT
43#define NFS3_pre_op_attr_sz (1+NFS3_wcc_attr_sz)
44#define NFS3_post_op_attr_sz (1+NFS3_fattr_sz)
f5fc3c50 45#define NFS3_wcc_data_sz (NFS3_pre_op_attr_sz+NFS3_post_op_attr_sz)
1da177e4 46#define NFS3_diropargs_sz (NFS3_fh_sz+NFS3_filename_sz)
ad96b5b5
CL
47
48#define NFS3_getattrargs_sz (NFS3_fh_sz)
49#define NFS3_setattrargs_sz (NFS3_fh_sz+NFS3_sattr_sz+3)
50#define NFS3_lookupargs_sz (NFS3_fh_sz+NFS3_filename_sz)
1da177e4
LT
51#define NFS3_accessargs_sz (NFS3_fh_sz+1)
52#define NFS3_readlinkargs_sz (NFS3_fh_sz)
53#define NFS3_readargs_sz (NFS3_fh_sz+3)
54#define NFS3_writeargs_sz (NFS3_fh_sz+5)
55#define NFS3_createargs_sz (NFS3_diropargs_sz+NFS3_sattr_sz)
56#define NFS3_mkdirargs_sz (NFS3_diropargs_sz+NFS3_sattr_sz)
94a6d753 57#define NFS3_symlinkargs_sz (NFS3_diropargs_sz+1+NFS3_sattr_sz)
1da177e4 58#define NFS3_mknodargs_sz (NFS3_diropargs_sz+2+NFS3_sattr_sz)
ad96b5b5 59#define NFS3_removeargs_sz (NFS3_fh_sz+NFS3_filename_sz)
1da177e4
LT
60#define NFS3_renameargs_sz (NFS3_diropargs_sz+NFS3_diropargs_sz)
61#define NFS3_linkargs_sz (NFS3_fh_sz+NFS3_diropargs_sz)
d9c407b1
CL
62#define NFS3_readdirargs_sz (NFS3_fh_sz+NFS3_cookieverf_sz+3)
63#define NFS3_readdirplusargs_sz (NFS3_fh_sz+NFS3_cookieverf_sz+4)
1da177e4
LT
64#define NFS3_commitargs_sz (NFS3_fh_sz+3)
65
f5fc3c50
CL
66#define NFS3_getattrres_sz (1+NFS3_fattr_sz)
67#define NFS3_setattrres_sz (1+NFS3_wcc_data_sz)
68#define NFS3_removeres_sz (NFS3_setattrres_sz)
1da177e4
LT
69#define NFS3_lookupres_sz (1+NFS3_fh_sz+(2 * NFS3_post_op_attr_sz))
70#define NFS3_accessres_sz (1+NFS3_post_op_attr_sz+1)
71#define NFS3_readlinkres_sz (1+NFS3_post_op_attr_sz+1)
72#define NFS3_readres_sz (1+NFS3_post_op_attr_sz+3)
73#define NFS3_writeres_sz (1+NFS3_wcc_data_sz+4)
74#define NFS3_createres_sz (1+NFS3_fh_sz+NFS3_post_op_attr_sz+NFS3_wcc_data_sz)
75#define NFS3_renameres_sz (1+(2 * NFS3_wcc_data_sz))
76#define NFS3_linkres_sz (1+NFS3_post_op_attr_sz+NFS3_wcc_data_sz)
77#define NFS3_readdirres_sz (1+NFS3_post_op_attr_sz+2)
78#define NFS3_fsstatres_sz (1+NFS3_post_op_attr_sz+13)
79#define NFS3_fsinfores_sz (1+NFS3_post_op_attr_sz+12)
80#define NFS3_pathconfres_sz (1+NFS3_post_op_attr_sz+6)
81#define NFS3_commitres_sz (1+NFS3_wcc_data_sz+2)
82
b7fa0554 83#define ACL3_getaclargs_sz (NFS3_fh_sz+1)
ae46141f
TM
84#define ACL3_setaclargs_sz (NFS3_fh_sz+1+ \
85 XDR_QUADLEN(NFS_ACL_INLINE_BUFSIZE))
86#define ACL3_getaclres_sz (1+NFS3_post_op_attr_sz+1+ \
87 XDR_QUADLEN(NFS_ACL_INLINE_BUFSIZE))
b7fa0554
AG
88#define ACL3_setaclres_sz (1+NFS3_post_op_attr_sz)
89
5e7e5a0d
BS
90static int nfs3_stat_to_errno(enum nfs_stat);
91
1da177e4
LT
92/*
93 * Map file type to S_IFMT bits
94 */
bca79478
TM
95static const umode_t nfs_type2fmt[] = {
96 [NF3BAD] = 0,
97 [NF3REG] = S_IFREG,
98 [NF3DIR] = S_IFDIR,
99 [NF3BLK] = S_IFBLK,
100 [NF3CHR] = S_IFCHR,
101 [NF3LNK] = S_IFLNK,
102 [NF3SOCK] = S_IFSOCK,
103 [NF3FIFO] = S_IFIFO,
1da177e4
LT
104};
105
d9c407b1
CL
106/*
107 * While encoding arguments, set up the reply buffer in advance to
108 * receive reply data directly into the page cache.
109 */
110static void prepare_reply_buffer(struct rpc_rqst *req, struct page **pages,
111 unsigned int base, unsigned int len,
112 unsigned int bufsize)
113{
114 struct rpc_auth *auth = req->rq_cred->cr_auth;
115 unsigned int replen;
116
117 replen = RPC_REPHDRSIZE + auth->au_rslack + bufsize;
118 xdr_inline_pages(&req->rq_rcv_buf, replen << 2, pages, base, len);
119}
120
e4f93234
CL
121/*
122 * Handle decode buffer overflows out-of-line.
123 */
124static void print_overflow_msg(const char *func, const struct xdr_stream *xdr)
125{
126 dprintk("NFS: %s prematurely hit the end of our receive buffer. "
127 "Remaining buffer length is %tu words.\n",
128 func, xdr->end - xdr->p);
129}
130
d9c407b1 131
d9c407b1
CL
132/*
133 * Encode/decode NFSv3 basic data types
134 *
135 * Basic NFSv3 data types are defined in section 2.5 of RFC 1813:
136 * "NFS Version 3 Protocol Specification".
137 *
138 * Not all basic data types have their own encoding and decoding
139 * functions. For run-time efficiency, some data types are encoded
140 * or decoded inline.
141 */
142
143static void encode_uint32(struct xdr_stream *xdr, u32 value)
144{
145 __be32 *p = xdr_reserve_space(xdr, 4);
146 *p = cpu_to_be32(value);
147}
148
e4f93234
CL
149static int decode_uint32(struct xdr_stream *xdr, u32 *value)
150{
151 __be32 *p;
152
153 p = xdr_inline_decode(xdr, 4);
154 if (unlikely(p == NULL))
155 goto out_overflow;
156 *value = be32_to_cpup(p);
157 return 0;
158out_overflow:
159 print_overflow_msg(__func__, xdr);
160 return -EIO;
161}
162
163static int decode_uint64(struct xdr_stream *xdr, u64 *value)
164{
165 __be32 *p;
166
167 p = xdr_inline_decode(xdr, 8);
168 if (unlikely(p == NULL))
169 goto out_overflow;
170 xdr_decode_hyper(p, value);
171 return 0;
172out_overflow:
173 print_overflow_msg(__func__, xdr);
174 return -EIO;
175}
176
177/*
178 * fileid3
179 *
180 * typedef uint64 fileid3;
181 */
f6048709
CL
182static __be32 *xdr_decode_fileid3(__be32 *p, u64 *fileid)
183{
184 return xdr_decode_hyper(p, fileid);
185}
186
e4f93234
CL
187static int decode_fileid3(struct xdr_stream *xdr, u64 *fileid)
188{
189 return decode_uint64(xdr, fileid);
190}
191
d9c407b1
CL
192/*
193 * filename3
194 *
195 * typedef string filename3<>;
196 */
197static void encode_filename3(struct xdr_stream *xdr,
198 const char *name, u32 length)
199{
200 __be32 *p;
201
7fc38846 202 WARN_ON_ONCE(length > NFS3_MAXNAMLEN);
d9c407b1
CL
203 p = xdr_reserve_space(xdr, 4 + length);
204 xdr_encode_opaque(p, name, length);
205}
206
e4f93234
CL
207static int decode_inline_filename3(struct xdr_stream *xdr,
208 const char **name, u32 *length)
209{
210 __be32 *p;
211 u32 count;
212
213 p = xdr_inline_decode(xdr, 4);
214 if (unlikely(p == NULL))
215 goto out_overflow;
216 count = be32_to_cpup(p);
217 if (count > NFS3_MAXNAMLEN)
218 goto out_nametoolong;
219 p = xdr_inline_decode(xdr, count);
220 if (unlikely(p == NULL))
221 goto out_overflow;
222 *name = (const char *)p;
223 *length = count;
224 return 0;
225
226out_nametoolong:
227 dprintk("NFS: returned filename too long: %u\n", count);
228 return -ENAMETOOLONG;
229out_overflow:
230 print_overflow_msg(__func__, xdr);
231 return -EIO;
232}
233
d9c407b1
CL
234/*
235 * nfspath3
236 *
237 * typedef string nfspath3<>;
238 */
239static void encode_nfspath3(struct xdr_stream *xdr, struct page **pages,
240 const u32 length)
241{
d9c407b1
CL
242 encode_uint32(xdr, length);
243 xdr_write_pages(xdr, pages, 0, length);
244}
245
e4f93234
CL
246static int decode_nfspath3(struct xdr_stream *xdr)
247{
248 u32 recvd, count;
e4f93234
CL
249 __be32 *p;
250
251 p = xdr_inline_decode(xdr, 4);
252 if (unlikely(p == NULL))
253 goto out_overflow;
254 count = be32_to_cpup(p);
255 if (unlikely(count >= xdr->buf->page_len || count > NFS3_MAXPATHLEN))
256 goto out_nametoolong;
64bd577e 257 recvd = xdr_read_pages(xdr, count);
e4f93234
CL
258 if (unlikely(count > recvd))
259 goto out_cheating;
e4f93234
CL
260 xdr_terminate_string(xdr->buf, count);
261 return 0;
262
263out_nametoolong:
264 dprintk("NFS: returned pathname too long: %u\n", count);
265 return -ENAMETOOLONG;
266out_cheating:
267 dprintk("NFS: server cheating in pathname result: "
268 "count %u > recvd %u\n", count, recvd);
269 return -EIO;
270out_overflow:
271 print_overflow_msg(__func__, xdr);
272 return -EIO;
273}
274
d9c407b1
CL
275/*
276 * cookie3
277 *
278 * typedef uint64 cookie3
279 */
280static __be32 *xdr_encode_cookie3(__be32 *p, u64 cookie)
281{
282 return xdr_encode_hyper(p, cookie);
283}
284
e4f93234
CL
285static int decode_cookie3(struct xdr_stream *xdr, u64 *cookie)
286{
287 return decode_uint64(xdr, cookie);
288}
289
d9c407b1
CL
290/*
291 * cookieverf3
292 *
293 * typedef opaque cookieverf3[NFS3_COOKIEVERFSIZE];
294 */
295static __be32 *xdr_encode_cookieverf3(__be32 *p, const __be32 *verifier)
296{
297 memcpy(p, verifier, NFS3_COOKIEVERFSIZE);
298 return p + XDR_QUADLEN(NFS3_COOKIEVERFSIZE);
299}
300
e4f93234
CL
301static int decode_cookieverf3(struct xdr_stream *xdr, __be32 *verifier)
302{
303 __be32 *p;
304
305 p = xdr_inline_decode(xdr, NFS3_COOKIEVERFSIZE);
306 if (unlikely(p == NULL))
307 goto out_overflow;
308 memcpy(verifier, p, NFS3_COOKIEVERFSIZE);
309 return 0;
310out_overflow:
311 print_overflow_msg(__func__, xdr);
312 return -EIO;
313}
314
d9c407b1
CL
315/*
316 * createverf3
317 *
318 * typedef opaque createverf3[NFS3_CREATEVERFSIZE];
319 */
320static void encode_createverf3(struct xdr_stream *xdr, const __be32 *verifier)
321{
322 __be32 *p;
323
324 p = xdr_reserve_space(xdr, NFS3_CREATEVERFSIZE);
325 memcpy(p, verifier, NFS3_CREATEVERFSIZE);
326}
327
2f2c63bc 328static int decode_writeverf3(struct xdr_stream *xdr, struct nfs_write_verifier *verifier)
e4f93234
CL
329{
330 __be32 *p;
331
332 p = xdr_inline_decode(xdr, NFS3_WRITEVERFSIZE);
333 if (unlikely(p == NULL))
334 goto out_overflow;
2f2c63bc 335 memcpy(verifier->data, p, NFS3_WRITEVERFSIZE);
e4f93234
CL
336 return 0;
337out_overflow:
338 print_overflow_msg(__func__, xdr);
339 return -EIO;
340}
341
342/*
343 * size3
344 *
345 * typedef uint64 size3;
346 */
347static __be32 *xdr_decode_size3(__be32 *p, u64 *size)
348{
349 return xdr_decode_hyper(p, size);
350}
351
352/*
353 * nfsstat3
354 *
355 * enum nfsstat3 {
356 * NFS3_OK = 0,
357 * ...
358 * }
359 */
360#define NFS3_OK NFS_OK
361
362static int decode_nfsstat3(struct xdr_stream *xdr, enum nfs_stat *status)
363{
364 __be32 *p;
365
366 p = xdr_inline_decode(xdr, 4);
367 if (unlikely(p == NULL))
368 goto out_overflow;
369 *status = be32_to_cpup(p);
370 return 0;
371out_overflow:
372 print_overflow_msg(__func__, xdr);
373 return -EIO;
374}
375
d9c407b1
CL
376/*
377 * ftype3
378 *
379 * enum ftype3 {
380 * NF3REG = 1,
381 * NF3DIR = 2,
382 * NF3BLK = 3,
383 * NF3CHR = 4,
384 * NF3LNK = 5,
385 * NF3SOCK = 6,
386 * NF3FIFO = 7
387 * };
388 */
389static void encode_ftype3(struct xdr_stream *xdr, const u32 type)
390{
d9c407b1
CL
391 encode_uint32(xdr, type);
392}
393
f6048709
CL
394static __be32 *xdr_decode_ftype3(__be32 *p, umode_t *mode)
395{
396 u32 type;
397
398 type = be32_to_cpup(p++);
399 if (type > NF3FIFO)
400 type = NF3NON;
401 *mode = nfs_type2fmt[type];
402 return p;
403}
404
d9c407b1
CL
405/*
406 * specdata3
407 *
408 * struct specdata3 {
409 * uint32 specdata1;
410 * uint32 specdata2;
411 * };
412 */
413static void encode_specdata3(struct xdr_stream *xdr, const dev_t rdev)
414{
415 __be32 *p;
416
417 p = xdr_reserve_space(xdr, 8);
418 *p++ = cpu_to_be32(MAJOR(rdev));
419 *p = cpu_to_be32(MINOR(rdev));
420}
421
f6048709
CL
422static __be32 *xdr_decode_specdata3(__be32 *p, dev_t *rdev)
423{
424 unsigned int major, minor;
425
426 major = be32_to_cpup(p++);
427 minor = be32_to_cpup(p++);
428 *rdev = MKDEV(major, minor);
429 if (MAJOR(*rdev) != major || MINOR(*rdev) != minor)
430 *rdev = 0;
431 return p;
432}
433
d9c407b1
CL
434/*
435 * nfs_fh3
436 *
437 * struct nfs_fh3 {
438 * opaque data<NFS3_FHSIZE>;
439 * };
440 */
441static void encode_nfs_fh3(struct xdr_stream *xdr, const struct nfs_fh *fh)
442{
443 __be32 *p;
444
7fc38846 445 WARN_ON_ONCE(fh->size > NFS3_FHSIZE);
d9c407b1
CL
446 p = xdr_reserve_space(xdr, 4 + fh->size);
447 xdr_encode_opaque(p, fh->data, fh->size);
448}
449
e4f93234
CL
450static int decode_nfs_fh3(struct xdr_stream *xdr, struct nfs_fh *fh)
451{
452 u32 length;
453 __be32 *p;
454
455 p = xdr_inline_decode(xdr, 4);
456 if (unlikely(p == NULL))
457 goto out_overflow;
458 length = be32_to_cpup(p++);
459 if (unlikely(length > NFS3_FHSIZE))
460 goto out_toobig;
461 p = xdr_inline_decode(xdr, length);
462 if (unlikely(p == NULL))
463 goto out_overflow;
464 fh->size = length;
465 memcpy(fh->data, p, length);
466 return 0;
467out_toobig:
468 dprintk("NFS: file handle size (%u) too big\n", length);
469 return -E2BIG;
470out_overflow:
471 print_overflow_msg(__func__, xdr);
472 return -EIO;
473}
474
475static void zero_nfs_fh3(struct nfs_fh *fh)
476{
477 memset(fh, 0, sizeof(*fh));
478}
479
9d5a6434
CL
480/*
481 * nfstime3
482 *
483 * struct nfstime3 {
484 * uint32 seconds;
485 * uint32 nseconds;
486 * };
487 */
488static __be32 *xdr_encode_nfstime3(__be32 *p, const struct timespec *timep)
489{
490 *p++ = cpu_to_be32(timep->tv_sec);
491 *p++ = cpu_to_be32(timep->tv_nsec);
492 return p;
493}
494
f6048709
CL
495static __be32 *xdr_decode_nfstime3(__be32 *p, struct timespec *timep)
496{
497 timep->tv_sec = be32_to_cpup(p++);
498 timep->tv_nsec = be32_to_cpup(p++);
499 return p;
500}
501
d9c407b1
CL
502/*
503 * sattr3
504 *
505 * enum time_how {
506 * DONT_CHANGE = 0,
507 * SET_TO_SERVER_TIME = 1,
508 * SET_TO_CLIENT_TIME = 2
509 * };
510 *
511 * union set_mode3 switch (bool set_it) {
512 * case TRUE:
513 * mode3 mode;
514 * default:
515 * void;
516 * };
517 *
518 * union set_uid3 switch (bool set_it) {
519 * case TRUE:
520 * uid3 uid;
521 * default:
522 * void;
523 * };
524 *
525 * union set_gid3 switch (bool set_it) {
526 * case TRUE:
527 * gid3 gid;
528 * default:
529 * void;
530 * };
531 *
532 * union set_size3 switch (bool set_it) {
533 * case TRUE:
534 * size3 size;
535 * default:
536 * void;
537 * };
538 *
539 * union set_atime switch (time_how set_it) {
540 * case SET_TO_CLIENT_TIME:
541 * nfstime3 atime;
542 * default:
543 * void;
544 * };
545 *
546 * union set_mtime switch (time_how set_it) {
547 * case SET_TO_CLIENT_TIME:
548 * nfstime3 mtime;
549 * default:
550 * void;
551 * };
552 *
553 * struct sattr3 {
554 * set_mode3 mode;
555 * set_uid3 uid;
556 * set_gid3 gid;
557 * set_size3 size;
558 * set_atime atime;
559 * set_mtime mtime;
560 * };
561 */
562static void encode_sattr3(struct xdr_stream *xdr, const struct iattr *attr)
563{
95582b00 564 struct timespec ts;
d9c407b1
CL
565 u32 nbytes;
566 __be32 *p;
567
568 /*
569 * In order to make only a single xdr_reserve_space() call,
570 * pre-compute the total number of bytes to be reserved.
571 * Six boolean values, one for each set_foo field, are always
572 * present in the encoded result, so start there.
573 */
574 nbytes = 6 * 4;
575 if (attr->ia_valid & ATTR_MODE)
576 nbytes += 4;
577 if (attr->ia_valid & ATTR_UID)
578 nbytes += 4;
579 if (attr->ia_valid & ATTR_GID)
580 nbytes += 4;
581 if (attr->ia_valid & ATTR_SIZE)
582 nbytes += 8;
583 if (attr->ia_valid & ATTR_ATIME_SET)
584 nbytes += 8;
585 if (attr->ia_valid & ATTR_MTIME_SET)
586 nbytes += 8;
587 p = xdr_reserve_space(xdr, nbytes);
588
9d5a6434
CL
589 if (attr->ia_valid & ATTR_MODE) {
590 *p++ = xdr_one;
591 *p++ = cpu_to_be32(attr->ia_mode & S_IALLUGO);
592 } else
593 *p++ = xdr_zero;
594
595 if (attr->ia_valid & ATTR_UID) {
596 *p++ = xdr_one;
57a38dae 597 *p++ = cpu_to_be32(from_kuid(&init_user_ns, attr->ia_uid));
9d5a6434
CL
598 } else
599 *p++ = xdr_zero;
600
601 if (attr->ia_valid & ATTR_GID) {
602 *p++ = xdr_one;
57a38dae 603 *p++ = cpu_to_be32(from_kgid(&init_user_ns, attr->ia_gid));
9d5a6434
CL
604 } else
605 *p++ = xdr_zero;
606
607 if (attr->ia_valid & ATTR_SIZE) {
608 *p++ = xdr_one;
609 p = xdr_encode_hyper(p, (u64)attr->ia_size);
610 } else
611 *p++ = xdr_zero;
612
613 if (attr->ia_valid & ATTR_ATIME_SET) {
95582b00 614 struct timespec ts;
9d5a6434 615 *p++ = xdr_two;
95582b00
DD
616 ts = timespec64_to_timespec(attr->ia_atime);
617 p = xdr_encode_nfstime3(p, &ts);
9d5a6434
CL
618 } else if (attr->ia_valid & ATTR_ATIME) {
619 *p++ = xdr_one;
620 } else
621 *p++ = xdr_zero;
622
623 if (attr->ia_valid & ATTR_MTIME_SET) {
624 *p++ = xdr_two;
95582b00
DD
625 ts = timespec64_to_timespec(attr->ia_mtime);
626 xdr_encode_nfstime3(p, &ts);
9d5a6434
CL
627 } else if (attr->ia_valid & ATTR_MTIME) {
628 *p = xdr_one;
629 } else
630 *p = xdr_zero;
d9c407b1
CL
631}
632
e4f93234
CL
633/*
634 * fattr3
635 *
636 * struct fattr3 {
637 * ftype3 type;
638 * mode3 mode;
639 * uint32 nlink;
640 * uid3 uid;
641 * gid3 gid;
642 * size3 size;
643 * size3 used;
644 * specdata3 rdev;
645 * uint64 fsid;
646 * fileid3 fileid;
647 * nfstime3 atime;
648 * nfstime3 mtime;
649 * nfstime3 ctime;
650 * };
651 */
652static int decode_fattr3(struct xdr_stream *xdr, struct nfs_fattr *fattr)
653{
f6048709 654 umode_t fmode;
e4f93234
CL
655 __be32 *p;
656
657 p = xdr_inline_decode(xdr, NFS3_fattr_sz << 2);
658 if (unlikely(p == NULL))
659 goto out_overflow;
f6048709
CL
660
661 p = xdr_decode_ftype3(p, &fmode);
662
663 fattr->mode = (be32_to_cpup(p++) & ~S_IFMT) | fmode;
664 fattr->nlink = be32_to_cpup(p++);
57a38dae
EB
665 fattr->uid = make_kuid(&init_user_ns, be32_to_cpup(p++));
666 if (!uid_valid(fattr->uid))
667 goto out_uid;
668 fattr->gid = make_kgid(&init_user_ns, be32_to_cpup(p++));
669 if (!gid_valid(fattr->gid))
670 goto out_gid;
f6048709
CL
671
672 p = xdr_decode_size3(p, &fattr->size);
673 p = xdr_decode_size3(p, &fattr->du.nfs3.used);
674 p = xdr_decode_specdata3(p, &fattr->rdev);
675
676 p = xdr_decode_hyper(p, &fattr->fsid.major);
677 fattr->fsid.minor = 0;
678
679 p = xdr_decode_fileid3(p, &fattr->fileid);
680 p = xdr_decode_nfstime3(p, &fattr->atime);
681 p = xdr_decode_nfstime3(p, &fattr->mtime);
682 xdr_decode_nfstime3(p, &fattr->ctime);
3a1556e8 683 fattr->change_attr = nfs_timespec_to_change_attr(&fattr->ctime);
f6048709
CL
684
685 fattr->valid |= NFS_ATTR_FATTR_V3;
e4f93234 686 return 0;
57a38dae
EB
687out_uid:
688 dprintk("NFS: returned invalid uid\n");
689 return -EINVAL;
690out_gid:
691 dprintk("NFS: returned invalid gid\n");
692 return -EINVAL;
e4f93234
CL
693out_overflow:
694 print_overflow_msg(__func__, xdr);
695 return -EIO;
696}
697
698/*
699 * post_op_attr
700 *
701 * union post_op_attr switch (bool attributes_follow) {
702 * case TRUE:
703 * fattr3 attributes;
704 * case FALSE:
705 * void;
706 * };
707 */
708static int decode_post_op_attr(struct xdr_stream *xdr, struct nfs_fattr *fattr)
709{
710 __be32 *p;
711
712 p = xdr_inline_decode(xdr, 4);
713 if (unlikely(p == NULL))
714 goto out_overflow;
715 if (*p != xdr_zero)
716 return decode_fattr3(xdr, fattr);
717 return 0;
718out_overflow:
719 print_overflow_msg(__func__, xdr);
720 return -EIO;
721}
722
723/*
724 * wcc_attr
725 * struct wcc_attr {
726 * size3 size;
727 * nfstime3 mtime;
728 * nfstime3 ctime;
729 * };
730 */
731static int decode_wcc_attr(struct xdr_stream *xdr, struct nfs_fattr *fattr)
732{
733 __be32 *p;
734
735 p = xdr_inline_decode(xdr, NFS3_wcc_attr_sz << 2);
736 if (unlikely(p == NULL))
737 goto out_overflow;
f6048709
CL
738
739 fattr->valid |= NFS_ATTR_FATTR_PRESIZE
3a1556e8 740 | NFS_ATTR_FATTR_PRECHANGE
f6048709
CL
741 | NFS_ATTR_FATTR_PREMTIME
742 | NFS_ATTR_FATTR_PRECTIME;
743
744 p = xdr_decode_size3(p, &fattr->pre_size);
745 p = xdr_decode_nfstime3(p, &fattr->pre_mtime);
746 xdr_decode_nfstime3(p, &fattr->pre_ctime);
3a1556e8 747 fattr->pre_change_attr = nfs_timespec_to_change_attr(&fattr->pre_ctime);
f6048709 748
e4f93234
CL
749 return 0;
750out_overflow:
751 print_overflow_msg(__func__, xdr);
752 return -EIO;
753}
754
755/*
756 * pre_op_attr
757 * union pre_op_attr switch (bool attributes_follow) {
758 * case TRUE:
759 * wcc_attr attributes;
760 * case FALSE:
761 * void;
762 * };
763 *
764 * wcc_data
765 *
766 * struct wcc_data {
767 * pre_op_attr before;
768 * post_op_attr after;
769 * };
770 */
771static int decode_pre_op_attr(struct xdr_stream *xdr, struct nfs_fattr *fattr)
772{
773 __be32 *p;
774
775 p = xdr_inline_decode(xdr, 4);
776 if (unlikely(p == NULL))
777 goto out_overflow;
778 if (*p != xdr_zero)
779 return decode_wcc_attr(xdr, fattr);
780 return 0;
781out_overflow:
782 print_overflow_msg(__func__, xdr);
783 return -EIO;
784}
785
786static int decode_wcc_data(struct xdr_stream *xdr, struct nfs_fattr *fattr)
787{
788 int error;
789
790 error = decode_pre_op_attr(xdr, fattr);
791 if (unlikely(error))
792 goto out;
793 error = decode_post_op_attr(xdr, fattr);
794out:
795 return error;
796}
797
798/*
799 * post_op_fh3
800 *
801 * union post_op_fh3 switch (bool handle_follows) {
802 * case TRUE:
803 * nfs_fh3 handle;
804 * case FALSE:
805 * void;
806 * };
807 */
808static int decode_post_op_fh3(struct xdr_stream *xdr, struct nfs_fh *fh)
809{
810 __be32 *p = xdr_inline_decode(xdr, 4);
811 if (unlikely(p == NULL))
812 goto out_overflow;
813 if (*p != xdr_zero)
814 return decode_nfs_fh3(xdr, fh);
815 zero_nfs_fh3(fh);
816 return 0;
817out_overflow:
818 print_overflow_msg(__func__, xdr);
819 return -EIO;
820}
821
d9c407b1
CL
822/*
823 * diropargs3
824 *
825 * struct diropargs3 {
826 * nfs_fh3 dir;
827 * filename3 name;
828 * };
829 */
830static void encode_diropargs3(struct xdr_stream *xdr, const struct nfs_fh *fh,
831 const char *name, u32 length)
832{
833 encode_nfs_fh3(xdr, fh);
834 encode_filename3(xdr, name, length);
835}
836
837
1da177e4 838/*
499ff710
CL
839 * NFSv3 XDR encode functions
840 *
841 * NFSv3 argument types are defined in section 3.3 of RFC 1813:
842 * "NFS Version 3 Protocol Specification".
1da177e4
LT
843 */
844
d9c407b1
CL
845/*
846 * 3.3.1 GETATTR3args
847 *
848 * struct GETATTR3args {
849 * nfs_fh3 object;
850 * };
851 */
9f06c719
CL
852static void nfs3_xdr_enc_getattr3args(struct rpc_rqst *req,
853 struct xdr_stream *xdr,
fcc85819 854 const void *data)
d9c407b1 855{
fcc85819
CH
856 const struct nfs_fh *fh = data;
857
9f06c719 858 encode_nfs_fh3(xdr, fh);
d9c407b1
CL
859}
860
d9c407b1
CL
861/*
862 * 3.3.2 SETATTR3args
863 *
864 * union sattrguard3 switch (bool check) {
865 * case TRUE:
866 * nfstime3 obj_ctime;
867 * case FALSE:
868 * void;
869 * };
870 *
871 * struct SETATTR3args {
872 * nfs_fh3 object;
873 * sattr3 new_attributes;
874 * sattrguard3 guard;
875 * };
876 */
877static void encode_sattrguard3(struct xdr_stream *xdr,
878 const struct nfs3_sattrargs *args)
879{
880 __be32 *p;
881
882 if (args->guard) {
883 p = xdr_reserve_space(xdr, 4 + 8);
884 *p++ = xdr_one;
9d5a6434 885 xdr_encode_nfstime3(p, &args->guardtime);
d9c407b1
CL
886 } else {
887 p = xdr_reserve_space(xdr, 4);
888 *p = xdr_zero;
889 }
890}
891
9f06c719
CL
892static void nfs3_xdr_enc_setattr3args(struct rpc_rqst *req,
893 struct xdr_stream *xdr,
fcc85819 894 const void *data)
d9c407b1 895{
fcc85819 896 const struct nfs3_sattrargs *args = data;
9f06c719
CL
897 encode_nfs_fh3(xdr, args->fh);
898 encode_sattr3(xdr, args->sattr);
899 encode_sattrguard3(xdr, args);
d9c407b1
CL
900}
901
d9c407b1
CL
902/*
903 * 3.3.3 LOOKUP3args
904 *
905 * struct LOOKUP3args {
906 * diropargs3 what;
907 * };
908 */
9f06c719
CL
909static void nfs3_xdr_enc_lookup3args(struct rpc_rqst *req,
910 struct xdr_stream *xdr,
fcc85819 911 const void *data)
d9c407b1 912{
fcc85819
CH
913 const struct nfs3_diropargs *args = data;
914
9f06c719 915 encode_diropargs3(xdr, args->fh, args->name, args->len);
d9c407b1
CL
916}
917
d9c407b1
CL
918/*
919 * 3.3.4 ACCESS3args
920 *
921 * struct ACCESS3args {
922 * nfs_fh3 object;
923 * uint32 access;
924 * };
925 */
926static void encode_access3args(struct xdr_stream *xdr,
927 const struct nfs3_accessargs *args)
928{
929 encode_nfs_fh3(xdr, args->fh);
930 encode_uint32(xdr, args->access);
931}
932
9f06c719
CL
933static void nfs3_xdr_enc_access3args(struct rpc_rqst *req,
934 struct xdr_stream *xdr,
fcc85819 935 const void *data)
d9c407b1 936{
fcc85819
CH
937 const struct nfs3_accessargs *args = data;
938
9f06c719 939 encode_access3args(xdr, args);
d9c407b1
CL
940}
941
942/*
943 * 3.3.5 READLINK3args
944 *
945 * struct READLINK3args {
946 * nfs_fh3 symlink;
947 * };
948 */
9f06c719
CL
949static void nfs3_xdr_enc_readlink3args(struct rpc_rqst *req,
950 struct xdr_stream *xdr,
fcc85819 951 const void *data)
d9c407b1 952{
fcc85819
CH
953 const struct nfs3_readlinkargs *args = data;
954
9f06c719 955 encode_nfs_fh3(xdr, args->fh);
d9c407b1
CL
956 prepare_reply_buffer(req, args->pages, args->pgbase,
957 args->pglen, NFS3_readlinkres_sz);
d9c407b1
CL
958}
959
d9c407b1
CL
960/*
961 * 3.3.6 READ3args
962 *
963 * struct READ3args {
964 * nfs_fh3 file;
965 * offset3 offset;
966 * count3 count;
967 * };
968 */
969static void encode_read3args(struct xdr_stream *xdr,
3c6b899c 970 const struct nfs_pgio_args *args)
d9c407b1
CL
971{
972 __be32 *p;
973
974 encode_nfs_fh3(xdr, args->fh);
975
976 p = xdr_reserve_space(xdr, 8 + 4);
977 p = xdr_encode_hyper(p, args->offset);
978 *p = cpu_to_be32(args->count);
979}
980
9f06c719
CL
981static void nfs3_xdr_enc_read3args(struct rpc_rqst *req,
982 struct xdr_stream *xdr,
fcc85819 983 const void *data)
d9c407b1 984{
fcc85819 985 const struct nfs_pgio_args *args = data;
8d8928d8 986 unsigned int replen = args->replen ? args->replen : NFS3_readres_sz;
fcc85819 987
9f06c719 988 encode_read3args(xdr, args);
d9c407b1 989 prepare_reply_buffer(req, args->pages, args->pgbase,
8d8928d8 990 args->count, replen);
d9c407b1 991 req->rq_rcv_buf.flags |= XDRBUF_READ;
d9c407b1
CL
992}
993
d9c407b1
CL
994/*
995 * 3.3.7 WRITE3args
996 *
997 * enum stable_how {
998 * UNSTABLE = 0,
999 * DATA_SYNC = 1,
1000 * FILE_SYNC = 2
1001 * };
1002 *
1003 * struct WRITE3args {
1004 * nfs_fh3 file;
1005 * offset3 offset;
1006 * count3 count;
1007 * stable_how stable;
1008 * opaque data<>;
1009 * };
1010 */
1011static void encode_write3args(struct xdr_stream *xdr,
3c6b899c 1012 const struct nfs_pgio_args *args)
d9c407b1
CL
1013{
1014 __be32 *p;
1015
1016 encode_nfs_fh3(xdr, args->fh);
1017
1018 p = xdr_reserve_space(xdr, 8 + 4 + 4 + 4);
1019 p = xdr_encode_hyper(p, args->offset);
1020 *p++ = cpu_to_be32(args->count);
d9c407b1 1021 *p++ = cpu_to_be32(args->stable);
d9c407b1
CL
1022 *p = cpu_to_be32(args->count);
1023 xdr_write_pages(xdr, args->pages, args->pgbase, args->count);
1024}
1025
9f06c719
CL
1026static void nfs3_xdr_enc_write3args(struct rpc_rqst *req,
1027 struct xdr_stream *xdr,
fcc85819 1028 const void *data)
d9c407b1 1029{
fcc85819
CH
1030 const struct nfs_pgio_args *args = data;
1031
9f06c719
CL
1032 encode_write3args(xdr, args);
1033 xdr->buf->flags |= XDRBUF_WRITE;
d9c407b1
CL
1034}
1035
d9c407b1
CL
1036/*
1037 * 3.3.8 CREATE3args
1038 *
1039 * enum createmode3 {
1040 * UNCHECKED = 0,
1041 * GUARDED = 1,
1042 * EXCLUSIVE = 2
1043 * };
1044 *
1045 * union createhow3 switch (createmode3 mode) {
1046 * case UNCHECKED:
1047 * case GUARDED:
1048 * sattr3 obj_attributes;
1049 * case EXCLUSIVE:
1050 * createverf3 verf;
1051 * };
1052 *
1053 * struct CREATE3args {
1054 * diropargs3 where;
1055 * createhow3 how;
1056 * };
1057 */
1058static void encode_createhow3(struct xdr_stream *xdr,
1059 const struct nfs3_createargs *args)
1060{
1061 encode_uint32(xdr, args->createmode);
1062 switch (args->createmode) {
1063 case NFS3_CREATE_UNCHECKED:
1064 case NFS3_CREATE_GUARDED:
1065 encode_sattr3(xdr, args->sattr);
1066 break;
1067 case NFS3_CREATE_EXCLUSIVE:
1068 encode_createverf3(xdr, args->verifier);
1069 break;
1070 default:
1071 BUG();
1072 }
1073}
1074
9f06c719
CL
1075static void nfs3_xdr_enc_create3args(struct rpc_rqst *req,
1076 struct xdr_stream *xdr,
fcc85819 1077 const void *data)
d9c407b1 1078{
fcc85819
CH
1079 const struct nfs3_createargs *args = data;
1080
9f06c719
CL
1081 encode_diropargs3(xdr, args->fh, args->name, args->len);
1082 encode_createhow3(xdr, args);
d9c407b1
CL
1083}
1084
d9c407b1
CL
1085/*
1086 * 3.3.9 MKDIR3args
1087 *
1088 * struct MKDIR3args {
1089 * diropargs3 where;
1090 * sattr3 attributes;
1091 * };
1092 */
9f06c719
CL
1093static void nfs3_xdr_enc_mkdir3args(struct rpc_rqst *req,
1094 struct xdr_stream *xdr,
fcc85819 1095 const void *data)
d9c407b1 1096{
fcc85819
CH
1097 const struct nfs3_mkdirargs *args = data;
1098
9f06c719
CL
1099 encode_diropargs3(xdr, args->fh, args->name, args->len);
1100 encode_sattr3(xdr, args->sattr);
d9c407b1
CL
1101}
1102
d9c407b1
CL
1103/*
1104 * 3.3.10 SYMLINK3args
1105 *
1106 * struct symlinkdata3 {
1107 * sattr3 symlink_attributes;
1108 * nfspath3 symlink_data;
1109 * };
1110 *
1111 * struct SYMLINK3args {
1112 * diropargs3 where;
1113 * symlinkdata3 symlink;
1114 * };
1115 */
1116static void encode_symlinkdata3(struct xdr_stream *xdr,
fcc85819 1117 const void *data)
d9c407b1 1118{
fcc85819
CH
1119 const struct nfs3_symlinkargs *args = data;
1120
d9c407b1
CL
1121 encode_sattr3(xdr, args->sattr);
1122 encode_nfspath3(xdr, args->pages, args->pathlen);
1123}
1124
9f06c719
CL
1125static void nfs3_xdr_enc_symlink3args(struct rpc_rqst *req,
1126 struct xdr_stream *xdr,
fcc85819 1127 const void *data)
d9c407b1 1128{
fcc85819
CH
1129 const struct nfs3_symlinkargs *args = data;
1130
9f06c719
CL
1131 encode_diropargs3(xdr, args->fromfh, args->fromname, args->fromlen);
1132 encode_symlinkdata3(xdr, args);
2fcc213a 1133 xdr->buf->flags |= XDRBUF_WRITE;
d9c407b1
CL
1134}
1135
d9c407b1
CL
1136/*
1137 * 3.3.11 MKNOD3args
1138 *
1139 * struct devicedata3 {
1140 * sattr3 dev_attributes;
1141 * specdata3 spec;
1142 * };
1143 *
1144 * union mknoddata3 switch (ftype3 type) {
1145 * case NF3CHR:
1146 * case NF3BLK:
1147 * devicedata3 device;
1148 * case NF3SOCK:
1149 * case NF3FIFO:
1150 * sattr3 pipe_attributes;
1151 * default:
1152 * void;
1153 * };
1154 *
1155 * struct MKNOD3args {
1156 * diropargs3 where;
1157 * mknoddata3 what;
1158 * };
1159 */
1160static void encode_devicedata3(struct xdr_stream *xdr,
1161 const struct nfs3_mknodargs *args)
1162{
1163 encode_sattr3(xdr, args->sattr);
1164 encode_specdata3(xdr, args->rdev);
1165}
1166
1167static void encode_mknoddata3(struct xdr_stream *xdr,
1168 const struct nfs3_mknodargs *args)
1169{
1170 encode_ftype3(xdr, args->type);
1171 switch (args->type) {
1172 case NF3CHR:
1173 case NF3BLK:
1174 encode_devicedata3(xdr, args);
1175 break;
1176 case NF3SOCK:
1177 case NF3FIFO:
1178 encode_sattr3(xdr, args->sattr);
1179 break;
1180 case NF3REG:
1181 case NF3DIR:
1182 break;
1183 default:
1184 BUG();
1185 }
1186}
1187
9f06c719
CL
1188static void nfs3_xdr_enc_mknod3args(struct rpc_rqst *req,
1189 struct xdr_stream *xdr,
fcc85819 1190 const void *data)
d9c407b1 1191{
fcc85819
CH
1192 const struct nfs3_mknodargs *args = data;
1193
9f06c719
CL
1194 encode_diropargs3(xdr, args->fh, args->name, args->len);
1195 encode_mknoddata3(xdr, args);
d9c407b1
CL
1196}
1197
1198/*
1199 * 3.3.12 REMOVE3args
1200 *
1201 * struct REMOVE3args {
1202 * diropargs3 object;
1203 * };
1204 */
9f06c719
CL
1205static void nfs3_xdr_enc_remove3args(struct rpc_rqst *req,
1206 struct xdr_stream *xdr,
fcc85819 1207 const void *data)
d9c407b1 1208{
fcc85819
CH
1209 const struct nfs_removeargs *args = data;
1210
9f06c719 1211 encode_diropargs3(xdr, args->fh, args->name.name, args->name.len);
d9c407b1
CL
1212}
1213
d9c407b1
CL
1214/*
1215 * 3.3.14 RENAME3args
1216 *
1217 * struct RENAME3args {
1218 * diropargs3 from;
1219 * diropargs3 to;
1220 * };
1221 */
9f06c719
CL
1222static void nfs3_xdr_enc_rename3args(struct rpc_rqst *req,
1223 struct xdr_stream *xdr,
fcc85819 1224 const void *data)
d9c407b1 1225{
fcc85819 1226 const struct nfs_renameargs *args = data;
d9c407b1
CL
1227 const struct qstr *old = args->old_name;
1228 const struct qstr *new = args->new_name;
d9c407b1 1229
9f06c719
CL
1230 encode_diropargs3(xdr, args->old_dir, old->name, old->len);
1231 encode_diropargs3(xdr, args->new_dir, new->name, new->len);
d9c407b1
CL
1232}
1233
d9c407b1
CL
1234/*
1235 * 3.3.15 LINK3args
1236 *
1237 * struct LINK3args {
1238 * nfs_fh3 file;
1239 * diropargs3 link;
1240 * };
1241 */
9f06c719
CL
1242static void nfs3_xdr_enc_link3args(struct rpc_rqst *req,
1243 struct xdr_stream *xdr,
fcc85819 1244 const void *data)
d9c407b1 1245{
fcc85819
CH
1246 const struct nfs3_linkargs *args = data;
1247
9f06c719
CL
1248 encode_nfs_fh3(xdr, args->fromfh);
1249 encode_diropargs3(xdr, args->tofh, args->toname, args->tolen);
d9c407b1
CL
1250}
1251
d9c407b1
CL
1252/*
1253 * 3.3.16 READDIR3args
1254 *
1255 * struct READDIR3args {
1256 * nfs_fh3 dir;
1257 * cookie3 cookie;
1258 * cookieverf3 cookieverf;
1259 * count3 count;
1260 * };
1261 */
1262static void encode_readdir3args(struct xdr_stream *xdr,
1263 const struct nfs3_readdirargs *args)
1264{
1265 __be32 *p;
1266
1267 encode_nfs_fh3(xdr, args->fh);
1268
1269 p = xdr_reserve_space(xdr, 8 + NFS3_COOKIEVERFSIZE + 4);
1270 p = xdr_encode_cookie3(p, args->cookie);
1271 p = xdr_encode_cookieverf3(p, args->verf);
1272 *p = cpu_to_be32(args->count);
1273}
1274
9f06c719
CL
1275static void nfs3_xdr_enc_readdir3args(struct rpc_rqst *req,
1276 struct xdr_stream *xdr,
fcc85819 1277 const void *data)
d9c407b1 1278{
fcc85819
CH
1279 const struct nfs3_readdirargs *args = data;
1280
9f06c719 1281 encode_readdir3args(xdr, args);
d9c407b1
CL
1282 prepare_reply_buffer(req, args->pages, 0,
1283 args->count, NFS3_readdirres_sz);
d9c407b1
CL
1284}
1285
1286/*
1287 * 3.3.17 READDIRPLUS3args
1288 *
1289 * struct READDIRPLUS3args {
1290 * nfs_fh3 dir;
1291 * cookie3 cookie;
1292 * cookieverf3 cookieverf;
1293 * count3 dircount;
1294 * count3 maxcount;
1295 * };
1296 */
1297static void encode_readdirplus3args(struct xdr_stream *xdr,
1298 const struct nfs3_readdirargs *args)
1299{
1300 __be32 *p;
1301
1302 encode_nfs_fh3(xdr, args->fh);
1303
1304 p = xdr_reserve_space(xdr, 8 + NFS3_COOKIEVERFSIZE + 4 + 4);
1305 p = xdr_encode_cookie3(p, args->cookie);
1306 p = xdr_encode_cookieverf3(p, args->verf);
1307
1308 /*
1309 * readdirplus: need dircount + buffer size.
1310 * We just make sure we make dircount big enough
1311 */
1312 *p++ = cpu_to_be32(args->count >> 3);
1313
1314 *p = cpu_to_be32(args->count);
1315}
1316
9f06c719
CL
1317static void nfs3_xdr_enc_readdirplus3args(struct rpc_rqst *req,
1318 struct xdr_stream *xdr,
fcc85819 1319 const void *data)
d9c407b1 1320{
fcc85819
CH
1321 const struct nfs3_readdirargs *args = data;
1322
9f06c719 1323 encode_readdirplus3args(xdr, args);
d9c407b1
CL
1324 prepare_reply_buffer(req, args->pages, 0,
1325 args->count, NFS3_readdirres_sz);
d9c407b1
CL
1326}
1327
d9c407b1
CL
1328/*
1329 * 3.3.21 COMMIT3args
1330 *
1331 * struct COMMIT3args {
1332 * nfs_fh3 file;
1333 * offset3 offset;
1334 * count3 count;
1335 * };
1336 */
1337static void encode_commit3args(struct xdr_stream *xdr,
0b7c0153 1338 const struct nfs_commitargs *args)
d9c407b1
CL
1339{
1340 __be32 *p;
1341
1342 encode_nfs_fh3(xdr, args->fh);
1343
1344 p = xdr_reserve_space(xdr, 8 + 4);
1345 p = xdr_encode_hyper(p, args->offset);
1346 *p = cpu_to_be32(args->count);
1347}
1348
9f06c719
CL
1349static void nfs3_xdr_enc_commit3args(struct rpc_rqst *req,
1350 struct xdr_stream *xdr,
fcc85819 1351 const void *data)
d9c407b1 1352{
fcc85819
CH
1353 const struct nfs_commitargs *args = data;
1354
9f06c719 1355 encode_commit3args(xdr, args);
d9c407b1
CL
1356}
1357
b7fa0554 1358#ifdef CONFIG_NFS_V3_ACL
b7fa0554 1359
9f06c719
CL
1360static void nfs3_xdr_enc_getacl3args(struct rpc_rqst *req,
1361 struct xdr_stream *xdr,
fcc85819 1362 const void *data)
d9c407b1 1363{
fcc85819
CH
1364 const struct nfs3_getaclargs *args = data;
1365
9f06c719
CL
1366 encode_nfs_fh3(xdr, args->fh);
1367 encode_uint32(xdr, args->mask);
431f6eb3 1368 if (args->mask & (NFS_ACL | NFS_DFACL)) {
d9c407b1
CL
1369 prepare_reply_buffer(req, args->pages, 0,
1370 NFSACL_MAXPAGES << PAGE_SHIFT,
1371 ACL3_getaclres_sz);
431f6eb3
TM
1372 req->rq_rcv_buf.flags |= XDRBUF_SPARSE_PAGES;
1373 }
d9c407b1
CL
1374}
1375
9f06c719
CL
1376static void nfs3_xdr_enc_setacl3args(struct rpc_rqst *req,
1377 struct xdr_stream *xdr,
fcc85819 1378 const void *data)
d9c407b1 1379{
fcc85819 1380 const struct nfs3_setaclargs *args = data;
d9c407b1
CL
1381 unsigned int base;
1382 int error;
1383
9f06c719
CL
1384 encode_nfs_fh3(xdr, NFS_FH(args->inode));
1385 encode_uint32(xdr, args->mask);
ee5dc773
CL
1386
1387 base = req->rq_slen;
d9c407b1 1388 if (args->npages != 0)
9f06c719 1389 xdr_write_pages(xdr, args->pages, 0, args->len);
ee5dc773 1390 else
d683cc49 1391 xdr_reserve_space(xdr, args->len);
d9c407b1 1392
9f06c719 1393 error = nfsacl_encode(xdr->buf, base, args->inode,
d9c407b1
CL
1394 (args->mask & NFS_ACL) ?
1395 args->acl_access : NULL, 1, 0);
7fc38846 1396 /* FIXME: this is just broken */
d9c407b1 1397 BUG_ON(error < 0);
9f06c719 1398 error = nfsacl_encode(xdr->buf, base + error, args->inode,
d9c407b1
CL
1399 (args->mask & NFS_DFACL) ?
1400 args->acl_default : NULL, 1,
1401 NFS_ACL_DEFAULT);
1402 BUG_ON(error < 0);
d9c407b1
CL
1403}
1404
b7fa0554
AG
1405#endif /* CONFIG_NFS_V3_ACL */
1406
1da177e4 1407/*
b2cdd9c9
CL
1408 * NFSv3 XDR decode functions
1409 *
1410 * NFSv3 result types are defined in section 3.3 of RFC 1813:
1411 * "NFS Version 3 Protocol Specification".
1da177e4 1412 */
1da177e4
LT
1413
1414/*
e4f93234
CL
1415 * 3.3.1 GETATTR3res
1416 *
1417 * struct GETATTR3resok {
1418 * fattr3 obj_attributes;
1419 * };
1420 *
1421 * union GETATTR3res switch (nfsstat3 status) {
1422 * case NFS3_OK:
1423 * GETATTR3resok resok;
1424 * default:
1425 * void;
1426 * };
1da177e4 1427 */
bf269551
CL
1428static int nfs3_xdr_dec_getattr3res(struct rpc_rqst *req,
1429 struct xdr_stream *xdr,
fc016483 1430 void *result)
1da177e4 1431{
e4f93234
CL
1432 enum nfs_stat status;
1433 int error;
1434
bf269551 1435 error = decode_nfsstat3(xdr, &status);
e4f93234
CL
1436 if (unlikely(error))
1437 goto out;
1438 if (status != NFS3_OK)
1439 goto out_default;
bf269551 1440 error = decode_fattr3(xdr, result);
e4f93234
CL
1441out:
1442 return error;
1443out_default:
5e7e5a0d 1444 return nfs3_stat_to_errno(status);
e4f93234
CL
1445}
1446
e4f93234
CL
1447/*
1448 * 3.3.2 SETATTR3res
1449 *
1450 * struct SETATTR3resok {
1451 * wcc_data obj_wcc;
1452 * };
1453 *
1454 * struct SETATTR3resfail {
1455 * wcc_data obj_wcc;
1456 * };
1457 *
1458 * union SETATTR3res switch (nfsstat3 status) {
1459 * case NFS3_OK:
1460 * SETATTR3resok resok;
1461 * default:
1462 * SETATTR3resfail resfail;
1463 * };
1464 */
bf269551
CL
1465static int nfs3_xdr_dec_setattr3res(struct rpc_rqst *req,
1466 struct xdr_stream *xdr,
fc016483 1467 void *result)
e4f93234 1468{
e4f93234
CL
1469 enum nfs_stat status;
1470 int error;
1471
bf269551 1472 error = decode_nfsstat3(xdr, &status);
e4f93234
CL
1473 if (unlikely(error))
1474 goto out;
bf269551 1475 error = decode_wcc_data(xdr, result);
e4f93234
CL
1476 if (unlikely(error))
1477 goto out;
1478 if (status != NFS3_OK)
1479 goto out_status;
1480out:
1481 return error;
1482out_status:
5e7e5a0d 1483 return nfs3_stat_to_errno(status);
e4f93234
CL
1484}
1485
e4f93234
CL
1486/*
1487 * 3.3.3 LOOKUP3res
1488 *
1489 * struct LOOKUP3resok {
1490 * nfs_fh3 object;
1491 * post_op_attr obj_attributes;
1492 * post_op_attr dir_attributes;
1493 * };
1494 *
1495 * struct LOOKUP3resfail {
1496 * post_op_attr dir_attributes;
1497 * };
1498 *
1499 * union LOOKUP3res switch (nfsstat3 status) {
1500 * case NFS3_OK:
1501 * LOOKUP3resok resok;
1502 * default:
1503 * LOOKUP3resfail resfail;
1504 * };
1505 */
bf269551
CL
1506static int nfs3_xdr_dec_lookup3res(struct rpc_rqst *req,
1507 struct xdr_stream *xdr,
fc016483 1508 void *data)
e4f93234 1509{
fc016483 1510 struct nfs3_diropres *result = data;
e4f93234
CL
1511 enum nfs_stat status;
1512 int error;
1513
bf269551 1514 error = decode_nfsstat3(xdr, &status);
e4f93234
CL
1515 if (unlikely(error))
1516 goto out;
1517 if (status != NFS3_OK)
1518 goto out_default;
bf269551 1519 error = decode_nfs_fh3(xdr, result->fh);
e4f93234
CL
1520 if (unlikely(error))
1521 goto out;
bf269551 1522 error = decode_post_op_attr(xdr, result->fattr);
e4f93234
CL
1523 if (unlikely(error))
1524 goto out;
bf269551 1525 error = decode_post_op_attr(xdr, result->dir_attr);
e4f93234
CL
1526out:
1527 return error;
1528out_default:
bf269551 1529 error = decode_post_op_attr(xdr, result->dir_attr);
e4f93234
CL
1530 if (unlikely(error))
1531 goto out;
5e7e5a0d 1532 return nfs3_stat_to_errno(status);
e4f93234
CL
1533}
1534
e4f93234
CL
1535/*
1536 * 3.3.4 ACCESS3res
1537 *
1538 * struct ACCESS3resok {
1539 * post_op_attr obj_attributes;
1540 * uint32 access;
1541 * };
1542 *
1543 * struct ACCESS3resfail {
1544 * post_op_attr obj_attributes;
1545 * };
1546 *
1547 * union ACCESS3res switch (nfsstat3 status) {
1548 * case NFS3_OK:
1549 * ACCESS3resok resok;
1550 * default:
1551 * ACCESS3resfail resfail;
1552 * };
1553 */
bf269551
CL
1554static int nfs3_xdr_dec_access3res(struct rpc_rqst *req,
1555 struct xdr_stream *xdr,
fc016483 1556 void *data)
e4f93234 1557{
fc016483 1558 struct nfs3_accessres *result = data;
e4f93234
CL
1559 enum nfs_stat status;
1560 int error;
1561
bf269551 1562 error = decode_nfsstat3(xdr, &status);
e4f93234
CL
1563 if (unlikely(error))
1564 goto out;
bf269551 1565 error = decode_post_op_attr(xdr, result->fattr);
e4f93234
CL
1566 if (unlikely(error))
1567 goto out;
1568 if (status != NFS3_OK)
1569 goto out_default;
bf269551 1570 error = decode_uint32(xdr, &result->access);
e4f93234
CL
1571out:
1572 return error;
1573out_default:
5e7e5a0d 1574 return nfs3_stat_to_errno(status);
e4f93234
CL
1575}
1576
e4f93234
CL
1577/*
1578 * 3.3.5 READLINK3res
1579 *
1580 * struct READLINK3resok {
1581 * post_op_attr symlink_attributes;
1582 * nfspath3 data;
1583 * };
1584 *
1585 * struct READLINK3resfail {
1586 * post_op_attr symlink_attributes;
1587 * };
1588 *
1589 * union READLINK3res switch (nfsstat3 status) {
1590 * case NFS3_OK:
1591 * READLINK3resok resok;
1592 * default:
1593 * READLINK3resfail resfail;
1594 * };
1595 */
bf269551
CL
1596static int nfs3_xdr_dec_readlink3res(struct rpc_rqst *req,
1597 struct xdr_stream *xdr,
fc016483 1598 void *result)
e4f93234 1599{
e4f93234
CL
1600 enum nfs_stat status;
1601 int error;
1602
bf269551 1603 error = decode_nfsstat3(xdr, &status);
e4f93234
CL
1604 if (unlikely(error))
1605 goto out;
bf269551 1606 error = decode_post_op_attr(xdr, result);
e4f93234
CL
1607 if (unlikely(error))
1608 goto out;
1609 if (status != NFS3_OK)
1610 goto out_default;
bf269551 1611 error = decode_nfspath3(xdr);
e4f93234
CL
1612out:
1613 return error;
1614out_default:
5e7e5a0d 1615 return nfs3_stat_to_errno(status);
e4f93234
CL
1616}
1617
e4f93234
CL
1618/*
1619 * 3.3.6 READ3res
1620 *
1621 * struct READ3resok {
1622 * post_op_attr file_attributes;
1623 * count3 count;
1624 * bool eof;
1625 * opaque data<>;
1626 * };
1627 *
1628 * struct READ3resfail {
1629 * post_op_attr file_attributes;
1630 * };
1631 *
1632 * union READ3res switch (nfsstat3 status) {
1633 * case NFS3_OK:
1634 * READ3resok resok;
1635 * default:
1636 * READ3resfail resfail;
1637 * };
1638 */
1639static int decode_read3resok(struct xdr_stream *xdr,
9137bdf3 1640 struct nfs_pgio_res *result)
e4f93234
CL
1641{
1642 u32 eof, count, ocount, recvd;
e4f93234
CL
1643 __be32 *p;
1644
1645 p = xdr_inline_decode(xdr, 4 + 4 + 4);
1646 if (unlikely(p == NULL))
1647 goto out_overflow;
1648 count = be32_to_cpup(p++);
1649 eof = be32_to_cpup(p++);
1650 ocount = be32_to_cpup(p++);
1651 if (unlikely(ocount != count))
1652 goto out_mismatch;
64bd577e 1653 recvd = xdr_read_pages(xdr, count);
e4f93234
CL
1654 if (unlikely(count > recvd))
1655 goto out_cheating;
e4f93234 1656out:
e4f93234
CL
1657 result->eof = eof;
1658 result->count = count;
1659 return count;
1660out_mismatch:
1661 dprintk("NFS: READ count doesn't match length of opaque: "
1662 "count %u != ocount %u\n", count, ocount);
1663 return -EIO;
1664out_cheating:
1665 dprintk("NFS: server cheating in read result: "
1666 "count %u > recvd %u\n", count, recvd);
1667 count = recvd;
1668 eof = 0;
1669 goto out;
1670out_overflow:
1671 print_overflow_msg(__func__, xdr);
1672 return -EIO;
1673}
1674
bf269551 1675static int nfs3_xdr_dec_read3res(struct rpc_rqst *req, struct xdr_stream *xdr,
fc016483 1676 void *data)
e4f93234 1677{
fc016483 1678 struct nfs_pgio_res *result = data;
8d8928d8 1679 unsigned int pos;
e4f93234
CL
1680 enum nfs_stat status;
1681 int error;
1682
8d8928d8 1683 pos = xdr_stream_pos(xdr);
bf269551 1684 error = decode_nfsstat3(xdr, &status);
e4f93234
CL
1685 if (unlikely(error))
1686 goto out;
bf269551 1687 error = decode_post_op_attr(xdr, result->fattr);
e4f93234
CL
1688 if (unlikely(error))
1689 goto out;
aabff4dd 1690 result->op_status = status;
e4f93234
CL
1691 if (status != NFS3_OK)
1692 goto out_status;
8d8928d8 1693 result->replen = 3 + ((xdr_stream_pos(xdr) - pos) >> 2);
bf269551 1694 error = decode_read3resok(xdr, result);
e4f93234
CL
1695out:
1696 return error;
1697out_status:
5e7e5a0d 1698 return nfs3_stat_to_errno(status);
e4f93234
CL
1699}
1700
e4f93234
CL
1701/*
1702 * 3.3.7 WRITE3res
1703 *
1704 * enum stable_how {
1705 * UNSTABLE = 0,
1706 * DATA_SYNC = 1,
1707 * FILE_SYNC = 2
1708 * };
1709 *
1710 * struct WRITE3resok {
1711 * wcc_data file_wcc;
1712 * count3 count;
1713 * stable_how committed;
1714 * writeverf3 verf;
1715 * };
1716 *
1717 * struct WRITE3resfail {
1718 * wcc_data file_wcc;
1719 * };
1720 *
1721 * union WRITE3res switch (nfsstat3 status) {
1722 * case NFS3_OK:
1723 * WRITE3resok resok;
1724 * default:
1725 * WRITE3resfail resfail;
1726 * };
1727 */
1728static int decode_write3resok(struct xdr_stream *xdr,
9137bdf3 1729 struct nfs_pgio_res *result)
e4f93234
CL
1730{
1731 __be32 *p;
1732
2f2c63bc 1733 p = xdr_inline_decode(xdr, 4 + 4);
e4f93234
CL
1734 if (unlikely(p == NULL))
1735 goto out_overflow;
1736 result->count = be32_to_cpup(p++);
1737 result->verf->committed = be32_to_cpup(p++);
1738 if (unlikely(result->verf->committed > NFS_FILE_SYNC))
1739 goto out_badvalue;
2f2c63bc
TM
1740 if (decode_writeverf3(xdr, &result->verf->verifier))
1741 goto out_eio;
e4f93234
CL
1742 return result->count;
1743out_badvalue:
1744 dprintk("NFS: bad stable_how value: %u\n", result->verf->committed);
1745 return -EIO;
1746out_overflow:
1747 print_overflow_msg(__func__, xdr);
2f2c63bc 1748out_eio:
e4f93234
CL
1749 return -EIO;
1750}
1751
bf269551 1752static int nfs3_xdr_dec_write3res(struct rpc_rqst *req, struct xdr_stream *xdr,
fc016483 1753 void *data)
e4f93234 1754{
fc016483 1755 struct nfs_pgio_res *result = data;
e4f93234
CL
1756 enum nfs_stat status;
1757 int error;
1758
bf269551 1759 error = decode_nfsstat3(xdr, &status);
e4f93234
CL
1760 if (unlikely(error))
1761 goto out;
bf269551 1762 error = decode_wcc_data(xdr, result->fattr);
e4f93234
CL
1763 if (unlikely(error))
1764 goto out;
aabff4dd 1765 result->op_status = status;
e4f93234
CL
1766 if (status != NFS3_OK)
1767 goto out_status;
bf269551 1768 error = decode_write3resok(xdr, result);
e4f93234
CL
1769out:
1770 return error;
1771out_status:
5e7e5a0d 1772 return nfs3_stat_to_errno(status);
e4f93234
CL
1773}
1774
e4f93234
CL
1775/*
1776 * 3.3.8 CREATE3res
1777 *
1778 * struct CREATE3resok {
1779 * post_op_fh3 obj;
1780 * post_op_attr obj_attributes;
1781 * wcc_data dir_wcc;
1782 * };
1783 *
1784 * struct CREATE3resfail {
1785 * wcc_data dir_wcc;
1786 * };
1787 *
1788 * union CREATE3res switch (nfsstat3 status) {
1789 * case NFS3_OK:
1790 * CREATE3resok resok;
1791 * default:
1792 * CREATE3resfail resfail;
1793 * };
1794 */
1795static int decode_create3resok(struct xdr_stream *xdr,
1796 struct nfs3_diropres *result)
1797{
1798 int error;
1799
1800 error = decode_post_op_fh3(xdr, result->fh);
1801 if (unlikely(error))
1802 goto out;
1803 error = decode_post_op_attr(xdr, result->fattr);
1804 if (unlikely(error))
1805 goto out;
1806 /* The server isn't required to return a file handle.
1807 * If it didn't, force the client to perform a LOOKUP
1808 * to determine the correct file handle and attribute
1809 * values for the new object. */
1810 if (result->fh->size == 0)
1811 result->fattr->valid = 0;
1812 error = decode_wcc_data(xdr, result->dir_attr);
1813out:
1814 return error;
1815}
1816
bf269551
CL
1817static int nfs3_xdr_dec_create3res(struct rpc_rqst *req,
1818 struct xdr_stream *xdr,
fc016483 1819 void *data)
e4f93234 1820{
fc016483 1821 struct nfs3_diropres *result = data;
e4f93234
CL
1822 enum nfs_stat status;
1823 int error;
1824
bf269551 1825 error = decode_nfsstat3(xdr, &status);
e4f93234
CL
1826 if (unlikely(error))
1827 goto out;
1828 if (status != NFS3_OK)
1829 goto out_default;
bf269551 1830 error = decode_create3resok(xdr, result);
e4f93234
CL
1831out:
1832 return error;
1833out_default:
bf269551 1834 error = decode_wcc_data(xdr, result->dir_attr);
e4f93234
CL
1835 if (unlikely(error))
1836 goto out;
5e7e5a0d 1837 return nfs3_stat_to_errno(status);
e4f93234
CL
1838}
1839
1840/*
1841 * 3.3.12 REMOVE3res
1842 *
1843 * struct REMOVE3resok {
1844 * wcc_data dir_wcc;
1845 * };
1846 *
1847 * struct REMOVE3resfail {
1848 * wcc_data dir_wcc;
1849 * };
1850 *
1851 * union REMOVE3res switch (nfsstat3 status) {
1852 * case NFS3_OK:
1853 * REMOVE3resok resok;
1854 * default:
1855 * REMOVE3resfail resfail;
1856 * };
1857 */
bf269551
CL
1858static int nfs3_xdr_dec_remove3res(struct rpc_rqst *req,
1859 struct xdr_stream *xdr,
fc016483 1860 void *data)
e4f93234 1861{
fc016483 1862 struct nfs_removeres *result = data;
e4f93234
CL
1863 enum nfs_stat status;
1864 int error;
1865
bf269551 1866 error = decode_nfsstat3(xdr, &status);
e4f93234
CL
1867 if (unlikely(error))
1868 goto out;
bf269551 1869 error = decode_wcc_data(xdr, result->dir_attr);
e4f93234
CL
1870 if (unlikely(error))
1871 goto out;
1872 if (status != NFS3_OK)
1873 goto out_status;
1874out:
1875 return error;
1876out_status:
5e7e5a0d 1877 return nfs3_stat_to_errno(status);
e4f93234
CL
1878}
1879
e4f93234
CL
1880/*
1881 * 3.3.14 RENAME3res
1882 *
1883 * struct RENAME3resok {
1884 * wcc_data fromdir_wcc;
1885 * wcc_data todir_wcc;
1886 * };
1887 *
1888 * struct RENAME3resfail {
1889 * wcc_data fromdir_wcc;
1890 * wcc_data todir_wcc;
1891 * };
1892 *
1893 * union RENAME3res switch (nfsstat3 status) {
1894 * case NFS3_OK:
1895 * RENAME3resok resok;
1896 * default:
1897 * RENAME3resfail resfail;
1898 * };
1899 */
bf269551
CL
1900static int nfs3_xdr_dec_rename3res(struct rpc_rqst *req,
1901 struct xdr_stream *xdr,
fc016483 1902 void *data)
e4f93234 1903{
fc016483 1904 struct nfs_renameres *result = data;
e4f93234
CL
1905 enum nfs_stat status;
1906 int error;
1907
bf269551 1908 error = decode_nfsstat3(xdr, &status);
e4f93234
CL
1909 if (unlikely(error))
1910 goto out;
bf269551 1911 error = decode_wcc_data(xdr, result->old_fattr);
e4f93234
CL
1912 if (unlikely(error))
1913 goto out;
bf269551 1914 error = decode_wcc_data(xdr, result->new_fattr);
e4f93234
CL
1915 if (unlikely(error))
1916 goto out;
1917 if (status != NFS3_OK)
1918 goto out_status;
1919out:
1920 return error;
1921out_status:
5e7e5a0d 1922 return nfs3_stat_to_errno(status);
e4f93234
CL
1923}
1924
e4f93234
CL
1925/*
1926 * 3.3.15 LINK3res
1927 *
1928 * struct LINK3resok {
1929 * post_op_attr file_attributes;
1930 * wcc_data linkdir_wcc;
1931 * };
1932 *
1933 * struct LINK3resfail {
1934 * post_op_attr file_attributes;
1935 * wcc_data linkdir_wcc;
1936 * };
1937 *
1938 * union LINK3res switch (nfsstat3 status) {
1939 * case NFS3_OK:
1940 * LINK3resok resok;
1941 * default:
1942 * LINK3resfail resfail;
1943 * };
1944 */
bf269551 1945static int nfs3_xdr_dec_link3res(struct rpc_rqst *req, struct xdr_stream *xdr,
fc016483 1946 void *data)
e4f93234 1947{
fc016483 1948 struct nfs3_linkres *result = data;
e4f93234
CL
1949 enum nfs_stat status;
1950 int error;
1951
bf269551 1952 error = decode_nfsstat3(xdr, &status);
e4f93234
CL
1953 if (unlikely(error))
1954 goto out;
bf269551 1955 error = decode_post_op_attr(xdr, result->fattr);
e4f93234
CL
1956 if (unlikely(error))
1957 goto out;
bf269551 1958 error = decode_wcc_data(xdr, result->dir_attr);
e4f93234
CL
1959 if (unlikely(error))
1960 goto out;
1961 if (status != NFS3_OK)
1962 goto out_status;
1963out:
1964 return error;
1965out_status:
5e7e5a0d 1966 return nfs3_stat_to_errno(status);
e4f93234
CL
1967}
1968
1969/**
1970 * nfs3_decode_dirent - Decode a single NFSv3 directory entry stored in
1971 * the local page cache
1972 * @xdr: XDR stream where entry resides
1973 * @entry: buffer to fill in with entry data
e4f93234
CL
1974 * @plus: boolean indicating whether this should be a readdirplus entry
1975 *
573c4e1e
CL
1976 * Returns zero if successful, otherwise a negative errno value is
1977 * returned.
e4f93234
CL
1978 *
1979 * This function is not invoked during READDIR reply decoding, but
1980 * rather whenever an application invokes the getdents(2) system call
1981 * on a directory already in our cache.
1982 *
1983 * 3.3.16 entry3
1984 *
1985 * struct entry3 {
1986 * fileid3 fileid;
1987 * filename3 name;
1988 * cookie3 cookie;
1989 * fhandle3 filehandle;
1990 * post_op_attr3 attributes;
1991 * entry3 *nextentry;
1992 * };
1993 *
1994 * 3.3.17 entryplus3
1995 * struct entryplus3 {
1996 * fileid3 fileid;
1997 * filename3 name;
1998 * cookie3 cookie;
1999 * post_op_attr name_attributes;
2000 * post_op_fh3 name_handle;
2001 * entryplus3 *nextentry;
2002 * };
2003 */
573c4e1e 2004int nfs3_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry,
a7a3b1e9 2005 bool plus)
e4f93234
CL
2006{
2007 struct nfs_entry old = *entry;
2008 __be32 *p;
2009 int error;
98de9ce6 2010 u64 new_cookie;
e4f93234
CL
2011
2012 p = xdr_inline_decode(xdr, 4);
2013 if (unlikely(p == NULL))
2014 goto out_overflow;
2015 if (*p == xdr_zero) {
2016 p = xdr_inline_decode(xdr, 4);
2017 if (unlikely(p == NULL))
2018 goto out_overflow;
2019 if (*p == xdr_zero)
573c4e1e 2020 return -EAGAIN;
e4f93234 2021 entry->eof = 1;
573c4e1e 2022 return -EBADCOOKIE;
e4f93234
CL
2023 }
2024
2025 error = decode_fileid3(xdr, &entry->ino);
2026 if (unlikely(error))
573c4e1e 2027 return error;
e4f93234
CL
2028
2029 error = decode_inline_filename3(xdr, &entry->name, &entry->len);
2030 if (unlikely(error))
573c4e1e 2031 return error;
e4f93234 2032
98de9ce6 2033 error = decode_cookie3(xdr, &new_cookie);
e4f93234 2034 if (unlikely(error))
573c4e1e 2035 return error;
e4f93234
CL
2036
2037 entry->d_type = DT_UNKNOWN;
2038
2039 if (plus) {
2040 entry->fattr->valid = 0;
2041 error = decode_post_op_attr(xdr, entry->fattr);
2042 if (unlikely(error))
573c4e1e 2043 return error;
e4f93234
CL
2044 if (entry->fattr->valid & NFS_ATTR_FATTR_V3)
2045 entry->d_type = nfs_umode_to_dtype(entry->fattr->mode);
2046
1ae04b25
TM
2047 if (entry->fattr->fileid != entry->ino) {
2048 entry->fattr->mounted_on_fileid = entry->ino;
2049 entry->fattr->valid |= NFS_ATTR_FATTR_MOUNTED_ON_FILEID;
2050 }
2051
e4f93234
CL
2052 /* In fact, a post_op_fh3: */
2053 p = xdr_inline_decode(xdr, 4);
2054 if (unlikely(p == NULL))
2055 goto out_overflow;
2056 if (*p != xdr_zero) {
2057 error = decode_nfs_fh3(xdr, entry->fh);
2058 if (unlikely(error)) {
2059 if (error == -E2BIG)
2060 goto out_truncated;
573c4e1e 2061 return error;
e4f93234
CL
2062 }
2063 } else
2064 zero_nfs_fh3(entry->fh);
2065 }
2066
98de9ce6
FS
2067 entry->prev_cookie = entry->cookie;
2068 entry->cookie = new_cookie;
2069
573c4e1e 2070 return 0;
e4f93234
CL
2071
2072out_overflow:
2073 print_overflow_msg(__func__, xdr);
573c4e1e 2074 return -EAGAIN;
e4f93234
CL
2075out_truncated:
2076 dprintk("NFS: directory entry contains invalid file handle\n");
2077 *entry = old;
573c4e1e 2078 return -EAGAIN;
e4f93234
CL
2079}
2080
2081/*
2082 * 3.3.16 READDIR3res
2083 *
2084 * struct dirlist3 {
2085 * entry3 *entries;
2086 * bool eof;
2087 * };
2088 *
2089 * struct READDIR3resok {
2090 * post_op_attr dir_attributes;
2091 * cookieverf3 cookieverf;
2092 * dirlist3 reply;
2093 * };
2094 *
2095 * struct READDIR3resfail {
2096 * post_op_attr dir_attributes;
2097 * };
2098 *
2099 * union READDIR3res switch (nfsstat3 status) {
2100 * case NFS3_OK:
2101 * READDIR3resok resok;
2102 * default:
2103 * READDIR3resfail resfail;
2104 * };
2105 *
2106 * Read the directory contents into the page cache, but otherwise
2107 * don't touch them. The actual decoding is done by nfs3_decode_entry()
2108 * during subsequent nfs_readdir() calls.
2109 */
2110static int decode_dirlist3(struct xdr_stream *xdr)
2111{
64bd577e 2112 return xdr_read_pages(xdr, xdr->buf->page_len);
e4f93234
CL
2113}
2114
2115static int decode_readdir3resok(struct xdr_stream *xdr,
2116 struct nfs3_readdirres *result)
2117{
2118 int error;
2119
2120 error = decode_post_op_attr(xdr, result->dir_attr);
2121 if (unlikely(error))
2122 goto out;
2123 /* XXX: do we need to check if result->verf != NULL ? */
2124 error = decode_cookieverf3(xdr, result->verf);
2125 if (unlikely(error))
2126 goto out;
2127 error = decode_dirlist3(xdr);
2128out:
2129 return error;
2130}
2131
bf269551
CL
2132static int nfs3_xdr_dec_readdir3res(struct rpc_rqst *req,
2133 struct xdr_stream *xdr,
fc016483 2134 void *data)
e4f93234 2135{
fc016483 2136 struct nfs3_readdirres *result = data;
e4f93234
CL
2137 enum nfs_stat status;
2138 int error;
2139
bf269551 2140 error = decode_nfsstat3(xdr, &status);
e4f93234
CL
2141 if (unlikely(error))
2142 goto out;
2143 if (status != NFS3_OK)
2144 goto out_default;
bf269551 2145 error = decode_readdir3resok(xdr, result);
e4f93234
CL
2146out:
2147 return error;
2148out_default:
bf269551 2149 error = decode_post_op_attr(xdr, result->dir_attr);
e4f93234
CL
2150 if (unlikely(error))
2151 goto out;
5e7e5a0d 2152 return nfs3_stat_to_errno(status);
e4f93234
CL
2153}
2154
e4f93234
CL
2155/*
2156 * 3.3.18 FSSTAT3res
2157 *
2158 * struct FSSTAT3resok {
2159 * post_op_attr obj_attributes;
2160 * size3 tbytes;
2161 * size3 fbytes;
2162 * size3 abytes;
2163 * size3 tfiles;
2164 * size3 ffiles;
2165 * size3 afiles;
2166 * uint32 invarsec;
2167 * };
2168 *
2169 * struct FSSTAT3resfail {
2170 * post_op_attr obj_attributes;
2171 * };
2172 *
2173 * union FSSTAT3res switch (nfsstat3 status) {
2174 * case NFS3_OK:
2175 * FSSTAT3resok resok;
2176 * default:
2177 * FSSTAT3resfail resfail;
2178 * };
2179 */
2180static int decode_fsstat3resok(struct xdr_stream *xdr,
2181 struct nfs_fsstat *result)
2182{
2183 __be32 *p;
2184
2185 p = xdr_inline_decode(xdr, 8 * 6 + 4);
2186 if (unlikely(p == NULL))
2187 goto out_overflow;
2188 p = xdr_decode_size3(p, &result->tbytes);
2189 p = xdr_decode_size3(p, &result->fbytes);
2190 p = xdr_decode_size3(p, &result->abytes);
2191 p = xdr_decode_size3(p, &result->tfiles);
2192 p = xdr_decode_size3(p, &result->ffiles);
2193 xdr_decode_size3(p, &result->afiles);
2194 /* ignore invarsec */
2195 return 0;
2196out_overflow:
2197 print_overflow_msg(__func__, xdr);
2198 return -EIO;
2199}
2200
bf269551
CL
2201static int nfs3_xdr_dec_fsstat3res(struct rpc_rqst *req,
2202 struct xdr_stream *xdr,
fc016483 2203 void *data)
e4f93234 2204{
fc016483 2205 struct nfs_fsstat *result = data;
e4f93234
CL
2206 enum nfs_stat status;
2207 int error;
2208
bf269551 2209 error = decode_nfsstat3(xdr, &status);
e4f93234
CL
2210 if (unlikely(error))
2211 goto out;
bf269551 2212 error = decode_post_op_attr(xdr, result->fattr);
e4f93234
CL
2213 if (unlikely(error))
2214 goto out;
2215 if (status != NFS3_OK)
2216 goto out_status;
bf269551 2217 error = decode_fsstat3resok(xdr, result);
e4f93234
CL
2218out:
2219 return error;
2220out_status:
5e7e5a0d 2221 return nfs3_stat_to_errno(status);
e4f93234
CL
2222}
2223
e4f93234
CL
2224/*
2225 * 3.3.19 FSINFO3res
2226 *
2227 * struct FSINFO3resok {
2228 * post_op_attr obj_attributes;
2229 * uint32 rtmax;
2230 * uint32 rtpref;
2231 * uint32 rtmult;
2232 * uint32 wtmax;
2233 * uint32 wtpref;
2234 * uint32 wtmult;
2235 * uint32 dtpref;
2236 * size3 maxfilesize;
2237 * nfstime3 time_delta;
2238 * uint32 properties;
2239 * };
2240 *
2241 * struct FSINFO3resfail {
2242 * post_op_attr obj_attributes;
2243 * };
2244 *
2245 * union FSINFO3res switch (nfsstat3 status) {
2246 * case NFS3_OK:
2247 * FSINFO3resok resok;
2248 * default:
2249 * FSINFO3resfail resfail;
2250 * };
2251 */
2252static int decode_fsinfo3resok(struct xdr_stream *xdr,
2253 struct nfs_fsinfo *result)
2254{
2255 __be32 *p;
2256
2257 p = xdr_inline_decode(xdr, 4 * 7 + 8 + 8 + 4);
2258 if (unlikely(p == NULL))
2259 goto out_overflow;
2260 result->rtmax = be32_to_cpup(p++);
2261 result->rtpref = be32_to_cpup(p++);
2262 result->rtmult = be32_to_cpup(p++);
2263 result->wtmax = be32_to_cpup(p++);
2264 result->wtpref = be32_to_cpup(p++);
2265 result->wtmult = be32_to_cpup(p++);
2266 result->dtpref = be32_to_cpup(p++);
2267 p = xdr_decode_size3(p, &result->maxfilesize);
f6048709 2268 xdr_decode_nfstime3(p, &result->time_delta);
e4f93234
CL
2269
2270 /* ignore properties */
2271 result->lease_time = 0;
2272 return 0;
2273out_overflow:
2274 print_overflow_msg(__func__, xdr);
2275 return -EIO;
2276}
2277
bf269551
CL
2278static int nfs3_xdr_dec_fsinfo3res(struct rpc_rqst *req,
2279 struct xdr_stream *xdr,
fc016483 2280 void *data)
e4f93234 2281{
fc016483 2282 struct nfs_fsinfo *result = data;
e4f93234
CL
2283 enum nfs_stat status;
2284 int error;
2285
bf269551 2286 error = decode_nfsstat3(xdr, &status);
e4f93234
CL
2287 if (unlikely(error))
2288 goto out;
bf269551 2289 error = decode_post_op_attr(xdr, result->fattr);
e4f93234
CL
2290 if (unlikely(error))
2291 goto out;
2292 if (status != NFS3_OK)
2293 goto out_status;
bf269551 2294 error = decode_fsinfo3resok(xdr, result);
e4f93234
CL
2295out:
2296 return error;
2297out_status:
5e7e5a0d 2298 return nfs3_stat_to_errno(status);
e4f93234
CL
2299}
2300
e4f93234
CL
2301/*
2302 * 3.3.20 PATHCONF3res
2303 *
2304 * struct PATHCONF3resok {
2305 * post_op_attr obj_attributes;
2306 * uint32 linkmax;
2307 * uint32 name_max;
2308 * bool no_trunc;
2309 * bool chown_restricted;
2310 * bool case_insensitive;
2311 * bool case_preserving;
2312 * };
2313 *
2314 * struct PATHCONF3resfail {
2315 * post_op_attr obj_attributes;
2316 * };
2317 *
2318 * union PATHCONF3res switch (nfsstat3 status) {
2319 * case NFS3_OK:
2320 * PATHCONF3resok resok;
2321 * default:
2322 * PATHCONF3resfail resfail;
2323 * };
2324 */
2325static int decode_pathconf3resok(struct xdr_stream *xdr,
2326 struct nfs_pathconf *result)
2327{
2328 __be32 *p;
2329
2330 p = xdr_inline_decode(xdr, 4 * 6);
2331 if (unlikely(p == NULL))
2332 goto out_overflow;
2333 result->max_link = be32_to_cpup(p++);
2334 result->max_namelen = be32_to_cpup(p);
2335 /* ignore remaining fields */
2336 return 0;
2337out_overflow:
2338 print_overflow_msg(__func__, xdr);
2339 return -EIO;
2340}
2341
bf269551
CL
2342static int nfs3_xdr_dec_pathconf3res(struct rpc_rqst *req,
2343 struct xdr_stream *xdr,
fc016483 2344 void *data)
e4f93234 2345{
fc016483 2346 struct nfs_pathconf *result = data;
e4f93234
CL
2347 enum nfs_stat status;
2348 int error;
2349
bf269551 2350 error = decode_nfsstat3(xdr, &status);
e4f93234
CL
2351 if (unlikely(error))
2352 goto out;
bf269551 2353 error = decode_post_op_attr(xdr, result->fattr);
e4f93234
CL
2354 if (unlikely(error))
2355 goto out;
2356 if (status != NFS3_OK)
2357 goto out_status;
bf269551 2358 error = decode_pathconf3resok(xdr, result);
e4f93234
CL
2359out:
2360 return error;
2361out_status:
5e7e5a0d 2362 return nfs3_stat_to_errno(status);
e4f93234
CL
2363}
2364
e4f93234
CL
2365/*
2366 * 3.3.21 COMMIT3res
2367 *
2368 * struct COMMIT3resok {
2369 * wcc_data file_wcc;
2370 * writeverf3 verf;
2371 * };
2372 *
2373 * struct COMMIT3resfail {
2374 * wcc_data file_wcc;
2375 * };
2376 *
2377 * union COMMIT3res switch (nfsstat3 status) {
2378 * case NFS3_OK:
2379 * COMMIT3resok resok;
2380 * default:
2381 * COMMIT3resfail resfail;
2382 * };
2383 */
bf269551
CL
2384static int nfs3_xdr_dec_commit3res(struct rpc_rqst *req,
2385 struct xdr_stream *xdr,
fc016483 2386 void *data)
e4f93234 2387{
fc016483 2388 struct nfs_commitres *result = data;
e4f93234
CL
2389 enum nfs_stat status;
2390 int error;
2391
bf269551 2392 error = decode_nfsstat3(xdr, &status);
e4f93234
CL
2393 if (unlikely(error))
2394 goto out;
bf269551 2395 error = decode_wcc_data(xdr, result->fattr);
e4f93234
CL
2396 if (unlikely(error))
2397 goto out;
aabff4dd 2398 result->op_status = status;
e4f93234
CL
2399 if (status != NFS3_OK)
2400 goto out_status;
2f2c63bc 2401 error = decode_writeverf3(xdr, &result->verf->verifier);
e4f93234
CL
2402out:
2403 return error;
2404out_status:
5e7e5a0d 2405 return nfs3_stat_to_errno(status);
e4f93234
CL
2406}
2407
b7fa0554 2408#ifdef CONFIG_NFS_V3_ACL
b7fa0554 2409
e4f93234
CL
2410static inline int decode_getacl3resok(struct xdr_stream *xdr,
2411 struct nfs3_getaclres *result)
2412{
2413 struct posix_acl **acl;
2414 unsigned int *aclcnt;
2415 size_t hdrlen;
2416 int error;
2417
2418 error = decode_post_op_attr(xdr, result->fattr);
2419 if (unlikely(error))
2420 goto out;
2421 error = decode_uint32(xdr, &result->mask);
2422 if (unlikely(error))
2423 goto out;
2424 error = -EINVAL;
2425 if (result->mask & ~(NFS_ACL|NFS_ACLCNT|NFS_DFACL|NFS_DFACLCNT))
2426 goto out;
2427
1aecca3e 2428 hdrlen = xdr_stream_pos(xdr);
e4f93234
CL
2429
2430 acl = NULL;
2431 if (result->mask & NFS_ACL)
2432 acl = &result->acl_access;
2433 aclcnt = NULL;
2434 if (result->mask & NFS_ACLCNT)
2435 aclcnt = &result->acl_access_count;
2436 error = nfsacl_decode(xdr->buf, hdrlen, aclcnt, acl);
2437 if (unlikely(error <= 0))
2438 goto out;
2439
2440 acl = NULL;
2441 if (result->mask & NFS_DFACL)
2442 acl = &result->acl_default;
2443 aclcnt = NULL;
2444 if (result->mask & NFS_DFACLCNT)
2445 aclcnt = &result->acl_default_count;
2446 error = nfsacl_decode(xdr->buf, hdrlen + error, aclcnt, acl);
2447 if (unlikely(error <= 0))
2448 return error;
2449 error = 0;
2450out:
2451 return error;
2452}
2453
bf269551
CL
2454static int nfs3_xdr_dec_getacl3res(struct rpc_rqst *req,
2455 struct xdr_stream *xdr,
fc016483 2456 void *result)
e4f93234 2457{
e4f93234
CL
2458 enum nfs_stat status;
2459 int error;
2460
bf269551 2461 error = decode_nfsstat3(xdr, &status);
e4f93234
CL
2462 if (unlikely(error))
2463 goto out;
2464 if (status != NFS3_OK)
2465 goto out_default;
bf269551 2466 error = decode_getacl3resok(xdr, result);
e4f93234
CL
2467out:
2468 return error;
2469out_default:
5e7e5a0d 2470 return nfs3_stat_to_errno(status);
e4f93234
CL
2471}
2472
bf269551
CL
2473static int nfs3_xdr_dec_setacl3res(struct rpc_rqst *req,
2474 struct xdr_stream *xdr,
fc016483 2475 void *result)
e4f93234 2476{
e4f93234
CL
2477 enum nfs_stat status;
2478 int error;
2479
bf269551 2480 error = decode_nfsstat3(xdr, &status);
e4f93234
CL
2481 if (unlikely(error))
2482 goto out;
2483 if (status != NFS3_OK)
2484 goto out_default;
bf269551 2485 error = decode_post_op_attr(xdr, result);
e4f93234
CL
2486out:
2487 return error;
2488out_default:
5e7e5a0d 2489 return nfs3_stat_to_errno(status);
e4f93234
CL
2490}
2491
b7fa0554
AG
2492#endif /* CONFIG_NFS_V3_ACL */
2493
5e7e5a0d
BS
2494
2495/*
2496 * We need to translate between nfs status return values and
2497 * the local errno values which may not be the same.
2498 */
2499static const struct {
2500 int stat;
2501 int errno;
2502} nfs_errtbl[] = {
2503 { NFS_OK, 0 },
2504 { NFSERR_PERM, -EPERM },
2505 { NFSERR_NOENT, -ENOENT },
2506 { NFSERR_IO, -errno_NFSERR_IO},
2507 { NFSERR_NXIO, -ENXIO },
2508/* { NFSERR_EAGAIN, -EAGAIN }, */
2509 { NFSERR_ACCES, -EACCES },
2510 { NFSERR_EXIST, -EEXIST },
2511 { NFSERR_XDEV, -EXDEV },
2512 { NFSERR_NODEV, -ENODEV },
2513 { NFSERR_NOTDIR, -ENOTDIR },
2514 { NFSERR_ISDIR, -EISDIR },
2515 { NFSERR_INVAL, -EINVAL },
2516 { NFSERR_FBIG, -EFBIG },
2517 { NFSERR_NOSPC, -ENOSPC },
2518 { NFSERR_ROFS, -EROFS },
2519 { NFSERR_MLINK, -EMLINK },
2520 { NFSERR_NAMETOOLONG, -ENAMETOOLONG },
2521 { NFSERR_NOTEMPTY, -ENOTEMPTY },
2522 { NFSERR_DQUOT, -EDQUOT },
2523 { NFSERR_STALE, -ESTALE },
2524 { NFSERR_REMOTE, -EREMOTE },
2525#ifdef EWFLUSH
2526 { NFSERR_WFLUSH, -EWFLUSH },
2527#endif
2528 { NFSERR_BADHANDLE, -EBADHANDLE },
2529 { NFSERR_NOT_SYNC, -ENOTSYNC },
2530 { NFSERR_BAD_COOKIE, -EBADCOOKIE },
2531 { NFSERR_NOTSUPP, -ENOTSUPP },
2532 { NFSERR_TOOSMALL, -ETOOSMALL },
2533 { NFSERR_SERVERFAULT, -EREMOTEIO },
2534 { NFSERR_BADTYPE, -EBADTYPE },
2535 { NFSERR_JUKEBOX, -EJUKEBOX },
2536 { -1, -EIO }
2537};
2538
2539/**
2540 * nfs3_stat_to_errno - convert an NFS status code to a local errno
2541 * @status: NFS status code to convert
2542 *
2543 * Returns a local errno value, or -EIO if the NFS status code is
2544 * not recognized. This function is used jointly by NFSv2 and NFSv3.
2545 */
2546static int nfs3_stat_to_errno(enum nfs_stat status)
2547{
2548 int i;
2549
2550 for (i = 0; nfs_errtbl[i].stat != -1; i++) {
2551 if (nfs_errtbl[i].stat == (int)status)
2552 return nfs_errtbl[i].errno;
2553 }
2554 dprintk("NFS: Unrecognized nfs status value: %u\n", status);
2555 return nfs_errtbl[i].errno;
2556}
2557
2558
1da177e4
LT
2559#define PROC(proc, argtype, restype, timer) \
2560[NFS3PROC_##proc] = { \
2561 .p_proc = NFS3PROC_##proc, \
fcc85819 2562 .p_encode = nfs3_xdr_enc_##argtype##3args, \
fc016483 2563 .p_decode = nfs3_xdr_dec_##restype##3res, \
ad96b5b5 2564 .p_arglen = NFS3_##argtype##args_sz, \
f5fc3c50 2565 .p_replen = NFS3_##restype##res_sz, \
cc0175c1
CL
2566 .p_timer = timer, \
2567 .p_statidx = NFS3PROC_##proc, \
2568 .p_name = #proc, \
1da177e4
LT
2569 }
2570
511e936b 2571const struct rpc_procinfo nfs3_procedures[] = {
f5fc3c50
CL
2572 PROC(GETATTR, getattr, getattr, 1),
2573 PROC(SETATTR, setattr, setattr, 0),
2574 PROC(LOOKUP, lookup, lookup, 2),
2575 PROC(ACCESS, access, access, 1),
2576 PROC(READLINK, readlink, readlink, 3),
2577 PROC(READ, read, read, 3),
2578 PROC(WRITE, write, write, 4),
2579 PROC(CREATE, create, create, 0),
2580 PROC(MKDIR, mkdir, create, 0),
2581 PROC(SYMLINK, symlink, create, 0),
2582 PROC(MKNOD, mknod, create, 0),
2583 PROC(REMOVE, remove, remove, 0),
2584 PROC(RMDIR, lookup, setattr, 0),
2585 PROC(RENAME, rename, rename, 0),
2586 PROC(LINK, link, link, 0),
2587 PROC(READDIR, readdir, readdir, 3),
2588 PROC(READDIRPLUS, readdirplus, readdir, 3),
2589 PROC(FSSTAT, getattr, fsstat, 0),
2590 PROC(FSINFO, getattr, fsinfo, 0),
2591 PROC(PATHCONF, getattr, pathconf, 0),
2592 PROC(COMMIT, commit, commit, 5),
1da177e4
LT
2593};
2594
c551858a 2595static unsigned int nfs_version3_counts[ARRAY_SIZE(nfs3_procedures)];
a613fa16 2596const struct rpc_version nfs_version3 = {
1da177e4 2597 .number = 3,
e8c96f8c 2598 .nrprocs = ARRAY_SIZE(nfs3_procedures),
c551858a
CH
2599 .procs = nfs3_procedures,
2600 .counts = nfs_version3_counts,
1da177e4
LT
2601};
2602
b7fa0554 2603#ifdef CONFIG_NFS_V3_ACL
511e936b 2604static const struct rpc_procinfo nfs3_acl_procedures[] = {
b7fa0554
AG
2605 [ACLPROC3_GETACL] = {
2606 .p_proc = ACLPROC3_GETACL,
fcc85819 2607 .p_encode = nfs3_xdr_enc_getacl3args,
fc016483 2608 .p_decode = nfs3_xdr_dec_getacl3res,
2bea90d4
CL
2609 .p_arglen = ACL3_getaclargs_sz,
2610 .p_replen = ACL3_getaclres_sz,
b7fa0554 2611 .p_timer = 1,
cc0175c1 2612 .p_name = "GETACL",
b7fa0554
AG
2613 },
2614 [ACLPROC3_SETACL] = {
2615 .p_proc = ACLPROC3_SETACL,
fcc85819 2616 .p_encode = nfs3_xdr_enc_setacl3args,
fc016483 2617 .p_decode = nfs3_xdr_dec_setacl3res,
2bea90d4
CL
2618 .p_arglen = ACL3_setaclargs_sz,
2619 .p_replen = ACL3_setaclres_sz,
b7fa0554 2620 .p_timer = 0,
cc0175c1 2621 .p_name = "SETACL",
b7fa0554
AG
2622 },
2623};
2624
c551858a 2625static unsigned int nfs3_acl_counts[ARRAY_SIZE(nfs3_acl_procedures)];
a613fa16 2626const struct rpc_version nfsacl_version3 = {
b7fa0554 2627 .number = 3,
9ae7d8ff 2628 .nrprocs = ARRAY_SIZE(nfs3_acl_procedures),
b7fa0554 2629 .procs = nfs3_acl_procedures,
c551858a 2630 .counts = nfs3_acl_counts,
b7fa0554
AG
2631};
2632#endif /* CONFIG_NFS_V3_ACL */