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 nfs4_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 2 (u64) out of (NFS4_OPAQUE_LIMIT >> 2)
73 #define open_owner_id_maxsz (1 + 4)
74 #define lock_owner_id_maxsz (1 + 4)
75 #define decode_lockowner_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ))
76 #define compound_encode_hdr_maxsz (3 + (NFS4_MAXTAGLEN >> 2))
77 #define compound_decode_hdr_maxsz (3 + (NFS4_MAXTAGLEN >> 2))
78 #define op_encode_hdr_maxsz (1)
79 #define op_decode_hdr_maxsz (2)
80 #define encode_stateid_maxsz (XDR_QUADLEN(NFS4_STATEID_SIZE))
81 #define decode_stateid_maxsz (XDR_QUADLEN(NFS4_STATEID_SIZE))
82 #define encode_verifier_maxsz (XDR_QUADLEN(NFS4_VERIFIER_SIZE))
83 #define decode_verifier_maxsz (XDR_QUADLEN(NFS4_VERIFIER_SIZE))
84 #define encode_putfh_maxsz (op_encode_hdr_maxsz + 1 + \
86 #define decode_putfh_maxsz (op_decode_hdr_maxsz)
87 #define encode_putrootfh_maxsz (op_encode_hdr_maxsz)
88 #define decode_putrootfh_maxsz (op_decode_hdr_maxsz)
89 #define encode_getfh_maxsz (op_encode_hdr_maxsz)
90 #define decode_getfh_maxsz (op_decode_hdr_maxsz + 1 + \
91 ((3+NFS4_FHSIZE) >> 2))
92 #define nfs4_fattr_bitmap_maxsz 3
93 #define encode_getattr_maxsz (op_encode_hdr_maxsz + nfs4_fattr_bitmap_maxsz)
94 #define nfs4_name_maxsz (1 + ((3 + NFS4_MAXNAMLEN) >> 2))
95 #define nfs4_path_maxsz (1 + ((3 + NFS4_MAXPATHLEN) >> 2))
96 #define nfs4_owner_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ))
97 #define nfs4_group_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ))
98 /* This is based on getfattr, which uses the most attributes: */
99 #define nfs4_fattr_value_maxsz (1 + (1 + 2 + 2 + 4 + 2 + 1 + 1 + 2 + 2 + \
100 3 + 3 + 3 + nfs4_owner_maxsz + nfs4_group_maxsz))
101 #define nfs4_fattr_maxsz (nfs4_fattr_bitmap_maxsz + \
102 nfs4_fattr_value_maxsz)
103 #define decode_getattr_maxsz (op_decode_hdr_maxsz + nfs4_fattr_maxsz)
104 #define encode_attrs_maxsz (nfs4_fattr_bitmap_maxsz + \
109 #define encode_savefh_maxsz (op_encode_hdr_maxsz)
110 #define decode_savefh_maxsz (op_decode_hdr_maxsz)
111 #define encode_restorefh_maxsz (op_encode_hdr_maxsz)
112 #define decode_restorefh_maxsz (op_decode_hdr_maxsz)
113 #define encode_fsinfo_maxsz (encode_getattr_maxsz)
114 #define decode_fsinfo_maxsz (op_decode_hdr_maxsz + 11)
115 #define encode_renew_maxsz (op_encode_hdr_maxsz + 3)
116 #define decode_renew_maxsz (op_decode_hdr_maxsz)
117 #define encode_setclientid_maxsz \
118 (op_encode_hdr_maxsz + \
119 XDR_QUADLEN(NFS4_VERIFIER_SIZE) + \
120 XDR_QUADLEN(NFS4_SETCLIENTID_NAMELEN) + \
122 XDR_QUADLEN(RPCBIND_MAXNETIDLEN) + \
123 XDR_QUADLEN(RPCBIND_MAXUADDRLEN) + \
125 #define decode_setclientid_maxsz \
126 (op_decode_hdr_maxsz + \
128 1024) /* large value for CLID_INUSE */
129 #define encode_setclientid_confirm_maxsz \
130 (op_encode_hdr_maxsz + \
131 3 + (NFS4_VERIFIER_SIZE >> 2))
132 #define decode_setclientid_confirm_maxsz \
133 (op_decode_hdr_maxsz)
134 #define encode_lookup_maxsz (op_encode_hdr_maxsz + nfs4_name_maxsz)
135 #define decode_lookup_maxsz (op_decode_hdr_maxsz)
136 #define encode_share_access_maxsz \
138 #define encode_createmode_maxsz (1 + encode_attrs_maxsz)
139 #define encode_opentype_maxsz (1 + encode_createmode_maxsz)
140 #define encode_claim_null_maxsz (1 + nfs4_name_maxsz)
141 #define encode_open_maxsz (op_encode_hdr_maxsz + \
142 2 + encode_share_access_maxsz + 2 + \
143 open_owner_id_maxsz + \
144 encode_opentype_maxsz + \
145 encode_claim_null_maxsz)
146 #define decode_ace_maxsz (3 + nfs4_owner_maxsz)
147 #define decode_delegation_maxsz (1 + decode_stateid_maxsz + 1 + \
149 #define decode_change_info_maxsz (5)
150 #define decode_open_maxsz (op_decode_hdr_maxsz + \
151 decode_stateid_maxsz + \
152 decode_change_info_maxsz + 1 + \
153 nfs4_fattr_bitmap_maxsz + \
154 decode_delegation_maxsz)
155 #define encode_open_confirm_maxsz \
156 (op_encode_hdr_maxsz + \
157 encode_stateid_maxsz + 1)
158 #define decode_open_confirm_maxsz \
159 (op_decode_hdr_maxsz + \
160 decode_stateid_maxsz)
161 #define encode_open_downgrade_maxsz \
162 (op_encode_hdr_maxsz + \
163 encode_stateid_maxsz + 1 + \
164 encode_share_access_maxsz)
165 #define decode_open_downgrade_maxsz \
166 (op_decode_hdr_maxsz + \
167 decode_stateid_maxsz)
168 #define encode_close_maxsz (op_encode_hdr_maxsz + \
169 1 + encode_stateid_maxsz)
170 #define decode_close_maxsz (op_decode_hdr_maxsz + \
171 decode_stateid_maxsz)
172 #define encode_setattr_maxsz (op_encode_hdr_maxsz + \
173 encode_stateid_maxsz + \
175 #define decode_setattr_maxsz (op_decode_hdr_maxsz + \
176 nfs4_fattr_bitmap_maxsz)
177 #define encode_read_maxsz (op_encode_hdr_maxsz + \
178 encode_stateid_maxsz + 3)
179 #define decode_read_maxsz (op_decode_hdr_maxsz + 2)
180 #define encode_readdir_maxsz (op_encode_hdr_maxsz + \
181 2 + encode_verifier_maxsz + 5)
182 #define decode_readdir_maxsz (op_decode_hdr_maxsz + \
183 decode_verifier_maxsz)
184 #define encode_readlink_maxsz (op_encode_hdr_maxsz)
185 #define decode_readlink_maxsz (op_decode_hdr_maxsz + 1)
186 #define encode_write_maxsz (op_encode_hdr_maxsz + \
187 encode_stateid_maxsz + 4)
188 #define decode_write_maxsz (op_decode_hdr_maxsz + \
189 2 + decode_verifier_maxsz)
190 #define encode_commit_maxsz (op_encode_hdr_maxsz + 3)
191 #define decode_commit_maxsz (op_decode_hdr_maxsz + \
192 decode_verifier_maxsz)
193 #define encode_remove_maxsz (op_encode_hdr_maxsz + \
195 #define decode_remove_maxsz (op_decode_hdr_maxsz + \
196 decode_change_info_maxsz)
197 #define encode_rename_maxsz (op_encode_hdr_maxsz + \
199 #define decode_rename_maxsz (op_decode_hdr_maxsz + \
200 decode_change_info_maxsz + \
201 decode_change_info_maxsz)
202 #define encode_link_maxsz (op_encode_hdr_maxsz + \
204 #define decode_link_maxsz (op_decode_hdr_maxsz + decode_change_info_maxsz)
205 #define encode_lock_maxsz (op_encode_hdr_maxsz + \
207 1 + encode_stateid_maxsz + 8)
208 #define decode_lock_denied_maxsz \
209 (8 + decode_lockowner_maxsz)
210 #define decode_lock_maxsz (op_decode_hdr_maxsz + \
211 decode_lock_denied_maxsz)
212 #define encode_lockt_maxsz (op_encode_hdr_maxsz + 12)
213 #define decode_lockt_maxsz (op_decode_hdr_maxsz + \
214 decode_lock_denied_maxsz)
215 #define encode_locku_maxsz (op_encode_hdr_maxsz + 3 + \
216 encode_stateid_maxsz + \
218 #define decode_locku_maxsz (op_decode_hdr_maxsz + \
219 decode_stateid_maxsz)
220 #define encode_access_maxsz (op_encode_hdr_maxsz + 1)
221 #define decode_access_maxsz (op_decode_hdr_maxsz + 2)
222 #define encode_symlink_maxsz (op_encode_hdr_maxsz + \
223 1 + nfs4_name_maxsz + \
226 #define decode_symlink_maxsz (op_decode_hdr_maxsz + 8)
227 #define encode_create_maxsz (op_encode_hdr_maxsz + \
228 1 + 2 + nfs4_name_maxsz + \
230 #define decode_create_maxsz (op_decode_hdr_maxsz + \
231 decode_change_info_maxsz + \
232 nfs4_fattr_bitmap_maxsz)
233 #define encode_statfs_maxsz (encode_getattr_maxsz)
234 #define decode_statfs_maxsz (decode_getattr_maxsz)
235 #define encode_delegreturn_maxsz (op_encode_hdr_maxsz + 4)
236 #define decode_delegreturn_maxsz (op_decode_hdr_maxsz)
237 #define encode_getacl_maxsz (encode_getattr_maxsz)
238 #define decode_getacl_maxsz (op_decode_hdr_maxsz + \
239 nfs4_fattr_bitmap_maxsz + 1)
240 #define encode_setacl_maxsz (op_encode_hdr_maxsz + \
241 encode_stateid_maxsz + 3)
242 #define decode_setacl_maxsz (decode_setattr_maxsz)
243 #define encode_fs_locations_maxsz \
244 (encode_getattr_maxsz)
245 #define decode_fs_locations_maxsz \
247 #define NFS4_enc_compound_sz (1024) /* XXX: large enough? */
248 #define NFS4_dec_compound_sz (1024) /* XXX: large enough? */
249 #define NFS4_enc_read_sz (compound_encode_hdr_maxsz + \
250 encode_putfh_maxsz + \
252 #define NFS4_dec_read_sz (compound_decode_hdr_maxsz + \
253 decode_putfh_maxsz + \
255 #define NFS4_enc_readlink_sz (compound_encode_hdr_maxsz + \
256 encode_putfh_maxsz + \
257 encode_readlink_maxsz)
258 #define NFS4_dec_readlink_sz (compound_decode_hdr_maxsz + \
259 decode_putfh_maxsz + \
260 decode_readlink_maxsz)
261 #define NFS4_enc_readdir_sz (compound_encode_hdr_maxsz + \
262 encode_putfh_maxsz + \
263 encode_readdir_maxsz)
264 #define NFS4_dec_readdir_sz (compound_decode_hdr_maxsz + \
265 decode_putfh_maxsz + \
266 decode_readdir_maxsz)
267 #define NFS4_enc_write_sz (compound_encode_hdr_maxsz + \
268 encode_putfh_maxsz + \
269 encode_write_maxsz + \
270 encode_getattr_maxsz)
271 #define NFS4_dec_write_sz (compound_decode_hdr_maxsz + \
272 decode_putfh_maxsz + \
273 decode_write_maxsz + \
274 decode_getattr_maxsz)
275 #define NFS4_enc_commit_sz (compound_encode_hdr_maxsz + \
276 encode_putfh_maxsz + \
277 encode_commit_maxsz + \
278 encode_getattr_maxsz)
279 #define NFS4_dec_commit_sz (compound_decode_hdr_maxsz + \
280 decode_putfh_maxsz + \
281 decode_commit_maxsz + \
282 decode_getattr_maxsz)
283 #define NFS4_enc_open_sz (compound_encode_hdr_maxsz + \
284 encode_putfh_maxsz + \
285 encode_savefh_maxsz + \
286 encode_open_maxsz + \
287 encode_getfh_maxsz + \
288 encode_getattr_maxsz + \
289 encode_restorefh_maxsz + \
290 encode_getattr_maxsz)
291 #define NFS4_dec_open_sz (compound_decode_hdr_maxsz + \
292 decode_putfh_maxsz + \
293 decode_savefh_maxsz + \
294 decode_open_maxsz + \
295 decode_getfh_maxsz + \
296 decode_getattr_maxsz + \
297 decode_restorefh_maxsz + \
298 decode_getattr_maxsz)
299 #define NFS4_enc_open_confirm_sz \
300 (compound_encode_hdr_maxsz + \
301 encode_putfh_maxsz + \
302 encode_open_confirm_maxsz)
303 #define NFS4_dec_open_confirm_sz \
304 (compound_decode_hdr_maxsz + \
305 decode_putfh_maxsz + \
306 decode_open_confirm_maxsz)
307 #define NFS4_enc_open_noattr_sz (compound_encode_hdr_maxsz + \
308 encode_putfh_maxsz + \
309 encode_open_maxsz + \
310 encode_getattr_maxsz)
311 #define NFS4_dec_open_noattr_sz (compound_decode_hdr_maxsz + \
312 decode_putfh_maxsz + \
313 decode_open_maxsz + \
314 decode_getattr_maxsz)
315 #define NFS4_enc_open_downgrade_sz \
316 (compound_encode_hdr_maxsz + \
317 encode_putfh_maxsz + \
318 encode_open_downgrade_maxsz + \
319 encode_getattr_maxsz)
320 #define NFS4_dec_open_downgrade_sz \
321 (compound_decode_hdr_maxsz + \
322 decode_putfh_maxsz + \
323 decode_open_downgrade_maxsz + \
324 decode_getattr_maxsz)
325 #define NFS4_enc_close_sz (compound_encode_hdr_maxsz + \
326 encode_putfh_maxsz + \
327 encode_close_maxsz + \
328 encode_getattr_maxsz)
329 #define NFS4_dec_close_sz (compound_decode_hdr_maxsz + \
330 decode_putfh_maxsz + \
331 decode_close_maxsz + \
332 decode_getattr_maxsz)
333 #define NFS4_enc_setattr_sz (compound_encode_hdr_maxsz + \
334 encode_putfh_maxsz + \
335 encode_setattr_maxsz + \
336 encode_getattr_maxsz)
337 #define NFS4_dec_setattr_sz (compound_decode_hdr_maxsz + \
338 decode_putfh_maxsz + \
339 decode_setattr_maxsz + \
340 decode_getattr_maxsz)
341 #define NFS4_enc_fsinfo_sz (compound_encode_hdr_maxsz + \
342 encode_putfh_maxsz + \
344 #define NFS4_dec_fsinfo_sz (compound_decode_hdr_maxsz + \
345 decode_putfh_maxsz + \
347 #define NFS4_enc_renew_sz (compound_encode_hdr_maxsz + \
349 #define NFS4_dec_renew_sz (compound_decode_hdr_maxsz + \
351 #define NFS4_enc_setclientid_sz (compound_encode_hdr_maxsz + \
352 encode_setclientid_maxsz)
353 #define NFS4_dec_setclientid_sz (compound_decode_hdr_maxsz + \
354 decode_setclientid_maxsz)
355 #define NFS4_enc_setclientid_confirm_sz \
356 (compound_encode_hdr_maxsz + \
357 encode_setclientid_confirm_maxsz + \
358 encode_putrootfh_maxsz + \
360 #define NFS4_dec_setclientid_confirm_sz \
361 (compound_decode_hdr_maxsz + \
362 decode_setclientid_confirm_maxsz + \
363 decode_putrootfh_maxsz + \
365 #define NFS4_enc_lock_sz (compound_encode_hdr_maxsz + \
366 encode_putfh_maxsz + \
368 #define NFS4_dec_lock_sz (compound_decode_hdr_maxsz + \
369 decode_putfh_maxsz + \
371 #define NFS4_enc_lockt_sz (compound_encode_hdr_maxsz + \
372 encode_putfh_maxsz + \
374 #define NFS4_dec_lockt_sz (compound_decode_hdr_maxsz + \
375 decode_putfh_maxsz + \
377 #define NFS4_enc_locku_sz (compound_encode_hdr_maxsz + \
378 encode_putfh_maxsz + \
380 #define NFS4_dec_locku_sz (compound_decode_hdr_maxsz + \
381 decode_putfh_maxsz + \
383 #define NFS4_enc_access_sz (compound_encode_hdr_maxsz + \
384 encode_putfh_maxsz + \
385 encode_access_maxsz + \
386 encode_getattr_maxsz)
387 #define NFS4_dec_access_sz (compound_decode_hdr_maxsz + \
388 decode_putfh_maxsz + \
389 decode_access_maxsz + \
390 decode_getattr_maxsz)
391 #define NFS4_enc_getattr_sz (compound_encode_hdr_maxsz + \
392 encode_putfh_maxsz + \
393 encode_getattr_maxsz)
394 #define NFS4_dec_getattr_sz (compound_decode_hdr_maxsz + \
395 decode_putfh_maxsz + \
396 decode_getattr_maxsz)
397 #define NFS4_enc_lookup_sz (compound_encode_hdr_maxsz + \
398 encode_putfh_maxsz + \
399 encode_lookup_maxsz + \
400 encode_getattr_maxsz + \
402 #define NFS4_dec_lookup_sz (compound_decode_hdr_maxsz + \
403 decode_putfh_maxsz + \
404 decode_lookup_maxsz + \
405 decode_getattr_maxsz + \
407 #define NFS4_enc_lookup_root_sz (compound_encode_hdr_maxsz + \
408 encode_putrootfh_maxsz + \
409 encode_getattr_maxsz + \
411 #define NFS4_dec_lookup_root_sz (compound_decode_hdr_maxsz + \
412 decode_putrootfh_maxsz + \
413 decode_getattr_maxsz + \
415 #define NFS4_enc_remove_sz (compound_encode_hdr_maxsz + \
416 encode_putfh_maxsz + \
417 encode_remove_maxsz + \
418 encode_getattr_maxsz)
419 #define NFS4_dec_remove_sz (compound_decode_hdr_maxsz + \
420 decode_putfh_maxsz + \
421 decode_remove_maxsz + \
422 decode_getattr_maxsz)
423 #define NFS4_enc_rename_sz (compound_encode_hdr_maxsz + \
424 encode_putfh_maxsz + \
425 encode_savefh_maxsz + \
426 encode_putfh_maxsz + \
427 encode_rename_maxsz + \
428 encode_getattr_maxsz + \
429 encode_restorefh_maxsz + \
430 encode_getattr_maxsz)
431 #define NFS4_dec_rename_sz (compound_decode_hdr_maxsz + \
432 decode_putfh_maxsz + \
433 decode_savefh_maxsz + \
434 decode_putfh_maxsz + \
435 decode_rename_maxsz + \
436 decode_getattr_maxsz + \
437 decode_restorefh_maxsz + \
438 decode_getattr_maxsz)
439 #define NFS4_enc_link_sz (compound_encode_hdr_maxsz + \
440 encode_putfh_maxsz + \
441 encode_savefh_maxsz + \
442 encode_putfh_maxsz + \
443 encode_link_maxsz + \
444 decode_getattr_maxsz + \
445 encode_restorefh_maxsz + \
446 decode_getattr_maxsz)
447 #define NFS4_dec_link_sz (compound_decode_hdr_maxsz + \
448 decode_putfh_maxsz + \
449 decode_savefh_maxsz + \
450 decode_putfh_maxsz + \
451 decode_link_maxsz + \
452 decode_getattr_maxsz + \
453 decode_restorefh_maxsz + \
454 decode_getattr_maxsz)
455 #define NFS4_enc_symlink_sz (compound_encode_hdr_maxsz + \
456 encode_putfh_maxsz + \
457 encode_symlink_maxsz + \
458 encode_getattr_maxsz + \
460 #define NFS4_dec_symlink_sz (compound_decode_hdr_maxsz + \
461 decode_putfh_maxsz + \
462 decode_symlink_maxsz + \
463 decode_getattr_maxsz + \
465 #define NFS4_enc_create_sz (compound_encode_hdr_maxsz + \
466 encode_putfh_maxsz + \
467 encode_savefh_maxsz + \
468 encode_create_maxsz + \
469 encode_getfh_maxsz + \
470 encode_getattr_maxsz + \
471 encode_restorefh_maxsz + \
472 encode_getattr_maxsz)
473 #define NFS4_dec_create_sz (compound_decode_hdr_maxsz + \
474 decode_putfh_maxsz + \
475 decode_savefh_maxsz + \
476 decode_create_maxsz + \
477 decode_getfh_maxsz + \
478 decode_getattr_maxsz + \
479 decode_restorefh_maxsz + \
480 decode_getattr_maxsz)
481 #define NFS4_enc_pathconf_sz (compound_encode_hdr_maxsz + \
482 encode_putfh_maxsz + \
483 encode_getattr_maxsz)
484 #define NFS4_dec_pathconf_sz (compound_decode_hdr_maxsz + \
485 decode_putfh_maxsz + \
486 decode_getattr_maxsz)
487 #define NFS4_enc_statfs_sz (compound_encode_hdr_maxsz + \
488 encode_putfh_maxsz + \
490 #define NFS4_dec_statfs_sz (compound_decode_hdr_maxsz + \
491 decode_putfh_maxsz + \
493 #define NFS4_enc_server_caps_sz (compound_encode_hdr_maxsz + \
494 encode_putfh_maxsz + \
495 encode_getattr_maxsz)
496 #define NFS4_dec_server_caps_sz (compound_decode_hdr_maxsz + \
497 decode_putfh_maxsz + \
498 decode_getattr_maxsz)
499 #define NFS4_enc_delegreturn_sz (compound_encode_hdr_maxsz + \
500 encode_putfh_maxsz + \
501 encode_delegreturn_maxsz + \
502 encode_getattr_maxsz)
503 #define NFS4_dec_delegreturn_sz (compound_decode_hdr_maxsz + \
504 decode_delegreturn_maxsz + \
505 decode_getattr_maxsz)
506 #define NFS4_enc_getacl_sz (compound_encode_hdr_maxsz + \
507 encode_putfh_maxsz + \
509 #define NFS4_dec_getacl_sz (compound_decode_hdr_maxsz + \
510 decode_putfh_maxsz + \
512 #define NFS4_enc_setacl_sz (compound_encode_hdr_maxsz + \
513 encode_putfh_maxsz + \
515 #define NFS4_dec_setacl_sz (compound_decode_hdr_maxsz + \
516 decode_putfh_maxsz + \
518 #define NFS4_enc_fs_locations_sz \
519 (compound_encode_hdr_maxsz + \
520 encode_putfh_maxsz + \
521 encode_lookup_maxsz + \
522 encode_fs_locations_maxsz)
523 #define NFS4_dec_fs_locations_sz \
524 (compound_decode_hdr_maxsz + \
525 decode_putfh_maxsz + \
526 decode_lookup_maxsz + \
527 decode_fs_locations_maxsz)
529 static const umode_t nfs_type2fmt[] = {
536 [NF4SOCK] = S_IFSOCK,
542 struct compound_hdr {
548 uint32_t replen; /* expected reply words */
553 * START OF "GENERIC" ENCODE ROUTINES.
554 * These may look a little ugly since they are imported from a "generic"
555 * set of XDR encode/decode routines which are intended to be shared by
556 * all of our NFSv4 implementations (OpenBSD, MacOS X...).
558 * If the pain of reading these is too great, it should be a straightforward
559 * task to translate them into Linux-specific versions which are more
560 * consistent with the style used in NFSv2/v3...
562 #define WRITE32(n) *p++ = htonl(n)
563 #define WRITE64(n) do { \
564 *p++ = htonl((uint32_t)((n) >> 32)); \
565 *p++ = htonl((uint32_t)(n)); \
567 #define WRITEMEM(ptr,nbytes) do { \
568 p = xdr_encode_opaque_fixed(p, ptr, nbytes); \
571 #define RESERVE_SPACE(nbytes) do { \
572 p = xdr_reserve_space(xdr, nbytes); \
576 static void encode_string(struct xdr_stream *xdr, unsigned int len, const char *str)
580 p = xdr_reserve_space(xdr, 4 + len);
582 xdr_encode_opaque(p, str, len);
585 static void encode_compound_hdr(struct xdr_stream *xdr,
586 struct rpc_rqst *req,
587 struct compound_hdr *hdr)
590 struct rpc_auth *auth = req->rq_task->tk_msg.rpc_cred->cr_auth;
592 /* initialize running count of expected bytes in reply.
593 * NOTE: the replied tag SHOULD be the same is the one sent,
594 * but this is not required as a MUST for the server to do so. */
595 hdr->replen = RPC_REPHDRSIZE + auth->au_rslack + 3 + hdr->taglen;
597 dprintk("encode_compound: tag=%.*s\n", (int)hdr->taglen, hdr->tag);
598 BUG_ON(hdr->taglen > NFS4_MAXTAGLEN);
599 RESERVE_SPACE(12+(XDR_QUADLEN(hdr->taglen)<<2));
600 WRITE32(hdr->taglen);
601 WRITEMEM(hdr->tag, hdr->taglen);
602 WRITE32(hdr->minorversion);
607 static void encode_nops(struct compound_hdr *hdr)
609 *hdr->nops_p = htonl(hdr->nops);
612 static void encode_nfs4_verifier(struct xdr_stream *xdr, const nfs4_verifier *verf)
616 p = xdr_reserve_space(xdr, NFS4_VERIFIER_SIZE);
618 xdr_encode_opaque_fixed(p, verf->data, NFS4_VERIFIER_SIZE);
621 static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap, const struct nfs_server *server)
623 char owner_name[IDMAP_NAMESZ];
624 char owner_group[IDMAP_NAMESZ];
625 int owner_namelen = 0;
626 int owner_grouplen = 0;
634 * We reserve enough space to write the entire attribute buffer at once.
635 * In the worst-case, this would be
636 * 12(bitmap) + 4(attrlen) + 8(size) + 4(mode) + 4(atime) + 4(mtime)
637 * = 36 bytes, plus any contribution from variable-length fields
638 * such as owner/group.
643 if (iap->ia_valid & ATTR_SIZE)
645 if (iap->ia_valid & ATTR_MODE)
647 if (iap->ia_valid & ATTR_UID) {
648 owner_namelen = nfs_map_uid_to_name(server->nfs_client, iap->ia_uid, owner_name);
649 if (owner_namelen < 0) {
650 dprintk("nfs: couldn't resolve uid %d to string\n",
653 strcpy(owner_name, "nobody");
654 owner_namelen = sizeof("nobody") - 1;
657 len += 4 + (XDR_QUADLEN(owner_namelen) << 2);
659 if (iap->ia_valid & ATTR_GID) {
660 owner_grouplen = nfs_map_gid_to_group(server->nfs_client, iap->ia_gid, owner_group);
661 if (owner_grouplen < 0) {
662 dprintk("nfs: couldn't resolve gid %d to string\n",
664 strcpy(owner_group, "nobody");
665 owner_grouplen = sizeof("nobody") - 1;
668 len += 4 + (XDR_QUADLEN(owner_grouplen) << 2);
670 if (iap->ia_valid & ATTR_ATIME_SET)
672 else if (iap->ia_valid & ATTR_ATIME)
674 if (iap->ia_valid & ATTR_MTIME_SET)
676 else if (iap->ia_valid & ATTR_MTIME)
681 * We write the bitmap length now, but leave the bitmap and the attribute
682 * buffer length to be backfilled at the end of this routine.
688 if (iap->ia_valid & ATTR_SIZE) {
689 bmval0 |= FATTR4_WORD0_SIZE;
690 WRITE64(iap->ia_size);
692 if (iap->ia_valid & ATTR_MODE) {
693 bmval1 |= FATTR4_WORD1_MODE;
694 WRITE32(iap->ia_mode & S_IALLUGO);
696 if (iap->ia_valid & ATTR_UID) {
697 bmval1 |= FATTR4_WORD1_OWNER;
698 WRITE32(owner_namelen);
699 WRITEMEM(owner_name, owner_namelen);
701 if (iap->ia_valid & ATTR_GID) {
702 bmval1 |= FATTR4_WORD1_OWNER_GROUP;
703 WRITE32(owner_grouplen);
704 WRITEMEM(owner_group, owner_grouplen);
706 if (iap->ia_valid & ATTR_ATIME_SET) {
707 bmval1 |= FATTR4_WORD1_TIME_ACCESS_SET;
708 WRITE32(NFS4_SET_TO_CLIENT_TIME);
710 WRITE32(iap->ia_mtime.tv_sec);
711 WRITE32(iap->ia_mtime.tv_nsec);
713 else if (iap->ia_valid & ATTR_ATIME) {
714 bmval1 |= FATTR4_WORD1_TIME_ACCESS_SET;
715 WRITE32(NFS4_SET_TO_SERVER_TIME);
717 if (iap->ia_valid & ATTR_MTIME_SET) {
718 bmval1 |= FATTR4_WORD1_TIME_MODIFY_SET;
719 WRITE32(NFS4_SET_TO_CLIENT_TIME);
721 WRITE32(iap->ia_mtime.tv_sec);
722 WRITE32(iap->ia_mtime.tv_nsec);
724 else if (iap->ia_valid & ATTR_MTIME) {
725 bmval1 |= FATTR4_WORD1_TIME_MODIFY_SET;
726 WRITE32(NFS4_SET_TO_SERVER_TIME);
730 * Now we backfill the bitmap and the attribute buffer length.
732 if (len != ((char *)p - (char *)q) + 4) {
733 printk(KERN_ERR "nfs: Attr length error, %u != %Zu\n",
734 len, ((char *)p - (char *)q) + 4);
737 len = (char *)p - (char *)q - 12;
738 *q++ = htonl(bmval0);
739 *q++ = htonl(bmval1);
745 static void encode_access(struct xdr_stream *xdr, u32 access, struct compound_hdr *hdr)
753 hdr->replen += decode_access_maxsz;
756 static void encode_close(struct xdr_stream *xdr, const struct nfs_closeargs *arg, struct compound_hdr *hdr)
760 RESERVE_SPACE(8+NFS4_STATEID_SIZE);
762 WRITE32(arg->seqid->sequence->counter);
763 WRITEMEM(arg->stateid->data, NFS4_STATEID_SIZE);
765 hdr->replen += decode_close_maxsz;
768 static void encode_commit(struct xdr_stream *xdr, const struct nfs_writeargs *args, struct compound_hdr *hdr)
774 WRITE64(args->offset);
775 WRITE32(args->count);
777 hdr->replen += decode_commit_maxsz;
780 static void encode_create(struct xdr_stream *xdr, const struct nfs4_create_arg *create, struct compound_hdr *hdr)
786 WRITE32(create->ftype);
788 switch (create->ftype) {
791 WRITE32(create->u.symlink.len);
792 xdr_write_pages(xdr, create->u.symlink.pages, 0, create->u.symlink.len);
795 case NF4BLK: case NF4CHR:
797 WRITE32(create->u.device.specdata1);
798 WRITE32(create->u.device.specdata2);
805 RESERVE_SPACE(4 + create->name->len);
806 WRITE32(create->name->len);
807 WRITEMEM(create->name->name, create->name->len);
809 hdr->replen += decode_create_maxsz;
811 encode_attrs(xdr, create->attrs, create->server);
814 static void encode_getattr_one(struct xdr_stream *xdr, uint32_t bitmap, struct compound_hdr *hdr)
823 hdr->replen += decode_getattr_maxsz;
826 static void encode_getattr_two(struct xdr_stream *xdr, uint32_t bm0, uint32_t bm1, struct compound_hdr *hdr)
836 hdr->replen += decode_getattr_maxsz;
839 static void encode_getfattr(struct xdr_stream *xdr, const u32* bitmask, struct compound_hdr *hdr)
841 encode_getattr_two(xdr, bitmask[0] & nfs4_fattr_bitmap[0],
842 bitmask[1] & nfs4_fattr_bitmap[1], hdr);
845 static void encode_fsinfo(struct xdr_stream *xdr, const u32* bitmask, struct compound_hdr *hdr)
847 encode_getattr_two(xdr, bitmask[0] & nfs4_fsinfo_bitmap[0],
848 bitmask[1] & nfs4_fsinfo_bitmap[1], hdr);
851 static void encode_fs_locations(struct xdr_stream *xdr, const u32* bitmask, struct compound_hdr *hdr)
853 encode_getattr_two(xdr, bitmask[0] & nfs4_fs_locations_bitmap[0],
854 bitmask[1] & nfs4_fs_locations_bitmap[1], hdr);
857 static void encode_getfh(struct xdr_stream *xdr, struct compound_hdr *hdr)
864 hdr->replen += decode_getfh_maxsz;
867 static void encode_link(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr)
871 RESERVE_SPACE(8 + name->len);
874 WRITEMEM(name->name, name->len);
876 hdr->replen += decode_link_maxsz;
879 static inline int nfs4_lock_type(struct file_lock *fl, int block)
881 if ((fl->fl_type & (F_RDLCK|F_WRLCK|F_UNLCK)) == F_RDLCK)
882 return block ? NFS4_READW_LT : NFS4_READ_LT;
883 return block ? NFS4_WRITEW_LT : NFS4_WRITE_LT;
886 static inline uint64_t nfs4_lock_length(struct file_lock *fl)
888 if (fl->fl_end == OFFSET_MAX)
890 return fl->fl_end - fl->fl_start + 1;
894 * opcode,type,reclaim,offset,length,new_lock_owner = 32
895 * open_seqid,open_stateid,lock_seqid,lock_owner.clientid, lock_owner.id = 40
897 static void encode_lock(struct xdr_stream *xdr, const struct nfs_lock_args *args, struct compound_hdr *hdr)
903 WRITE32(nfs4_lock_type(args->fl, args->block));
904 WRITE32(args->reclaim);
905 WRITE64(args->fl->fl_start);
906 WRITE64(nfs4_lock_length(args->fl));
907 WRITE32(args->new_lock_owner);
908 if (args->new_lock_owner){
909 RESERVE_SPACE(4+NFS4_STATEID_SIZE+32);
910 WRITE32(args->open_seqid->sequence->counter);
911 WRITEMEM(args->open_stateid->data, NFS4_STATEID_SIZE);
912 WRITE32(args->lock_seqid->sequence->counter);
913 WRITE64(args->lock_owner.clientid);
915 WRITEMEM("lock id:", 8);
916 WRITE64(args->lock_owner.id);
919 RESERVE_SPACE(NFS4_STATEID_SIZE+4);
920 WRITEMEM(args->lock_stateid->data, NFS4_STATEID_SIZE);
921 WRITE32(args->lock_seqid->sequence->counter);
924 hdr->replen += decode_lock_maxsz;
927 static void encode_lockt(struct xdr_stream *xdr, const struct nfs_lockt_args *args, struct compound_hdr *hdr)
933 WRITE32(nfs4_lock_type(args->fl, 0));
934 WRITE64(args->fl->fl_start);
935 WRITE64(nfs4_lock_length(args->fl));
936 WRITE64(args->lock_owner.clientid);
938 WRITEMEM("lock id:", 8);
939 WRITE64(args->lock_owner.id);
941 hdr->replen += decode_lockt_maxsz;
944 static void encode_locku(struct xdr_stream *xdr, const struct nfs_locku_args *args, struct compound_hdr *hdr)
948 RESERVE_SPACE(12+NFS4_STATEID_SIZE+16);
950 WRITE32(nfs4_lock_type(args->fl, 0));
951 WRITE32(args->seqid->sequence->counter);
952 WRITEMEM(args->stateid->data, NFS4_STATEID_SIZE);
953 WRITE64(args->fl->fl_start);
954 WRITE64(nfs4_lock_length(args->fl));
956 hdr->replen += decode_locku_maxsz;
959 static void encode_lookup(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr)
964 RESERVE_SPACE(8 + len);
967 WRITEMEM(name->name, len);
969 hdr->replen += decode_lookup_maxsz;
972 static void encode_share_access(struct xdr_stream *xdr, fmode_t fmode)
977 switch (fmode & (FMODE_READ|FMODE_WRITE)) {
979 WRITE32(NFS4_SHARE_ACCESS_READ);
982 WRITE32(NFS4_SHARE_ACCESS_WRITE);
984 case FMODE_READ|FMODE_WRITE:
985 WRITE32(NFS4_SHARE_ACCESS_BOTH);
990 WRITE32(0); /* for linux, share_deny = 0 always */
993 static inline void encode_openhdr(struct xdr_stream *xdr, const struct nfs_openargs *arg)
997 * opcode 4, seqid 4, share_access 4, share_deny 4, clientid 8, ownerlen 4,
1002 WRITE32(arg->seqid->sequence->counter);
1003 encode_share_access(xdr, arg->fmode);
1005 WRITE64(arg->clientid);
1007 WRITEMEM("open id:", 8);
1011 static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_openargs *arg)
1016 switch(arg->open_flags & O_EXCL) {
1018 WRITE32(NFS4_CREATE_UNCHECKED);
1019 encode_attrs(xdr, arg->u.attrs, arg->server);
1022 WRITE32(NFS4_CREATE_EXCLUSIVE);
1023 encode_nfs4_verifier(xdr, &arg->u.verifier);
1027 static void encode_opentype(struct xdr_stream *xdr, const struct nfs_openargs *arg)
1032 switch (arg->open_flags & O_CREAT) {
1034 WRITE32(NFS4_OPEN_NOCREATE);
1037 BUG_ON(arg->claim != NFS4_OPEN_CLAIM_NULL);
1038 WRITE32(NFS4_OPEN_CREATE);
1039 encode_createmode(xdr, arg);
1043 static inline void encode_delegation_type(struct xdr_stream *xdr, fmode_t delegation_type)
1048 switch (delegation_type) {
1050 WRITE32(NFS4_OPEN_DELEGATE_NONE);
1053 WRITE32(NFS4_OPEN_DELEGATE_READ);
1055 case FMODE_WRITE|FMODE_READ:
1056 WRITE32(NFS4_OPEN_DELEGATE_WRITE);
1063 static inline void encode_claim_null(struct xdr_stream *xdr, const struct qstr *name)
1068 WRITE32(NFS4_OPEN_CLAIM_NULL);
1069 encode_string(xdr, name->len, name->name);
1072 static inline void encode_claim_previous(struct xdr_stream *xdr, fmode_t type)
1077 WRITE32(NFS4_OPEN_CLAIM_PREVIOUS);
1078 encode_delegation_type(xdr, type);
1081 static inline void encode_claim_delegate_cur(struct xdr_stream *xdr, const struct qstr *name, const nfs4_stateid *stateid)
1085 RESERVE_SPACE(4+NFS4_STATEID_SIZE);
1086 WRITE32(NFS4_OPEN_CLAIM_DELEGATE_CUR);
1087 WRITEMEM(stateid->data, NFS4_STATEID_SIZE);
1088 encode_string(xdr, name->len, name->name);
1091 static void encode_open(struct xdr_stream *xdr, const struct nfs_openargs *arg, struct compound_hdr *hdr)
1093 encode_openhdr(xdr, arg);
1094 encode_opentype(xdr, arg);
1095 switch (arg->claim) {
1096 case NFS4_OPEN_CLAIM_NULL:
1097 encode_claim_null(xdr, arg->name);
1099 case NFS4_OPEN_CLAIM_PREVIOUS:
1100 encode_claim_previous(xdr, arg->u.delegation_type);
1102 case NFS4_OPEN_CLAIM_DELEGATE_CUR:
1103 encode_claim_delegate_cur(xdr, arg->name, &arg->u.delegation);
1109 hdr->replen += decode_open_maxsz;
1112 static void encode_open_confirm(struct xdr_stream *xdr, const struct nfs_open_confirmargs *arg, struct compound_hdr *hdr)
1116 RESERVE_SPACE(4+NFS4_STATEID_SIZE+4);
1117 WRITE32(OP_OPEN_CONFIRM);
1118 WRITEMEM(arg->stateid->data, NFS4_STATEID_SIZE);
1119 WRITE32(arg->seqid->sequence->counter);
1121 hdr->replen += decode_open_confirm_maxsz;
1124 static void encode_open_downgrade(struct xdr_stream *xdr, const struct nfs_closeargs *arg, struct compound_hdr *hdr)
1128 RESERVE_SPACE(4+NFS4_STATEID_SIZE+4);
1129 WRITE32(OP_OPEN_DOWNGRADE);
1130 WRITEMEM(arg->stateid->data, NFS4_STATEID_SIZE);
1131 WRITE32(arg->seqid->sequence->counter);
1132 encode_share_access(xdr, arg->fmode);
1134 hdr->replen += decode_open_downgrade_maxsz;
1138 encode_putfh(struct xdr_stream *xdr, const struct nfs_fh *fh, struct compound_hdr *hdr)
1143 RESERVE_SPACE(8 + len);
1146 WRITEMEM(fh->data, len);
1148 hdr->replen += decode_putfh_maxsz;
1151 static void encode_putrootfh(struct xdr_stream *xdr, struct compound_hdr *hdr)
1156 WRITE32(OP_PUTROOTFH);
1158 hdr->replen += decode_putrootfh_maxsz;
1161 static void encode_stateid(struct xdr_stream *xdr, const struct nfs_open_context *ctx)
1163 nfs4_stateid stateid;
1166 RESERVE_SPACE(NFS4_STATEID_SIZE);
1167 if (ctx->state != NULL) {
1168 nfs4_copy_stateid(&stateid, ctx->state, ctx->lockowner);
1169 WRITEMEM(stateid.data, NFS4_STATEID_SIZE);
1171 WRITEMEM(zero_stateid.data, NFS4_STATEID_SIZE);
1174 static void encode_read(struct xdr_stream *xdr, const struct nfs_readargs *args, struct compound_hdr *hdr)
1181 encode_stateid(xdr, args->context);
1184 WRITE64(args->offset);
1185 WRITE32(args->count);
1187 hdr->replen += decode_read_maxsz;
1190 static void encode_readdir(struct xdr_stream *xdr, const struct nfs4_readdir_arg *readdir, struct rpc_rqst *req, struct compound_hdr *hdr)
1192 uint32_t attrs[2] = {
1193 FATTR4_WORD0_RDATTR_ERROR|FATTR4_WORD0_FILEID,
1194 FATTR4_WORD1_MOUNTED_ON_FILEID,
1198 RESERVE_SPACE(12+NFS4_VERIFIER_SIZE+20);
1199 WRITE32(OP_READDIR);
1200 WRITE64(readdir->cookie);
1201 WRITEMEM(readdir->verifier.data, NFS4_VERIFIER_SIZE);
1202 WRITE32(readdir->count >> 1); /* We're not doing readdirplus */
1203 WRITE32(readdir->count);
1205 /* Switch to mounted_on_fileid if the server supports it */
1206 if (readdir->bitmask[1] & FATTR4_WORD1_MOUNTED_ON_FILEID)
1207 attrs[0] &= ~FATTR4_WORD0_FILEID;
1209 attrs[1] &= ~FATTR4_WORD1_MOUNTED_ON_FILEID;
1210 WRITE32(attrs[0] & readdir->bitmask[0]);
1211 WRITE32(attrs[1] & readdir->bitmask[1]);
1213 hdr->replen += decode_readdir_maxsz;
1214 dprintk("%s: cookie = %Lu, verifier = %08x:%08x, bitmap = %08x:%08x\n",
1216 (unsigned long long)readdir->cookie,
1217 ((u32 *)readdir->verifier.data)[0],
1218 ((u32 *)readdir->verifier.data)[1],
1219 attrs[0] & readdir->bitmask[0],
1220 attrs[1] & readdir->bitmask[1]);
1223 static void encode_readlink(struct xdr_stream *xdr, const struct nfs4_readlink *readlink, struct rpc_rqst *req, struct compound_hdr *hdr)
1228 WRITE32(OP_READLINK);
1230 hdr->replen += decode_readlink_maxsz;
1233 static void encode_remove(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr)
1237 RESERVE_SPACE(8 + name->len);
1240 WRITEMEM(name->name, name->len);
1242 hdr->replen += decode_remove_maxsz;
1245 static void encode_rename(struct xdr_stream *xdr, const struct qstr *oldname, const struct qstr *newname, struct compound_hdr *hdr)
1249 RESERVE_SPACE(8 + oldname->len);
1251 WRITE32(oldname->len);
1252 WRITEMEM(oldname->name, oldname->len);
1254 RESERVE_SPACE(4 + newname->len);
1255 WRITE32(newname->len);
1256 WRITEMEM(newname->name, newname->len);
1258 hdr->replen += decode_rename_maxsz;
1261 static void encode_renew(struct xdr_stream *xdr, const struct nfs_client *client_stateid, struct compound_hdr *hdr)
1267 WRITE64(client_stateid->cl_clientid);
1269 hdr->replen += decode_renew_maxsz;
1273 encode_restorefh(struct xdr_stream *xdr, struct compound_hdr *hdr)
1278 WRITE32(OP_RESTOREFH);
1280 hdr->replen += decode_restorefh_maxsz;
1284 encode_setacl(struct xdr_stream *xdr, struct nfs_setaclargs *arg, struct compound_hdr *hdr)
1288 RESERVE_SPACE(4+NFS4_STATEID_SIZE);
1289 WRITE32(OP_SETATTR);
1290 WRITEMEM(zero_stateid.data, NFS4_STATEID_SIZE);
1293 WRITE32(FATTR4_WORD0_ACL);
1294 if (arg->acl_len % 4)
1297 WRITE32(arg->acl_len);
1298 xdr_write_pages(xdr, arg->acl_pages, arg->acl_pgbase, arg->acl_len);
1300 hdr->replen += decode_setacl_maxsz;
1305 encode_savefh(struct xdr_stream *xdr, struct compound_hdr *hdr)
1312 hdr->replen += decode_savefh_maxsz;
1315 static void encode_setattr(struct xdr_stream *xdr, const struct nfs_setattrargs *arg, const struct nfs_server *server, struct compound_hdr *hdr)
1319 RESERVE_SPACE(4+NFS4_STATEID_SIZE);
1320 WRITE32(OP_SETATTR);
1321 WRITEMEM(arg->stateid.data, NFS4_STATEID_SIZE);
1323 hdr->replen += decode_setattr_maxsz;
1324 encode_attrs(xdr, arg->iap, server);
1327 static void encode_setclientid(struct xdr_stream *xdr, const struct nfs4_setclientid *setclientid, struct compound_hdr *hdr)
1331 RESERVE_SPACE(4 + NFS4_VERIFIER_SIZE);
1332 WRITE32(OP_SETCLIENTID);
1333 WRITEMEM(setclientid->sc_verifier->data, NFS4_VERIFIER_SIZE);
1335 encode_string(xdr, setclientid->sc_name_len, setclientid->sc_name);
1337 WRITE32(setclientid->sc_prog);
1338 encode_string(xdr, setclientid->sc_netid_len, setclientid->sc_netid);
1339 encode_string(xdr, setclientid->sc_uaddr_len, setclientid->sc_uaddr);
1341 WRITE32(setclientid->sc_cb_ident);
1343 hdr->replen += decode_setclientid_maxsz;
1346 static void encode_setclientid_confirm(struct xdr_stream *xdr, const struct nfs_client *client_state, struct compound_hdr *hdr)
1350 RESERVE_SPACE(12 + NFS4_VERIFIER_SIZE);
1351 WRITE32(OP_SETCLIENTID_CONFIRM);
1352 WRITE64(client_state->cl_clientid);
1353 WRITEMEM(client_state->cl_confirm.data, NFS4_VERIFIER_SIZE);
1355 hdr->replen += decode_setclientid_confirm_maxsz;
1358 static void encode_write(struct xdr_stream *xdr, const struct nfs_writeargs *args, struct compound_hdr *hdr)
1365 encode_stateid(xdr, args->context);
1368 WRITE64(args->offset);
1369 WRITE32(args->stable);
1370 WRITE32(args->count);
1372 xdr_write_pages(xdr, args->pages, args->pgbase, args->count);
1374 hdr->replen += decode_write_maxsz;
1377 static void encode_delegreturn(struct xdr_stream *xdr, const nfs4_stateid *stateid, struct compound_hdr *hdr)
1381 RESERVE_SPACE(4+NFS4_STATEID_SIZE);
1383 WRITE32(OP_DELEGRETURN);
1384 WRITEMEM(stateid->data, NFS4_STATEID_SIZE);
1386 hdr->replen += decode_delegreturn_maxsz;
1389 * END OF "GENERIC" ENCODE ROUTINES.
1392 static u32 nfs4_xdr_minorversion(const struct nfs4_sequence_args *args)
1394 #if defined(CONFIG_NFS_V4_1)
1395 if (args->sa_session)
1396 return args->sa_session->clp->cl_minorversion;
1397 #endif /* CONFIG_NFS_V4_1 */
1402 * Encode an ACCESS request
1404 static int nfs4_xdr_enc_access(struct rpc_rqst *req, __be32 *p, const struct nfs4_accessargs *args)
1406 struct xdr_stream xdr;
1407 struct compound_hdr hdr = {
1408 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
1411 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1412 encode_compound_hdr(&xdr, req, &hdr);
1413 encode_putfh(&xdr, args->fh, &hdr);
1414 encode_access(&xdr, args->access, &hdr);
1415 encode_getfattr(&xdr, args->bitmask, &hdr);
1421 * Encode LOOKUP request
1423 static int nfs4_xdr_enc_lookup(struct rpc_rqst *req, __be32 *p, const struct nfs4_lookup_arg *args)
1425 struct xdr_stream xdr;
1426 struct compound_hdr hdr = {
1427 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
1430 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1431 encode_compound_hdr(&xdr, req, &hdr);
1432 encode_putfh(&xdr, args->dir_fh, &hdr);
1433 encode_lookup(&xdr, args->name, &hdr);
1434 encode_getfh(&xdr, &hdr);
1435 encode_getfattr(&xdr, args->bitmask, &hdr);
1441 * Encode LOOKUP_ROOT request
1443 static int nfs4_xdr_enc_lookup_root(struct rpc_rqst *req, __be32 *p, const struct nfs4_lookup_root_arg *args)
1445 struct xdr_stream xdr;
1446 struct compound_hdr hdr = {
1447 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
1450 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1451 encode_compound_hdr(&xdr, req, &hdr);
1452 encode_putrootfh(&xdr, &hdr);
1453 encode_getfh(&xdr, &hdr);
1454 encode_getfattr(&xdr, args->bitmask, &hdr);
1460 * Encode REMOVE request
1462 static int nfs4_xdr_enc_remove(struct rpc_rqst *req, __be32 *p, const struct nfs_removeargs *args)
1464 struct xdr_stream xdr;
1465 struct compound_hdr hdr = {
1466 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
1469 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1470 encode_compound_hdr(&xdr, req, &hdr);
1471 encode_putfh(&xdr, args->fh, &hdr);
1472 encode_remove(&xdr, &args->name, &hdr);
1473 encode_getfattr(&xdr, args->bitmask, &hdr);
1479 * Encode RENAME request
1481 static int nfs4_xdr_enc_rename(struct rpc_rqst *req, __be32 *p, const struct nfs4_rename_arg *args)
1483 struct xdr_stream xdr;
1484 struct compound_hdr hdr = {
1485 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
1488 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1489 encode_compound_hdr(&xdr, req, &hdr);
1490 encode_putfh(&xdr, args->old_dir, &hdr);
1491 encode_savefh(&xdr, &hdr);
1492 encode_putfh(&xdr, args->new_dir, &hdr);
1493 encode_rename(&xdr, args->old_name, args->new_name, &hdr);
1494 encode_getfattr(&xdr, args->bitmask, &hdr);
1495 encode_restorefh(&xdr, &hdr);
1496 encode_getfattr(&xdr, args->bitmask, &hdr);
1502 * Encode LINK request
1504 static int nfs4_xdr_enc_link(struct rpc_rqst *req, __be32 *p, const struct nfs4_link_arg *args)
1506 struct xdr_stream xdr;
1507 struct compound_hdr hdr = {
1508 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
1511 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1512 encode_compound_hdr(&xdr, req, &hdr);
1513 encode_putfh(&xdr, args->fh, &hdr);
1514 encode_savefh(&xdr, &hdr);
1515 encode_putfh(&xdr, args->dir_fh, &hdr);
1516 encode_link(&xdr, args->name, &hdr);
1517 encode_getfattr(&xdr, args->bitmask, &hdr);
1518 encode_restorefh(&xdr, &hdr);
1519 encode_getfattr(&xdr, args->bitmask, &hdr);
1525 * Encode CREATE request
1527 static int nfs4_xdr_enc_create(struct rpc_rqst *req, __be32 *p, const struct nfs4_create_arg *args)
1529 struct xdr_stream xdr;
1530 struct compound_hdr hdr = {
1531 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
1534 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1535 encode_compound_hdr(&xdr, req, &hdr);
1536 encode_putfh(&xdr, args->dir_fh, &hdr);
1537 encode_savefh(&xdr, &hdr);
1538 encode_create(&xdr, args, &hdr);
1539 encode_getfh(&xdr, &hdr);
1540 encode_getfattr(&xdr, args->bitmask, &hdr);
1541 encode_restorefh(&xdr, &hdr);
1542 encode_getfattr(&xdr, args->bitmask, &hdr);
1548 * Encode SYMLINK request
1550 static int nfs4_xdr_enc_symlink(struct rpc_rqst *req, __be32 *p, const struct nfs4_create_arg *args)
1552 return nfs4_xdr_enc_create(req, p, args);
1556 * Encode GETATTR request
1558 static int nfs4_xdr_enc_getattr(struct rpc_rqst *req, __be32 *p, const struct nfs4_getattr_arg *args)
1560 struct xdr_stream xdr;
1561 struct compound_hdr hdr = {
1562 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
1565 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1566 encode_compound_hdr(&xdr, req, &hdr);
1567 encode_putfh(&xdr, args->fh, &hdr);
1568 encode_getfattr(&xdr, args->bitmask, &hdr);
1574 * Encode a CLOSE request
1576 static int nfs4_xdr_enc_close(struct rpc_rqst *req, __be32 *p, struct nfs_closeargs *args)
1578 struct xdr_stream xdr;
1579 struct compound_hdr hdr = {
1580 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
1583 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1584 encode_compound_hdr(&xdr, req, &hdr);
1585 encode_putfh(&xdr, args->fh, &hdr);
1586 encode_close(&xdr, args, &hdr);
1587 encode_getfattr(&xdr, args->bitmask, &hdr);
1593 * Encode an OPEN request
1595 static int nfs4_xdr_enc_open(struct rpc_rqst *req, __be32 *p, struct nfs_openargs *args)
1597 struct xdr_stream xdr;
1598 struct compound_hdr hdr = {
1599 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
1602 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1603 encode_compound_hdr(&xdr, req, &hdr);
1604 encode_putfh(&xdr, args->fh, &hdr);
1605 encode_savefh(&xdr, &hdr);
1606 encode_open(&xdr, args, &hdr);
1607 encode_getfh(&xdr, &hdr);
1608 encode_getfattr(&xdr, args->bitmask, &hdr);
1609 encode_restorefh(&xdr, &hdr);
1610 encode_getfattr(&xdr, args->bitmask, &hdr);
1616 * Encode an OPEN_CONFIRM request
1618 static int nfs4_xdr_enc_open_confirm(struct rpc_rqst *req, __be32 *p, struct nfs_open_confirmargs *args)
1620 struct xdr_stream xdr;
1621 struct compound_hdr hdr = {
1625 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1626 encode_compound_hdr(&xdr, req, &hdr);
1627 encode_putfh(&xdr, args->fh, &hdr);
1628 encode_open_confirm(&xdr, args, &hdr);
1634 * Encode an OPEN request with no attributes.
1636 static int nfs4_xdr_enc_open_noattr(struct rpc_rqst *req, __be32 *p, struct nfs_openargs *args)
1638 struct xdr_stream xdr;
1639 struct compound_hdr hdr = {
1640 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
1643 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1644 encode_compound_hdr(&xdr, req, &hdr);
1645 encode_putfh(&xdr, args->fh, &hdr);
1646 encode_open(&xdr, args, &hdr);
1647 encode_getfattr(&xdr, args->bitmask, &hdr);
1653 * Encode an OPEN_DOWNGRADE request
1655 static int nfs4_xdr_enc_open_downgrade(struct rpc_rqst *req, __be32 *p, struct nfs_closeargs *args)
1657 struct xdr_stream xdr;
1658 struct compound_hdr hdr = {
1659 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
1662 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1663 encode_compound_hdr(&xdr, req, &hdr);
1664 encode_putfh(&xdr, args->fh, &hdr);
1665 encode_open_downgrade(&xdr, args, &hdr);
1666 encode_getfattr(&xdr, args->bitmask, &hdr);
1672 * Encode a LOCK request
1674 static int nfs4_xdr_enc_lock(struct rpc_rqst *req, __be32 *p, struct nfs_lock_args *args)
1676 struct xdr_stream xdr;
1677 struct compound_hdr hdr = {
1678 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
1681 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1682 encode_compound_hdr(&xdr, req, &hdr);
1683 encode_putfh(&xdr, args->fh, &hdr);
1684 encode_lock(&xdr, args, &hdr);
1690 * Encode a LOCKT request
1692 static int nfs4_xdr_enc_lockt(struct rpc_rqst *req, __be32 *p, struct nfs_lockt_args *args)
1694 struct xdr_stream xdr;
1695 struct compound_hdr hdr = {
1696 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
1699 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1700 encode_compound_hdr(&xdr, req, &hdr);
1701 encode_putfh(&xdr, args->fh, &hdr);
1702 encode_lockt(&xdr, args, &hdr);
1708 * Encode a LOCKU request
1710 static int nfs4_xdr_enc_locku(struct rpc_rqst *req, __be32 *p, struct nfs_locku_args *args)
1712 struct xdr_stream xdr;
1713 struct compound_hdr hdr = {
1714 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
1717 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1718 encode_compound_hdr(&xdr, req, &hdr);
1719 encode_putfh(&xdr, args->fh, &hdr);
1720 encode_locku(&xdr, args, &hdr);
1726 * Encode a READLINK request
1728 static int nfs4_xdr_enc_readlink(struct rpc_rqst *req, __be32 *p, const struct nfs4_readlink *args)
1730 struct xdr_stream xdr;
1731 struct compound_hdr hdr = {
1732 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
1735 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1736 encode_compound_hdr(&xdr, req, &hdr);
1737 encode_putfh(&xdr, args->fh, &hdr);
1738 encode_readlink(&xdr, args, req, &hdr);
1740 xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, args->pages,
1741 args->pgbase, args->pglen);
1747 * Encode a READDIR request
1749 static int nfs4_xdr_enc_readdir(struct rpc_rqst *req, __be32 *p, const struct nfs4_readdir_arg *args)
1751 struct xdr_stream xdr;
1752 struct compound_hdr hdr = {
1753 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
1756 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1757 encode_compound_hdr(&xdr, req, &hdr);
1758 encode_putfh(&xdr, args->fh, &hdr);
1759 encode_readdir(&xdr, args, req, &hdr);
1761 xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, args->pages,
1762 args->pgbase, args->count);
1763 dprintk("%s: inlined page args = (%u, %p, %u, %u)\n",
1764 __func__, hdr.replen << 2, args->pages,
1765 args->pgbase, args->count);
1771 * Encode a READ request
1773 static int nfs4_xdr_enc_read(struct rpc_rqst *req, __be32 *p, struct nfs_readargs *args)
1775 struct xdr_stream xdr;
1776 struct compound_hdr hdr = {
1777 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
1780 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1781 encode_compound_hdr(&xdr, req, &hdr);
1782 encode_putfh(&xdr, args->fh, &hdr);
1783 encode_read(&xdr, args, &hdr);
1785 xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2,
1786 args->pages, args->pgbase, args->count);
1787 req->rq_rcv_buf.flags |= XDRBUF_READ;
1793 * Encode an SETATTR request
1795 static int nfs4_xdr_enc_setattr(struct rpc_rqst *req, __be32 *p, struct nfs_setattrargs *args)
1797 struct xdr_stream xdr;
1798 struct compound_hdr hdr = {
1799 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
1802 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1803 encode_compound_hdr(&xdr, req, &hdr);
1804 encode_putfh(&xdr, args->fh, &hdr);
1805 encode_setattr(&xdr, args, args->server, &hdr);
1806 encode_getfattr(&xdr, args->bitmask, &hdr);
1812 * Encode a GETACL request
1815 nfs4_xdr_enc_getacl(struct rpc_rqst *req, __be32 *p,
1816 struct nfs_getaclargs *args)
1818 struct xdr_stream xdr;
1819 struct compound_hdr hdr = {
1820 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
1824 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1825 encode_compound_hdr(&xdr, req, &hdr);
1826 encode_putfh(&xdr, args->fh, &hdr);
1827 replen = hdr.replen + nfs4_fattr_bitmap_maxsz + 1;
1828 encode_getattr_two(&xdr, FATTR4_WORD0_ACL, 0, &hdr);
1830 xdr_inline_pages(&req->rq_rcv_buf, replen << 2,
1831 args->acl_pages, args->acl_pgbase, args->acl_len);
1837 * Encode a WRITE request
1839 static int nfs4_xdr_enc_write(struct rpc_rqst *req, __be32 *p, struct nfs_writeargs *args)
1841 struct xdr_stream xdr;
1842 struct compound_hdr hdr = {
1843 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
1846 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1847 encode_compound_hdr(&xdr, req, &hdr);
1848 encode_putfh(&xdr, args->fh, &hdr);
1849 encode_write(&xdr, args, &hdr);
1850 req->rq_snd_buf.flags |= XDRBUF_WRITE;
1851 encode_getfattr(&xdr, args->bitmask, &hdr);
1859 static int nfs4_xdr_enc_commit(struct rpc_rqst *req, __be32 *p, struct nfs_writeargs *args)
1861 struct xdr_stream xdr;
1862 struct compound_hdr hdr = {
1863 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
1866 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1867 encode_compound_hdr(&xdr, req, &hdr);
1868 encode_putfh(&xdr, args->fh, &hdr);
1869 encode_commit(&xdr, args, &hdr);
1870 encode_getfattr(&xdr, args->bitmask, &hdr);
1878 static int nfs4_xdr_enc_fsinfo(struct rpc_rqst *req, __be32 *p, struct nfs4_fsinfo_arg *args)
1880 struct xdr_stream xdr;
1881 struct compound_hdr hdr = {
1882 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
1885 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1886 encode_compound_hdr(&xdr, req, &hdr);
1887 encode_putfh(&xdr, args->fh, &hdr);
1888 encode_fsinfo(&xdr, args->bitmask, &hdr);
1894 * a PATHCONF request
1896 static int nfs4_xdr_enc_pathconf(struct rpc_rqst *req, __be32 *p, const struct nfs4_pathconf_arg *args)
1898 struct xdr_stream xdr;
1899 struct compound_hdr hdr = {
1900 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
1903 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1904 encode_compound_hdr(&xdr, req, &hdr);
1905 encode_putfh(&xdr, args->fh, &hdr);
1906 encode_getattr_one(&xdr, args->bitmask[0] & nfs4_pathconf_bitmap[0],
1915 static int nfs4_xdr_enc_statfs(struct rpc_rqst *req, __be32 *p, const struct nfs4_statfs_arg *args)
1917 struct xdr_stream xdr;
1918 struct compound_hdr hdr = {
1919 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
1922 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1923 encode_compound_hdr(&xdr, req, &hdr);
1924 encode_putfh(&xdr, args->fh, &hdr);
1925 encode_getattr_two(&xdr, args->bitmask[0] & nfs4_statfs_bitmap[0],
1926 args->bitmask[1] & nfs4_statfs_bitmap[1], &hdr);
1932 * GETATTR_BITMAP request
1934 static int nfs4_xdr_enc_server_caps(struct rpc_rqst *req, __be32 *p,
1935 struct nfs4_server_caps_arg *args)
1937 struct xdr_stream xdr;
1938 struct compound_hdr hdr = {
1939 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
1942 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1943 encode_compound_hdr(&xdr, req, &hdr);
1944 encode_putfh(&xdr, args->fhandle, &hdr);
1945 encode_getattr_one(&xdr, FATTR4_WORD0_SUPPORTED_ATTRS|
1946 FATTR4_WORD0_LINK_SUPPORT|
1947 FATTR4_WORD0_SYMLINK_SUPPORT|
1948 FATTR4_WORD0_ACLSUPPORT, &hdr);
1956 static int nfs4_xdr_enc_renew(struct rpc_rqst *req, __be32 *p, struct nfs_client *clp)
1958 struct xdr_stream xdr;
1959 struct compound_hdr hdr = {
1963 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1964 encode_compound_hdr(&xdr, req, &hdr);
1965 encode_renew(&xdr, clp, &hdr);
1971 * a SETCLIENTID request
1973 static int nfs4_xdr_enc_setclientid(struct rpc_rqst *req, __be32 *p, struct nfs4_setclientid *sc)
1975 struct xdr_stream xdr;
1976 struct compound_hdr hdr = {
1980 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1981 encode_compound_hdr(&xdr, req, &hdr);
1982 encode_setclientid(&xdr, sc, &hdr);
1988 * a SETCLIENTID_CONFIRM request
1990 static int nfs4_xdr_enc_setclientid_confirm(struct rpc_rqst *req, __be32 *p, struct nfs_client *clp)
1992 struct xdr_stream xdr;
1993 struct compound_hdr hdr = {
1996 const u32 lease_bitmap[2] = { FATTR4_WORD0_LEASE_TIME, 0 };
1998 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1999 encode_compound_hdr(&xdr, req, &hdr);
2000 encode_setclientid_confirm(&xdr, clp, &hdr);
2001 encode_putrootfh(&xdr, &hdr);
2002 encode_fsinfo(&xdr, lease_bitmap, &hdr);
2008 * DELEGRETURN request
2010 static int nfs4_xdr_enc_delegreturn(struct rpc_rqst *req, __be32 *p, const struct nfs4_delegreturnargs *args)
2012 struct xdr_stream xdr;
2013 struct compound_hdr hdr = {
2014 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2017 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
2018 encode_compound_hdr(&xdr, req, &hdr);
2019 encode_putfh(&xdr, args->fhandle, &hdr);
2020 encode_delegreturn(&xdr, args->stateid, &hdr);
2021 encode_getfattr(&xdr, args->bitmask, &hdr);
2027 * Encode FS_LOCATIONS request
2029 static int nfs4_xdr_enc_fs_locations(struct rpc_rqst *req, __be32 *p, struct nfs4_fs_locations_arg *args)
2031 struct xdr_stream xdr;
2032 struct compound_hdr hdr = {
2033 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2037 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
2038 encode_compound_hdr(&xdr, req, &hdr);
2039 encode_putfh(&xdr, args->dir_fh, &hdr);
2040 encode_lookup(&xdr, args->name, &hdr);
2041 replen = hdr.replen; /* get the attribute into args->page */
2042 encode_fs_locations(&xdr, args->bitmask, &hdr);
2044 xdr_inline_pages(&req->rq_rcv_buf, replen << 2, &args->page,
2051 * START OF "GENERIC" DECODE ROUTINES.
2052 * These may look a little ugly since they are imported from a "generic"
2053 * set of XDR encode/decode routines which are intended to be shared by
2054 * all of our NFSv4 implementations (OpenBSD, MacOS X...).
2056 * If the pain of reading these is too great, it should be a straightforward
2057 * task to translate them into Linux-specific versions which are more
2058 * consistent with the style used in NFSv2/v3...
2060 #define READ32(x) (x) = ntohl(*p++)
2061 #define READ64(x) do { \
2062 (x) = (u64)ntohl(*p++) << 32; \
2063 (x) |= ntohl(*p++); \
2065 #define READTIME(x) do { \
2067 (x.tv_sec) = ntohl(*p++); \
2068 (x.tv_nsec) = ntohl(*p++); \
2070 #define COPYMEM(x,nbytes) do { \
2071 memcpy((x), p, nbytes); \
2072 p += XDR_QUADLEN(nbytes); \
2075 #define READ_BUF(nbytes) do { \
2076 p = xdr_inline_decode(xdr, nbytes); \
2077 if (unlikely(!p)) { \
2078 dprintk("nfs: %s: prematurely hit end of receive" \
2079 " buffer\n", __func__); \
2080 dprintk("nfs: %s: xdr->p=%p, bytes=%u, xdr->end=%p\n", \
2081 __func__, xdr->p, nbytes, xdr->end); \
2086 static int decode_opaque_inline(struct xdr_stream *xdr, unsigned int *len, char **string)
2093 *string = (char *)p;
2097 static int decode_compound_hdr(struct xdr_stream *xdr, struct compound_hdr *hdr)
2102 READ32(hdr->status);
2103 READ32(hdr->taglen);
2105 READ_BUF(hdr->taglen + 4);
2106 hdr->tag = (char *)p;
2107 p += XDR_QUADLEN(hdr->taglen);
2109 if (unlikely(hdr->nops < 1))
2110 return nfs4_stat_to_errno(hdr->status);
2114 static int decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected)
2122 if (opnum != expected) {
2123 dprintk("nfs: Server returned operation"
2124 " %d but we issued a request for %d\n",
2129 if (nfserr != NFS_OK)
2130 return nfs4_stat_to_errno(nfserr);
2135 static int decode_ace(struct xdr_stream *xdr, void *ace, struct nfs_client *clp)
2138 unsigned int strlen;
2142 return decode_opaque_inline(xdr, &strlen, &str);
2145 static int decode_attr_bitmap(struct xdr_stream *xdr, uint32_t *bitmap)
2153 bitmap[0] = bitmap[1] = 0;
2154 READ_BUF((bmlen << 2));
2163 static inline int decode_attr_length(struct xdr_stream *xdr, uint32_t *attrlen, __be32 **savep)
2173 static int decode_attr_supported(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *bitmask)
2175 if (likely(bitmap[0] & FATTR4_WORD0_SUPPORTED_ATTRS)) {
2176 decode_attr_bitmap(xdr, bitmask);
2177 bitmap[0] &= ~FATTR4_WORD0_SUPPORTED_ATTRS;
2179 bitmask[0] = bitmask[1] = 0;
2180 dprintk("%s: bitmask=%08x:%08x\n", __func__, bitmask[0], bitmask[1]);
2184 static int decode_attr_type(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *type)
2190 if (unlikely(bitmap[0] & (FATTR4_WORD0_TYPE - 1U)))
2192 if (likely(bitmap[0] & FATTR4_WORD0_TYPE)) {
2195 if (*type < NF4REG || *type > NF4NAMEDATTR) {
2196 dprintk("%s: bad type %d\n", __func__, *type);
2199 bitmap[0] &= ~FATTR4_WORD0_TYPE;
2200 ret = NFS_ATTR_FATTR_TYPE;
2202 dprintk("%s: type=0%o\n", __func__, nfs_type2fmt[*type]);
2206 static int decode_attr_change(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *change)
2212 if (unlikely(bitmap[0] & (FATTR4_WORD0_CHANGE - 1U)))
2214 if (likely(bitmap[0] & FATTR4_WORD0_CHANGE)) {
2217 bitmap[0] &= ~FATTR4_WORD0_CHANGE;
2218 ret = NFS_ATTR_FATTR_CHANGE;
2220 dprintk("%s: change attribute=%Lu\n", __func__,
2221 (unsigned long long)*change);
2225 static int decode_attr_size(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *size)
2231 if (unlikely(bitmap[0] & (FATTR4_WORD0_SIZE - 1U)))
2233 if (likely(bitmap[0] & FATTR4_WORD0_SIZE)) {
2236 bitmap[0] &= ~FATTR4_WORD0_SIZE;
2237 ret = NFS_ATTR_FATTR_SIZE;
2239 dprintk("%s: file size=%Lu\n", __func__, (unsigned long long)*size);
2243 static int decode_attr_link_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
2248 if (unlikely(bitmap[0] & (FATTR4_WORD0_LINK_SUPPORT - 1U)))
2250 if (likely(bitmap[0] & FATTR4_WORD0_LINK_SUPPORT)) {
2253 bitmap[0] &= ~FATTR4_WORD0_LINK_SUPPORT;
2255 dprintk("%s: link support=%s\n", __func__, *res == 0 ? "false" : "true");
2259 static int decode_attr_symlink_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
2264 if (unlikely(bitmap[0] & (FATTR4_WORD0_SYMLINK_SUPPORT - 1U)))
2266 if (likely(bitmap[0] & FATTR4_WORD0_SYMLINK_SUPPORT)) {
2269 bitmap[0] &= ~FATTR4_WORD0_SYMLINK_SUPPORT;
2271 dprintk("%s: symlink support=%s\n", __func__, *res == 0 ? "false" : "true");
2275 static int decode_attr_fsid(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs_fsid *fsid)
2282 if (unlikely(bitmap[0] & (FATTR4_WORD0_FSID - 1U)))
2284 if (likely(bitmap[0] & FATTR4_WORD0_FSID)) {
2286 READ64(fsid->major);
2287 READ64(fsid->minor);
2288 bitmap[0] &= ~FATTR4_WORD0_FSID;
2289 ret = NFS_ATTR_FATTR_FSID;
2291 dprintk("%s: fsid=(0x%Lx/0x%Lx)\n", __func__,
2292 (unsigned long long)fsid->major,
2293 (unsigned long long)fsid->minor);
2297 static int decode_attr_lease_time(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
2302 if (unlikely(bitmap[0] & (FATTR4_WORD0_LEASE_TIME - 1U)))
2304 if (likely(bitmap[0] & FATTR4_WORD0_LEASE_TIME)) {
2307 bitmap[0] &= ~FATTR4_WORD0_LEASE_TIME;
2309 dprintk("%s: file size=%u\n", __func__, (unsigned int)*res);
2313 static int decode_attr_aclsupport(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
2317 *res = ACL4_SUPPORT_ALLOW_ACL|ACL4_SUPPORT_DENY_ACL;
2318 if (unlikely(bitmap[0] & (FATTR4_WORD0_ACLSUPPORT - 1U)))
2320 if (likely(bitmap[0] & FATTR4_WORD0_ACLSUPPORT)) {
2323 bitmap[0] &= ~FATTR4_WORD0_ACLSUPPORT;
2325 dprintk("%s: ACLs supported=%u\n", __func__, (unsigned int)*res);
2329 static int decode_attr_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid)
2335 if (unlikely(bitmap[0] & (FATTR4_WORD0_FILEID - 1U)))
2337 if (likely(bitmap[0] & FATTR4_WORD0_FILEID)) {
2340 bitmap[0] &= ~FATTR4_WORD0_FILEID;
2341 ret = NFS_ATTR_FATTR_FILEID;
2343 dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid);
2347 static int decode_attr_mounted_on_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid)
2353 if (unlikely(bitmap[1] & (FATTR4_WORD1_MOUNTED_ON_FILEID - 1U)))
2355 if (likely(bitmap[1] & FATTR4_WORD1_MOUNTED_ON_FILEID)) {
2358 bitmap[1] &= ~FATTR4_WORD1_MOUNTED_ON_FILEID;
2359 ret = NFS_ATTR_FATTR_FILEID;
2361 dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid);
2365 static int decode_attr_files_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
2371 if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_AVAIL - 1U)))
2373 if (likely(bitmap[0] & FATTR4_WORD0_FILES_AVAIL)) {
2376 bitmap[0] &= ~FATTR4_WORD0_FILES_AVAIL;
2378 dprintk("%s: files avail=%Lu\n", __func__, (unsigned long long)*res);
2382 static int decode_attr_files_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
2388 if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_FREE - 1U)))
2390 if (likely(bitmap[0] & FATTR4_WORD0_FILES_FREE)) {
2393 bitmap[0] &= ~FATTR4_WORD0_FILES_FREE;
2395 dprintk("%s: files free=%Lu\n", __func__, (unsigned long long)*res);
2399 static int decode_attr_files_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
2405 if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_TOTAL - 1U)))
2407 if (likely(bitmap[0] & FATTR4_WORD0_FILES_TOTAL)) {
2410 bitmap[0] &= ~FATTR4_WORD0_FILES_TOTAL;
2412 dprintk("%s: files total=%Lu\n", __func__, (unsigned long long)*res);
2416 static int decode_pathname(struct xdr_stream *xdr, struct nfs4_pathname *path)
2427 path->ncomponents = 0;
2428 while (path->ncomponents < n) {
2429 struct nfs4_string *component = &path->components[path->ncomponents];
2430 status = decode_opaque_inline(xdr, &component->len, &component->data);
2431 if (unlikely(status != 0))
2433 if (path->ncomponents != n)
2435 dprintk("%s", component->data);
2436 if (path->ncomponents < NFS4_PATHNAME_MAXCOMPONENTS)
2437 path->ncomponents++;
2439 dprintk("cannot parse %d components in path\n", n);
2447 /* a root pathname is sent as a zero component4 */
2448 path->ncomponents = 1;
2449 path->components[0].len=0;
2450 path->components[0].data=NULL;
2451 dprintk("path /\n");
2454 dprintk(" status %d", status);
2459 static int decode_attr_fs_locations(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs4_fs_locations *res)
2465 if (unlikely(bitmap[0] & (FATTR4_WORD0_FS_LOCATIONS -1U)))
2468 if (unlikely(!(bitmap[0] & FATTR4_WORD0_FS_LOCATIONS)))
2470 dprintk("%s: fsroot ", __func__);
2471 status = decode_pathname(xdr, &res->fs_path);
2472 if (unlikely(status != 0))
2478 res->nlocations = 0;
2479 while (res->nlocations < n) {
2481 struct nfs4_fs_location *loc = &res->locations[res->nlocations];
2487 dprintk("%s: servers ", __func__);
2488 while (loc->nservers < m) {
2489 struct nfs4_string *server = &loc->servers[loc->nservers];
2490 status = decode_opaque_inline(xdr, &server->len, &server->data);
2491 if (unlikely(status != 0))
2493 dprintk("%s ", server->data);
2494 if (loc->nservers < NFS4_FS_LOCATION_MAXSERVERS)
2498 dprintk("%s: using first %u of %u servers "
2499 "returned for location %u\n",
2501 NFS4_FS_LOCATION_MAXSERVERS,
2502 m, res->nlocations);
2503 for (i = loc->nservers; i < m; i++) {
2506 status = decode_opaque_inline(xdr, &len, &data);
2507 if (unlikely(status != 0))
2512 status = decode_pathname(xdr, &loc->rootpath);
2513 if (unlikely(status != 0))
2515 if (res->nlocations < NFS4_FS_LOCATIONS_MAXENTRIES)
2518 if (res->nlocations != 0)
2519 status = NFS_ATTR_FATTR_V4_REFERRAL;
2521 dprintk("%s: fs_locations done, error = %d\n", __func__, status);
2528 static int decode_attr_maxfilesize(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
2534 if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXFILESIZE - 1U)))
2536 if (likely(bitmap[0] & FATTR4_WORD0_MAXFILESIZE)) {
2539 bitmap[0] &= ~FATTR4_WORD0_MAXFILESIZE;
2541 dprintk("%s: maxfilesize=%Lu\n", __func__, (unsigned long long)*res);
2545 static int decode_attr_maxlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxlink)
2551 if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXLINK - 1U)))
2553 if (likely(bitmap[0] & FATTR4_WORD0_MAXLINK)) {
2556 bitmap[0] &= ~FATTR4_WORD0_MAXLINK;
2558 dprintk("%s: maxlink=%u\n", __func__, *maxlink);
2562 static int decode_attr_maxname(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxname)
2568 if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXNAME - 1U)))
2570 if (likely(bitmap[0] & FATTR4_WORD0_MAXNAME)) {
2573 bitmap[0] &= ~FATTR4_WORD0_MAXNAME;
2575 dprintk("%s: maxname=%u\n", __func__, *maxname);
2579 static int decode_attr_maxread(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
2585 if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXREAD - 1U)))
2587 if (likely(bitmap[0] & FATTR4_WORD0_MAXREAD)) {
2591 if (maxread > 0x7FFFFFFF)
2592 maxread = 0x7FFFFFFF;
2593 *res = (uint32_t)maxread;
2594 bitmap[0] &= ~FATTR4_WORD0_MAXREAD;
2596 dprintk("%s: maxread=%lu\n", __func__, (unsigned long)*res);
2600 static int decode_attr_maxwrite(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
2606 if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXWRITE - 1U)))
2608 if (likely(bitmap[0] & FATTR4_WORD0_MAXWRITE)) {
2612 if (maxwrite > 0x7FFFFFFF)
2613 maxwrite = 0x7FFFFFFF;
2614 *res = (uint32_t)maxwrite;
2615 bitmap[0] &= ~FATTR4_WORD0_MAXWRITE;
2617 dprintk("%s: maxwrite=%lu\n", __func__, (unsigned long)*res);
2621 static int decode_attr_mode(struct xdr_stream *xdr, uint32_t *bitmap, umode_t *mode)
2628 if (unlikely(bitmap[1] & (FATTR4_WORD1_MODE - 1U)))
2630 if (likely(bitmap[1] & FATTR4_WORD1_MODE)) {
2633 *mode = tmp & ~S_IFMT;
2634 bitmap[1] &= ~FATTR4_WORD1_MODE;
2635 ret = NFS_ATTR_FATTR_MODE;
2637 dprintk("%s: file mode=0%o\n", __func__, (unsigned int)*mode);
2641 static int decode_attr_nlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *nlink)
2647 if (unlikely(bitmap[1] & (FATTR4_WORD1_NUMLINKS - 1U)))
2649 if (likely(bitmap[1] & FATTR4_WORD1_NUMLINKS)) {
2652 bitmap[1] &= ~FATTR4_WORD1_NUMLINKS;
2653 ret = NFS_ATTR_FATTR_NLINK;
2655 dprintk("%s: nlink=%u\n", __func__, (unsigned int)*nlink);
2659 static int decode_attr_owner(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs_client *clp, uint32_t *uid)
2666 if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER - 1U)))
2668 if (likely(bitmap[1] & FATTR4_WORD1_OWNER)) {
2672 if (len < XDR_MAX_NETOBJ) {
2673 if (nfs_map_name_to_uid(clp, (char *)p, len, uid) == 0)
2674 ret = NFS_ATTR_FATTR_OWNER;
2676 dprintk("%s: nfs_map_name_to_uid failed!\n",
2679 dprintk("%s: name too long (%u)!\n",
2681 bitmap[1] &= ~FATTR4_WORD1_OWNER;
2683 dprintk("%s: uid=%d\n", __func__, (int)*uid);
2687 static int decode_attr_group(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs_client *clp, uint32_t *gid)
2694 if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER_GROUP - 1U)))
2696 if (likely(bitmap[1] & FATTR4_WORD1_OWNER_GROUP)) {
2700 if (len < XDR_MAX_NETOBJ) {
2701 if (nfs_map_group_to_gid(clp, (char *)p, len, gid) == 0)
2702 ret = NFS_ATTR_FATTR_GROUP;
2704 dprintk("%s: nfs_map_group_to_gid failed!\n",
2707 dprintk("%s: name too long (%u)!\n",
2709 bitmap[1] &= ~FATTR4_WORD1_OWNER_GROUP;
2711 dprintk("%s: gid=%d\n", __func__, (int)*gid);
2715 static int decode_attr_rdev(struct xdr_stream *xdr, uint32_t *bitmap, dev_t *rdev)
2717 uint32_t major = 0, minor = 0;
2722 if (unlikely(bitmap[1] & (FATTR4_WORD1_RAWDEV - 1U)))
2724 if (likely(bitmap[1] & FATTR4_WORD1_RAWDEV)) {
2730 tmp = MKDEV(major, minor);
2731 if (MAJOR(tmp) == major && MINOR(tmp) == minor)
2733 bitmap[1] &= ~ FATTR4_WORD1_RAWDEV;
2734 ret = NFS_ATTR_FATTR_RDEV;
2736 dprintk("%s: rdev=(0x%x:0x%x)\n", __func__, major, minor);
2740 static int decode_attr_space_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
2746 if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_AVAIL - 1U)))
2748 if (likely(bitmap[1] & FATTR4_WORD1_SPACE_AVAIL)) {
2751 bitmap[1] &= ~FATTR4_WORD1_SPACE_AVAIL;
2753 dprintk("%s: space avail=%Lu\n", __func__, (unsigned long long)*res);
2757 static int decode_attr_space_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
2763 if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_FREE - 1U)))
2765 if (likely(bitmap[1] & FATTR4_WORD1_SPACE_FREE)) {
2768 bitmap[1] &= ~FATTR4_WORD1_SPACE_FREE;
2770 dprintk("%s: space free=%Lu\n", __func__, (unsigned long long)*res);
2774 static int decode_attr_space_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
2780 if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_TOTAL - 1U)))
2782 if (likely(bitmap[1] & FATTR4_WORD1_SPACE_TOTAL)) {
2785 bitmap[1] &= ~FATTR4_WORD1_SPACE_TOTAL;
2787 dprintk("%s: space total=%Lu\n", __func__, (unsigned long long)*res);
2791 static int decode_attr_space_used(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *used)
2797 if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_USED - 1U)))
2799 if (likely(bitmap[1] & FATTR4_WORD1_SPACE_USED)) {
2802 bitmap[1] &= ~FATTR4_WORD1_SPACE_USED;
2803 ret = NFS_ATTR_FATTR_SPACE_USED;
2805 dprintk("%s: space used=%Lu\n", __func__,
2806 (unsigned long long)*used);
2810 static int decode_attr_time(struct xdr_stream *xdr, struct timespec *time)
2819 time->tv_sec = (time_t)sec;
2820 time->tv_nsec = (long)nsec;
2824 static int decode_attr_time_access(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time)
2830 if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_ACCESS - 1U)))
2832 if (likely(bitmap[1] & FATTR4_WORD1_TIME_ACCESS)) {
2833 status = decode_attr_time(xdr, time);
2835 status = NFS_ATTR_FATTR_ATIME;
2836 bitmap[1] &= ~FATTR4_WORD1_TIME_ACCESS;
2838 dprintk("%s: atime=%ld\n", __func__, (long)time->tv_sec);
2842 static int decode_attr_time_metadata(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time)
2848 if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_METADATA - 1U)))
2850 if (likely(bitmap[1] & FATTR4_WORD1_TIME_METADATA)) {
2851 status = decode_attr_time(xdr, time);
2853 status = NFS_ATTR_FATTR_CTIME;
2854 bitmap[1] &= ~FATTR4_WORD1_TIME_METADATA;
2856 dprintk("%s: ctime=%ld\n", __func__, (long)time->tv_sec);
2860 static int decode_attr_time_modify(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time)
2866 if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_MODIFY - 1U)))
2868 if (likely(bitmap[1] & FATTR4_WORD1_TIME_MODIFY)) {
2869 status = decode_attr_time(xdr, time);
2871 status = NFS_ATTR_FATTR_MTIME;
2872 bitmap[1] &= ~FATTR4_WORD1_TIME_MODIFY;
2874 dprintk("%s: mtime=%ld\n", __func__, (long)time->tv_sec);
2878 static int verify_attr_len(struct xdr_stream *xdr, __be32 *savep, uint32_t attrlen)
2880 unsigned int attrwords = XDR_QUADLEN(attrlen);
2881 unsigned int nwords = xdr->p - savep;
2883 if (unlikely(attrwords != nwords)) {
2884 dprintk("%s: server returned incorrect attribute length: "
2888 (attrwords < nwords) ? '<' : '>',
2895 static int decode_change_info(struct xdr_stream *xdr, struct nfs4_change_info *cinfo)
2900 READ32(cinfo->atomic);
2901 READ64(cinfo->before);
2902 READ64(cinfo->after);
2906 static int decode_access(struct xdr_stream *xdr, struct nfs4_accessres *access)
2912 status = decode_op_hdr(xdr, OP_ACCESS);
2918 access->supported = supp;
2919 access->access = acc;
2923 static int decode_close(struct xdr_stream *xdr, struct nfs_closeres *res)
2928 status = decode_op_hdr(xdr, OP_CLOSE);
2930 nfs_increment_open_seqid(status, res->seqid);
2933 READ_BUF(NFS4_STATEID_SIZE);
2934 COPYMEM(res->stateid.data, NFS4_STATEID_SIZE);
2938 static int decode_commit(struct xdr_stream *xdr, struct nfs_writeres *res)
2943 status = decode_op_hdr(xdr, OP_COMMIT);
2947 COPYMEM(res->verf->verifier, 8);
2951 static int decode_create(struct xdr_stream *xdr, struct nfs4_change_info *cinfo)
2957 status = decode_op_hdr(xdr, OP_CREATE);
2960 if ((status = decode_change_info(xdr, cinfo)))
2964 READ_BUF(bmlen << 2);
2968 static int decode_server_caps(struct xdr_stream *xdr, struct nfs4_server_caps_res *res)
2971 uint32_t attrlen, bitmap[2] = {0};
2974 if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0)
2976 if ((status = decode_attr_bitmap(xdr, bitmap)) != 0)
2978 if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0)
2980 if ((status = decode_attr_supported(xdr, bitmap, res->attr_bitmask)) != 0)
2982 if ((status = decode_attr_link_support(xdr, bitmap, &res->has_links)) != 0)
2984 if ((status = decode_attr_symlink_support(xdr, bitmap, &res->has_symlinks)) != 0)
2986 if ((status = decode_attr_aclsupport(xdr, bitmap, &res->acl_bitmask)) != 0)
2988 status = verify_attr_len(xdr, savep, attrlen);
2990 dprintk("%s: xdr returned %d!\n", __func__, -status);
2994 static int decode_statfs(struct xdr_stream *xdr, struct nfs_fsstat *fsstat)
2997 uint32_t attrlen, bitmap[2] = {0};
3000 if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0)
3002 if ((status = decode_attr_bitmap(xdr, bitmap)) != 0)
3004 if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0)
3007 if ((status = decode_attr_files_avail(xdr, bitmap, &fsstat->afiles)) != 0)
3009 if ((status = decode_attr_files_free(xdr, bitmap, &fsstat->ffiles)) != 0)
3011 if ((status = decode_attr_files_total(xdr, bitmap, &fsstat->tfiles)) != 0)
3013 if ((status = decode_attr_space_avail(xdr, bitmap, &fsstat->abytes)) != 0)
3015 if ((status = decode_attr_space_free(xdr, bitmap, &fsstat->fbytes)) != 0)
3017 if ((status = decode_attr_space_total(xdr, bitmap, &fsstat->tbytes)) != 0)
3020 status = verify_attr_len(xdr, savep, attrlen);
3022 dprintk("%s: xdr returned %d!\n", __func__, -status);
3026 static int decode_pathconf(struct xdr_stream *xdr, struct nfs_pathconf *pathconf)
3029 uint32_t attrlen, bitmap[2] = {0};
3032 if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0)
3034 if ((status = decode_attr_bitmap(xdr, bitmap)) != 0)
3036 if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0)
3039 if ((status = decode_attr_maxlink(xdr, bitmap, &pathconf->max_link)) != 0)
3041 if ((status = decode_attr_maxname(xdr, bitmap, &pathconf->max_namelen)) != 0)
3044 status = verify_attr_len(xdr, savep, attrlen);
3046 dprintk("%s: xdr returned %d!\n", __func__, -status);
3050 static int decode_getfattr(struct xdr_stream *xdr, struct nfs_fattr *fattr, const struct nfs_server *server)
3060 status = decode_op_hdr(xdr, OP_GETATTR);
3064 status = decode_attr_bitmap(xdr, bitmap);
3068 status = decode_attr_length(xdr, &attrlen, &savep);
3073 status = decode_attr_type(xdr, bitmap, &type);
3078 fattr->mode |= nfs_type2fmt[type];
3079 fattr->valid |= status;
3082 status = decode_attr_change(xdr, bitmap, &fattr->change_attr);
3085 fattr->valid |= status;
3087 status = decode_attr_size(xdr, bitmap, &fattr->size);
3090 fattr->valid |= status;
3092 status = decode_attr_fsid(xdr, bitmap, &fattr->fsid);
3095 fattr->valid |= status;
3097 status = decode_attr_fileid(xdr, bitmap, &fattr->fileid);
3100 fattr->valid |= status;
3102 status = decode_attr_fs_locations(xdr, bitmap, container_of(fattr,
3103 struct nfs4_fs_locations,
3107 fattr->valid |= status;
3109 status = decode_attr_mode(xdr, bitmap, &fmode);
3113 fattr->mode |= fmode;
3114 fattr->valid |= status;
3117 status = decode_attr_nlink(xdr, bitmap, &fattr->nlink);
3120 fattr->valid |= status;
3122 status = decode_attr_owner(xdr, bitmap, server->nfs_client, &fattr->uid);
3125 fattr->valid |= status;
3127 status = decode_attr_group(xdr, bitmap, server->nfs_client, &fattr->gid);
3130 fattr->valid |= status;
3132 status = decode_attr_rdev(xdr, bitmap, &fattr->rdev);
3135 fattr->valid |= status;
3137 status = decode_attr_space_used(xdr, bitmap, &fattr->du.nfs3.used);
3140 fattr->valid |= status;
3142 status = decode_attr_time_access(xdr, bitmap, &fattr->atime);
3145 fattr->valid |= status;
3147 status = decode_attr_time_metadata(xdr, bitmap, &fattr->ctime);
3150 fattr->valid |= status;
3152 status = decode_attr_time_modify(xdr, bitmap, &fattr->mtime);
3155 fattr->valid |= status;
3157 status = decode_attr_mounted_on_fileid(xdr, bitmap, &fileid);
3160 if (status != 0 && !(fattr->valid & status)) {
3161 fattr->fileid = fileid;
3162 fattr->valid |= status;
3165 status = verify_attr_len(xdr, savep, attrlen);
3167 dprintk("%s: xdr returned %d\n", __func__, -status);
3172 static int decode_fsinfo(struct xdr_stream *xdr, struct nfs_fsinfo *fsinfo)
3175 uint32_t attrlen, bitmap[2];
3178 if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0)
3180 if ((status = decode_attr_bitmap(xdr, bitmap)) != 0)
3182 if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0)
3185 fsinfo->rtmult = fsinfo->wtmult = 512; /* ??? */
3187 if ((status = decode_attr_lease_time(xdr, bitmap, &fsinfo->lease_time)) != 0)
3189 if ((status = decode_attr_maxfilesize(xdr, bitmap, &fsinfo->maxfilesize)) != 0)
3191 if ((status = decode_attr_maxread(xdr, bitmap, &fsinfo->rtmax)) != 0)
3193 fsinfo->rtpref = fsinfo->dtpref = fsinfo->rtmax;
3194 if ((status = decode_attr_maxwrite(xdr, bitmap, &fsinfo->wtmax)) != 0)
3196 fsinfo->wtpref = fsinfo->wtmax;
3198 status = verify_attr_len(xdr, savep, attrlen);
3200 dprintk("%s: xdr returned %d!\n", __func__, -status);
3204 static int decode_getfh(struct xdr_stream *xdr, struct nfs_fh *fh)
3210 /* Zero handle first to allow comparisons */
3211 memset(fh, 0, sizeof(*fh));
3213 status = decode_op_hdr(xdr, OP_GETFH);
3219 if (len > NFS4_FHSIZE)
3223 COPYMEM(fh->data, len);
3227 static int decode_link(struct xdr_stream *xdr, struct nfs4_change_info *cinfo)
3231 status = decode_op_hdr(xdr, OP_LINK);
3234 return decode_change_info(xdr, cinfo);
3238 * We create the owner, so we know a proper owner.id length is 4.
3240 static int decode_lock_denied (struct xdr_stream *xdr, struct file_lock *fl)
3242 uint64_t offset, length, clientid;
3244 uint32_t namelen, type;
3251 fl->fl_start = (loff_t)offset;
3252 fl->fl_end = fl->fl_start + (loff_t)length - 1;
3253 if (length == ~(uint64_t)0)
3254 fl->fl_end = OFFSET_MAX;
3255 fl->fl_type = F_WRLCK;
3257 fl->fl_type = F_RDLCK;
3263 return -NFS4ERR_DENIED;
3266 static int decode_lock(struct xdr_stream *xdr, struct nfs_lock_res *res)
3271 status = decode_op_hdr(xdr, OP_LOCK);
3275 READ_BUF(NFS4_STATEID_SIZE);
3276 COPYMEM(res->stateid.data, NFS4_STATEID_SIZE);
3277 } else if (status == -NFS4ERR_DENIED)
3278 status = decode_lock_denied(xdr, NULL);
3279 if (res->open_seqid != NULL)
3280 nfs_increment_open_seqid(status, res->open_seqid);
3281 nfs_increment_lock_seqid(status, res->lock_seqid);
3286 static int decode_lockt(struct xdr_stream *xdr, struct nfs_lockt_res *res)
3289 status = decode_op_hdr(xdr, OP_LOCKT);
3290 if (status == -NFS4ERR_DENIED)
3291 return decode_lock_denied(xdr, res->denied);
3295 static int decode_locku(struct xdr_stream *xdr, struct nfs_locku_res *res)
3300 status = decode_op_hdr(xdr, OP_LOCKU);
3302 nfs_increment_lock_seqid(status, res->seqid);
3304 READ_BUF(NFS4_STATEID_SIZE);
3305 COPYMEM(res->stateid.data, NFS4_STATEID_SIZE);
3310 static int decode_lookup(struct xdr_stream *xdr)
3312 return decode_op_hdr(xdr, OP_LOOKUP);
3315 /* This is too sick! */
3316 static int decode_space_limit(struct xdr_stream *xdr, u64 *maxsize)
3319 uint32_t limit_type, nblocks, blocksize;
3323 switch (limit_type) {
3330 *maxsize = (uint64_t)nblocks * (uint64_t)blocksize;
3335 static int decode_delegation(struct xdr_stream *xdr, struct nfs_openres *res)
3338 uint32_t delegation_type;
3341 READ32(delegation_type);
3342 if (delegation_type == NFS4_OPEN_DELEGATE_NONE) {
3343 res->delegation_type = 0;
3346 READ_BUF(NFS4_STATEID_SIZE+4);
3347 COPYMEM(res->delegation.data, NFS4_STATEID_SIZE);
3348 READ32(res->do_recall);
3350 switch (delegation_type) {
3351 case NFS4_OPEN_DELEGATE_READ:
3352 res->delegation_type = FMODE_READ;
3354 case NFS4_OPEN_DELEGATE_WRITE:
3355 res->delegation_type = FMODE_WRITE|FMODE_READ;
3356 if (decode_space_limit(xdr, &res->maxsize) < 0)
3359 return decode_ace(xdr, NULL, res->server->nfs_client);
3362 static int decode_open(struct xdr_stream *xdr, struct nfs_openres *res)
3365 uint32_t savewords, bmlen, i;
3368 status = decode_op_hdr(xdr, OP_OPEN);
3370 nfs_increment_open_seqid(status, res->seqid);
3373 READ_BUF(NFS4_STATEID_SIZE);
3374 COPYMEM(res->stateid.data, NFS4_STATEID_SIZE);
3376 decode_change_info(xdr, &res->cinfo);
3379 READ32(res->rflags);
3384 READ_BUF(bmlen << 2);
3385 savewords = min_t(uint32_t, bmlen, NFS4_BITMAP_SIZE);
3386 for (i = 0; i < savewords; ++i)
3387 READ32(res->attrset[i]);
3388 for (; i < NFS4_BITMAP_SIZE; i++)
3389 res->attrset[i] = 0;
3391 return decode_delegation(xdr, res);
3393 dprintk("%s: Bitmap too large! Length = %u\n", __func__, bmlen);
3397 static int decode_open_confirm(struct xdr_stream *xdr, struct nfs_open_confirmres *res)
3402 status = decode_op_hdr(xdr, OP_OPEN_CONFIRM);
3404 nfs_increment_open_seqid(status, res->seqid);
3407 READ_BUF(NFS4_STATEID_SIZE);
3408 COPYMEM(res->stateid.data, NFS4_STATEID_SIZE);
3412 static int decode_open_downgrade(struct xdr_stream *xdr, struct nfs_closeres *res)
3417 status = decode_op_hdr(xdr, OP_OPEN_DOWNGRADE);
3419 nfs_increment_open_seqid(status, res->seqid);
3422 READ_BUF(NFS4_STATEID_SIZE);
3423 COPYMEM(res->stateid.data, NFS4_STATEID_SIZE);
3427 static int decode_putfh(struct xdr_stream *xdr)
3429 return decode_op_hdr(xdr, OP_PUTFH);
3432 static int decode_putrootfh(struct xdr_stream *xdr)
3434 return decode_op_hdr(xdr, OP_PUTROOTFH);
3437 static int decode_read(struct xdr_stream *xdr, struct rpc_rqst *req, struct nfs_readres *res)
3439 struct kvec *iov = req->rq_rcv_buf.head;
3441 uint32_t count, eof, recvd, hdrlen;
3444 status = decode_op_hdr(xdr, OP_READ);
3450 hdrlen = (u8 *) p - (u8 *) iov->iov_base;
3451 recvd = req->rq_rcv_buf.len - hdrlen;
3452 if (count > recvd) {
3453 dprintk("NFS: server cheating in read reply: "
3454 "count %u > recvd %u\n", count, recvd);
3458 xdr_read_pages(xdr, count);
3464 static int decode_readdir(struct xdr_stream *xdr, struct rpc_rqst *req, struct nfs4_readdir_res *readdir)
3466 struct xdr_buf *rcvbuf = &req->rq_rcv_buf;
3467 struct page *page = *rcvbuf->pages;
3468 struct kvec *iov = rcvbuf->head;
3470 u32 recvd, pglen = rcvbuf->page_len;
3471 __be32 *end, *entry, *p, *kaddr;
3472 unsigned int nr = 0;
3475 status = decode_op_hdr(xdr, OP_READDIR);
3479 COPYMEM(readdir->verifier.data, 8);
3480 dprintk("%s: verifier = %08x:%08x\n",
3482 ((u32 *)readdir->verifier.data)[0],
3483 ((u32 *)readdir->verifier.data)[1]);
3486 hdrlen = (char *) p - (char *) iov->iov_base;
3487 recvd = rcvbuf->len - hdrlen;
3490 xdr_read_pages(xdr, pglen);
3492 BUG_ON(pglen + readdir->pgbase > PAGE_CACHE_SIZE);
3493 kaddr = p = kmap_atomic(page, KM_USER0);
3494 end = p + ((pglen + readdir->pgbase) >> 2);
3497 /* Make sure the packet actually has a value_follows and EOF entry */
3498 if ((entry + 1) > end)
3501 for (; *p++; nr++) {
3502 u32 len, attrlen, xlen;
3505 dprintk("cookie = %Lu, ", *((unsigned long long *)p));
3506 p += 2; /* cookie */
3507 len = ntohl(*p++); /* filename length */
3508 if (len > NFS4_MAXNAMLEN) {
3509 dprintk("NFS: giant filename in readdir (len 0x%x)\n",
3513 xlen = XDR_QUADLEN(len);
3514 if (end - p < xlen + 1)
3516 dprintk("filename = %*s\n", len, (char *)p);
3518 len = ntohl(*p++); /* bitmap length */
3519 if (end - p < len + 1)
3522 attrlen = XDR_QUADLEN(ntohl(*p++));
3523 if (end - p < attrlen + 2)
3525 p += attrlen; /* attributes */
3529 * Apparently some server sends responses that are a valid size, but
3530 * contain no entries, and have value_follows==0 and EOF==0. For
3531 * those, just set the EOF marker.
3533 if (!nr && entry[1] == 0) {
3534 dprintk("NFS: readdir reply truncated!\n");
3538 kunmap_atomic(kaddr, KM_USER0);
3542 * When we get a short packet there are 2 possibilities. We can
3543 * return an error, or fix up the response to look like a valid
3544 * response and return what we have so far. If there are no
3545 * entries and the packet was short, then return -EIO. If there
3546 * are valid entries in the response, return them and pretend that
3547 * the call was successful, but incomplete. The caller can retry the
3548 * readdir starting at the last cookie.
3550 dprintk("%s: short packet at entry %d\n", __func__, nr);
3551 entry[0] = entry[1] = 0;
3555 kunmap_atomic(kaddr, KM_USER0);
3556 return -errno_NFSERR_IO;
3559 static int decode_readlink(struct xdr_stream *xdr, struct rpc_rqst *req)
3561 struct xdr_buf *rcvbuf = &req->rq_rcv_buf;
3562 struct kvec *iov = rcvbuf->head;
3569 status = decode_op_hdr(xdr, OP_READLINK);
3573 /* Convert length of symlink */
3576 if (len >= rcvbuf->page_len || len <= 0) {
3577 dprintk("nfs: server returned giant symlink!\n");
3578 return -ENAMETOOLONG;
3580 hdrlen = (char *) xdr->p - (char *) iov->iov_base;
3581 recvd = req->rq_rcv_buf.len - hdrlen;
3583 dprintk("NFS: server cheating in readlink reply: "
3584 "count %u > recvd %u\n", len, recvd);
3587 xdr_read_pages(xdr, len);
3589 * The XDR encode routine has set things up so that
3590 * the link text will be copied directly into the
3591 * buffer. We just have to do overflow-checking,
3592 * and and null-terminate the text (the VFS expects
3593 * null-termination).
3595 kaddr = (char *)kmap_atomic(rcvbuf->pages[0], KM_USER0);
3596 kaddr[len+rcvbuf->page_base] = '\0';
3597 kunmap_atomic(kaddr, KM_USER0);
3601 static int decode_remove(struct xdr_stream *xdr, struct nfs4_change_info *cinfo)
3605 status = decode_op_hdr(xdr, OP_REMOVE);
3608 status = decode_change_info(xdr, cinfo);
3613 static int decode_rename(struct xdr_stream *xdr, struct nfs4_change_info *old_cinfo,
3614 struct nfs4_change_info *new_cinfo)
3618 status = decode_op_hdr(xdr, OP_RENAME);
3621 if ((status = decode_change_info(xdr, old_cinfo)))
3623 status = decode_change_info(xdr, new_cinfo);
3628 static int decode_renew(struct xdr_stream *xdr)
3630 return decode_op_hdr(xdr, OP_RENEW);
3634 decode_restorefh(struct xdr_stream *xdr)
3636 return decode_op_hdr(xdr, OP_RESTOREFH);
3639 static int decode_getacl(struct xdr_stream *xdr, struct rpc_rqst *req,
3645 struct kvec *iov = req->rq_rcv_buf.head;
3649 if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0)
3651 if ((status = decode_attr_bitmap(xdr, bitmap)) != 0)
3653 if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0)
3656 if (unlikely(bitmap[0] & (FATTR4_WORD0_ACL - 1U)))
3658 if (likely(bitmap[0] & FATTR4_WORD0_ACL)) {
3662 /* We ignore &savep and don't do consistency checks on
3663 * the attr length. Let userspace figure it out.... */
3664 hdrlen = (u8 *)xdr->p - (u8 *)iov->iov_base;
3665 recvd = req->rq_rcv_buf.len - hdrlen;
3666 if (attrlen > recvd) {
3667 dprintk("NFS: server cheating in getattr"
3668 " acl reply: attrlen %u > recvd %u\n",
3672 xdr_read_pages(xdr, attrlen);
3675 status = -EOPNOTSUPP;
3682 decode_savefh(struct xdr_stream *xdr)
3684 return decode_op_hdr(xdr, OP_SAVEFH);
3687 static int decode_setattr(struct xdr_stream *xdr)
3693 status = decode_op_hdr(xdr, OP_SETATTR);
3698 READ_BUF(bmlen << 2);
3702 static int decode_setclientid(struct xdr_stream *xdr, struct nfs_client *clp)
3710 if (opnum != OP_SETCLIENTID) {
3711 dprintk("nfs: decode_setclientid: Server returned operation"
3716 if (nfserr == NFS_OK) {
3717 READ_BUF(8 + NFS4_VERIFIER_SIZE);
3718 READ64(clp->cl_clientid);
3719 COPYMEM(clp->cl_confirm.data, NFS4_VERIFIER_SIZE);
3720 } else if (nfserr == NFSERR_CLID_INUSE) {
3723 /* skip netid string */
3728 /* skip uaddr string */
3732 return -NFSERR_CLID_INUSE;
3734 return nfs4_stat_to_errno(nfserr);
3739 static int decode_setclientid_confirm(struct xdr_stream *xdr)
3741 return decode_op_hdr(xdr, OP_SETCLIENTID_CONFIRM);
3744 static int decode_write(struct xdr_stream *xdr, struct nfs_writeres *res)
3749 status = decode_op_hdr(xdr, OP_WRITE);
3755 READ32(res->verf->committed);
3756 COPYMEM(res->verf->verifier, 8);
3760 static int decode_delegreturn(struct xdr_stream *xdr)
3762 return decode_op_hdr(xdr, OP_DELEGRETURN);
3766 * END OF "GENERIC" DECODE ROUTINES.
3770 * Decode OPEN_DOWNGRADE response
3772 static int nfs4_xdr_dec_open_downgrade(struct rpc_rqst *rqstp, __be32 *p, struct nfs_closeres *res)
3774 struct xdr_stream xdr;
3775 struct compound_hdr hdr;
3778 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
3779 status = decode_compound_hdr(&xdr, &hdr);
3782 status = decode_putfh(&xdr);
3785 status = decode_open_downgrade(&xdr, res);
3788 decode_getfattr(&xdr, res->fattr, res->server);
3794 * Decode ACCESS response
3796 static int nfs4_xdr_dec_access(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_accessres *res)
3798 struct xdr_stream xdr;
3799 struct compound_hdr hdr;
3802 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
3803 if ((status = decode_compound_hdr(&xdr, &hdr)) != 0)
3805 status = decode_putfh(&xdr);
3808 status = decode_access(&xdr, res);
3811 decode_getfattr(&xdr, res->fattr, res->server);
3817 * Decode LOOKUP response
3819 static int nfs4_xdr_dec_lookup(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_lookup_res *res)
3821 struct xdr_stream xdr;
3822 struct compound_hdr hdr;
3825 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
3826 if ((status = decode_compound_hdr(&xdr, &hdr)) != 0)
3828 if ((status = decode_putfh(&xdr)) != 0)
3830 if ((status = decode_lookup(&xdr)) != 0)
3832 if ((status = decode_getfh(&xdr, res->fh)) != 0)
3834 status = decode_getfattr(&xdr, res->fattr, res->server);
3840 * Decode LOOKUP_ROOT response
3842 static int nfs4_xdr_dec_lookup_root(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_lookup_res *res)
3844 struct xdr_stream xdr;
3845 struct compound_hdr hdr;
3848 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
3849 if ((status = decode_compound_hdr(&xdr, &hdr)) != 0)
3851 if ((status = decode_putrootfh(&xdr)) != 0)
3853 if ((status = decode_getfh(&xdr, res->fh)) == 0)
3854 status = decode_getfattr(&xdr, res->fattr, res->server);
3860 * Decode REMOVE response
3862 static int nfs4_xdr_dec_remove(struct rpc_rqst *rqstp, __be32 *p, struct nfs_removeres *res)
3864 struct xdr_stream xdr;
3865 struct compound_hdr hdr;
3868 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
3869 if ((status = decode_compound_hdr(&xdr, &hdr)) != 0)
3871 if ((status = decode_putfh(&xdr)) != 0)
3873 if ((status = decode_remove(&xdr, &res->cinfo)) != 0)
3875 decode_getfattr(&xdr, &res->dir_attr, res->server);
3881 * Decode RENAME response
3883 static int nfs4_xdr_dec_rename(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_rename_res *res)
3885 struct xdr_stream xdr;
3886 struct compound_hdr hdr;
3889 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
3890 if ((status = decode_compound_hdr(&xdr, &hdr)) != 0)
3892 if ((status = decode_putfh(&xdr)) != 0)
3894 if ((status = decode_savefh(&xdr)) != 0)
3896 if ((status = decode_putfh(&xdr)) != 0)
3898 if ((status = decode_rename(&xdr, &res->old_cinfo, &res->new_cinfo)) != 0)
3900 /* Current FH is target directory */
3901 if (decode_getfattr(&xdr, res->new_fattr, res->server) != 0)
3903 if ((status = decode_restorefh(&xdr)) != 0)
3905 decode_getfattr(&xdr, res->old_fattr, res->server);
3911 * Decode LINK response
3913 static int nfs4_xdr_dec_link(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_link_res *res)
3915 struct xdr_stream xdr;
3916 struct compound_hdr hdr;
3919 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
3920 if ((status = decode_compound_hdr(&xdr, &hdr)) != 0)
3922 if ((status = decode_putfh(&xdr)) != 0)
3924 if ((status = decode_savefh(&xdr)) != 0)
3926 if ((status = decode_putfh(&xdr)) != 0)
3928 if ((status = decode_link(&xdr, &res->cinfo)) != 0)
3931 * Note order: OP_LINK leaves the directory as the current
3934 if (decode_getfattr(&xdr, res->dir_attr, res->server) != 0)
3936 if ((status = decode_restorefh(&xdr)) != 0)
3938 decode_getfattr(&xdr, res->fattr, res->server);
3944 * Decode CREATE response
3946 static int nfs4_xdr_dec_create(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_create_res *res)
3948 struct xdr_stream xdr;
3949 struct compound_hdr hdr;
3952 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
3953 if ((status = decode_compound_hdr(&xdr, &hdr)) != 0)
3955 if ((status = decode_putfh(&xdr)) != 0)
3957 if ((status = decode_savefh(&xdr)) != 0)
3959 if ((status = decode_create(&xdr,&res->dir_cinfo)) != 0)
3961 if ((status = decode_getfh(&xdr, res->fh)) != 0)
3963 if (decode_getfattr(&xdr, res->fattr, res->server) != 0)
3965 if ((status = decode_restorefh(&xdr)) != 0)
3967 decode_getfattr(&xdr, res->dir_fattr, res->server);
3973 * Decode SYMLINK response
3975 static int nfs4_xdr_dec_symlink(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_create_res *res)
3977 return nfs4_xdr_dec_create(rqstp, p, res);
3981 * Decode GETATTR response
3983 static int nfs4_xdr_dec_getattr(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_getattr_res *res)
3985 struct xdr_stream xdr;
3986 struct compound_hdr hdr;
3989 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
3990 status = decode_compound_hdr(&xdr, &hdr);
3993 status = decode_putfh(&xdr);
3996 status = decode_getfattr(&xdr, res->fattr, res->server);
4002 * Encode an SETACL request
4005 nfs4_xdr_enc_setacl(struct rpc_rqst *req, __be32 *p, struct nfs_setaclargs *args)
4007 struct xdr_stream xdr;
4008 struct compound_hdr hdr = {
4009 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
4013 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
4014 encode_compound_hdr(&xdr, req, &hdr);
4015 encode_putfh(&xdr, args->fh, &hdr);
4016 status = encode_setacl(&xdr, args, &hdr);
4022 * Decode SETACL response
4025 nfs4_xdr_dec_setacl(struct rpc_rqst *rqstp, __be32 *p,
4026 struct nfs_setaclres *res)
4028 struct xdr_stream xdr;
4029 struct compound_hdr hdr;
4032 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
4033 status = decode_compound_hdr(&xdr, &hdr);
4036 status = decode_putfh(&xdr);
4039 status = decode_setattr(&xdr);
4045 * Decode GETACL response
4048 nfs4_xdr_dec_getacl(struct rpc_rqst *rqstp, __be32 *p,
4049 struct nfs_getaclres *res)
4051 struct xdr_stream xdr;
4052 struct compound_hdr hdr;
4055 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
4056 status = decode_compound_hdr(&xdr, &hdr);
4059 status = decode_putfh(&xdr);
4062 status = decode_getacl(&xdr, rqstp, &res->acl_len);
4069 * Decode CLOSE response
4071 static int nfs4_xdr_dec_close(struct rpc_rqst *rqstp, __be32 *p, struct nfs_closeres *res)
4073 struct xdr_stream xdr;
4074 struct compound_hdr hdr;
4077 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
4078 status = decode_compound_hdr(&xdr, &hdr);
4081 status = decode_putfh(&xdr);
4084 status = decode_close(&xdr, res);
4088 * Note: Server may do delete on close for this file
4089 * in which case the getattr call will fail with
4090 * an ESTALE error. Shouldn't be a problem,
4091 * though, since fattr->valid will remain unset.
4093 decode_getfattr(&xdr, res->fattr, res->server);
4099 * Decode OPEN response
4101 static int nfs4_xdr_dec_open(struct rpc_rqst *rqstp, __be32 *p, struct nfs_openres *res)
4103 struct xdr_stream xdr;
4104 struct compound_hdr hdr;
4107 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
4108 status = decode_compound_hdr(&xdr, &hdr);
4111 status = decode_putfh(&xdr);
4114 status = decode_savefh(&xdr);
4117 status = decode_open(&xdr, res);
4120 if (decode_getfh(&xdr, &res->fh) != 0)
4122 if (decode_getfattr(&xdr, res->f_attr, res->server) != 0)
4124 if (decode_restorefh(&xdr) != 0)
4126 decode_getfattr(&xdr, res->dir_attr, res->server);
4132 * Decode OPEN_CONFIRM response
4134 static int nfs4_xdr_dec_open_confirm(struct rpc_rqst *rqstp, __be32 *p, struct nfs_open_confirmres *res)
4136 struct xdr_stream xdr;
4137 struct compound_hdr hdr;
4140 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
4141 status = decode_compound_hdr(&xdr, &hdr);
4144 status = decode_putfh(&xdr);
4147 status = decode_open_confirm(&xdr, res);
4153 * Decode OPEN response
4155 static int nfs4_xdr_dec_open_noattr(struct rpc_rqst *rqstp, __be32 *p, struct nfs_openres *res)
4157 struct xdr_stream xdr;
4158 struct compound_hdr hdr;
4161 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
4162 status = decode_compound_hdr(&xdr, &hdr);
4165 status = decode_putfh(&xdr);
4168 status = decode_open(&xdr, res);
4171 decode_getfattr(&xdr, res->f_attr, res->server);
4177 * Decode SETATTR response
4179 static int nfs4_xdr_dec_setattr(struct rpc_rqst *rqstp, __be32 *p, struct nfs_setattrres *res)
4181 struct xdr_stream xdr;
4182 struct compound_hdr hdr;
4185 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
4186 status = decode_compound_hdr(&xdr, &hdr);
4189 status = decode_putfh(&xdr);
4192 status = decode_setattr(&xdr);
4195 decode_getfattr(&xdr, res->fattr, res->server);
4201 * Decode LOCK response
4203 static int nfs4_xdr_dec_lock(struct rpc_rqst *rqstp, __be32 *p, struct nfs_lock_res *res)
4205 struct xdr_stream xdr;
4206 struct compound_hdr hdr;
4209 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
4210 status = decode_compound_hdr(&xdr, &hdr);
4213 status = decode_putfh(&xdr);
4216 status = decode_lock(&xdr, res);
4222 * Decode LOCKT response
4224 static int nfs4_xdr_dec_lockt(struct rpc_rqst *rqstp, __be32 *p, struct nfs_lockt_res *res)
4226 struct xdr_stream xdr;
4227 struct compound_hdr hdr;
4230 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
4231 status = decode_compound_hdr(&xdr, &hdr);
4234 status = decode_putfh(&xdr);
4237 status = decode_lockt(&xdr, res);
4243 * Decode LOCKU response
4245 static int nfs4_xdr_dec_locku(struct rpc_rqst *rqstp, __be32 *p, struct nfs_locku_res *res)
4247 struct xdr_stream xdr;
4248 struct compound_hdr hdr;
4251 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
4252 status = decode_compound_hdr(&xdr, &hdr);
4255 status = decode_putfh(&xdr);
4258 status = decode_locku(&xdr, res);
4264 * Decode READLINK response
4266 static int nfs4_xdr_dec_readlink(struct rpc_rqst *rqstp, __be32 *p,
4267 struct nfs4_readlink_res *res)
4269 struct xdr_stream xdr;
4270 struct compound_hdr hdr;
4273 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
4274 status = decode_compound_hdr(&xdr, &hdr);
4277 status = decode_putfh(&xdr);
4280 status = decode_readlink(&xdr, rqstp);
4286 * Decode READDIR response
4288 static int nfs4_xdr_dec_readdir(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_readdir_res *res)
4290 struct xdr_stream xdr;
4291 struct compound_hdr hdr;
4294 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
4295 status = decode_compound_hdr(&xdr, &hdr);
4298 status = decode_putfh(&xdr);
4301 status = decode_readdir(&xdr, rqstp, res);
4307 * Decode Read response
4309 static int nfs4_xdr_dec_read(struct rpc_rqst *rqstp, __be32 *p, struct nfs_readres *res)
4311 struct xdr_stream xdr;
4312 struct compound_hdr hdr;
4315 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
4316 status = decode_compound_hdr(&xdr, &hdr);
4319 status = decode_putfh(&xdr);
4322 status = decode_read(&xdr, rqstp, res);
4324 status = res->count;
4330 * Decode WRITE response
4332 static int nfs4_xdr_dec_write(struct rpc_rqst *rqstp, __be32 *p, struct nfs_writeres *res)
4334 struct xdr_stream xdr;
4335 struct compound_hdr hdr;
4338 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
4339 status = decode_compound_hdr(&xdr, &hdr);
4342 status = decode_putfh(&xdr);
4345 status = decode_write(&xdr, res);
4348 decode_getfattr(&xdr, res->fattr, res->server);
4350 status = res->count;
4356 * Decode COMMIT response
4358 static int nfs4_xdr_dec_commit(struct rpc_rqst *rqstp, __be32 *p, struct nfs_writeres *res)
4360 struct xdr_stream xdr;
4361 struct compound_hdr hdr;
4364 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
4365 status = decode_compound_hdr(&xdr, &hdr);
4368 status = decode_putfh(&xdr);
4371 status = decode_commit(&xdr, res);
4374 decode_getfattr(&xdr, res->fattr, res->server);
4382 static int nfs4_xdr_dec_fsinfo(struct rpc_rqst *req, __be32 *p,
4383 struct nfs4_fsinfo_res *res)
4385 struct xdr_stream xdr;
4386 struct compound_hdr hdr;
4389 xdr_init_decode(&xdr, &req->rq_rcv_buf, p);
4390 status = decode_compound_hdr(&xdr, &hdr);
4392 status = decode_putfh(&xdr);
4394 status = decode_fsinfo(&xdr, res->fsinfo);
4401 static int nfs4_xdr_dec_pathconf(struct rpc_rqst *req, __be32 *p,
4402 struct nfs4_pathconf_res *res)
4404 struct xdr_stream xdr;
4405 struct compound_hdr hdr;
4408 xdr_init_decode(&xdr, &req->rq_rcv_buf, p);
4409 status = decode_compound_hdr(&xdr, &hdr);
4411 status = decode_putfh(&xdr);
4413 status = decode_pathconf(&xdr, res->pathconf);
4420 static int nfs4_xdr_dec_statfs(struct rpc_rqst *req, __be32 *p,
4421 struct nfs4_statfs_res *res)
4423 struct xdr_stream xdr;
4424 struct compound_hdr hdr;
4427 xdr_init_decode(&xdr, &req->rq_rcv_buf, p);
4428 status = decode_compound_hdr(&xdr, &hdr);
4430 status = decode_putfh(&xdr);
4432 status = decode_statfs(&xdr, res->fsstat);
4437 * GETATTR_BITMAP request
4439 static int nfs4_xdr_dec_server_caps(struct rpc_rqst *req, __be32 *p, struct nfs4_server_caps_res *res)
4441 struct xdr_stream xdr;
4442 struct compound_hdr hdr;
4445 xdr_init_decode(&xdr, &req->rq_rcv_buf, p);
4446 if ((status = decode_compound_hdr(&xdr, &hdr)) != 0)
4448 if ((status = decode_putfh(&xdr)) != 0)
4450 status = decode_server_caps(&xdr, res);
4456 * Decode RENEW response
4458 static int nfs4_xdr_dec_renew(struct rpc_rqst *rqstp, __be32 *p, void *dummy)
4460 struct xdr_stream xdr;
4461 struct compound_hdr hdr;
4464 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
4465 status = decode_compound_hdr(&xdr, &hdr);
4467 status = decode_renew(&xdr);
4472 * a SETCLIENTID request
4474 static int nfs4_xdr_dec_setclientid(struct rpc_rqst *req, __be32 *p,
4475 struct nfs_client *clp)
4477 struct xdr_stream xdr;
4478 struct compound_hdr hdr;
4481 xdr_init_decode(&xdr, &req->rq_rcv_buf, p);
4482 status = decode_compound_hdr(&xdr, &hdr);
4484 status = decode_setclientid(&xdr, clp);
4489 * a SETCLIENTID_CONFIRM request
4491 static int nfs4_xdr_dec_setclientid_confirm(struct rpc_rqst *req, __be32 *p, struct nfs_fsinfo *fsinfo)
4493 struct xdr_stream xdr;
4494 struct compound_hdr hdr;
4497 xdr_init_decode(&xdr, &req->rq_rcv_buf, p);
4498 status = decode_compound_hdr(&xdr, &hdr);
4500 status = decode_setclientid_confirm(&xdr);
4502 status = decode_putrootfh(&xdr);
4504 status = decode_fsinfo(&xdr, fsinfo);
4509 * DELEGRETURN request
4511 static int nfs4_xdr_dec_delegreturn(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_delegreturnres *res)
4513 struct xdr_stream xdr;
4514 struct compound_hdr hdr;
4517 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
4518 status = decode_compound_hdr(&xdr, &hdr);
4521 status = decode_putfh(&xdr);
4524 status = decode_delegreturn(&xdr);
4525 decode_getfattr(&xdr, res->fattr, res->server);
4531 * FS_LOCATIONS request
4533 static int nfs4_xdr_dec_fs_locations(struct rpc_rqst *req, __be32 *p,
4534 struct nfs4_fs_locations_res *res)
4536 struct xdr_stream xdr;
4537 struct compound_hdr hdr;
4540 xdr_init_decode(&xdr, &req->rq_rcv_buf, p);
4541 status = decode_compound_hdr(&xdr, &hdr);
4544 if ((status = decode_putfh(&xdr)) != 0)
4546 if ((status = decode_lookup(&xdr)) != 0)
4548 xdr_enter_page(&xdr, PAGE_SIZE);
4549 status = decode_getfattr(&xdr, &res->fs_locations->fattr,
4550 res->fs_locations->server);
4555 __be32 *nfs4_decode_dirent(__be32 *p, struct nfs_entry *entry, int plus)
4557 uint32_t bitmap[2] = {0};
4562 return ERR_PTR(-EAGAIN);
4564 return ERR_PTR(-EBADCOOKIE);
4567 entry->prev_cookie = entry->cookie;
4568 p = xdr_decode_hyper(p, &entry->cookie);
4569 entry->len = ntohl(*p++);
4570 entry->name = (const char *) p;
4571 p += XDR_QUADLEN(entry->len);
4574 * In case the server doesn't return an inode number,
4575 * we fake one here. (We don't use inode number 0,
4576 * since glibc seems to choke on it...)
4580 len = ntohl(*p++); /* bitmap length */
4582 bitmap[0] = ntohl(*p++);
4584 bitmap[1] = ntohl(*p++);
4588 len = XDR_QUADLEN(ntohl(*p++)); /* attribute buffer length */
4590 if (bitmap[0] & FATTR4_WORD0_RDATTR_ERROR) {
4591 bitmap[0] &= ~FATTR4_WORD0_RDATTR_ERROR;
4592 /* Ignore the return value of rdattr_error for now */
4596 if (bitmap[0] == 0 && bitmap[1] == FATTR4_WORD1_MOUNTED_ON_FILEID)
4597 xdr_decode_hyper(p, &entry->ino);
4598 else if (bitmap[0] == FATTR4_WORD0_FILEID)
4599 xdr_decode_hyper(p, &entry->ino);
4603 entry->eof = !p[0] && p[1];
4608 * We need to translate between nfs status return values and
4609 * the local errno values which may not be the same.
4616 { NFS4ERR_PERM, -EPERM },
4617 { NFS4ERR_NOENT, -ENOENT },
4618 { NFS4ERR_IO, -errno_NFSERR_IO},
4619 { NFS4ERR_NXIO, -ENXIO },
4620 { NFS4ERR_ACCESS, -EACCES },
4621 { NFS4ERR_EXIST, -EEXIST },
4622 { NFS4ERR_XDEV, -EXDEV },
4623 { NFS4ERR_NOTDIR, -ENOTDIR },
4624 { NFS4ERR_ISDIR, -EISDIR },
4625 { NFS4ERR_INVAL, -EINVAL },
4626 { NFS4ERR_FBIG, -EFBIG },
4627 { NFS4ERR_NOSPC, -ENOSPC },
4628 { NFS4ERR_ROFS, -EROFS },
4629 { NFS4ERR_MLINK, -EMLINK },
4630 { NFS4ERR_NAMETOOLONG, -ENAMETOOLONG },
4631 { NFS4ERR_NOTEMPTY, -ENOTEMPTY },
4632 { NFS4ERR_DQUOT, -EDQUOT },
4633 { NFS4ERR_STALE, -ESTALE },
4634 { NFS4ERR_BADHANDLE, -EBADHANDLE },
4635 { NFS4ERR_BADOWNER, -EINVAL },
4636 { NFS4ERR_BADNAME, -EINVAL },
4637 { NFS4ERR_BAD_COOKIE, -EBADCOOKIE },
4638 { NFS4ERR_NOTSUPP, -ENOTSUPP },
4639 { NFS4ERR_TOOSMALL, -ETOOSMALL },
4640 { NFS4ERR_SERVERFAULT, -ESERVERFAULT },
4641 { NFS4ERR_BADTYPE, -EBADTYPE },
4642 { NFS4ERR_LOCKED, -EAGAIN },
4643 { NFS4ERR_RESOURCE, -EREMOTEIO },
4644 { NFS4ERR_SYMLINK, -ELOOP },
4645 { NFS4ERR_OP_ILLEGAL, -EOPNOTSUPP },
4646 { NFS4ERR_DEADLOCK, -EDEADLK },
4647 { NFS4ERR_WRONGSEC, -EPERM }, /* FIXME: this needs
4648 * to be handled by a
4655 * Convert an NFS error code to a local one.
4656 * This one is used jointly by NFSv2 and NFSv3.
4659 nfs4_stat_to_errno(int stat)
4662 for (i = 0; nfs_errtbl[i].stat != -1; i++) {
4663 if (nfs_errtbl[i].stat == stat)
4664 return nfs_errtbl[i].errno;
4666 if (stat <= 10000 || stat > 10100) {
4667 /* The server is looney tunes. */
4668 return -ESERVERFAULT;
4670 /* If we cannot translate the error, the recovery routines should
4672 * Note: remaining NFSv4 error codes have values > 10000, so should
4673 * not conflict with native Linux error codes.
4678 #define PROC(proc, argtype, restype) \
4679 [NFSPROC4_CLNT_##proc] = { \
4680 .p_proc = NFSPROC4_COMPOUND, \
4681 .p_encode = (kxdrproc_t) nfs4_xdr_##argtype, \
4682 .p_decode = (kxdrproc_t) nfs4_xdr_##restype, \
4683 .p_arglen = NFS4_##argtype##_sz, \
4684 .p_replen = NFS4_##restype##_sz, \
4685 .p_statidx = NFSPROC4_CLNT_##proc, \
4689 struct rpc_procinfo nfs4_procedures[] = {
4690 PROC(READ, enc_read, dec_read),
4691 PROC(WRITE, enc_write, dec_write),
4692 PROC(COMMIT, enc_commit, dec_commit),
4693 PROC(OPEN, enc_open, dec_open),
4694 PROC(OPEN_CONFIRM, enc_open_confirm, dec_open_confirm),
4695 PROC(OPEN_NOATTR, enc_open_noattr, dec_open_noattr),
4696 PROC(OPEN_DOWNGRADE, enc_open_downgrade, dec_open_downgrade),
4697 PROC(CLOSE, enc_close, dec_close),
4698 PROC(SETATTR, enc_setattr, dec_setattr),
4699 PROC(FSINFO, enc_fsinfo, dec_fsinfo),
4700 PROC(RENEW, enc_renew, dec_renew),
4701 PROC(SETCLIENTID, enc_setclientid, dec_setclientid),
4702 PROC(SETCLIENTID_CONFIRM, enc_setclientid_confirm, dec_setclientid_confirm),
4703 PROC(LOCK, enc_lock, dec_lock),
4704 PROC(LOCKT, enc_lockt, dec_lockt),
4705 PROC(LOCKU, enc_locku, dec_locku),
4706 PROC(ACCESS, enc_access, dec_access),
4707 PROC(GETATTR, enc_getattr, dec_getattr),
4708 PROC(LOOKUP, enc_lookup, dec_lookup),
4709 PROC(LOOKUP_ROOT, enc_lookup_root, dec_lookup_root),
4710 PROC(REMOVE, enc_remove, dec_remove),
4711 PROC(RENAME, enc_rename, dec_rename),
4712 PROC(LINK, enc_link, dec_link),
4713 PROC(SYMLINK, enc_symlink, dec_symlink),
4714 PROC(CREATE, enc_create, dec_create),
4715 PROC(PATHCONF, enc_pathconf, dec_pathconf),
4716 PROC(STATFS, enc_statfs, dec_statfs),
4717 PROC(READLINK, enc_readlink, dec_readlink),
4718 PROC(READDIR, enc_readdir, dec_readdir),
4719 PROC(SERVER_CAPS, enc_server_caps, dec_server_caps),
4720 PROC(DELEGRETURN, enc_delegreturn, dec_delegreturn),
4721 PROC(GETACL, enc_getacl, dec_getacl),
4722 PROC(SETACL, enc_setacl, dec_setacl),
4723 PROC(FS_LOCATIONS, enc_fs_locations, dec_fs_locations),
4726 struct rpc_version nfs_version4 = {
4728 .nrprocs = ARRAY_SIZE(nfs4_procedures),
4729 .procs = nfs4_procedures