4 * Client-side XDR for NFSv4.
6 * Copyright (c) 2002 The Regents of the University of Michigan.
9 * Kendrick Smith <kmsmith@umich.edu>
10 * Andy Adamson <andros@umich.edu>
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 * 3. Neither the name of the University nor the names of its
22 * contributors may be used to endorse or promote products derived
23 * from this software without specific prior written permission.
25 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
26 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
27 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
32 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 #include <linux/param.h>
39 #include <linux/time.h>
41 #include <linux/slab.h>
42 #include <linux/utsname.h>
43 #include <linux/errno.h>
44 #include <linux/string.h>
46 #include <linux/pagemap.h>
47 #include <linux/proc_fs.h>
48 #include <linux/kdev_t.h>
49 #include <linux/sunrpc/clnt.h>
50 #include <linux/nfs.h>
51 #include <linux/nfs4.h>
52 #include <linux/nfs_fs.h>
53 #include <linux/nfs_idmap.h>
56 #define NFSDBG_FACILITY NFSDBG_XDR
58 /* Mapping from NFS error code to "errno" error code. */
59 #define errno_NFSERR_IO EIO
61 static int nfs_stat_to_errno(int);
63 /* NFSv4 COMPOUND tags are only wanted for debugging purposes */
65 #define NFS4_MAXTAGLEN 20
67 #define NFS4_MAXTAGLEN 0
70 /* lock,open owner id:
71 * we currently use size 1 (u32) out of (NFS4_OPAQUE_LIMIT >> 2)
73 #define owner_id_maxsz (1 + 1)
74 #define compound_encode_hdr_maxsz (3 + (NFS4_MAXTAGLEN >> 2))
75 #define compound_decode_hdr_maxsz (3 + (NFS4_MAXTAGLEN >> 2))
76 #define op_encode_hdr_maxsz (1)
77 #define op_decode_hdr_maxsz (2)
78 #define encode_putfh_maxsz (op_encode_hdr_maxsz + 1 + \
80 #define decode_putfh_maxsz (op_decode_hdr_maxsz)
81 #define encode_putrootfh_maxsz (op_encode_hdr_maxsz)
82 #define decode_putrootfh_maxsz (op_decode_hdr_maxsz)
83 #define encode_getfh_maxsz (op_encode_hdr_maxsz)
84 #define decode_getfh_maxsz (op_decode_hdr_maxsz + 1 + \
85 ((3+NFS4_FHSIZE) >> 2))
86 #define nfs4_fattr_bitmap_maxsz 3
87 #define encode_getattr_maxsz (op_encode_hdr_maxsz + nfs4_fattr_bitmap_maxsz)
88 #define nfs4_name_maxsz (1 + ((3 + NFS4_MAXNAMLEN) >> 2))
89 #define nfs4_path_maxsz (1 + ((3 + NFS4_MAXPATHLEN) >> 2))
90 /* This is based on getfattr, which uses the most attributes: */
91 #define nfs4_fattr_value_maxsz (1 + (1 + 2 + 2 + 4 + 2 + 1 + 1 + 2 + 2 + \
92 3 + 3 + 3 + 2 * nfs4_name_maxsz))
93 #define nfs4_fattr_maxsz (nfs4_fattr_bitmap_maxsz + \
94 nfs4_fattr_value_maxsz)
95 #define decode_getattr_maxsz (op_decode_hdr_maxsz + nfs4_fattr_maxsz)
96 #define encode_savefh_maxsz (op_encode_hdr_maxsz)
97 #define decode_savefh_maxsz (op_decode_hdr_maxsz)
98 #define encode_fsinfo_maxsz (op_encode_hdr_maxsz + 2)
99 #define decode_fsinfo_maxsz (op_decode_hdr_maxsz + 11)
100 #define encode_renew_maxsz (op_encode_hdr_maxsz + 3)
101 #define decode_renew_maxsz (op_decode_hdr_maxsz)
102 #define encode_setclientid_maxsz \
103 (op_encode_hdr_maxsz + \
104 4 /*server->ip_addr*/ + \
107 6 + (NFS4_VERIFIER_SIZE >> 2))
108 #define decode_setclientid_maxsz \
109 (op_decode_hdr_maxsz + \
111 1024) /* large value for CLID_INUSE */
112 #define encode_setclientid_confirm_maxsz \
113 (op_encode_hdr_maxsz + \
114 3 + (NFS4_VERIFIER_SIZE >> 2))
115 #define decode_setclientid_confirm_maxsz \
116 (op_decode_hdr_maxsz)
117 #define encode_lookup_maxsz (op_encode_hdr_maxsz + \
118 1 + ((3 + NFS4_FHSIZE) >> 2))
119 #define encode_remove_maxsz (op_encode_hdr_maxsz + \
121 #define encode_rename_maxsz (op_encode_hdr_maxsz + \
123 #define decode_rename_maxsz (op_decode_hdr_maxsz + 5 + 5)
124 #define encode_link_maxsz (op_encode_hdr_maxsz + \
126 #define decode_link_maxsz (op_decode_hdr_maxsz + 5)
127 #define encode_symlink_maxsz (op_encode_hdr_maxsz + \
128 1 + nfs4_name_maxsz + \
131 #define decode_symlink_maxsz (op_decode_hdr_maxsz + 8)
132 #define encode_create_maxsz (op_encode_hdr_maxsz + \
133 2 + nfs4_name_maxsz + \
135 #define decode_create_maxsz (op_decode_hdr_maxsz + 8)
136 #define encode_delegreturn_maxsz (op_encode_hdr_maxsz + 4)
137 #define decode_delegreturn_maxsz (op_decode_hdr_maxsz)
138 #define NFS4_enc_compound_sz (1024) /* XXX: large enough? */
139 #define NFS4_dec_compound_sz (1024) /* XXX: large enough? */
140 #define NFS4_enc_read_sz (compound_encode_hdr_maxsz + \
141 encode_putfh_maxsz + \
142 op_encode_hdr_maxsz + 7)
143 #define NFS4_dec_read_sz (compound_decode_hdr_maxsz + \
144 decode_putfh_maxsz + \
145 op_decode_hdr_maxsz + 2)
146 #define NFS4_enc_readlink_sz (compound_encode_hdr_maxsz + \
147 encode_putfh_maxsz + \
149 #define NFS4_dec_readlink_sz (compound_decode_hdr_maxsz + \
150 decode_putfh_maxsz + \
152 #define NFS4_enc_readdir_sz (compound_encode_hdr_maxsz + \
153 encode_putfh_maxsz + \
154 op_encode_hdr_maxsz + 9)
155 #define NFS4_dec_readdir_sz (compound_decode_hdr_maxsz + \
156 decode_putfh_maxsz + \
157 op_decode_hdr_maxsz + 2)
158 #define NFS4_enc_write_sz (compound_encode_hdr_maxsz + \
159 encode_putfh_maxsz + \
160 op_encode_hdr_maxsz + 8)
161 #define NFS4_dec_write_sz (compound_decode_hdr_maxsz + \
162 decode_putfh_maxsz + \
163 op_decode_hdr_maxsz + 4)
164 #define NFS4_enc_commit_sz (compound_encode_hdr_maxsz + \
165 encode_putfh_maxsz + \
166 op_encode_hdr_maxsz + 3)
167 #define NFS4_dec_commit_sz (compound_decode_hdr_maxsz + \
168 decode_putfh_maxsz + \
169 op_decode_hdr_maxsz + 2)
170 #define NFS4_enc_open_sz (compound_encode_hdr_maxsz + \
171 encode_putfh_maxsz + \
172 op_encode_hdr_maxsz + \
174 encode_getattr_maxsz + \
176 #define NFS4_dec_open_sz (compound_decode_hdr_maxsz + \
177 decode_putfh_maxsz + \
178 op_decode_hdr_maxsz + 4 + 5 + 2 + 3 + \
179 decode_getattr_maxsz + \
181 #define NFS4_enc_open_confirm_sz \
182 (compound_encode_hdr_maxsz + \
183 encode_putfh_maxsz + \
184 op_encode_hdr_maxsz + 5)
185 #define NFS4_dec_open_confirm_sz (compound_decode_hdr_maxsz + \
186 decode_putfh_maxsz + \
187 op_decode_hdr_maxsz + 4)
188 #define NFS4_enc_open_noattr_sz (compound_encode_hdr_maxsz + \
189 encode_putfh_maxsz + \
190 op_encode_hdr_maxsz + \
192 #define NFS4_dec_open_noattr_sz (compound_decode_hdr_maxsz + \
193 decode_putfh_maxsz + \
194 op_decode_hdr_maxsz + \
196 #define NFS4_enc_open_downgrade_sz \
197 (compound_encode_hdr_maxsz + \
198 encode_putfh_maxsz + \
199 op_encode_hdr_maxsz + 7)
200 #define NFS4_dec_open_downgrade_sz \
201 (compound_decode_hdr_maxsz + \
202 decode_putfh_maxsz + \
203 op_decode_hdr_maxsz + 4)
204 #define NFS4_enc_close_sz (compound_encode_hdr_maxsz + \
205 encode_putfh_maxsz + \
206 op_encode_hdr_maxsz + 5)
207 #define NFS4_dec_close_sz (compound_decode_hdr_maxsz + \
208 decode_putfh_maxsz + \
209 op_decode_hdr_maxsz + 4)
210 #define NFS4_enc_setattr_sz (compound_encode_hdr_maxsz + \
211 encode_putfh_maxsz + \
212 op_encode_hdr_maxsz + 4 + \
214 encode_getattr_maxsz)
215 #define NFS4_dec_setattr_sz (compound_decode_hdr_maxsz + \
216 decode_putfh_maxsz + \
217 op_decode_hdr_maxsz + 3)
218 #define NFS4_enc_fsinfo_sz (compound_encode_hdr_maxsz + \
219 encode_putfh_maxsz + \
221 #define NFS4_dec_fsinfo_sz (compound_decode_hdr_maxsz + \
222 decode_putfh_maxsz + \
224 #define NFS4_enc_renew_sz (compound_encode_hdr_maxsz + \
226 #define NFS4_dec_renew_sz (compound_decode_hdr_maxsz + \
228 #define NFS4_enc_setclientid_sz (compound_encode_hdr_maxsz + \
229 encode_setclientid_maxsz)
230 #define NFS4_dec_setclientid_sz (compound_decode_hdr_maxsz + \
231 decode_setclientid_maxsz)
232 #define NFS4_enc_setclientid_confirm_sz \
233 (compound_encode_hdr_maxsz + \
234 encode_setclientid_confirm_maxsz + \
235 encode_putrootfh_maxsz + \
237 #define NFS4_dec_setclientid_confirm_sz \
238 (compound_decode_hdr_maxsz + \
239 decode_setclientid_confirm_maxsz + \
240 decode_putrootfh_maxsz + \
242 #define NFS4_enc_lock_sz (compound_encode_hdr_maxsz + \
243 encode_putfh_maxsz + \
244 encode_getattr_maxsz + \
245 op_encode_hdr_maxsz + \
249 #define NFS4_dec_lock_sz (compound_decode_hdr_maxsz + \
250 decode_putfh_maxsz + \
251 decode_getattr_maxsz + \
252 op_decode_hdr_maxsz + \
255 #define NFS4_enc_lockt_sz (compound_encode_hdr_maxsz + \
256 encode_putfh_maxsz + \
257 encode_getattr_maxsz + \
258 op_encode_hdr_maxsz + \
261 #define NFS4_dec_lockt_sz (NFS4_dec_lock_sz)
262 #define NFS4_enc_locku_sz (compound_encode_hdr_maxsz + \
263 encode_putfh_maxsz + \
264 encode_getattr_maxsz + \
265 op_encode_hdr_maxsz + \
267 #define NFS4_dec_locku_sz (compound_decode_hdr_maxsz + \
268 decode_putfh_maxsz + \
269 decode_getattr_maxsz + \
270 op_decode_hdr_maxsz + 4)
271 #define NFS4_enc_access_sz (compound_encode_hdr_maxsz + \
272 encode_putfh_maxsz + \
273 op_encode_hdr_maxsz + 1)
274 #define NFS4_dec_access_sz (compound_decode_hdr_maxsz + \
275 decode_putfh_maxsz + \
276 op_decode_hdr_maxsz + 2)
277 #define NFS4_enc_getattr_sz (compound_encode_hdr_maxsz + \
278 encode_putfh_maxsz + \
279 encode_getattr_maxsz)
280 #define NFS4_dec_getattr_sz (compound_decode_hdr_maxsz + \
281 decode_putfh_maxsz + \
282 decode_getattr_maxsz)
283 #define NFS4_enc_lookup_sz (compound_encode_hdr_maxsz + \
284 encode_putfh_maxsz + \
285 encode_lookup_maxsz + \
286 encode_getattr_maxsz + \
288 #define NFS4_dec_lookup_sz (compound_decode_hdr_maxsz + \
289 decode_putfh_maxsz + \
290 op_decode_hdr_maxsz + \
291 decode_getattr_maxsz + \
293 #define NFS4_enc_lookup_root_sz (compound_encode_hdr_maxsz + \
294 encode_putrootfh_maxsz + \
295 encode_getattr_maxsz + \
297 #define NFS4_dec_lookup_root_sz (compound_decode_hdr_maxsz + \
298 decode_putrootfh_maxsz + \
299 decode_getattr_maxsz + \
301 #define NFS4_enc_remove_sz (compound_encode_hdr_maxsz + \
302 encode_putfh_maxsz + \
304 #define NFS4_dec_remove_sz (compound_decode_hdr_maxsz + \
305 decode_putfh_maxsz + \
306 op_decode_hdr_maxsz + 5)
307 #define NFS4_enc_rename_sz (compound_encode_hdr_maxsz + \
308 encode_putfh_maxsz + \
309 encode_savefh_maxsz + \
310 encode_putfh_maxsz + \
312 #define NFS4_dec_rename_sz (compound_decode_hdr_maxsz + \
313 decode_putfh_maxsz + \
314 decode_savefh_maxsz + \
315 decode_putfh_maxsz + \
317 #define NFS4_enc_link_sz (compound_encode_hdr_maxsz + \
318 encode_putfh_maxsz + \
319 encode_savefh_maxsz + \
320 encode_putfh_maxsz + \
322 #define NFS4_dec_link_sz (compound_decode_hdr_maxsz + \
323 decode_putfh_maxsz + \
324 decode_savefh_maxsz + \
325 decode_putfh_maxsz + \
327 #define NFS4_enc_symlink_sz (compound_encode_hdr_maxsz + \
328 encode_putfh_maxsz + \
329 encode_symlink_maxsz + \
330 encode_getattr_maxsz + \
332 #define NFS4_dec_symlink_sz (compound_decode_hdr_maxsz + \
333 decode_putfh_maxsz + \
334 decode_symlink_maxsz + \
335 decode_getattr_maxsz + \
337 #define NFS4_enc_create_sz (compound_encode_hdr_maxsz + \
338 encode_putfh_maxsz + \
339 encode_create_maxsz + \
340 encode_getattr_maxsz + \
342 #define NFS4_dec_create_sz (compound_decode_hdr_maxsz + \
343 decode_putfh_maxsz + \
344 decode_create_maxsz + \
345 decode_getattr_maxsz + \
347 #define NFS4_enc_pathconf_sz (compound_encode_hdr_maxsz + \
348 encode_putfh_maxsz + \
349 encode_getattr_maxsz)
350 #define NFS4_dec_pathconf_sz (compound_decode_hdr_maxsz + \
351 decode_putfh_maxsz + \
352 decode_getattr_maxsz)
353 #define NFS4_enc_statfs_sz (compound_encode_hdr_maxsz + \
354 encode_putfh_maxsz + \
355 encode_getattr_maxsz)
356 #define NFS4_dec_statfs_sz (compound_decode_hdr_maxsz + \
357 decode_putfh_maxsz + \
358 op_decode_hdr_maxsz + 12)
359 #define NFS4_enc_server_caps_sz (compound_encode_hdr_maxsz + \
360 encode_getattr_maxsz)
361 #define NFS4_dec_server_caps_sz (compound_decode_hdr_maxsz + \
362 decode_getattr_maxsz)
363 #define NFS4_enc_delegreturn_sz (compound_encode_hdr_maxsz + \
364 encode_putfh_maxsz + \
365 encode_delegreturn_maxsz)
366 #define NFS4_dec_delegreturn_sz (compound_decode_hdr_maxsz + \
367 decode_delegreturn_maxsz)
368 #define NFS4_enc_getacl_sz (compound_encode_hdr_maxsz + \
369 encode_putfh_maxsz + \
370 encode_getattr_maxsz)
371 #define NFS4_dec_getacl_sz (compound_decode_hdr_maxsz + \
372 decode_putfh_maxsz + \
373 op_decode_hdr_maxsz + \
374 nfs4_fattr_bitmap_maxsz + 1)
375 #define NFS4_enc_setacl_sz (compound_encode_hdr_maxsz + \
376 encode_putfh_maxsz + \
377 op_encode_hdr_maxsz + 4 + \
378 nfs4_fattr_bitmap_maxsz + 1)
379 #define NFS4_dec_setacl_sz (compound_decode_hdr_maxsz + \
380 decode_putfh_maxsz + \
381 op_decode_hdr_maxsz + nfs4_fattr_bitmap_maxsz)
385 unsigned int nfs2type;
393 { S_IFSOCK, NFSOCK },
399 struct compound_hdr {
407 * START OF "GENERIC" ENCODE ROUTINES.
408 * These may look a little ugly since they are imported from a "generic"
409 * set of XDR encode/decode routines which are intended to be shared by
410 * all of our NFSv4 implementations (OpenBSD, MacOS X...).
412 * If the pain of reading these is too great, it should be a straightforward
413 * task to translate them into Linux-specific versions which are more
414 * consistent with the style used in NFSv2/v3...
416 #define WRITE32(n) *p++ = htonl(n)
417 #define WRITE64(n) do { \
418 *p++ = htonl((uint32_t)((n) >> 32)); \
419 *p++ = htonl((uint32_t)(n)); \
421 #define WRITEMEM(ptr,nbytes) do { \
422 p = xdr_encode_opaque_fixed(p, ptr, nbytes); \
425 #define RESERVE_SPACE(nbytes) do { \
426 p = xdr_reserve_space(xdr, nbytes); \
427 if (!p) printk("RESERVE_SPACE(%d) failed in function %s\n", (int) (nbytes), __FUNCTION__); \
431 static void encode_string(struct xdr_stream *xdr, unsigned int len, const char *str)
435 p = xdr_reserve_space(xdr, 4 + len);
437 xdr_encode_opaque(p, str, len);
440 static int encode_compound_hdr(struct xdr_stream *xdr, struct compound_hdr *hdr)
444 dprintk("encode_compound: tag=%.*s\n", (int)hdr->taglen, hdr->tag);
445 BUG_ON(hdr->taglen > NFS4_MAXTAGLEN);
446 RESERVE_SPACE(12+(XDR_QUADLEN(hdr->taglen)<<2));
447 WRITE32(hdr->taglen);
448 WRITEMEM(hdr->tag, hdr->taglen);
449 WRITE32(NFS4_MINOR_VERSION);
454 static void encode_nfs4_verifier(struct xdr_stream *xdr, const nfs4_verifier *verf)
458 p = xdr_reserve_space(xdr, NFS4_VERIFIER_SIZE);
460 xdr_encode_opaque_fixed(p, verf->data, NFS4_VERIFIER_SIZE);
463 static int encode_attrs(struct xdr_stream *xdr, const struct iattr *iap, const struct nfs_server *server)
465 char owner_name[IDMAP_NAMESZ];
466 char owner_group[IDMAP_NAMESZ];
467 int owner_namelen = 0;
468 int owner_grouplen = 0;
477 * We reserve enough space to write the entire attribute buffer at once.
478 * In the worst-case, this would be
479 * 12(bitmap) + 4(attrlen) + 8(size) + 4(mode) + 4(atime) + 4(mtime)
480 * = 36 bytes, plus any contribution from variable-length fields
481 * such as owner/group.
486 if (iap->ia_valid & ATTR_SIZE)
488 if (iap->ia_valid & ATTR_MODE)
490 if (iap->ia_valid & ATTR_UID) {
491 owner_namelen = nfs_map_uid_to_name(server->nfs4_state, iap->ia_uid, owner_name);
492 if (owner_namelen < 0) {
493 printk(KERN_WARNING "nfs: couldn't resolve uid %d to string\n",
496 strcpy(owner_name, "nobody");
497 owner_namelen = sizeof("nobody") - 1;
500 len += 4 + (XDR_QUADLEN(owner_namelen) << 2);
502 if (iap->ia_valid & ATTR_GID) {
503 owner_grouplen = nfs_map_gid_to_group(server->nfs4_state, iap->ia_gid, owner_group);
504 if (owner_grouplen < 0) {
505 printk(KERN_WARNING "nfs4: couldn't resolve gid %d to string\n",
507 strcpy(owner_group, "nobody");
508 owner_grouplen = sizeof("nobody") - 1;
511 len += 4 + (XDR_QUADLEN(owner_grouplen) << 2);
513 if (iap->ia_valid & ATTR_ATIME_SET)
515 else if (iap->ia_valid & ATTR_ATIME)
517 if (iap->ia_valid & ATTR_MTIME_SET)
519 else if (iap->ia_valid & ATTR_MTIME)
524 * We write the bitmap length now, but leave the bitmap and the attribute
525 * buffer length to be backfilled at the end of this routine.
531 if (iap->ia_valid & ATTR_SIZE) {
532 bmval0 |= FATTR4_WORD0_SIZE;
533 WRITE64(iap->ia_size);
535 if (iap->ia_valid & ATTR_MODE) {
536 bmval1 |= FATTR4_WORD1_MODE;
537 WRITE32(iap->ia_mode);
539 if (iap->ia_valid & ATTR_UID) {
540 bmval1 |= FATTR4_WORD1_OWNER;
541 WRITE32(owner_namelen);
542 WRITEMEM(owner_name, owner_namelen);
544 if (iap->ia_valid & ATTR_GID) {
545 bmval1 |= FATTR4_WORD1_OWNER_GROUP;
546 WRITE32(owner_grouplen);
547 WRITEMEM(owner_group, owner_grouplen);
549 if (iap->ia_valid & ATTR_ATIME_SET) {
550 bmval1 |= FATTR4_WORD1_TIME_ACCESS_SET;
551 WRITE32(NFS4_SET_TO_CLIENT_TIME);
553 WRITE32(iap->ia_mtime.tv_sec);
554 WRITE32(iap->ia_mtime.tv_nsec);
556 else if (iap->ia_valid & ATTR_ATIME) {
557 bmval1 |= FATTR4_WORD1_TIME_ACCESS_SET;
558 WRITE32(NFS4_SET_TO_SERVER_TIME);
560 if (iap->ia_valid & ATTR_MTIME_SET) {
561 bmval1 |= FATTR4_WORD1_TIME_MODIFY_SET;
562 WRITE32(NFS4_SET_TO_CLIENT_TIME);
564 WRITE32(iap->ia_mtime.tv_sec);
565 WRITE32(iap->ia_mtime.tv_nsec);
567 else if (iap->ia_valid & ATTR_MTIME) {
568 bmval1 |= FATTR4_WORD1_TIME_MODIFY_SET;
569 WRITE32(NFS4_SET_TO_SERVER_TIME);
573 * Now we backfill the bitmap and the attribute buffer length.
575 if (len != ((char *)p - (char *)q) + 4) {
576 printk ("encode_attr: Attr length calculation error! %u != %Zu\n",
577 len, ((char *)p - (char *)q) + 4);
580 len = (char *)p - (char *)q - 12;
581 *q++ = htonl(bmval0);
582 *q++ = htonl(bmval1);
590 static int encode_access(struct xdr_stream *xdr, u32 access)
601 static int encode_close(struct xdr_stream *xdr, const struct nfs_closeargs *arg)
605 RESERVE_SPACE(8+sizeof(arg->stateid->data));
607 WRITE32(arg->seqid->sequence->counter);
608 WRITEMEM(arg->stateid->data, sizeof(arg->stateid->data));
613 static int encode_commit(struct xdr_stream *xdr, const struct nfs_writeargs *args)
619 WRITE64(args->offset);
620 WRITE32(args->count);
625 static int encode_create(struct xdr_stream *xdr, const struct nfs4_create_arg *create)
631 WRITE32(create->ftype);
633 switch (create->ftype) {
635 RESERVE_SPACE(4 + create->u.symlink->len);
636 WRITE32(create->u.symlink->len);
637 WRITEMEM(create->u.symlink->name, create->u.symlink->len);
640 case NF4BLK: case NF4CHR:
642 WRITE32(create->u.device.specdata1);
643 WRITE32(create->u.device.specdata2);
650 RESERVE_SPACE(4 + create->name->len);
651 WRITE32(create->name->len);
652 WRITEMEM(create->name->name, create->name->len);
654 return encode_attrs(xdr, create->attrs, create->server);
657 static int encode_getattr_one(struct xdr_stream *xdr, uint32_t bitmap)
668 static int encode_getattr_two(struct xdr_stream *xdr, uint32_t bm0, uint32_t bm1)
680 static int encode_getfattr(struct xdr_stream *xdr, const u32* bitmask)
682 return encode_getattr_two(xdr,
683 bitmask[0] & nfs4_fattr_bitmap[0],
684 bitmask[1] & nfs4_fattr_bitmap[1]);
687 static int encode_fsinfo(struct xdr_stream *xdr, const u32* bitmask)
689 return encode_getattr_two(xdr, bitmask[0] & nfs4_fsinfo_bitmap[0],
690 bitmask[1] & nfs4_fsinfo_bitmap[1]);
693 static int encode_getfh(struct xdr_stream *xdr)
703 static int encode_link(struct xdr_stream *xdr, const struct qstr *name)
707 RESERVE_SPACE(8 + name->len);
710 WRITEMEM(name->name, name->len);
716 * opcode,type,reclaim,offset,length,new_lock_owner = 32
717 * open_seqid,open_stateid,lock_seqid,lock_owner.clientid, lock_owner.id = 40
719 static int encode_lock(struct xdr_stream *xdr, const struct nfs_lockargs *arg)
722 struct nfs_lock_opargs *opargs = arg->u.lock;
727 WRITE32(opargs->reclaim);
728 WRITE64(arg->offset);
729 WRITE64(arg->length);
730 WRITE32(opargs->new_lock_owner);
731 if (opargs->new_lock_owner){
733 WRITE32(opargs->open_seqid->sequence->counter);
734 WRITEMEM(opargs->open_stateid->data, sizeof(opargs->open_stateid->data));
735 WRITE32(opargs->lock_seqid->sequence->counter);
736 WRITE64(opargs->lock_owner.clientid);
738 WRITE32(opargs->lock_owner.id);
742 WRITEMEM(opargs->lock_stateid->data, sizeof(opargs->lock_stateid->data));
743 WRITE32(opargs->lock_seqid->sequence->counter);
749 static int encode_lockt(struct xdr_stream *xdr, const struct nfs_lockargs *arg)
752 struct nfs_lowner *opargs = arg->u.lockt;
757 WRITE64(arg->offset);
758 WRITE64(arg->length);
759 WRITE64(opargs->clientid);
766 static int encode_locku(struct xdr_stream *xdr, const struct nfs_lockargs *arg)
769 struct nfs_locku_opargs *opargs = arg->u.locku;
774 WRITE32(opargs->seqid->sequence->counter);
775 WRITEMEM(opargs->stateid->data, sizeof(opargs->stateid->data));
776 WRITE64(arg->offset);
777 WRITE64(arg->length);
782 static int encode_lookup(struct xdr_stream *xdr, const struct qstr *name)
787 RESERVE_SPACE(8 + len);
790 WRITEMEM(name->name, len);
795 static void encode_share_access(struct xdr_stream *xdr, int open_flags)
800 switch (open_flags & (FMODE_READ|FMODE_WRITE)) {
802 WRITE32(NFS4_SHARE_ACCESS_READ);
805 WRITE32(NFS4_SHARE_ACCESS_WRITE);
807 case FMODE_READ|FMODE_WRITE:
808 WRITE32(NFS4_SHARE_ACCESS_BOTH);
813 WRITE32(0); /* for linux, share_deny = 0 always */
816 static inline void encode_openhdr(struct xdr_stream *xdr, const struct nfs_openargs *arg)
820 * opcode 4, seqid 4, share_access 4, share_deny 4, clientid 8, ownerlen 4,
825 WRITE32(arg->seqid->sequence->counter);
826 encode_share_access(xdr, arg->open_flags);
828 WRITE64(arg->clientid);
833 static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_openargs *arg)
838 switch(arg->open_flags & O_EXCL) {
840 WRITE32(NFS4_CREATE_UNCHECKED);
841 encode_attrs(xdr, arg->u.attrs, arg->server);
844 WRITE32(NFS4_CREATE_EXCLUSIVE);
845 encode_nfs4_verifier(xdr, &arg->u.verifier);
849 static void encode_opentype(struct xdr_stream *xdr, const struct nfs_openargs *arg)
854 switch (arg->open_flags & O_CREAT) {
856 WRITE32(NFS4_OPEN_NOCREATE);
859 BUG_ON(arg->claim != NFS4_OPEN_CLAIM_NULL);
860 WRITE32(NFS4_OPEN_CREATE);
861 encode_createmode(xdr, arg);
865 static inline void encode_delegation_type(struct xdr_stream *xdr, int delegation_type)
870 switch (delegation_type) {
872 WRITE32(NFS4_OPEN_DELEGATE_NONE);
875 WRITE32(NFS4_OPEN_DELEGATE_READ);
877 case FMODE_WRITE|FMODE_READ:
878 WRITE32(NFS4_OPEN_DELEGATE_WRITE);
885 static inline void encode_claim_null(struct xdr_stream *xdr, const struct qstr *name)
890 WRITE32(NFS4_OPEN_CLAIM_NULL);
891 encode_string(xdr, name->len, name->name);
894 static inline void encode_claim_previous(struct xdr_stream *xdr, int type)
899 WRITE32(NFS4_OPEN_CLAIM_PREVIOUS);
900 encode_delegation_type(xdr, type);
903 static inline void encode_claim_delegate_cur(struct xdr_stream *xdr, const struct qstr *name, const nfs4_stateid *stateid)
907 RESERVE_SPACE(4+sizeof(stateid->data));
908 WRITE32(NFS4_OPEN_CLAIM_DELEGATE_CUR);
909 WRITEMEM(stateid->data, sizeof(stateid->data));
910 encode_string(xdr, name->len, name->name);
913 static int encode_open(struct xdr_stream *xdr, const struct nfs_openargs *arg)
915 encode_openhdr(xdr, arg);
916 encode_opentype(xdr, arg);
917 switch (arg->claim) {
918 case NFS4_OPEN_CLAIM_NULL:
919 encode_claim_null(xdr, arg->name);
921 case NFS4_OPEN_CLAIM_PREVIOUS:
922 encode_claim_previous(xdr, arg->u.delegation_type);
924 case NFS4_OPEN_CLAIM_DELEGATE_CUR:
925 encode_claim_delegate_cur(xdr, arg->name, &arg->u.delegation);
933 static int encode_open_confirm(struct xdr_stream *xdr, const struct nfs_open_confirmargs *arg)
937 RESERVE_SPACE(8+sizeof(arg->stateid.data));
938 WRITE32(OP_OPEN_CONFIRM);
939 WRITEMEM(arg->stateid.data, sizeof(arg->stateid.data));
940 WRITE32(arg->seqid->sequence->counter);
945 static int encode_open_downgrade(struct xdr_stream *xdr, const struct nfs_closeargs *arg)
949 RESERVE_SPACE(8+sizeof(arg->stateid->data));
950 WRITE32(OP_OPEN_DOWNGRADE);
951 WRITEMEM(arg->stateid->data, sizeof(arg->stateid->data));
952 WRITE32(arg->seqid->sequence->counter);
953 encode_share_access(xdr, arg->open_flags);
958 encode_putfh(struct xdr_stream *xdr, const struct nfs_fh *fh)
963 RESERVE_SPACE(8 + len);
966 WRITEMEM(fh->data, len);
971 static int encode_putrootfh(struct xdr_stream *xdr)
976 WRITE32(OP_PUTROOTFH);
981 static void encode_stateid(struct xdr_stream *xdr, const struct nfs_open_context *ctx)
983 nfs4_stateid stateid;
987 if (ctx->state != NULL) {
988 nfs4_copy_stateid(&stateid, ctx->state, ctx->lockowner);
989 WRITEMEM(stateid.data, sizeof(stateid.data));
991 WRITEMEM(zero_stateid.data, sizeof(zero_stateid.data));
994 static int encode_read(struct xdr_stream *xdr, const struct nfs_readargs *args)
1001 encode_stateid(xdr, args->context);
1004 WRITE64(args->offset);
1005 WRITE32(args->count);
1010 static int encode_readdir(struct xdr_stream *xdr, const struct nfs4_readdir_arg *readdir, struct rpc_rqst *req)
1012 struct rpc_auth *auth = req->rq_task->tk_auth;
1013 uint32_t attrs[2] = {
1014 FATTR4_WORD0_RDATTR_ERROR|FATTR4_WORD0_FILEID,
1015 FATTR4_WORD1_MOUNTED_ON_FILEID,
1020 RESERVE_SPACE(32+sizeof(nfs4_verifier));
1021 WRITE32(OP_READDIR);
1022 WRITE64(readdir->cookie);
1023 WRITEMEM(readdir->verifier.data, sizeof(readdir->verifier.data));
1024 WRITE32(readdir->count >> 1); /* We're not doing readdirplus */
1025 WRITE32(readdir->count);
1027 /* Switch to mounted_on_fileid if the server supports it */
1028 if (readdir->bitmask[1] & FATTR4_WORD1_MOUNTED_ON_FILEID)
1029 attrs[0] &= ~FATTR4_WORD0_FILEID;
1031 attrs[1] &= ~FATTR4_WORD1_MOUNTED_ON_FILEID;
1032 WRITE32(attrs[0] & readdir->bitmask[0]);
1033 WRITE32(attrs[1] & readdir->bitmask[1]);
1034 dprintk("%s: cookie = %Lu, verifier = 0x%x%x, bitmap = 0x%x%x\n",
1036 (unsigned long long)readdir->cookie,
1037 ((u32 *)readdir->verifier.data)[0],
1038 ((u32 *)readdir->verifier.data)[1],
1039 attrs[0] & readdir->bitmask[0],
1040 attrs[1] & readdir->bitmask[1]);
1042 /* set up reply kvec
1043 * toplevel_status + taglen + rescount + OP_PUTFH + status
1044 * + OP_READDIR + status + verifer(2) = 9
1046 replen = (RPC_REPHDRSIZE + auth->au_rslack + 9) << 2;
1047 xdr_inline_pages(&req->rq_rcv_buf, replen, readdir->pages,
1048 readdir->pgbase, readdir->count);
1049 dprintk("%s: inlined page args = (%u, %p, %u, %u)\n",
1050 __FUNCTION__, replen, readdir->pages,
1051 readdir->pgbase, readdir->count);
1056 static int encode_readlink(struct xdr_stream *xdr, const struct nfs4_readlink *readlink, struct rpc_rqst *req)
1058 struct rpc_auth *auth = req->rq_task->tk_auth;
1059 unsigned int replen;
1063 WRITE32(OP_READLINK);
1065 /* set up reply kvec
1066 * toplevel_status + taglen + rescount + OP_PUTFH + status
1067 * + OP_READLINK + status + string length = 8
1069 replen = (RPC_REPHDRSIZE + auth->au_rslack + 8) << 2;
1070 xdr_inline_pages(&req->rq_rcv_buf, replen, readlink->pages,
1071 readlink->pgbase, readlink->pglen);
1076 static int encode_remove(struct xdr_stream *xdr, const struct qstr *name)
1080 RESERVE_SPACE(8 + name->len);
1083 WRITEMEM(name->name, name->len);
1088 static int encode_rename(struct xdr_stream *xdr, const struct qstr *oldname, const struct qstr *newname)
1092 RESERVE_SPACE(8 + oldname->len);
1094 WRITE32(oldname->len);
1095 WRITEMEM(oldname->name, oldname->len);
1097 RESERVE_SPACE(4 + newname->len);
1098 WRITE32(newname->len);
1099 WRITEMEM(newname->name, newname->len);
1104 static int encode_renew(struct xdr_stream *xdr, const struct nfs4_client *client_stateid)
1110 WRITE64(client_stateid->cl_clientid);
1116 encode_setacl(struct xdr_stream *xdr, struct nfs_setaclargs *arg)
1120 RESERVE_SPACE(4+sizeof(zero_stateid.data));
1121 WRITE32(OP_SETATTR);
1122 WRITEMEM(zero_stateid.data, sizeof(zero_stateid.data));
1125 WRITE32(FATTR4_WORD0_ACL);
1126 if (arg->acl_len % 4)
1129 WRITE32(arg->acl_len);
1130 xdr_write_pages(xdr, arg->acl_pages, arg->acl_pgbase, arg->acl_len);
1135 encode_savefh(struct xdr_stream *xdr)
1145 static int encode_setattr(struct xdr_stream *xdr, const struct nfs_setattrargs *arg, const struct nfs_server *server)
1150 RESERVE_SPACE(4+sizeof(arg->stateid.data));
1151 WRITE32(OP_SETATTR);
1152 WRITEMEM(arg->stateid.data, sizeof(arg->stateid.data));
1154 if ((status = encode_attrs(xdr, arg->iap, server)))
1160 static int encode_setclientid(struct xdr_stream *xdr, const struct nfs4_setclientid *setclientid)
1164 RESERVE_SPACE(4 + sizeof(setclientid->sc_verifier->data));
1165 WRITE32(OP_SETCLIENTID);
1166 WRITEMEM(setclientid->sc_verifier->data, sizeof(setclientid->sc_verifier->data));
1168 encode_string(xdr, setclientid->sc_name_len, setclientid->sc_name);
1170 WRITE32(setclientid->sc_prog);
1171 encode_string(xdr, setclientid->sc_netid_len, setclientid->sc_netid);
1172 encode_string(xdr, setclientid->sc_uaddr_len, setclientid->sc_uaddr);
1174 WRITE32(setclientid->sc_cb_ident);
1179 static int encode_setclientid_confirm(struct xdr_stream *xdr, const struct nfs4_client *client_state)
1183 RESERVE_SPACE(12 + sizeof(client_state->cl_confirm.data));
1184 WRITE32(OP_SETCLIENTID_CONFIRM);
1185 WRITE64(client_state->cl_clientid);
1186 WRITEMEM(client_state->cl_confirm.data, sizeof(client_state->cl_confirm.data));
1191 static int encode_write(struct xdr_stream *xdr, const struct nfs_writeargs *args)
1198 encode_stateid(xdr, args->context);
1201 WRITE64(args->offset);
1202 WRITE32(args->stable);
1203 WRITE32(args->count);
1205 xdr_write_pages(xdr, args->pages, args->pgbase, args->count);
1210 static int encode_delegreturn(struct xdr_stream *xdr, const nfs4_stateid *stateid)
1216 WRITE32(OP_DELEGRETURN);
1217 WRITEMEM(stateid->data, sizeof(stateid->data));
1222 * END OF "GENERIC" ENCODE ROUTINES.
1226 * Encode an ACCESS request
1228 static int nfs4_xdr_enc_access(struct rpc_rqst *req, uint32_t *p, const struct nfs4_accessargs *args)
1230 struct xdr_stream xdr;
1231 struct compound_hdr hdr = {
1236 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1237 encode_compound_hdr(&xdr, &hdr);
1238 if ((status = encode_putfh(&xdr, args->fh)) == 0)
1239 status = encode_access(&xdr, args->access);
1244 * Encode LOOKUP request
1246 static int nfs4_xdr_enc_lookup(struct rpc_rqst *req, uint32_t *p, const struct nfs4_lookup_arg *args)
1248 struct xdr_stream xdr;
1249 struct compound_hdr hdr = {
1254 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1255 encode_compound_hdr(&xdr, &hdr);
1256 if ((status = encode_putfh(&xdr, args->dir_fh)) != 0)
1258 if ((status = encode_lookup(&xdr, args->name)) != 0)
1260 if ((status = encode_getfh(&xdr)) != 0)
1262 status = encode_getfattr(&xdr, args->bitmask);
1268 * Encode LOOKUP_ROOT request
1270 static int nfs4_xdr_enc_lookup_root(struct rpc_rqst *req, uint32_t *p, const struct nfs4_lookup_root_arg *args)
1272 struct xdr_stream xdr;
1273 struct compound_hdr hdr = {
1278 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1279 encode_compound_hdr(&xdr, &hdr);
1280 if ((status = encode_putrootfh(&xdr)) != 0)
1282 if ((status = encode_getfh(&xdr)) == 0)
1283 status = encode_getfattr(&xdr, args->bitmask);
1289 * Encode REMOVE request
1291 static int nfs4_xdr_enc_remove(struct rpc_rqst *req, uint32_t *p, const struct nfs4_remove_arg *args)
1293 struct xdr_stream xdr;
1294 struct compound_hdr hdr = {
1299 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1300 encode_compound_hdr(&xdr, &hdr);
1301 if ((status = encode_putfh(&xdr, args->fh)) == 0)
1302 status = encode_remove(&xdr, args->name);
1307 * Encode RENAME request
1309 static int nfs4_xdr_enc_rename(struct rpc_rqst *req, uint32_t *p, const struct nfs4_rename_arg *args)
1311 struct xdr_stream xdr;
1312 struct compound_hdr hdr = {
1317 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1318 encode_compound_hdr(&xdr, &hdr);
1319 if ((status = encode_putfh(&xdr, args->old_dir)) != 0)
1321 if ((status = encode_savefh(&xdr)) != 0)
1323 if ((status = encode_putfh(&xdr, args->new_dir)) != 0)
1325 status = encode_rename(&xdr, args->old_name, args->new_name);
1331 * Encode LINK request
1333 static int nfs4_xdr_enc_link(struct rpc_rqst *req, uint32_t *p, const struct nfs4_link_arg *args)
1335 struct xdr_stream xdr;
1336 struct compound_hdr hdr = {
1341 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1342 encode_compound_hdr(&xdr, &hdr);
1343 if ((status = encode_putfh(&xdr, args->fh)) != 0)
1345 if ((status = encode_savefh(&xdr)) != 0)
1347 if ((status = encode_putfh(&xdr, args->dir_fh)) != 0)
1349 status = encode_link(&xdr, args->name);
1355 * Encode CREATE request
1357 static int nfs4_xdr_enc_create(struct rpc_rqst *req, uint32_t *p, const struct nfs4_create_arg *args)
1359 struct xdr_stream xdr;
1360 struct compound_hdr hdr = {
1365 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1366 encode_compound_hdr(&xdr, &hdr);
1367 if ((status = encode_putfh(&xdr, args->dir_fh)) != 0)
1369 if ((status = encode_create(&xdr, args)) != 0)
1371 if ((status = encode_getfh(&xdr)) != 0)
1373 status = encode_getfattr(&xdr, args->bitmask);
1379 * Encode SYMLINK request
1381 static int nfs4_xdr_enc_symlink(struct rpc_rqst *req, uint32_t *p, const struct nfs4_create_arg *args)
1383 return nfs4_xdr_enc_create(req, p, args);
1387 * Encode GETATTR request
1389 static int nfs4_xdr_enc_getattr(struct rpc_rqst *req, uint32_t *p, const struct nfs4_getattr_arg *args)
1391 struct xdr_stream xdr;
1392 struct compound_hdr hdr = {
1397 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1398 encode_compound_hdr(&xdr, &hdr);
1399 if ((status = encode_putfh(&xdr, args->fh)) == 0)
1400 status = encode_getfattr(&xdr, args->bitmask);
1405 * Encode a CLOSE request
1407 static int nfs4_xdr_enc_close(struct rpc_rqst *req, uint32_t *p, struct nfs_closeargs *args)
1409 struct xdr_stream xdr;
1410 struct compound_hdr hdr = {
1415 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1416 encode_compound_hdr(&xdr, &hdr);
1417 status = encode_putfh(&xdr, args->fh);
1420 status = encode_close(&xdr, args);
1426 * Encode an OPEN request
1428 static int nfs4_xdr_enc_open(struct rpc_rqst *req, uint32_t *p, struct nfs_openargs *args)
1430 struct xdr_stream xdr;
1431 struct compound_hdr hdr = {
1436 status = nfs_wait_on_sequence(args->seqid, req->rq_task);
1439 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1440 encode_compound_hdr(&xdr, &hdr);
1441 status = encode_putfh(&xdr, args->fh);
1444 status = encode_open(&xdr, args);
1447 status = encode_getfh(&xdr);
1450 status = encode_getfattr(&xdr, args->bitmask);
1456 * Encode an OPEN_CONFIRM request
1458 static int nfs4_xdr_enc_open_confirm(struct rpc_rqst *req, uint32_t *p, struct nfs_open_confirmargs *args)
1460 struct xdr_stream xdr;
1461 struct compound_hdr hdr = {
1466 status = nfs_wait_on_sequence(args->seqid, req->rq_task);
1469 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1470 encode_compound_hdr(&xdr, &hdr);
1471 status = encode_putfh(&xdr, args->fh);
1474 status = encode_open_confirm(&xdr, args);
1480 * Encode an OPEN request with no attributes.
1482 static int nfs4_xdr_enc_open_noattr(struct rpc_rqst *req, uint32_t *p, struct nfs_openargs *args)
1484 struct xdr_stream xdr;
1485 struct compound_hdr hdr = {
1490 status = nfs_wait_on_sequence(args->seqid, req->rq_task);
1493 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1494 encode_compound_hdr(&xdr, &hdr);
1495 status = encode_putfh(&xdr, args->fh);
1498 status = encode_open(&xdr, args);
1504 * Encode an OPEN_DOWNGRADE request
1506 static int nfs4_xdr_enc_open_downgrade(struct rpc_rqst *req, uint32_t *p, struct nfs_closeargs *args)
1508 struct xdr_stream xdr;
1509 struct compound_hdr hdr = {
1514 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1515 encode_compound_hdr(&xdr, &hdr);
1516 status = encode_putfh(&xdr, args->fh);
1519 status = encode_open_downgrade(&xdr, args);
1525 * Encode a LOCK request
1527 static int nfs4_xdr_enc_lock(struct rpc_rqst *req, uint32_t *p, struct nfs_lockargs *args)
1529 struct xdr_stream xdr;
1530 struct compound_hdr hdr = {
1533 struct nfs_lock_opargs *opargs = args->u.lock;
1536 status = nfs_wait_on_sequence(opargs->lock_seqid, req->rq_task);
1539 /* Do we need to do an open_to_lock_owner? */
1540 if (opargs->lock_seqid->sequence->flags & NFS_SEQID_CONFIRMED)
1541 opargs->new_lock_owner = 0;
1542 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1543 encode_compound_hdr(&xdr, &hdr);
1544 status = encode_putfh(&xdr, args->fh);
1547 status = encode_lock(&xdr, args);
1553 * Encode a LOCKT request
1555 static int nfs4_xdr_enc_lockt(struct rpc_rqst *req, uint32_t *p, struct nfs_lockargs *args)
1557 struct xdr_stream xdr;
1558 struct compound_hdr hdr = {
1563 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1564 encode_compound_hdr(&xdr, &hdr);
1565 status = encode_putfh(&xdr, args->fh);
1568 status = encode_lockt(&xdr, args);
1574 * Encode a LOCKU request
1576 static int nfs4_xdr_enc_locku(struct rpc_rqst *req, uint32_t *p, struct nfs_lockargs *args)
1578 struct xdr_stream xdr;
1579 struct compound_hdr hdr = {
1584 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1585 encode_compound_hdr(&xdr, &hdr);
1586 status = encode_putfh(&xdr, args->fh);
1589 status = encode_locku(&xdr, args);
1595 * Encode a READLINK request
1597 static int nfs4_xdr_enc_readlink(struct rpc_rqst *req, uint32_t *p, const struct nfs4_readlink *args)
1599 struct xdr_stream xdr;
1600 struct compound_hdr hdr = {
1605 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1606 encode_compound_hdr(&xdr, &hdr);
1607 status = encode_putfh(&xdr, args->fh);
1610 status = encode_readlink(&xdr, args, req);
1616 * Encode a READDIR request
1618 static int nfs4_xdr_enc_readdir(struct rpc_rqst *req, uint32_t *p, const struct nfs4_readdir_arg *args)
1620 struct xdr_stream xdr;
1621 struct compound_hdr hdr = {
1626 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1627 encode_compound_hdr(&xdr, &hdr);
1628 status = encode_putfh(&xdr, args->fh);
1631 status = encode_readdir(&xdr, args, req);
1637 * Encode a READ request
1639 static int nfs4_xdr_enc_read(struct rpc_rqst *req, uint32_t *p, struct nfs_readargs *args)
1641 struct rpc_auth *auth = req->rq_task->tk_auth;
1642 struct xdr_stream xdr;
1643 struct compound_hdr hdr = {
1648 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1649 encode_compound_hdr(&xdr, &hdr);
1650 status = encode_putfh(&xdr, args->fh);
1653 status = encode_read(&xdr, args);
1657 /* set up reply kvec
1658 * toplevel status + taglen=0 + rescount + OP_PUTFH + status
1659 * + OP_READ + status + eof + datalen = 9
1661 replen = (RPC_REPHDRSIZE + auth->au_rslack + NFS4_dec_read_sz) << 2;
1662 xdr_inline_pages(&req->rq_rcv_buf, replen,
1663 args->pages, args->pgbase, args->count);
1669 * Encode an SETATTR request
1671 static int nfs4_xdr_enc_setattr(struct rpc_rqst *req, uint32_t *p, struct nfs_setattrargs *args)
1674 struct xdr_stream xdr;
1675 struct compound_hdr hdr = {
1680 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1681 encode_compound_hdr(&xdr, &hdr);
1682 status = encode_putfh(&xdr, args->fh);
1685 status = encode_setattr(&xdr, args, args->server);
1688 status = encode_getfattr(&xdr, args->bitmask);
1694 * Encode a GETACL request
1697 nfs4_xdr_enc_getacl(struct rpc_rqst *req, uint32_t *p,
1698 struct nfs_getaclargs *args)
1700 struct xdr_stream xdr;
1701 struct rpc_auth *auth = req->rq_task->tk_auth;
1702 struct compound_hdr hdr = {
1707 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1708 encode_compound_hdr(&xdr, &hdr);
1709 status = encode_putfh(&xdr, args->fh);
1712 status = encode_getattr_two(&xdr, FATTR4_WORD0_ACL, 0);
1713 /* set up reply buffer: */
1714 replen = (RPC_REPHDRSIZE + auth->au_rslack + NFS4_dec_getacl_sz) << 2;
1715 xdr_inline_pages(&req->rq_rcv_buf, replen,
1716 args->acl_pages, args->acl_pgbase, args->acl_len);
1722 * Encode a WRITE request
1724 static int nfs4_xdr_enc_write(struct rpc_rqst *req, uint32_t *p, struct nfs_writeargs *args)
1726 struct xdr_stream xdr;
1727 struct compound_hdr hdr = {
1732 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1733 encode_compound_hdr(&xdr, &hdr);
1734 status = encode_putfh(&xdr, args->fh);
1737 status = encode_write(&xdr, args);
1745 static int nfs4_xdr_enc_commit(struct rpc_rqst *req, uint32_t *p, struct nfs_writeargs *args)
1747 struct xdr_stream xdr;
1748 struct compound_hdr hdr = {
1753 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1754 encode_compound_hdr(&xdr, &hdr);
1755 status = encode_putfh(&xdr, args->fh);
1758 status = encode_commit(&xdr, args);
1766 static int nfs4_xdr_enc_fsinfo(struct rpc_rqst *req, uint32_t *p, struct nfs4_fsinfo_arg *args)
1768 struct xdr_stream xdr;
1769 struct compound_hdr hdr = {
1774 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1775 encode_compound_hdr(&xdr, &hdr);
1776 status = encode_putfh(&xdr, args->fh);
1778 status = encode_fsinfo(&xdr, args->bitmask);
1783 * a PATHCONF request
1785 static int nfs4_xdr_enc_pathconf(struct rpc_rqst *req, uint32_t *p, const struct nfs4_pathconf_arg *args)
1787 struct xdr_stream xdr;
1788 struct compound_hdr hdr = {
1793 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1794 encode_compound_hdr(&xdr, &hdr);
1795 status = encode_putfh(&xdr, args->fh);
1797 status = encode_getattr_one(&xdr,
1798 args->bitmask[0] & nfs4_pathconf_bitmap[0]);
1805 static int nfs4_xdr_enc_statfs(struct rpc_rqst *req, uint32_t *p, const struct nfs4_statfs_arg *args)
1807 struct xdr_stream xdr;
1808 struct compound_hdr hdr = {
1813 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1814 encode_compound_hdr(&xdr, &hdr);
1815 status = encode_putfh(&xdr, args->fh);
1817 status = encode_getattr_two(&xdr,
1818 args->bitmask[0] & nfs4_statfs_bitmap[0],
1819 args->bitmask[1] & nfs4_statfs_bitmap[1]);
1824 * GETATTR_BITMAP request
1826 static int nfs4_xdr_enc_server_caps(struct rpc_rqst *req, uint32_t *p, const struct nfs_fh *fhandle)
1828 struct xdr_stream xdr;
1829 struct compound_hdr hdr = {
1834 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1835 encode_compound_hdr(&xdr, &hdr);
1836 status = encode_putfh(&xdr, fhandle);
1838 status = encode_getattr_one(&xdr, FATTR4_WORD0_SUPPORTED_ATTRS|
1839 FATTR4_WORD0_LINK_SUPPORT|
1840 FATTR4_WORD0_SYMLINK_SUPPORT|
1841 FATTR4_WORD0_ACLSUPPORT);
1848 static int nfs4_xdr_enc_renew(struct rpc_rqst *req, uint32_t *p, struct nfs4_client *clp)
1850 struct xdr_stream xdr;
1851 struct compound_hdr hdr = {
1855 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1856 encode_compound_hdr(&xdr, &hdr);
1857 return encode_renew(&xdr, clp);
1861 * a SETCLIENTID request
1863 static int nfs4_xdr_enc_setclientid(struct rpc_rqst *req, uint32_t *p, struct nfs4_setclientid *sc)
1865 struct xdr_stream xdr;
1866 struct compound_hdr hdr = {
1870 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1871 encode_compound_hdr(&xdr, &hdr);
1872 return encode_setclientid(&xdr, sc);
1876 * a SETCLIENTID_CONFIRM request
1878 static int nfs4_xdr_enc_setclientid_confirm(struct rpc_rqst *req, uint32_t *p, struct nfs4_client *clp)
1880 struct xdr_stream xdr;
1881 struct compound_hdr hdr = {
1884 const u32 lease_bitmap[2] = { FATTR4_WORD0_LEASE_TIME, 0 };
1887 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1888 encode_compound_hdr(&xdr, &hdr);
1889 status = encode_setclientid_confirm(&xdr, clp);
1891 status = encode_putrootfh(&xdr);
1893 status = encode_fsinfo(&xdr, lease_bitmap);
1898 * DELEGRETURN request
1900 static int nfs4_xdr_enc_delegreturn(struct rpc_rqst *req, uint32_t *p, const struct nfs4_delegreturnargs *args)
1902 struct xdr_stream xdr;
1903 struct compound_hdr hdr = {
1908 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1909 encode_compound_hdr(&xdr, &hdr);
1910 if ((status = encode_putfh(&xdr, args->fhandle)) == 0)
1911 status = encode_delegreturn(&xdr, args->stateid);
1916 * START OF "GENERIC" DECODE ROUTINES.
1917 * These may look a little ugly since they are imported from a "generic"
1918 * set of XDR encode/decode routines which are intended to be shared by
1919 * all of our NFSv4 implementations (OpenBSD, MacOS X...).
1921 * If the pain of reading these is too great, it should be a straightforward
1922 * task to translate them into Linux-specific versions which are more
1923 * consistent with the style used in NFSv2/v3...
1925 #define READ32(x) (x) = ntohl(*p++)
1926 #define READ64(x) do { \
1927 (x) = (u64)ntohl(*p++) << 32; \
1928 (x) |= ntohl(*p++); \
1930 #define READTIME(x) do { \
1932 (x.tv_sec) = ntohl(*p++); \
1933 (x.tv_nsec) = ntohl(*p++); \
1935 #define COPYMEM(x,nbytes) do { \
1936 memcpy((x), p, nbytes); \
1937 p += XDR_QUADLEN(nbytes); \
1940 #define READ_BUF(nbytes) do { \
1941 p = xdr_inline_decode(xdr, nbytes); \
1943 printk(KERN_WARNING "%s: reply buffer overflowed in line %d.", \
1944 __FUNCTION__, __LINE__); \
1949 static int decode_opaque_inline(struct xdr_stream *xdr, uint32_t *len, char **string)
1956 *string = (char *)p;
1960 static int decode_compound_hdr(struct xdr_stream *xdr, struct compound_hdr *hdr)
1965 READ32(hdr->status);
1966 READ32(hdr->taglen);
1968 READ_BUF(hdr->taglen + 4);
1969 hdr->tag = (char *)p;
1970 p += XDR_QUADLEN(hdr->taglen);
1975 static int decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected)
1983 if (opnum != expected) {
1985 "nfs4_decode_op_hdr: Server returned operation"
1986 " %d but we issued a request for %d\n",
1991 if (nfserr != NFS_OK)
1992 return -nfs_stat_to_errno(nfserr);
1997 static int decode_ace(struct xdr_stream *xdr, void *ace, struct nfs4_client *clp)
2004 return decode_opaque_inline(xdr, &strlen, &str);
2007 static int decode_attr_bitmap(struct xdr_stream *xdr, uint32_t *bitmap)
2014 bitmap[0] = bitmap[1] = 0;
2015 READ_BUF((bmlen << 2));
2024 static inline int decode_attr_length(struct xdr_stream *xdr, uint32_t *attrlen, uint32_t **savep)
2034 static int decode_attr_supported(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *bitmask)
2036 if (likely(bitmap[0] & FATTR4_WORD0_SUPPORTED_ATTRS)) {
2037 decode_attr_bitmap(xdr, bitmask);
2038 bitmap[0] &= ~FATTR4_WORD0_SUPPORTED_ATTRS;
2040 bitmask[0] = bitmask[1] = 0;
2041 dprintk("%s: bitmask=0x%x%x\n", __FUNCTION__, bitmask[0], bitmask[1]);
2045 static int decode_attr_type(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *type)
2050 if (unlikely(bitmap[0] & (FATTR4_WORD0_TYPE - 1U)))
2052 if (likely(bitmap[0] & FATTR4_WORD0_TYPE)) {
2055 if (*type < NF4REG || *type > NF4NAMEDATTR) {
2056 dprintk("%s: bad type %d\n", __FUNCTION__, *type);
2059 bitmap[0] &= ~FATTR4_WORD0_TYPE;
2061 dprintk("%s: type=0%o\n", __FUNCTION__, nfs_type2fmt[*type].nfs2type);
2065 static int decode_attr_change(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *change)
2070 if (unlikely(bitmap[0] & (FATTR4_WORD0_CHANGE - 1U)))
2072 if (likely(bitmap[0] & FATTR4_WORD0_CHANGE)) {
2075 bitmap[0] &= ~FATTR4_WORD0_CHANGE;
2077 dprintk("%s: change attribute=%Lu\n", __FUNCTION__,
2078 (unsigned long long)*change);
2082 static int decode_attr_size(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *size)
2087 if (unlikely(bitmap[0] & (FATTR4_WORD0_SIZE - 1U)))
2089 if (likely(bitmap[0] & FATTR4_WORD0_SIZE)) {
2092 bitmap[0] &= ~FATTR4_WORD0_SIZE;
2094 dprintk("%s: file size=%Lu\n", __FUNCTION__, (unsigned long long)*size);
2098 static int decode_attr_link_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
2103 if (unlikely(bitmap[0] & (FATTR4_WORD0_LINK_SUPPORT - 1U)))
2105 if (likely(bitmap[0] & FATTR4_WORD0_LINK_SUPPORT)) {
2108 bitmap[0] &= ~FATTR4_WORD0_LINK_SUPPORT;
2110 dprintk("%s: link support=%s\n", __FUNCTION__, *res == 0 ? "false" : "true");
2114 static int decode_attr_symlink_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
2119 if (unlikely(bitmap[0] & (FATTR4_WORD0_SYMLINK_SUPPORT - 1U)))
2121 if (likely(bitmap[0] & FATTR4_WORD0_SYMLINK_SUPPORT)) {
2124 bitmap[0] &= ~FATTR4_WORD0_SYMLINK_SUPPORT;
2126 dprintk("%s: symlink support=%s\n", __FUNCTION__, *res == 0 ? "false" : "true");
2130 static int decode_attr_fsid(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs4_fsid *fsid)
2136 if (unlikely(bitmap[0] & (FATTR4_WORD0_FSID - 1U)))
2138 if (likely(bitmap[0] & FATTR4_WORD0_FSID)) {
2140 READ64(fsid->major);
2141 READ64(fsid->minor);
2142 bitmap[0] &= ~FATTR4_WORD0_FSID;
2144 dprintk("%s: fsid=(0x%Lx/0x%Lx)\n", __FUNCTION__,
2145 (unsigned long long)fsid->major,
2146 (unsigned long long)fsid->minor);
2150 static int decode_attr_lease_time(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
2155 if (unlikely(bitmap[0] & (FATTR4_WORD0_LEASE_TIME - 1U)))
2157 if (likely(bitmap[0] & FATTR4_WORD0_LEASE_TIME)) {
2160 bitmap[0] &= ~FATTR4_WORD0_LEASE_TIME;
2162 dprintk("%s: file size=%u\n", __FUNCTION__, (unsigned int)*res);
2166 static int decode_attr_aclsupport(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
2170 *res = ACL4_SUPPORT_ALLOW_ACL|ACL4_SUPPORT_DENY_ACL;
2171 if (unlikely(bitmap[0] & (FATTR4_WORD0_ACLSUPPORT - 1U)))
2173 if (likely(bitmap[0] & FATTR4_WORD0_ACLSUPPORT)) {
2176 bitmap[0] &= ~FATTR4_WORD0_ACLSUPPORT;
2178 dprintk("%s: ACLs supported=%u\n", __FUNCTION__, (unsigned int)*res);
2182 static int decode_attr_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid)
2187 if (unlikely(bitmap[0] & (FATTR4_WORD0_FILEID - 1U)))
2189 if (likely(bitmap[0] & FATTR4_WORD0_FILEID)) {
2192 bitmap[0] &= ~FATTR4_WORD0_FILEID;
2194 dprintk("%s: fileid=%Lu\n", __FUNCTION__, (unsigned long long)*fileid);
2198 static int decode_attr_files_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
2204 if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_AVAIL - 1U)))
2206 if (likely(bitmap[0] & FATTR4_WORD0_FILES_AVAIL)) {
2209 bitmap[0] &= ~FATTR4_WORD0_FILES_AVAIL;
2211 dprintk("%s: files avail=%Lu\n", __FUNCTION__, (unsigned long long)*res);
2215 static int decode_attr_files_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
2221 if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_FREE - 1U)))
2223 if (likely(bitmap[0] & FATTR4_WORD0_FILES_FREE)) {
2226 bitmap[0] &= ~FATTR4_WORD0_FILES_FREE;
2228 dprintk("%s: files free=%Lu\n", __FUNCTION__, (unsigned long long)*res);
2232 static int decode_attr_files_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
2238 if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_TOTAL - 1U)))
2240 if (likely(bitmap[0] & FATTR4_WORD0_FILES_TOTAL)) {
2243 bitmap[0] &= ~FATTR4_WORD0_FILES_TOTAL;
2245 dprintk("%s: files total=%Lu\n", __FUNCTION__, (unsigned long long)*res);
2249 static int decode_attr_maxfilesize(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
2255 if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXFILESIZE - 1U)))
2257 if (likely(bitmap[0] & FATTR4_WORD0_MAXFILESIZE)) {
2260 bitmap[0] &= ~FATTR4_WORD0_MAXFILESIZE;
2262 dprintk("%s: maxfilesize=%Lu\n", __FUNCTION__, (unsigned long long)*res);
2266 static int decode_attr_maxlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxlink)
2272 if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXLINK - 1U)))
2274 if (likely(bitmap[0] & FATTR4_WORD0_MAXLINK)) {
2277 bitmap[0] &= ~FATTR4_WORD0_MAXLINK;
2279 dprintk("%s: maxlink=%u\n", __FUNCTION__, *maxlink);
2283 static int decode_attr_maxname(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxname)
2289 if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXNAME - 1U)))
2291 if (likely(bitmap[0] & FATTR4_WORD0_MAXNAME)) {
2294 bitmap[0] &= ~FATTR4_WORD0_MAXNAME;
2296 dprintk("%s: maxname=%u\n", __FUNCTION__, *maxname);
2300 static int decode_attr_maxread(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
2306 if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXREAD - 1U)))
2308 if (likely(bitmap[0] & FATTR4_WORD0_MAXREAD)) {
2312 if (maxread > 0x7FFFFFFF)
2313 maxread = 0x7FFFFFFF;
2314 *res = (uint32_t)maxread;
2315 bitmap[0] &= ~FATTR4_WORD0_MAXREAD;
2317 dprintk("%s: maxread=%lu\n", __FUNCTION__, (unsigned long)*res);
2321 static int decode_attr_maxwrite(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
2327 if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXWRITE - 1U)))
2329 if (likely(bitmap[0] & FATTR4_WORD0_MAXWRITE)) {
2333 if (maxwrite > 0x7FFFFFFF)
2334 maxwrite = 0x7FFFFFFF;
2335 *res = (uint32_t)maxwrite;
2336 bitmap[0] &= ~FATTR4_WORD0_MAXWRITE;
2338 dprintk("%s: maxwrite=%lu\n", __FUNCTION__, (unsigned long)*res);
2342 static int decode_attr_mode(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *mode)
2347 if (unlikely(bitmap[1] & (FATTR4_WORD1_MODE - 1U)))
2349 if (likely(bitmap[1] & FATTR4_WORD1_MODE)) {
2353 bitmap[1] &= ~FATTR4_WORD1_MODE;
2355 dprintk("%s: file mode=0%o\n", __FUNCTION__, (unsigned int)*mode);
2359 static int decode_attr_nlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *nlink)
2364 if (unlikely(bitmap[1] & (FATTR4_WORD1_NUMLINKS - 1U)))
2366 if (likely(bitmap[1] & FATTR4_WORD1_NUMLINKS)) {
2369 bitmap[1] &= ~FATTR4_WORD1_NUMLINKS;
2371 dprintk("%s: nlink=%u\n", __FUNCTION__, (unsigned int)*nlink);
2375 static int decode_attr_owner(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs4_client *clp, int32_t *uid)
2380 if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER - 1U)))
2382 if (likely(bitmap[1] & FATTR4_WORD1_OWNER)) {
2386 if (len < XDR_MAX_NETOBJ) {
2387 if (nfs_map_name_to_uid(clp, (char *)p, len, uid) != 0)
2388 dprintk("%s: nfs_map_name_to_uid failed!\n",
2391 printk(KERN_WARNING "%s: name too long (%u)!\n",
2393 bitmap[1] &= ~FATTR4_WORD1_OWNER;
2395 dprintk("%s: uid=%d\n", __FUNCTION__, (int)*uid);
2399 static int decode_attr_group(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs4_client *clp, int32_t *gid)
2404 if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER_GROUP - 1U)))
2406 if (likely(bitmap[1] & FATTR4_WORD1_OWNER_GROUP)) {
2410 if (len < XDR_MAX_NETOBJ) {
2411 if (nfs_map_group_to_gid(clp, (char *)p, len, gid) != 0)
2412 dprintk("%s: nfs_map_group_to_gid failed!\n",
2415 printk(KERN_WARNING "%s: name too long (%u)!\n",
2417 bitmap[1] &= ~FATTR4_WORD1_OWNER_GROUP;
2419 dprintk("%s: gid=%d\n", __FUNCTION__, (int)*gid);
2423 static int decode_attr_rdev(struct xdr_stream *xdr, uint32_t *bitmap, dev_t *rdev)
2425 uint32_t major = 0, minor = 0, *p;
2428 if (unlikely(bitmap[1] & (FATTR4_WORD1_RAWDEV - 1U)))
2430 if (likely(bitmap[1] & FATTR4_WORD1_RAWDEV)) {
2436 tmp = MKDEV(major, minor);
2437 if (MAJOR(tmp) == major && MINOR(tmp) == minor)
2439 bitmap[1] &= ~ FATTR4_WORD1_RAWDEV;
2441 dprintk("%s: rdev=(0x%x:0x%x)\n", __FUNCTION__, major, minor);
2445 static int decode_attr_space_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
2451 if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_AVAIL - 1U)))
2453 if (likely(bitmap[1] & FATTR4_WORD1_SPACE_AVAIL)) {
2456 bitmap[1] &= ~FATTR4_WORD1_SPACE_AVAIL;
2458 dprintk("%s: space avail=%Lu\n", __FUNCTION__, (unsigned long long)*res);
2462 static int decode_attr_space_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
2468 if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_FREE - 1U)))
2470 if (likely(bitmap[1] & FATTR4_WORD1_SPACE_FREE)) {
2473 bitmap[1] &= ~FATTR4_WORD1_SPACE_FREE;
2475 dprintk("%s: space free=%Lu\n", __FUNCTION__, (unsigned long long)*res);
2479 static int decode_attr_space_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
2485 if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_TOTAL - 1U)))
2487 if (likely(bitmap[1] & FATTR4_WORD1_SPACE_TOTAL)) {
2490 bitmap[1] &= ~FATTR4_WORD1_SPACE_TOTAL;
2492 dprintk("%s: space total=%Lu\n", __FUNCTION__, (unsigned long long)*res);
2496 static int decode_attr_space_used(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *used)
2501 if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_USED - 1U)))
2503 if (likely(bitmap[1] & FATTR4_WORD1_SPACE_USED)) {
2506 bitmap[1] &= ~FATTR4_WORD1_SPACE_USED;
2508 dprintk("%s: space used=%Lu\n", __FUNCTION__,
2509 (unsigned long long)*used);
2513 static int decode_attr_time(struct xdr_stream *xdr, struct timespec *time)
2522 time->tv_sec = (time_t)sec;
2523 time->tv_nsec = (long)nsec;
2527 static int decode_attr_time_access(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time)
2533 if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_ACCESS - 1U)))
2535 if (likely(bitmap[1] & FATTR4_WORD1_TIME_ACCESS)) {
2536 status = decode_attr_time(xdr, time);
2537 bitmap[1] &= ~FATTR4_WORD1_TIME_ACCESS;
2539 dprintk("%s: atime=%ld\n", __FUNCTION__, (long)time->tv_sec);
2543 static int decode_attr_time_metadata(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time)
2549 if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_METADATA - 1U)))
2551 if (likely(bitmap[1] & FATTR4_WORD1_TIME_METADATA)) {
2552 status = decode_attr_time(xdr, time);
2553 bitmap[1] &= ~FATTR4_WORD1_TIME_METADATA;
2555 dprintk("%s: ctime=%ld\n", __FUNCTION__, (long)time->tv_sec);
2559 static int decode_attr_time_modify(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time)
2565 if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_MODIFY - 1U)))
2567 if (likely(bitmap[1] & FATTR4_WORD1_TIME_MODIFY)) {
2568 status = decode_attr_time(xdr, time);
2569 bitmap[1] &= ~FATTR4_WORD1_TIME_MODIFY;
2571 dprintk("%s: mtime=%ld\n", __FUNCTION__, (long)time->tv_sec);
2575 static int verify_attr_len(struct xdr_stream *xdr, uint32_t *savep, uint32_t attrlen)
2577 unsigned int attrwords = XDR_QUADLEN(attrlen);
2578 unsigned int nwords = xdr->p - savep;
2580 if (unlikely(attrwords != nwords)) {
2581 printk(KERN_WARNING "%s: server returned incorrect attribute length: %u %c %u\n",
2584 (attrwords < nwords) ? '<' : '>',
2591 static int decode_change_info(struct xdr_stream *xdr, struct nfs4_change_info *cinfo)
2596 READ32(cinfo->atomic);
2597 READ64(cinfo->before);
2598 READ64(cinfo->after);
2602 static int decode_access(struct xdr_stream *xdr, struct nfs4_accessres *access)
2608 status = decode_op_hdr(xdr, OP_ACCESS);
2614 access->supported = supp;
2615 access->access = acc;
2619 static int decode_close(struct xdr_stream *xdr, struct nfs_closeres *res)
2624 status = decode_op_hdr(xdr, OP_CLOSE);
2627 READ_BUF(sizeof(res->stateid.data));
2628 COPYMEM(res->stateid.data, sizeof(res->stateid.data));
2632 static int decode_commit(struct xdr_stream *xdr, struct nfs_writeres *res)
2637 status = decode_op_hdr(xdr, OP_COMMIT);
2641 COPYMEM(res->verf->verifier, 8);
2645 static int decode_create(struct xdr_stream *xdr, struct nfs4_change_info *cinfo)
2651 status = decode_op_hdr(xdr, OP_CREATE);
2654 if ((status = decode_change_info(xdr, cinfo)))
2658 READ_BUF(bmlen << 2);
2662 static int decode_server_caps(struct xdr_stream *xdr, struct nfs4_server_caps_res *res)
2669 if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0)
2671 if ((status = decode_attr_bitmap(xdr, bitmap)) != 0)
2673 if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0)
2675 if ((status = decode_attr_supported(xdr, bitmap, res->attr_bitmask)) != 0)
2677 if ((status = decode_attr_link_support(xdr, bitmap, &res->has_links)) != 0)
2679 if ((status = decode_attr_symlink_support(xdr, bitmap, &res->has_symlinks)) != 0)
2681 if ((status = decode_attr_aclsupport(xdr, bitmap, &res->acl_bitmask)) != 0)
2683 status = verify_attr_len(xdr, savep, attrlen);
2686 printk(KERN_NOTICE "%s: xdr error %d!\n", __FUNCTION__, -status);
2690 static int decode_statfs(struct xdr_stream *xdr, struct nfs_fsstat *fsstat)
2697 if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0)
2699 if ((status = decode_attr_bitmap(xdr, bitmap)) != 0)
2701 if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0)
2704 if ((status = decode_attr_files_avail(xdr, bitmap, &fsstat->afiles)) != 0)
2706 if ((status = decode_attr_files_free(xdr, bitmap, &fsstat->ffiles)) != 0)
2708 if ((status = decode_attr_files_total(xdr, bitmap, &fsstat->tfiles)) != 0)
2710 if ((status = decode_attr_space_avail(xdr, bitmap, &fsstat->abytes)) != 0)
2712 if ((status = decode_attr_space_free(xdr, bitmap, &fsstat->fbytes)) != 0)
2714 if ((status = decode_attr_space_total(xdr, bitmap, &fsstat->tbytes)) != 0)
2717 status = verify_attr_len(xdr, savep, attrlen);
2720 printk(KERN_NOTICE "%s: xdr error %d!\n", __FUNCTION__, -status);
2724 static int decode_pathconf(struct xdr_stream *xdr, struct nfs_pathconf *pathconf)
2731 if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0)
2733 if ((status = decode_attr_bitmap(xdr, bitmap)) != 0)
2735 if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0)
2738 if ((status = decode_attr_maxlink(xdr, bitmap, &pathconf->max_link)) != 0)
2740 if ((status = decode_attr_maxname(xdr, bitmap, &pathconf->max_namelen)) != 0)
2743 status = verify_attr_len(xdr, savep, attrlen);
2746 printk(KERN_NOTICE "%s: xdr error %d!\n", __FUNCTION__, -status);
2750 static int decode_getfattr(struct xdr_stream *xdr, struct nfs_fattr *fattr, const struct nfs_server *server)
2756 int status, fmode = 0;
2758 if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0)
2760 if ((status = decode_attr_bitmap(xdr, bitmap)) != 0)
2763 fattr->bitmap[0] = bitmap[0];
2764 fattr->bitmap[1] = bitmap[1];
2766 if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0)
2770 if ((status = decode_attr_type(xdr, bitmap, &type)) != 0)
2772 fattr->type = nfs_type2fmt[type].nfs2type;
2773 fmode = nfs_type2fmt[type].mode;
2775 if ((status = decode_attr_change(xdr, bitmap, &fattr->change_attr)) != 0)
2777 if ((status = decode_attr_size(xdr, bitmap, &fattr->size)) != 0)
2779 if ((status = decode_attr_fsid(xdr, bitmap, &fattr->fsid_u.nfs4)) != 0)
2781 if ((status = decode_attr_fileid(xdr, bitmap, &fattr->fileid)) != 0)
2783 if ((status = decode_attr_mode(xdr, bitmap, &fattr->mode)) != 0)
2785 fattr->mode |= fmode;
2786 if ((status = decode_attr_nlink(xdr, bitmap, &fattr->nlink)) != 0)
2788 if ((status = decode_attr_owner(xdr, bitmap, server->nfs4_state, &fattr->uid)) != 0)
2790 if ((status = decode_attr_group(xdr, bitmap, server->nfs4_state, &fattr->gid)) != 0)
2792 if ((status = decode_attr_rdev(xdr, bitmap, &fattr->rdev)) != 0)
2794 if ((status = decode_attr_space_used(xdr, bitmap, &fattr->du.nfs3.used)) != 0)
2796 if ((status = decode_attr_time_access(xdr, bitmap, &fattr->atime)) != 0)
2798 if ((status = decode_attr_time_metadata(xdr, bitmap, &fattr->ctime)) != 0)
2800 if ((status = decode_attr_time_modify(xdr, bitmap, &fattr->mtime)) != 0)
2802 if ((status = verify_attr_len(xdr, savep, attrlen)) == 0)
2803 fattr->valid = NFS_ATTR_FATTR | NFS_ATTR_FATTR_V3 | NFS_ATTR_FATTR_V4;
2806 printk(KERN_NOTICE "%s: xdr error %d!\n", __FUNCTION__, -status);
2811 static int decode_fsinfo(struct xdr_stream *xdr, struct nfs_fsinfo *fsinfo)
2814 uint32_t attrlen, bitmap[2];
2817 if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0)
2819 if ((status = decode_attr_bitmap(xdr, bitmap)) != 0)
2821 if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0)
2824 fsinfo->rtmult = fsinfo->wtmult = 512; /* ??? */
2826 if ((status = decode_attr_lease_time(xdr, bitmap, &fsinfo->lease_time)) != 0)
2828 if ((status = decode_attr_maxfilesize(xdr, bitmap, &fsinfo->maxfilesize)) != 0)
2830 if ((status = decode_attr_maxread(xdr, bitmap, &fsinfo->rtmax)) != 0)
2832 fsinfo->rtpref = fsinfo->dtpref = fsinfo->rtmax;
2833 if ((status = decode_attr_maxwrite(xdr, bitmap, &fsinfo->wtmax)) != 0)
2835 fsinfo->wtpref = fsinfo->wtmax;
2837 status = verify_attr_len(xdr, savep, attrlen);
2840 printk(KERN_NOTICE "%s: xdr error %d!\n", __FUNCTION__, -status);
2844 static int decode_getfh(struct xdr_stream *xdr, struct nfs_fh *fh)
2850 status = decode_op_hdr(xdr, OP_GETFH);
2853 /* Zero handle first to allow comparisons */
2854 memset(fh, 0, sizeof(*fh));
2858 if (len > NFS4_FHSIZE)
2862 COPYMEM(fh->data, len);
2866 static int decode_link(struct xdr_stream *xdr, struct nfs4_change_info *cinfo)
2870 status = decode_op_hdr(xdr, OP_LINK);
2873 return decode_change_info(xdr, cinfo);
2877 * We create the owner, so we know a proper owner.id length is 4.
2879 static int decode_lock_denied (struct xdr_stream *xdr, struct nfs_lock_denied *denied)
2885 READ64(denied->offset);
2886 READ64(denied->length);
2887 READ32(denied->type);
2888 READ64(denied->owner.clientid);
2892 READ32(denied->owner.id);
2893 return -NFS4ERR_DENIED;
2896 static int decode_lock(struct xdr_stream *xdr, struct nfs_lockres *res)
2901 status = decode_op_hdr(xdr, OP_LOCK);
2903 READ_BUF(sizeof(res->u.stateid.data));
2904 COPYMEM(res->u.stateid.data, sizeof(res->u.stateid.data));
2905 } else if (status == -NFS4ERR_DENIED)
2906 return decode_lock_denied(xdr, &res->u.denied);
2910 static int decode_lockt(struct xdr_stream *xdr, struct nfs_lockres *res)
2913 status = decode_op_hdr(xdr, OP_LOCKT);
2914 if (status == -NFS4ERR_DENIED)
2915 return decode_lock_denied(xdr, &res->u.denied);
2919 static int decode_locku(struct xdr_stream *xdr, struct nfs_lockres *res)
2924 status = decode_op_hdr(xdr, OP_LOCKU);
2926 READ_BUF(sizeof(res->u.stateid.data));
2927 COPYMEM(res->u.stateid.data, sizeof(res->u.stateid.data));
2932 static int decode_lookup(struct xdr_stream *xdr)
2934 return decode_op_hdr(xdr, OP_LOOKUP);
2937 /* This is too sick! */
2938 static int decode_space_limit(struct xdr_stream *xdr, u64 *maxsize)
2941 uint32_t limit_type, nblocks, blocksize;
2945 switch (limit_type) {
2952 *maxsize = (uint64_t)nblocks * (uint64_t)blocksize;
2957 static int decode_delegation(struct xdr_stream *xdr, struct nfs_openres *res)
2960 uint32_t delegation_type;
2963 READ32(delegation_type);
2964 if (delegation_type == NFS4_OPEN_DELEGATE_NONE) {
2965 res->delegation_type = 0;
2969 COPYMEM(res->delegation.data, sizeof(res->delegation.data));
2970 READ32(res->do_recall);
2971 switch (delegation_type) {
2972 case NFS4_OPEN_DELEGATE_READ:
2973 res->delegation_type = FMODE_READ;
2975 case NFS4_OPEN_DELEGATE_WRITE:
2976 res->delegation_type = FMODE_WRITE|FMODE_READ;
2977 if (decode_space_limit(xdr, &res->maxsize) < 0)
2980 return decode_ace(xdr, NULL, res->server->nfs4_state);
2983 static int decode_open(struct xdr_stream *xdr, struct nfs_openres *res)
2989 status = decode_op_hdr(xdr, OP_OPEN);
2992 READ_BUF(sizeof(res->stateid.data));
2993 COPYMEM(res->stateid.data, sizeof(res->stateid.data));
2995 decode_change_info(xdr, &res->cinfo);
2998 READ32(res->rflags);
3003 READ_BUF(bmlen << 2);
3005 return decode_delegation(xdr, res);
3007 printk(KERN_NOTICE "%s: xdr error!\n", __FUNCTION__);
3011 static int decode_open_confirm(struct xdr_stream *xdr, struct nfs_open_confirmres *res)
3016 status = decode_op_hdr(xdr, OP_OPEN_CONFIRM);
3019 READ_BUF(sizeof(res->stateid.data));
3020 COPYMEM(res->stateid.data, sizeof(res->stateid.data));
3024 static int decode_open_downgrade(struct xdr_stream *xdr, struct nfs_closeres *res)
3029 status = decode_op_hdr(xdr, OP_OPEN_DOWNGRADE);
3032 READ_BUF(sizeof(res->stateid.data));
3033 COPYMEM(res->stateid.data, sizeof(res->stateid.data));
3037 static int decode_putfh(struct xdr_stream *xdr)
3039 return decode_op_hdr(xdr, OP_PUTFH);
3042 static int decode_putrootfh(struct xdr_stream *xdr)
3044 return decode_op_hdr(xdr, OP_PUTROOTFH);
3047 static int decode_read(struct xdr_stream *xdr, struct rpc_rqst *req, struct nfs_readres *res)
3049 struct kvec *iov = req->rq_rcv_buf.head;
3051 uint32_t count, eof, recvd, hdrlen;
3054 status = decode_op_hdr(xdr, OP_READ);
3060 hdrlen = (u8 *) p - (u8 *) iov->iov_base;
3061 recvd = req->rq_rcv_buf.len - hdrlen;
3062 if (count > recvd) {
3063 printk(KERN_WARNING "NFS: server cheating in read reply: "
3064 "count %u > recvd %u\n", count, recvd);
3068 xdr_read_pages(xdr, count);
3074 static int decode_readdir(struct xdr_stream *xdr, struct rpc_rqst *req, struct nfs4_readdir_res *readdir)
3076 struct xdr_buf *rcvbuf = &req->rq_rcv_buf;
3077 struct page *page = *rcvbuf->pages;
3078 struct kvec *iov = rcvbuf->head;
3079 unsigned int nr, pglen = rcvbuf->page_len;
3080 uint32_t *end, *entry, *p, *kaddr;
3081 uint32_t len, attrlen;
3082 int hdrlen, recvd, status;
3084 status = decode_op_hdr(xdr, OP_READDIR);
3088 COPYMEM(readdir->verifier.data, 8);
3089 dprintk("%s: verifier = 0x%x%x\n",
3091 ((u32 *)readdir->verifier.data)[0],
3092 ((u32 *)readdir->verifier.data)[1]);
3095 hdrlen = (char *) p - (char *) iov->iov_base;
3096 recvd = rcvbuf->len - hdrlen;
3099 xdr_read_pages(xdr, pglen);
3101 BUG_ON(pglen + readdir->pgbase > PAGE_CACHE_SIZE);
3102 kaddr = p = (uint32_t *) kmap_atomic(page, KM_USER0);
3103 end = (uint32_t *) ((char *)p + pglen + readdir->pgbase);
3105 for (nr = 0; *p++; nr++) {
3108 dprintk("cookie = %Lu, ", *((unsigned long long *)p));
3109 p += 2; /* cookie */
3110 len = ntohl(*p++); /* filename length */
3111 if (len > NFS4_MAXNAMLEN) {
3112 printk(KERN_WARNING "NFS: giant filename in readdir (len 0x%x)\n", len);
3115 dprintk("filename = %*s\n", len, (char *)p);
3116 p += XDR_QUADLEN(len);
3119 len = ntohl(*p++); /* bitmap length */
3123 attrlen = XDR_QUADLEN(ntohl(*p++));
3124 p += attrlen; /* attributes */
3129 if (!nr && (entry[0] != 0 || entry[1] == 0))
3132 kunmap_atomic(kaddr, KM_USER0);
3135 dprintk("%s: short packet at entry %d\n", __FUNCTION__, nr);
3136 entry[0] = entry[1] = 0;
3137 /* truncate listing ? */
3139 printk(KERN_NOTICE "NFS: readdir reply truncated!\n");
3144 kunmap_atomic(kaddr, KM_USER0);
3145 return -errno_NFSERR_IO;
3148 static int decode_readlink(struct xdr_stream *xdr, struct rpc_rqst *req)
3150 struct xdr_buf *rcvbuf = &req->rq_rcv_buf;
3151 struct kvec *iov = rcvbuf->head;
3152 int hdrlen, len, recvd;
3157 status = decode_op_hdr(xdr, OP_READLINK);
3161 /* Convert length of symlink */
3164 if (len >= rcvbuf->page_len || len <= 0) {
3165 dprintk(KERN_WARNING "nfs: server returned giant symlink!\n");
3166 return -ENAMETOOLONG;
3168 hdrlen = (char *) xdr->p - (char *) iov->iov_base;
3169 recvd = req->rq_rcv_buf.len - hdrlen;
3171 printk(KERN_WARNING "NFS: server cheating in readlink reply: "
3172 "count %u > recvd %u\n", len, recvd);
3175 xdr_read_pages(xdr, len);
3177 * The XDR encode routine has set things up so that
3178 * the link text will be copied directly into the
3179 * buffer. We just have to do overflow-checking,
3180 * and and null-terminate the text (the VFS expects
3181 * null-termination).
3183 kaddr = (char *)kmap_atomic(rcvbuf->pages[0], KM_USER0);
3184 kaddr[len+rcvbuf->page_base] = '\0';
3185 kunmap_atomic(kaddr, KM_USER0);
3189 static int decode_remove(struct xdr_stream *xdr, struct nfs4_change_info *cinfo)
3193 status = decode_op_hdr(xdr, OP_REMOVE);
3196 status = decode_change_info(xdr, cinfo);
3201 static int decode_rename(struct xdr_stream *xdr, struct nfs4_change_info *old_cinfo,
3202 struct nfs4_change_info *new_cinfo)
3206 status = decode_op_hdr(xdr, OP_RENAME);
3209 if ((status = decode_change_info(xdr, old_cinfo)))
3211 status = decode_change_info(xdr, new_cinfo);
3216 static int decode_renew(struct xdr_stream *xdr)
3218 return decode_op_hdr(xdr, OP_RENEW);
3221 static int decode_getacl(struct xdr_stream *xdr, struct rpc_rqst *req,
3227 struct kvec *iov = req->rq_rcv_buf.head;
3231 if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0)
3233 if ((status = decode_attr_bitmap(xdr, bitmap)) != 0)
3235 if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0)
3238 if (unlikely(bitmap[0] & (FATTR4_WORD0_ACL - 1U)))
3240 if (likely(bitmap[0] & FATTR4_WORD0_ACL)) {
3243 /* We ignore &savep and don't do consistency checks on
3244 * the attr length. Let userspace figure it out.... */
3245 hdrlen = (u8 *)xdr->p - (u8 *)iov->iov_base;
3246 recvd = req->rq_rcv_buf.len - hdrlen;
3247 if (attrlen > recvd) {
3248 printk(KERN_WARNING "NFS: server cheating in getattr"
3249 " acl reply: attrlen %u > recvd %u\n",
3253 if (attrlen <= *acl_len)
3254 xdr_read_pages(xdr, attrlen);
3257 status = -EOPNOTSUPP;
3264 decode_savefh(struct xdr_stream *xdr)
3266 return decode_op_hdr(xdr, OP_SAVEFH);
3269 static int decode_setattr(struct xdr_stream *xdr, struct nfs_setattrres *res)
3276 status = decode_op_hdr(xdr, OP_SETATTR);
3281 READ_BUF(bmlen << 2);
3285 static int decode_setclientid(struct xdr_stream *xdr, struct nfs4_client *clp)
3293 if (opnum != OP_SETCLIENTID) {
3295 "nfs4_decode_setclientid: Server returned operation"
3300 if (nfserr == NFS_OK) {
3301 READ_BUF(8 + sizeof(clp->cl_confirm.data));
3302 READ64(clp->cl_clientid);
3303 COPYMEM(clp->cl_confirm.data, sizeof(clp->cl_confirm.data));
3304 } else if (nfserr == NFSERR_CLID_INUSE) {
3307 /* skip netid string */
3312 /* skip uaddr string */
3316 return -NFSERR_CLID_INUSE;
3318 return -nfs_stat_to_errno(nfserr);
3323 static int decode_setclientid_confirm(struct xdr_stream *xdr)
3325 return decode_op_hdr(xdr, OP_SETCLIENTID_CONFIRM);
3328 static int decode_write(struct xdr_stream *xdr, struct nfs_writeres *res)
3333 status = decode_op_hdr(xdr, OP_WRITE);
3339 READ32(res->verf->committed);
3340 COPYMEM(res->verf->verifier, 8);
3344 static int decode_delegreturn(struct xdr_stream *xdr)
3346 return decode_op_hdr(xdr, OP_DELEGRETURN);
3350 * Decode OPEN_DOWNGRADE response
3352 static int nfs4_xdr_dec_open_downgrade(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_closeres *res)
3354 struct xdr_stream xdr;
3355 struct compound_hdr hdr;
3358 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
3359 status = decode_compound_hdr(&xdr, &hdr);
3362 status = decode_putfh(&xdr);
3365 status = decode_open_downgrade(&xdr, res);
3371 * END OF "GENERIC" DECODE ROUTINES.
3375 * Decode ACCESS response
3377 static int nfs4_xdr_dec_access(struct rpc_rqst *rqstp, uint32_t *p, struct nfs4_accessres *res)
3379 struct xdr_stream xdr;
3380 struct compound_hdr hdr;
3383 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
3384 if ((status = decode_compound_hdr(&xdr, &hdr)) != 0)
3386 if ((status = decode_putfh(&xdr)) == 0)
3387 status = decode_access(&xdr, res);
3393 * Decode LOOKUP response
3395 static int nfs4_xdr_dec_lookup(struct rpc_rqst *rqstp, uint32_t *p, struct nfs4_lookup_res *res)
3397 struct xdr_stream xdr;
3398 struct compound_hdr hdr;
3401 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
3402 if ((status = decode_compound_hdr(&xdr, &hdr)) != 0)
3404 if ((status = decode_putfh(&xdr)) != 0)
3406 if ((status = decode_lookup(&xdr)) != 0)
3408 if ((status = decode_getfh(&xdr, res->fh)) != 0)
3410 status = decode_getfattr(&xdr, res->fattr, res->server);
3416 * Decode LOOKUP_ROOT response
3418 static int nfs4_xdr_dec_lookup_root(struct rpc_rqst *rqstp, uint32_t *p, struct nfs4_lookup_res *res)
3420 struct xdr_stream xdr;
3421 struct compound_hdr hdr;
3424 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
3425 if ((status = decode_compound_hdr(&xdr, &hdr)) != 0)
3427 if ((status = decode_putrootfh(&xdr)) != 0)
3429 if ((status = decode_getfh(&xdr, res->fh)) == 0)
3430 status = decode_getfattr(&xdr, res->fattr, res->server);
3436 * Decode REMOVE response
3438 static int nfs4_xdr_dec_remove(struct rpc_rqst *rqstp, uint32_t *p, struct nfs4_change_info *cinfo)
3440 struct xdr_stream xdr;
3441 struct compound_hdr hdr;
3444 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
3445 if ((status = decode_compound_hdr(&xdr, &hdr)) != 0)
3447 if ((status = decode_putfh(&xdr)) == 0)
3448 status = decode_remove(&xdr, cinfo);
3454 * Decode RENAME response
3456 static int nfs4_xdr_dec_rename(struct rpc_rqst *rqstp, uint32_t *p, struct nfs4_rename_res *res)
3458 struct xdr_stream xdr;
3459 struct compound_hdr hdr;
3462 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
3463 if ((status = decode_compound_hdr(&xdr, &hdr)) != 0)
3465 if ((status = decode_putfh(&xdr)) != 0)
3467 if ((status = decode_savefh(&xdr)) != 0)
3469 if ((status = decode_putfh(&xdr)) != 0)
3471 status = decode_rename(&xdr, &res->old_cinfo, &res->new_cinfo);
3477 * Decode LINK response
3479 static int nfs4_xdr_dec_link(struct rpc_rqst *rqstp, uint32_t *p, struct nfs4_change_info *cinfo)
3481 struct xdr_stream xdr;
3482 struct compound_hdr hdr;
3485 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
3486 if ((status = decode_compound_hdr(&xdr, &hdr)) != 0)
3488 if ((status = decode_putfh(&xdr)) != 0)
3490 if ((status = decode_savefh(&xdr)) != 0)
3492 if ((status = decode_putfh(&xdr)) != 0)
3494 status = decode_link(&xdr, cinfo);
3500 * Decode CREATE response
3502 static int nfs4_xdr_dec_create(struct rpc_rqst *rqstp, uint32_t *p, struct nfs4_create_res *res)
3504 struct xdr_stream xdr;
3505 struct compound_hdr hdr;
3508 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
3509 if ((status = decode_compound_hdr(&xdr, &hdr)) != 0)
3511 if ((status = decode_putfh(&xdr)) != 0)
3513 if ((status = decode_create(&xdr,&res->dir_cinfo)) != 0)
3515 if ((status = decode_getfh(&xdr, res->fh)) != 0)
3517 status = decode_getfattr(&xdr, res->fattr, res->server);
3518 if (status == NFS4ERR_DELAY)
3525 * Decode SYMLINK response
3527 static int nfs4_xdr_dec_symlink(struct rpc_rqst *rqstp, uint32_t *p, struct nfs4_create_res *res)
3529 return nfs4_xdr_dec_create(rqstp, p, res);
3533 * Decode GETATTR response
3535 static int nfs4_xdr_dec_getattr(struct rpc_rqst *rqstp, uint32_t *p, struct nfs4_getattr_res *res)
3537 struct xdr_stream xdr;
3538 struct compound_hdr hdr;
3541 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
3542 status = decode_compound_hdr(&xdr, &hdr);
3545 status = decode_putfh(&xdr);
3548 status = decode_getfattr(&xdr, res->fattr, res->server);
3555 * Encode an SETACL request
3558 nfs4_xdr_enc_setacl(struct rpc_rqst *req, uint32_t *p, struct nfs_setaclargs *args)
3560 struct xdr_stream xdr;
3561 struct compound_hdr hdr = {
3566 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
3567 encode_compound_hdr(&xdr, &hdr);
3568 status = encode_putfh(&xdr, args->fh);
3571 status = encode_setacl(&xdr, args);
3576 * Decode SETACL response
3579 nfs4_xdr_dec_setacl(struct rpc_rqst *rqstp, uint32_t *p, void *res)
3581 struct xdr_stream xdr;
3582 struct compound_hdr hdr;
3585 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
3586 status = decode_compound_hdr(&xdr, &hdr);
3589 status = decode_putfh(&xdr);
3592 status = decode_setattr(&xdr, res);
3598 * Decode GETACL response
3601 nfs4_xdr_dec_getacl(struct rpc_rqst *rqstp, uint32_t *p, size_t *acl_len)
3603 struct xdr_stream xdr;
3604 struct compound_hdr hdr;
3607 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
3608 status = decode_compound_hdr(&xdr, &hdr);
3611 status = decode_putfh(&xdr);
3614 status = decode_getacl(&xdr, rqstp, acl_len);
3621 * Decode CLOSE response
3623 static int nfs4_xdr_dec_close(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_closeres *res)
3625 struct xdr_stream xdr;
3626 struct compound_hdr hdr;
3629 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
3630 status = decode_compound_hdr(&xdr, &hdr);
3633 status = decode_putfh(&xdr);
3636 status = decode_close(&xdr, res);
3642 * Decode OPEN response
3644 static int nfs4_xdr_dec_open(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_openres *res)
3646 struct xdr_stream xdr;
3647 struct compound_hdr hdr;
3650 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
3651 status = decode_compound_hdr(&xdr, &hdr);
3654 status = decode_putfh(&xdr);
3657 status = decode_open(&xdr, res);
3660 status = decode_getfh(&xdr, &res->fh);
3663 status = decode_getfattr(&xdr, res->f_attr, res->server);
3664 if (status == NFS4ERR_DELAY)
3671 * Decode OPEN_CONFIRM response
3673 static int nfs4_xdr_dec_open_confirm(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_open_confirmres *res)
3675 struct xdr_stream xdr;
3676 struct compound_hdr hdr;
3679 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
3680 status = decode_compound_hdr(&xdr, &hdr);
3683 status = decode_putfh(&xdr);
3686 status = decode_open_confirm(&xdr, res);
3692 * Decode OPEN response
3694 static int nfs4_xdr_dec_open_noattr(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_openres *res)
3696 struct xdr_stream xdr;
3697 struct compound_hdr hdr;
3700 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
3701 status = decode_compound_hdr(&xdr, &hdr);
3704 status = decode_putfh(&xdr);
3707 status = decode_open(&xdr, res);
3713 * Decode SETATTR response
3715 static int nfs4_xdr_dec_setattr(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_setattrres *res)
3717 struct xdr_stream xdr;
3718 struct compound_hdr hdr;
3721 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
3722 status = decode_compound_hdr(&xdr, &hdr);
3725 status = decode_putfh(&xdr);
3728 status = decode_setattr(&xdr, res);
3731 status = decode_getfattr(&xdr, res->fattr, res->server);
3732 if (status == NFS4ERR_DELAY)
3739 * Decode LOCK response
3741 static int nfs4_xdr_dec_lock(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_lockres *res)
3743 struct xdr_stream xdr;
3744 struct compound_hdr hdr;
3747 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
3748 status = decode_compound_hdr(&xdr, &hdr);
3751 status = decode_putfh(&xdr);
3754 status = decode_lock(&xdr, res);
3760 * Decode LOCKT response
3762 static int nfs4_xdr_dec_lockt(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_lockres *res)
3764 struct xdr_stream xdr;
3765 struct compound_hdr hdr;
3768 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
3769 status = decode_compound_hdr(&xdr, &hdr);
3772 status = decode_putfh(&xdr);
3775 status = decode_lockt(&xdr, res);
3781 * Decode LOCKU response
3783 static int nfs4_xdr_dec_locku(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_lockres *res)
3785 struct xdr_stream xdr;
3786 struct compound_hdr hdr;
3789 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
3790 status = decode_compound_hdr(&xdr, &hdr);
3793 status = decode_putfh(&xdr);
3796 status = decode_locku(&xdr, res);
3802 * Decode READLINK response
3804 static int nfs4_xdr_dec_readlink(struct rpc_rqst *rqstp, uint32_t *p, void *res)
3806 struct xdr_stream xdr;
3807 struct compound_hdr hdr;
3810 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
3811 status = decode_compound_hdr(&xdr, &hdr);
3814 status = decode_putfh(&xdr);
3817 status = decode_readlink(&xdr, rqstp);
3823 * Decode READDIR response
3825 static int nfs4_xdr_dec_readdir(struct rpc_rqst *rqstp, uint32_t *p, struct nfs4_readdir_res *res)
3827 struct xdr_stream xdr;
3828 struct compound_hdr hdr;
3831 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
3832 status = decode_compound_hdr(&xdr, &hdr);
3835 status = decode_putfh(&xdr);
3838 status = decode_readdir(&xdr, rqstp, res);
3844 * Decode Read response
3846 static int nfs4_xdr_dec_read(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_readres *res)
3848 struct xdr_stream xdr;
3849 struct compound_hdr hdr;
3852 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
3853 status = decode_compound_hdr(&xdr, &hdr);
3856 status = decode_putfh(&xdr);
3859 status = decode_read(&xdr, rqstp, res);
3861 status = res->count;
3867 * Decode WRITE response
3869 static int nfs4_xdr_dec_write(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_writeres *res)
3871 struct xdr_stream xdr;
3872 struct compound_hdr hdr;
3875 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
3876 status = decode_compound_hdr(&xdr, &hdr);
3879 status = decode_putfh(&xdr);
3882 status = decode_write(&xdr, res);
3884 status = res->count;
3890 * Decode COMMIT response
3892 static int nfs4_xdr_dec_commit(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_writeres *res)
3894 struct xdr_stream xdr;
3895 struct compound_hdr hdr;
3898 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
3899 status = decode_compound_hdr(&xdr, &hdr);
3902 status = decode_putfh(&xdr);
3905 status = decode_commit(&xdr, res);
3913 static int nfs4_xdr_dec_fsinfo(struct rpc_rqst *req, uint32_t *p, struct nfs_fsinfo *fsinfo)
3915 struct xdr_stream xdr;
3916 struct compound_hdr hdr;
3919 xdr_init_decode(&xdr, &req->rq_rcv_buf, p);
3920 status = decode_compound_hdr(&xdr, &hdr);
3922 status = decode_putfh(&xdr);
3924 status = decode_fsinfo(&xdr, fsinfo);
3926 status = -nfs_stat_to_errno(hdr.status);
3933 static int nfs4_xdr_dec_pathconf(struct rpc_rqst *req, uint32_t *p, struct nfs_pathconf *pathconf)
3935 struct xdr_stream xdr;
3936 struct compound_hdr hdr;
3939 xdr_init_decode(&xdr, &req->rq_rcv_buf, p);
3940 status = decode_compound_hdr(&xdr, &hdr);
3942 status = decode_putfh(&xdr);
3944 status = decode_pathconf(&xdr, pathconf);
3951 static int nfs4_xdr_dec_statfs(struct rpc_rqst *req, uint32_t *p, struct nfs_fsstat *fsstat)
3953 struct xdr_stream xdr;
3954 struct compound_hdr hdr;
3957 xdr_init_decode(&xdr, &req->rq_rcv_buf, p);
3958 status = decode_compound_hdr(&xdr, &hdr);
3960 status = decode_putfh(&xdr);
3962 status = decode_statfs(&xdr, fsstat);
3967 * GETATTR_BITMAP request
3969 static int nfs4_xdr_dec_server_caps(struct rpc_rqst *req, uint32_t *p, struct nfs4_server_caps_res *res)
3971 struct xdr_stream xdr;
3972 struct compound_hdr hdr;
3975 xdr_init_decode(&xdr, &req->rq_rcv_buf, p);
3976 if ((status = decode_compound_hdr(&xdr, &hdr)) != 0)
3978 if ((status = decode_putfh(&xdr)) != 0)
3980 status = decode_server_caps(&xdr, res);
3986 * Decode RENEW response
3988 static int nfs4_xdr_dec_renew(struct rpc_rqst *rqstp, uint32_t *p, void *dummy)
3990 struct xdr_stream xdr;
3991 struct compound_hdr hdr;
3994 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
3995 status = decode_compound_hdr(&xdr, &hdr);
3997 status = decode_renew(&xdr);
4002 * a SETCLIENTID request
4004 static int nfs4_xdr_dec_setclientid(struct rpc_rqst *req, uint32_t *p,
4005 struct nfs4_client *clp)
4007 struct xdr_stream xdr;
4008 struct compound_hdr hdr;
4011 xdr_init_decode(&xdr, &req->rq_rcv_buf, p);
4012 status = decode_compound_hdr(&xdr, &hdr);
4014 status = decode_setclientid(&xdr, clp);
4016 status = -nfs_stat_to_errno(hdr.status);
4021 * a SETCLIENTID_CONFIRM request
4023 static int nfs4_xdr_dec_setclientid_confirm(struct rpc_rqst *req, uint32_t *p, struct nfs_fsinfo *fsinfo)
4025 struct xdr_stream xdr;
4026 struct compound_hdr hdr;
4029 xdr_init_decode(&xdr, &req->rq_rcv_buf, p);
4030 status = decode_compound_hdr(&xdr, &hdr);
4032 status = decode_setclientid_confirm(&xdr);
4034 status = decode_putrootfh(&xdr);
4036 status = decode_fsinfo(&xdr, fsinfo);
4038 status = -nfs_stat_to_errno(hdr.status);
4043 * DELEGRETURN request
4045 static int nfs4_xdr_dec_delegreturn(struct rpc_rqst *rqstp, uint32_t *p, void *dummy)
4047 struct xdr_stream xdr;
4048 struct compound_hdr hdr;
4051 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
4052 status = decode_compound_hdr(&xdr, &hdr);
4054 status = decode_putfh(&xdr);
4056 status = decode_delegreturn(&xdr);
4061 uint32_t *nfs4_decode_dirent(uint32_t *p, struct nfs_entry *entry, int plus)
4063 uint32_t bitmap[2] = {0};
4068 return ERR_PTR(-EAGAIN);
4070 return ERR_PTR(-EBADCOOKIE);
4073 entry->prev_cookie = entry->cookie;
4074 p = xdr_decode_hyper(p, &entry->cookie);
4075 entry->len = ntohl(*p++);
4076 entry->name = (const char *) p;
4077 p += XDR_QUADLEN(entry->len);
4080 * In case the server doesn't return an inode number,
4081 * we fake one here. (We don't use inode number 0,
4082 * since glibc seems to choke on it...)
4086 len = ntohl(*p++); /* bitmap length */
4088 bitmap[0] = ntohl(*p++);
4090 bitmap[1] = ntohl(*p++);
4094 len = XDR_QUADLEN(ntohl(*p++)); /* attribute buffer length */
4096 if (bitmap[0] & FATTR4_WORD0_RDATTR_ERROR) {
4097 bitmap[0] &= ~FATTR4_WORD0_RDATTR_ERROR;
4098 /* Ignore the return value of rdattr_error for now */
4102 if (bitmap[0] == 0 && bitmap[1] == FATTR4_WORD1_MOUNTED_ON_FILEID)
4103 xdr_decode_hyper(p, &entry->ino);
4104 else if (bitmap[0] == FATTR4_WORD0_FILEID)
4105 xdr_decode_hyper(p, &entry->ino);
4109 entry->eof = !p[0] && p[1];
4114 * We need to translate between nfs status return values and
4115 * the local errno values which may not be the same.
4122 { NFS4ERR_PERM, EPERM },
4123 { NFS4ERR_NOENT, ENOENT },
4124 { NFS4ERR_IO, errno_NFSERR_IO },
4125 { NFS4ERR_NXIO, ENXIO },
4126 { NFS4ERR_ACCESS, EACCES },
4127 { NFS4ERR_EXIST, EEXIST },
4128 { NFS4ERR_XDEV, EXDEV },
4129 { NFS4ERR_NOTDIR, ENOTDIR },
4130 { NFS4ERR_ISDIR, EISDIR },
4131 { NFS4ERR_INVAL, EINVAL },
4132 { NFS4ERR_FBIG, EFBIG },
4133 { NFS4ERR_NOSPC, ENOSPC },
4134 { NFS4ERR_ROFS, EROFS },
4135 { NFS4ERR_MLINK, EMLINK },
4136 { NFS4ERR_NAMETOOLONG, ENAMETOOLONG },
4137 { NFS4ERR_NOTEMPTY, ENOTEMPTY },
4138 { NFS4ERR_DQUOT, EDQUOT },
4139 { NFS4ERR_STALE, ESTALE },
4140 { NFS4ERR_BADHANDLE, EBADHANDLE },
4141 { NFS4ERR_BADOWNER, EINVAL },
4142 { NFS4ERR_BADNAME, EINVAL },
4143 { NFS4ERR_BAD_COOKIE, EBADCOOKIE },
4144 { NFS4ERR_NOTSUPP, ENOTSUPP },
4145 { NFS4ERR_TOOSMALL, ETOOSMALL },
4146 { NFS4ERR_SERVERFAULT, ESERVERFAULT },
4147 { NFS4ERR_BADTYPE, EBADTYPE },
4148 { NFS4ERR_LOCKED, EAGAIN },
4149 { NFS4ERR_RESOURCE, EREMOTEIO },
4150 { NFS4ERR_SYMLINK, ELOOP },
4151 { NFS4ERR_OP_ILLEGAL, EOPNOTSUPP },
4152 { NFS4ERR_DEADLOCK, EDEADLK },
4153 { NFS4ERR_WRONGSEC, EPERM }, /* FIXME: this needs
4154 * to be handled by a
4161 * Convert an NFS error code to a local one.
4162 * This one is used jointly by NFSv2 and NFSv3.
4165 nfs_stat_to_errno(int stat)
4168 for (i = 0; nfs_errtbl[i].stat != -1; i++) {
4169 if (nfs_errtbl[i].stat == stat)
4170 return nfs_errtbl[i].errno;
4172 if (stat <= 10000 || stat > 10100) {
4173 /* The server is looney tunes. */
4174 return ESERVERFAULT;
4176 /* If we cannot translate the error, the recovery routines should
4178 * Note: remaining NFSv4 error codes have values > 10000, so should
4179 * not conflict with native Linux error codes.
4185 # define MAX(a, b) (((a) > (b))? (a) : (b))
4188 #define PROC(proc, argtype, restype) \
4189 [NFSPROC4_CLNT_##proc] = { \
4190 .p_proc = NFSPROC4_COMPOUND, \
4191 .p_encode = (kxdrproc_t) nfs4_xdr_##argtype, \
4192 .p_decode = (kxdrproc_t) nfs4_xdr_##restype, \
4193 .p_bufsiz = MAX(NFS4_##argtype##_sz,NFS4_##restype##_sz) << 2, \
4196 struct rpc_procinfo nfs4_procedures[] = {
4197 PROC(READ, enc_read, dec_read),
4198 PROC(WRITE, enc_write, dec_write),
4199 PROC(COMMIT, enc_commit, dec_commit),
4200 PROC(OPEN, enc_open, dec_open),
4201 PROC(OPEN_CONFIRM, enc_open_confirm, dec_open_confirm),
4202 PROC(OPEN_NOATTR, enc_open_noattr, dec_open_noattr),
4203 PROC(OPEN_DOWNGRADE, enc_open_downgrade, dec_open_downgrade),
4204 PROC(CLOSE, enc_close, dec_close),
4205 PROC(SETATTR, enc_setattr, dec_setattr),
4206 PROC(FSINFO, enc_fsinfo, dec_fsinfo),
4207 PROC(RENEW, enc_renew, dec_renew),
4208 PROC(SETCLIENTID, enc_setclientid, dec_setclientid),
4209 PROC(SETCLIENTID_CONFIRM, enc_setclientid_confirm, dec_setclientid_confirm),
4210 PROC(LOCK, enc_lock, dec_lock),
4211 PROC(LOCKT, enc_lockt, dec_lockt),
4212 PROC(LOCKU, enc_locku, dec_locku),
4213 PROC(ACCESS, enc_access, dec_access),
4214 PROC(GETATTR, enc_getattr, dec_getattr),
4215 PROC(LOOKUP, enc_lookup, dec_lookup),
4216 PROC(LOOKUP_ROOT, enc_lookup_root, dec_lookup_root),
4217 PROC(REMOVE, enc_remove, dec_remove),
4218 PROC(RENAME, enc_rename, dec_rename),
4219 PROC(LINK, enc_link, dec_link),
4220 PROC(SYMLINK, enc_symlink, dec_symlink),
4221 PROC(CREATE, enc_create, dec_create),
4222 PROC(PATHCONF, enc_pathconf, dec_pathconf),
4223 PROC(STATFS, enc_statfs, dec_statfs),
4224 PROC(READLINK, enc_readlink, dec_readlink),
4225 PROC(READDIR, enc_readdir, dec_readdir),
4226 PROC(SERVER_CAPS, enc_server_caps, dec_server_caps),
4227 PROC(DELEGRETURN, enc_delegreturn, dec_delegreturn),
4228 PROC(GETACL, enc_getacl, dec_getacl),
4229 PROC(SETACL, enc_setacl, dec_setacl),
4232 struct rpc_version nfs_version4 = {
4234 .nrprocs = sizeof(nfs4_procedures)/sizeof(nfs4_procedures[0]),
4235 .procs = nfs4_procedures