Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * fs/nfs/nfs4xdr.c | |
3 | * | |
4 | * Client-side XDR for NFSv4. | |
5 | * | |
6 | * Copyright (c) 2002 The Regents of the University of Michigan. | |
7 | * All rights reserved. | |
8 | * | |
9 | * Kendrick Smith <kmsmith@umich.edu> | |
10 | * Andy Adamson <andros@umich.edu> | |
6c0195a4 | 11 | * |
1da177e4 LT |
12 | * Redistribution and use in source and binary forms, with or without |
13 | * modification, are permitted provided that the following conditions | |
14 | * are met: | |
15 | * | |
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. | |
24 | * | |
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. | |
36 | */ | |
37 | ||
38 | #include <linux/param.h> | |
39 | #include <linux/time.h> | |
40 | #include <linux/mm.h> | |
1da177e4 LT |
41 | #include <linux/errno.h> |
42 | #include <linux/string.h> | |
43 | #include <linux/in.h> | |
44 | #include <linux/pagemap.h> | |
45 | #include <linux/proc_fs.h> | |
46 | #include <linux/kdev_t.h> | |
db8ac8ba WAA |
47 | #include <linux/module.h> |
48 | #include <linux/utsname.h> | |
1da177e4 | 49 | #include <linux/sunrpc/clnt.h> |
2449ea2e | 50 | #include <linux/sunrpc/msg_prot.h> |
5a5ea0d4 | 51 | #include <linux/sunrpc/gss_api.h> |
1da177e4 LT |
52 | #include <linux/nfs.h> |
53 | #include <linux/nfs4.h> | |
54 | #include <linux/nfs_fs.h> | |
55 | #include <linux/nfs_idmap.h> | |
f092075d | 56 | |
4ce79717 | 57 | #include "nfs4_fs.h" |
4882ef72 | 58 | #include "internal.h" |
76e697ba | 59 | #include "nfs4session.h" |
b1f69b75 | 60 | #include "pnfs.h" |
f092075d | 61 | #include "netns.h" |
1da177e4 LT |
62 | |
63 | #define NFSDBG_FACILITY NFSDBG_XDR | |
64 | ||
65 | /* Mapping from NFS error code to "errno" error code. */ | |
66 | #define errno_NFSERR_IO EIO | |
67 | ||
0a8ea437 | 68 | static int nfs4_stat_to_errno(int); |
1da177e4 LT |
69 | |
70 | /* NFSv4 COMPOUND tags are only wanted for debugging purposes */ | |
71 | #ifdef DEBUG | |
72 | #define NFS4_MAXTAGLEN 20 | |
73 | #else | |
74 | #define NFS4_MAXTAGLEN 0 | |
75 | #endif | |
76 | ||
6c0195a4 | 77 | /* lock,open owner id: |
9f958ab8 | 78 | * we currently use size 2 (u64) out of (NFS4_OPAQUE_LIMIT >> 2) |
1da177e4 | 79 | */ |
95b72eb0 | 80 | #define open_owner_id_maxsz (1 + 2 + 1 + 1 + 2) |
d035c36c | 81 | #define lock_owner_id_maxsz (1 + 1 + 4) |
9104a55d | 82 | #define decode_lockowner_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ)) |
1da177e4 LT |
83 | #define compound_encode_hdr_maxsz (3 + (NFS4_MAXTAGLEN >> 2)) |
84 | #define compound_decode_hdr_maxsz (3 + (NFS4_MAXTAGLEN >> 2)) | |
85 | #define op_encode_hdr_maxsz (1) | |
86 | #define op_decode_hdr_maxsz (2) | |
9104a55d TM |
87 | #define encode_stateid_maxsz (XDR_QUADLEN(NFS4_STATEID_SIZE)) |
88 | #define decode_stateid_maxsz (XDR_QUADLEN(NFS4_STATEID_SIZE)) | |
89 | #define encode_verifier_maxsz (XDR_QUADLEN(NFS4_VERIFIER_SIZE)) | |
90 | #define decode_verifier_maxsz (XDR_QUADLEN(NFS4_VERIFIER_SIZE)) | |
1da177e4 LT |
91 | #define encode_putfh_maxsz (op_encode_hdr_maxsz + 1 + \ |
92 | (NFS4_FHSIZE >> 2)) | |
93 | #define decode_putfh_maxsz (op_decode_hdr_maxsz) | |
94 | #define encode_putrootfh_maxsz (op_encode_hdr_maxsz) | |
95 | #define decode_putrootfh_maxsz (op_decode_hdr_maxsz) | |
96 | #define encode_getfh_maxsz (op_encode_hdr_maxsz) | |
97 | #define decode_getfh_maxsz (op_decode_hdr_maxsz + 1 + \ | |
98 | ((3+NFS4_FHSIZE) >> 2)) | |
e5012d1f | 99 | #define nfs4_fattr_bitmap_maxsz 4 |
96928206 | 100 | #define encode_getattr_maxsz (op_encode_hdr_maxsz + nfs4_fattr_bitmap_maxsz) |
1da177e4 LT |
101 | #define nfs4_name_maxsz (1 + ((3 + NFS4_MAXNAMLEN) >> 2)) |
102 | #define nfs4_path_maxsz (1 + ((3 + NFS4_MAXPATHLEN) >> 2)) | |
bd625ba8 TM |
103 | #define nfs4_owner_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ)) |
104 | #define nfs4_group_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ)) | |
aa9c2669 DQ |
105 | #ifdef CONFIG_NFS_V4_SECURITY_LABEL |
106 | /* PI(4 bytes) + LFS(4 bytes) + 1(for null terminator?) + MAXLABELLEN */ | |
107 | #define nfs4_label_maxsz (4 + 4 + 1 + XDR_QUADLEN(NFS4_MAXLABELLEN)) | |
aa9c2669 DQ |
108 | #else |
109 | #define nfs4_label_maxsz 0 | |
aa9c2669 | 110 | #endif |
88034c3d AA |
111 | /* We support only one layout type per file system */ |
112 | #define decode_mdsthreshold_maxsz (1 + 1 + nfs4_fattr_bitmap_maxsz + 1 + 8) | |
96928206 BF |
113 | /* This is based on getfattr, which uses the most attributes: */ |
114 | #define nfs4_fattr_value_maxsz (1 + (1 + 2 + 2 + 4 + 2 + 1 + 1 + 2 + 2 + \ | |
88034c3d | 115 | 3 + 3 + 3 + nfs4_owner_maxsz + \ |
aa9c2669 DQ |
116 | nfs4_group_maxsz + nfs4_label_maxsz + \ |
117 | decode_mdsthreshold_maxsz)) | |
96928206 BF |
118 | #define nfs4_fattr_maxsz (nfs4_fattr_bitmap_maxsz + \ |
119 | nfs4_fattr_value_maxsz) | |
120 | #define decode_getattr_maxsz (op_decode_hdr_maxsz + nfs4_fattr_maxsz) | |
9104a55d TM |
121 | #define encode_attrs_maxsz (nfs4_fattr_bitmap_maxsz + \ |
122 | 1 + 2 + 1 + \ | |
123 | nfs4_owner_maxsz + \ | |
124 | nfs4_group_maxsz + \ | |
aa9c2669 | 125 | nfs4_label_maxsz + \ |
9104a55d | 126 | 4 + 4) |
1da177e4 LT |
127 | #define encode_savefh_maxsz (op_encode_hdr_maxsz) |
128 | #define decode_savefh_maxsz (op_decode_hdr_maxsz) | |
56ae19f3 TM |
129 | #define encode_restorefh_maxsz (op_encode_hdr_maxsz) |
130 | #define decode_restorefh_maxsz (op_decode_hdr_maxsz) | |
2f42b5d0 | 131 | #define encode_fsinfo_maxsz (encode_getattr_maxsz) |
dae100c2 FI |
132 | /* The 5 accounts for the PNFS attributes, and assumes that at most three |
133 | * layout types will be returned. | |
134 | */ | |
135 | #define decode_fsinfo_maxsz (op_decode_hdr_maxsz + \ | |
136 | nfs4_fattr_bitmap_maxsz + 4 + 8 + 5) | |
1da177e4 LT |
137 | #define encode_renew_maxsz (op_encode_hdr_maxsz + 3) |
138 | #define decode_renew_maxsz (op_decode_hdr_maxsz) | |
139 | #define encode_setclientid_maxsz \ | |
140 | (op_encode_hdr_maxsz + \ | |
cc38bac3 CL |
141 | XDR_QUADLEN(NFS4_VERIFIER_SIZE) + \ |
142 | XDR_QUADLEN(NFS4_SETCLIENTID_NAMELEN) + \ | |
143 | 1 /* sc_prog */ + \ | |
144 | XDR_QUADLEN(RPCBIND_MAXNETIDLEN) + \ | |
145 | XDR_QUADLEN(RPCBIND_MAXUADDRLEN) + \ | |
146 | 1) /* sc_cb_ident */ | |
1da177e4 LT |
147 | #define decode_setclientid_maxsz \ |
148 | (op_decode_hdr_maxsz + \ | |
149 | 2 + \ | |
150 | 1024) /* large value for CLID_INUSE */ | |
151 | #define encode_setclientid_confirm_maxsz \ | |
152 | (op_encode_hdr_maxsz + \ | |
153 | 3 + (NFS4_VERIFIER_SIZE >> 2)) | |
154 | #define decode_setclientid_confirm_maxsz \ | |
155 | (op_decode_hdr_maxsz) | |
e6889620 TM |
156 | #define encode_lookup_maxsz (op_encode_hdr_maxsz + nfs4_name_maxsz) |
157 | #define decode_lookup_maxsz (op_decode_hdr_maxsz) | |
2cebf828 TM |
158 | #define encode_share_access_maxsz \ |
159 | (2) | |
4882ef72 | 160 | #define encode_createmode_maxsz (1 + encode_attrs_maxsz + encode_verifier_maxsz) |
2cebf828 TM |
161 | #define encode_opentype_maxsz (1 + encode_createmode_maxsz) |
162 | #define encode_claim_null_maxsz (1 + nfs4_name_maxsz) | |
163 | #define encode_open_maxsz (op_encode_hdr_maxsz + \ | |
164 | 2 + encode_share_access_maxsz + 2 + \ | |
165 | open_owner_id_maxsz + \ | |
166 | encode_opentype_maxsz + \ | |
167 | encode_claim_null_maxsz) | |
168 | #define decode_ace_maxsz (3 + nfs4_owner_maxsz) | |
9104a55d | 169 | #define decode_delegation_maxsz (1 + decode_stateid_maxsz + 1 + \ |
2cebf828 TM |
170 | decode_ace_maxsz) |
171 | #define decode_change_info_maxsz (5) | |
172 | #define decode_open_maxsz (op_decode_hdr_maxsz + \ | |
9104a55d | 173 | decode_stateid_maxsz + \ |
2cebf828 TM |
174 | decode_change_info_maxsz + 1 + \ |
175 | nfs4_fattr_bitmap_maxsz + \ | |
176 | decode_delegation_maxsz) | |
9104a55d TM |
177 | #define encode_open_confirm_maxsz \ |
178 | (op_encode_hdr_maxsz + \ | |
179 | encode_stateid_maxsz + 1) | |
180 | #define decode_open_confirm_maxsz \ | |
181 | (op_decode_hdr_maxsz + \ | |
182 | decode_stateid_maxsz) | |
183 | #define encode_open_downgrade_maxsz \ | |
184 | (op_encode_hdr_maxsz + \ | |
185 | encode_stateid_maxsz + 1 + \ | |
186 | encode_share_access_maxsz) | |
187 | #define decode_open_downgrade_maxsz \ | |
188 | (op_decode_hdr_maxsz + \ | |
189 | decode_stateid_maxsz) | |
190 | #define encode_close_maxsz (op_encode_hdr_maxsz + \ | |
191 | 1 + encode_stateid_maxsz) | |
192 | #define decode_close_maxsz (op_decode_hdr_maxsz + \ | |
193 | decode_stateid_maxsz) | |
194 | #define encode_setattr_maxsz (op_encode_hdr_maxsz + \ | |
195 | encode_stateid_maxsz + \ | |
196 | encode_attrs_maxsz) | |
197 | #define decode_setattr_maxsz (op_decode_hdr_maxsz + \ | |
198 | nfs4_fattr_bitmap_maxsz) | |
199 | #define encode_read_maxsz (op_encode_hdr_maxsz + \ | |
200 | encode_stateid_maxsz + 3) | |
201 | #define decode_read_maxsz (op_decode_hdr_maxsz + 2) | |
202 | #define encode_readdir_maxsz (op_encode_hdr_maxsz + \ | |
aa9c2669 DQ |
203 | 2 + encode_verifier_maxsz + 5 + \ |
204 | nfs4_label_maxsz) | |
9104a55d | 205 | #define decode_readdir_maxsz (op_decode_hdr_maxsz + \ |
a7697f6f | 206 | decode_verifier_maxsz) |
9104a55d TM |
207 | #define encode_readlink_maxsz (op_encode_hdr_maxsz) |
208 | #define decode_readlink_maxsz (op_decode_hdr_maxsz + 1) | |
209 | #define encode_write_maxsz (op_encode_hdr_maxsz + \ | |
210 | encode_stateid_maxsz + 4) | |
211 | #define decode_write_maxsz (op_decode_hdr_maxsz + \ | |
212 | 2 + decode_verifier_maxsz) | |
213 | #define encode_commit_maxsz (op_encode_hdr_maxsz + 3) | |
214 | #define decode_commit_maxsz (op_decode_hdr_maxsz + \ | |
215 | decode_verifier_maxsz) | |
1da177e4 LT |
216 | #define encode_remove_maxsz (op_encode_hdr_maxsz + \ |
217 | nfs4_name_maxsz) | |
6ce18391 BH |
218 | #define decode_remove_maxsz (op_decode_hdr_maxsz + \ |
219 | decode_change_info_maxsz) | |
1da177e4 LT |
220 | #define encode_rename_maxsz (op_encode_hdr_maxsz + \ |
221 | 2 * nfs4_name_maxsz) | |
6ce18391 BH |
222 | #define decode_rename_maxsz (op_decode_hdr_maxsz + \ |
223 | decode_change_info_maxsz + \ | |
224 | decode_change_info_maxsz) | |
1da177e4 LT |
225 | #define encode_link_maxsz (op_encode_hdr_maxsz + \ |
226 | nfs4_name_maxsz) | |
6ce18391 | 227 | #define decode_link_maxsz (op_decode_hdr_maxsz + decode_change_info_maxsz) |
daccbded | 228 | #define encode_lockowner_maxsz (7) |
9104a55d TM |
229 | #define encode_lock_maxsz (op_encode_hdr_maxsz + \ |
230 | 7 + \ | |
daccbded TM |
231 | 1 + encode_stateid_maxsz + 1 + \ |
232 | encode_lockowner_maxsz) | |
9104a55d TM |
233 | #define decode_lock_denied_maxsz \ |
234 | (8 + decode_lockowner_maxsz) | |
235 | #define decode_lock_maxsz (op_decode_hdr_maxsz + \ | |
236 | decode_lock_denied_maxsz) | |
daccbded TM |
237 | #define encode_lockt_maxsz (op_encode_hdr_maxsz + 5 + \ |
238 | encode_lockowner_maxsz) | |
9104a55d TM |
239 | #define decode_lockt_maxsz (op_decode_hdr_maxsz + \ |
240 | decode_lock_denied_maxsz) | |
241 | #define encode_locku_maxsz (op_encode_hdr_maxsz + 3 + \ | |
242 | encode_stateid_maxsz + \ | |
243 | 4) | |
244 | #define decode_locku_maxsz (op_decode_hdr_maxsz + \ | |
245 | decode_stateid_maxsz) | |
d3c7b7cc TM |
246 | #define encode_release_lockowner_maxsz \ |
247 | (op_encode_hdr_maxsz + \ | |
248 | encode_lockowner_maxsz) | |
249 | #define decode_release_lockowner_maxsz \ | |
250 | (op_decode_hdr_maxsz) | |
9104a55d TM |
251 | #define encode_access_maxsz (op_encode_hdr_maxsz + 1) |
252 | #define decode_access_maxsz (op_decode_hdr_maxsz + 2) | |
1da177e4 LT |
253 | #define encode_symlink_maxsz (op_encode_hdr_maxsz + \ |
254 | 1 + nfs4_name_maxsz + \ | |
94a6d753 | 255 | 1 + \ |
96928206 | 256 | nfs4_fattr_maxsz) |
1da177e4 LT |
257 | #define decode_symlink_maxsz (op_decode_hdr_maxsz + 8) |
258 | #define encode_create_maxsz (op_encode_hdr_maxsz + \ | |
9104a55d TM |
259 | 1 + 2 + nfs4_name_maxsz + \ |
260 | encode_attrs_maxsz) | |
2cebf828 TM |
261 | #define decode_create_maxsz (op_decode_hdr_maxsz + \ |
262 | decode_change_info_maxsz + \ | |
263 | nfs4_fattr_bitmap_maxsz) | |
9104a55d TM |
264 | #define encode_statfs_maxsz (encode_getattr_maxsz) |
265 | #define decode_statfs_maxsz (decode_getattr_maxsz) | |
1da177e4 LT |
266 | #define encode_delegreturn_maxsz (op_encode_hdr_maxsz + 4) |
267 | #define decode_delegreturn_maxsz (op_decode_hdr_maxsz) | |
9104a55d TM |
268 | #define encode_getacl_maxsz (encode_getattr_maxsz) |
269 | #define decode_getacl_maxsz (op_decode_hdr_maxsz + \ | |
270 | nfs4_fattr_bitmap_maxsz + 1) | |
271 | #define encode_setacl_maxsz (op_encode_hdr_maxsz + \ | |
272 | encode_stateid_maxsz + 3) | |
273 | #define decode_setacl_maxsz (decode_setattr_maxsz) | |
e6889620 TM |
274 | #define encode_fs_locations_maxsz \ |
275 | (encode_getattr_maxsz) | |
276 | #define decode_fs_locations_maxsz \ | |
277 | (0) | |
5a5ea0d4 | 278 | #define encode_secinfo_maxsz (op_encode_hdr_maxsz + nfs4_name_maxsz) |
1650add2 | 279 | #define decode_secinfo_maxsz (op_decode_hdr_maxsz + 1 + ((NFS_MAX_SECFLAVORS * (16 + GSS_OID_MAX_LEN)) / 4)) |
9b7b9fcc AA |
280 | |
281 | #if defined(CONFIG_NFS_V4_1) | |
fc931582 | 282 | #define NFS4_MAX_MACHINE_NAME_LEN (64) |
d751f748 JR |
283 | #define IMPL_NAME_LIMIT (sizeof(utsname()->sysname) + sizeof(utsname()->release) + \ |
284 | sizeof(utsname()->version) + sizeof(utsname()->machine) + 8) | |
fc931582 | 285 | |
99fe60d0 BH |
286 | #define encode_exchange_id_maxsz (op_encode_hdr_maxsz + \ |
287 | encode_verifier_maxsz + \ | |
288 | 1 /* co_ownerid.len */ + \ | |
289 | XDR_QUADLEN(NFS4_EXCHANGE_ID_LEN) + \ | |
290 | 1 /* flags */ + \ | |
291 | 1 /* spa_how */ + \ | |
2031cd1a WAA |
292 | /* max is SP4_MACH_CRED (for now) */ + \ |
293 | 1 + NFS4_OP_MAP_NUM_WORDS + \ | |
294 | 1 + NFS4_OP_MAP_NUM_WORDS + \ | |
db8ac8ba WAA |
295 | 1 /* implementation id array of size 1 */ + \ |
296 | 1 /* nii_domain */ + \ | |
297 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \ | |
298 | 1 /* nii_name */ + \ | |
d751f748 | 299 | XDR_QUADLEN(IMPL_NAME_LIMIT) + \ |
db8ac8ba | 300 | 3 /* nii_date */) |
99fe60d0 BH |
301 | #define decode_exchange_id_maxsz (op_decode_hdr_maxsz + \ |
302 | 2 /* eir_clientid */ + \ | |
303 | 1 /* eir_sequenceid */ + \ | |
304 | 1 /* eir_flags */ + \ | |
305 | 1 /* spr_how */ + \ | |
2031cd1a WAA |
306 | /* max is SP4_MACH_CRED (for now) */ + \ |
307 | 1 + NFS4_OP_MAP_NUM_WORDS + \ | |
308 | 1 + NFS4_OP_MAP_NUM_WORDS + \ | |
99fe60d0 BH |
309 | 2 /* eir_server_owner.so_minor_id */ + \ |
310 | /* eir_server_owner.so_major_id<> */ \ | |
311 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + 1 + \ | |
312 | /* eir_server_scope<> */ \ | |
313 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + 1 + \ | |
314 | 1 /* eir_server_impl_id array length */ + \ | |
7d2ed9ac WAA |
315 | 1 /* nii_domain */ + \ |
316 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \ | |
317 | 1 /* nii_name */ + \ | |
318 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \ | |
319 | 3 /* nii_date */) | |
fc931582 AA |
320 | #define encode_channel_attrs_maxsz (6 + 1 /* ca_rdma_ird.len (0) */) |
321 | #define decode_channel_attrs_maxsz (6 + \ | |
322 | 1 /* ca_rdma_ird.len */ + \ | |
323 | 1 /* ca_rdma_ird */) | |
324 | #define encode_create_session_maxsz (op_encode_hdr_maxsz + \ | |
325 | 2 /* csa_clientid */ + \ | |
326 | 1 /* csa_sequence */ + \ | |
327 | 1 /* csa_flags */ + \ | |
328 | encode_channel_attrs_maxsz + \ | |
329 | encode_channel_attrs_maxsz + \ | |
330 | 1 /* csa_cb_program */ + \ | |
331 | 1 /* csa_sec_parms.len (1) */ + \ | |
332 | 1 /* cb_secflavor (AUTH_SYS) */ + \ | |
333 | 1 /* stamp */ + \ | |
334 | 1 /* machinename.len */ + \ | |
335 | XDR_QUADLEN(NFS4_MAX_MACHINE_NAME_LEN) + \ | |
336 | 1 /* uid */ + \ | |
337 | 1 /* gid */ + \ | |
338 | 1 /* gids.len (0) */) | |
339 | #define decode_create_session_maxsz (op_decode_hdr_maxsz + \ | |
340 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + \ | |
341 | 1 /* csr_sequence */ + \ | |
342 | 1 /* csr_flags */ + \ | |
343 | decode_channel_attrs_maxsz + \ | |
344 | decode_channel_attrs_maxsz) | |
7c44f1ae WAA |
345 | #define encode_bind_conn_to_session_maxsz (op_encode_hdr_maxsz + \ |
346 | /* bctsa_sessid */ \ | |
347 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + \ | |
348 | 1 /* bctsa_dir */ + \ | |
349 | 1 /* bctsa_use_conn_in_rdma_mode */) | |
350 | #define decode_bind_conn_to_session_maxsz (op_decode_hdr_maxsz + \ | |
351 | /* bctsr_sessid */ \ | |
352 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + \ | |
353 | 1 /* bctsr_dir */ + \ | |
354 | 1 /* bctsr_use_conn_in_rdma_mode */) | |
0f3e66c6 AA |
355 | #define encode_destroy_session_maxsz (op_encode_hdr_maxsz + 4) |
356 | #define decode_destroy_session_maxsz (op_decode_hdr_maxsz) | |
66245539 TM |
357 | #define encode_destroy_clientid_maxsz (op_encode_hdr_maxsz + 2) |
358 | #define decode_destroy_clientid_maxsz (op_decode_hdr_maxsz) | |
fc01cea9 AA |
359 | #define encode_sequence_maxsz (op_encode_hdr_maxsz + \ |
360 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 4) | |
361 | #define decode_sequence_maxsz (op_decode_hdr_maxsz + \ | |
362 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 5) | |
18019753 RL |
363 | #define encode_reclaim_complete_maxsz (op_encode_hdr_maxsz + 4) |
364 | #define decode_reclaim_complete_maxsz (op_decode_hdr_maxsz + 4) | |
84c9dee3 CH |
365 | #define encode_getdeviceinfo_maxsz (op_encode_hdr_maxsz + \ |
366 | XDR_QUADLEN(NFS4_DEVICEID4_SIZE) + \ | |
367 | 1 /* layout type */ + \ | |
368 | 1 /* maxcount */ + \ | |
369 | 1 /* bitmap size */ + \ | |
370 | 1 /* notification bitmap length */ + \ | |
371 | 1 /* notification bitmap, word 0 */) | |
b1f69b75 AA |
372 | #define decode_getdeviceinfo_maxsz (op_decode_hdr_maxsz + \ |
373 | 1 /* layout type */ + \ | |
374 | 1 /* opaque devaddr4 length */ + \ | |
375 | /* devaddr4 payload is read into page */ \ | |
376 | 1 /* notification bitmap length */ + \ | |
84c9dee3 | 377 | 1 /* notification bitmap, word 0 */) |
b1f69b75 AA |
378 | #define encode_layoutget_maxsz (op_encode_hdr_maxsz + 10 + \ |
379 | encode_stateid_maxsz) | |
380 | #define decode_layoutget_maxsz (op_decode_hdr_maxsz + 8 + \ | |
381 | decode_stateid_maxsz + \ | |
382 | XDR_QUADLEN(PNFS_LAYOUT_MAXSIZE)) | |
863a3c6c AA |
383 | #define encode_layoutcommit_maxsz (op_encode_hdr_maxsz + \ |
384 | 2 /* offset */ + \ | |
385 | 2 /* length */ + \ | |
386 | 1 /* reclaim */ + \ | |
387 | encode_stateid_maxsz + \ | |
388 | 1 /* new offset (true) */ + \ | |
389 | 2 /* last byte written */ + \ | |
390 | 1 /* nt_timechanged (false) */ + \ | |
391 | 1 /* layoutupdate4 layout type */ + \ | |
5f919c9f CH |
392 | 1 /* layoutupdate4 opaqueue len */) |
393 | /* the actual content of layoutupdate4 should | |
394 | be allocated by drivers and spliced in | |
395 | using xdr_write_pages */ | |
863a3c6c | 396 | #define decode_layoutcommit_maxsz (op_decode_hdr_maxsz + 3) |
cbe82603 BH |
397 | #define encode_layoutreturn_maxsz (8 + op_encode_hdr_maxsz + \ |
398 | encode_stateid_maxsz + \ | |
399 | 1 /* FIXME: opaque lrf_body always empty at the moment */) | |
400 | #define decode_layoutreturn_maxsz (op_decode_hdr_maxsz + \ | |
401 | 1 + decode_stateid_maxsz) | |
fca78d6d BS |
402 | #define encode_secinfo_no_name_maxsz (op_encode_hdr_maxsz + 1) |
403 | #define decode_secinfo_no_name_maxsz decode_secinfo_maxsz | |
7d974794 BS |
404 | #define encode_test_stateid_maxsz (op_encode_hdr_maxsz + 2 + \ |
405 | XDR_QUADLEN(NFS4_STATEID_SIZE)) | |
406 | #define decode_test_stateid_maxsz (op_decode_hdr_maxsz + 2 + 1) | |
9aeda35f BS |
407 | #define encode_free_stateid_maxsz (op_encode_hdr_maxsz + 1 + \ |
408 | XDR_QUADLEN(NFS4_STATEID_SIZE)) | |
9f79fb48 | 409 | #define decode_free_stateid_maxsz (op_decode_hdr_maxsz) |
9b7b9fcc AA |
410 | #else /* CONFIG_NFS_V4_1 */ |
411 | #define encode_sequence_maxsz 0 | |
412 | #define decode_sequence_maxsz 0 | |
413 | #endif /* CONFIG_NFS_V4_1 */ | |
414 | ||
1da177e4 LT |
415 | #define NFS4_enc_compound_sz (1024) /* XXX: large enough? */ |
416 | #define NFS4_dec_compound_sz (1024) /* XXX: large enough? */ | |
417 | #define NFS4_enc_read_sz (compound_encode_hdr_maxsz + \ | |
9b7b9fcc | 418 | encode_sequence_maxsz + \ |
1da177e4 | 419 | encode_putfh_maxsz + \ |
9104a55d | 420 | encode_read_maxsz) |
1da177e4 | 421 | #define NFS4_dec_read_sz (compound_decode_hdr_maxsz + \ |
9b7b9fcc | 422 | decode_sequence_maxsz + \ |
1da177e4 | 423 | decode_putfh_maxsz + \ |
9104a55d | 424 | decode_read_maxsz) |
1da177e4 | 425 | #define NFS4_enc_readlink_sz (compound_encode_hdr_maxsz + \ |
9b7b9fcc | 426 | encode_sequence_maxsz + \ |
1da177e4 | 427 | encode_putfh_maxsz + \ |
9104a55d | 428 | encode_readlink_maxsz) |
1da177e4 | 429 | #define NFS4_dec_readlink_sz (compound_decode_hdr_maxsz + \ |
9b7b9fcc | 430 | decode_sequence_maxsz + \ |
1da177e4 | 431 | decode_putfh_maxsz + \ |
9104a55d | 432 | decode_readlink_maxsz) |
1da177e4 | 433 | #define NFS4_enc_readdir_sz (compound_encode_hdr_maxsz + \ |
9b7b9fcc | 434 | encode_sequence_maxsz + \ |
1da177e4 | 435 | encode_putfh_maxsz + \ |
9104a55d | 436 | encode_readdir_maxsz) |
1da177e4 | 437 | #define NFS4_dec_readdir_sz (compound_decode_hdr_maxsz + \ |
9b7b9fcc | 438 | decode_sequence_maxsz + \ |
1da177e4 | 439 | decode_putfh_maxsz + \ |
9104a55d | 440 | decode_readdir_maxsz) |
1da177e4 | 441 | #define NFS4_enc_write_sz (compound_encode_hdr_maxsz + \ |
9b7b9fcc | 442 | encode_sequence_maxsz + \ |
1da177e4 | 443 | encode_putfh_maxsz + \ |
9104a55d | 444 | encode_write_maxsz + \ |
4f9838c7 | 445 | encode_getattr_maxsz) |
1da177e4 | 446 | #define NFS4_dec_write_sz (compound_decode_hdr_maxsz + \ |
9b7b9fcc | 447 | decode_sequence_maxsz + \ |
1da177e4 | 448 | decode_putfh_maxsz + \ |
9104a55d | 449 | decode_write_maxsz + \ |
4f9838c7 | 450 | decode_getattr_maxsz) |
1da177e4 | 451 | #define NFS4_enc_commit_sz (compound_encode_hdr_maxsz + \ |
9b7b9fcc | 452 | encode_sequence_maxsz + \ |
1da177e4 | 453 | encode_putfh_maxsz + \ |
8582715e | 454 | encode_commit_maxsz) |
1da177e4 | 455 | #define NFS4_dec_commit_sz (compound_decode_hdr_maxsz + \ |
9b7b9fcc | 456 | decode_sequence_maxsz + \ |
1da177e4 | 457 | decode_putfh_maxsz + \ |
8582715e | 458 | decode_commit_maxsz) |
1da177e4 | 459 | #define NFS4_enc_open_sz (compound_encode_hdr_maxsz + \ |
9b7b9fcc | 460 | encode_sequence_maxsz + \ |
2cebf828 | 461 | encode_putfh_maxsz + \ |
2cebf828 | 462 | encode_open_maxsz + \ |
6168f62c | 463 | encode_access_maxsz + \ |
2cebf828 | 464 | encode_getfh_maxsz + \ |
2cebf828 | 465 | encode_getattr_maxsz) |
1da177e4 | 466 | #define NFS4_dec_open_sz (compound_decode_hdr_maxsz + \ |
9b7b9fcc | 467 | decode_sequence_maxsz + \ |
2cebf828 | 468 | decode_putfh_maxsz + \ |
2cebf828 | 469 | decode_open_maxsz + \ |
6168f62c | 470 | decode_access_maxsz + \ |
2cebf828 | 471 | decode_getfh_maxsz + \ |
2cebf828 | 472 | decode_getattr_maxsz) |
9104a55d TM |
473 | #define NFS4_enc_open_confirm_sz \ |
474 | (compound_encode_hdr_maxsz + \ | |
475 | encode_putfh_maxsz + \ | |
476 | encode_open_confirm_maxsz) | |
477 | #define NFS4_dec_open_confirm_sz \ | |
478 | (compound_decode_hdr_maxsz + \ | |
479 | decode_putfh_maxsz + \ | |
480 | decode_open_confirm_maxsz) | |
1da177e4 | 481 | #define NFS4_enc_open_noattr_sz (compound_encode_hdr_maxsz + \ |
9b7b9fcc | 482 | encode_sequence_maxsz + \ |
1da177e4 | 483 | encode_putfh_maxsz + \ |
2cebf828 | 484 | encode_open_maxsz + \ |
6168f62c | 485 | encode_access_maxsz + \ |
2cebf828 | 486 | encode_getattr_maxsz) |
1da177e4 | 487 | #define NFS4_dec_open_noattr_sz (compound_decode_hdr_maxsz + \ |
9b7b9fcc | 488 | decode_sequence_maxsz + \ |
1da177e4 | 489 | decode_putfh_maxsz + \ |
2cebf828 | 490 | decode_open_maxsz + \ |
6168f62c | 491 | decode_access_maxsz + \ |
2cebf828 | 492 | decode_getattr_maxsz) |
1da177e4 LT |
493 | #define NFS4_enc_open_downgrade_sz \ |
494 | (compound_encode_hdr_maxsz + \ | |
9b7b9fcc | 495 | encode_sequence_maxsz + \ |
9104a55d TM |
496 | encode_putfh_maxsz + \ |
497 | encode_open_downgrade_maxsz + \ | |
498 | encode_getattr_maxsz) | |
1da177e4 LT |
499 | #define NFS4_dec_open_downgrade_sz \ |
500 | (compound_decode_hdr_maxsz + \ | |
9b7b9fcc | 501 | decode_sequence_maxsz + \ |
9104a55d TM |
502 | decode_putfh_maxsz + \ |
503 | decode_open_downgrade_maxsz + \ | |
504 | decode_getattr_maxsz) | |
505 | #define NFS4_enc_close_sz (compound_encode_hdr_maxsz + \ | |
9b7b9fcc | 506 | encode_sequence_maxsz + \ |
9104a55d TM |
507 | encode_putfh_maxsz + \ |
508 | encode_close_maxsz + \ | |
509 | encode_getattr_maxsz) | |
510 | #define NFS4_dec_close_sz (compound_decode_hdr_maxsz + \ | |
9b7b9fcc | 511 | decode_sequence_maxsz + \ |
9104a55d TM |
512 | decode_putfh_maxsz + \ |
513 | decode_close_maxsz + \ | |
514 | decode_getattr_maxsz) | |
515 | #define NFS4_enc_setattr_sz (compound_encode_hdr_maxsz + \ | |
9b7b9fcc | 516 | encode_sequence_maxsz + \ |
9104a55d TM |
517 | encode_putfh_maxsz + \ |
518 | encode_setattr_maxsz + \ | |
519 | encode_getattr_maxsz) | |
520 | #define NFS4_dec_setattr_sz (compound_decode_hdr_maxsz + \ | |
9b7b9fcc | 521 | decode_sequence_maxsz + \ |
9104a55d TM |
522 | decode_putfh_maxsz + \ |
523 | decode_setattr_maxsz + \ | |
524 | decode_getattr_maxsz) | |
1da177e4 | 525 | #define NFS4_enc_fsinfo_sz (compound_encode_hdr_maxsz + \ |
9b7b9fcc | 526 | encode_sequence_maxsz + \ |
1da177e4 LT |
527 | encode_putfh_maxsz + \ |
528 | encode_fsinfo_maxsz) | |
529 | #define NFS4_dec_fsinfo_sz (compound_decode_hdr_maxsz + \ | |
9b7b9fcc | 530 | decode_sequence_maxsz + \ |
1da177e4 LT |
531 | decode_putfh_maxsz + \ |
532 | decode_fsinfo_maxsz) | |
533 | #define NFS4_enc_renew_sz (compound_encode_hdr_maxsz + \ | |
534 | encode_renew_maxsz) | |
535 | #define NFS4_dec_renew_sz (compound_decode_hdr_maxsz + \ | |
536 | decode_renew_maxsz) | |
537 | #define NFS4_enc_setclientid_sz (compound_encode_hdr_maxsz + \ | |
538 | encode_setclientid_maxsz) | |
539 | #define NFS4_dec_setclientid_sz (compound_decode_hdr_maxsz + \ | |
540 | decode_setclientid_maxsz) | |
541 | #define NFS4_enc_setclientid_confirm_sz \ | |
542 | (compound_encode_hdr_maxsz + \ | |
83ca7f5a | 543 | encode_setclientid_confirm_maxsz) |
1da177e4 LT |
544 | #define NFS4_dec_setclientid_confirm_sz \ |
545 | (compound_decode_hdr_maxsz + \ | |
83ca7f5a | 546 | decode_setclientid_confirm_maxsz) |
1da177e4 | 547 | #define NFS4_enc_lock_sz (compound_encode_hdr_maxsz + \ |
9b7b9fcc | 548 | encode_sequence_maxsz + \ |
1da177e4 | 549 | encode_putfh_maxsz + \ |
9104a55d | 550 | encode_lock_maxsz) |
1da177e4 | 551 | #define NFS4_dec_lock_sz (compound_decode_hdr_maxsz + \ |
9b7b9fcc | 552 | decode_sequence_maxsz + \ |
1da177e4 | 553 | decode_putfh_maxsz + \ |
9104a55d | 554 | decode_lock_maxsz) |
1da177e4 | 555 | #define NFS4_enc_lockt_sz (compound_encode_hdr_maxsz + \ |
9b7b9fcc | 556 | encode_sequence_maxsz + \ |
1da177e4 | 557 | encode_putfh_maxsz + \ |
9104a55d TM |
558 | encode_lockt_maxsz) |
559 | #define NFS4_dec_lockt_sz (compound_decode_hdr_maxsz + \ | |
9b7b9fcc | 560 | decode_sequence_maxsz + \ |
9104a55d TM |
561 | decode_putfh_maxsz + \ |
562 | decode_lockt_maxsz) | |
1da177e4 | 563 | #define NFS4_enc_locku_sz (compound_encode_hdr_maxsz + \ |
9b7b9fcc | 564 | encode_sequence_maxsz + \ |
1da177e4 | 565 | encode_putfh_maxsz + \ |
9104a55d | 566 | encode_locku_maxsz) |
1da177e4 | 567 | #define NFS4_dec_locku_sz (compound_decode_hdr_maxsz + \ |
9b7b9fcc | 568 | decode_sequence_maxsz + \ |
1da177e4 | 569 | decode_putfh_maxsz + \ |
9104a55d | 570 | decode_locku_maxsz) |
d3c7b7cc TM |
571 | #define NFS4_enc_release_lockowner_sz \ |
572 | (compound_encode_hdr_maxsz + \ | |
573 | encode_lockowner_maxsz) | |
574 | #define NFS4_dec_release_lockowner_sz \ | |
575 | (compound_decode_hdr_maxsz + \ | |
576 | decode_lockowner_maxsz) | |
1da177e4 | 577 | #define NFS4_enc_access_sz (compound_encode_hdr_maxsz + \ |
9b7b9fcc | 578 | encode_sequence_maxsz + \ |
1da177e4 | 579 | encode_putfh_maxsz + \ |
76b32999 TM |
580 | encode_access_maxsz + \ |
581 | encode_getattr_maxsz) | |
1da177e4 | 582 | #define NFS4_dec_access_sz (compound_decode_hdr_maxsz + \ |
9b7b9fcc | 583 | decode_sequence_maxsz + \ |
1da177e4 | 584 | decode_putfh_maxsz + \ |
76b32999 TM |
585 | decode_access_maxsz + \ |
586 | decode_getattr_maxsz) | |
1da177e4 | 587 | #define NFS4_enc_getattr_sz (compound_encode_hdr_maxsz + \ |
9b7b9fcc | 588 | encode_sequence_maxsz + \ |
1da177e4 | 589 | encode_putfh_maxsz + \ |
44c99933 CL |
590 | encode_getattr_maxsz + \ |
591 | encode_renew_maxsz) | |
1da177e4 | 592 | #define NFS4_dec_getattr_sz (compound_decode_hdr_maxsz + \ |
9b7b9fcc | 593 | decode_sequence_maxsz + \ |
1da177e4 | 594 | decode_putfh_maxsz + \ |
44c99933 CL |
595 | decode_getattr_maxsz + \ |
596 | decode_renew_maxsz) | |
1da177e4 | 597 | #define NFS4_enc_lookup_sz (compound_encode_hdr_maxsz + \ |
9b7b9fcc | 598 | encode_sequence_maxsz + \ |
1da177e4 LT |
599 | encode_putfh_maxsz + \ |
600 | encode_lookup_maxsz + \ | |
601 | encode_getattr_maxsz + \ | |
602 | encode_getfh_maxsz) | |
603 | #define NFS4_dec_lookup_sz (compound_decode_hdr_maxsz + \ | |
9b7b9fcc | 604 | decode_sequence_maxsz + \ |
1da177e4 | 605 | decode_putfh_maxsz + \ |
e6889620 | 606 | decode_lookup_maxsz + \ |
1da177e4 LT |
607 | decode_getattr_maxsz + \ |
608 | decode_getfh_maxsz) | |
609 | #define NFS4_enc_lookup_root_sz (compound_encode_hdr_maxsz + \ | |
9b7b9fcc | 610 | encode_sequence_maxsz + \ |
1da177e4 LT |
611 | encode_putrootfh_maxsz + \ |
612 | encode_getattr_maxsz + \ | |
613 | encode_getfh_maxsz) | |
614 | #define NFS4_dec_lookup_root_sz (compound_decode_hdr_maxsz + \ | |
9b7b9fcc | 615 | decode_sequence_maxsz + \ |
1da177e4 LT |
616 | decode_putrootfh_maxsz + \ |
617 | decode_getattr_maxsz + \ | |
618 | decode_getfh_maxsz) | |
619 | #define NFS4_enc_remove_sz (compound_encode_hdr_maxsz + \ | |
9b7b9fcc | 620 | encode_sequence_maxsz + \ |
1da177e4 | 621 | encode_putfh_maxsz + \ |
778d2817 | 622 | encode_remove_maxsz) |
1da177e4 | 623 | #define NFS4_dec_remove_sz (compound_decode_hdr_maxsz + \ |
9b7b9fcc | 624 | decode_sequence_maxsz + \ |
1da177e4 | 625 | decode_putfh_maxsz + \ |
778d2817 | 626 | decode_remove_maxsz) |
1da177e4 | 627 | #define NFS4_enc_rename_sz (compound_encode_hdr_maxsz + \ |
9b7b9fcc | 628 | encode_sequence_maxsz + \ |
1da177e4 LT |
629 | encode_putfh_maxsz + \ |
630 | encode_savefh_maxsz + \ | |
631 | encode_putfh_maxsz + \ | |
778d2817 | 632 | encode_rename_maxsz) |
1da177e4 | 633 | #define NFS4_dec_rename_sz (compound_decode_hdr_maxsz + \ |
9b7b9fcc | 634 | decode_sequence_maxsz + \ |
1da177e4 LT |
635 | decode_putfh_maxsz + \ |
636 | decode_savefh_maxsz + \ | |
637 | decode_putfh_maxsz + \ | |
778d2817 | 638 | decode_rename_maxsz) |
1da177e4 | 639 | #define NFS4_enc_link_sz (compound_encode_hdr_maxsz + \ |
9b7b9fcc | 640 | encode_sequence_maxsz + \ |
1da177e4 LT |
641 | encode_putfh_maxsz + \ |
642 | encode_savefh_maxsz + \ | |
643 | encode_putfh_maxsz + \ | |
91ba2eee | 644 | encode_link_maxsz + \ |
91ba2eee | 645 | encode_restorefh_maxsz + \ |
a9f6991b | 646 | encode_getattr_maxsz) |
1da177e4 | 647 | #define NFS4_dec_link_sz (compound_decode_hdr_maxsz + \ |
9b7b9fcc | 648 | decode_sequence_maxsz + \ |
1da177e4 LT |
649 | decode_putfh_maxsz + \ |
650 | decode_savefh_maxsz + \ | |
651 | decode_putfh_maxsz + \ | |
91ba2eee | 652 | decode_link_maxsz + \ |
91ba2eee TM |
653 | decode_restorefh_maxsz + \ |
654 | decode_getattr_maxsz) | |
1da177e4 | 655 | #define NFS4_enc_symlink_sz (compound_encode_hdr_maxsz + \ |
9b7b9fcc | 656 | encode_sequence_maxsz + \ |
1da177e4 LT |
657 | encode_putfh_maxsz + \ |
658 | encode_symlink_maxsz + \ | |
659 | encode_getattr_maxsz + \ | |
660 | encode_getfh_maxsz) | |
661 | #define NFS4_dec_symlink_sz (compound_decode_hdr_maxsz + \ | |
9b7b9fcc | 662 | decode_sequence_maxsz + \ |
1da177e4 LT |
663 | decode_putfh_maxsz + \ |
664 | decode_symlink_maxsz + \ | |
665 | decode_getattr_maxsz + \ | |
666 | decode_getfh_maxsz) | |
667 | #define NFS4_enc_create_sz (compound_encode_hdr_maxsz + \ | |
9b7b9fcc | 668 | encode_sequence_maxsz + \ |
1da177e4 LT |
669 | encode_putfh_maxsz + \ |
670 | encode_create_maxsz + \ | |
56ae19f3 | 671 | encode_getfh_maxsz + \ |
56ae19f3 | 672 | encode_getattr_maxsz) |
1da177e4 | 673 | #define NFS4_dec_create_sz (compound_decode_hdr_maxsz + \ |
9b7b9fcc | 674 | decode_sequence_maxsz + \ |
1da177e4 LT |
675 | decode_putfh_maxsz + \ |
676 | decode_create_maxsz + \ | |
56ae19f3 | 677 | decode_getfh_maxsz + \ |
56ae19f3 | 678 | decode_getattr_maxsz) |
1da177e4 | 679 | #define NFS4_enc_pathconf_sz (compound_encode_hdr_maxsz + \ |
9b7b9fcc | 680 | encode_sequence_maxsz + \ |
1da177e4 LT |
681 | encode_putfh_maxsz + \ |
682 | encode_getattr_maxsz) | |
683 | #define NFS4_dec_pathconf_sz (compound_decode_hdr_maxsz + \ | |
9b7b9fcc | 684 | decode_sequence_maxsz + \ |
1da177e4 LT |
685 | decode_putfh_maxsz + \ |
686 | decode_getattr_maxsz) | |
687 | #define NFS4_enc_statfs_sz (compound_encode_hdr_maxsz + \ | |
9b7b9fcc | 688 | encode_sequence_maxsz + \ |
1da177e4 | 689 | encode_putfh_maxsz + \ |
9104a55d | 690 | encode_statfs_maxsz) |
1da177e4 | 691 | #define NFS4_dec_statfs_sz (compound_decode_hdr_maxsz + \ |
9b7b9fcc | 692 | decode_sequence_maxsz + \ |
1da177e4 | 693 | decode_putfh_maxsz + \ |
9104a55d | 694 | decode_statfs_maxsz) |
1da177e4 | 695 | #define NFS4_enc_server_caps_sz (compound_encode_hdr_maxsz + \ |
9b7b9fcc | 696 | encode_sequence_maxsz + \ |
ab91f264 | 697 | encode_putfh_maxsz + \ |
1da177e4 LT |
698 | encode_getattr_maxsz) |
699 | #define NFS4_dec_server_caps_sz (compound_decode_hdr_maxsz + \ | |
9b7b9fcc | 700 | decode_sequence_maxsz + \ |
ab91f264 | 701 | decode_putfh_maxsz + \ |
1da177e4 LT |
702 | decode_getattr_maxsz) |
703 | #define NFS4_enc_delegreturn_sz (compound_encode_hdr_maxsz + \ | |
9b7b9fcc | 704 | encode_sequence_maxsz + \ |
1da177e4 | 705 | encode_putfh_maxsz + \ |
fa178f29 TM |
706 | encode_delegreturn_maxsz + \ |
707 | encode_getattr_maxsz) | |
1da177e4 | 708 | #define NFS4_dec_delegreturn_sz (compound_decode_hdr_maxsz + \ |
9b7b9fcc | 709 | decode_sequence_maxsz + \ |
fa178f29 TM |
710 | decode_delegreturn_maxsz + \ |
711 | decode_getattr_maxsz) | |
029d105e | 712 | #define NFS4_enc_getacl_sz (compound_encode_hdr_maxsz + \ |
9b7b9fcc | 713 | encode_sequence_maxsz + \ |
029d105e | 714 | encode_putfh_maxsz + \ |
9104a55d | 715 | encode_getacl_maxsz) |
029d105e | 716 | #define NFS4_dec_getacl_sz (compound_decode_hdr_maxsz + \ |
9b7b9fcc | 717 | decode_sequence_maxsz + \ |
029d105e | 718 | decode_putfh_maxsz + \ |
9104a55d | 719 | decode_getacl_maxsz) |
23ec6965 | 720 | #define NFS4_enc_setacl_sz (compound_encode_hdr_maxsz + \ |
9b7b9fcc | 721 | encode_sequence_maxsz + \ |
23ec6965 | 722 | encode_putfh_maxsz + \ |
9104a55d | 723 | encode_setacl_maxsz) |
23ec6965 | 724 | #define NFS4_dec_setacl_sz (compound_decode_hdr_maxsz + \ |
9b7b9fcc | 725 | decode_sequence_maxsz + \ |
23ec6965 | 726 | decode_putfh_maxsz + \ |
9104a55d | 727 | decode_setacl_maxsz) |
683b57b4 TM |
728 | #define NFS4_enc_fs_locations_sz \ |
729 | (compound_encode_hdr_maxsz + \ | |
9b7b9fcc | 730 | encode_sequence_maxsz + \ |
683b57b4 | 731 | encode_putfh_maxsz + \ |
e6889620 | 732 | encode_lookup_maxsz + \ |
b03d735b CL |
733 | encode_fs_locations_maxsz + \ |
734 | encode_renew_maxsz) | |
683b57b4 TM |
735 | #define NFS4_dec_fs_locations_sz \ |
736 | (compound_decode_hdr_maxsz + \ | |
9b7b9fcc | 737 | decode_sequence_maxsz + \ |
683b57b4 | 738 | decode_putfh_maxsz + \ |
e6889620 | 739 | decode_lookup_maxsz + \ |
b03d735b CL |
740 | decode_fs_locations_maxsz + \ |
741 | decode_renew_maxsz) | |
5a5ea0d4 BS |
742 | #define NFS4_enc_secinfo_sz (compound_encode_hdr_maxsz + \ |
743 | encode_sequence_maxsz + \ | |
744 | encode_putfh_maxsz + \ | |
745 | encode_secinfo_maxsz) | |
746 | #define NFS4_dec_secinfo_sz (compound_decode_hdr_maxsz + \ | |
747 | decode_sequence_maxsz + \ | |
748 | decode_putfh_maxsz + \ | |
749 | decode_secinfo_maxsz) | |
44c99933 CL |
750 | #define NFS4_enc_fsid_present_sz \ |
751 | (compound_encode_hdr_maxsz + \ | |
752 | encode_sequence_maxsz + \ | |
753 | encode_putfh_maxsz + \ | |
754 | encode_getfh_maxsz + \ | |
755 | encode_renew_maxsz) | |
756 | #define NFS4_dec_fsid_present_sz \ | |
757 | (compound_decode_hdr_maxsz + \ | |
758 | decode_sequence_maxsz + \ | |
759 | decode_putfh_maxsz + \ | |
760 | decode_getfh_maxsz + \ | |
761 | decode_renew_maxsz) | |
99fe60d0 | 762 | #if defined(CONFIG_NFS_V4_1) |
7c44f1ae WAA |
763 | #define NFS4_enc_bind_conn_to_session_sz \ |
764 | (compound_encode_hdr_maxsz + \ | |
765 | encode_bind_conn_to_session_maxsz) | |
766 | #define NFS4_dec_bind_conn_to_session_sz \ | |
767 | (compound_decode_hdr_maxsz + \ | |
768 | decode_bind_conn_to_session_maxsz) | |
99fe60d0 BH |
769 | #define NFS4_enc_exchange_id_sz \ |
770 | (compound_encode_hdr_maxsz + \ | |
771 | encode_exchange_id_maxsz) | |
772 | #define NFS4_dec_exchange_id_sz \ | |
773 | (compound_decode_hdr_maxsz + \ | |
774 | decode_exchange_id_maxsz) | |
fc931582 AA |
775 | #define NFS4_enc_create_session_sz \ |
776 | (compound_encode_hdr_maxsz + \ | |
777 | encode_create_session_maxsz) | |
778 | #define NFS4_dec_create_session_sz \ | |
779 | (compound_decode_hdr_maxsz + \ | |
780 | decode_create_session_maxsz) | |
0f3e66c6 AA |
781 | #define NFS4_enc_destroy_session_sz (compound_encode_hdr_maxsz + \ |
782 | encode_destroy_session_maxsz) | |
783 | #define NFS4_dec_destroy_session_sz (compound_decode_hdr_maxsz + \ | |
784 | decode_destroy_session_maxsz) | |
66245539 TM |
785 | #define NFS4_enc_destroy_clientid_sz (compound_encode_hdr_maxsz + \ |
786 | encode_destroy_clientid_maxsz) | |
787 | #define NFS4_dec_destroy_clientid_sz (compound_decode_hdr_maxsz + \ | |
788 | decode_destroy_clientid_maxsz) | |
fc01cea9 AA |
789 | #define NFS4_enc_sequence_sz \ |
790 | (compound_decode_hdr_maxsz + \ | |
791 | encode_sequence_maxsz) | |
792 | #define NFS4_dec_sequence_sz \ | |
793 | (compound_decode_hdr_maxsz + \ | |
794 | decode_sequence_maxsz) | |
2050f0cc AA |
795 | #define NFS4_enc_get_lease_time_sz (compound_encode_hdr_maxsz + \ |
796 | encode_sequence_maxsz + \ | |
797 | encode_putrootfh_maxsz + \ | |
798 | encode_fsinfo_maxsz) | |
799 | #define NFS4_dec_get_lease_time_sz (compound_decode_hdr_maxsz + \ | |
800 | decode_sequence_maxsz + \ | |
801 | decode_putrootfh_maxsz + \ | |
802 | decode_fsinfo_maxsz) | |
18019753 RL |
803 | #define NFS4_enc_reclaim_complete_sz (compound_encode_hdr_maxsz + \ |
804 | encode_sequence_maxsz + \ | |
805 | encode_reclaim_complete_maxsz) | |
806 | #define NFS4_dec_reclaim_complete_sz (compound_decode_hdr_maxsz + \ | |
807 | decode_sequence_maxsz + \ | |
808 | decode_reclaim_complete_maxsz) | |
b1f69b75 AA |
809 | #define NFS4_enc_getdeviceinfo_sz (compound_encode_hdr_maxsz + \ |
810 | encode_sequence_maxsz +\ | |
811 | encode_getdeviceinfo_maxsz) | |
812 | #define NFS4_dec_getdeviceinfo_sz (compound_decode_hdr_maxsz + \ | |
813 | decode_sequence_maxsz + \ | |
814 | decode_getdeviceinfo_maxsz) | |
815 | #define NFS4_enc_layoutget_sz (compound_encode_hdr_maxsz + \ | |
816 | encode_sequence_maxsz + \ | |
817 | encode_putfh_maxsz + \ | |
818 | encode_layoutget_maxsz) | |
819 | #define NFS4_dec_layoutget_sz (compound_decode_hdr_maxsz + \ | |
820 | decode_sequence_maxsz + \ | |
821 | decode_putfh_maxsz + \ | |
822 | decode_layoutget_maxsz) | |
863a3c6c AA |
823 | #define NFS4_enc_layoutcommit_sz (compound_encode_hdr_maxsz + \ |
824 | encode_sequence_maxsz +\ | |
825 | encode_putfh_maxsz + \ | |
826 | encode_layoutcommit_maxsz + \ | |
827 | encode_getattr_maxsz) | |
828 | #define NFS4_dec_layoutcommit_sz (compound_decode_hdr_maxsz + \ | |
829 | decode_sequence_maxsz + \ | |
830 | decode_putfh_maxsz + \ | |
831 | decode_layoutcommit_maxsz + \ | |
832 | decode_getattr_maxsz) | |
cbe82603 BH |
833 | #define NFS4_enc_layoutreturn_sz (compound_encode_hdr_maxsz + \ |
834 | encode_sequence_maxsz + \ | |
835 | encode_putfh_maxsz + \ | |
836 | encode_layoutreturn_maxsz) | |
837 | #define NFS4_dec_layoutreturn_sz (compound_decode_hdr_maxsz + \ | |
838 | decode_sequence_maxsz + \ | |
839 | decode_putfh_maxsz + \ | |
840 | decode_layoutreturn_maxsz) | |
fca78d6d BS |
841 | #define NFS4_enc_secinfo_no_name_sz (compound_encode_hdr_maxsz + \ |
842 | encode_sequence_maxsz + \ | |
843 | encode_putrootfh_maxsz +\ | |
844 | encode_secinfo_no_name_maxsz) | |
845 | #define NFS4_dec_secinfo_no_name_sz (compound_decode_hdr_maxsz + \ | |
846 | decode_sequence_maxsz + \ | |
847 | decode_putrootfh_maxsz + \ | |
848 | decode_secinfo_no_name_maxsz) | |
7d974794 BS |
849 | #define NFS4_enc_test_stateid_sz (compound_encode_hdr_maxsz + \ |
850 | encode_sequence_maxsz + \ | |
851 | encode_test_stateid_maxsz) | |
852 | #define NFS4_dec_test_stateid_sz (compound_decode_hdr_maxsz + \ | |
853 | decode_sequence_maxsz + \ | |
854 | decode_test_stateid_maxsz) | |
9aeda35f BS |
855 | #define NFS4_enc_free_stateid_sz (compound_encode_hdr_maxsz + \ |
856 | encode_sequence_maxsz + \ | |
857 | encode_free_stateid_maxsz) | |
858 | #define NFS4_dec_free_stateid_sz (compound_decode_hdr_maxsz + \ | |
859 | decode_sequence_maxsz + \ | |
860 | decode_free_stateid_maxsz) | |
2449ea2e AB |
861 | |
862 | const u32 nfs41_maxwrite_overhead = ((RPC_MAX_HEADER_WITH_AUTH + | |
863 | compound_encode_hdr_maxsz + | |
864 | encode_sequence_maxsz + | |
865 | encode_putfh_maxsz + | |
866 | encode_getattr_maxsz) * | |
867 | XDR_UNIT); | |
868 | ||
869 | const u32 nfs41_maxread_overhead = ((RPC_MAX_HEADER_WITH_AUTH + | |
870 | compound_decode_hdr_maxsz + | |
871 | decode_sequence_maxsz + | |
872 | decode_putfh_maxsz) * | |
873 | XDR_UNIT); | |
f1c097be AA |
874 | |
875 | const u32 nfs41_maxgetdevinfo_overhead = ((RPC_MAX_REPHEADER_WITH_AUTH + | |
876 | compound_decode_hdr_maxsz + | |
877 | decode_sequence_maxsz) * | |
878 | XDR_UNIT); | |
879 | EXPORT_SYMBOL_GPL(nfs41_maxgetdevinfo_overhead); | |
99fe60d0 | 880 | #endif /* CONFIG_NFS_V4_1 */ |
1da177e4 | 881 | |
bca79478 TM |
882 | static const umode_t nfs_type2fmt[] = { |
883 | [NF4BAD] = 0, | |
884 | [NF4REG] = S_IFREG, | |
885 | [NF4DIR] = S_IFDIR, | |
886 | [NF4BLK] = S_IFBLK, | |
887 | [NF4CHR] = S_IFCHR, | |
888 | [NF4LNK] = S_IFLNK, | |
889 | [NF4SOCK] = S_IFSOCK, | |
890 | [NF4FIFO] = S_IFIFO, | |
891 | [NF4ATTRDIR] = 0, | |
892 | [NF4NAMEDATTR] = 0, | |
1da177e4 LT |
893 | }; |
894 | ||
895 | struct compound_hdr { | |
896 | int32_t status; | |
897 | uint32_t nops; | |
d017931c | 898 | __be32 * nops_p; |
1da177e4 LT |
899 | uint32_t taglen; |
900 | char * tag; | |
0c4e8c18 | 901 | uint32_t replen; /* expected reply words */ |
66cc0429 | 902 | u32 minorversion; |
1da177e4 LT |
903 | }; |
904 | ||
13c65ce9 BH |
905 | static __be32 *reserve_space(struct xdr_stream *xdr, size_t nbytes) |
906 | { | |
907 | __be32 *p = xdr_reserve_space(xdr, nbytes); | |
908 | BUG_ON(!p); | |
909 | return p; | |
910 | } | |
1da177e4 | 911 | |
cb17e556 TM |
912 | static void encode_opaque_fixed(struct xdr_stream *xdr, const void *buf, size_t len) |
913 | { | |
914 | __be32 *p; | |
915 | ||
916 | p = xdr_reserve_space(xdr, len); | |
917 | xdr_encode_opaque_fixed(p, buf, len); | |
918 | } | |
919 | ||
1da177e4 LT |
920 | static void encode_string(struct xdr_stream *xdr, unsigned int len, const char *str) |
921 | { | |
8687b63a | 922 | __be32 *p; |
1da177e4 | 923 | |
6fdfb0bc | 924 | p = reserve_space(xdr, 4 + len); |
1da177e4 LT |
925 | xdr_encode_opaque(p, str, len); |
926 | } | |
927 | ||
4ade9821 TM |
928 | static void encode_uint32(struct xdr_stream *xdr, u32 n) |
929 | { | |
930 | __be32 *p; | |
931 | ||
932 | p = reserve_space(xdr, 4); | |
933 | *p = cpu_to_be32(n); | |
934 | } | |
935 | ||
ff2eb681 TM |
936 | static void encode_uint64(struct xdr_stream *xdr, u64 n) |
937 | { | |
938 | __be32 *p; | |
939 | ||
940 | p = reserve_space(xdr, 8); | |
941 | xdr_encode_hyper(p, n); | |
942 | } | |
943 | ||
4ade9821 TM |
944 | static void encode_nfs4_seqid(struct xdr_stream *xdr, |
945 | const struct nfs_seqid *seqid) | |
946 | { | |
947 | encode_uint32(xdr, seqid->sequence->counter); | |
948 | } | |
949 | ||
0c4e8c18 BH |
950 | static void encode_compound_hdr(struct xdr_stream *xdr, |
951 | struct rpc_rqst *req, | |
952 | struct compound_hdr *hdr) | |
1da177e4 | 953 | { |
8687b63a | 954 | __be32 *p; |
a17c2153 | 955 | struct rpc_auth *auth = req->rq_cred->cr_auth; |
0c4e8c18 BH |
956 | |
957 | /* initialize running count of expected bytes in reply. | |
958 | * NOTE: the replied tag SHOULD be the same is the one sent, | |
959 | * but this is not required as a MUST for the server to do so. */ | |
960 | hdr->replen = RPC_REPHDRSIZE + auth->au_rslack + 3 + hdr->taglen; | |
1da177e4 | 961 | |
7fc38846 | 962 | WARN_ON_ONCE(hdr->taglen > NFS4_MAXTAGLEN); |
6fdfb0bc TM |
963 | encode_string(xdr, hdr->taglen, hdr->tag); |
964 | p = reserve_space(xdr, 8); | |
e75bc1c8 | 965 | *p++ = cpu_to_be32(hdr->minorversion); |
d017931c | 966 | hdr->nops_p = p; |
34558513 | 967 | *p = cpu_to_be32(hdr->nops); |
d017931c AA |
968 | } |
969 | ||
ab19b481 TM |
970 | static void encode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 op, |
971 | uint32_t replen, | |
972 | struct compound_hdr *hdr) | |
973 | { | |
974 | encode_uint32(xdr, op); | |
975 | hdr->nops++; | |
976 | hdr->replen += replen; | |
977 | } | |
978 | ||
d017931c AA |
979 | static void encode_nops(struct compound_hdr *hdr) |
980 | { | |
7fc38846 | 981 | WARN_ON_ONCE(hdr->nops > NFS4_MAX_OPS); |
d017931c | 982 | *hdr->nops_p = htonl(hdr->nops); |
1da177e4 LT |
983 | } |
984 | ||
ea9d23f5 TM |
985 | static void encode_nfs4_stateid(struct xdr_stream *xdr, const nfs4_stateid *stateid) |
986 | { | |
2d2f24ad | 987 | encode_opaque_fixed(xdr, stateid, NFS4_STATEID_SIZE); |
ea9d23f5 TM |
988 | } |
989 | ||
1da177e4 LT |
990 | static void encode_nfs4_verifier(struct xdr_stream *xdr, const nfs4_verifier *verf) |
991 | { | |
cb17e556 | 992 | encode_opaque_fixed(xdr, verf->data, NFS4_VERIFIER_SIZE); |
1da177e4 LT |
993 | } |
994 | ||
aa9c2669 DQ |
995 | static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap, |
996 | const struct nfs4_label *label, | |
997 | const struct nfs_server *server) | |
1da177e4 LT |
998 | { |
999 | char owner_name[IDMAP_NAMESZ]; | |
1000 | char owner_group[IDMAP_NAMESZ]; | |
1001 | int owner_namelen = 0; | |
1002 | int owner_grouplen = 0; | |
8687b63a | 1003 | __be32 *p; |
d7067b2d TM |
1004 | unsigned i; |
1005 | uint32_t len = 0; | |
1006 | uint32_t bmval_len; | |
1007 | uint32_t bmval[3] = { 0 }; | |
1da177e4 LT |
1008 | |
1009 | /* | |
1010 | * We reserve enough space to write the entire attribute buffer at once. | |
1011 | * In the worst-case, this would be | |
a09df2ca DQ |
1012 | * 16(bitmap) + 4(attrlen) + 8(size) + 4(mode) + 4(atime) + 4(mtime) |
1013 | * = 40 bytes, plus any contribution from variable-length fields | |
23ec6965 | 1014 | * such as owner/group. |
1da177e4 | 1015 | */ |
d7067b2d TM |
1016 | if (iap->ia_valid & ATTR_SIZE) { |
1017 | bmval[0] |= FATTR4_WORD0_SIZE; | |
1da177e4 | 1018 | len += 8; |
d7067b2d TM |
1019 | } |
1020 | if (iap->ia_valid & ATTR_MODE) { | |
1021 | bmval[1] |= FATTR4_WORD1_MODE; | |
1da177e4 | 1022 | len += 4; |
d7067b2d | 1023 | } |
1da177e4 | 1024 | if (iap->ia_valid & ATTR_UID) { |
e4fd72a1 | 1025 | owner_namelen = nfs_map_uid_to_name(server, iap->ia_uid, owner_name, IDMAP_NAMESZ); |
1da177e4 | 1026 | if (owner_namelen < 0) { |
fe82a183 | 1027 | dprintk("nfs: couldn't resolve uid %d to string\n", |
e5782076 | 1028 | from_kuid(&init_user_ns, iap->ia_uid)); |
1da177e4 LT |
1029 | /* XXX */ |
1030 | strcpy(owner_name, "nobody"); | |
1031 | owner_namelen = sizeof("nobody") - 1; | |
1032 | /* goto out; */ | |
1033 | } | |
d7067b2d | 1034 | bmval[1] |= FATTR4_WORD1_OWNER; |
1da177e4 LT |
1035 | len += 4 + (XDR_QUADLEN(owner_namelen) << 2); |
1036 | } | |
1037 | if (iap->ia_valid & ATTR_GID) { | |
e4fd72a1 | 1038 | owner_grouplen = nfs_map_gid_to_group(server, iap->ia_gid, owner_group, IDMAP_NAMESZ); |
1da177e4 | 1039 | if (owner_grouplen < 0) { |
fe82a183 | 1040 | dprintk("nfs: couldn't resolve gid %d to string\n", |
e5782076 | 1041 | from_kgid(&init_user_ns, iap->ia_gid)); |
1da177e4 LT |
1042 | strcpy(owner_group, "nobody"); |
1043 | owner_grouplen = sizeof("nobody") - 1; | |
1044 | /* goto out; */ | |
1045 | } | |
d7067b2d | 1046 | bmval[1] |= FATTR4_WORD1_OWNER_GROUP; |
1da177e4 LT |
1047 | len += 4 + (XDR_QUADLEN(owner_grouplen) << 2); |
1048 | } | |
d7067b2d TM |
1049 | if (iap->ia_valid & ATTR_ATIME_SET) { |
1050 | bmval[1] |= FATTR4_WORD1_TIME_ACCESS_SET; | |
1da177e4 | 1051 | len += 16; |
d7067b2d TM |
1052 | } else if (iap->ia_valid & ATTR_ATIME) { |
1053 | bmval[1] |= FATTR4_WORD1_TIME_ACCESS_SET; | |
1da177e4 | 1054 | len += 4; |
d7067b2d TM |
1055 | } |
1056 | if (iap->ia_valid & ATTR_MTIME_SET) { | |
1057 | bmval[1] |= FATTR4_WORD1_TIME_MODIFY_SET; | |
1da177e4 | 1058 | len += 16; |
d7067b2d TM |
1059 | } else if (iap->ia_valid & ATTR_MTIME) { |
1060 | bmval[1] |= FATTR4_WORD1_TIME_MODIFY_SET; | |
1da177e4 | 1061 | len += 4; |
d7067b2d | 1062 | } |
b4a2cf76 TM |
1063 | if (label) { |
1064 | len += 4 + 4 + 4 + (XDR_QUADLEN(label->len) << 2); | |
d7067b2d | 1065 | bmval[2] |= FATTR4_WORD2_SECURITY_LABEL; |
b4a2cf76 TM |
1066 | } |
1067 | ||
d7067b2d TM |
1068 | if (bmval[2] != 0) |
1069 | bmval_len = 3; | |
1070 | else if (bmval[1] != 0) | |
1071 | bmval_len = 2; | |
1072 | else | |
1073 | bmval_len = 1; | |
1074 | ||
1075 | p = reserve_space(xdr, 4 + (bmval_len << 2) + 4 + len); | |
1da177e4 | 1076 | |
b4a2cf76 | 1077 | *p++ = cpu_to_be32(bmval_len); |
d7067b2d TM |
1078 | for (i = 0; i < bmval_len; i++) |
1079 | *p++ = cpu_to_be32(bmval[i]); | |
1080 | *p++ = cpu_to_be32(len); | |
1da177e4 | 1081 | |
d7067b2d | 1082 | if (bmval[0] & FATTR4_WORD0_SIZE) |
b95be5a9 | 1083 | p = xdr_encode_hyper(p, iap->ia_size); |
d7067b2d | 1084 | if (bmval[1] & FATTR4_WORD1_MODE) |
e75bc1c8 | 1085 | *p++ = cpu_to_be32(iap->ia_mode & S_IALLUGO); |
d7067b2d | 1086 | if (bmval[1] & FATTR4_WORD1_OWNER) |
811652bd | 1087 | p = xdr_encode_opaque(p, owner_name, owner_namelen); |
d7067b2d | 1088 | if (bmval[1] & FATTR4_WORD1_OWNER_GROUP) |
811652bd | 1089 | p = xdr_encode_opaque(p, owner_group, owner_grouplen); |
d7067b2d TM |
1090 | if (bmval[1] & FATTR4_WORD1_TIME_ACCESS_SET) { |
1091 | if (iap->ia_valid & ATTR_ATIME_SET) { | |
1092 | *p++ = cpu_to_be32(NFS4_SET_TO_CLIENT_TIME); | |
1093 | p = xdr_encode_hyper(p, (s64)iap->ia_atime.tv_sec); | |
1094 | *p++ = cpu_to_be32(iap->ia_atime.tv_nsec); | |
1095 | } else | |
1096 | *p++ = cpu_to_be32(NFS4_SET_TO_SERVER_TIME); | |
1da177e4 | 1097 | } |
d7067b2d TM |
1098 | if (bmval[1] & FATTR4_WORD1_TIME_MODIFY_SET) { |
1099 | if (iap->ia_valid & ATTR_MTIME_SET) { | |
1100 | *p++ = cpu_to_be32(NFS4_SET_TO_CLIENT_TIME); | |
1101 | p = xdr_encode_hyper(p, (s64)iap->ia_mtime.tv_sec); | |
1102 | *p++ = cpu_to_be32(iap->ia_mtime.tv_nsec); | |
1103 | } else | |
1104 | *p++ = cpu_to_be32(NFS4_SET_TO_SERVER_TIME); | |
1da177e4 | 1105 | } |
d7067b2d | 1106 | if (bmval[2] & FATTR4_WORD2_SECURITY_LABEL) { |
aa9c2669 DQ |
1107 | *p++ = cpu_to_be32(label->lfs); |
1108 | *p++ = cpu_to_be32(label->pi); | |
1109 | *p++ = cpu_to_be32(label->len); | |
1110 | p = xdr_encode_opaque_fixed(p, label->label, label->len); | |
1111 | } | |
6c0195a4 | 1112 | |
1da177e4 | 1113 | /* out: */ |
1da177e4 LT |
1114 | } |
1115 | ||
cf8cdbe5 | 1116 | static void encode_access(struct xdr_stream *xdr, u32 access, struct compound_hdr *hdr) |
1da177e4 | 1117 | { |
475d4ba0 TM |
1118 | encode_op_hdr(xdr, OP_ACCESS, decode_access_maxsz, hdr); |
1119 | encode_uint32(xdr, access); | |
1da177e4 LT |
1120 | } |
1121 | ||
cf8cdbe5 | 1122 | static void encode_close(struct xdr_stream *xdr, const struct nfs_closeargs *arg, struct compound_hdr *hdr) |
1da177e4 | 1123 | { |
ab19b481 | 1124 | encode_op_hdr(xdr, OP_CLOSE, decode_close_maxsz, hdr); |
4ade9821 | 1125 | encode_nfs4_seqid(xdr, arg->seqid); |
ea9d23f5 | 1126 | encode_nfs4_stateid(xdr, arg->stateid); |
1da177e4 LT |
1127 | } |
1128 | ||
0b7c0153 | 1129 | static void encode_commit(struct xdr_stream *xdr, const struct nfs_commitargs *args, struct compound_hdr *hdr) |
1da177e4 | 1130 | { |
8687b63a | 1131 | __be32 *p; |
6c0195a4 | 1132 | |
475d4ba0 TM |
1133 | encode_op_hdr(xdr, OP_COMMIT, decode_commit_maxsz, hdr); |
1134 | p = reserve_space(xdr, 12); | |
b95be5a9 | 1135 | p = xdr_encode_hyper(p, args->offset); |
34558513 | 1136 | *p = cpu_to_be32(args->count); |
1da177e4 LT |
1137 | } |
1138 | ||
cf8cdbe5 | 1139 | static void encode_create(struct xdr_stream *xdr, const struct nfs4_create_arg *create, struct compound_hdr *hdr) |
1da177e4 | 1140 | { |
8687b63a | 1141 | __be32 *p; |
6c0195a4 | 1142 | |
475d4ba0 TM |
1143 | encode_op_hdr(xdr, OP_CREATE, decode_create_maxsz, hdr); |
1144 | encode_uint32(xdr, create->ftype); | |
1da177e4 LT |
1145 | |
1146 | switch (create->ftype) { | |
1147 | case NF4LNK: | |
13c65ce9 | 1148 | p = reserve_space(xdr, 4); |
34558513 | 1149 | *p = cpu_to_be32(create->u.symlink.len); |
94a6d753 | 1150 | xdr_write_pages(xdr, create->u.symlink.pages, 0, create->u.symlink.len); |
1da177e4 LT |
1151 | break; |
1152 | ||
1153 | case NF4BLK: case NF4CHR: | |
13c65ce9 | 1154 | p = reserve_space(xdr, 8); |
e75bc1c8 | 1155 | *p++ = cpu_to_be32(create->u.device.specdata1); |
34558513 | 1156 | *p = cpu_to_be32(create->u.device.specdata2); |
1da177e4 LT |
1157 | break; |
1158 | ||
1159 | default: | |
1160 | break; | |
1161 | } | |
1162 | ||
811652bd | 1163 | encode_string(xdr, create->name->len, create->name->name); |
aa9c2669 | 1164 | encode_attrs(xdr, create->attrs, create->label, create->server); |
1da177e4 LT |
1165 | } |
1166 | ||
cf8cdbe5 | 1167 | static void encode_getattr_one(struct xdr_stream *xdr, uint32_t bitmap, struct compound_hdr *hdr) |
1da177e4 | 1168 | { |
05d564fe | 1169 | __be32 *p; |
1da177e4 | 1170 | |
475d4ba0 TM |
1171 | encode_op_hdr(xdr, OP_GETATTR, decode_getattr_maxsz, hdr); |
1172 | p = reserve_space(xdr, 8); | |
e75bc1c8 | 1173 | *p++ = cpu_to_be32(1); |
34558513 | 1174 | *p = cpu_to_be32(bitmap); |
1da177e4 LT |
1175 | } |
1176 | ||
cf8cdbe5 | 1177 | static void encode_getattr_two(struct xdr_stream *xdr, uint32_t bm0, uint32_t bm1, struct compound_hdr *hdr) |
1da177e4 | 1178 | { |
05d564fe | 1179 | __be32 *p; |
1da177e4 | 1180 | |
475d4ba0 TM |
1181 | encode_op_hdr(xdr, OP_GETATTR, decode_getattr_maxsz, hdr); |
1182 | p = reserve_space(xdr, 12); | |
e75bc1c8 BH |
1183 | *p++ = cpu_to_be32(2); |
1184 | *p++ = cpu_to_be32(bm0); | |
34558513 | 1185 | *p = cpu_to_be32(bm1); |
1da177e4 LT |
1186 | } |
1187 | ||
dae100c2 FI |
1188 | static void |
1189 | encode_getattr_three(struct xdr_stream *xdr, | |
1190 | uint32_t bm0, uint32_t bm1, uint32_t bm2, | |
1191 | struct compound_hdr *hdr) | |
1192 | { | |
1193 | __be32 *p; | |
1194 | ||
ab19b481 | 1195 | encode_op_hdr(xdr, OP_GETATTR, decode_getattr_maxsz, hdr); |
dae100c2 FI |
1196 | if (bm2) { |
1197 | p = reserve_space(xdr, 16); | |
1198 | *p++ = cpu_to_be32(3); | |
1199 | *p++ = cpu_to_be32(bm0); | |
1200 | *p++ = cpu_to_be32(bm1); | |
1201 | *p = cpu_to_be32(bm2); | |
1202 | } else if (bm1) { | |
1203 | p = reserve_space(xdr, 12); | |
1204 | *p++ = cpu_to_be32(2); | |
1205 | *p++ = cpu_to_be32(bm0); | |
1206 | *p = cpu_to_be32(bm1); | |
1207 | } else { | |
1208 | p = reserve_space(xdr, 8); | |
1209 | *p++ = cpu_to_be32(1); | |
1210 | *p = cpu_to_be32(bm0); | |
1211 | } | |
dae100c2 FI |
1212 | } |
1213 | ||
cf8cdbe5 | 1214 | static void encode_getfattr(struct xdr_stream *xdr, const u32* bitmask, struct compound_hdr *hdr) |
1da177e4 | 1215 | { |
a09df2ca DQ |
1216 | encode_getattr_three(xdr, bitmask[0] & nfs4_fattr_bitmap[0], |
1217 | bitmask[1] & nfs4_fattr_bitmap[1], | |
1218 | bitmask[2] & nfs4_fattr_bitmap[2], | |
1219 | hdr); | |
1da177e4 LT |
1220 | } |
1221 | ||
88034c3d | 1222 | static void encode_getfattr_open(struct xdr_stream *xdr, const u32 *bitmask, |
1549210f | 1223 | const u32 *open_bitmap, |
88034c3d AA |
1224 | struct compound_hdr *hdr) |
1225 | { | |
1226 | encode_getattr_three(xdr, | |
1549210f TM |
1227 | bitmask[0] & open_bitmap[0], |
1228 | bitmask[1] & open_bitmap[1], | |
1229 | bitmask[2] & open_bitmap[2], | |
88034c3d AA |
1230 | hdr); |
1231 | } | |
1232 | ||
cf8cdbe5 | 1233 | static void encode_fsinfo(struct xdr_stream *xdr, const u32* bitmask, struct compound_hdr *hdr) |
1da177e4 | 1234 | { |
dae100c2 FI |
1235 | encode_getattr_three(xdr, |
1236 | bitmask[0] & nfs4_fsinfo_bitmap[0], | |
1237 | bitmask[1] & nfs4_fsinfo_bitmap[1], | |
1238 | bitmask[2] & nfs4_fsinfo_bitmap[2], | |
1239 | hdr); | |
1da177e4 LT |
1240 | } |
1241 | ||
cf8cdbe5 | 1242 | static void encode_fs_locations(struct xdr_stream *xdr, const u32* bitmask, struct compound_hdr *hdr) |
830b8e33 | 1243 | { |
cf8cdbe5 AA |
1244 | encode_getattr_two(xdr, bitmask[0] & nfs4_fs_locations_bitmap[0], |
1245 | bitmask[1] & nfs4_fs_locations_bitmap[1], hdr); | |
830b8e33 MN |
1246 | } |
1247 | ||
cf8cdbe5 | 1248 | static void encode_getfh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
1da177e4 | 1249 | { |
ab19b481 | 1250 | encode_op_hdr(xdr, OP_GETFH, decode_getfh_maxsz, hdr); |
1da177e4 LT |
1251 | } |
1252 | ||
cf8cdbe5 | 1253 | static void encode_link(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr) |
1da177e4 | 1254 | { |
ab19b481 | 1255 | encode_op_hdr(xdr, OP_LINK, decode_link_maxsz, hdr); |
6fdfb0bc | 1256 | encode_string(xdr, name->len, name->name); |
1da177e4 LT |
1257 | } |
1258 | ||
911d1aaf TM |
1259 | static inline int nfs4_lock_type(struct file_lock *fl, int block) |
1260 | { | |
f44106e2 | 1261 | if (fl->fl_type == F_RDLCK) |
911d1aaf TM |
1262 | return block ? NFS4_READW_LT : NFS4_READ_LT; |
1263 | return block ? NFS4_WRITEW_LT : NFS4_WRITE_LT; | |
1264 | } | |
1265 | ||
1266 | static inline uint64_t nfs4_lock_length(struct file_lock *fl) | |
1267 | { | |
1268 | if (fl->fl_end == OFFSET_MAX) | |
1269 | return ~(uint64_t)0; | |
1270 | return fl->fl_end - fl->fl_start + 1; | |
1271 | } | |
1272 | ||
daccbded TM |
1273 | static void encode_lockowner(struct xdr_stream *xdr, const struct nfs_lowner *lowner) |
1274 | { | |
1275 | __be32 *p; | |
1276 | ||
d035c36c | 1277 | p = reserve_space(xdr, 32); |
daccbded | 1278 | p = xdr_encode_hyper(p, lowner->clientid); |
d035c36c | 1279 | *p++ = cpu_to_be32(20); |
daccbded | 1280 | p = xdr_encode_opaque_fixed(p, "lock id:", 8); |
d035c36c | 1281 | *p++ = cpu_to_be32(lowner->s_dev); |
daccbded TM |
1282 | xdr_encode_hyper(p, lowner->id); |
1283 | } | |
1284 | ||
1da177e4 LT |
1285 | /* |
1286 | * opcode,type,reclaim,offset,length,new_lock_owner = 32 | |
1287 | * open_seqid,open_stateid,lock_seqid,lock_owner.clientid, lock_owner.id = 40 | |
1288 | */ | |
cf8cdbe5 | 1289 | static void encode_lock(struct xdr_stream *xdr, const struct nfs_lock_args *args, struct compound_hdr *hdr) |
1da177e4 | 1290 | { |
8687b63a | 1291 | __be32 *p; |
1da177e4 | 1292 | |
475d4ba0 TM |
1293 | encode_op_hdr(xdr, OP_LOCK, decode_lock_maxsz, hdr); |
1294 | p = reserve_space(xdr, 28); | |
e75bc1c8 BH |
1295 | *p++ = cpu_to_be32(nfs4_lock_type(args->fl, args->block)); |
1296 | *p++ = cpu_to_be32(args->reclaim); | |
b95be5a9 BH |
1297 | p = xdr_encode_hyper(p, args->fl->fl_start); |
1298 | p = xdr_encode_hyper(p, nfs4_lock_length(args->fl)); | |
34558513 | 1299 | *p = cpu_to_be32(args->new_lock_owner); |
911d1aaf | 1300 | if (args->new_lock_owner){ |
4ade9821 | 1301 | encode_nfs4_seqid(xdr, args->open_seqid); |
ea9d23f5 | 1302 | encode_nfs4_stateid(xdr, args->open_stateid); |
4ade9821 | 1303 | encode_nfs4_seqid(xdr, args->lock_seqid); |
daccbded | 1304 | encode_lockowner(xdr, &args->lock_owner); |
1da177e4 LT |
1305 | } |
1306 | else { | |
ea9d23f5 | 1307 | encode_nfs4_stateid(xdr, args->lock_stateid); |
4ade9821 | 1308 | encode_nfs4_seqid(xdr, args->lock_seqid); |
1da177e4 | 1309 | } |
1da177e4 LT |
1310 | } |
1311 | ||
cf8cdbe5 | 1312 | static void encode_lockt(struct xdr_stream *xdr, const struct nfs_lockt_args *args, struct compound_hdr *hdr) |
1da177e4 | 1313 | { |
8687b63a | 1314 | __be32 *p; |
1da177e4 | 1315 | |
475d4ba0 TM |
1316 | encode_op_hdr(xdr, OP_LOCKT, decode_lockt_maxsz, hdr); |
1317 | p = reserve_space(xdr, 20); | |
e75bc1c8 | 1318 | *p++ = cpu_to_be32(nfs4_lock_type(args->fl, 0)); |
b95be5a9 BH |
1319 | p = xdr_encode_hyper(p, args->fl->fl_start); |
1320 | p = xdr_encode_hyper(p, nfs4_lock_length(args->fl)); | |
daccbded | 1321 | encode_lockowner(xdr, &args->lock_owner); |
1da177e4 LT |
1322 | } |
1323 | ||
cf8cdbe5 | 1324 | static void encode_locku(struct xdr_stream *xdr, const struct nfs_locku_args *args, struct compound_hdr *hdr) |
1da177e4 | 1325 | { |
8687b63a | 1326 | __be32 *p; |
1da177e4 | 1327 | |
475d4ba0 TM |
1328 | encode_op_hdr(xdr, OP_LOCKU, decode_locku_maxsz, hdr); |
1329 | encode_uint32(xdr, nfs4_lock_type(args->fl, 0)); | |
4ade9821 | 1330 | encode_nfs4_seqid(xdr, args->seqid); |
ea9d23f5 TM |
1331 | encode_nfs4_stateid(xdr, args->stateid); |
1332 | p = reserve_space(xdr, 16); | |
b95be5a9 | 1333 | p = xdr_encode_hyper(p, args->fl->fl_start); |
34558513 | 1334 | xdr_encode_hyper(p, nfs4_lock_length(args->fl)); |
1da177e4 LT |
1335 | } |
1336 | ||
d3c7b7cc TM |
1337 | static void encode_release_lockowner(struct xdr_stream *xdr, const struct nfs_lowner *lowner, struct compound_hdr *hdr) |
1338 | { | |
ab19b481 | 1339 | encode_op_hdr(xdr, OP_RELEASE_LOCKOWNER, decode_release_lockowner_maxsz, hdr); |
d3c7b7cc | 1340 | encode_lockowner(xdr, lowner); |
d3c7b7cc TM |
1341 | } |
1342 | ||
cf8cdbe5 | 1343 | static void encode_lookup(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr) |
1da177e4 | 1344 | { |
ab19b481 | 1345 | encode_op_hdr(xdr, OP_LOOKUP, decode_lookup_maxsz, hdr); |
6fdfb0bc | 1346 | encode_string(xdr, name->len, name->name); |
1da177e4 LT |
1347 | } |
1348 | ||
dc0b027d | 1349 | static void encode_share_access(struct xdr_stream *xdr, fmode_t fmode) |
1da177e4 | 1350 | { |
8687b63a | 1351 | __be32 *p; |
1da177e4 | 1352 | |
13c65ce9 | 1353 | p = reserve_space(xdr, 8); |
dc0b027d | 1354 | switch (fmode & (FMODE_READ|FMODE_WRITE)) { |
05d564fe | 1355 | case FMODE_READ: |
e75bc1c8 | 1356 | *p++ = cpu_to_be32(NFS4_SHARE_ACCESS_READ); |
05d564fe AA |
1357 | break; |
1358 | case FMODE_WRITE: | |
e75bc1c8 | 1359 | *p++ = cpu_to_be32(NFS4_SHARE_ACCESS_WRITE); |
05d564fe AA |
1360 | break; |
1361 | case FMODE_READ|FMODE_WRITE: | |
e75bc1c8 | 1362 | *p++ = cpu_to_be32(NFS4_SHARE_ACCESS_BOTH); |
05d564fe AA |
1363 | break; |
1364 | default: | |
e75bc1c8 | 1365 | *p++ = cpu_to_be32(0); |
1da177e4 | 1366 | } |
34558513 | 1367 | *p = cpu_to_be32(0); /* for linux, share_deny = 0 always */ |
1da177e4 LT |
1368 | } |
1369 | ||
1370 | static inline void encode_openhdr(struct xdr_stream *xdr, const struct nfs_openargs *arg) | |
1371 | { | |
8687b63a | 1372 | __be32 *p; |
1da177e4 LT |
1373 | /* |
1374 | * opcode 4, seqid 4, share_access 4, share_deny 4, clientid 8, ownerlen 4, | |
1375 | * owner 4 = 32 | |
1376 | */ | |
4ade9821 | 1377 | encode_nfs4_seqid(xdr, arg->seqid); |
dc0b027d | 1378 | encode_share_access(xdr, arg->fmode); |
95b72eb0 | 1379 | p = reserve_space(xdr, 36); |
b95be5a9 | 1380 | p = xdr_encode_hyper(p, arg->clientid); |
95b72eb0 | 1381 | *p++ = cpu_to_be32(24); |
93f0cf25 | 1382 | p = xdr_encode_opaque_fixed(p, "open id:", 8); |
d035c36c | 1383 | *p++ = cpu_to_be32(arg->server->s_dev); |
95b72eb0 TM |
1384 | *p++ = cpu_to_be32(arg->id.uniquifier); |
1385 | xdr_encode_hyper(p, arg->id.create_time); | |
1da177e4 LT |
1386 | } |
1387 | ||
1388 | static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_openargs *arg) | |
1389 | { | |
549b19cc | 1390 | struct iattr dummy; |
8687b63a | 1391 | __be32 *p; |
1da177e4 | 1392 | |
13c65ce9 | 1393 | p = reserve_space(xdr, 4); |
549b19cc TM |
1394 | switch(arg->createmode) { |
1395 | case NFS4_CREATE_UNCHECKED: | |
34558513 | 1396 | *p = cpu_to_be32(NFS4_CREATE_UNCHECKED); |
aa9c2669 | 1397 | encode_attrs(xdr, arg->u.attrs, arg->label, arg->server); |
05d564fe | 1398 | break; |
549b19cc TM |
1399 | case NFS4_CREATE_GUARDED: |
1400 | *p = cpu_to_be32(NFS4_CREATE_GUARDED); | |
aa9c2669 | 1401 | encode_attrs(xdr, arg->u.attrs, arg->label, arg->server); |
549b19cc TM |
1402 | break; |
1403 | case NFS4_CREATE_EXCLUSIVE: | |
1404 | *p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE); | |
1405 | encode_nfs4_verifier(xdr, &arg->u.verifier); | |
1406 | break; | |
1407 | case NFS4_CREATE_EXCLUSIVE4_1: | |
1408 | *p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE4_1); | |
1409 | encode_nfs4_verifier(xdr, &arg->u.verifier); | |
1410 | dummy.ia_valid = 0; | |
aa9c2669 | 1411 | encode_attrs(xdr, &dummy, arg->label, arg->server); |
1da177e4 LT |
1412 | } |
1413 | } | |
1414 | ||
1415 | static void encode_opentype(struct xdr_stream *xdr, const struct nfs_openargs *arg) | |
1416 | { | |
8687b63a | 1417 | __be32 *p; |
1da177e4 | 1418 | |
13c65ce9 | 1419 | p = reserve_space(xdr, 4); |
1da177e4 | 1420 | switch (arg->open_flags & O_CREAT) { |
05d564fe | 1421 | case 0: |
34558513 | 1422 | *p = cpu_to_be32(NFS4_OPEN_NOCREATE); |
05d564fe AA |
1423 | break; |
1424 | default: | |
34558513 | 1425 | *p = cpu_to_be32(NFS4_OPEN_CREATE); |
05d564fe | 1426 | encode_createmode(xdr, arg); |
1da177e4 LT |
1427 | } |
1428 | } | |
1429 | ||
bd7bf9d5 | 1430 | static inline void encode_delegation_type(struct xdr_stream *xdr, fmode_t delegation_type) |
1da177e4 | 1431 | { |
8687b63a | 1432 | __be32 *p; |
1da177e4 | 1433 | |
13c65ce9 | 1434 | p = reserve_space(xdr, 4); |
1da177e4 | 1435 | switch (delegation_type) { |
05d564fe | 1436 | case 0: |
34558513 | 1437 | *p = cpu_to_be32(NFS4_OPEN_DELEGATE_NONE); |
05d564fe AA |
1438 | break; |
1439 | case FMODE_READ: | |
34558513 | 1440 | *p = cpu_to_be32(NFS4_OPEN_DELEGATE_READ); |
05d564fe AA |
1441 | break; |
1442 | case FMODE_WRITE|FMODE_READ: | |
34558513 | 1443 | *p = cpu_to_be32(NFS4_OPEN_DELEGATE_WRITE); |
05d564fe AA |
1444 | break; |
1445 | default: | |
1446 | BUG(); | |
1da177e4 LT |
1447 | } |
1448 | } | |
1449 | ||
1450 | static inline void encode_claim_null(struct xdr_stream *xdr, const struct qstr *name) | |
1451 | { | |
8687b63a | 1452 | __be32 *p; |
1da177e4 | 1453 | |
13c65ce9 | 1454 | p = reserve_space(xdr, 4); |
34558513 | 1455 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_NULL); |
1da177e4 LT |
1456 | encode_string(xdr, name->len, name->name); |
1457 | } | |
1458 | ||
bd7bf9d5 | 1459 | static inline void encode_claim_previous(struct xdr_stream *xdr, fmode_t type) |
1da177e4 | 1460 | { |
8687b63a | 1461 | __be32 *p; |
1da177e4 | 1462 | |
13c65ce9 | 1463 | p = reserve_space(xdr, 4); |
34558513 | 1464 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_PREVIOUS); |
1da177e4 LT |
1465 | encode_delegation_type(xdr, type); |
1466 | } | |
1467 | ||
1468 | static inline void encode_claim_delegate_cur(struct xdr_stream *xdr, const struct qstr *name, const nfs4_stateid *stateid) | |
1469 | { | |
8687b63a | 1470 | __be32 *p; |
1da177e4 | 1471 | |
ea9d23f5 TM |
1472 | p = reserve_space(xdr, 4); |
1473 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_DELEGATE_CUR); | |
1474 | encode_nfs4_stateid(xdr, stateid); | |
1da177e4 LT |
1475 | encode_string(xdr, name->len, name->name); |
1476 | } | |
1477 | ||
d9fc6619 TM |
1478 | static inline void encode_claim_fh(struct xdr_stream *xdr) |
1479 | { | |
1480 | __be32 *p; | |
1481 | ||
1482 | p = reserve_space(xdr, 4); | |
1483 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_FH); | |
1484 | } | |
1485 | ||
1486 | static inline void encode_claim_delegate_cur_fh(struct xdr_stream *xdr, const nfs4_stateid *stateid) | |
1487 | { | |
1488 | __be32 *p; | |
1489 | ||
1490 | p = reserve_space(xdr, 4); | |
1491 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_DELEG_CUR_FH); | |
1492 | encode_nfs4_stateid(xdr, stateid); | |
1493 | } | |
1494 | ||
cf8cdbe5 | 1495 | static void encode_open(struct xdr_stream *xdr, const struct nfs_openargs *arg, struct compound_hdr *hdr) |
1da177e4 | 1496 | { |
ab19b481 | 1497 | encode_op_hdr(xdr, OP_OPEN, decode_open_maxsz, hdr); |
1da177e4 LT |
1498 | encode_openhdr(xdr, arg); |
1499 | encode_opentype(xdr, arg); | |
1500 | switch (arg->claim) { | |
05d564fe AA |
1501 | case NFS4_OPEN_CLAIM_NULL: |
1502 | encode_claim_null(xdr, arg->name); | |
1503 | break; | |
1504 | case NFS4_OPEN_CLAIM_PREVIOUS: | |
1505 | encode_claim_previous(xdr, arg->u.delegation_type); | |
1506 | break; | |
1507 | case NFS4_OPEN_CLAIM_DELEGATE_CUR: | |
1508 | encode_claim_delegate_cur(xdr, arg->name, &arg->u.delegation); | |
1509 | break; | |
d9fc6619 TM |
1510 | case NFS4_OPEN_CLAIM_FH: |
1511 | encode_claim_fh(xdr); | |
1512 | break; | |
1513 | case NFS4_OPEN_CLAIM_DELEG_CUR_FH: | |
1514 | encode_claim_delegate_cur_fh(xdr, &arg->u.delegation); | |
1515 | break; | |
05d564fe AA |
1516 | default: |
1517 | BUG(); | |
1da177e4 | 1518 | } |
1da177e4 LT |
1519 | } |
1520 | ||
cf8cdbe5 | 1521 | static void encode_open_confirm(struct xdr_stream *xdr, const struct nfs_open_confirmargs *arg, struct compound_hdr *hdr) |
1da177e4 | 1522 | { |
ab19b481 | 1523 | encode_op_hdr(xdr, OP_OPEN_CONFIRM, decode_open_confirm_maxsz, hdr); |
ea9d23f5 | 1524 | encode_nfs4_stateid(xdr, arg->stateid); |
4ade9821 | 1525 | encode_nfs4_seqid(xdr, arg->seqid); |
1da177e4 LT |
1526 | } |
1527 | ||
cf8cdbe5 | 1528 | static void encode_open_downgrade(struct xdr_stream *xdr, const struct nfs_closeargs *arg, struct compound_hdr *hdr) |
1da177e4 | 1529 | { |
ab19b481 | 1530 | encode_op_hdr(xdr, OP_OPEN_DOWNGRADE, decode_open_downgrade_maxsz, hdr); |
ea9d23f5 | 1531 | encode_nfs4_stateid(xdr, arg->stateid); |
4ade9821 | 1532 | encode_nfs4_seqid(xdr, arg->seqid); |
dc0b027d | 1533 | encode_share_access(xdr, arg->fmode); |
1da177e4 LT |
1534 | } |
1535 | ||
cf8cdbe5 | 1536 | static void |
d017931c | 1537 | encode_putfh(struct xdr_stream *xdr, const struct nfs_fh *fh, struct compound_hdr *hdr) |
1da177e4 | 1538 | { |
ab19b481 | 1539 | encode_op_hdr(xdr, OP_PUTFH, decode_putfh_maxsz, hdr); |
6fdfb0bc | 1540 | encode_string(xdr, fh->size, fh->data); |
1da177e4 LT |
1541 | } |
1542 | ||
cf8cdbe5 | 1543 | static void encode_putrootfh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
1da177e4 | 1544 | { |
ab19b481 | 1545 | encode_op_hdr(xdr, OP_PUTROOTFH, decode_putrootfh_maxsz, hdr); |
1da177e4 LT |
1546 | } |
1547 | ||
3c6b899c AS |
1548 | static void encode_read(struct xdr_stream *xdr, const struct nfs_pgio_args *args, |
1549 | struct compound_hdr *hdr) | |
1da177e4 | 1550 | { |
8687b63a | 1551 | __be32 *p; |
1da177e4 | 1552 | |
ab19b481 | 1553 | encode_op_hdr(xdr, OP_READ, decode_read_maxsz, hdr); |
9b206149 | 1554 | encode_nfs4_stateid(xdr, &args->stateid); |
1da177e4 | 1555 | |
13c65ce9 | 1556 | p = reserve_space(xdr, 12); |
b95be5a9 | 1557 | p = xdr_encode_hyper(p, args->offset); |
34558513 | 1558 | *p = cpu_to_be32(args->count); |
1da177e4 LT |
1559 | } |
1560 | ||
cf8cdbe5 | 1561 | static void encode_readdir(struct xdr_stream *xdr, const struct nfs4_readdir_arg *readdir, struct rpc_rqst *req, struct compound_hdr *hdr) |
1da177e4 | 1562 | { |
aa9c2669 | 1563 | uint32_t attrs[3] = { |
28331a46 TM |
1564 | FATTR4_WORD0_RDATTR_ERROR, |
1565 | FATTR4_WORD1_MOUNTED_ON_FILEID, | |
1566 | }; | |
6f7a35bd | 1567 | uint32_t dircount = readdir->count >> 1; |
cd93710e | 1568 | __be32 *p, verf[2]; |
d204c5d2 TM |
1569 | uint32_t attrlen = 0; |
1570 | unsigned int i; | |
1da177e4 | 1571 | |
82f2e547 BS |
1572 | if (readdir->plus) { |
1573 | attrs[0] |= FATTR4_WORD0_TYPE|FATTR4_WORD0_CHANGE|FATTR4_WORD0_SIZE| | |
28331a46 | 1574 | FATTR4_WORD0_FSID|FATTR4_WORD0_FILEHANDLE|FATTR4_WORD0_FILEID; |
82f2e547 BS |
1575 | attrs[1] |= FATTR4_WORD1_MODE|FATTR4_WORD1_NUMLINKS|FATTR4_WORD1_OWNER| |
1576 | FATTR4_WORD1_OWNER_GROUP|FATTR4_WORD1_RAWDEV| | |
1577 | FATTR4_WORD1_SPACE_USED|FATTR4_WORD1_TIME_ACCESS| | |
1578 | FATTR4_WORD1_TIME_METADATA|FATTR4_WORD1_TIME_MODIFY; | |
d204c5d2 | 1579 | attrs[2] |= FATTR4_WORD2_SECURITY_LABEL; |
6f7a35bd | 1580 | dircount >>= 1; |
82f2e547 | 1581 | } |
28331a46 TM |
1582 | /* Use mounted_on_fileid only if the server supports it */ |
1583 | if (!(readdir->bitmask[1] & FATTR4_WORD1_MOUNTED_ON_FILEID)) | |
1584 | attrs[0] |= FATTR4_WORD0_FILEID; | |
d204c5d2 TM |
1585 | for (i = 0; i < ARRAY_SIZE(attrs); i++) { |
1586 | attrs[i] &= readdir->bitmask[i]; | |
1587 | if (attrs[i] != 0) | |
1588 | attrlen = i+1; | |
1589 | } | |
82f2e547 | 1590 | |
475d4ba0 | 1591 | encode_op_hdr(xdr, OP_READDIR, decode_readdir_maxsz, hdr); |
ff2eb681 | 1592 | encode_uint64(xdr, readdir->cookie); |
cd93710e | 1593 | encode_nfs4_verifier(xdr, &readdir->verifier); |
d204c5d2 | 1594 | p = reserve_space(xdr, 12 + (attrlen << 2)); |
6f7a35bd | 1595 | *p++ = cpu_to_be32(dircount); |
e75bc1c8 | 1596 | *p++ = cpu_to_be32(readdir->count); |
d204c5d2 TM |
1597 | *p++ = cpu_to_be32(attrlen); |
1598 | for (i = 0; i < attrlen; i++) | |
1599 | *p++ = cpu_to_be32(attrs[i]); | |
cd93710e | 1600 | memcpy(verf, readdir->verifier.data, sizeof(verf)); |
aa9c2669 DQ |
1601 | |
1602 | dprintk("%s: cookie = %llu, verifier = %08x:%08x, bitmap = %08x:%08x:%08x\n", | |
44109241 | 1603 | __func__, |
eadf4598 | 1604 | (unsigned long long)readdir->cookie, |
cd93710e | 1605 | verf[0], verf[1], |
eadf4598 | 1606 | attrs[0] & readdir->bitmask[0], |
aa9c2669 DQ |
1607 | attrs[1] & readdir->bitmask[1], |
1608 | attrs[2] & readdir->bitmask[2]); | |
1da177e4 LT |
1609 | } |
1610 | ||
cf8cdbe5 | 1611 | static void encode_readlink(struct xdr_stream *xdr, const struct nfs4_readlink *readlink, struct rpc_rqst *req, struct compound_hdr *hdr) |
1da177e4 | 1612 | { |
ab19b481 | 1613 | encode_op_hdr(xdr, OP_READLINK, decode_readlink_maxsz, hdr); |
1da177e4 LT |
1614 | } |
1615 | ||
cf8cdbe5 | 1616 | static void encode_remove(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr) |
1da177e4 | 1617 | { |
ab19b481 | 1618 | encode_op_hdr(xdr, OP_REMOVE, decode_remove_maxsz, hdr); |
6fdfb0bc | 1619 | encode_string(xdr, name->len, name->name); |
1da177e4 LT |
1620 | } |
1621 | ||
cf8cdbe5 | 1622 | static void encode_rename(struct xdr_stream *xdr, const struct qstr *oldname, const struct qstr *newname, struct compound_hdr *hdr) |
1da177e4 | 1623 | { |
ab19b481 | 1624 | encode_op_hdr(xdr, OP_RENAME, decode_rename_maxsz, hdr); |
811652bd BH |
1625 | encode_string(xdr, oldname->len, oldname->name); |
1626 | encode_string(xdr, newname->len, newname->name); | |
1da177e4 LT |
1627 | } |
1628 | ||
bb4dae5e CL |
1629 | static void encode_renew(struct xdr_stream *xdr, clientid4 clid, |
1630 | struct compound_hdr *hdr) | |
1da177e4 | 1631 | { |
475d4ba0 | 1632 | encode_op_hdr(xdr, OP_RENEW, decode_renew_maxsz, hdr); |
ff2eb681 | 1633 | encode_uint64(xdr, clid); |
1da177e4 LT |
1634 | } |
1635 | ||
cf8cdbe5 | 1636 | static void |
d017931c | 1637 | encode_restorefh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
56ae19f3 | 1638 | { |
ab19b481 | 1639 | encode_op_hdr(xdr, OP_RESTOREFH, decode_restorefh_maxsz, hdr); |
56ae19f3 TM |
1640 | } |
1641 | ||
9f06c719 | 1642 | static void |
d017931c | 1643 | encode_setacl(struct xdr_stream *xdr, struct nfs_setaclargs *arg, struct compound_hdr *hdr) |
23ec6965 | 1644 | { |
8687b63a | 1645 | __be32 *p; |
23ec6965 | 1646 | |
ab19b481 | 1647 | encode_op_hdr(xdr, OP_SETATTR, decode_setacl_maxsz, hdr); |
ea9d23f5 | 1648 | encode_nfs4_stateid(xdr, &zero_stateid); |
13c65ce9 | 1649 | p = reserve_space(xdr, 2*4); |
e75bc1c8 | 1650 | *p++ = cpu_to_be32(1); |
34558513 | 1651 | *p = cpu_to_be32(FATTR4_WORD0_ACL); |
13c65ce9 | 1652 | p = reserve_space(xdr, 4); |
34558513 | 1653 | *p = cpu_to_be32(arg->acl_len); |
23ec6965 | 1654 | xdr_write_pages(xdr, arg->acl_pages, arg->acl_pgbase, arg->acl_len); |
23ec6965 BF |
1655 | } |
1656 | ||
cf8cdbe5 | 1657 | static void |
d017931c | 1658 | encode_savefh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
1da177e4 | 1659 | { |
ab19b481 | 1660 | encode_op_hdr(xdr, OP_SAVEFH, decode_savefh_maxsz, hdr); |
1da177e4 LT |
1661 | } |
1662 | ||
cf8cdbe5 | 1663 | static void encode_setattr(struct xdr_stream *xdr, const struct nfs_setattrargs *arg, const struct nfs_server *server, struct compound_hdr *hdr) |
1da177e4 | 1664 | { |
ab19b481 | 1665 | encode_op_hdr(xdr, OP_SETATTR, decode_setattr_maxsz, hdr); |
ea9d23f5 | 1666 | encode_nfs4_stateid(xdr, &arg->stateid); |
aa9c2669 | 1667 | encode_attrs(xdr, arg->iap, arg->label, server); |
1da177e4 LT |
1668 | } |
1669 | ||
cf8cdbe5 | 1670 | static void encode_setclientid(struct xdr_stream *xdr, const struct nfs4_setclientid *setclientid, struct compound_hdr *hdr) |
1da177e4 | 1671 | { |
8687b63a | 1672 | __be32 *p; |
1da177e4 | 1673 | |
70019514 | 1674 | encode_op_hdr(xdr, OP_SETCLIENTID, decode_setclientid_maxsz, hdr); |
cd93710e | 1675 | encode_nfs4_verifier(xdr, setclientid->sc_verifier); |
1da177e4 LT |
1676 | |
1677 | encode_string(xdr, setclientid->sc_name_len, setclientid->sc_name); | |
13c65ce9 | 1678 | p = reserve_space(xdr, 4); |
34558513 | 1679 | *p = cpu_to_be32(setclientid->sc_prog); |
1da177e4 LT |
1680 | encode_string(xdr, setclientid->sc_netid_len, setclientid->sc_netid); |
1681 | encode_string(xdr, setclientid->sc_uaddr_len, setclientid->sc_uaddr); | |
13c65ce9 | 1682 | p = reserve_space(xdr, 4); |
34558513 | 1683 | *p = cpu_to_be32(setclientid->sc_cb_ident); |
1da177e4 LT |
1684 | } |
1685 | ||
bb8b27e5 | 1686 | static void encode_setclientid_confirm(struct xdr_stream *xdr, const struct nfs4_setclientid_res *arg, struct compound_hdr *hdr) |
1da177e4 | 1687 | { |
475d4ba0 TM |
1688 | encode_op_hdr(xdr, OP_SETCLIENTID_CONFIRM, |
1689 | decode_setclientid_confirm_maxsz, hdr); | |
ff2eb681 | 1690 | encode_uint64(xdr, arg->clientid); |
cd93710e | 1691 | encode_nfs4_verifier(xdr, &arg->confirm); |
1da177e4 LT |
1692 | } |
1693 | ||
3c6b899c AS |
1694 | static void encode_write(struct xdr_stream *xdr, const struct nfs_pgio_args *args, |
1695 | struct compound_hdr *hdr) | |
1da177e4 | 1696 | { |
8687b63a | 1697 | __be32 *p; |
1da177e4 | 1698 | |
ab19b481 | 1699 | encode_op_hdr(xdr, OP_WRITE, decode_write_maxsz, hdr); |
9b206149 | 1700 | encode_nfs4_stateid(xdr, &args->stateid); |
1da177e4 | 1701 | |
13c65ce9 | 1702 | p = reserve_space(xdr, 16); |
b95be5a9 | 1703 | p = xdr_encode_hyper(p, args->offset); |
e75bc1c8 | 1704 | *p++ = cpu_to_be32(args->stable); |
34558513 | 1705 | *p = cpu_to_be32(args->count); |
1da177e4 LT |
1706 | |
1707 | xdr_write_pages(xdr, args->pages, args->pgbase, args->count); | |
1da177e4 LT |
1708 | } |
1709 | ||
cf8cdbe5 | 1710 | static void encode_delegreturn(struct xdr_stream *xdr, const nfs4_stateid *stateid, struct compound_hdr *hdr) |
1da177e4 | 1711 | { |
ab19b481 | 1712 | encode_op_hdr(xdr, OP_DELEGRETURN, decode_delegreturn_maxsz, hdr); |
ea9d23f5 | 1713 | encode_nfs4_stateid(xdr, stateid); |
1da177e4 | 1714 | } |
9b7b9fcc | 1715 | |
5a5ea0d4 BS |
1716 | static void encode_secinfo(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr) |
1717 | { | |
ab19b481 | 1718 | encode_op_hdr(xdr, OP_SECINFO, decode_secinfo_maxsz, hdr); |
6fdfb0bc | 1719 | encode_string(xdr, name->len, name->name); |
5a5ea0d4 BS |
1720 | } |
1721 | ||
99fe60d0 | 1722 | #if defined(CONFIG_NFS_V4_1) |
9b7b9fcc | 1723 | /* NFSv4.1 operations */ |
7c44f1ae WAA |
1724 | static void encode_bind_conn_to_session(struct xdr_stream *xdr, |
1725 | struct nfs4_session *session, | |
1726 | struct compound_hdr *hdr) | |
1727 | { | |
1728 | __be32 *p; | |
1729 | ||
1730 | encode_op_hdr(xdr, OP_BIND_CONN_TO_SESSION, | |
1731 | decode_bind_conn_to_session_maxsz, hdr); | |
1732 | encode_opaque_fixed(xdr, session->sess_id.data, NFS4_MAX_SESSIONID_LEN); | |
1733 | p = xdr_reserve_space(xdr, 8); | |
1734 | *p++ = cpu_to_be32(NFS4_CDFC4_BACK_OR_BOTH); | |
1735 | *p = 0; /* use_conn_in_rdma_mode = False */ | |
1736 | } | |
1737 | ||
2031cd1a WAA |
1738 | static void encode_op_map(struct xdr_stream *xdr, struct nfs4_op_map *op_map) |
1739 | { | |
1740 | unsigned int i; | |
1741 | encode_uint32(xdr, NFS4_OP_MAP_NUM_WORDS); | |
1742 | for (i = 0; i < NFS4_OP_MAP_NUM_WORDS; i++) | |
1743 | encode_uint32(xdr, op_map->u.words[i]); | |
1744 | } | |
1745 | ||
99fe60d0 BH |
1746 | static void encode_exchange_id(struct xdr_stream *xdr, |
1747 | struct nfs41_exchange_id_args *args, | |
1748 | struct compound_hdr *hdr) | |
1749 | { | |
1750 | __be32 *p; | |
d751f748 | 1751 | char impl_name[IMPL_NAME_LIMIT]; |
db8ac8ba | 1752 | int len = 0; |
99fe60d0 | 1753 | |
70019514 | 1754 | encode_op_hdr(xdr, OP_EXCHANGE_ID, decode_exchange_id_maxsz, hdr); |
cd93710e | 1755 | encode_nfs4_verifier(xdr, args->verifier); |
99fe60d0 BH |
1756 | |
1757 | encode_string(xdr, args->id_len, args->id); | |
1758 | ||
2031cd1a WAA |
1759 | encode_uint32(xdr, args->flags); |
1760 | encode_uint32(xdr, args->state_protect.how); | |
1761 | ||
1762 | switch (args->state_protect.how) { | |
1763 | case SP4_NONE: | |
1764 | break; | |
1765 | case SP4_MACH_CRED: | |
1766 | encode_op_map(xdr, &args->state_protect.enforce); | |
1767 | encode_op_map(xdr, &args->state_protect.allow); | |
1768 | break; | |
1769 | default: | |
1770 | WARN_ON_ONCE(1); | |
1771 | break; | |
1772 | } | |
db8ac8ba WAA |
1773 | |
1774 | if (send_implementation_id && | |
1775 | sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) > 1 && | |
1776 | sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) | |
d751f748 | 1777 | <= sizeof(impl_name) + 1) |
db8ac8ba WAA |
1778 | len = snprintf(impl_name, sizeof(impl_name), "%s %s %s %s", |
1779 | utsname()->sysname, utsname()->release, | |
1780 | utsname()->version, utsname()->machine); | |
1781 | ||
1782 | if (len > 0) { | |
2031cd1a | 1783 | encode_uint32(xdr, 1); /* implementation id array length=1 */ |
db8ac8ba WAA |
1784 | |
1785 | encode_string(xdr, | |
1786 | sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) - 1, | |
1787 | CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN); | |
1788 | encode_string(xdr, len, impl_name); | |
1789 | /* just send zeros for nii_date - the date is in nii_name */ | |
1790 | p = reserve_space(xdr, 12); | |
1791 | p = xdr_encode_hyper(p, 0); | |
1792 | *p = cpu_to_be32(0); | |
1793 | } else | |
2031cd1a | 1794 | encode_uint32(xdr, 0); /* implementation id array length=0 */ |
99fe60d0 | 1795 | } |
fc931582 AA |
1796 | |
1797 | static void encode_create_session(struct xdr_stream *xdr, | |
1798 | struct nfs41_create_session_args *args, | |
1799 | struct compound_hdr *hdr) | |
1800 | { | |
1801 | __be32 *p; | |
1802 | char machine_name[NFS4_MAX_MACHINE_NAME_LEN]; | |
1803 | uint32_t len; | |
1804 | struct nfs_client *clp = args->client; | |
f092075d | 1805 | struct nfs_net *nn = net_generic(clp->cl_net, nfs_net_id); |
8e0d46e1 MS |
1806 | u32 max_resp_sz_cached; |
1807 | ||
1808 | /* | |
1809 | * Assumes OPEN is the biggest non-idempotent compound. | |
1810 | * 2 is the verifier. | |
1811 | */ | |
1812 | max_resp_sz_cached = (NFS4_dec_open_sz + RPC_REPHDRSIZE + | |
1813 | RPC_MAX_AUTH_SIZE + 2) * XDR_UNIT; | |
fc931582 | 1814 | |
42edd698 BH |
1815 | len = scnprintf(machine_name, sizeof(machine_name), "%s", |
1816 | clp->cl_ipaddr); | |
fc931582 | 1817 | |
475d4ba0 TM |
1818 | encode_op_hdr(xdr, OP_CREATE_SESSION, decode_create_session_maxsz, hdr); |
1819 | p = reserve_space(xdr, 16 + 2*28 + 20 + len + 12); | |
114f64b5 | 1820 | p = xdr_encode_hyper(p, clp->cl_clientid); |
e75bc1c8 BH |
1821 | *p++ = cpu_to_be32(clp->cl_seqid); /*Sequence id */ |
1822 | *p++ = cpu_to_be32(args->flags); /*flags */ | |
fc931582 | 1823 | |
fc931582 | 1824 | /* Fore Channel */ |
c9c30dd5 | 1825 | *p++ = cpu_to_be32(0); /* header padding size */ |
e75bc1c8 BH |
1826 | *p++ = cpu_to_be32(args->fc_attrs.max_rqst_sz); /* max req size */ |
1827 | *p++ = cpu_to_be32(args->fc_attrs.max_resp_sz); /* max resp size */ | |
8e0d46e1 | 1828 | *p++ = cpu_to_be32(max_resp_sz_cached); /* Max resp sz cached */ |
e75bc1c8 BH |
1829 | *p++ = cpu_to_be32(args->fc_attrs.max_ops); /* max operations */ |
1830 | *p++ = cpu_to_be32(args->fc_attrs.max_reqs); /* max requests */ | |
1831 | *p++ = cpu_to_be32(0); /* rdmachannel_attrs */ | |
fc931582 AA |
1832 | |
1833 | /* Back Channel */ | |
c9c30dd5 | 1834 | *p++ = cpu_to_be32(0); /* header padding size */ |
e75bc1c8 BH |
1835 | *p++ = cpu_to_be32(args->bc_attrs.max_rqst_sz); /* max req size */ |
1836 | *p++ = cpu_to_be32(args->bc_attrs.max_resp_sz); /* max resp size */ | |
1837 | *p++ = cpu_to_be32(args->bc_attrs.max_resp_sz_cached); /* Max resp sz cached */ | |
1838 | *p++ = cpu_to_be32(args->bc_attrs.max_ops); /* max operations */ | |
1839 | *p++ = cpu_to_be32(args->bc_attrs.max_reqs); /* max requests */ | |
1840 | *p++ = cpu_to_be32(0); /* rdmachannel_attrs */ | |
fc931582 | 1841 | |
e75bc1c8 | 1842 | *p++ = cpu_to_be32(args->cb_program); /* cb_program */ |
e75bc1c8 | 1843 | *p++ = cpu_to_be32(1); |
e75bc1c8 | 1844 | *p++ = cpu_to_be32(RPC_AUTH_UNIX); /* auth_sys */ |
fc931582 AA |
1845 | |
1846 | /* authsys_parms rfc1831 */ | |
17f26b12 | 1847 | *p++ = cpu_to_be32(nn->boot_time.tv_nsec); /* stamp */ |
811652bd | 1848 | p = xdr_encode_opaque(p, machine_name, len); |
e75bc1c8 BH |
1849 | *p++ = cpu_to_be32(0); /* UID */ |
1850 | *p++ = cpu_to_be32(0); /* GID */ | |
34558513 | 1851 | *p = cpu_to_be32(0); /* No more gids */ |
fc931582 | 1852 | } |
0f3e66c6 AA |
1853 | |
1854 | static void encode_destroy_session(struct xdr_stream *xdr, | |
1855 | struct nfs4_session *session, | |
1856 | struct compound_hdr *hdr) | |
1857 | { | |
475d4ba0 TM |
1858 | encode_op_hdr(xdr, OP_DESTROY_SESSION, decode_destroy_session_maxsz, hdr); |
1859 | encode_opaque_fixed(xdr, session->sess_id.data, NFS4_MAX_SESSIONID_LEN); | |
0f3e66c6 | 1860 | } |
18019753 | 1861 | |
66245539 TM |
1862 | static void encode_destroy_clientid(struct xdr_stream *xdr, |
1863 | uint64_t clientid, | |
1864 | struct compound_hdr *hdr) | |
1865 | { | |
1866 | encode_op_hdr(xdr, OP_DESTROY_CLIENTID, decode_destroy_clientid_maxsz, hdr); | |
1867 | encode_uint64(xdr, clientid); | |
1868 | } | |
1869 | ||
18019753 RL |
1870 | static void encode_reclaim_complete(struct xdr_stream *xdr, |
1871 | struct nfs41_reclaim_complete_args *args, | |
1872 | struct compound_hdr *hdr) | |
1873 | { | |
475d4ba0 TM |
1874 | encode_op_hdr(xdr, OP_RECLAIM_COMPLETE, decode_reclaim_complete_maxsz, hdr); |
1875 | encode_uint32(xdr, args->one_fs); | |
18019753 | 1876 | } |
99fe60d0 BH |
1877 | #endif /* CONFIG_NFS_V4_1 */ |
1878 | ||
9b7b9fcc AA |
1879 | static void encode_sequence(struct xdr_stream *xdr, |
1880 | const struct nfs4_sequence_args *args, | |
1881 | struct compound_hdr *hdr) | |
1882 | { | |
1883 | #if defined(CONFIG_NFS_V4_1) | |
2b2fa717 | 1884 | struct nfs4_session *session; |
fc01cea9 | 1885 | struct nfs4_slot_table *tp; |
2b2fa717 | 1886 | struct nfs4_slot *slot = args->sa_slot; |
fc01cea9 | 1887 | __be32 *p; |
9b7b9fcc | 1888 | |
2b2fa717 TM |
1889 | tp = slot->table; |
1890 | session = tp->session; | |
3bd2384a CL |
1891 | if (!session) |
1892 | return; | |
fc01cea9 | 1893 | |
475d4ba0 | 1894 | encode_op_hdr(xdr, OP_SEQUENCE, decode_sequence_maxsz, hdr); |
fc01cea9 AA |
1895 | |
1896 | /* | |
1897 | * Sessionid + seqid + slotid + max slotid + cache_this | |
1898 | */ | |
1899 | dprintk("%s: sessionid=%u:%u:%u:%u seqid=%d slotid=%d " | |
1900 | "max_slotid=%d cache_this=%d\n", | |
1901 | __func__, | |
1902 | ((u32 *)session->sess_id.data)[0], | |
1903 | ((u32 *)session->sess_id.data)[1], | |
1904 | ((u32 *)session->sess_id.data)[2], | |
1905 | ((u32 *)session->sess_id.data)[3], | |
2b2fa717 | 1906 | slot->seq_nr, slot->slot_nr, |
fc01cea9 | 1907 | tp->highest_used_slotid, args->sa_cache_this); |
475d4ba0 | 1908 | p = reserve_space(xdr, NFS4_MAX_SESSIONID_LEN + 16); |
93f0cf25 | 1909 | p = xdr_encode_opaque_fixed(p, session->sess_id.data, NFS4_MAX_SESSIONID_LEN); |
e75bc1c8 | 1910 | *p++ = cpu_to_be32(slot->seq_nr); |
2b2fa717 | 1911 | *p++ = cpu_to_be32(slot->slot_nr); |
e75bc1c8 | 1912 | *p++ = cpu_to_be32(tp->highest_used_slotid); |
34558513 | 1913 | *p = cpu_to_be32(args->sa_cache_this); |
9b7b9fcc AA |
1914 | #endif /* CONFIG_NFS_V4_1 */ |
1915 | } | |
1916 | ||
b1f69b75 AA |
1917 | #ifdef CONFIG_NFS_V4_1 |
1918 | static void | |
1919 | encode_getdeviceinfo(struct xdr_stream *xdr, | |
1920 | const struct nfs4_getdeviceinfo_args *args, | |
1921 | struct compound_hdr *hdr) | |
1922 | { | |
1923 | __be32 *p; | |
1924 | ||
475d4ba0 | 1925 | encode_op_hdr(xdr, OP_GETDEVICEINFO, decode_getdeviceinfo_maxsz, hdr); |
84c9dee3 | 1926 | p = reserve_space(xdr, NFS4_DEVICEID4_SIZE + 4 + 4); |
b1f69b75 AA |
1927 | p = xdr_encode_opaque_fixed(p, args->pdev->dev_id.data, |
1928 | NFS4_DEVICEID4_SIZE); | |
1929 | *p++ = cpu_to_be32(args->pdev->layout_type); | |
f1c097be | 1930 | *p++ = cpu_to_be32(args->pdev->maxcount); /* gdia_maxcount */ |
84c9dee3 CH |
1931 | |
1932 | p = reserve_space(xdr, 4 + 4); | |
1933 | *p++ = cpu_to_be32(1); /* bitmap length */ | |
1934 | *p++ = cpu_to_be32(NOTIFY_DEVICEID4_CHANGE | NOTIFY_DEVICEID4_DELETE); | |
b1f69b75 AA |
1935 | } |
1936 | ||
1937 | static void | |
1938 | encode_layoutget(struct xdr_stream *xdr, | |
1939 | const struct nfs4_layoutget_args *args, | |
1940 | struct compound_hdr *hdr) | |
1941 | { | |
b1f69b75 AA |
1942 | __be32 *p; |
1943 | ||
475d4ba0 TM |
1944 | encode_op_hdr(xdr, OP_LAYOUTGET, decode_layoutget_maxsz, hdr); |
1945 | p = reserve_space(xdr, 36); | |
b1f69b75 AA |
1946 | *p++ = cpu_to_be32(0); /* Signal layout available */ |
1947 | *p++ = cpu_to_be32(args->type); | |
1948 | *p++ = cpu_to_be32(args->range.iomode); | |
1949 | p = xdr_encode_hyper(p, args->range.offset); | |
1950 | p = xdr_encode_hyper(p, args->range.length); | |
1951 | p = xdr_encode_hyper(p, args->minlength); | |
ea9d23f5 | 1952 | encode_nfs4_stateid(xdr, &args->stateid); |
475d4ba0 | 1953 | encode_uint32(xdr, args->maxcount); |
b1f69b75 AA |
1954 | |
1955 | dprintk("%s: 1st type:0x%x iomode:%d off:%lu len:%lu mc:%d\n", | |
1956 | __func__, | |
1957 | args->type, | |
1958 | args->range.iomode, | |
1959 | (unsigned long)args->range.offset, | |
1960 | (unsigned long)args->range.length, | |
1961 | args->maxcount); | |
b1f69b75 | 1962 | } |
863a3c6c AA |
1963 | |
1964 | static int | |
1965 | encode_layoutcommit(struct xdr_stream *xdr, | |
ac7db726 | 1966 | struct inode *inode, |
5f919c9f | 1967 | struct nfs4_layoutcommit_args *args, |
863a3c6c AA |
1968 | struct compound_hdr *hdr) |
1969 | { | |
1970 | __be32 *p; | |
1971 | ||
1972 | dprintk("%s: lbw: %llu type: %d\n", __func__, args->lastbytewritten, | |
1973 | NFS_SERVER(args->inode)->pnfs_curr_ld->id); | |
1974 | ||
475d4ba0 TM |
1975 | encode_op_hdr(xdr, OP_LAYOUTCOMMIT, decode_layoutcommit_maxsz, hdr); |
1976 | p = reserve_space(xdr, 20); | |
863a3c6c AA |
1977 | /* Only whole file layouts */ |
1978 | p = xdr_encode_hyper(p, 0); /* offset */ | |
3557c6c3 | 1979 | p = xdr_encode_hyper(p, args->lastbytewritten + 1); /* length */ |
ea9d23f5 TM |
1980 | *p = cpu_to_be32(0); /* reclaim */ |
1981 | encode_nfs4_stateid(xdr, &args->stateid); | |
1982 | p = reserve_space(xdr, 20); | |
863a3c6c AA |
1983 | *p++ = cpu_to_be32(1); /* newoffset = TRUE */ |
1984 | p = xdr_encode_hyper(p, args->lastbytewritten); | |
1985 | *p++ = cpu_to_be32(0); /* Never send time_modify_changed */ | |
1986 | *p++ = cpu_to_be32(NFS_SERVER(args->inode)->pnfs_curr_ld->id);/* type */ | |
ac7db726 | 1987 | |
5f919c9f | 1988 | if (NFS_SERVER(inode)->pnfs_curr_ld->encode_layoutcommit) { |
ac7db726 BH |
1989 | NFS_SERVER(inode)->pnfs_curr_ld->encode_layoutcommit( |
1990 | NFS_I(inode)->layout, xdr, args); | |
5f919c9f CH |
1991 | } else { |
1992 | encode_uint32(xdr, args->layoutupdate_len); | |
1993 | if (args->layoutupdate_pages) { | |
1994 | xdr_write_pages(xdr, args->layoutupdate_pages, 0, | |
1995 | args->layoutupdate_len); | |
1996 | } | |
1997 | } | |
863a3c6c | 1998 | |
863a3c6c AA |
1999 | return 0; |
2000 | } | |
cbe82603 BH |
2001 | |
2002 | static void | |
2003 | encode_layoutreturn(struct xdr_stream *xdr, | |
2004 | const struct nfs4_layoutreturn_args *args, | |
2005 | struct compound_hdr *hdr) | |
2006 | { | |
2007 | __be32 *p; | |
2008 | ||
475d4ba0 TM |
2009 | encode_op_hdr(xdr, OP_LAYOUTRETURN, decode_layoutreturn_maxsz, hdr); |
2010 | p = reserve_space(xdr, 16); | |
cbe82603 BH |
2011 | *p++ = cpu_to_be32(0); /* reclaim. always 0 for now */ |
2012 | *p++ = cpu_to_be32(args->layout_type); | |
2013 | *p++ = cpu_to_be32(IOMODE_ANY); | |
2014 | *p = cpu_to_be32(RETURN_FILE); | |
ea9d23f5 | 2015 | p = reserve_space(xdr, 16); |
cbe82603 BH |
2016 | p = xdr_encode_hyper(p, 0); |
2017 | p = xdr_encode_hyper(p, NFS4_MAX_UINT64); | |
2018 | spin_lock(&args->inode->i_lock); | |
ea9d23f5 | 2019 | encode_nfs4_stateid(xdr, &args->stateid); |
cbe82603 | 2020 | spin_unlock(&args->inode->i_lock); |
04a55549 AA |
2021 | if (NFS_SERVER(args->inode)->pnfs_curr_ld->encode_layoutreturn) { |
2022 | NFS_SERVER(args->inode)->pnfs_curr_ld->encode_layoutreturn( | |
2023 | NFS_I(args->inode)->layout, xdr, args); | |
475d4ba0 TM |
2024 | } else |
2025 | encode_uint32(xdr, 0); | |
cbe82603 | 2026 | } |
fca78d6d BS |
2027 | |
2028 | static int | |
2029 | encode_secinfo_no_name(struct xdr_stream *xdr, | |
2030 | const struct nfs41_secinfo_no_name_args *args, | |
2031 | struct compound_hdr *hdr) | |
2032 | { | |
475d4ba0 TM |
2033 | encode_op_hdr(xdr, OP_SECINFO_NO_NAME, decode_secinfo_no_name_maxsz, hdr); |
2034 | encode_uint32(xdr, args->style); | |
fca78d6d BS |
2035 | return 0; |
2036 | } | |
7d974794 BS |
2037 | |
2038 | static void encode_test_stateid(struct xdr_stream *xdr, | |
2039 | struct nfs41_test_stateid_args *args, | |
2040 | struct compound_hdr *hdr) | |
2041 | { | |
475d4ba0 TM |
2042 | encode_op_hdr(xdr, OP_TEST_STATEID, decode_test_stateid_maxsz, hdr); |
2043 | encode_uint32(xdr, 1); | |
ea9d23f5 | 2044 | encode_nfs4_stateid(xdr, args->stateid); |
7d974794 | 2045 | } |
9aeda35f BS |
2046 | |
2047 | static void encode_free_stateid(struct xdr_stream *xdr, | |
2048 | struct nfs41_free_stateid_args *args, | |
2049 | struct compound_hdr *hdr) | |
2050 | { | |
ab19b481 | 2051 | encode_op_hdr(xdr, OP_FREE_STATEID, decode_free_stateid_maxsz, hdr); |
7c1d5fae | 2052 | encode_nfs4_stateid(xdr, &args->stateid); |
9aeda35f | 2053 | } |
b1f69b75 AA |
2054 | #endif /* CONFIG_NFS_V4_1 */ |
2055 | ||
1da177e4 LT |
2056 | /* |
2057 | * END OF "GENERIC" ENCODE ROUTINES. | |
2058 | */ | |
2059 | ||
66cc0429 BH |
2060 | static u32 nfs4_xdr_minorversion(const struct nfs4_sequence_args *args) |
2061 | { | |
2062 | #if defined(CONFIG_NFS_V4_1) | |
3bd2384a CL |
2063 | struct nfs4_session *session = args->sa_slot->table->session; |
2064 | if (session) | |
2065 | return session->clp->cl_mvops->minor_version; | |
66cc0429 BH |
2066 | #endif /* CONFIG_NFS_V4_1 */ |
2067 | return 0; | |
2068 | } | |
2069 | ||
1da177e4 LT |
2070 | /* |
2071 | * Encode an ACCESS request | |
2072 | */ | |
9f06c719 CL |
2073 | static void nfs4_xdr_enc_access(struct rpc_rqst *req, struct xdr_stream *xdr, |
2074 | const struct nfs4_accessargs *args) | |
1da177e4 | 2075 | { |
1da177e4 | 2076 | struct compound_hdr hdr = { |
66cc0429 | 2077 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1da177e4 | 2078 | }; |
1da177e4 | 2079 | |
9f06c719 CL |
2080 | encode_compound_hdr(xdr, req, &hdr); |
2081 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2082 | encode_putfh(xdr, args->fh, &hdr); | |
2083 | encode_access(xdr, args->access, &hdr); | |
2084 | encode_getfattr(xdr, args->bitmask, &hdr); | |
d017931c | 2085 | encode_nops(&hdr); |
1da177e4 LT |
2086 | } |
2087 | ||
2088 | /* | |
2089 | * Encode LOOKUP request | |
2090 | */ | |
9f06c719 CL |
2091 | static void nfs4_xdr_enc_lookup(struct rpc_rqst *req, struct xdr_stream *xdr, |
2092 | const struct nfs4_lookup_arg *args) | |
1da177e4 | 2093 | { |
1da177e4 | 2094 | struct compound_hdr hdr = { |
66cc0429 | 2095 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1da177e4 | 2096 | }; |
1da177e4 | 2097 | |
9f06c719 CL |
2098 | encode_compound_hdr(xdr, req, &hdr); |
2099 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2100 | encode_putfh(xdr, args->dir_fh, &hdr); | |
2101 | encode_lookup(xdr, args->name, &hdr); | |
2102 | encode_getfh(xdr, &hdr); | |
2103 | encode_getfattr(xdr, args->bitmask, &hdr); | |
d017931c | 2104 | encode_nops(&hdr); |
1da177e4 LT |
2105 | } |
2106 | ||
2107 | /* | |
2108 | * Encode LOOKUP_ROOT request | |
2109 | */ | |
9f06c719 CL |
2110 | static void nfs4_xdr_enc_lookup_root(struct rpc_rqst *req, |
2111 | struct xdr_stream *xdr, | |
2112 | const struct nfs4_lookup_root_arg *args) | |
1da177e4 | 2113 | { |
1da177e4 | 2114 | struct compound_hdr hdr = { |
66cc0429 | 2115 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1da177e4 | 2116 | }; |
1da177e4 | 2117 | |
9f06c719 CL |
2118 | encode_compound_hdr(xdr, req, &hdr); |
2119 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2120 | encode_putrootfh(xdr, &hdr); | |
2121 | encode_getfh(xdr, &hdr); | |
2122 | encode_getfattr(xdr, args->bitmask, &hdr); | |
d017931c | 2123 | encode_nops(&hdr); |
1da177e4 LT |
2124 | } |
2125 | ||
2126 | /* | |
2127 | * Encode REMOVE request | |
2128 | */ | |
9f06c719 CL |
2129 | static void nfs4_xdr_enc_remove(struct rpc_rqst *req, struct xdr_stream *xdr, |
2130 | const struct nfs_removeargs *args) | |
1da177e4 | 2131 | { |
1da177e4 | 2132 | struct compound_hdr hdr = { |
66cc0429 | 2133 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1da177e4 | 2134 | }; |
1da177e4 | 2135 | |
9f06c719 CL |
2136 | encode_compound_hdr(xdr, req, &hdr); |
2137 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2138 | encode_putfh(xdr, args->fh, &hdr); | |
2139 | encode_remove(xdr, &args->name, &hdr); | |
d017931c | 2140 | encode_nops(&hdr); |
1da177e4 LT |
2141 | } |
2142 | ||
2143 | /* | |
2144 | * Encode RENAME request | |
2145 | */ | |
9f06c719 CL |
2146 | static void nfs4_xdr_enc_rename(struct rpc_rqst *req, struct xdr_stream *xdr, |
2147 | const struct nfs_renameargs *args) | |
1da177e4 | 2148 | { |
1da177e4 | 2149 | struct compound_hdr hdr = { |
66cc0429 | 2150 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1da177e4 | 2151 | }; |
1da177e4 | 2152 | |
9f06c719 CL |
2153 | encode_compound_hdr(xdr, req, &hdr); |
2154 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2155 | encode_putfh(xdr, args->old_dir, &hdr); | |
2156 | encode_savefh(xdr, &hdr); | |
2157 | encode_putfh(xdr, args->new_dir, &hdr); | |
2158 | encode_rename(xdr, args->old_name, args->new_name, &hdr); | |
d017931c | 2159 | encode_nops(&hdr); |
1da177e4 LT |
2160 | } |
2161 | ||
2162 | /* | |
2163 | * Encode LINK request | |
2164 | */ | |
9f06c719 CL |
2165 | static void nfs4_xdr_enc_link(struct rpc_rqst *req, struct xdr_stream *xdr, |
2166 | const struct nfs4_link_arg *args) | |
1da177e4 | 2167 | { |
1da177e4 | 2168 | struct compound_hdr hdr = { |
66cc0429 | 2169 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1da177e4 | 2170 | }; |
1da177e4 | 2171 | |
9f06c719 CL |
2172 | encode_compound_hdr(xdr, req, &hdr); |
2173 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2174 | encode_putfh(xdr, args->fh, &hdr); | |
2175 | encode_savefh(xdr, &hdr); | |
2176 | encode_putfh(xdr, args->dir_fh, &hdr); | |
2177 | encode_link(xdr, args->name, &hdr); | |
9f06c719 CL |
2178 | encode_restorefh(xdr, &hdr); |
2179 | encode_getfattr(xdr, args->bitmask, &hdr); | |
d017931c | 2180 | encode_nops(&hdr); |
1da177e4 LT |
2181 | } |
2182 | ||
2183 | /* | |
2184 | * Encode CREATE request | |
2185 | */ | |
9f06c719 CL |
2186 | static void nfs4_xdr_enc_create(struct rpc_rqst *req, struct xdr_stream *xdr, |
2187 | const struct nfs4_create_arg *args) | |
1da177e4 | 2188 | { |
1da177e4 | 2189 | struct compound_hdr hdr = { |
66cc0429 | 2190 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1da177e4 | 2191 | }; |
1da177e4 | 2192 | |
9f06c719 CL |
2193 | encode_compound_hdr(xdr, req, &hdr); |
2194 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2195 | encode_putfh(xdr, args->dir_fh, &hdr); | |
9f06c719 CL |
2196 | encode_create(xdr, args, &hdr); |
2197 | encode_getfh(xdr, &hdr); | |
2198 | encode_getfattr(xdr, args->bitmask, &hdr); | |
d017931c | 2199 | encode_nops(&hdr); |
1da177e4 LT |
2200 | } |
2201 | ||
2202 | /* | |
2203 | * Encode SYMLINK request | |
2204 | */ | |
9f06c719 CL |
2205 | static void nfs4_xdr_enc_symlink(struct rpc_rqst *req, struct xdr_stream *xdr, |
2206 | const struct nfs4_create_arg *args) | |
1da177e4 | 2207 | { |
9f06c719 | 2208 | nfs4_xdr_enc_create(req, xdr, args); |
1da177e4 LT |
2209 | } |
2210 | ||
2211 | /* | |
2212 | * Encode GETATTR request | |
2213 | */ | |
9f06c719 CL |
2214 | static void nfs4_xdr_enc_getattr(struct rpc_rqst *req, struct xdr_stream *xdr, |
2215 | const struct nfs4_getattr_arg *args) | |
1da177e4 | 2216 | { |
1da177e4 | 2217 | struct compound_hdr hdr = { |
66cc0429 | 2218 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1da177e4 | 2219 | }; |
1da177e4 | 2220 | |
9f06c719 CL |
2221 | encode_compound_hdr(xdr, req, &hdr); |
2222 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2223 | encode_putfh(xdr, args->fh, &hdr); | |
2224 | encode_getfattr(xdr, args->bitmask, &hdr); | |
d017931c | 2225 | encode_nops(&hdr); |
1da177e4 LT |
2226 | } |
2227 | ||
2228 | /* | |
2229 | * Encode a CLOSE request | |
2230 | */ | |
9f06c719 CL |
2231 | static void nfs4_xdr_enc_close(struct rpc_rqst *req, struct xdr_stream *xdr, |
2232 | struct nfs_closeargs *args) | |
1da177e4 | 2233 | { |
05d564fe | 2234 | struct compound_hdr hdr = { |
66cc0429 | 2235 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
05d564fe | 2236 | }; |
05d564fe | 2237 | |
9f06c719 CL |
2238 | encode_compound_hdr(xdr, req, &hdr); |
2239 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2240 | encode_putfh(xdr, args->fh, &hdr); | |
2241 | encode_close(xdr, args, &hdr); | |
2242 | encode_getfattr(xdr, args->bitmask, &hdr); | |
d017931c | 2243 | encode_nops(&hdr); |
1da177e4 LT |
2244 | } |
2245 | ||
2246 | /* | |
2247 | * Encode an OPEN request | |
2248 | */ | |
9f06c719 CL |
2249 | static void nfs4_xdr_enc_open(struct rpc_rqst *req, struct xdr_stream *xdr, |
2250 | struct nfs_openargs *args) | |
1da177e4 | 2251 | { |
1da177e4 | 2252 | struct compound_hdr hdr = { |
66cc0429 | 2253 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1da177e4 | 2254 | }; |
1da177e4 | 2255 | |
9f06c719 CL |
2256 | encode_compound_hdr(xdr, req, &hdr); |
2257 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2258 | encode_putfh(xdr, args->fh, &hdr); | |
9f06c719 CL |
2259 | encode_open(xdr, args, &hdr); |
2260 | encode_getfh(xdr, &hdr); | |
ae2bb032 WAA |
2261 | if (args->access) |
2262 | encode_access(xdr, args->access, &hdr); | |
1549210f | 2263 | encode_getfattr_open(xdr, args->bitmask, args->open_bitmap, &hdr); |
d017931c | 2264 | encode_nops(&hdr); |
1da177e4 LT |
2265 | } |
2266 | ||
2267 | /* | |
2268 | * Encode an OPEN_CONFIRM request | |
2269 | */ | |
9f06c719 CL |
2270 | static void nfs4_xdr_enc_open_confirm(struct rpc_rqst *req, |
2271 | struct xdr_stream *xdr, | |
2272 | struct nfs_open_confirmargs *args) | |
1da177e4 | 2273 | { |
1da177e4 | 2274 | struct compound_hdr hdr = { |
d017931c | 2275 | .nops = 0, |
1da177e4 | 2276 | }; |
1da177e4 | 2277 | |
9f06c719 CL |
2278 | encode_compound_hdr(xdr, req, &hdr); |
2279 | encode_putfh(xdr, args->fh, &hdr); | |
2280 | encode_open_confirm(xdr, args, &hdr); | |
d017931c | 2281 | encode_nops(&hdr); |
1da177e4 LT |
2282 | } |
2283 | ||
2284 | /* | |
2285 | * Encode an OPEN request with no attributes. | |
2286 | */ | |
9f06c719 CL |
2287 | static void nfs4_xdr_enc_open_noattr(struct rpc_rqst *req, |
2288 | struct xdr_stream *xdr, | |
2289 | struct nfs_openargs *args) | |
1da177e4 | 2290 | { |
1da177e4 | 2291 | struct compound_hdr hdr = { |
66cc0429 | 2292 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1da177e4 | 2293 | }; |
1da177e4 | 2294 | |
9f06c719 CL |
2295 | encode_compound_hdr(xdr, req, &hdr); |
2296 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2297 | encode_putfh(xdr, args->fh, &hdr); | |
2298 | encode_open(xdr, args, &hdr); | |
ae2bb032 WAA |
2299 | if (args->access) |
2300 | encode_access(xdr, args->access, &hdr); | |
e23008ec | 2301 | encode_getfattr_open(xdr, args->bitmask, args->open_bitmap, &hdr); |
d017931c | 2302 | encode_nops(&hdr); |
1da177e4 LT |
2303 | } |
2304 | ||
2305 | /* | |
2306 | * Encode an OPEN_DOWNGRADE request | |
2307 | */ | |
9f06c719 CL |
2308 | static void nfs4_xdr_enc_open_downgrade(struct rpc_rqst *req, |
2309 | struct xdr_stream *xdr, | |
2310 | struct nfs_closeargs *args) | |
1da177e4 | 2311 | { |
1da177e4 | 2312 | struct compound_hdr hdr = { |
66cc0429 | 2313 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1da177e4 | 2314 | }; |
1da177e4 | 2315 | |
9f06c719 CL |
2316 | encode_compound_hdr(xdr, req, &hdr); |
2317 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2318 | encode_putfh(xdr, args->fh, &hdr); | |
2319 | encode_open_downgrade(xdr, args, &hdr); | |
2320 | encode_getfattr(xdr, args->bitmask, &hdr); | |
d017931c | 2321 | encode_nops(&hdr); |
1da177e4 LT |
2322 | } |
2323 | ||
2324 | /* | |
2325 | * Encode a LOCK request | |
2326 | */ | |
9f06c719 CL |
2327 | static void nfs4_xdr_enc_lock(struct rpc_rqst *req, struct xdr_stream *xdr, |
2328 | struct nfs_lock_args *args) | |
1da177e4 | 2329 | { |
1da177e4 | 2330 | struct compound_hdr hdr = { |
66cc0429 | 2331 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1da177e4 | 2332 | }; |
1da177e4 | 2333 | |
9f06c719 CL |
2334 | encode_compound_hdr(xdr, req, &hdr); |
2335 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2336 | encode_putfh(xdr, args->fh, &hdr); | |
2337 | encode_lock(xdr, args, &hdr); | |
d017931c | 2338 | encode_nops(&hdr); |
1da177e4 LT |
2339 | } |
2340 | ||
2341 | /* | |
2342 | * Encode a LOCKT request | |
2343 | */ | |
9f06c719 CL |
2344 | static void nfs4_xdr_enc_lockt(struct rpc_rqst *req, struct xdr_stream *xdr, |
2345 | struct nfs_lockt_args *args) | |
1da177e4 | 2346 | { |
1da177e4 | 2347 | struct compound_hdr hdr = { |
66cc0429 | 2348 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1da177e4 | 2349 | }; |
1da177e4 | 2350 | |
9f06c719 CL |
2351 | encode_compound_hdr(xdr, req, &hdr); |
2352 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2353 | encode_putfh(xdr, args->fh, &hdr); | |
2354 | encode_lockt(xdr, args, &hdr); | |
d017931c | 2355 | encode_nops(&hdr); |
1da177e4 LT |
2356 | } |
2357 | ||
2358 | /* | |
2359 | * Encode a LOCKU request | |
2360 | */ | |
9f06c719 CL |
2361 | static void nfs4_xdr_enc_locku(struct rpc_rqst *req, struct xdr_stream *xdr, |
2362 | struct nfs_locku_args *args) | |
1da177e4 | 2363 | { |
1da177e4 | 2364 | struct compound_hdr hdr = { |
66cc0429 | 2365 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1da177e4 | 2366 | }; |
1da177e4 | 2367 | |
9f06c719 CL |
2368 | encode_compound_hdr(xdr, req, &hdr); |
2369 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2370 | encode_putfh(xdr, args->fh, &hdr); | |
2371 | encode_locku(xdr, args, &hdr); | |
d017931c | 2372 | encode_nops(&hdr); |
1da177e4 LT |
2373 | } |
2374 | ||
9f06c719 CL |
2375 | static void nfs4_xdr_enc_release_lockowner(struct rpc_rqst *req, |
2376 | struct xdr_stream *xdr, | |
2377 | struct nfs_release_lockowner_args *args) | |
d3c7b7cc | 2378 | { |
d3c7b7cc TM |
2379 | struct compound_hdr hdr = { |
2380 | .minorversion = 0, | |
2381 | }; | |
2382 | ||
9f06c719 CL |
2383 | encode_compound_hdr(xdr, req, &hdr); |
2384 | encode_release_lockowner(xdr, &args->lock_owner, &hdr); | |
d3c7b7cc | 2385 | encode_nops(&hdr); |
d3c7b7cc TM |
2386 | } |
2387 | ||
1da177e4 LT |
2388 | /* |
2389 | * Encode a READLINK request | |
2390 | */ | |
9f06c719 CL |
2391 | static void nfs4_xdr_enc_readlink(struct rpc_rqst *req, struct xdr_stream *xdr, |
2392 | const struct nfs4_readlink *args) | |
1da177e4 | 2393 | { |
1da177e4 | 2394 | struct compound_hdr hdr = { |
66cc0429 | 2395 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1da177e4 | 2396 | }; |
1da177e4 | 2397 | |
9f06c719 CL |
2398 | encode_compound_hdr(xdr, req, &hdr); |
2399 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2400 | encode_putfh(xdr, args->fh, &hdr); | |
2401 | encode_readlink(xdr, args, req, &hdr); | |
e3a535e1 | 2402 | |
28f56694 | 2403 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, args->pages, |
e3a535e1 | 2404 | args->pgbase, args->pglen); |
d017931c | 2405 | encode_nops(&hdr); |
1da177e4 LT |
2406 | } |
2407 | ||
2408 | /* | |
2409 | * Encode a READDIR request | |
2410 | */ | |
9f06c719 CL |
2411 | static void nfs4_xdr_enc_readdir(struct rpc_rqst *req, struct xdr_stream *xdr, |
2412 | const struct nfs4_readdir_arg *args) | |
1da177e4 | 2413 | { |
1da177e4 | 2414 | struct compound_hdr hdr = { |
66cc0429 | 2415 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1da177e4 | 2416 | }; |
1da177e4 | 2417 | |
9f06c719 CL |
2418 | encode_compound_hdr(xdr, req, &hdr); |
2419 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2420 | encode_putfh(xdr, args->fh, &hdr); | |
2421 | encode_readdir(xdr, args, req, &hdr); | |
d6ac02df | 2422 | |
28f56694 | 2423 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, args->pages, |
d6ac02df TM |
2424 | args->pgbase, args->count); |
2425 | dprintk("%s: inlined page args = (%u, %p, %u, %u)\n", | |
28f56694 | 2426 | __func__, hdr.replen << 2, args->pages, |
d6ac02df | 2427 | args->pgbase, args->count); |
d017931c | 2428 | encode_nops(&hdr); |
1da177e4 LT |
2429 | } |
2430 | ||
2431 | /* | |
2432 | * Encode a READ request | |
2433 | */ | |
9f06c719 | 2434 | static void nfs4_xdr_enc_read(struct rpc_rqst *req, struct xdr_stream *xdr, |
3c6b899c | 2435 | struct nfs_pgio_args *args) |
1da177e4 | 2436 | { |
1da177e4 | 2437 | struct compound_hdr hdr = { |
66cc0429 | 2438 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1da177e4 | 2439 | }; |
1da177e4 | 2440 | |
9f06c719 CL |
2441 | encode_compound_hdr(xdr, req, &hdr); |
2442 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2443 | encode_putfh(xdr, args->fh, &hdr); | |
2444 | encode_read(xdr, args, &hdr); | |
1da177e4 | 2445 | |
28f56694 | 2446 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, |
1da177e4 | 2447 | args->pages, args->pgbase, args->count); |
4f22ccc3 | 2448 | req->rq_rcv_buf.flags |= XDRBUF_READ; |
d017931c | 2449 | encode_nops(&hdr); |
1da177e4 LT |
2450 | } |
2451 | ||
2452 | /* | |
2453 | * Encode an SETATTR request | |
2454 | */ | |
9f06c719 CL |
2455 | static void nfs4_xdr_enc_setattr(struct rpc_rqst *req, struct xdr_stream *xdr, |
2456 | struct nfs_setattrargs *args) | |
1da177e4 | 2457 | { |
05d564fe | 2458 | struct compound_hdr hdr = { |
66cc0429 | 2459 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
05d564fe | 2460 | }; |
05d564fe | 2461 | |
9f06c719 CL |
2462 | encode_compound_hdr(xdr, req, &hdr); |
2463 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2464 | encode_putfh(xdr, args->fh, &hdr); | |
2465 | encode_setattr(xdr, args, args->server, &hdr); | |
2466 | encode_getfattr(xdr, args->bitmask, &hdr); | |
d017931c | 2467 | encode_nops(&hdr); |
1da177e4 LT |
2468 | } |
2469 | ||
029d105e BF |
2470 | /* |
2471 | * Encode a GETACL request | |
2472 | */ | |
9f06c719 CL |
2473 | static void nfs4_xdr_enc_getacl(struct rpc_rqst *req, struct xdr_stream *xdr, |
2474 | struct nfs_getaclargs *args) | |
029d105e | 2475 | { |
029d105e | 2476 | struct compound_hdr hdr = { |
66cc0429 | 2477 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
029d105e | 2478 | }; |
28f56694 | 2479 | uint32_t replen; |
029d105e | 2480 | |
9f06c719 CL |
2481 | encode_compound_hdr(xdr, req, &hdr); |
2482 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2483 | encode_putfh(xdr, args->fh, &hdr); | |
bf118a34 | 2484 | replen = hdr.replen + op_decode_hdr_maxsz + 1; |
9f06c719 | 2485 | encode_getattr_two(xdr, FATTR4_WORD0_ACL, 0, &hdr); |
cf8cdbe5 | 2486 | |
28f56694 | 2487 | xdr_inline_pages(&req->rq_rcv_buf, replen << 2, |
029d105e | 2488 | args->acl_pages, args->acl_pgbase, args->acl_len); |
bf118a34 | 2489 | |
d017931c | 2490 | encode_nops(&hdr); |
029d105e BF |
2491 | } |
2492 | ||
1da177e4 LT |
2493 | /* |
2494 | * Encode a WRITE request | |
2495 | */ | |
9f06c719 | 2496 | static void nfs4_xdr_enc_write(struct rpc_rqst *req, struct xdr_stream *xdr, |
3c6b899c | 2497 | struct nfs_pgio_args *args) |
1da177e4 | 2498 | { |
1da177e4 | 2499 | struct compound_hdr hdr = { |
66cc0429 | 2500 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1da177e4 | 2501 | }; |
1da177e4 | 2502 | |
9f06c719 CL |
2503 | encode_compound_hdr(xdr, req, &hdr); |
2504 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2505 | encode_putfh(xdr, args->fh, &hdr); | |
2506 | encode_write(xdr, args, &hdr); | |
4f22ccc3 | 2507 | req->rq_snd_buf.flags |= XDRBUF_WRITE; |
7ffd1064 FI |
2508 | if (args->bitmask) |
2509 | encode_getfattr(xdr, args->bitmask, &hdr); | |
d017931c | 2510 | encode_nops(&hdr); |
1da177e4 LT |
2511 | } |
2512 | ||
2513 | /* | |
2514 | * a COMMIT request | |
2515 | */ | |
9f06c719 | 2516 | static void nfs4_xdr_enc_commit(struct rpc_rqst *req, struct xdr_stream *xdr, |
0b7c0153 | 2517 | struct nfs_commitargs *args) |
1da177e4 | 2518 | { |
1da177e4 | 2519 | struct compound_hdr hdr = { |
66cc0429 | 2520 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1da177e4 | 2521 | }; |
1da177e4 | 2522 | |
9f06c719 CL |
2523 | encode_compound_hdr(xdr, req, &hdr); |
2524 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2525 | encode_putfh(xdr, args->fh, &hdr); | |
2526 | encode_commit(xdr, args, &hdr); | |
d017931c | 2527 | encode_nops(&hdr); |
1da177e4 LT |
2528 | } |
2529 | ||
2530 | /* | |
2531 | * FSINFO request | |
2532 | */ | |
9f06c719 CL |
2533 | static void nfs4_xdr_enc_fsinfo(struct rpc_rqst *req, struct xdr_stream *xdr, |
2534 | struct nfs4_fsinfo_arg *args) | |
1da177e4 | 2535 | { |
1da177e4 | 2536 | struct compound_hdr hdr = { |
66cc0429 | 2537 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1da177e4 | 2538 | }; |
1da177e4 | 2539 | |
9f06c719 CL |
2540 | encode_compound_hdr(xdr, req, &hdr); |
2541 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2542 | encode_putfh(xdr, args->fh, &hdr); | |
2543 | encode_fsinfo(xdr, args->bitmask, &hdr); | |
d017931c | 2544 | encode_nops(&hdr); |
1da177e4 LT |
2545 | } |
2546 | ||
2547 | /* | |
2548 | * a PATHCONF request | |
2549 | */ | |
9f06c719 CL |
2550 | static void nfs4_xdr_enc_pathconf(struct rpc_rqst *req, struct xdr_stream *xdr, |
2551 | const struct nfs4_pathconf_arg *args) | |
1da177e4 | 2552 | { |
1da177e4 | 2553 | struct compound_hdr hdr = { |
66cc0429 | 2554 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1da177e4 | 2555 | }; |
1da177e4 | 2556 | |
9f06c719 CL |
2557 | encode_compound_hdr(xdr, req, &hdr); |
2558 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2559 | encode_putfh(xdr, args->fh, &hdr); | |
2560 | encode_getattr_one(xdr, args->bitmask[0] & nfs4_pathconf_bitmap[0], | |
cf8cdbe5 | 2561 | &hdr); |
d017931c | 2562 | encode_nops(&hdr); |
1da177e4 LT |
2563 | } |
2564 | ||
2565 | /* | |
2566 | * a STATFS request | |
2567 | */ | |
9f06c719 CL |
2568 | static void nfs4_xdr_enc_statfs(struct rpc_rqst *req, struct xdr_stream *xdr, |
2569 | const struct nfs4_statfs_arg *args) | |
1da177e4 | 2570 | { |
1da177e4 | 2571 | struct compound_hdr hdr = { |
66cc0429 | 2572 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1da177e4 | 2573 | }; |
1da177e4 | 2574 | |
9f06c719 CL |
2575 | encode_compound_hdr(xdr, req, &hdr); |
2576 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2577 | encode_putfh(xdr, args->fh, &hdr); | |
2578 | encode_getattr_two(xdr, args->bitmask[0] & nfs4_statfs_bitmap[0], | |
cf8cdbe5 | 2579 | args->bitmask[1] & nfs4_statfs_bitmap[1], &hdr); |
d017931c | 2580 | encode_nops(&hdr); |
1da177e4 LT |
2581 | } |
2582 | ||
2583 | /* | |
2584 | * GETATTR_BITMAP request | |
2585 | */ | |
9f06c719 CL |
2586 | static void nfs4_xdr_enc_server_caps(struct rpc_rqst *req, |
2587 | struct xdr_stream *xdr, | |
2588 | struct nfs4_server_caps_arg *args) | |
1da177e4 | 2589 | { |
1da177e4 | 2590 | struct compound_hdr hdr = { |
66cc0429 | 2591 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1da177e4 | 2592 | }; |
1da177e4 | 2593 | |
9f06c719 CL |
2594 | encode_compound_hdr(xdr, req, &hdr); |
2595 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2596 | encode_putfh(xdr, args->fhandle, &hdr); | |
2597 | encode_getattr_one(xdr, FATTR4_WORD0_SUPPORTED_ATTRS| | |
264e6351 | 2598 | FATTR4_WORD0_FH_EXPIRE_TYPE| |
cf8cdbe5 AA |
2599 | FATTR4_WORD0_LINK_SUPPORT| |
2600 | FATTR4_WORD0_SYMLINK_SUPPORT| | |
2601 | FATTR4_WORD0_ACLSUPPORT, &hdr); | |
d017931c | 2602 | encode_nops(&hdr); |
1da177e4 LT |
2603 | } |
2604 | ||
2605 | /* | |
2606 | * a RENEW request | |
2607 | */ | |
9f06c719 CL |
2608 | static void nfs4_xdr_enc_renew(struct rpc_rqst *req, struct xdr_stream *xdr, |
2609 | struct nfs_client *clp) | |
1da177e4 | 2610 | { |
1da177e4 | 2611 | struct compound_hdr hdr = { |
d017931c | 2612 | .nops = 0, |
1da177e4 LT |
2613 | }; |
2614 | ||
9f06c719 | 2615 | encode_compound_hdr(xdr, req, &hdr); |
bb4dae5e | 2616 | encode_renew(xdr, clp->cl_clientid, &hdr); |
d017931c | 2617 | encode_nops(&hdr); |
1da177e4 LT |
2618 | } |
2619 | ||
2620 | /* | |
2621 | * a SETCLIENTID request | |
2622 | */ | |
9f06c719 CL |
2623 | static void nfs4_xdr_enc_setclientid(struct rpc_rqst *req, |
2624 | struct xdr_stream *xdr, | |
2625 | struct nfs4_setclientid *sc) | |
1da177e4 | 2626 | { |
1da177e4 | 2627 | struct compound_hdr hdr = { |
d017931c | 2628 | .nops = 0, |
1da177e4 LT |
2629 | }; |
2630 | ||
9f06c719 CL |
2631 | encode_compound_hdr(xdr, req, &hdr); |
2632 | encode_setclientid(xdr, sc, &hdr); | |
d017931c | 2633 | encode_nops(&hdr); |
1da177e4 LT |
2634 | } |
2635 | ||
2636 | /* | |
2637 | * a SETCLIENTID_CONFIRM request | |
2638 | */ | |
9f06c719 CL |
2639 | static void nfs4_xdr_enc_setclientid_confirm(struct rpc_rqst *req, |
2640 | struct xdr_stream *xdr, | |
2641 | struct nfs4_setclientid_res *arg) | |
1da177e4 | 2642 | { |
1da177e4 | 2643 | struct compound_hdr hdr = { |
d017931c | 2644 | .nops = 0, |
1da177e4 | 2645 | }; |
1da177e4 | 2646 | |
9f06c719 CL |
2647 | encode_compound_hdr(xdr, req, &hdr); |
2648 | encode_setclientid_confirm(xdr, arg, &hdr); | |
d017931c | 2649 | encode_nops(&hdr); |
1da177e4 LT |
2650 | } |
2651 | ||
2652 | /* | |
2653 | * DELEGRETURN request | |
2654 | */ | |
9f06c719 CL |
2655 | static void nfs4_xdr_enc_delegreturn(struct rpc_rqst *req, |
2656 | struct xdr_stream *xdr, | |
2657 | const struct nfs4_delegreturnargs *args) | |
1da177e4 | 2658 | { |
1da177e4 | 2659 | struct compound_hdr hdr = { |
66cc0429 | 2660 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
1da177e4 | 2661 | }; |
1da177e4 | 2662 | |
9f06c719 CL |
2663 | encode_compound_hdr(xdr, req, &hdr); |
2664 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2665 | encode_putfh(xdr, args->fhandle, &hdr); | |
9f06c719 | 2666 | encode_getfattr(xdr, args->bitmask, &hdr); |
e144cbcc | 2667 | encode_delegreturn(xdr, args->stateid, &hdr); |
d017931c | 2668 | encode_nops(&hdr); |
1da177e4 LT |
2669 | } |
2670 | ||
683b57b4 TM |
2671 | /* |
2672 | * Encode FS_LOCATIONS request | |
2673 | */ | |
9f06c719 CL |
2674 | static void nfs4_xdr_enc_fs_locations(struct rpc_rqst *req, |
2675 | struct xdr_stream *xdr, | |
2676 | struct nfs4_fs_locations_arg *args) | |
683b57b4 | 2677 | { |
683b57b4 | 2678 | struct compound_hdr hdr = { |
66cc0429 | 2679 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
683b57b4 | 2680 | }; |
28f56694 | 2681 | uint32_t replen; |
683b57b4 | 2682 | |
9f06c719 CL |
2683 | encode_compound_hdr(xdr, req, &hdr); |
2684 | encode_sequence(xdr, &args->seq_args, &hdr); | |
b03d735b CL |
2685 | if (args->migration) { |
2686 | encode_putfh(xdr, args->fh, &hdr); | |
2687 | replen = hdr.replen; | |
2688 | encode_fs_locations(xdr, args->bitmask, &hdr); | |
2689 | if (args->renew) | |
2690 | encode_renew(xdr, args->clientid, &hdr); | |
2691 | } else { | |
2692 | encode_putfh(xdr, args->dir_fh, &hdr); | |
2693 | encode_lookup(xdr, args->name, &hdr); | |
2694 | replen = hdr.replen; | |
2695 | encode_fs_locations(xdr, args->bitmask, &hdr); | |
2696 | } | |
cf8cdbe5 | 2697 | |
b03d735b | 2698 | /* Set up reply kvec to capture returned fs_locations array. */ |
28f56694 | 2699 | xdr_inline_pages(&req->rq_rcv_buf, replen << 2, &args->page, |
683b57b4 | 2700 | 0, PAGE_SIZE); |
d017931c | 2701 | encode_nops(&hdr); |
683b57b4 TM |
2702 | } |
2703 | ||
5a5ea0d4 BS |
2704 | /* |
2705 | * Encode SECINFO request | |
2706 | */ | |
2707 | static void nfs4_xdr_enc_secinfo(struct rpc_rqst *req, | |
2708 | struct xdr_stream *xdr, | |
2709 | struct nfs4_secinfo_arg *args) | |
2710 | { | |
2711 | struct compound_hdr hdr = { | |
2712 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | |
2713 | }; | |
2714 | ||
2715 | encode_compound_hdr(xdr, req, &hdr); | |
2716 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2717 | encode_putfh(xdr, args->dir_fh, &hdr); | |
2718 | encode_secinfo(xdr, args->name, &hdr); | |
2719 | encode_nops(&hdr); | |
2720 | } | |
2721 | ||
44c99933 CL |
2722 | /* |
2723 | * Encode FSID_PRESENT request | |
2724 | */ | |
2725 | static void nfs4_xdr_enc_fsid_present(struct rpc_rqst *req, | |
2726 | struct xdr_stream *xdr, | |
2727 | struct nfs4_fsid_present_arg *args) | |
2728 | { | |
2729 | struct compound_hdr hdr = { | |
2730 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | |
2731 | }; | |
2732 | ||
2733 | encode_compound_hdr(xdr, req, &hdr); | |
2734 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2735 | encode_putfh(xdr, args->fh, &hdr); | |
2736 | encode_getfh(xdr, &hdr); | |
2737 | if (args->renew) | |
2738 | encode_renew(xdr, args->clientid, &hdr); | |
2739 | encode_nops(&hdr); | |
2740 | } | |
2741 | ||
99fe60d0 | 2742 | #if defined(CONFIG_NFS_V4_1) |
7c44f1ae WAA |
2743 | /* |
2744 | * BIND_CONN_TO_SESSION request | |
2745 | */ | |
2746 | static void nfs4_xdr_enc_bind_conn_to_session(struct rpc_rqst *req, | |
2747 | struct xdr_stream *xdr, | |
2748 | struct nfs_client *clp) | |
2749 | { | |
2750 | struct compound_hdr hdr = { | |
2751 | .minorversion = clp->cl_mvops->minor_version, | |
2752 | }; | |
2753 | ||
2754 | encode_compound_hdr(xdr, req, &hdr); | |
2755 | encode_bind_conn_to_session(xdr, clp->cl_session, &hdr); | |
2756 | encode_nops(&hdr); | |
2757 | } | |
2758 | ||
99fe60d0 BH |
2759 | /* |
2760 | * EXCHANGE_ID request | |
2761 | */ | |
9f06c719 CL |
2762 | static void nfs4_xdr_enc_exchange_id(struct rpc_rqst *req, |
2763 | struct xdr_stream *xdr, | |
2764 | struct nfs41_exchange_id_args *args) | |
99fe60d0 | 2765 | { |
99fe60d0 | 2766 | struct compound_hdr hdr = { |
a4432345 | 2767 | .minorversion = args->client->cl_mvops->minor_version, |
99fe60d0 BH |
2768 | }; |
2769 | ||
9f06c719 CL |
2770 | encode_compound_hdr(xdr, req, &hdr); |
2771 | encode_exchange_id(xdr, args, &hdr); | |
99fe60d0 | 2772 | encode_nops(&hdr); |
99fe60d0 | 2773 | } |
2050f0cc | 2774 | |
fc931582 AA |
2775 | /* |
2776 | * a CREATE_SESSION request | |
2777 | */ | |
9f06c719 CL |
2778 | static void nfs4_xdr_enc_create_session(struct rpc_rqst *req, |
2779 | struct xdr_stream *xdr, | |
2780 | struct nfs41_create_session_args *args) | |
fc931582 | 2781 | { |
fc931582 | 2782 | struct compound_hdr hdr = { |
a4432345 | 2783 | .minorversion = args->client->cl_mvops->minor_version, |
fc931582 AA |
2784 | }; |
2785 | ||
9f06c719 CL |
2786 | encode_compound_hdr(xdr, req, &hdr); |
2787 | encode_create_session(xdr, args, &hdr); | |
fc931582 | 2788 | encode_nops(&hdr); |
fc931582 AA |
2789 | } |
2790 | ||
0f3e66c6 AA |
2791 | /* |
2792 | * a DESTROY_SESSION request | |
2793 | */ | |
9f06c719 CL |
2794 | static void nfs4_xdr_enc_destroy_session(struct rpc_rqst *req, |
2795 | struct xdr_stream *xdr, | |
2796 | struct nfs4_session *session) | |
0f3e66c6 | 2797 | { |
0f3e66c6 | 2798 | struct compound_hdr hdr = { |
a4432345 | 2799 | .minorversion = session->clp->cl_mvops->minor_version, |
0f3e66c6 AA |
2800 | }; |
2801 | ||
9f06c719 CL |
2802 | encode_compound_hdr(xdr, req, &hdr); |
2803 | encode_destroy_session(xdr, session, &hdr); | |
0f3e66c6 | 2804 | encode_nops(&hdr); |
0f3e66c6 AA |
2805 | } |
2806 | ||
66245539 TM |
2807 | /* |
2808 | * a DESTROY_CLIENTID request | |
2809 | */ | |
2810 | static void nfs4_xdr_enc_destroy_clientid(struct rpc_rqst *req, | |
2811 | struct xdr_stream *xdr, | |
2812 | struct nfs_client *clp) | |
2813 | { | |
2814 | struct compound_hdr hdr = { | |
2815 | .minorversion = clp->cl_mvops->minor_version, | |
2816 | }; | |
2817 | ||
2818 | encode_compound_hdr(xdr, req, &hdr); | |
2819 | encode_destroy_clientid(xdr, clp->cl_clientid, &hdr); | |
2820 | encode_nops(&hdr); | |
2821 | } | |
2822 | ||
fc01cea9 AA |
2823 | /* |
2824 | * a SEQUENCE request | |
2825 | */ | |
9f06c719 CL |
2826 | static void nfs4_xdr_enc_sequence(struct rpc_rqst *req, struct xdr_stream *xdr, |
2827 | struct nfs4_sequence_args *args) | |
fc01cea9 | 2828 | { |
fc01cea9 AA |
2829 | struct compound_hdr hdr = { |
2830 | .minorversion = nfs4_xdr_minorversion(args), | |
2831 | }; | |
2832 | ||
9f06c719 CL |
2833 | encode_compound_hdr(xdr, req, &hdr); |
2834 | encode_sequence(xdr, args, &hdr); | |
fc01cea9 | 2835 | encode_nops(&hdr); |
fc01cea9 AA |
2836 | } |
2837 | ||
2050f0cc AA |
2838 | /* |
2839 | * a GET_LEASE_TIME request | |
2840 | */ | |
9f06c719 CL |
2841 | static void nfs4_xdr_enc_get_lease_time(struct rpc_rqst *req, |
2842 | struct xdr_stream *xdr, | |
2843 | struct nfs4_get_lease_time_args *args) | |
2050f0cc | 2844 | { |
2050f0cc AA |
2845 | struct compound_hdr hdr = { |
2846 | .minorversion = nfs4_xdr_minorversion(&args->la_seq_args), | |
2847 | }; | |
dae100c2 | 2848 | const u32 lease_bitmap[3] = { FATTR4_WORD0_LEASE_TIME }; |
2050f0cc | 2849 | |
9f06c719 CL |
2850 | encode_compound_hdr(xdr, req, &hdr); |
2851 | encode_sequence(xdr, &args->la_seq_args, &hdr); | |
2852 | encode_putrootfh(xdr, &hdr); | |
2853 | encode_fsinfo(xdr, lease_bitmap, &hdr); | |
2050f0cc | 2854 | encode_nops(&hdr); |
2050f0cc | 2855 | } |
18019753 RL |
2856 | |
2857 | /* | |
2858 | * a RECLAIM_COMPLETE request | |
2859 | */ | |
9f06c719 CL |
2860 | static void nfs4_xdr_enc_reclaim_complete(struct rpc_rqst *req, |
2861 | struct xdr_stream *xdr, | |
2862 | struct nfs41_reclaim_complete_args *args) | |
18019753 | 2863 | { |
18019753 RL |
2864 | struct compound_hdr hdr = { |
2865 | .minorversion = nfs4_xdr_minorversion(&args->seq_args) | |
2866 | }; | |
2867 | ||
9f06c719 CL |
2868 | encode_compound_hdr(xdr, req, &hdr); |
2869 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2870 | encode_reclaim_complete(xdr, args, &hdr); | |
18019753 | 2871 | encode_nops(&hdr); |
18019753 RL |
2872 | } |
2873 | ||
b1f69b75 AA |
2874 | /* |
2875 | * Encode GETDEVICEINFO request | |
2876 | */ | |
9f06c719 CL |
2877 | static void nfs4_xdr_enc_getdeviceinfo(struct rpc_rqst *req, |
2878 | struct xdr_stream *xdr, | |
2879 | struct nfs4_getdeviceinfo_args *args) | |
b1f69b75 | 2880 | { |
b1f69b75 AA |
2881 | struct compound_hdr hdr = { |
2882 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | |
2883 | }; | |
2884 | ||
9f06c719 CL |
2885 | encode_compound_hdr(xdr, req, &hdr); |
2886 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2887 | encode_getdeviceinfo(xdr, args, &hdr); | |
b1f69b75 AA |
2888 | |
2889 | /* set up reply kvec. Subtract notification bitmap max size (2) | |
2890 | * so that notification bitmap is put in xdr_buf tail */ | |
2891 | xdr_inline_pages(&req->rq_rcv_buf, (hdr.replen - 2) << 2, | |
2892 | args->pdev->pages, args->pdev->pgbase, | |
2893 | args->pdev->pglen); | |
2894 | ||
2895 | encode_nops(&hdr); | |
b1f69b75 AA |
2896 | } |
2897 | ||
2898 | /* | |
2899 | * Encode LAYOUTGET request | |
2900 | */ | |
9f06c719 CL |
2901 | static void nfs4_xdr_enc_layoutget(struct rpc_rqst *req, |
2902 | struct xdr_stream *xdr, | |
2903 | struct nfs4_layoutget_args *args) | |
b1f69b75 | 2904 | { |
b1f69b75 AA |
2905 | struct compound_hdr hdr = { |
2906 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | |
2907 | }; | |
2908 | ||
9f06c719 CL |
2909 | encode_compound_hdr(xdr, req, &hdr); |
2910 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2911 | encode_putfh(xdr, NFS_FH(args->inode), &hdr); | |
2912 | encode_layoutget(xdr, args, &hdr); | |
35124a09 WAA |
2913 | |
2914 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, | |
2915 | args->layout.pages, 0, args->layout.pglen); | |
2916 | ||
b1f69b75 | 2917 | encode_nops(&hdr); |
b1f69b75 | 2918 | } |
863a3c6c AA |
2919 | |
2920 | /* | |
2921 | * Encode LAYOUTCOMMIT request | |
2922 | */ | |
cbe82603 BH |
2923 | static void nfs4_xdr_enc_layoutcommit(struct rpc_rqst *req, |
2924 | struct xdr_stream *xdr, | |
2925 | struct nfs4_layoutcommit_args *args) | |
863a3c6c | 2926 | { |
ac7db726 BH |
2927 | struct nfs4_layoutcommit_data *data = |
2928 | container_of(args, struct nfs4_layoutcommit_data, args); | |
863a3c6c AA |
2929 | struct compound_hdr hdr = { |
2930 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | |
2931 | }; | |
2932 | ||
2933 | encode_compound_hdr(xdr, req, &hdr); | |
2934 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2935 | encode_putfh(xdr, NFS_FH(args->inode), &hdr); | |
ac7db726 | 2936 | encode_layoutcommit(xdr, data->args.inode, args, &hdr); |
863a3c6c | 2937 | encode_getfattr(xdr, args->bitmask, &hdr); |
b1f69b75 | 2938 | encode_nops(&hdr); |
cbe82603 BH |
2939 | } |
2940 | ||
2941 | /* | |
2942 | * Encode LAYOUTRETURN request | |
2943 | */ | |
2944 | static void nfs4_xdr_enc_layoutreturn(struct rpc_rqst *req, | |
2945 | struct xdr_stream *xdr, | |
2946 | struct nfs4_layoutreturn_args *args) | |
2947 | { | |
2948 | struct compound_hdr hdr = { | |
2949 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | |
2950 | }; | |
2951 | ||
2952 | encode_compound_hdr(xdr, req, &hdr); | |
2953 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2954 | encode_putfh(xdr, NFS_FH(args->inode), &hdr); | |
2955 | encode_layoutreturn(xdr, args, &hdr); | |
2956 | encode_nops(&hdr); | |
b1f69b75 | 2957 | } |
fca78d6d BS |
2958 | |
2959 | /* | |
2960 | * Encode SECINFO_NO_NAME request | |
2961 | */ | |
2962 | static int nfs4_xdr_enc_secinfo_no_name(struct rpc_rqst *req, | |
2963 | struct xdr_stream *xdr, | |
2964 | struct nfs41_secinfo_no_name_args *args) | |
2965 | { | |
2966 | struct compound_hdr hdr = { | |
2967 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | |
2968 | }; | |
2969 | ||
2970 | encode_compound_hdr(xdr, req, &hdr); | |
2971 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2972 | encode_putrootfh(xdr, &hdr); | |
2973 | encode_secinfo_no_name(xdr, args, &hdr); | |
2974 | encode_nops(&hdr); | |
2975 | return 0; | |
2976 | } | |
7d974794 BS |
2977 | |
2978 | /* | |
2979 | * Encode TEST_STATEID request | |
2980 | */ | |
2981 | static void nfs4_xdr_enc_test_stateid(struct rpc_rqst *req, | |
2982 | struct xdr_stream *xdr, | |
2983 | struct nfs41_test_stateid_args *args) | |
2984 | { | |
2985 | struct compound_hdr hdr = { | |
2986 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | |
2987 | }; | |
2988 | ||
2989 | encode_compound_hdr(xdr, req, &hdr); | |
2990 | encode_sequence(xdr, &args->seq_args, &hdr); | |
2991 | encode_test_stateid(xdr, args, &hdr); | |
2992 | encode_nops(&hdr); | |
2993 | } | |
9aeda35f BS |
2994 | |
2995 | /* | |
2996 | * Encode FREE_STATEID request | |
2997 | */ | |
2998 | static void nfs4_xdr_enc_free_stateid(struct rpc_rqst *req, | |
2999 | struct xdr_stream *xdr, | |
3000 | struct nfs41_free_stateid_args *args) | |
3001 | { | |
3002 | struct compound_hdr hdr = { | |
3003 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | |
3004 | }; | |
3005 | ||
3006 | encode_compound_hdr(xdr, req, &hdr); | |
3007 | encode_sequence(xdr, &args->seq_args, &hdr); | |
3008 | encode_free_stateid(xdr, args, &hdr); | |
3009 | encode_nops(&hdr); | |
3010 | } | |
99fe60d0 BH |
3011 | #endif /* CONFIG_NFS_V4_1 */ |
3012 | ||
686841b3 BH |
3013 | static void print_overflow_msg(const char *func, const struct xdr_stream *xdr) |
3014 | { | |
3015 | dprintk("nfs: %s: prematurely hit end of receive buffer. " | |
3016 | "Remaining buffer length is %tu words.\n", | |
3017 | func, xdr->end - xdr->p); | |
3018 | } | |
1da177e4 | 3019 | |
683b57b4 | 3020 | static int decode_opaque_inline(struct xdr_stream *xdr, unsigned int *len, char **string) |
1da177e4 | 3021 | { |
8687b63a | 3022 | __be32 *p; |
1da177e4 | 3023 | |
c0eae66e BH |
3024 | p = xdr_inline_decode(xdr, 4); |
3025 | if (unlikely(!p)) | |
3026 | goto out_overflow; | |
cccddf4f | 3027 | *len = be32_to_cpup(p); |
c0eae66e BH |
3028 | p = xdr_inline_decode(xdr, *len); |
3029 | if (unlikely(!p)) | |
3030 | goto out_overflow; | |
1da177e4 LT |
3031 | *string = (char *)p; |
3032 | return 0; | |
c0eae66e BH |
3033 | out_overflow: |
3034 | print_overflow_msg(__func__, xdr); | |
3035 | return -EIO; | |
1da177e4 LT |
3036 | } |
3037 | ||
3038 | static int decode_compound_hdr(struct xdr_stream *xdr, struct compound_hdr *hdr) | |
3039 | { | |
8687b63a | 3040 | __be32 *p; |
1da177e4 | 3041 | |
c0eae66e BH |
3042 | p = xdr_inline_decode(xdr, 8); |
3043 | if (unlikely(!p)) | |
3044 | goto out_overflow; | |
6f723f77 | 3045 | hdr->status = be32_to_cpup(p++); |
cccddf4f | 3046 | hdr->taglen = be32_to_cpup(p); |
6c0195a4 | 3047 | |
c0eae66e BH |
3048 | p = xdr_inline_decode(xdr, hdr->taglen + 4); |
3049 | if (unlikely(!p)) | |
3050 | goto out_overflow; | |
1da177e4 LT |
3051 | hdr->tag = (char *)p; |
3052 | p += XDR_QUADLEN(hdr->taglen); | |
cccddf4f | 3053 | hdr->nops = be32_to_cpup(p); |
aadf6152 BH |
3054 | if (unlikely(hdr->nops < 1)) |
3055 | return nfs4_stat_to_errno(hdr->status); | |
1da177e4 | 3056 | return 0; |
c0eae66e BH |
3057 | out_overflow: |
3058 | print_overflow_msg(__func__, xdr); | |
3059 | return -EIO; | |
1da177e4 LT |
3060 | } |
3061 | ||
c7848f69 TM |
3062 | static bool __decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected, |
3063 | int *nfs_retval) | |
1da177e4 | 3064 | { |
8687b63a | 3065 | __be32 *p; |
1da177e4 LT |
3066 | uint32_t opnum; |
3067 | int32_t nfserr; | |
3068 | ||
c0eae66e BH |
3069 | p = xdr_inline_decode(xdr, 8); |
3070 | if (unlikely(!p)) | |
3071 | goto out_overflow; | |
6f723f77 | 3072 | opnum = be32_to_cpup(p++); |
c7848f69 TM |
3073 | if (unlikely(opnum != expected)) |
3074 | goto out_bad_operation; | |
cccddf4f | 3075 | nfserr = be32_to_cpup(p); |
c7848f69 TM |
3076 | if (nfserr == NFS_OK) |
3077 | *nfs_retval = 0; | |
3078 | else | |
3079 | *nfs_retval = nfs4_stat_to_errno(nfserr); | |
3080 | return true; | |
3081 | out_bad_operation: | |
3082 | dprintk("nfs: Server returned operation" | |
3083 | " %d but we issued a request for %d\n", | |
3084 | opnum, expected); | |
3085 | *nfs_retval = -EREMOTEIO; | |
3086 | return false; | |
c0eae66e BH |
3087 | out_overflow: |
3088 | print_overflow_msg(__func__, xdr); | |
c7848f69 TM |
3089 | *nfs_retval = -EIO; |
3090 | return false; | |
3091 | } | |
3092 | ||
3093 | static int decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected) | |
3094 | { | |
3095 | int retval; | |
3096 | ||
3097 | __decode_op_hdr(xdr, expected, &retval); | |
3098 | return retval; | |
1da177e4 LT |
3099 | } |
3100 | ||
3101 | /* Dummy routine */ | |
adfa6f98 | 3102 | static int decode_ace(struct xdr_stream *xdr, void *ace, struct nfs_client *clp) |
1da177e4 | 3103 | { |
8687b63a | 3104 | __be32 *p; |
683b57b4 | 3105 | unsigned int strlen; |
1da177e4 LT |
3106 | char *str; |
3107 | ||
c0eae66e BH |
3108 | p = xdr_inline_decode(xdr, 12); |
3109 | if (likely(p)) | |
3110 | return decode_opaque_inline(xdr, &strlen, &str); | |
3111 | print_overflow_msg(__func__, xdr); | |
3112 | return -EIO; | |
1da177e4 LT |
3113 | } |
3114 | ||
3115 | static int decode_attr_bitmap(struct xdr_stream *xdr, uint32_t *bitmap) | |
3116 | { | |
8687b63a AV |
3117 | uint32_t bmlen; |
3118 | __be32 *p; | |
1da177e4 | 3119 | |
c0eae66e BH |
3120 | p = xdr_inline_decode(xdr, 4); |
3121 | if (unlikely(!p)) | |
3122 | goto out_overflow; | |
cccddf4f | 3123 | bmlen = be32_to_cpup(p); |
1da177e4 | 3124 | |
dae100c2 | 3125 | bitmap[0] = bitmap[1] = bitmap[2] = 0; |
c0eae66e BH |
3126 | p = xdr_inline_decode(xdr, (bmlen << 2)); |
3127 | if (unlikely(!p)) | |
3128 | goto out_overflow; | |
1da177e4 | 3129 | if (bmlen > 0) { |
6f723f77 | 3130 | bitmap[0] = be32_to_cpup(p++); |
dae100c2 FI |
3131 | if (bmlen > 1) { |
3132 | bitmap[1] = be32_to_cpup(p++); | |
3133 | if (bmlen > 2) | |
3134 | bitmap[2] = be32_to_cpup(p); | |
3135 | } | |
1da177e4 LT |
3136 | } |
3137 | return 0; | |
c0eae66e BH |
3138 | out_overflow: |
3139 | print_overflow_msg(__func__, xdr); | |
3140 | return -EIO; | |
1da177e4 LT |
3141 | } |
3142 | ||
256e48bb | 3143 | static int decode_attr_length(struct xdr_stream *xdr, uint32_t *attrlen, unsigned int *savep) |
1da177e4 | 3144 | { |
8687b63a | 3145 | __be32 *p; |
1da177e4 | 3146 | |
c0eae66e BH |
3147 | p = xdr_inline_decode(xdr, 4); |
3148 | if (unlikely(!p)) | |
3149 | goto out_overflow; | |
cccddf4f | 3150 | *attrlen = be32_to_cpup(p); |
256e48bb | 3151 | *savep = xdr_stream_pos(xdr); |
1da177e4 | 3152 | return 0; |
c0eae66e BH |
3153 | out_overflow: |
3154 | print_overflow_msg(__func__, xdr); | |
3155 | return -EIO; | |
1da177e4 LT |
3156 | } |
3157 | ||
3158 | static int decode_attr_supported(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *bitmask) | |
3159 | { | |
3160 | if (likely(bitmap[0] & FATTR4_WORD0_SUPPORTED_ATTRS)) { | |
3388bff5 RB |
3161 | int ret; |
3162 | ret = decode_attr_bitmap(xdr, bitmask); | |
3163 | if (unlikely(ret < 0)) | |
3164 | return ret; | |
1da177e4 LT |
3165 | bitmap[0] &= ~FATTR4_WORD0_SUPPORTED_ATTRS; |
3166 | } else | |
dae100c2 FI |
3167 | bitmask[0] = bitmask[1] = bitmask[2] = 0; |
3168 | dprintk("%s: bitmask=%08x:%08x:%08x\n", __func__, | |
3169 | bitmask[0], bitmask[1], bitmask[2]); | |
1da177e4 LT |
3170 | return 0; |
3171 | } | |
3172 | ||
3173 | static int decode_attr_type(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *type) | |
3174 | { | |
8687b63a | 3175 | __be32 *p; |
409924e4 | 3176 | int ret = 0; |
1da177e4 LT |
3177 | |
3178 | *type = 0; | |
3179 | if (unlikely(bitmap[0] & (FATTR4_WORD0_TYPE - 1U))) | |
3180 | return -EIO; | |
3181 | if (likely(bitmap[0] & FATTR4_WORD0_TYPE)) { | |
c0eae66e BH |
3182 | p = xdr_inline_decode(xdr, 4); |
3183 | if (unlikely(!p)) | |
3184 | goto out_overflow; | |
cccddf4f | 3185 | *type = be32_to_cpup(p); |
1da177e4 | 3186 | if (*type < NF4REG || *type > NF4NAMEDATTR) { |
3110ff80 | 3187 | dprintk("%s: bad type %d\n", __func__, *type); |
1da177e4 LT |
3188 | return -EIO; |
3189 | } | |
3190 | bitmap[0] &= ~FATTR4_WORD0_TYPE; | |
409924e4 | 3191 | ret = NFS_ATTR_FATTR_TYPE; |
1da177e4 | 3192 | } |
bca79478 | 3193 | dprintk("%s: type=0%o\n", __func__, nfs_type2fmt[*type]); |
409924e4 | 3194 | return ret; |
c0eae66e BH |
3195 | out_overflow: |
3196 | print_overflow_msg(__func__, xdr); | |
3197 | return -EIO; | |
1da177e4 LT |
3198 | } |
3199 | ||
264e6351 CL |
3200 | static int decode_attr_fh_expire_type(struct xdr_stream *xdr, |
3201 | uint32_t *bitmap, uint32_t *type) | |
3202 | { | |
3203 | __be32 *p; | |
3204 | ||
3205 | *type = 0; | |
3206 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FH_EXPIRE_TYPE - 1U))) | |
3207 | return -EIO; | |
3208 | if (likely(bitmap[0] & FATTR4_WORD0_FH_EXPIRE_TYPE)) { | |
3209 | p = xdr_inline_decode(xdr, 4); | |
3210 | if (unlikely(!p)) | |
3211 | goto out_overflow; | |
3212 | *type = be32_to_cpup(p); | |
3213 | bitmap[0] &= ~FATTR4_WORD0_FH_EXPIRE_TYPE; | |
3214 | } | |
3215 | dprintk("%s: expire type=0x%x\n", __func__, *type); | |
3216 | return 0; | |
3217 | out_overflow: | |
3218 | print_overflow_msg(__func__, xdr); | |
3219 | return -EIO; | |
3220 | } | |
3221 | ||
1da177e4 LT |
3222 | static int decode_attr_change(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *change) |
3223 | { | |
8687b63a | 3224 | __be32 *p; |
409924e4 | 3225 | int ret = 0; |
1da177e4 LT |
3226 | |
3227 | *change = 0; | |
3228 | if (unlikely(bitmap[0] & (FATTR4_WORD0_CHANGE - 1U))) | |
3229 | return -EIO; | |
3230 | if (likely(bitmap[0] & FATTR4_WORD0_CHANGE)) { | |
c0eae66e BH |
3231 | p = xdr_inline_decode(xdr, 8); |
3232 | if (unlikely(!p)) | |
3233 | goto out_overflow; | |
cccddf4f | 3234 | xdr_decode_hyper(p, change); |
1da177e4 | 3235 | bitmap[0] &= ~FATTR4_WORD0_CHANGE; |
409924e4 | 3236 | ret = NFS_ATTR_FATTR_CHANGE; |
1da177e4 | 3237 | } |
3110ff80 | 3238 | dprintk("%s: change attribute=%Lu\n", __func__, |
1da177e4 | 3239 | (unsigned long long)*change); |
409924e4 | 3240 | return ret; |
c0eae66e BH |
3241 | out_overflow: |
3242 | print_overflow_msg(__func__, xdr); | |
3243 | return -EIO; | |
1da177e4 LT |
3244 | } |
3245 | ||
3246 | static int decode_attr_size(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *size) | |
3247 | { | |
8687b63a | 3248 | __be32 *p; |
409924e4 | 3249 | int ret = 0; |
1da177e4 LT |
3250 | |
3251 | *size = 0; | |
3252 | if (unlikely(bitmap[0] & (FATTR4_WORD0_SIZE - 1U))) | |
3253 | return -EIO; | |
3254 | if (likely(bitmap[0] & FATTR4_WORD0_SIZE)) { | |
c0eae66e BH |
3255 | p = xdr_inline_decode(xdr, 8); |
3256 | if (unlikely(!p)) | |
3257 | goto out_overflow; | |
cccddf4f | 3258 | xdr_decode_hyper(p, size); |
1da177e4 | 3259 | bitmap[0] &= ~FATTR4_WORD0_SIZE; |
409924e4 | 3260 | ret = NFS_ATTR_FATTR_SIZE; |
1da177e4 | 3261 | } |
3110ff80 | 3262 | dprintk("%s: file size=%Lu\n", __func__, (unsigned long long)*size); |
409924e4 | 3263 | return ret; |
c0eae66e BH |
3264 | out_overflow: |
3265 | print_overflow_msg(__func__, xdr); | |
3266 | return -EIO; | |
1da177e4 LT |
3267 | } |
3268 | ||
3269 | static int decode_attr_link_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) | |
3270 | { | |
8687b63a | 3271 | __be32 *p; |
1da177e4 LT |
3272 | |
3273 | *res = 0; | |
3274 | if (unlikely(bitmap[0] & (FATTR4_WORD0_LINK_SUPPORT - 1U))) | |
3275 | return -EIO; | |
3276 | if (likely(bitmap[0] & FATTR4_WORD0_LINK_SUPPORT)) { | |
c0eae66e BH |
3277 | p = xdr_inline_decode(xdr, 4); |
3278 | if (unlikely(!p)) | |
3279 | goto out_overflow; | |
cccddf4f | 3280 | *res = be32_to_cpup(p); |
1da177e4 LT |
3281 | bitmap[0] &= ~FATTR4_WORD0_LINK_SUPPORT; |
3282 | } | |
3110ff80 | 3283 | dprintk("%s: link support=%s\n", __func__, *res == 0 ? "false" : "true"); |
1da177e4 | 3284 | return 0; |
c0eae66e BH |
3285 | out_overflow: |
3286 | print_overflow_msg(__func__, xdr); | |
3287 | return -EIO; | |
1da177e4 LT |
3288 | } |
3289 | ||
3290 | static int decode_attr_symlink_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) | |
3291 | { | |
8687b63a | 3292 | __be32 *p; |
1da177e4 LT |
3293 | |
3294 | *res = 0; | |
3295 | if (unlikely(bitmap[0] & (FATTR4_WORD0_SYMLINK_SUPPORT - 1U))) | |
3296 | return -EIO; | |
3297 | if (likely(bitmap[0] & FATTR4_WORD0_SYMLINK_SUPPORT)) { | |
c0eae66e BH |
3298 | p = xdr_inline_decode(xdr, 4); |
3299 | if (unlikely(!p)) | |
3300 | goto out_overflow; | |
cccddf4f | 3301 | *res = be32_to_cpup(p); |
1da177e4 LT |
3302 | bitmap[0] &= ~FATTR4_WORD0_SYMLINK_SUPPORT; |
3303 | } | |
3110ff80 | 3304 | dprintk("%s: symlink support=%s\n", __func__, *res == 0 ? "false" : "true"); |
1da177e4 | 3305 | return 0; |
c0eae66e BH |
3306 | out_overflow: |
3307 | print_overflow_msg(__func__, xdr); | |
3308 | return -EIO; | |
1da177e4 LT |
3309 | } |
3310 | ||
8b4bdcf8 | 3311 | static int decode_attr_fsid(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs_fsid *fsid) |
1da177e4 | 3312 | { |
8687b63a | 3313 | __be32 *p; |
409924e4 | 3314 | int ret = 0; |
1da177e4 LT |
3315 | |
3316 | fsid->major = 0; | |
3317 | fsid->minor = 0; | |
3318 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FSID - 1U))) | |
3319 | return -EIO; | |
3320 | if (likely(bitmap[0] & FATTR4_WORD0_FSID)) { | |
c0eae66e BH |
3321 | p = xdr_inline_decode(xdr, 16); |
3322 | if (unlikely(!p)) | |
3323 | goto out_overflow; | |
3ceb4dbb | 3324 | p = xdr_decode_hyper(p, &fsid->major); |
cccddf4f | 3325 | xdr_decode_hyper(p, &fsid->minor); |
1da177e4 | 3326 | bitmap[0] &= ~FATTR4_WORD0_FSID; |
409924e4 | 3327 | ret = NFS_ATTR_FATTR_FSID; |
1da177e4 | 3328 | } |
3110ff80 | 3329 | dprintk("%s: fsid=(0x%Lx/0x%Lx)\n", __func__, |
1da177e4 LT |
3330 | (unsigned long long)fsid->major, |
3331 | (unsigned long long)fsid->minor); | |
409924e4 | 3332 | return ret; |
c0eae66e BH |
3333 | out_overflow: |
3334 | print_overflow_msg(__func__, xdr); | |
3335 | return -EIO; | |
1da177e4 LT |
3336 | } |
3337 | ||
3338 | static int decode_attr_lease_time(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) | |
3339 | { | |
8687b63a | 3340 | __be32 *p; |
1da177e4 LT |
3341 | |
3342 | *res = 60; | |
3343 | if (unlikely(bitmap[0] & (FATTR4_WORD0_LEASE_TIME - 1U))) | |
3344 | return -EIO; | |
3345 | if (likely(bitmap[0] & FATTR4_WORD0_LEASE_TIME)) { | |
c0eae66e BH |
3346 | p = xdr_inline_decode(xdr, 4); |
3347 | if (unlikely(!p)) | |
3348 | goto out_overflow; | |
cccddf4f | 3349 | *res = be32_to_cpup(p); |
1da177e4 LT |
3350 | bitmap[0] &= ~FATTR4_WORD0_LEASE_TIME; |
3351 | } | |
3110ff80 | 3352 | dprintk("%s: file size=%u\n", __func__, (unsigned int)*res); |
1da177e4 | 3353 | return 0; |
c0eae66e BH |
3354 | out_overflow: |
3355 | print_overflow_msg(__func__, xdr); | |
3356 | return -EIO; | |
1da177e4 LT |
3357 | } |
3358 | ||
ee7b75fc | 3359 | static int decode_attr_error(struct xdr_stream *xdr, uint32_t *bitmap, int32_t *res) |
ae42c70a BS |
3360 | { |
3361 | __be32 *p; | |
3362 | ||
3363 | if (unlikely(bitmap[0] & (FATTR4_WORD0_RDATTR_ERROR - 1U))) | |
3364 | return -EIO; | |
3365 | if (likely(bitmap[0] & FATTR4_WORD0_RDATTR_ERROR)) { | |
3366 | p = xdr_inline_decode(xdr, 4); | |
3367 | if (unlikely(!p)) | |
3368 | goto out_overflow; | |
3369 | bitmap[0] &= ~FATTR4_WORD0_RDATTR_ERROR; | |
ee7b75fc | 3370 | *res = -be32_to_cpup(p); |
ae42c70a BS |
3371 | } |
3372 | return 0; | |
3373 | out_overflow: | |
3374 | print_overflow_msg(__func__, xdr); | |
3375 | return -EIO; | |
3376 | } | |
3377 | ||
3378 | static int decode_attr_filehandle(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs_fh *fh) | |
3379 | { | |
3380 | __be32 *p; | |
3381 | int len; | |
3382 | ||
7ad07353 TM |
3383 | if (fh != NULL) |
3384 | memset(fh, 0, sizeof(*fh)); | |
ae42c70a BS |
3385 | |
3386 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILEHANDLE - 1U))) | |
3387 | return -EIO; | |
3388 | if (likely(bitmap[0] & FATTR4_WORD0_FILEHANDLE)) { | |
3389 | p = xdr_inline_decode(xdr, 4); | |
3390 | if (unlikely(!p)) | |
3391 | goto out_overflow; | |
3392 | len = be32_to_cpup(p); | |
3393 | if (len > NFS4_FHSIZE) | |
3394 | return -EIO; | |
ae42c70a BS |
3395 | p = xdr_inline_decode(xdr, len); |
3396 | if (unlikely(!p)) | |
3397 | goto out_overflow; | |
7ad07353 TM |
3398 | if (fh != NULL) { |
3399 | memcpy(fh->data, p, len); | |
3400 | fh->size = len; | |
3401 | } | |
ae42c70a BS |
3402 | bitmap[0] &= ~FATTR4_WORD0_FILEHANDLE; |
3403 | } | |
3404 | return 0; | |
3405 | out_overflow: | |
3406 | print_overflow_msg(__func__, xdr); | |
3407 | return -EIO; | |
3408 | } | |
3409 | ||
1da177e4 LT |
3410 | static int decode_attr_aclsupport(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
3411 | { | |
8687b63a | 3412 | __be32 *p; |
1da177e4 | 3413 | |
a1800aca | 3414 | *res = 0; |
1da177e4 LT |
3415 | if (unlikely(bitmap[0] & (FATTR4_WORD0_ACLSUPPORT - 1U))) |
3416 | return -EIO; | |
3417 | if (likely(bitmap[0] & FATTR4_WORD0_ACLSUPPORT)) { | |
c0eae66e BH |
3418 | p = xdr_inline_decode(xdr, 4); |
3419 | if (unlikely(!p)) | |
3420 | goto out_overflow; | |
cccddf4f | 3421 | *res = be32_to_cpup(p); |
1da177e4 LT |
3422 | bitmap[0] &= ~FATTR4_WORD0_ACLSUPPORT; |
3423 | } | |
3110ff80 | 3424 | dprintk("%s: ACLs supported=%u\n", __func__, (unsigned int)*res); |
1da177e4 | 3425 | return 0; |
c0eae66e BH |
3426 | out_overflow: |
3427 | print_overflow_msg(__func__, xdr); | |
3428 | return -EIO; | |
1da177e4 LT |
3429 | } |
3430 | ||
3431 | static int decode_attr_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid) | |
3432 | { | |
8687b63a | 3433 | __be32 *p; |
409924e4 | 3434 | int ret = 0; |
1da177e4 LT |
3435 | |
3436 | *fileid = 0; | |
3437 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILEID - 1U))) | |
3438 | return -EIO; | |
3439 | if (likely(bitmap[0] & FATTR4_WORD0_FILEID)) { | |
c0eae66e BH |
3440 | p = xdr_inline_decode(xdr, 8); |
3441 | if (unlikely(!p)) | |
3442 | goto out_overflow; | |
cccddf4f | 3443 | xdr_decode_hyper(p, fileid); |
1da177e4 | 3444 | bitmap[0] &= ~FATTR4_WORD0_FILEID; |
409924e4 | 3445 | ret = NFS_ATTR_FATTR_FILEID; |
1da177e4 | 3446 | } |
3110ff80 | 3447 | dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid); |
409924e4 | 3448 | return ret; |
c0eae66e BH |
3449 | out_overflow: |
3450 | print_overflow_msg(__func__, xdr); | |
3451 | return -EIO; | |
1da177e4 LT |
3452 | } |
3453 | ||
99baf625 MN |
3454 | static int decode_attr_mounted_on_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid) |
3455 | { | |
8687b63a | 3456 | __be32 *p; |
409924e4 | 3457 | int ret = 0; |
99baf625 MN |
3458 | |
3459 | *fileid = 0; | |
3460 | if (unlikely(bitmap[1] & (FATTR4_WORD1_MOUNTED_ON_FILEID - 1U))) | |
3461 | return -EIO; | |
3462 | if (likely(bitmap[1] & FATTR4_WORD1_MOUNTED_ON_FILEID)) { | |
c0eae66e BH |
3463 | p = xdr_inline_decode(xdr, 8); |
3464 | if (unlikely(!p)) | |
3465 | goto out_overflow; | |
cccddf4f | 3466 | xdr_decode_hyper(p, fileid); |
99baf625 | 3467 | bitmap[1] &= ~FATTR4_WORD1_MOUNTED_ON_FILEID; |
28331a46 | 3468 | ret = NFS_ATTR_FATTR_MOUNTED_ON_FILEID; |
99baf625 | 3469 | } |
3110ff80 | 3470 | dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid); |
409924e4 | 3471 | return ret; |
c0eae66e BH |
3472 | out_overflow: |
3473 | print_overflow_msg(__func__, xdr); | |
3474 | return -EIO; | |
99baf625 MN |
3475 | } |
3476 | ||
1da177e4 LT |
3477 | static int decode_attr_files_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
3478 | { | |
8687b63a | 3479 | __be32 *p; |
1da177e4 LT |
3480 | int status = 0; |
3481 | ||
3482 | *res = 0; | |
3483 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_AVAIL - 1U))) | |
3484 | return -EIO; | |
3485 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_AVAIL)) { | |
c0eae66e BH |
3486 | p = xdr_inline_decode(xdr, 8); |
3487 | if (unlikely(!p)) | |
3488 | goto out_overflow; | |
cccddf4f | 3489 | xdr_decode_hyper(p, res); |
1da177e4 LT |
3490 | bitmap[0] &= ~FATTR4_WORD0_FILES_AVAIL; |
3491 | } | |
3110ff80 | 3492 | dprintk("%s: files avail=%Lu\n", __func__, (unsigned long long)*res); |
1da177e4 | 3493 | return status; |
c0eae66e BH |
3494 | out_overflow: |
3495 | print_overflow_msg(__func__, xdr); | |
3496 | return -EIO; | |
1da177e4 LT |
3497 | } |
3498 | ||
3499 | static int decode_attr_files_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) | |
3500 | { | |
8687b63a | 3501 | __be32 *p; |
1da177e4 LT |
3502 | int status = 0; |
3503 | ||
3504 | *res = 0; | |
3505 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_FREE - 1U))) | |
3506 | return -EIO; | |
3507 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_FREE)) { | |
c0eae66e BH |
3508 | p = xdr_inline_decode(xdr, 8); |
3509 | if (unlikely(!p)) | |
3510 | goto out_overflow; | |
cccddf4f | 3511 | xdr_decode_hyper(p, res); |
1da177e4 LT |
3512 | bitmap[0] &= ~FATTR4_WORD0_FILES_FREE; |
3513 | } | |
3110ff80 | 3514 | dprintk("%s: files free=%Lu\n", __func__, (unsigned long long)*res); |
1da177e4 | 3515 | return status; |
c0eae66e BH |
3516 | out_overflow: |
3517 | print_overflow_msg(__func__, xdr); | |
3518 | return -EIO; | |
1da177e4 LT |
3519 | } |
3520 | ||
3521 | static int decode_attr_files_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) | |
3522 | { | |
8687b63a | 3523 | __be32 *p; |
1da177e4 LT |
3524 | int status = 0; |
3525 | ||
3526 | *res = 0; | |
3527 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_TOTAL - 1U))) | |
3528 | return -EIO; | |
3529 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_TOTAL)) { | |
c0eae66e BH |
3530 | p = xdr_inline_decode(xdr, 8); |
3531 | if (unlikely(!p)) | |
3532 | goto out_overflow; | |
cccddf4f | 3533 | xdr_decode_hyper(p, res); |
1da177e4 LT |
3534 | bitmap[0] &= ~FATTR4_WORD0_FILES_TOTAL; |
3535 | } | |
3110ff80 | 3536 | dprintk("%s: files total=%Lu\n", __func__, (unsigned long long)*res); |
1da177e4 | 3537 | return status; |
c0eae66e BH |
3538 | out_overflow: |
3539 | print_overflow_msg(__func__, xdr); | |
3540 | return -EIO; | |
1da177e4 LT |
3541 | } |
3542 | ||
7aaa0b3b MN |
3543 | static int decode_pathname(struct xdr_stream *xdr, struct nfs4_pathname *path) |
3544 | { | |
464ad6b1 | 3545 | u32 n; |
8687b63a | 3546 | __be32 *p; |
7aaa0b3b MN |
3547 | int status = 0; |
3548 | ||
c0eae66e BH |
3549 | p = xdr_inline_decode(xdr, 4); |
3550 | if (unlikely(!p)) | |
3551 | goto out_overflow; | |
cccddf4f | 3552 | n = be32_to_cpup(p); |
33a43f28 AA |
3553 | if (n == 0) |
3554 | goto root_path; | |
02a2976c | 3555 | dprintk("pathname4: "); |
809b426c TM |
3556 | if (n > NFS4_PATHNAME_MAXCOMPONENTS) { |
3557 | dprintk("cannot parse %d components in path\n", n); | |
3558 | goto out_eio; | |
3559 | } | |
3560 | for (path->ncomponents = 0; path->ncomponents < n; path->ncomponents++) { | |
7aaa0b3b MN |
3561 | struct nfs4_string *component = &path->components[path->ncomponents]; |
3562 | status = decode_opaque_inline(xdr, &component->len, &component->data); | |
3563 | if (unlikely(status != 0)) | |
3564 | goto out_eio; | |
95a13f7b | 3565 | ifdebug (XDR) |
02a2976c CL |
3566 | pr_cont("%s%.*s ", |
3567 | (path->ncomponents != n ? "/ " : ""), | |
3568 | component->len, component->data); | |
7aaa0b3b MN |
3569 | } |
3570 | out: | |
7aaa0b3b | 3571 | return status; |
33a43f28 AA |
3572 | root_path: |
3573 | /* a root pathname is sent as a zero component4 */ | |
3574 | path->ncomponents = 1; | |
3575 | path->components[0].len=0; | |
3576 | path->components[0].data=NULL; | |
02a2976c | 3577 | dprintk("pathname4: /\n"); |
33a43f28 | 3578 | goto out; |
7aaa0b3b MN |
3579 | out_eio: |
3580 | dprintk(" status %d", status); | |
3581 | status = -EIO; | |
3582 | goto out; | |
c0eae66e BH |
3583 | out_overflow: |
3584 | print_overflow_msg(__func__, xdr); | |
3585 | return -EIO; | |
7aaa0b3b MN |
3586 | } |
3587 | ||
3588 | static int decode_attr_fs_locations(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs4_fs_locations *res) | |
683b57b4 TM |
3589 | { |
3590 | int n; | |
8687b63a | 3591 | __be32 *p; |
683b57b4 TM |
3592 | int status = -EIO; |
3593 | ||
3594 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FS_LOCATIONS -1U))) | |
3595 | goto out; | |
3596 | status = 0; | |
3597 | if (unlikely(!(bitmap[0] & FATTR4_WORD0_FS_LOCATIONS))) | |
3598 | goto out; | |
8b7e3f49 TM |
3599 | status = -EIO; |
3600 | /* Ignore borken servers that return unrequested attrs */ | |
3601 | if (unlikely(res == NULL)) | |
3602 | goto out; | |
02a2976c | 3603 | dprintk("%s: fsroot:\n", __func__); |
7aaa0b3b | 3604 | status = decode_pathname(xdr, &res->fs_path); |
683b57b4 TM |
3605 | if (unlikely(status != 0)) |
3606 | goto out; | |
c0eae66e BH |
3607 | p = xdr_inline_decode(xdr, 4); |
3608 | if (unlikely(!p)) | |
3609 | goto out_overflow; | |
cccddf4f | 3610 | n = be32_to_cpup(p); |
683b57b4 TM |
3611 | if (n <= 0) |
3612 | goto out_eio; | |
809b426c | 3613 | for (res->nlocations = 0; res->nlocations < n; res->nlocations++) { |
464ad6b1 | 3614 | u32 m; |
809b426c | 3615 | struct nfs4_fs_location *loc; |
683b57b4 | 3616 | |
809b426c TM |
3617 | if (res->nlocations == NFS4_FS_LOCATIONS_MAXENTRIES) |
3618 | break; | |
3619 | loc = &res->locations[res->nlocations]; | |
c0eae66e BH |
3620 | p = xdr_inline_decode(xdr, 4); |
3621 | if (unlikely(!p)) | |
3622 | goto out_overflow; | |
cccddf4f | 3623 | m = be32_to_cpup(p); |
7aaa0b3b | 3624 | |
02a2976c | 3625 | dprintk("%s: servers:\n", __func__); |
809b426c TM |
3626 | for (loc->nservers = 0; loc->nservers < m; loc->nservers++) { |
3627 | struct nfs4_string *server; | |
3628 | ||
3629 | if (loc->nservers == NFS4_FS_LOCATION_MAXSERVERS) { | |
464ad6b1 CL |
3630 | unsigned int i; |
3631 | dprintk("%s: using first %u of %u servers " | |
3632 | "returned for location %u\n", | |
3110ff80 | 3633 | __func__, |
464ad6b1 CL |
3634 | NFS4_FS_LOCATION_MAXSERVERS, |
3635 | m, res->nlocations); | |
7aaa0b3b | 3636 | for (i = loc->nservers; i < m; i++) { |
2e42c3e2 | 3637 | unsigned int len; |
7aaa0b3b MN |
3638 | char *data; |
3639 | status = decode_opaque_inline(xdr, &len, &data); | |
3640 | if (unlikely(status != 0)) | |
3641 | goto out_eio; | |
3642 | } | |
809b426c | 3643 | break; |
7aaa0b3b | 3644 | } |
809b426c TM |
3645 | server = &loc->servers[loc->nservers]; |
3646 | status = decode_opaque_inline(xdr, &server->len, &server->data); | |
3647 | if (unlikely(status != 0)) | |
3648 | goto out_eio; | |
3649 | dprintk("%s ", server->data); | |
7aaa0b3b MN |
3650 | } |
3651 | status = decode_pathname(xdr, &loc->rootpath); | |
683b57b4 TM |
3652 | if (unlikely(status != 0)) |
3653 | goto out_eio; | |
683b57b4 | 3654 | } |
409924e4 | 3655 | if (res->nlocations != 0) |
81934ddb | 3656 | status = NFS_ATTR_FATTR_V4_LOCATIONS; |
683b57b4 | 3657 | out: |
3110ff80 | 3658 | dprintk("%s: fs_locations done, error = %d\n", __func__, status); |
683b57b4 | 3659 | return status; |
c0eae66e BH |
3660 | out_overflow: |
3661 | print_overflow_msg(__func__, xdr); | |
683b57b4 TM |
3662 | out_eio: |
3663 | status = -EIO; | |
3664 | goto out; | |
3665 | } | |
3666 | ||
1da177e4 LT |
3667 | static int decode_attr_maxfilesize(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
3668 | { | |
8687b63a | 3669 | __be32 *p; |
1da177e4 LT |
3670 | int status = 0; |
3671 | ||
3672 | *res = 0; | |
3673 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXFILESIZE - 1U))) | |
3674 | return -EIO; | |
3675 | if (likely(bitmap[0] & FATTR4_WORD0_MAXFILESIZE)) { | |
c0eae66e BH |
3676 | p = xdr_inline_decode(xdr, 8); |
3677 | if (unlikely(!p)) | |
3678 | goto out_overflow; | |
cccddf4f | 3679 | xdr_decode_hyper(p, res); |
1da177e4 LT |
3680 | bitmap[0] &= ~FATTR4_WORD0_MAXFILESIZE; |
3681 | } | |
3110ff80 | 3682 | dprintk("%s: maxfilesize=%Lu\n", __func__, (unsigned long long)*res); |
1da177e4 | 3683 | return status; |
c0eae66e BH |
3684 | out_overflow: |
3685 | print_overflow_msg(__func__, xdr); | |
3686 | return -EIO; | |
1da177e4 LT |
3687 | } |
3688 | ||
3689 | static int decode_attr_maxlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxlink) | |
3690 | { | |
8687b63a | 3691 | __be32 *p; |
1da177e4 LT |
3692 | int status = 0; |
3693 | ||
3694 | *maxlink = 1; | |
3695 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXLINK - 1U))) | |
3696 | return -EIO; | |
3697 | if (likely(bitmap[0] & FATTR4_WORD0_MAXLINK)) { | |
c0eae66e BH |
3698 | p = xdr_inline_decode(xdr, 4); |
3699 | if (unlikely(!p)) | |
3700 | goto out_overflow; | |
cccddf4f | 3701 | *maxlink = be32_to_cpup(p); |
1da177e4 LT |
3702 | bitmap[0] &= ~FATTR4_WORD0_MAXLINK; |
3703 | } | |
3110ff80 | 3704 | dprintk("%s: maxlink=%u\n", __func__, *maxlink); |
1da177e4 | 3705 | return status; |
c0eae66e BH |
3706 | out_overflow: |
3707 | print_overflow_msg(__func__, xdr); | |
3708 | return -EIO; | |
1da177e4 LT |
3709 | } |
3710 | ||
3711 | static int decode_attr_maxname(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxname) | |
3712 | { | |
8687b63a | 3713 | __be32 *p; |
1da177e4 LT |
3714 | int status = 0; |
3715 | ||
3716 | *maxname = 1024; | |
3717 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXNAME - 1U))) | |
3718 | return -EIO; | |
3719 | if (likely(bitmap[0] & FATTR4_WORD0_MAXNAME)) { | |
c0eae66e BH |
3720 | p = xdr_inline_decode(xdr, 4); |
3721 | if (unlikely(!p)) | |
3722 | goto out_overflow; | |
cccddf4f | 3723 | *maxname = be32_to_cpup(p); |
1da177e4 LT |
3724 | bitmap[0] &= ~FATTR4_WORD0_MAXNAME; |
3725 | } | |
3110ff80 | 3726 | dprintk("%s: maxname=%u\n", __func__, *maxname); |
1da177e4 | 3727 | return status; |
c0eae66e BH |
3728 | out_overflow: |
3729 | print_overflow_msg(__func__, xdr); | |
3730 | return -EIO; | |
1da177e4 LT |
3731 | } |
3732 | ||
3733 | static int decode_attr_maxread(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) | |
3734 | { | |
8687b63a | 3735 | __be32 *p; |
1da177e4 LT |
3736 | int status = 0; |
3737 | ||
3738 | *res = 1024; | |
3739 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXREAD - 1U))) | |
3740 | return -EIO; | |
3741 | if (likely(bitmap[0] & FATTR4_WORD0_MAXREAD)) { | |
3742 | uint64_t maxread; | |
c0eae66e BH |
3743 | p = xdr_inline_decode(xdr, 8); |
3744 | if (unlikely(!p)) | |
3745 | goto out_overflow; | |
cccddf4f | 3746 | xdr_decode_hyper(p, &maxread); |
1da177e4 LT |
3747 | if (maxread > 0x7FFFFFFF) |
3748 | maxread = 0x7FFFFFFF; | |
3749 | *res = (uint32_t)maxread; | |
3750 | bitmap[0] &= ~FATTR4_WORD0_MAXREAD; | |
3751 | } | |
3110ff80 | 3752 | dprintk("%s: maxread=%lu\n", __func__, (unsigned long)*res); |
1da177e4 | 3753 | return status; |
c0eae66e BH |
3754 | out_overflow: |
3755 | print_overflow_msg(__func__, xdr); | |
3756 | return -EIO; | |
1da177e4 LT |
3757 | } |
3758 | ||
3759 | static int decode_attr_maxwrite(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) | |
3760 | { | |
8687b63a | 3761 | __be32 *p; |
1da177e4 LT |
3762 | int status = 0; |
3763 | ||
3764 | *res = 1024; | |
3765 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXWRITE - 1U))) | |
3766 | return -EIO; | |
3767 | if (likely(bitmap[0] & FATTR4_WORD0_MAXWRITE)) { | |
3768 | uint64_t maxwrite; | |
c0eae66e BH |
3769 | p = xdr_inline_decode(xdr, 8); |
3770 | if (unlikely(!p)) | |
3771 | goto out_overflow; | |
cccddf4f | 3772 | xdr_decode_hyper(p, &maxwrite); |
1da177e4 LT |
3773 | if (maxwrite > 0x7FFFFFFF) |
3774 | maxwrite = 0x7FFFFFFF; | |
3775 | *res = (uint32_t)maxwrite; | |
3776 | bitmap[0] &= ~FATTR4_WORD0_MAXWRITE; | |
3777 | } | |
3110ff80 | 3778 | dprintk("%s: maxwrite=%lu\n", __func__, (unsigned long)*res); |
1da177e4 | 3779 | return status; |
c0eae66e BH |
3780 | out_overflow: |
3781 | print_overflow_msg(__func__, xdr); | |
3782 | return -EIO; | |
1da177e4 LT |
3783 | } |
3784 | ||
bca79478 | 3785 | static int decode_attr_mode(struct xdr_stream *xdr, uint32_t *bitmap, umode_t *mode) |
1da177e4 | 3786 | { |
bca79478 | 3787 | uint32_t tmp; |
8687b63a | 3788 | __be32 *p; |
409924e4 | 3789 | int ret = 0; |
1da177e4 LT |
3790 | |
3791 | *mode = 0; | |
3792 | if (unlikely(bitmap[1] & (FATTR4_WORD1_MODE - 1U))) | |
3793 | return -EIO; | |
3794 | if (likely(bitmap[1] & FATTR4_WORD1_MODE)) { | |
c0eae66e BH |
3795 | p = xdr_inline_decode(xdr, 4); |
3796 | if (unlikely(!p)) | |
3797 | goto out_overflow; | |
cccddf4f | 3798 | tmp = be32_to_cpup(p); |
bca79478 | 3799 | *mode = tmp & ~S_IFMT; |
1da177e4 | 3800 | bitmap[1] &= ~FATTR4_WORD1_MODE; |
409924e4 | 3801 | ret = NFS_ATTR_FATTR_MODE; |
1da177e4 | 3802 | } |
3110ff80 | 3803 | dprintk("%s: file mode=0%o\n", __func__, (unsigned int)*mode); |
409924e4 | 3804 | return ret; |
c0eae66e BH |
3805 | out_overflow: |
3806 | print_overflow_msg(__func__, xdr); | |
3807 | return -EIO; | |
1da177e4 LT |
3808 | } |
3809 | ||
3810 | static int decode_attr_nlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *nlink) | |
3811 | { | |
8687b63a | 3812 | __be32 *p; |
409924e4 | 3813 | int ret = 0; |
1da177e4 LT |
3814 | |
3815 | *nlink = 1; | |
3816 | if (unlikely(bitmap[1] & (FATTR4_WORD1_NUMLINKS - 1U))) | |
3817 | return -EIO; | |
3818 | if (likely(bitmap[1] & FATTR4_WORD1_NUMLINKS)) { | |
c0eae66e BH |
3819 | p = xdr_inline_decode(xdr, 4); |
3820 | if (unlikely(!p)) | |
3821 | goto out_overflow; | |
cccddf4f | 3822 | *nlink = be32_to_cpup(p); |
1da177e4 | 3823 | bitmap[1] &= ~FATTR4_WORD1_NUMLINKS; |
409924e4 | 3824 | ret = NFS_ATTR_FATTR_NLINK; |
1da177e4 | 3825 | } |
3110ff80 | 3826 | dprintk("%s: nlink=%u\n", __func__, (unsigned int)*nlink); |
409924e4 | 3827 | return ret; |
c0eae66e BH |
3828 | out_overflow: |
3829 | print_overflow_msg(__func__, xdr); | |
3830 | return -EIO; | |
1da177e4 LT |
3831 | } |
3832 | ||
80e52ace | 3833 | static int decode_attr_owner(struct xdr_stream *xdr, uint32_t *bitmap, |
e5782076 | 3834 | const struct nfs_server *server, kuid_t *uid, |
6926afd1 | 3835 | struct nfs4_string *owner_name) |
1da177e4 | 3836 | { |
8687b63a AV |
3837 | uint32_t len; |
3838 | __be32 *p; | |
409924e4 | 3839 | int ret = 0; |
1da177e4 | 3840 | |
e5782076 | 3841 | *uid = make_kuid(&init_user_ns, -2); |
1da177e4 LT |
3842 | if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER - 1U))) |
3843 | return -EIO; | |
3844 | if (likely(bitmap[1] & FATTR4_WORD1_OWNER)) { | |
c0eae66e BH |
3845 | p = xdr_inline_decode(xdr, 4); |
3846 | if (unlikely(!p)) | |
3847 | goto out_overflow; | |
cccddf4f | 3848 | len = be32_to_cpup(p); |
c0eae66e BH |
3849 | p = xdr_inline_decode(xdr, len); |
3850 | if (unlikely(!p)) | |
3851 | goto out_overflow; | |
6926afd1 TM |
3852 | if (owner_name != NULL) { |
3853 | owner_name->data = kmemdup(p, len, GFP_NOWAIT); | |
3854 | if (owner_name->data != NULL) { | |
3855 | owner_name->len = len; | |
3856 | ret = NFS_ATTR_FATTR_OWNER_NAME; | |
3857 | } | |
80e52ace | 3858 | } else if (len < XDR_MAX_NETOBJ) { |
e4fd72a1 | 3859 | if (nfs_map_name_to_uid(server, (char *)p, len, uid) == 0) |
409924e4 TM |
3860 | ret = NFS_ATTR_FATTR_OWNER; |
3861 | else | |
1da177e4 | 3862 | dprintk("%s: nfs_map_name_to_uid failed!\n", |
3110ff80 | 3863 | __func__); |
1da177e4 | 3864 | } else |
fe82a183 | 3865 | dprintk("%s: name too long (%u)!\n", |
3110ff80 | 3866 | __func__, len); |
1da177e4 LT |
3867 | bitmap[1] &= ~FATTR4_WORD1_OWNER; |
3868 | } | |
e5782076 | 3869 | dprintk("%s: uid=%d\n", __func__, (int)from_kuid(&init_user_ns, *uid)); |
409924e4 | 3870 | return ret; |
c0eae66e BH |
3871 | out_overflow: |
3872 | print_overflow_msg(__func__, xdr); | |
3873 | return -EIO; | |
1da177e4 LT |
3874 | } |
3875 | ||
80e52ace | 3876 | static int decode_attr_group(struct xdr_stream *xdr, uint32_t *bitmap, |
e5782076 | 3877 | const struct nfs_server *server, kgid_t *gid, |
6926afd1 | 3878 | struct nfs4_string *group_name) |
1da177e4 | 3879 | { |
8687b63a AV |
3880 | uint32_t len; |
3881 | __be32 *p; | |
409924e4 | 3882 | int ret = 0; |
1da177e4 | 3883 | |
e5782076 | 3884 | *gid = make_kgid(&init_user_ns, -2); |
1da177e4 LT |
3885 | if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER_GROUP - 1U))) |
3886 | return -EIO; | |
3887 | if (likely(bitmap[1] & FATTR4_WORD1_OWNER_GROUP)) { | |
c0eae66e BH |
3888 | p = xdr_inline_decode(xdr, 4); |
3889 | if (unlikely(!p)) | |
3890 | goto out_overflow; | |
cccddf4f | 3891 | len = be32_to_cpup(p); |
c0eae66e BH |
3892 | p = xdr_inline_decode(xdr, len); |
3893 | if (unlikely(!p)) | |
3894 | goto out_overflow; | |
6926afd1 TM |
3895 | if (group_name != NULL) { |
3896 | group_name->data = kmemdup(p, len, GFP_NOWAIT); | |
3897 | if (group_name->data != NULL) { | |
3898 | group_name->len = len; | |
3899 | ret = NFS_ATTR_FATTR_GROUP_NAME; | |
3900 | } | |
80e52ace | 3901 | } else if (len < XDR_MAX_NETOBJ) { |
e4fd72a1 | 3902 | if (nfs_map_group_to_gid(server, (char *)p, len, gid) == 0) |
409924e4 TM |
3903 | ret = NFS_ATTR_FATTR_GROUP; |
3904 | else | |
1da177e4 | 3905 | dprintk("%s: nfs_map_group_to_gid failed!\n", |
3110ff80 | 3906 | __func__); |
1da177e4 | 3907 | } else |
fe82a183 | 3908 | dprintk("%s: name too long (%u)!\n", |
3110ff80 | 3909 | __func__, len); |
1da177e4 LT |
3910 | bitmap[1] &= ~FATTR4_WORD1_OWNER_GROUP; |
3911 | } | |
e5782076 | 3912 | dprintk("%s: gid=%d\n", __func__, (int)from_kgid(&init_user_ns, *gid)); |
409924e4 | 3913 | return ret; |
c0eae66e BH |
3914 | out_overflow: |
3915 | print_overflow_msg(__func__, xdr); | |
3916 | return -EIO; | |
1da177e4 LT |
3917 | } |
3918 | ||
3919 | static int decode_attr_rdev(struct xdr_stream *xdr, uint32_t *bitmap, dev_t *rdev) | |
3920 | { | |
8687b63a AV |
3921 | uint32_t major = 0, minor = 0; |
3922 | __be32 *p; | |
409924e4 | 3923 | int ret = 0; |
1da177e4 LT |
3924 | |
3925 | *rdev = MKDEV(0,0); | |
3926 | if (unlikely(bitmap[1] & (FATTR4_WORD1_RAWDEV - 1U))) | |
3927 | return -EIO; | |
3928 | if (likely(bitmap[1] & FATTR4_WORD1_RAWDEV)) { | |
3929 | dev_t tmp; | |
3930 | ||
c0eae66e BH |
3931 | p = xdr_inline_decode(xdr, 8); |
3932 | if (unlikely(!p)) | |
3933 | goto out_overflow; | |
6f723f77 | 3934 | major = be32_to_cpup(p++); |
cccddf4f | 3935 | minor = be32_to_cpup(p); |
1da177e4 LT |
3936 | tmp = MKDEV(major, minor); |
3937 | if (MAJOR(tmp) == major && MINOR(tmp) == minor) | |
3938 | *rdev = tmp; | |
3939 | bitmap[1] &= ~ FATTR4_WORD1_RAWDEV; | |
409924e4 | 3940 | ret = NFS_ATTR_FATTR_RDEV; |
1da177e4 | 3941 | } |
3110ff80 | 3942 | dprintk("%s: rdev=(0x%x:0x%x)\n", __func__, major, minor); |
409924e4 | 3943 | return ret; |
c0eae66e BH |
3944 | out_overflow: |
3945 | print_overflow_msg(__func__, xdr); | |
3946 | return -EIO; | |
1da177e4 LT |
3947 | } |
3948 | ||
3949 | static int decode_attr_space_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) | |
3950 | { | |
8687b63a | 3951 | __be32 *p; |
1da177e4 LT |
3952 | int status = 0; |
3953 | ||
3954 | *res = 0; | |
3955 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_AVAIL - 1U))) | |
3956 | return -EIO; | |
3957 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_AVAIL)) { | |
c0eae66e BH |
3958 | p = xdr_inline_decode(xdr, 8); |
3959 | if (unlikely(!p)) | |
3960 | goto out_overflow; | |
cccddf4f | 3961 | xdr_decode_hyper(p, res); |
1da177e4 LT |
3962 | bitmap[1] &= ~FATTR4_WORD1_SPACE_AVAIL; |
3963 | } | |
3110ff80 | 3964 | dprintk("%s: space avail=%Lu\n", __func__, (unsigned long long)*res); |
1da177e4 | 3965 | return status; |
c0eae66e BH |
3966 | out_overflow: |
3967 | print_overflow_msg(__func__, xdr); | |
3968 | return -EIO; | |
1da177e4 LT |
3969 | } |
3970 | ||
3971 | static int decode_attr_space_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) | |
3972 | { | |
8687b63a | 3973 | __be32 *p; |
1da177e4 LT |
3974 | int status = 0; |
3975 | ||
3976 | *res = 0; | |
3977 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_FREE - 1U))) | |
3978 | return -EIO; | |
3979 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_FREE)) { | |
c0eae66e BH |
3980 | p = xdr_inline_decode(xdr, 8); |
3981 | if (unlikely(!p)) | |
3982 | goto out_overflow; | |
cccddf4f | 3983 | xdr_decode_hyper(p, res); |
1da177e4 LT |
3984 | bitmap[1] &= ~FATTR4_WORD1_SPACE_FREE; |
3985 | } | |
3110ff80 | 3986 | dprintk("%s: space free=%Lu\n", __func__, (unsigned long long)*res); |
1da177e4 | 3987 | return status; |
c0eae66e BH |
3988 | out_overflow: |
3989 | print_overflow_msg(__func__, xdr); | |
3990 | return -EIO; | |
1da177e4 LT |
3991 | } |
3992 | ||
3993 | static int decode_attr_space_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) | |
3994 | { | |
8687b63a | 3995 | __be32 *p; |
1da177e4 LT |
3996 | int status = 0; |
3997 | ||
3998 | *res = 0; | |
3999 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_TOTAL - 1U))) | |
4000 | return -EIO; | |
4001 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_TOTAL)) { | |
c0eae66e BH |
4002 | p = xdr_inline_decode(xdr, 8); |
4003 | if (unlikely(!p)) | |
4004 | goto out_overflow; | |
cccddf4f | 4005 | xdr_decode_hyper(p, res); |
1da177e4 LT |
4006 | bitmap[1] &= ~FATTR4_WORD1_SPACE_TOTAL; |
4007 | } | |
3110ff80 | 4008 | dprintk("%s: space total=%Lu\n", __func__, (unsigned long long)*res); |
1da177e4 | 4009 | return status; |
c0eae66e BH |
4010 | out_overflow: |
4011 | print_overflow_msg(__func__, xdr); | |
4012 | return -EIO; | |
1da177e4 LT |
4013 | } |
4014 | ||
4015 | static int decode_attr_space_used(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *used) | |
4016 | { | |
8687b63a | 4017 | __be32 *p; |
409924e4 | 4018 | int ret = 0; |
1da177e4 LT |
4019 | |
4020 | *used = 0; | |
4021 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_USED - 1U))) | |
4022 | return -EIO; | |
4023 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_USED)) { | |
c0eae66e BH |
4024 | p = xdr_inline_decode(xdr, 8); |
4025 | if (unlikely(!p)) | |
4026 | goto out_overflow; | |
cccddf4f | 4027 | xdr_decode_hyper(p, used); |
1da177e4 | 4028 | bitmap[1] &= ~FATTR4_WORD1_SPACE_USED; |
409924e4 | 4029 | ret = NFS_ATTR_FATTR_SPACE_USED; |
1da177e4 | 4030 | } |
3110ff80 | 4031 | dprintk("%s: space used=%Lu\n", __func__, |
1da177e4 | 4032 | (unsigned long long)*used); |
409924e4 | 4033 | return ret; |
c0eae66e BH |
4034 | out_overflow: |
4035 | print_overflow_msg(__func__, xdr); | |
4036 | return -EIO; | |
1da177e4 LT |
4037 | } |
4038 | ||
4039 | static int decode_attr_time(struct xdr_stream *xdr, struct timespec *time) | |
4040 | { | |
8687b63a | 4041 | __be32 *p; |
1da177e4 LT |
4042 | uint64_t sec; |
4043 | uint32_t nsec; | |
4044 | ||
c0eae66e BH |
4045 | p = xdr_inline_decode(xdr, 12); |
4046 | if (unlikely(!p)) | |
4047 | goto out_overflow; | |
3ceb4dbb | 4048 | p = xdr_decode_hyper(p, &sec); |
cccddf4f | 4049 | nsec = be32_to_cpup(p); |
1da177e4 LT |
4050 | time->tv_sec = (time_t)sec; |
4051 | time->tv_nsec = (long)nsec; | |
4052 | return 0; | |
c0eae66e BH |
4053 | out_overflow: |
4054 | print_overflow_msg(__func__, xdr); | |
4055 | return -EIO; | |
1da177e4 LT |
4056 | } |
4057 | ||
4058 | static int decode_attr_time_access(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time) | |
4059 | { | |
4060 | int status = 0; | |
4061 | ||
4062 | time->tv_sec = 0; | |
4063 | time->tv_nsec = 0; | |
4064 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_ACCESS - 1U))) | |
4065 | return -EIO; | |
4066 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_ACCESS)) { | |
4067 | status = decode_attr_time(xdr, time); | |
409924e4 TM |
4068 | if (status == 0) |
4069 | status = NFS_ATTR_FATTR_ATIME; | |
1da177e4 LT |
4070 | bitmap[1] &= ~FATTR4_WORD1_TIME_ACCESS; |
4071 | } | |
3110ff80 | 4072 | dprintk("%s: atime=%ld\n", __func__, (long)time->tv_sec); |
1da177e4 LT |
4073 | return status; |
4074 | } | |
4075 | ||
4076 | static int decode_attr_time_metadata(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time) | |
4077 | { | |
4078 | int status = 0; | |
4079 | ||
4080 | time->tv_sec = 0; | |
4081 | time->tv_nsec = 0; | |
4082 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_METADATA - 1U))) | |
4083 | return -EIO; | |
4084 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_METADATA)) { | |
4085 | status = decode_attr_time(xdr, time); | |
409924e4 TM |
4086 | if (status == 0) |
4087 | status = NFS_ATTR_FATTR_CTIME; | |
1da177e4 LT |
4088 | bitmap[1] &= ~FATTR4_WORD1_TIME_METADATA; |
4089 | } | |
3110ff80 | 4090 | dprintk("%s: ctime=%ld\n", __func__, (long)time->tv_sec); |
1da177e4 LT |
4091 | return status; |
4092 | } | |
4093 | ||
55b6e774 RL |
4094 | static int decode_attr_time_delta(struct xdr_stream *xdr, uint32_t *bitmap, |
4095 | struct timespec *time) | |
4096 | { | |
4097 | int status = 0; | |
4098 | ||
4099 | time->tv_sec = 0; | |
4100 | time->tv_nsec = 0; | |
4101 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_DELTA - 1U))) | |
4102 | return -EIO; | |
4103 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_DELTA)) { | |
4104 | status = decode_attr_time(xdr, time); | |
4105 | bitmap[1] &= ~FATTR4_WORD1_TIME_DELTA; | |
4106 | } | |
4107 | dprintk("%s: time_delta=%ld %ld\n", __func__, (long)time->tv_sec, | |
4108 | (long)time->tv_nsec); | |
4109 | return status; | |
4110 | } | |
4111 | ||
aa9c2669 DQ |
4112 | static int decode_attr_security_label(struct xdr_stream *xdr, uint32_t *bitmap, |
4113 | struct nfs4_label *label) | |
4114 | { | |
4115 | uint32_t pi = 0; | |
4116 | uint32_t lfs = 0; | |
4117 | __u32 len; | |
4118 | __be32 *p; | |
4119 | int status = 0; | |
4120 | ||
4121 | if (unlikely(bitmap[2] & (FATTR4_WORD2_SECURITY_LABEL - 1U))) | |
4122 | return -EIO; | |
4123 | if (likely(bitmap[2] & FATTR4_WORD2_SECURITY_LABEL)) { | |
4124 | p = xdr_inline_decode(xdr, 4); | |
4125 | if (unlikely(!p)) | |
4126 | goto out_overflow; | |
4127 | lfs = be32_to_cpup(p++); | |
4128 | p = xdr_inline_decode(xdr, 4); | |
4129 | if (unlikely(!p)) | |
4130 | goto out_overflow; | |
4131 | pi = be32_to_cpup(p++); | |
4132 | p = xdr_inline_decode(xdr, 4); | |
4133 | if (unlikely(!p)) | |
4134 | goto out_overflow; | |
4135 | len = be32_to_cpup(p++); | |
4136 | p = xdr_inline_decode(xdr, len); | |
4137 | if (unlikely(!p)) | |
4138 | goto out_overflow; | |
4139 | if (len < NFS4_MAXLABELLEN) { | |
4140 | if (label) { | |
4141 | memcpy(label->label, p, len); | |
4142 | label->len = len; | |
4143 | label->pi = pi; | |
4144 | label->lfs = lfs; | |
4145 | status = NFS_ATTR_FATTR_V4_SECURITY_LABEL; | |
4146 | } | |
4147 | bitmap[2] &= ~FATTR4_WORD2_SECURITY_LABEL; | |
4148 | } else | |
4149 | printk(KERN_WARNING "%s: label too long (%u)!\n", | |
4150 | __func__, len); | |
4151 | } | |
4152 | if (label && label->label) | |
4153 | dprintk("%s: label=%s, len=%d, PI=%d, LFS=%d\n", __func__, | |
4154 | (char *)label->label, label->len, label->pi, label->lfs); | |
4155 | return status; | |
4156 | ||
4157 | out_overflow: | |
4158 | print_overflow_msg(__func__, xdr); | |
4159 | return -EIO; | |
4160 | } | |
4161 | ||
1da177e4 LT |
4162 | static int decode_attr_time_modify(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time) |
4163 | { | |
4164 | int status = 0; | |
4165 | ||
4166 | time->tv_sec = 0; | |
4167 | time->tv_nsec = 0; | |
4168 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_MODIFY - 1U))) | |
4169 | return -EIO; | |
4170 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_MODIFY)) { | |
4171 | status = decode_attr_time(xdr, time); | |
409924e4 TM |
4172 | if (status == 0) |
4173 | status = NFS_ATTR_FATTR_MTIME; | |
1da177e4 LT |
4174 | bitmap[1] &= ~FATTR4_WORD1_TIME_MODIFY; |
4175 | } | |
3110ff80 | 4176 | dprintk("%s: mtime=%ld\n", __func__, (long)time->tv_sec); |
1da177e4 LT |
4177 | return status; |
4178 | } | |
4179 | ||
256e48bb | 4180 | static int verify_attr_len(struct xdr_stream *xdr, unsigned int savep, uint32_t attrlen) |
1da177e4 LT |
4181 | { |
4182 | unsigned int attrwords = XDR_QUADLEN(attrlen); | |
256e48bb | 4183 | unsigned int nwords = (xdr_stream_pos(xdr) - savep) >> 2; |
1da177e4 LT |
4184 | |
4185 | if (unlikely(attrwords != nwords)) { | |
fe82a183 CL |
4186 | dprintk("%s: server returned incorrect attribute length: " |
4187 | "%u %c %u\n", | |
3110ff80 | 4188 | __func__, |
1da177e4 LT |
4189 | attrwords << 2, |
4190 | (attrwords < nwords) ? '<' : '>', | |
4191 | nwords << 2); | |
4192 | return -EIO; | |
4193 | } | |
4194 | return 0; | |
4195 | } | |
4196 | ||
4197 | static int decode_change_info(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) | |
4198 | { | |
8687b63a | 4199 | __be32 *p; |
1da177e4 | 4200 | |
c0eae66e BH |
4201 | p = xdr_inline_decode(xdr, 20); |
4202 | if (unlikely(!p)) | |
4203 | goto out_overflow; | |
6f723f77 | 4204 | cinfo->atomic = be32_to_cpup(p++); |
3ceb4dbb | 4205 | p = xdr_decode_hyper(p, &cinfo->before); |
cccddf4f | 4206 | xdr_decode_hyper(p, &cinfo->after); |
1da177e4 | 4207 | return 0; |
c0eae66e BH |
4208 | out_overflow: |
4209 | print_overflow_msg(__func__, xdr); | |
4210 | return -EIO; | |
1da177e4 LT |
4211 | } |
4212 | ||
6168f62c | 4213 | static int decode_access(struct xdr_stream *xdr, u32 *supported, u32 *access) |
1da177e4 | 4214 | { |
8687b63a | 4215 | __be32 *p; |
1da177e4 LT |
4216 | uint32_t supp, acc; |
4217 | int status; | |
4218 | ||
4219 | status = decode_op_hdr(xdr, OP_ACCESS); | |
4220 | if (status) | |
4221 | return status; | |
c0eae66e BH |
4222 | p = xdr_inline_decode(xdr, 8); |
4223 | if (unlikely(!p)) | |
4224 | goto out_overflow; | |
6f723f77 | 4225 | supp = be32_to_cpup(p++); |
cccddf4f | 4226 | acc = be32_to_cpup(p); |
6168f62c WAA |
4227 | *supported = supp; |
4228 | *access = acc; | |
1da177e4 | 4229 | return 0; |
c0eae66e BH |
4230 | out_overflow: |
4231 | print_overflow_msg(__func__, xdr); | |
4232 | return -EIO; | |
1da177e4 LT |
4233 | } |
4234 | ||
07d30434 | 4235 | static int decode_opaque_fixed(struct xdr_stream *xdr, void *buf, size_t len) |
1da177e4 | 4236 | { |
8687b63a | 4237 | __be32 *p; |
07d30434 BH |
4238 | |
4239 | p = xdr_inline_decode(xdr, len); | |
4240 | if (likely(p)) { | |
4241 | memcpy(buf, p, len); | |
4242 | return 0; | |
4243 | } | |
4244 | print_overflow_msg(__func__, xdr); | |
4245 | return -EIO; | |
4246 | } | |
4247 | ||
4248 | static int decode_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) | |
4249 | { | |
2d2f24ad | 4250 | return decode_opaque_fixed(xdr, stateid, NFS4_STATEID_SIZE); |
07d30434 BH |
4251 | } |
4252 | ||
4253 | static int decode_close(struct xdr_stream *xdr, struct nfs_closeres *res) | |
4254 | { | |
1da177e4 LT |
4255 | int status; |
4256 | ||
4257 | status = decode_op_hdr(xdr, OP_CLOSE); | |
c1d51931 TM |
4258 | if (status != -EIO) |
4259 | nfs_increment_open_seqid(status, res->seqid); | |
07d30434 BH |
4260 | if (!status) |
4261 | status = decode_stateid(xdr, &res->stateid); | |
4262 | return status; | |
1da177e4 LT |
4263 | } |
4264 | ||
db942bbd BH |
4265 | static int decode_verifier(struct xdr_stream *xdr, void *verifier) |
4266 | { | |
cd93710e | 4267 | return decode_opaque_fixed(xdr, verifier, NFS4_VERIFIER_SIZE); |
1da177e4 LT |
4268 | } |
4269 | ||
2f2c63bc TM |
4270 | static int decode_write_verifier(struct xdr_stream *xdr, struct nfs_write_verifier *verifier) |
4271 | { | |
4272 | return decode_opaque_fixed(xdr, verifier->data, NFS4_VERIFIER_SIZE); | |
4273 | } | |
4274 | ||
0b7c0153 | 4275 | static int decode_commit(struct xdr_stream *xdr, struct nfs_commitres *res) |
1da177e4 | 4276 | { |
1da177e4 LT |
4277 | int status; |
4278 | ||
4279 | status = decode_op_hdr(xdr, OP_COMMIT); | |
db942bbd | 4280 | if (!status) |
2f2c63bc | 4281 | status = decode_write_verifier(xdr, &res->verf->verifier); |
db942bbd | 4282 | return status; |
1da177e4 LT |
4283 | } |
4284 | ||
4285 | static int decode_create(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) | |
4286 | { | |
8687b63a | 4287 | __be32 *p; |
1da177e4 LT |
4288 | uint32_t bmlen; |
4289 | int status; | |
4290 | ||
4291 | status = decode_op_hdr(xdr, OP_CREATE); | |
4292 | if (status) | |
4293 | return status; | |
4294 | if ((status = decode_change_info(xdr, cinfo))) | |
4295 | return status; | |
c0eae66e BH |
4296 | p = xdr_inline_decode(xdr, 4); |
4297 | if (unlikely(!p)) | |
4298 | goto out_overflow; | |
cccddf4f | 4299 | bmlen = be32_to_cpup(p); |
c0eae66e BH |
4300 | p = xdr_inline_decode(xdr, bmlen << 2); |
4301 | if (likely(p)) | |
4302 | return 0; | |
4303 | out_overflow: | |
4304 | print_overflow_msg(__func__, xdr); | |
4305 | return -EIO; | |
1da177e4 LT |
4306 | } |
4307 | ||
4308 | static int decode_server_caps(struct xdr_stream *xdr, struct nfs4_server_caps_res *res) | |
4309 | { | |
256e48bb | 4310 | unsigned int savep; |
dae100c2 | 4311 | uint32_t attrlen, bitmap[3] = {0}; |
1da177e4 LT |
4312 | int status; |
4313 | ||
4314 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) | |
4315 | goto xdr_error; | |
4316 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) | |
4317 | goto xdr_error; | |
4318 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) | |
4319 | goto xdr_error; | |
4320 | if ((status = decode_attr_supported(xdr, bitmap, res->attr_bitmask)) != 0) | |
4321 | goto xdr_error; | |
264e6351 CL |
4322 | if ((status = decode_attr_fh_expire_type(xdr, bitmap, |
4323 | &res->fh_expire_type)) != 0) | |
4324 | goto xdr_error; | |
1da177e4 LT |
4325 | if ((status = decode_attr_link_support(xdr, bitmap, &res->has_links)) != 0) |
4326 | goto xdr_error; | |
4327 | if ((status = decode_attr_symlink_support(xdr, bitmap, &res->has_symlinks)) != 0) | |
4328 | goto xdr_error; | |
4329 | if ((status = decode_attr_aclsupport(xdr, bitmap, &res->acl_bitmask)) != 0) | |
4330 | goto xdr_error; | |
4331 | status = verify_attr_len(xdr, savep, attrlen); | |
4332 | xdr_error: | |
3110ff80 | 4333 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
1da177e4 LT |
4334 | return status; |
4335 | } | |
6c0195a4 | 4336 | |
1da177e4 LT |
4337 | static int decode_statfs(struct xdr_stream *xdr, struct nfs_fsstat *fsstat) |
4338 | { | |
256e48bb | 4339 | unsigned int savep; |
dae100c2 | 4340 | uint32_t attrlen, bitmap[3] = {0}; |
1da177e4 | 4341 | int status; |
6c0195a4 | 4342 | |
1da177e4 LT |
4343 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
4344 | goto xdr_error; | |
4345 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) | |
4346 | goto xdr_error; | |
4347 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) | |
4348 | goto xdr_error; | |
4349 | ||
4350 | if ((status = decode_attr_files_avail(xdr, bitmap, &fsstat->afiles)) != 0) | |
4351 | goto xdr_error; | |
4352 | if ((status = decode_attr_files_free(xdr, bitmap, &fsstat->ffiles)) != 0) | |
4353 | goto xdr_error; | |
4354 | if ((status = decode_attr_files_total(xdr, bitmap, &fsstat->tfiles)) != 0) | |
4355 | goto xdr_error; | |
4356 | if ((status = decode_attr_space_avail(xdr, bitmap, &fsstat->abytes)) != 0) | |
4357 | goto xdr_error; | |
4358 | if ((status = decode_attr_space_free(xdr, bitmap, &fsstat->fbytes)) != 0) | |
4359 | goto xdr_error; | |
4360 | if ((status = decode_attr_space_total(xdr, bitmap, &fsstat->tbytes)) != 0) | |
4361 | goto xdr_error; | |
4362 | ||
4363 | status = verify_attr_len(xdr, savep, attrlen); | |
4364 | xdr_error: | |
3110ff80 | 4365 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
1da177e4 LT |
4366 | return status; |
4367 | } | |
4368 | ||
4369 | static int decode_pathconf(struct xdr_stream *xdr, struct nfs_pathconf *pathconf) | |
4370 | { | |
256e48bb | 4371 | unsigned int savep; |
dae100c2 | 4372 | uint32_t attrlen, bitmap[3] = {0}; |
1da177e4 | 4373 | int status; |
6c0195a4 | 4374 | |
1da177e4 LT |
4375 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
4376 | goto xdr_error; | |
4377 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) | |
4378 | goto xdr_error; | |
4379 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) | |
4380 | goto xdr_error; | |
4381 | ||
4382 | if ((status = decode_attr_maxlink(xdr, bitmap, &pathconf->max_link)) != 0) | |
4383 | goto xdr_error; | |
4384 | if ((status = decode_attr_maxname(xdr, bitmap, &pathconf->max_namelen)) != 0) | |
4385 | goto xdr_error; | |
4386 | ||
4387 | status = verify_attr_len(xdr, savep, attrlen); | |
4388 | xdr_error: | |
3110ff80 | 4389 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
1da177e4 LT |
4390 | return status; |
4391 | } | |
4392 | ||
88034c3d AA |
4393 | static int decode_threshold_hint(struct xdr_stream *xdr, |
4394 | uint32_t *bitmap, | |
4395 | uint64_t *res, | |
4396 | uint32_t hint_bit) | |
4397 | { | |
4398 | __be32 *p; | |
4399 | ||
4400 | *res = 0; | |
4401 | if (likely(bitmap[0] & hint_bit)) { | |
4402 | p = xdr_inline_decode(xdr, 8); | |
4403 | if (unlikely(!p)) | |
4404 | goto out_overflow; | |
4405 | xdr_decode_hyper(p, res); | |
4406 | } | |
4407 | return 0; | |
4408 | out_overflow: | |
4409 | print_overflow_msg(__func__, xdr); | |
4410 | return -EIO; | |
4411 | } | |
4412 | ||
4413 | static int decode_first_threshold_item4(struct xdr_stream *xdr, | |
4414 | struct nfs4_threshold *res) | |
4415 | { | |
256e48bb TM |
4416 | __be32 *p; |
4417 | unsigned int savep; | |
88034c3d AA |
4418 | uint32_t bitmap[3] = {0,}, attrlen; |
4419 | int status; | |
4420 | ||
4421 | /* layout type */ | |
4422 | p = xdr_inline_decode(xdr, 4); | |
4423 | if (unlikely(!p)) { | |
4424 | print_overflow_msg(__func__, xdr); | |
4425 | return -EIO; | |
4426 | } | |
4427 | res->l_type = be32_to_cpup(p); | |
4428 | ||
4429 | /* thi_hintset bitmap */ | |
4430 | status = decode_attr_bitmap(xdr, bitmap); | |
4431 | if (status < 0) | |
4432 | goto xdr_error; | |
4433 | ||
4434 | /* thi_hintlist length */ | |
4435 | status = decode_attr_length(xdr, &attrlen, &savep); | |
4436 | if (status < 0) | |
4437 | goto xdr_error; | |
4438 | /* thi_hintlist */ | |
4439 | status = decode_threshold_hint(xdr, bitmap, &res->rd_sz, THRESHOLD_RD); | |
4440 | if (status < 0) | |
4441 | goto xdr_error; | |
4442 | status = decode_threshold_hint(xdr, bitmap, &res->wr_sz, THRESHOLD_WR); | |
4443 | if (status < 0) | |
4444 | goto xdr_error; | |
4445 | status = decode_threshold_hint(xdr, bitmap, &res->rd_io_sz, | |
4446 | THRESHOLD_RD_IO); | |
4447 | if (status < 0) | |
4448 | goto xdr_error; | |
4449 | status = decode_threshold_hint(xdr, bitmap, &res->wr_io_sz, | |
4450 | THRESHOLD_WR_IO); | |
4451 | if (status < 0) | |
4452 | goto xdr_error; | |
4453 | ||
4454 | status = verify_attr_len(xdr, savep, attrlen); | |
4455 | res->bm = bitmap[0]; | |
4456 | ||
4457 | dprintk("%s bm=0x%x rd_sz=%llu wr_sz=%llu rd_io=%llu wr_io=%llu\n", | |
4458 | __func__, res->bm, res->rd_sz, res->wr_sz, res->rd_io_sz, | |
4459 | res->wr_io_sz); | |
4460 | xdr_error: | |
4461 | dprintk("%s ret=%d!\n", __func__, status); | |
4462 | return status; | |
4463 | } | |
4464 | ||
4465 | /* | |
4466 | * Thresholds on pNFS direct I/O vrs MDS I/O | |
4467 | */ | |
4468 | static int decode_attr_mdsthreshold(struct xdr_stream *xdr, | |
4469 | uint32_t *bitmap, | |
4470 | struct nfs4_threshold *res) | |
4471 | { | |
4472 | __be32 *p; | |
4473 | int status = 0; | |
4474 | uint32_t num; | |
4475 | ||
4476 | if (unlikely(bitmap[2] & (FATTR4_WORD2_MDSTHRESHOLD - 1U))) | |
4477 | return -EIO; | |
029c5347 | 4478 | if (bitmap[2] & FATTR4_WORD2_MDSTHRESHOLD) { |
1549210f TM |
4479 | /* Did the server return an unrequested attribute? */ |
4480 | if (unlikely(res == NULL)) | |
4481 | return -EREMOTEIO; | |
88034c3d AA |
4482 | p = xdr_inline_decode(xdr, 4); |
4483 | if (unlikely(!p)) | |
4484 | goto out_overflow; | |
4485 | num = be32_to_cpup(p); | |
4486 | if (num == 0) | |
4487 | return 0; | |
4488 | if (num > 1) | |
4489 | printk(KERN_INFO "%s: Warning: Multiple pNFS layout " | |
4490 | "drivers per filesystem not supported\n", | |
4491 | __func__); | |
4492 | ||
4493 | status = decode_first_threshold_item4(xdr, res); | |
029c5347 | 4494 | bitmap[2] &= ~FATTR4_WORD2_MDSTHRESHOLD; |
88034c3d AA |
4495 | } |
4496 | return status; | |
4497 | out_overflow: | |
4498 | print_overflow_msg(__func__, xdr); | |
4499 | return -EIO; | |
4500 | } | |
4501 | ||
ae42c70a BS |
4502 | static int decode_getfattr_attrs(struct xdr_stream *xdr, uint32_t *bitmap, |
4503 | struct nfs_fattr *fattr, struct nfs_fh *fh, | |
aa9c2669 | 4504 | struct nfs4_fs_locations *fs_loc, struct nfs4_label *label, |
6926afd1 | 4505 | const struct nfs_server *server) |
1da177e4 | 4506 | { |
bca79478 TM |
4507 | int status; |
4508 | umode_t fmode = 0; | |
ae42c70a | 4509 | uint32_t type; |
ee7b75fc | 4510 | int32_t err; |
1da177e4 | 4511 | |
f26c7a78 TM |
4512 | status = decode_attr_type(xdr, bitmap, &type); |
4513 | if (status < 0) | |
1da177e4 | 4514 | goto xdr_error; |
409924e4 TM |
4515 | fattr->mode = 0; |
4516 | if (status != 0) { | |
4517 | fattr->mode |= nfs_type2fmt[type]; | |
4518 | fattr->valid |= status; | |
4519 | } | |
1da177e4 | 4520 | |
f26c7a78 TM |
4521 | status = decode_attr_change(xdr, bitmap, &fattr->change_attr); |
4522 | if (status < 0) | |
1da177e4 | 4523 | goto xdr_error; |
409924e4 | 4524 | fattr->valid |= status; |
f26c7a78 TM |
4525 | |
4526 | status = decode_attr_size(xdr, bitmap, &fattr->size); | |
4527 | if (status < 0) | |
1da177e4 | 4528 | goto xdr_error; |
409924e4 | 4529 | fattr->valid |= status; |
f26c7a78 TM |
4530 | |
4531 | status = decode_attr_fsid(xdr, bitmap, &fattr->fsid); | |
4532 | if (status < 0) | |
1da177e4 | 4533 | goto xdr_error; |
409924e4 | 4534 | fattr->valid |= status; |
f26c7a78 | 4535 | |
ee7b75fc TM |
4536 | err = 0; |
4537 | status = decode_attr_error(xdr, bitmap, &err); | |
ae42c70a BS |
4538 | if (status < 0) |
4539 | goto xdr_error; | |
4540 | ||
4541 | status = decode_attr_filehandle(xdr, bitmap, fh); | |
4542 | if (status < 0) | |
4543 | goto xdr_error; | |
4544 | ||
f26c7a78 TM |
4545 | status = decode_attr_fileid(xdr, bitmap, &fattr->fileid); |
4546 | if (status < 0) | |
1da177e4 | 4547 | goto xdr_error; |
409924e4 | 4548 | fattr->valid |= status; |
f26c7a78 | 4549 | |
8b7e3f49 | 4550 | status = decode_attr_fs_locations(xdr, bitmap, fs_loc); |
f26c7a78 | 4551 | if (status < 0) |
683b57b4 | 4552 | goto xdr_error; |
409924e4 | 4553 | fattr->valid |= status; |
f26c7a78 TM |
4554 | |
4555 | status = decode_attr_mode(xdr, bitmap, &fmode); | |
4556 | if (status < 0) | |
1da177e4 | 4557 | goto xdr_error; |
409924e4 TM |
4558 | if (status != 0) { |
4559 | fattr->mode |= fmode; | |
4560 | fattr->valid |= status; | |
4561 | } | |
f26c7a78 TM |
4562 | |
4563 | status = decode_attr_nlink(xdr, bitmap, &fattr->nlink); | |
4564 | if (status < 0) | |
1da177e4 | 4565 | goto xdr_error; |
409924e4 | 4566 | fattr->valid |= status; |
f26c7a78 | 4567 | |
6926afd1 | 4568 | status = decode_attr_owner(xdr, bitmap, server, &fattr->uid, fattr->owner_name); |
f26c7a78 | 4569 | if (status < 0) |
1da177e4 | 4570 | goto xdr_error; |
409924e4 | 4571 | fattr->valid |= status; |
f26c7a78 | 4572 | |
6926afd1 | 4573 | status = decode_attr_group(xdr, bitmap, server, &fattr->gid, fattr->group_name); |
f26c7a78 | 4574 | if (status < 0) |
1da177e4 | 4575 | goto xdr_error; |
409924e4 | 4576 | fattr->valid |= status; |
f26c7a78 TM |
4577 | |
4578 | status = decode_attr_rdev(xdr, bitmap, &fattr->rdev); | |
4579 | if (status < 0) | |
1da177e4 | 4580 | goto xdr_error; |
409924e4 | 4581 | fattr->valid |= status; |
f26c7a78 TM |
4582 | |
4583 | status = decode_attr_space_used(xdr, bitmap, &fattr->du.nfs3.used); | |
4584 | if (status < 0) | |
1da177e4 | 4585 | goto xdr_error; |
409924e4 | 4586 | fattr->valid |= status; |
f26c7a78 TM |
4587 | |
4588 | status = decode_attr_time_access(xdr, bitmap, &fattr->atime); | |
4589 | if (status < 0) | |
1da177e4 | 4590 | goto xdr_error; |
409924e4 | 4591 | fattr->valid |= status; |
f26c7a78 TM |
4592 | |
4593 | status = decode_attr_time_metadata(xdr, bitmap, &fattr->ctime); | |
4594 | if (status < 0) | |
1da177e4 | 4595 | goto xdr_error; |
409924e4 | 4596 | fattr->valid |= status; |
f26c7a78 TM |
4597 | |
4598 | status = decode_attr_time_modify(xdr, bitmap, &fattr->mtime); | |
4599 | if (status < 0) | |
1da177e4 | 4600 | goto xdr_error; |
409924e4 | 4601 | fattr->valid |= status; |
f26c7a78 | 4602 | |
28331a46 | 4603 | status = decode_attr_mounted_on_fileid(xdr, bitmap, &fattr->mounted_on_fileid); |
f26c7a78 | 4604 | if (status < 0) |
99baf625 | 4605 | goto xdr_error; |
28331a46 | 4606 | fattr->valid |= status; |
f26c7a78 | 4607 | |
88034c3d AA |
4608 | status = decode_attr_mdsthreshold(xdr, bitmap, fattr->mdsthreshold); |
4609 | if (status < 0) | |
4610 | goto xdr_error; | |
4611 | ||
aa9c2669 DQ |
4612 | if (label) { |
4613 | status = decode_attr_security_label(xdr, bitmap, label); | |
4614 | if (status < 0) | |
4615 | goto xdr_error; | |
4616 | fattr->valid |= status; | |
4617 | } | |
4618 | ||
ae42c70a BS |
4619 | xdr_error: |
4620 | dprintk("%s: xdr returned %d\n", __func__, -status); | |
4621 | return status; | |
4622 | } | |
4623 | ||
4624 | static int decode_getfattr_generic(struct xdr_stream *xdr, struct nfs_fattr *fattr, | |
8b7e3f49 | 4625 | struct nfs_fh *fh, struct nfs4_fs_locations *fs_loc, |
aa9c2669 | 4626 | struct nfs4_label *label, const struct nfs_server *server) |
ae42c70a | 4627 | { |
256e48bb | 4628 | unsigned int savep; |
ae42c70a | 4629 | uint32_t attrlen, |
dae100c2 | 4630 | bitmap[3] = {0}; |
ae42c70a BS |
4631 | int status; |
4632 | ||
4633 | status = decode_op_hdr(xdr, OP_GETATTR); | |
4634 | if (status < 0) | |
4635 | goto xdr_error; | |
4636 | ||
4637 | status = decode_attr_bitmap(xdr, bitmap); | |
4638 | if (status < 0) | |
4639 | goto xdr_error; | |
4640 | ||
4641 | status = decode_attr_length(xdr, &attrlen, &savep); | |
4642 | if (status < 0) | |
4643 | goto xdr_error; | |
4644 | ||
aa9c2669 DQ |
4645 | status = decode_getfattr_attrs(xdr, bitmap, fattr, fh, fs_loc, |
4646 | label, server); | |
ae42c70a BS |
4647 | if (status < 0) |
4648 | goto xdr_error; | |
4649 | ||
f26c7a78 | 4650 | status = verify_attr_len(xdr, savep, attrlen); |
1da177e4 | 4651 | xdr_error: |
3110ff80 | 4652 | dprintk("%s: xdr returned %d\n", __func__, -status); |
1da177e4 LT |
4653 | return status; |
4654 | } | |
4655 | ||
aa9c2669 DQ |
4656 | static int decode_getfattr_label(struct xdr_stream *xdr, struct nfs_fattr *fattr, |
4657 | struct nfs4_label *label, const struct nfs_server *server) | |
4658 | { | |
4659 | return decode_getfattr_generic(xdr, fattr, NULL, NULL, label, server); | |
4660 | } | |
4661 | ||
ae42c70a | 4662 | static int decode_getfattr(struct xdr_stream *xdr, struct nfs_fattr *fattr, |
6926afd1 | 4663 | const struct nfs_server *server) |
ae42c70a | 4664 | { |
aa9c2669 | 4665 | return decode_getfattr_generic(xdr, fattr, NULL, NULL, NULL, server); |
ae42c70a | 4666 | } |
1da177e4 | 4667 | |
504913fb AA |
4668 | /* |
4669 | * Decode potentially multiple layout types. Currently we only support | |
4670 | * one layout driver per file system. | |
4671 | */ | |
4672 | static int decode_first_pnfs_layout_type(struct xdr_stream *xdr, | |
4673 | uint32_t *layouttype) | |
4674 | { | |
b8a8a0dd | 4675 | __be32 *p; |
504913fb AA |
4676 | int num; |
4677 | ||
4678 | p = xdr_inline_decode(xdr, 4); | |
4679 | if (unlikely(!p)) | |
4680 | goto out_overflow; | |
4681 | num = be32_to_cpup(p); | |
4682 | ||
4683 | /* pNFS is not supported by the underlying file system */ | |
4684 | if (num == 0) { | |
4685 | *layouttype = 0; | |
4686 | return 0; | |
4687 | } | |
4688 | if (num > 1) | |
a030889a WAA |
4689 | printk(KERN_INFO "NFS: %s: Warning: Multiple pNFS layout " |
4690 | "drivers per filesystem not supported\n", __func__); | |
504913fb AA |
4691 | |
4692 | /* Decode and set first layout type, move xdr->p past unused types */ | |
4693 | p = xdr_inline_decode(xdr, num * 4); | |
4694 | if (unlikely(!p)) | |
4695 | goto out_overflow; | |
4696 | *layouttype = be32_to_cpup(p); | |
4697 | return 0; | |
4698 | out_overflow: | |
4699 | print_overflow_msg(__func__, xdr); | |
4700 | return -EIO; | |
4701 | } | |
4702 | ||
4703 | /* | |
4704 | * The type of file system exported. | |
4705 | * Note we must ensure that layouttype is set in any non-error case. | |
4706 | */ | |
4707 | static int decode_attr_pnfstype(struct xdr_stream *xdr, uint32_t *bitmap, | |
4708 | uint32_t *layouttype) | |
4709 | { | |
4710 | int status = 0; | |
4711 | ||
4712 | dprintk("%s: bitmap is %x\n", __func__, bitmap[1]); | |
4713 | if (unlikely(bitmap[1] & (FATTR4_WORD1_FS_LAYOUT_TYPES - 1U))) | |
4714 | return -EIO; | |
4715 | if (bitmap[1] & FATTR4_WORD1_FS_LAYOUT_TYPES) { | |
4716 | status = decode_first_pnfs_layout_type(xdr, layouttype); | |
4717 | bitmap[1] &= ~FATTR4_WORD1_FS_LAYOUT_TYPES; | |
4718 | } else | |
4719 | *layouttype = 0; | |
4720 | return status; | |
4721 | } | |
4722 | ||
dae100c2 FI |
4723 | /* |
4724 | * The prefered block size for layout directed io | |
4725 | */ | |
4726 | static int decode_attr_layout_blksize(struct xdr_stream *xdr, uint32_t *bitmap, | |
4727 | uint32_t *res) | |
4728 | { | |
4729 | __be32 *p; | |
4730 | ||
4731 | dprintk("%s: bitmap is %x\n", __func__, bitmap[2]); | |
4732 | *res = 0; | |
4733 | if (bitmap[2] & FATTR4_WORD2_LAYOUT_BLKSIZE) { | |
4734 | p = xdr_inline_decode(xdr, 4); | |
4735 | if (unlikely(!p)) { | |
4736 | print_overflow_msg(__func__, xdr); | |
4737 | return -EIO; | |
4738 | } | |
4739 | *res = be32_to_cpup(p); | |
4740 | bitmap[2] &= ~FATTR4_WORD2_LAYOUT_BLKSIZE; | |
4741 | } | |
4742 | return 0; | |
4743 | } | |
4744 | ||
1da177e4 LT |
4745 | static int decode_fsinfo(struct xdr_stream *xdr, struct nfs_fsinfo *fsinfo) |
4746 | { | |
256e48bb | 4747 | unsigned int savep; |
dae100c2 | 4748 | uint32_t attrlen, bitmap[3]; |
1da177e4 LT |
4749 | int status; |
4750 | ||
4751 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) | |
4752 | goto xdr_error; | |
4753 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) | |
4754 | goto xdr_error; | |
4755 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) | |
4756 | goto xdr_error; | |
4757 | ||
4758 | fsinfo->rtmult = fsinfo->wtmult = 512; /* ??? */ | |
4759 | ||
4760 | if ((status = decode_attr_lease_time(xdr, bitmap, &fsinfo->lease_time)) != 0) | |
4761 | goto xdr_error; | |
4762 | if ((status = decode_attr_maxfilesize(xdr, bitmap, &fsinfo->maxfilesize)) != 0) | |
4763 | goto xdr_error; | |
4764 | if ((status = decode_attr_maxread(xdr, bitmap, &fsinfo->rtmax)) != 0) | |
4765 | goto xdr_error; | |
4766 | fsinfo->rtpref = fsinfo->dtpref = fsinfo->rtmax; | |
4767 | if ((status = decode_attr_maxwrite(xdr, bitmap, &fsinfo->wtmax)) != 0) | |
4768 | goto xdr_error; | |
4769 | fsinfo->wtpref = fsinfo->wtmax; | |
55b6e774 | 4770 | status = decode_attr_time_delta(xdr, bitmap, &fsinfo->time_delta); |
504913fb AA |
4771 | if (status != 0) |
4772 | goto xdr_error; | |
4773 | status = decode_attr_pnfstype(xdr, bitmap, &fsinfo->layouttype); | |
55b6e774 RL |
4774 | if (status != 0) |
4775 | goto xdr_error; | |
dae100c2 FI |
4776 | status = decode_attr_layout_blksize(xdr, bitmap, &fsinfo->blksize); |
4777 | if (status) | |
4778 | goto xdr_error; | |
1da177e4 LT |
4779 | |
4780 | status = verify_attr_len(xdr, savep, attrlen); | |
4781 | xdr_error: | |
3110ff80 | 4782 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
1da177e4 LT |
4783 | return status; |
4784 | } | |
4785 | ||
4786 | static int decode_getfh(struct xdr_stream *xdr, struct nfs_fh *fh) | |
4787 | { | |
8687b63a | 4788 | __be32 *p; |
1da177e4 LT |
4789 | uint32_t len; |
4790 | int status; | |
4791 | ||
9936781d TM |
4792 | /* Zero handle first to allow comparisons */ |
4793 | memset(fh, 0, sizeof(*fh)); | |
4794 | ||
1da177e4 LT |
4795 | status = decode_op_hdr(xdr, OP_GETFH); |
4796 | if (status) | |
4797 | return status; | |
1da177e4 | 4798 | |
c0eae66e BH |
4799 | p = xdr_inline_decode(xdr, 4); |
4800 | if (unlikely(!p)) | |
4801 | goto out_overflow; | |
cccddf4f | 4802 | len = be32_to_cpup(p); |
1da177e4 LT |
4803 | if (len > NFS4_FHSIZE) |
4804 | return -EIO; | |
4805 | fh->size = len; | |
c0eae66e BH |
4806 | p = xdr_inline_decode(xdr, len); |
4807 | if (unlikely(!p)) | |
4808 | goto out_overflow; | |
99398d06 | 4809 | memcpy(fh->data, p, len); |
1da177e4 | 4810 | return 0; |
c0eae66e BH |
4811 | out_overflow: |
4812 | print_overflow_msg(__func__, xdr); | |
4813 | return -EIO; | |
1da177e4 LT |
4814 | } |
4815 | ||
4816 | static int decode_link(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) | |
4817 | { | |
4818 | int status; | |
6c0195a4 | 4819 | |
1da177e4 LT |
4820 | status = decode_op_hdr(xdr, OP_LINK); |
4821 | if (status) | |
4822 | return status; | |
4823 | return decode_change_info(xdr, cinfo); | |
4824 | } | |
4825 | ||
4826 | /* | |
4827 | * We create the owner, so we know a proper owner.id length is 4. | |
4828 | */ | |
911d1aaf | 4829 | static int decode_lock_denied (struct xdr_stream *xdr, struct file_lock *fl) |
1da177e4 | 4830 | { |
911d1aaf | 4831 | uint64_t offset, length, clientid; |
8687b63a | 4832 | __be32 *p; |
911d1aaf | 4833 | uint32_t namelen, type; |
1da177e4 | 4834 | |
babddc72 | 4835 | p = xdr_inline_decode(xdr, 32); /* read 32 bytes */ |
c0eae66e BH |
4836 | if (unlikely(!p)) |
4837 | goto out_overflow; | |
babddc72 | 4838 | p = xdr_decode_hyper(p, &offset); /* read 2 8-byte long words */ |
3ceb4dbb | 4839 | p = xdr_decode_hyper(p, &length); |
babddc72 BS |
4840 | type = be32_to_cpup(p++); /* 4 byte read */ |
4841 | if (fl != NULL) { /* manipulate file lock */ | |
911d1aaf TM |
4842 | fl->fl_start = (loff_t)offset; |
4843 | fl->fl_end = fl->fl_start + (loff_t)length - 1; | |
4844 | if (length == ~(uint64_t)0) | |
4845 | fl->fl_end = OFFSET_MAX; | |
4846 | fl->fl_type = F_WRLCK; | |
4847 | if (type & 1) | |
4848 | fl->fl_type = F_RDLCK; | |
4849 | fl->fl_pid = 0; | |
4850 | } | |
babddc72 BS |
4851 | p = xdr_decode_hyper(p, &clientid); /* read 8 bytes */ |
4852 | namelen = be32_to_cpup(p); /* read 4 bytes */ /* have read all 32 bytes now */ | |
4853 | p = xdr_inline_decode(xdr, namelen); /* variable size field */ | |
c0eae66e BH |
4854 | if (likely(p)) |
4855 | return -NFS4ERR_DENIED; | |
4856 | out_overflow: | |
4857 | print_overflow_msg(__func__, xdr); | |
4858 | return -EIO; | |
1da177e4 LT |
4859 | } |
4860 | ||
911d1aaf | 4861 | static int decode_lock(struct xdr_stream *xdr, struct nfs_lock_res *res) |
1da177e4 | 4862 | { |
1da177e4 LT |
4863 | int status; |
4864 | ||
4865 | status = decode_op_hdr(xdr, OP_LOCK); | |
c1d51931 TM |
4866 | if (status == -EIO) |
4867 | goto out; | |
1da177e4 | 4868 | if (status == 0) { |
07d30434 BH |
4869 | status = decode_stateid(xdr, &res->stateid); |
4870 | if (unlikely(status)) | |
4871 | goto out; | |
1da177e4 | 4872 | } else if (status == -NFS4ERR_DENIED) |
c1d51931 TM |
4873 | status = decode_lock_denied(xdr, NULL); |
4874 | if (res->open_seqid != NULL) | |
4875 | nfs_increment_open_seqid(status, res->open_seqid); | |
4876 | nfs_increment_lock_seqid(status, res->lock_seqid); | |
4877 | out: | |
1da177e4 LT |
4878 | return status; |
4879 | } | |
4880 | ||
911d1aaf | 4881 | static int decode_lockt(struct xdr_stream *xdr, struct nfs_lockt_res *res) |
1da177e4 LT |
4882 | { |
4883 | int status; | |
4884 | status = decode_op_hdr(xdr, OP_LOCKT); | |
4885 | if (status == -NFS4ERR_DENIED) | |
911d1aaf | 4886 | return decode_lock_denied(xdr, res->denied); |
1da177e4 LT |
4887 | return status; |
4888 | } | |
4889 | ||
911d1aaf | 4890 | static int decode_locku(struct xdr_stream *xdr, struct nfs_locku_res *res) |
1da177e4 | 4891 | { |
1da177e4 LT |
4892 | int status; |
4893 | ||
4894 | status = decode_op_hdr(xdr, OP_LOCKU); | |
c1d51931 TM |
4895 | if (status != -EIO) |
4896 | nfs_increment_lock_seqid(status, res->seqid); | |
07d30434 BH |
4897 | if (status == 0) |
4898 | status = decode_stateid(xdr, &res->stateid); | |
1da177e4 LT |
4899 | return status; |
4900 | } | |
4901 | ||
d3c7b7cc TM |
4902 | static int decode_release_lockowner(struct xdr_stream *xdr) |
4903 | { | |
4904 | return decode_op_hdr(xdr, OP_RELEASE_LOCKOWNER); | |
4905 | } | |
4906 | ||
1da177e4 LT |
4907 | static int decode_lookup(struct xdr_stream *xdr) |
4908 | { | |
4909 | return decode_op_hdr(xdr, OP_LOOKUP); | |
4910 | } | |
4911 | ||
4912 | /* This is too sick! */ | |
4913 | static int decode_space_limit(struct xdr_stream *xdr, u64 *maxsize) | |
4914 | { | |
05d564fe | 4915 | __be32 *p; |
1da177e4 LT |
4916 | uint32_t limit_type, nblocks, blocksize; |
4917 | ||
c0eae66e BH |
4918 | p = xdr_inline_decode(xdr, 12); |
4919 | if (unlikely(!p)) | |
4920 | goto out_overflow; | |
6f723f77 | 4921 | limit_type = be32_to_cpup(p++); |
1da177e4 | 4922 | switch (limit_type) { |
05d564fe | 4923 | case 1: |
cccddf4f | 4924 | xdr_decode_hyper(p, maxsize); |
05d564fe AA |
4925 | break; |
4926 | case 2: | |
6f723f77 | 4927 | nblocks = be32_to_cpup(p++); |
cccddf4f | 4928 | blocksize = be32_to_cpup(p); |
05d564fe | 4929 | *maxsize = (uint64_t)nblocks * (uint64_t)blocksize; |
1da177e4 LT |
4930 | } |
4931 | return 0; | |
c0eae66e BH |
4932 | out_overflow: |
4933 | print_overflow_msg(__func__, xdr); | |
4934 | return -EIO; | |
1da177e4 LT |
4935 | } |
4936 | ||
4937 | static int decode_delegation(struct xdr_stream *xdr, struct nfs_openres *res) | |
4938 | { | |
05d564fe AA |
4939 | __be32 *p; |
4940 | uint32_t delegation_type; | |
07d30434 | 4941 | int status; |
1da177e4 | 4942 | |
c0eae66e BH |
4943 | p = xdr_inline_decode(xdr, 4); |
4944 | if (unlikely(!p)) | |
4945 | goto out_overflow; | |
cccddf4f | 4946 | delegation_type = be32_to_cpup(p); |
1da177e4 LT |
4947 | if (delegation_type == NFS4_OPEN_DELEGATE_NONE) { |
4948 | res->delegation_type = 0; | |
4949 | return 0; | |
4950 | } | |
07d30434 BH |
4951 | status = decode_stateid(xdr, &res->delegation); |
4952 | if (unlikely(status)) | |
4953 | return status; | |
c0eae66e BH |
4954 | p = xdr_inline_decode(xdr, 4); |
4955 | if (unlikely(!p)) | |
4956 | goto out_overflow; | |
cccddf4f | 4957 | res->do_recall = be32_to_cpup(p); |
05d564fe | 4958 | |
1da177e4 | 4959 | switch (delegation_type) { |
05d564fe AA |
4960 | case NFS4_OPEN_DELEGATE_READ: |
4961 | res->delegation_type = FMODE_READ; | |
4962 | break; | |
4963 | case NFS4_OPEN_DELEGATE_WRITE: | |
4964 | res->delegation_type = FMODE_WRITE|FMODE_READ; | |
4965 | if (decode_space_limit(xdr, &res->maxsize) < 0) | |
1da177e4 LT |
4966 | return -EIO; |
4967 | } | |
7539bbab | 4968 | return decode_ace(xdr, NULL, res->server->nfs_client); |
c0eae66e BH |
4969 | out_overflow: |
4970 | print_overflow_msg(__func__, xdr); | |
4971 | return -EIO; | |
1da177e4 LT |
4972 | } |
4973 | ||
4974 | static int decode_open(struct xdr_stream *xdr, struct nfs_openres *res) | |
4975 | { | |
05d564fe | 4976 | __be32 *p; |
aa53ed54 | 4977 | uint32_t savewords, bmlen, i; |
05d564fe | 4978 | int status; |
1da177e4 | 4979 | |
c7848f69 TM |
4980 | if (!__decode_op_hdr(xdr, OP_OPEN, &status)) |
4981 | return status; | |
4982 | nfs_increment_open_seqid(status, res->seqid); | |
4983 | if (status) | |
4984 | return status; | |
4985 | status = decode_stateid(xdr, &res->stateid); | |
07d30434 | 4986 | if (unlikely(status)) |
05d564fe | 4987 | return status; |
1da177e4 | 4988 | |
05d564fe | 4989 | decode_change_info(xdr, &res->cinfo); |
1da177e4 | 4990 | |
c0eae66e BH |
4991 | p = xdr_inline_decode(xdr, 8); |
4992 | if (unlikely(!p)) | |
4993 | goto out_overflow; | |
6f723f77 | 4994 | res->rflags = be32_to_cpup(p++); |
cccddf4f | 4995 | bmlen = be32_to_cpup(p); |
05d564fe AA |
4996 | if (bmlen > 10) |
4997 | goto xdr_error; | |
1da177e4 | 4998 | |
c0eae66e BH |
4999 | p = xdr_inline_decode(xdr, bmlen << 2); |
5000 | if (unlikely(!p)) | |
5001 | goto out_overflow; | |
aa53ed54 JL |
5002 | savewords = min_t(uint32_t, bmlen, NFS4_BITMAP_SIZE); |
5003 | for (i = 0; i < savewords; ++i) | |
6f723f77 | 5004 | res->attrset[i] = be32_to_cpup(p++); |
aa53ed54 JL |
5005 | for (; i < NFS4_BITMAP_SIZE; i++) |
5006 | res->attrset[i] = 0; | |
5007 | ||
1da177e4 LT |
5008 | return decode_delegation(xdr, res); |
5009 | xdr_error: | |
3110ff80 | 5010 | dprintk("%s: Bitmap too large! Length = %u\n", __func__, bmlen); |
1da177e4 | 5011 | return -EIO; |
c0eae66e BH |
5012 | out_overflow: |
5013 | print_overflow_msg(__func__, xdr); | |
5014 | return -EIO; | |
1da177e4 LT |
5015 | } |
5016 | ||
5017 | static int decode_open_confirm(struct xdr_stream *xdr, struct nfs_open_confirmres *res) | |
5018 | { | |
1da177e4 LT |
5019 | int status; |
5020 | ||
05d564fe | 5021 | status = decode_op_hdr(xdr, OP_OPEN_CONFIRM); |
c1d51931 TM |
5022 | if (status != -EIO) |
5023 | nfs_increment_open_seqid(status, res->seqid); | |
07d30434 BH |
5024 | if (!status) |
5025 | status = decode_stateid(xdr, &res->stateid); | |
5026 | return status; | |
1da177e4 LT |
5027 | } |
5028 | ||
5029 | static int decode_open_downgrade(struct xdr_stream *xdr, struct nfs_closeres *res) | |
5030 | { | |
1da177e4 LT |
5031 | int status; |
5032 | ||
5033 | status = decode_op_hdr(xdr, OP_OPEN_DOWNGRADE); | |
c1d51931 TM |
5034 | if (status != -EIO) |
5035 | nfs_increment_open_seqid(status, res->seqid); | |
07d30434 BH |
5036 | if (!status) |
5037 | status = decode_stateid(xdr, &res->stateid); | |
5038 | return status; | |
1da177e4 LT |
5039 | } |
5040 | ||
5041 | static int decode_putfh(struct xdr_stream *xdr) | |
5042 | { | |
5043 | return decode_op_hdr(xdr, OP_PUTFH); | |
5044 | } | |
5045 | ||
5046 | static int decode_putrootfh(struct xdr_stream *xdr) | |
5047 | { | |
5048 | return decode_op_hdr(xdr, OP_PUTROOTFH); | |
5049 | } | |
5050 | ||
9137bdf3 AS |
5051 | static int decode_read(struct xdr_stream *xdr, struct rpc_rqst *req, |
5052 | struct nfs_pgio_res *res) | |
1da177e4 | 5053 | { |
8687b63a | 5054 | __be32 *p; |
64bd577e | 5055 | uint32_t count, eof, recvd; |
1da177e4 LT |
5056 | int status; |
5057 | ||
5058 | status = decode_op_hdr(xdr, OP_READ); | |
5059 | if (status) | |
5060 | return status; | |
c0eae66e BH |
5061 | p = xdr_inline_decode(xdr, 8); |
5062 | if (unlikely(!p)) | |
5063 | goto out_overflow; | |
6f723f77 | 5064 | eof = be32_to_cpup(p++); |
cccddf4f | 5065 | count = be32_to_cpup(p); |
64bd577e | 5066 | recvd = xdr_read_pages(xdr, count); |
1da177e4 | 5067 | if (count > recvd) { |
fe82a183 | 5068 | dprintk("NFS: server cheating in read reply: " |
1da177e4 LT |
5069 | "count %u > recvd %u\n", count, recvd); |
5070 | count = recvd; | |
5071 | eof = 0; | |
5072 | } | |
1da177e4 LT |
5073 | res->eof = eof; |
5074 | res->count = count; | |
5075 | return 0; | |
c0eae66e BH |
5076 | out_overflow: |
5077 | print_overflow_msg(__func__, xdr); | |
5078 | return -EIO; | |
1da177e4 LT |
5079 | } |
5080 | ||
5081 | static int decode_readdir(struct xdr_stream *xdr, struct rpc_rqst *req, struct nfs4_readdir_res *readdir) | |
5082 | { | |
bcecff77 | 5083 | int status; |
cd93710e | 5084 | __be32 verf[2]; |
1da177e4 LT |
5085 | |
5086 | status = decode_op_hdr(xdr, OP_READDIR); | |
db942bbd BH |
5087 | if (!status) |
5088 | status = decode_verifier(xdr, readdir->verifier.data); | |
5089 | if (unlikely(status)) | |
1da177e4 | 5090 | return status; |
cd93710e | 5091 | memcpy(verf, readdir->verifier.data, sizeof(verf)); |
44109241 | 5092 | dprintk("%s: verifier = %08x:%08x\n", |
cd93710e | 5093 | __func__, verf[0], verf[1]); |
64bd577e | 5094 | return xdr_read_pages(xdr, xdr->buf->page_len); |
1da177e4 LT |
5095 | } |
5096 | ||
5097 | static int decode_readlink(struct xdr_stream *xdr, struct rpc_rqst *req) | |
5098 | { | |
5099 | struct xdr_buf *rcvbuf = &req->rq_rcv_buf; | |
bcecff77 | 5100 | u32 len, recvd; |
8687b63a | 5101 | __be32 *p; |
1da177e4 LT |
5102 | int status; |
5103 | ||
5104 | status = decode_op_hdr(xdr, OP_READLINK); | |
5105 | if (status) | |
5106 | return status; | |
5107 | ||
5108 | /* Convert length of symlink */ | |
c0eae66e BH |
5109 | p = xdr_inline_decode(xdr, 4); |
5110 | if (unlikely(!p)) | |
5111 | goto out_overflow; | |
cccddf4f | 5112 | len = be32_to_cpup(p); |
1da177e4 | 5113 | if (len >= rcvbuf->page_len || len <= 0) { |
fe82a183 | 5114 | dprintk("nfs: server returned giant symlink!\n"); |
1da177e4 LT |
5115 | return -ENAMETOOLONG; |
5116 | } | |
64bd577e | 5117 | recvd = xdr_read_pages(xdr, len); |
1da177e4 | 5118 | if (recvd < len) { |
fe82a183 | 5119 | dprintk("NFS: server cheating in readlink reply: " |
1da177e4 LT |
5120 | "count %u > recvd %u\n", len, recvd); |
5121 | return -EIO; | |
5122 | } | |
1da177e4 LT |
5123 | /* |
5124 | * The XDR encode routine has set things up so that | |
5125 | * the link text will be copied directly into the | |
5126 | * buffer. We just have to do overflow-checking, | |
5127 | * and and null-terminate the text (the VFS expects | |
5128 | * null-termination). | |
5129 | */ | |
b4687da7 | 5130 | xdr_terminate_string(rcvbuf, len); |
1da177e4 | 5131 | return 0; |
c0eae66e BH |
5132 | out_overflow: |
5133 | print_overflow_msg(__func__, xdr); | |
5134 | return -EIO; | |
1da177e4 LT |
5135 | } |
5136 | ||
5137 | static int decode_remove(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) | |
5138 | { | |
5139 | int status; | |
5140 | ||
5141 | status = decode_op_hdr(xdr, OP_REMOVE); | |
5142 | if (status) | |
5143 | goto out; | |
5144 | status = decode_change_info(xdr, cinfo); | |
5145 | out: | |
5146 | return status; | |
5147 | } | |
5148 | ||
5149 | static int decode_rename(struct xdr_stream *xdr, struct nfs4_change_info *old_cinfo, | |
5150 | struct nfs4_change_info *new_cinfo) | |
5151 | { | |
5152 | int status; | |
5153 | ||
5154 | status = decode_op_hdr(xdr, OP_RENAME); | |
5155 | if (status) | |
5156 | goto out; | |
5157 | if ((status = decode_change_info(xdr, old_cinfo))) | |
5158 | goto out; | |
5159 | status = decode_change_info(xdr, new_cinfo); | |
5160 | out: | |
5161 | return status; | |
5162 | } | |
5163 | ||
5164 | static int decode_renew(struct xdr_stream *xdr) | |
5165 | { | |
5166 | return decode_op_hdr(xdr, OP_RENEW); | |
5167 | } | |
5168 | ||
56ae19f3 TM |
5169 | static int |
5170 | decode_restorefh(struct xdr_stream *xdr) | |
5171 | { | |
5172 | return decode_op_hdr(xdr, OP_RESTOREFH); | |
5173 | } | |
5174 | ||
029d105e | 5175 | static int decode_getacl(struct xdr_stream *xdr, struct rpc_rqst *req, |
bf118a34 | 5176 | struct nfs_getaclres *res) |
029d105e | 5177 | { |
256e48bb | 5178 | unsigned int savep; |
029d105e | 5179 | uint32_t attrlen, |
dae100c2 | 5180 | bitmap[3] = {0}; |
029d105e | 5181 | int status; |
cff298c7 | 5182 | unsigned int pg_offset; |
029d105e | 5183 | |
bf118a34 | 5184 | res->acl_len = 0; |
029d105e BF |
5185 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
5186 | goto out; | |
5a006899 | 5187 | |
519d3959 TM |
5188 | xdr_enter_page(xdr, xdr->buf->page_len); |
5189 | ||
cff298c7 TM |
5190 | /* Calculate the offset of the page data */ |
5191 | pg_offset = xdr->buf->head[0].iov_len; | |
5a006899 | 5192 | |
029d105e BF |
5193 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
5194 | goto out; | |
5195 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) | |
5196 | goto out; | |
5197 | ||
5198 | if (unlikely(bitmap[0] & (FATTR4_WORD0_ACL - 1U))) | |
5199 | return -EIO; | |
5200 | if (likely(bitmap[0] & FATTR4_WORD0_ACL)) { | |
029d105e | 5201 | |
bf118a34 AA |
5202 | /* The bitmap (xdr len + bitmaps) and the attr xdr len words |
5203 | * are stored with the acl data to handle the problem of | |
5204 | * variable length bitmaps.*/ | |
cff298c7 | 5205 | res->acl_data_offset = xdr_stream_pos(xdr) - pg_offset; |
519d3959 | 5206 | res->acl_len = attrlen; |
1f1ea6c2 TM |
5207 | |
5208 | /* Check for receive buffer overflow */ | |
5209 | if (res->acl_len > (xdr->nwords << 2) || | |
5210 | res->acl_len + res->acl_data_offset > xdr->buf->page_len) { | |
5211 | res->acl_flags |= NFS4_ACL_TRUNC; | |
519d3959 | 5212 | dprintk("NFS: acl reply: attrlen %u > page_len %u\n", |
cff298c7 | 5213 | attrlen, xdr->nwords << 2); |
029d105e | 5214 | } |
8c233cf9 BF |
5215 | } else |
5216 | status = -EOPNOTSUPP; | |
029d105e BF |
5217 | |
5218 | out: | |
5219 | return status; | |
5220 | } | |
5221 | ||
1da177e4 LT |
5222 | static int |
5223 | decode_savefh(struct xdr_stream *xdr) | |
5224 | { | |
5225 | return decode_op_hdr(xdr, OP_SAVEFH); | |
5226 | } | |
5227 | ||
9e9ecc03 | 5228 | static int decode_setattr(struct xdr_stream *xdr) |
1da177e4 | 5229 | { |
8687b63a | 5230 | __be32 *p; |
1da177e4 LT |
5231 | uint32_t bmlen; |
5232 | int status; | |
5233 | ||
1da177e4 LT |
5234 | status = decode_op_hdr(xdr, OP_SETATTR); |
5235 | if (status) | |
5236 | return status; | |
c0eae66e BH |
5237 | p = xdr_inline_decode(xdr, 4); |
5238 | if (unlikely(!p)) | |
5239 | goto out_overflow; | |
cccddf4f | 5240 | bmlen = be32_to_cpup(p); |
c0eae66e BH |
5241 | p = xdr_inline_decode(xdr, bmlen << 2); |
5242 | if (likely(p)) | |
5243 | return 0; | |
5244 | out_overflow: | |
5245 | print_overflow_msg(__func__, xdr); | |
5246 | return -EIO; | |
1da177e4 LT |
5247 | } |
5248 | ||
bb8b27e5 | 5249 | static int decode_setclientid(struct xdr_stream *xdr, struct nfs4_setclientid_res *res) |
1da177e4 | 5250 | { |
8687b63a | 5251 | __be32 *p; |
1da177e4 LT |
5252 | uint32_t opnum; |
5253 | int32_t nfserr; | |
5254 | ||
c0eae66e BH |
5255 | p = xdr_inline_decode(xdr, 8); |
5256 | if (unlikely(!p)) | |
5257 | goto out_overflow; | |
6f723f77 | 5258 | opnum = be32_to_cpup(p++); |
1da177e4 | 5259 | if (opnum != OP_SETCLIENTID) { |
fe82a183 | 5260 | dprintk("nfs: decode_setclientid: Server returned operation" |
6c0195a4 | 5261 | " %d\n", opnum); |
1da177e4 LT |
5262 | return -EIO; |
5263 | } | |
cccddf4f | 5264 | nfserr = be32_to_cpup(p); |
1da177e4 | 5265 | if (nfserr == NFS_OK) { |
c0eae66e BH |
5266 | p = xdr_inline_decode(xdr, 8 + NFS4_VERIFIER_SIZE); |
5267 | if (unlikely(!p)) | |
5268 | goto out_overflow; | |
bb8b27e5 TM |
5269 | p = xdr_decode_hyper(p, &res->clientid); |
5270 | memcpy(res->confirm.data, p, NFS4_VERIFIER_SIZE); | |
1da177e4 LT |
5271 | } else if (nfserr == NFSERR_CLID_INUSE) { |
5272 | uint32_t len; | |
5273 | ||
5274 | /* skip netid string */ | |
c0eae66e BH |
5275 | p = xdr_inline_decode(xdr, 4); |
5276 | if (unlikely(!p)) | |
5277 | goto out_overflow; | |
cccddf4f | 5278 | len = be32_to_cpup(p); |
c0eae66e BH |
5279 | p = xdr_inline_decode(xdr, len); |
5280 | if (unlikely(!p)) | |
5281 | goto out_overflow; | |
1da177e4 LT |
5282 | |
5283 | /* skip uaddr string */ | |
c0eae66e BH |
5284 | p = xdr_inline_decode(xdr, 4); |
5285 | if (unlikely(!p)) | |
5286 | goto out_overflow; | |
cccddf4f | 5287 | len = be32_to_cpup(p); |
c0eae66e BH |
5288 | p = xdr_inline_decode(xdr, len); |
5289 | if (unlikely(!p)) | |
5290 | goto out_overflow; | |
1da177e4 LT |
5291 | return -NFSERR_CLID_INUSE; |
5292 | } else | |
856dff3d | 5293 | return nfs4_stat_to_errno(nfserr); |
1da177e4 LT |
5294 | |
5295 | return 0; | |
c0eae66e BH |
5296 | out_overflow: |
5297 | print_overflow_msg(__func__, xdr); | |
5298 | return -EIO; | |
1da177e4 LT |
5299 | } |
5300 | ||
5301 | static int decode_setclientid_confirm(struct xdr_stream *xdr) | |
5302 | { | |
5303 | return decode_op_hdr(xdr, OP_SETCLIENTID_CONFIRM); | |
5304 | } | |
5305 | ||
9137bdf3 | 5306 | static int decode_write(struct xdr_stream *xdr, struct nfs_pgio_res *res) |
1da177e4 | 5307 | { |
8687b63a | 5308 | __be32 *p; |
1da177e4 LT |
5309 | int status; |
5310 | ||
5311 | status = decode_op_hdr(xdr, OP_WRITE); | |
5312 | if (status) | |
5313 | return status; | |
5314 | ||
2f2c63bc | 5315 | p = xdr_inline_decode(xdr, 8); |
c0eae66e BH |
5316 | if (unlikely(!p)) |
5317 | goto out_overflow; | |
6f723f77 BH |
5318 | res->count = be32_to_cpup(p++); |
5319 | res->verf->committed = be32_to_cpup(p++); | |
2f2c63bc | 5320 | return decode_write_verifier(xdr, &res->verf->verifier); |
c0eae66e BH |
5321 | out_overflow: |
5322 | print_overflow_msg(__func__, xdr); | |
5323 | return -EIO; | |
1da177e4 LT |
5324 | } |
5325 | ||
5326 | static int decode_delegreturn(struct xdr_stream *xdr) | |
5327 | { | |
5328 | return decode_op_hdr(xdr, OP_DELEGRETURN); | |
5329 | } | |
5330 | ||
fb15b26f CL |
5331 | static int decode_secinfo_gss(struct xdr_stream *xdr, |
5332 | struct nfs4_secinfo4 *flavor) | |
5a5ea0d4 | 5333 | { |
fb15b26f | 5334 | u32 oid_len; |
5a5ea0d4 BS |
5335 | __be32 *p; |
5336 | ||
5337 | p = xdr_inline_decode(xdr, 4); | |
5338 | if (unlikely(!p)) | |
5339 | goto out_overflow; | |
fb15b26f CL |
5340 | oid_len = be32_to_cpup(p); |
5341 | if (oid_len > GSS_OID_MAX_LEN) | |
5a5ea0d4 BS |
5342 | goto out_err; |
5343 | ||
fb15b26f | 5344 | p = xdr_inline_decode(xdr, oid_len); |
5a5ea0d4 BS |
5345 | if (unlikely(!p)) |
5346 | goto out_overflow; | |
fb15b26f CL |
5347 | memcpy(flavor->flavor_info.oid.data, p, oid_len); |
5348 | flavor->flavor_info.oid.len = oid_len; | |
5a5ea0d4 BS |
5349 | |
5350 | p = xdr_inline_decode(xdr, 8); | |
5351 | if (unlikely(!p)) | |
5352 | goto out_overflow; | |
fb15b26f CL |
5353 | flavor->flavor_info.qop = be32_to_cpup(p++); |
5354 | flavor->flavor_info.service = be32_to_cpup(p); | |
5a5ea0d4 BS |
5355 | |
5356 | return 0; | |
5357 | ||
5358 | out_overflow: | |
5359 | print_overflow_msg(__func__, xdr); | |
5360 | return -EIO; | |
5361 | out_err: | |
5362 | return -EINVAL; | |
5363 | } | |
5364 | ||
31e4dda4 | 5365 | static int decode_secinfo_common(struct xdr_stream *xdr, struct nfs4_secinfo_res *res) |
5a5ea0d4 | 5366 | { |
fb15b26f CL |
5367 | struct nfs4_secinfo4 *sec_flavor; |
5368 | unsigned int i, num_flavors; | |
5a5ea0d4 BS |
5369 | int status; |
5370 | __be32 *p; | |
5a5ea0d4 | 5371 | |
5a5ea0d4 BS |
5372 | p = xdr_inline_decode(xdr, 4); |
5373 | if (unlikely(!p)) | |
5374 | goto out_overflow; | |
5a5ea0d4 | 5375 | |
c3dfc280 BS |
5376 | res->flavors->num_flavors = 0; |
5377 | num_flavors = be32_to_cpup(p); | |
5378 | ||
5379 | for (i = 0; i < num_flavors; i++) { | |
5a5ea0d4 | 5380 | sec_flavor = &res->flavors->flavors[i]; |
c3dfc280 | 5381 | if ((char *)&sec_flavor[1] - (char *)res->flavors > PAGE_SIZE) |
5a5ea0d4 BS |
5382 | break; |
5383 | ||
5384 | p = xdr_inline_decode(xdr, 4); | |
5385 | if (unlikely(!p)) | |
5386 | goto out_overflow; | |
5387 | sec_flavor->flavor = be32_to_cpup(p); | |
5388 | ||
5389 | if (sec_flavor->flavor == RPC_AUTH_GSS) { | |
613e901e BS |
5390 | status = decode_secinfo_gss(xdr, sec_flavor); |
5391 | if (status) | |
5392 | goto out; | |
5a5ea0d4 | 5393 | } |
c3dfc280 | 5394 | res->flavors->num_flavors++; |
5a5ea0d4 BS |
5395 | } |
5396 | ||
31e4dda4 | 5397 | status = 0; |
613e901e BS |
5398 | out: |
5399 | return status; | |
5a5ea0d4 BS |
5400 | out_overflow: |
5401 | print_overflow_msg(__func__, xdr); | |
5402 | return -EIO; | |
5403 | } | |
5404 | ||
31e4dda4 BS |
5405 | static int decode_secinfo(struct xdr_stream *xdr, struct nfs4_secinfo_res *res) |
5406 | { | |
5407 | int status = decode_op_hdr(xdr, OP_SECINFO); | |
5408 | if (status) | |
5409 | return status; | |
5410 | return decode_secinfo_common(xdr, res); | |
5411 | } | |
5412 | ||
99fe60d0 | 5413 | #if defined(CONFIG_NFS_V4_1) |
31e4dda4 BS |
5414 | static int decode_secinfo_no_name(struct xdr_stream *xdr, struct nfs4_secinfo_res *res) |
5415 | { | |
5416 | int status = decode_op_hdr(xdr, OP_SECINFO_NO_NAME); | |
5417 | if (status) | |
5418 | return status; | |
5419 | return decode_secinfo_common(xdr, res); | |
5420 | } | |
5421 | ||
2031cd1a WAA |
5422 | static int decode_op_map(struct xdr_stream *xdr, struct nfs4_op_map *op_map) |
5423 | { | |
5424 | __be32 *p; | |
5425 | uint32_t bitmap_words; | |
5426 | unsigned int i; | |
5427 | ||
5428 | p = xdr_inline_decode(xdr, 4); | |
5429 | bitmap_words = be32_to_cpup(p++); | |
5430 | if (bitmap_words > NFS4_OP_MAP_NUM_WORDS) | |
5431 | return -EIO; | |
5432 | p = xdr_inline_decode(xdr, 4 * bitmap_words); | |
5433 | for (i = 0; i < bitmap_words; i++) | |
5434 | op_map->u.words[i] = be32_to_cpup(p++); | |
5435 | ||
5436 | return 0; | |
5437 | } | |
5438 | ||
99fe60d0 BH |
5439 | static int decode_exchange_id(struct xdr_stream *xdr, |
5440 | struct nfs41_exchange_id_res *res) | |
5441 | { | |
5442 | __be32 *p; | |
5443 | uint32_t dummy; | |
2460ba57 | 5444 | char *dummy_str; |
99fe60d0 | 5445 | int status; |
7d2ed9ac | 5446 | uint32_t impl_id_count; |
99fe60d0 BH |
5447 | |
5448 | status = decode_op_hdr(xdr, OP_EXCHANGE_ID); | |
5449 | if (status) | |
5450 | return status; | |
5451 | ||
c0eae66e BH |
5452 | p = xdr_inline_decode(xdr, 8); |
5453 | if (unlikely(!p)) | |
5454 | goto out_overflow; | |
32b01310 | 5455 | xdr_decode_hyper(p, &res->clientid); |
c0eae66e BH |
5456 | p = xdr_inline_decode(xdr, 12); |
5457 | if (unlikely(!p)) | |
5458 | goto out_overflow; | |
32b01310 TM |
5459 | res->seqid = be32_to_cpup(p++); |
5460 | res->flags = be32_to_cpup(p++); | |
99fe60d0 | 5461 | |
2031cd1a WAA |
5462 | res->state_protect.how = be32_to_cpup(p); |
5463 | switch (res->state_protect.how) { | |
5464 | case SP4_NONE: | |
5465 | break; | |
5466 | case SP4_MACH_CRED: | |
5467 | status = decode_op_map(xdr, &res->state_protect.enforce); | |
5468 | if (status) | |
5469 | return status; | |
5470 | status = decode_op_map(xdr, &res->state_protect.allow); | |
5471 | if (status) | |
5472 | return status; | |
5473 | break; | |
5474 | default: | |
5475 | WARN_ON_ONCE(1); | |
99fe60d0 | 5476 | return -EIO; |
2031cd1a | 5477 | } |
99fe60d0 | 5478 | |
acdeb69d | 5479 | /* server_owner4.so_minor_id */ |
c0eae66e BH |
5480 | p = xdr_inline_decode(xdr, 8); |
5481 | if (unlikely(!p)) | |
5482 | goto out_overflow; | |
acdeb69d | 5483 | p = xdr_decode_hyper(p, &res->server_owner->minor_id); |
99fe60d0 | 5484 | |
acdeb69d | 5485 | /* server_owner4.so_major_id */ |
2460ba57 BH |
5486 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); |
5487 | if (unlikely(status)) | |
5488 | return status; | |
acdeb69d CL |
5489 | if (unlikely(dummy > NFS4_OPAQUE_LIMIT)) |
5490 | return -EIO; | |
5491 | memcpy(res->server_owner->major_id, dummy_str, dummy); | |
5492 | res->server_owner->major_id_sz = dummy; | |
99fe60d0 | 5493 | |
acdeb69d | 5494 | /* server_scope4 */ |
2460ba57 BH |
5495 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); |
5496 | if (unlikely(status)) | |
5497 | return status; | |
78fe0f41 WAA |
5498 | if (unlikely(dummy > NFS4_OPAQUE_LIMIT)) |
5499 | return -EIO; | |
78fe0f41 WAA |
5500 | memcpy(res->server_scope->server_scope, dummy_str, dummy); |
5501 | res->server_scope->server_scope_sz = dummy; | |
5502 | ||
7d2ed9ac WAA |
5503 | /* Implementation Id */ |
5504 | p = xdr_inline_decode(xdr, 4); | |
5505 | if (unlikely(!p)) | |
5506 | goto out_overflow; | |
5507 | impl_id_count = be32_to_cpup(p++); | |
99fe60d0 | 5508 | |
7d2ed9ac WAA |
5509 | if (impl_id_count) { |
5510 | /* nii_domain */ | |
5511 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); | |
5512 | if (unlikely(status)) | |
5513 | return status; | |
5514 | if (unlikely(dummy > NFS4_OPAQUE_LIMIT)) | |
5515 | return -EIO; | |
5516 | memcpy(res->impl_id->domain, dummy_str, dummy); | |
5517 | ||
5518 | /* nii_name */ | |
5519 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); | |
5520 | if (unlikely(status)) | |
5521 | return status; | |
5522 | if (unlikely(dummy > NFS4_OPAQUE_LIMIT)) | |
5523 | return -EIO; | |
5524 | memcpy(res->impl_id->name, dummy_str, dummy); | |
5525 | ||
5526 | /* nii_date */ | |
5527 | p = xdr_inline_decode(xdr, 12); | |
5528 | if (unlikely(!p)) | |
5529 | goto out_overflow; | |
5530 | p = xdr_decode_hyper(p, &res->impl_id->date.seconds); | |
5531 | res->impl_id->date.nseconds = be32_to_cpup(p); | |
5532 | ||
5533 | /* if there's more than one entry, ignore the rest */ | |
5534 | } | |
99fe60d0 | 5535 | return 0; |
c0eae66e BH |
5536 | out_overflow: |
5537 | print_overflow_msg(__func__, xdr); | |
5538 | return -EIO; | |
99fe60d0 | 5539 | } |
fc931582 AA |
5540 | |
5541 | static int decode_chan_attrs(struct xdr_stream *xdr, | |
5542 | struct nfs4_channel_attrs *attrs) | |
5543 | { | |
5544 | __be32 *p; | |
c9c30dd5 | 5545 | u32 nr_attrs, val; |
fc931582 | 5546 | |
c0eae66e BH |
5547 | p = xdr_inline_decode(xdr, 28); |
5548 | if (unlikely(!p)) | |
5549 | goto out_overflow; | |
c9c30dd5 BH |
5550 | val = be32_to_cpup(p++); /* headerpadsz */ |
5551 | if (val) | |
5552 | return -EINVAL; /* no support for header padding yet */ | |
6f723f77 BH |
5553 | attrs->max_rqst_sz = be32_to_cpup(p++); |
5554 | attrs->max_resp_sz = be32_to_cpup(p++); | |
5555 | attrs->max_resp_sz_cached = be32_to_cpup(p++); | |
5556 | attrs->max_ops = be32_to_cpup(p++); | |
5557 | attrs->max_reqs = be32_to_cpup(p++); | |
cccddf4f | 5558 | nr_attrs = be32_to_cpup(p); |
fc931582 | 5559 | if (unlikely(nr_attrs > 1)) { |
a030889a WAA |
5560 | printk(KERN_WARNING "NFS: %s: Invalid rdma channel attrs " |
5561 | "count %u\n", __func__, nr_attrs); | |
fc931582 AA |
5562 | return -EINVAL; |
5563 | } | |
c0eae66e BH |
5564 | if (nr_attrs == 1) { |
5565 | p = xdr_inline_decode(xdr, 4); /* skip rdma_attrs */ | |
5566 | if (unlikely(!p)) | |
5567 | goto out_overflow; | |
5568 | } | |
fc931582 | 5569 | return 0; |
c0eae66e BH |
5570 | out_overflow: |
5571 | print_overflow_msg(__func__, xdr); | |
5572 | return -EIO; | |
fc931582 AA |
5573 | } |
5574 | ||
e78291e4 BH |
5575 | static int decode_sessionid(struct xdr_stream *xdr, struct nfs4_sessionid *sid) |
5576 | { | |
5577 | return decode_opaque_fixed(xdr, sid->data, NFS4_MAX_SESSIONID_LEN); | |
fc931582 AA |
5578 | } |
5579 | ||
7c44f1ae WAA |
5580 | static int decode_bind_conn_to_session(struct xdr_stream *xdr, |
5581 | struct nfs41_bind_conn_to_session_res *res) | |
5582 | { | |
5583 | __be32 *p; | |
5584 | int status; | |
5585 | ||
5586 | status = decode_op_hdr(xdr, OP_BIND_CONN_TO_SESSION); | |
5587 | if (!status) | |
5588 | status = decode_sessionid(xdr, &res->session->sess_id); | |
5589 | if (unlikely(status)) | |
5590 | return status; | |
5591 | ||
5592 | /* dir flags, rdma mode bool */ | |
5593 | p = xdr_inline_decode(xdr, 8); | |
5594 | if (unlikely(!p)) | |
5595 | goto out_overflow; | |
5596 | ||
5597 | res->dir = be32_to_cpup(p++); | |
5598 | if (res->dir == 0 || res->dir > NFS4_CDFS4_BOTH) | |
5599 | return -EIO; | |
5600 | if (be32_to_cpup(p) == 0) | |
5601 | res->use_conn_in_rdma_mode = false; | |
5602 | else | |
5603 | res->use_conn_in_rdma_mode = true; | |
5604 | ||
5605 | return 0; | |
5606 | out_overflow: | |
5607 | print_overflow_msg(__func__, xdr); | |
5608 | return -EIO; | |
5609 | } | |
5610 | ||
fc931582 AA |
5611 | static int decode_create_session(struct xdr_stream *xdr, |
5612 | struct nfs41_create_session_res *res) | |
5613 | { | |
5614 | __be32 *p; | |
5615 | int status; | |
5616 | struct nfs_client *clp = res->client; | |
5617 | struct nfs4_session *session = clp->cl_session; | |
5618 | ||
5619 | status = decode_op_hdr(xdr, OP_CREATE_SESSION); | |
e78291e4 BH |
5620 | if (!status) |
5621 | status = decode_sessionid(xdr, &session->sess_id); | |
5622 | if (unlikely(status)) | |
fc931582 AA |
5623 | return status; |
5624 | ||
fc931582 | 5625 | /* seqid, flags */ |
c0eae66e BH |
5626 | p = xdr_inline_decode(xdr, 8); |
5627 | if (unlikely(!p)) | |
5628 | goto out_overflow; | |
6f723f77 | 5629 | clp->cl_seqid = be32_to_cpup(p++); |
cccddf4f | 5630 | session->flags = be32_to_cpup(p); |
fc931582 AA |
5631 | |
5632 | /* Channel attributes */ | |
5633 | status = decode_chan_attrs(xdr, &session->fc_attrs); | |
5634 | if (!status) | |
5635 | status = decode_chan_attrs(xdr, &session->bc_attrs); | |
5636 | return status; | |
c0eae66e BH |
5637 | out_overflow: |
5638 | print_overflow_msg(__func__, xdr); | |
5639 | return -EIO; | |
fc931582 | 5640 | } |
0f3e66c6 AA |
5641 | |
5642 | static int decode_destroy_session(struct xdr_stream *xdr, void *dummy) | |
5643 | { | |
5644 | return decode_op_hdr(xdr, OP_DESTROY_SESSION); | |
5645 | } | |
18019753 | 5646 | |
66245539 TM |
5647 | static int decode_destroy_clientid(struct xdr_stream *xdr, void *dummy) |
5648 | { | |
5649 | return decode_op_hdr(xdr, OP_DESTROY_CLIENTID); | |
5650 | } | |
5651 | ||
18019753 RL |
5652 | static int decode_reclaim_complete(struct xdr_stream *xdr, void *dummy) |
5653 | { | |
5654 | return decode_op_hdr(xdr, OP_RECLAIM_COMPLETE); | |
5655 | } | |
99fe60d0 BH |
5656 | #endif /* CONFIG_NFS_V4_1 */ |
5657 | ||
9b7b9fcc AA |
5658 | static int decode_sequence(struct xdr_stream *xdr, |
5659 | struct nfs4_sequence_res *res, | |
5660 | struct rpc_rqst *rqstp) | |
5661 | { | |
5662 | #if defined(CONFIG_NFS_V4_1) | |
e3725ec0 | 5663 | struct nfs4_session *session; |
fc01cea9 AA |
5664 | struct nfs4_sessionid id; |
5665 | u32 dummy; | |
5666 | int status; | |
5667 | __be32 *p; | |
5668 | ||
e3725ec0 | 5669 | if (res->sr_slot == NULL) |
9b7b9fcc | 5670 | return 0; |
3bd2384a CL |
5671 | if (!res->sr_slot->table->session) |
5672 | return 0; | |
9b7b9fcc | 5673 | |
fc01cea9 | 5674 | status = decode_op_hdr(xdr, OP_SEQUENCE); |
e78291e4 BH |
5675 | if (!status) |
5676 | status = decode_sessionid(xdr, &id); | |
5677 | if (unlikely(status)) | |
fc01cea9 | 5678 | goto out_err; |
9b7b9fcc | 5679 | |
fc01cea9 AA |
5680 | /* |
5681 | * If the server returns different values for sessionID, slotID or | |
5682 | * sequence number, the server is looney tunes. | |
5683 | */ | |
fdcb4577 | 5684 | status = -EREMOTEIO; |
e3725ec0 | 5685 | session = res->sr_slot->table->session; |
fc01cea9 | 5686 | |
e3725ec0 | 5687 | if (memcmp(id.data, session->sess_id.data, |
fc01cea9 AA |
5688 | NFS4_MAX_SESSIONID_LEN)) { |
5689 | dprintk("%s Invalid session id\n", __func__); | |
5690 | goto out_err; | |
5691 | } | |
e78291e4 | 5692 | |
c0eae66e BH |
5693 | p = xdr_inline_decode(xdr, 20); |
5694 | if (unlikely(!p)) | |
5695 | goto out_overflow; | |
e78291e4 | 5696 | |
fc01cea9 | 5697 | /* seqid */ |
6f723f77 | 5698 | dummy = be32_to_cpup(p++); |
dfb4f309 | 5699 | if (dummy != res->sr_slot->seq_nr) { |
fc01cea9 AA |
5700 | dprintk("%s Invalid sequence number\n", __func__); |
5701 | goto out_err; | |
5702 | } | |
5703 | /* slot id */ | |
6f723f77 | 5704 | dummy = be32_to_cpup(p++); |
df2fabff | 5705 | if (dummy != res->sr_slot->slot_nr) { |
fc01cea9 AA |
5706 | dprintk("%s Invalid slot id\n", __func__); |
5707 | goto out_err; | |
5708 | } | |
da0507b7 TM |
5709 | /* highest slot id */ |
5710 | res->sr_highest_slotid = be32_to_cpup(p++); | |
464ee9f9 TM |
5711 | /* target highest slot id */ |
5712 | res->sr_target_highest_slotid = be32_to_cpup(p++); | |
0629e370 AB |
5713 | /* result flags */ |
5714 | res->sr_status_flags = be32_to_cpup(p); | |
fc01cea9 AA |
5715 | status = 0; |
5716 | out_err: | |
5717 | res->sr_status = status; | |
5718 | return status; | |
c0eae66e BH |
5719 | out_overflow: |
5720 | print_overflow_msg(__func__, xdr); | |
5721 | status = -EIO; | |
5722 | goto out_err; | |
fc01cea9 | 5723 | #else /* CONFIG_NFS_V4_1 */ |
9b7b9fcc | 5724 | return 0; |
fc01cea9 | 5725 | #endif /* CONFIG_NFS_V4_1 */ |
9b7b9fcc AA |
5726 | } |
5727 | ||
b1f69b75 | 5728 | #if defined(CONFIG_NFS_V4_1) |
b1f69b75 AA |
5729 | static int decode_getdeviceinfo(struct xdr_stream *xdr, |
5730 | struct pnfs_device *pdev) | |
5731 | { | |
5732 | __be32 *p; | |
5733 | uint32_t len, type; | |
5734 | int status; | |
5735 | ||
5736 | status = decode_op_hdr(xdr, OP_GETDEVICEINFO); | |
5737 | if (status) { | |
5738 | if (status == -ETOOSMALL) { | |
5739 | p = xdr_inline_decode(xdr, 4); | |
5740 | if (unlikely(!p)) | |
5741 | goto out_overflow; | |
5742 | pdev->mincount = be32_to_cpup(p); | |
5743 | dprintk("%s: Min count too small. mincnt = %u\n", | |
5744 | __func__, pdev->mincount); | |
5745 | } | |
5746 | return status; | |
5747 | } | |
5748 | ||
5749 | p = xdr_inline_decode(xdr, 8); | |
5750 | if (unlikely(!p)) | |
5751 | goto out_overflow; | |
5752 | type = be32_to_cpup(p++); | |
5753 | if (type != pdev->layout_type) { | |
5754 | dprintk("%s: layout mismatch req: %u pdev: %u\n", | |
5755 | __func__, pdev->layout_type, type); | |
5756 | return -EINVAL; | |
5757 | } | |
5758 | /* | |
5759 | * Get the length of the opaque device_addr4. xdr_read_pages places | |
5760 | * the opaque device_addr4 in the xdr_buf->pages (pnfs_device->pages) | |
5761 | * and places the remaining xdr data in xdr_buf->tail | |
5762 | */ | |
5763 | pdev->mincount = be32_to_cpup(p); | |
13fe4ba1 TM |
5764 | if (xdr_read_pages(xdr, pdev->mincount) != pdev->mincount) |
5765 | goto out_overflow; | |
b1f69b75 AA |
5766 | |
5767 | /* Parse notification bitmap, verifying that it is zero. */ | |
5768 | p = xdr_inline_decode(xdr, 4); | |
5769 | if (unlikely(!p)) | |
5770 | goto out_overflow; | |
5771 | len = be32_to_cpup(p); | |
5772 | if (len) { | |
ead00597 | 5773 | uint32_t i; |
b1f69b75 AA |
5774 | |
5775 | p = xdr_inline_decode(xdr, 4 * len); | |
5776 | if (unlikely(!p)) | |
5777 | goto out_overflow; | |
84c9dee3 CH |
5778 | |
5779 | if (be32_to_cpup(p++) & | |
5780 | ~(NOTIFY_DEVICEID4_CHANGE | NOTIFY_DEVICEID4_DELETE)) { | |
5781 | dprintk("%s: unsupported notification\n", | |
5782 | __func__); | |
5783 | } | |
5784 | ||
5785 | for (i = 1; i < len; i++) { | |
5786 | if (be32_to_cpup(p++)) { | |
5787 | dprintk("%s: unsupported notification\n", | |
b1f69b75 AA |
5788 | __func__); |
5789 | return -EIO; | |
5790 | } | |
5791 | } | |
5792 | } | |
5793 | return 0; | |
5794 | out_overflow: | |
5795 | print_overflow_msg(__func__, xdr); | |
5796 | return -EIO; | |
5797 | } | |
5798 | ||
5799 | static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req, | |
5800 | struct nfs4_layoutget_res *res) | |
5801 | { | |
5802 | __be32 *p; | |
5803 | int status; | |
5804 | u32 layout_count; | |
64bd577e | 5805 | u32 recvd; |
b1f69b75 AA |
5806 | |
5807 | status = decode_op_hdr(xdr, OP_LAYOUTGET); | |
5808 | if (status) | |
5809 | return status; | |
ea9d23f5 TM |
5810 | p = xdr_inline_decode(xdr, 4); |
5811 | if (unlikely(!p)) | |
5812 | goto out_overflow; | |
5813 | res->return_on_close = be32_to_cpup(p); | |
5814 | decode_stateid(xdr, &res->stateid); | |
5815 | p = xdr_inline_decode(xdr, 4); | |
b1f69b75 AA |
5816 | if (unlikely(!p)) |
5817 | goto out_overflow; | |
b1f69b75 AA |
5818 | layout_count = be32_to_cpup(p); |
5819 | if (!layout_count) { | |
5820 | dprintk("%s: server responded with empty layout array\n", | |
5821 | __func__); | |
5822 | return -EINVAL; | |
5823 | } | |
5824 | ||
35124a09 | 5825 | p = xdr_inline_decode(xdr, 28); |
b1f69b75 AA |
5826 | if (unlikely(!p)) |
5827 | goto out_overflow; | |
5828 | p = xdr_decode_hyper(p, &res->range.offset); | |
5829 | p = xdr_decode_hyper(p, &res->range.length); | |
5830 | res->range.iomode = be32_to_cpup(p++); | |
5831 | res->type = be32_to_cpup(p++); | |
35124a09 | 5832 | res->layoutp->len = be32_to_cpup(p); |
b1f69b75 AA |
5833 | |
5834 | dprintk("%s roff:%lu rlen:%lu riomode:%d, lo_type:0x%x, lo.len:%d\n", | |
5835 | __func__, | |
5836 | (unsigned long)res->range.offset, | |
5837 | (unsigned long)res->range.length, | |
5838 | res->range.iomode, | |
5839 | res->type, | |
35124a09 WAA |
5840 | res->layoutp->len); |
5841 | ||
64bd577e | 5842 | recvd = xdr_read_pages(xdr, res->layoutp->len); |
35124a09 WAA |
5843 | if (res->layoutp->len > recvd) { |
5844 | dprintk("NFS: server cheating in layoutget reply: " | |
5845 | "layout len %u > recvd %u\n", | |
5846 | res->layoutp->len, recvd); | |
5847 | return -EINVAL; | |
5848 | } | |
b1f69b75 | 5849 | |
b1f69b75 AA |
5850 | if (layout_count > 1) { |
5851 | /* We only handle a length one array at the moment. Any | |
5852 | * further entries are just ignored. Note that this means | |
5853 | * the client may see a response that is less than the | |
5854 | * minimum it requested. | |
5855 | */ | |
5856 | dprintk("%s: server responded with %d layouts, dropping tail\n", | |
5857 | __func__, layout_count); | |
5858 | } | |
5859 | ||
5860 | return 0; | |
5861 | out_overflow: | |
5862 | print_overflow_msg(__func__, xdr); | |
5863 | return -EIO; | |
5864 | } | |
863a3c6c | 5865 | |
cbe82603 BH |
5866 | static int decode_layoutreturn(struct xdr_stream *xdr, |
5867 | struct nfs4_layoutreturn_res *res) | |
5868 | { | |
5869 | __be32 *p; | |
5870 | int status; | |
5871 | ||
5872 | status = decode_op_hdr(xdr, OP_LAYOUTRETURN); | |
5873 | if (status) | |
5874 | return status; | |
5875 | p = xdr_inline_decode(xdr, 4); | |
5876 | if (unlikely(!p)) | |
5877 | goto out_overflow; | |
5878 | res->lrs_present = be32_to_cpup(p); | |
5879 | if (res->lrs_present) | |
5880 | status = decode_stateid(xdr, &res->stateid); | |
5881 | return status; | |
5882 | out_overflow: | |
5883 | print_overflow_msg(__func__, xdr); | |
5884 | return -EIO; | |
5885 | } | |
5886 | ||
863a3c6c AA |
5887 | static int decode_layoutcommit(struct xdr_stream *xdr, |
5888 | struct rpc_rqst *req, | |
5889 | struct nfs4_layoutcommit_res *res) | |
5890 | { | |
5891 | __be32 *p; | |
5892 | __u32 sizechanged; | |
5893 | int status; | |
5894 | ||
5895 | status = decode_op_hdr(xdr, OP_LAYOUTCOMMIT); | |
db29c089 | 5896 | res->status = status; |
863a3c6c AA |
5897 | if (status) |
5898 | return status; | |
5899 | ||
5900 | p = xdr_inline_decode(xdr, 4); | |
5901 | if (unlikely(!p)) | |
5902 | goto out_overflow; | |
5903 | sizechanged = be32_to_cpup(p); | |
5904 | ||
5905 | if (sizechanged) { | |
5906 | /* throw away new size */ | |
5907 | p = xdr_inline_decode(xdr, 8); | |
5908 | if (unlikely(!p)) | |
5909 | goto out_overflow; | |
5910 | } | |
5911 | return 0; | |
5912 | out_overflow: | |
5913 | print_overflow_msg(__func__, xdr); | |
5914 | return -EIO; | |
5915 | } | |
7d974794 BS |
5916 | |
5917 | static int decode_test_stateid(struct xdr_stream *xdr, | |
5918 | struct nfs41_test_stateid_res *res) | |
5919 | { | |
5920 | __be32 *p; | |
5921 | int status; | |
5922 | int num_res; | |
5923 | ||
5924 | status = decode_op_hdr(xdr, OP_TEST_STATEID); | |
5925 | if (status) | |
5926 | return status; | |
5927 | ||
5928 | p = xdr_inline_decode(xdr, 4); | |
5929 | if (unlikely(!p)) | |
5930 | goto out_overflow; | |
5931 | num_res = be32_to_cpup(p++); | |
5932 | if (num_res != 1) | |
5933 | goto out; | |
5934 | ||
5935 | p = xdr_inline_decode(xdr, 4); | |
5936 | if (unlikely(!p)) | |
5937 | goto out_overflow; | |
5938 | res->status = be32_to_cpup(p++); | |
1cab0652 BS |
5939 | |
5940 | return status; | |
7d974794 BS |
5941 | out_overflow: |
5942 | print_overflow_msg(__func__, xdr); | |
5943 | out: | |
5944 | return -EIO; | |
5945 | } | |
9aeda35f BS |
5946 | |
5947 | static int decode_free_stateid(struct xdr_stream *xdr, | |
5948 | struct nfs41_free_stateid_res *res) | |
5949 | { | |
9f79fb48 | 5950 | res->status = decode_op_hdr(xdr, OP_FREE_STATEID); |
9aeda35f | 5951 | return res->status; |
9aeda35f | 5952 | } |
b1f69b75 AA |
5953 | #endif /* CONFIG_NFS_V4_1 */ |
5954 | ||
49c2559e BH |
5955 | /* |
5956 | * END OF "GENERIC" DECODE ROUTINES. | |
5957 | */ | |
5958 | ||
1da177e4 LT |
5959 | /* |
5960 | * Decode OPEN_DOWNGRADE response | |
5961 | */ | |
bf269551 CL |
5962 | static int nfs4_xdr_dec_open_downgrade(struct rpc_rqst *rqstp, |
5963 | struct xdr_stream *xdr, | |
5964 | struct nfs_closeres *res) | |
1da177e4 | 5965 | { |
05d564fe AA |
5966 | struct compound_hdr hdr; |
5967 | int status; | |
5968 | ||
bf269551 | 5969 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc AA |
5970 | if (status) |
5971 | goto out; | |
bf269551 | 5972 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
05d564fe AA |
5973 | if (status) |
5974 | goto out; | |
bf269551 | 5975 | status = decode_putfh(xdr); |
05d564fe AA |
5976 | if (status) |
5977 | goto out; | |
bf269551 | 5978 | status = decode_open_downgrade(xdr, res); |
516a6af6 TM |
5979 | if (status != 0) |
5980 | goto out; | |
6926afd1 | 5981 | decode_getfattr(xdr, res->fattr, res->server); |
1da177e4 | 5982 | out: |
05d564fe | 5983 | return status; |
1da177e4 LT |
5984 | } |
5985 | ||
1da177e4 LT |
5986 | /* |
5987 | * Decode ACCESS response | |
5988 | */ | |
bf269551 CL |
5989 | static int nfs4_xdr_dec_access(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
5990 | struct nfs4_accessres *res) | |
1da177e4 | 5991 | { |
1da177e4 LT |
5992 | struct compound_hdr hdr; |
5993 | int status; | |
6c0195a4 | 5994 | |
bf269551 | 5995 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc AA |
5996 | if (status) |
5997 | goto out; | |
bf269551 | 5998 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
9b7b9fcc | 5999 | if (status) |
1da177e4 | 6000 | goto out; |
bf269551 | 6001 | status = decode_putfh(xdr); |
76b32999 TM |
6002 | if (status != 0) |
6003 | goto out; | |
6168f62c | 6004 | status = decode_access(xdr, &res->supported, &res->access); |
76b32999 TM |
6005 | if (status != 0) |
6006 | goto out; | |
6926afd1 | 6007 | decode_getfattr(xdr, res->fattr, res->server); |
1da177e4 LT |
6008 | out: |
6009 | return status; | |
6010 | } | |
6011 | ||
6012 | /* | |
6013 | * Decode LOOKUP response | |
6014 | */ | |
bf269551 CL |
6015 | static int nfs4_xdr_dec_lookup(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
6016 | struct nfs4_lookup_res *res) | |
1da177e4 | 6017 | { |
1da177e4 LT |
6018 | struct compound_hdr hdr; |
6019 | int status; | |
6c0195a4 | 6020 | |
bf269551 | 6021 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc AA |
6022 | if (status) |
6023 | goto out; | |
bf269551 | 6024 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
9b7b9fcc | 6025 | if (status) |
1da177e4 | 6026 | goto out; |
bf269551 CL |
6027 | status = decode_putfh(xdr); |
6028 | if (status) | |
1da177e4 | 6029 | goto out; |
bf269551 CL |
6030 | status = decode_lookup(xdr); |
6031 | if (status) | |
1da177e4 | 6032 | goto out; |
bf269551 CL |
6033 | status = decode_getfh(xdr, res->fh); |
6034 | if (status) | |
1da177e4 | 6035 | goto out; |
aa9c2669 | 6036 | status = decode_getfattr_label(xdr, res->fattr, res->label, res->server); |
1da177e4 LT |
6037 | out: |
6038 | return status; | |
6039 | } | |
6040 | ||
6041 | /* | |
6042 | * Decode LOOKUP_ROOT response | |
6043 | */ | |
bf269551 CL |
6044 | static int nfs4_xdr_dec_lookup_root(struct rpc_rqst *rqstp, |
6045 | struct xdr_stream *xdr, | |
6046 | struct nfs4_lookup_res *res) | |
1da177e4 | 6047 | { |
1da177e4 LT |
6048 | struct compound_hdr hdr; |
6049 | int status; | |
6c0195a4 | 6050 | |
bf269551 | 6051 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc AA |
6052 | if (status) |
6053 | goto out; | |
bf269551 | 6054 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
9b7b9fcc | 6055 | if (status) |
1da177e4 | 6056 | goto out; |
bf269551 CL |
6057 | status = decode_putrootfh(xdr); |
6058 | if (status) | |
1da177e4 | 6059 | goto out; |
bf269551 CL |
6060 | status = decode_getfh(xdr, res->fh); |
6061 | if (status == 0) | |
aa9c2669 DQ |
6062 | status = decode_getfattr_label(xdr, res->fattr, |
6063 | res->label, res->server); | |
1da177e4 LT |
6064 | out: |
6065 | return status; | |
6066 | } | |
6067 | ||
6068 | /* | |
6069 | * Decode REMOVE response | |
6070 | */ | |
bf269551 CL |
6071 | static int nfs4_xdr_dec_remove(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
6072 | struct nfs_removeres *res) | |
1da177e4 | 6073 | { |
1da177e4 LT |
6074 | struct compound_hdr hdr; |
6075 | int status; | |
6c0195a4 | 6076 | |
bf269551 | 6077 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc AA |
6078 | if (status) |
6079 | goto out; | |
bf269551 | 6080 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
9b7b9fcc | 6081 | if (status) |
1da177e4 | 6082 | goto out; |
bf269551 CL |
6083 | status = decode_putfh(xdr); |
6084 | if (status) | |
16e42959 | 6085 | goto out; |
bf269551 | 6086 | status = decode_remove(xdr, &res->cinfo); |
1da177e4 LT |
6087 | out: |
6088 | return status; | |
6089 | } | |
6090 | ||
6091 | /* | |
6092 | * Decode RENAME response | |
6093 | */ | |
bf269551 CL |
6094 | static int nfs4_xdr_dec_rename(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
6095 | struct nfs_renameres *res) | |
1da177e4 | 6096 | { |
1da177e4 LT |
6097 | struct compound_hdr hdr; |
6098 | int status; | |
6c0195a4 | 6099 | |
bf269551 | 6100 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc AA |
6101 | if (status) |
6102 | goto out; | |
bf269551 | 6103 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
9b7b9fcc | 6104 | if (status) |
1da177e4 | 6105 | goto out; |
bf269551 CL |
6106 | status = decode_putfh(xdr); |
6107 | if (status) | |
1da177e4 | 6108 | goto out; |
bf269551 CL |
6109 | status = decode_savefh(xdr); |
6110 | if (status) | |
1da177e4 | 6111 | goto out; |
bf269551 CL |
6112 | status = decode_putfh(xdr); |
6113 | if (status) | |
1da177e4 | 6114 | goto out; |
bf269551 | 6115 | status = decode_rename(xdr, &res->old_cinfo, &res->new_cinfo); |
1da177e4 LT |
6116 | out: |
6117 | return status; | |
6118 | } | |
6119 | ||
6120 | /* | |
6121 | * Decode LINK response | |
6122 | */ | |
bf269551 CL |
6123 | static int nfs4_xdr_dec_link(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
6124 | struct nfs4_link_res *res) | |
1da177e4 | 6125 | { |
1da177e4 LT |
6126 | struct compound_hdr hdr; |
6127 | int status; | |
6c0195a4 | 6128 | |
bf269551 | 6129 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc AA |
6130 | if (status) |
6131 | goto out; | |
bf269551 | 6132 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
9b7b9fcc | 6133 | if (status) |
1da177e4 | 6134 | goto out; |
bf269551 CL |
6135 | status = decode_putfh(xdr); |
6136 | if (status) | |
1da177e4 | 6137 | goto out; |
bf269551 CL |
6138 | status = decode_savefh(xdr); |
6139 | if (status) | |
1da177e4 | 6140 | goto out; |
bf269551 CL |
6141 | status = decode_putfh(xdr); |
6142 | if (status) | |
1da177e4 | 6143 | goto out; |
bf269551 CL |
6144 | status = decode_link(xdr, &res->cinfo); |
6145 | if (status) | |
91ba2eee TM |
6146 | goto out; |
6147 | /* | |
6148 | * Note order: OP_LINK leaves the directory as the current | |
6149 | * filehandle. | |
6150 | */ | |
bf269551 CL |
6151 | status = decode_restorefh(xdr); |
6152 | if (status) | |
91ba2eee | 6153 | goto out; |
aa9c2669 | 6154 | decode_getfattr_label(xdr, res->fattr, res->label, res->server); |
1da177e4 LT |
6155 | out: |
6156 | return status; | |
6157 | } | |
6158 | ||
6159 | /* | |
6160 | * Decode CREATE response | |
6161 | */ | |
bf269551 CL |
6162 | static int nfs4_xdr_dec_create(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
6163 | struct nfs4_create_res *res) | |
1da177e4 | 6164 | { |
1da177e4 LT |
6165 | struct compound_hdr hdr; |
6166 | int status; | |
6c0195a4 | 6167 | |
bf269551 | 6168 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc AA |
6169 | if (status) |
6170 | goto out; | |
bf269551 | 6171 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
9b7b9fcc | 6172 | if (status) |
1da177e4 | 6173 | goto out; |
bf269551 | 6174 | status = decode_putfh(xdr); |
bf269551 | 6175 | if (status) |
56ae19f3 | 6176 | goto out; |
bf269551 CL |
6177 | status = decode_create(xdr, &res->dir_cinfo); |
6178 | if (status) | |
1da177e4 | 6179 | goto out; |
bf269551 CL |
6180 | status = decode_getfh(xdr, res->fh); |
6181 | if (status) | |
1da177e4 | 6182 | goto out; |
aa9c2669 | 6183 | decode_getfattr_label(xdr, res->fattr, res->label, res->server); |
1da177e4 LT |
6184 | out: |
6185 | return status; | |
6186 | } | |
6187 | ||
6188 | /* | |
6189 | * Decode SYMLINK response | |
6190 | */ | |
bf269551 CL |
6191 | static int nfs4_xdr_dec_symlink(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
6192 | struct nfs4_create_res *res) | |
1da177e4 | 6193 | { |
bf269551 | 6194 | return nfs4_xdr_dec_create(rqstp, xdr, res); |
1da177e4 LT |
6195 | } |
6196 | ||
6197 | /* | |
6198 | * Decode GETATTR response | |
6199 | */ | |
bf269551 CL |
6200 | static int nfs4_xdr_dec_getattr(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
6201 | struct nfs4_getattr_res *res) | |
1da177e4 | 6202 | { |
1da177e4 LT |
6203 | struct compound_hdr hdr; |
6204 | int status; | |
6c0195a4 | 6205 | |
bf269551 | 6206 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc AA |
6207 | if (status) |
6208 | goto out; | |
bf269551 | 6209 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
1da177e4 LT |
6210 | if (status) |
6211 | goto out; | |
bf269551 | 6212 | status = decode_putfh(xdr); |
1da177e4 LT |
6213 | if (status) |
6214 | goto out; | |
aa9c2669 | 6215 | status = decode_getfattr_label(xdr, res->fattr, res->label, res->server); |
1da177e4 LT |
6216 | out: |
6217 | return status; | |
1da177e4 LT |
6218 | } |
6219 | ||
23ec6965 BF |
6220 | /* |
6221 | * Encode an SETACL request | |
6222 | */ | |
9f06c719 CL |
6223 | static void nfs4_xdr_enc_setacl(struct rpc_rqst *req, struct xdr_stream *xdr, |
6224 | struct nfs_setaclargs *args) | |
23ec6965 | 6225 | { |
05d564fe | 6226 | struct compound_hdr hdr = { |
66cc0429 | 6227 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
05d564fe | 6228 | }; |
05d564fe | 6229 | |
9f06c719 CL |
6230 | encode_compound_hdr(xdr, req, &hdr); |
6231 | encode_sequence(xdr, &args->seq_args, &hdr); | |
6232 | encode_putfh(xdr, args->fh, &hdr); | |
6233 | encode_setacl(xdr, args, &hdr); | |
d017931c | 6234 | encode_nops(&hdr); |
23ec6965 | 6235 | } |
05d564fe | 6236 | |
23ec6965 BF |
6237 | /* |
6238 | * Decode SETACL response | |
6239 | */ | |
6240 | static int | |
bf269551 | 6241 | nfs4_xdr_dec_setacl(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
73c403a9 | 6242 | struct nfs_setaclres *res) |
23ec6965 | 6243 | { |
23ec6965 BF |
6244 | struct compound_hdr hdr; |
6245 | int status; | |
6246 | ||
bf269551 | 6247 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc AA |
6248 | if (status) |
6249 | goto out; | |
bf269551 | 6250 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
23ec6965 BF |
6251 | if (status) |
6252 | goto out; | |
bf269551 | 6253 | status = decode_putfh(xdr); |
23ec6965 BF |
6254 | if (status) |
6255 | goto out; | |
bf269551 | 6256 | status = decode_setattr(xdr); |
23ec6965 BF |
6257 | out: |
6258 | return status; | |
6259 | } | |
1da177e4 | 6260 | |
029d105e BF |
6261 | /* |
6262 | * Decode GETACL response | |
6263 | */ | |
6264 | static int | |
bf269551 | 6265 | nfs4_xdr_dec_getacl(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
663c79b3 | 6266 | struct nfs_getaclres *res) |
029d105e | 6267 | { |
029d105e BF |
6268 | struct compound_hdr hdr; |
6269 | int status; | |
6270 | ||
331818f1 TM |
6271 | if (res->acl_scratch != NULL) { |
6272 | void *p = page_address(res->acl_scratch); | |
6273 | xdr_set_scratch_buffer(xdr, p, PAGE_SIZE); | |
6274 | } | |
bf269551 | 6275 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc AA |
6276 | if (status) |
6277 | goto out; | |
bf269551 | 6278 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
029d105e BF |
6279 | if (status) |
6280 | goto out; | |
bf269551 | 6281 | status = decode_putfh(xdr); |
029d105e BF |
6282 | if (status) |
6283 | goto out; | |
bf118a34 | 6284 | status = decode_getacl(xdr, rqstp, res); |
029d105e BF |
6285 | |
6286 | out: | |
6287 | return status; | |
6288 | } | |
6289 | ||
1da177e4 LT |
6290 | /* |
6291 | * Decode CLOSE response | |
6292 | */ | |
bf269551 CL |
6293 | static int nfs4_xdr_dec_close(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
6294 | struct nfs_closeres *res) | |
1da177e4 | 6295 | { |
05d564fe AA |
6296 | struct compound_hdr hdr; |
6297 | int status; | |
6298 | ||
bf269551 | 6299 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc AA |
6300 | if (status) |
6301 | goto out; | |
bf269551 | 6302 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
05d564fe AA |
6303 | if (status) |
6304 | goto out; | |
bf269551 | 6305 | status = decode_putfh(xdr); |
05d564fe AA |
6306 | if (status) |
6307 | goto out; | |
bf269551 | 6308 | status = decode_close(xdr, res); |
516a6af6 TM |
6309 | if (status != 0) |
6310 | goto out; | |
6311 | /* | |
6312 | * Note: Server may do delete on close for this file | |
6313 | * in which case the getattr call will fail with | |
6314 | * an ESTALE error. Shouldn't be a problem, | |
6315 | * though, since fattr->valid will remain unset. | |
6316 | */ | |
6926afd1 | 6317 | decode_getfattr(xdr, res->fattr, res->server); |
1da177e4 | 6318 | out: |
05d564fe | 6319 | return status; |
1da177e4 LT |
6320 | } |
6321 | ||
6322 | /* | |
6323 | * Decode OPEN response | |
6324 | */ | |
bf269551 CL |
6325 | static int nfs4_xdr_dec_open(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
6326 | struct nfs_openres *res) | |
1da177e4 | 6327 | { |
05d564fe AA |
6328 | struct compound_hdr hdr; |
6329 | int status; | |
6330 | ||
bf269551 | 6331 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc AA |
6332 | if (status) |
6333 | goto out; | |
bf269551 | 6334 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
05d564fe AA |
6335 | if (status) |
6336 | goto out; | |
bf269551 | 6337 | status = decode_putfh(xdr); |
05d564fe AA |
6338 | if (status) |
6339 | goto out; | |
bf269551 | 6340 | status = decode_open(xdr, res); |
56ae19f3 TM |
6341 | if (status) |
6342 | goto out; | |
01913b49 WAA |
6343 | status = decode_getfh(xdr, &res->fh); |
6344 | if (status) | |
1da177e4 | 6345 | goto out; |
ae2bb032 WAA |
6346 | if (res->access_request) |
6347 | decode_access(xdr, &res->access_supported, &res->access_result); | |
aa9c2669 | 6348 | decode_getfattr_label(xdr, res->f_attr, res->f_label, res->server); |
1da177e4 | 6349 | out: |
05d564fe | 6350 | return status; |
1da177e4 LT |
6351 | } |
6352 | ||
6353 | /* | |
6354 | * Decode OPEN_CONFIRM response | |
6355 | */ | |
bf269551 CL |
6356 | static int nfs4_xdr_dec_open_confirm(struct rpc_rqst *rqstp, |
6357 | struct xdr_stream *xdr, | |
6358 | struct nfs_open_confirmres *res) | |
1da177e4 | 6359 | { |
05d564fe AA |
6360 | struct compound_hdr hdr; |
6361 | int status; | |
6362 | ||
bf269551 | 6363 | status = decode_compound_hdr(xdr, &hdr); |
05d564fe AA |
6364 | if (status) |
6365 | goto out; | |
bf269551 | 6366 | status = decode_putfh(xdr); |
05d564fe AA |
6367 | if (status) |
6368 | goto out; | |
bf269551 | 6369 | status = decode_open_confirm(xdr, res); |
1da177e4 | 6370 | out: |
05d564fe | 6371 | return status; |
1da177e4 LT |
6372 | } |
6373 | ||
6374 | /* | |
6375 | * Decode OPEN response | |
6376 | */ | |
bf269551 CL |
6377 | static int nfs4_xdr_dec_open_noattr(struct rpc_rqst *rqstp, |
6378 | struct xdr_stream *xdr, | |
6379 | struct nfs_openres *res) | |
1da177e4 | 6380 | { |
05d564fe AA |
6381 | struct compound_hdr hdr; |
6382 | int status; | |
6383 | ||
bf269551 | 6384 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc AA |
6385 | if (status) |
6386 | goto out; | |
bf269551 | 6387 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
05d564fe AA |
6388 | if (status) |
6389 | goto out; | |
bf269551 | 6390 | status = decode_putfh(xdr); |
05d564fe AA |
6391 | if (status) |
6392 | goto out; | |
bf269551 | 6393 | status = decode_open(xdr, res); |
05d564fe AA |
6394 | if (status) |
6395 | goto out; | |
ae2bb032 WAA |
6396 | if (res->access_request) |
6397 | decode_access(xdr, &res->access_supported, &res->access_result); | |
6926afd1 | 6398 | decode_getfattr(xdr, res->f_attr, res->server); |
1da177e4 | 6399 | out: |
05d564fe | 6400 | return status; |
1da177e4 LT |
6401 | } |
6402 | ||
6403 | /* | |
6404 | * Decode SETATTR response | |
6405 | */ | |
bf269551 CL |
6406 | static int nfs4_xdr_dec_setattr(struct rpc_rqst *rqstp, |
6407 | struct xdr_stream *xdr, | |
6408 | struct nfs_setattrres *res) | |
1da177e4 | 6409 | { |
05d564fe AA |
6410 | struct compound_hdr hdr; |
6411 | int status; | |
6412 | ||
bf269551 | 6413 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc AA |
6414 | if (status) |
6415 | goto out; | |
bf269551 | 6416 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
05d564fe AA |
6417 | if (status) |
6418 | goto out; | |
bf269551 | 6419 | status = decode_putfh(xdr); |
05d564fe AA |
6420 | if (status) |
6421 | goto out; | |
bf269551 | 6422 | status = decode_setattr(xdr); |
05d564fe AA |
6423 | if (status) |
6424 | goto out; | |
aa9c2669 | 6425 | decode_getfattr_label(xdr, res->fattr, res->label, res->server); |
1da177e4 | 6426 | out: |
05d564fe | 6427 | return status; |
1da177e4 LT |
6428 | } |
6429 | ||
6430 | /* | |
6431 | * Decode LOCK response | |
6432 | */ | |
bf269551 CL |
6433 | static int nfs4_xdr_dec_lock(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
6434 | struct nfs_lock_res *res) | |
1da177e4 | 6435 | { |
1da177e4 LT |
6436 | struct compound_hdr hdr; |
6437 | int status; | |
6438 | ||
bf269551 | 6439 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc AA |
6440 | if (status) |
6441 | goto out; | |
bf269551 | 6442 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
1da177e4 LT |
6443 | if (status) |
6444 | goto out; | |
bf269551 | 6445 | status = decode_putfh(xdr); |
1da177e4 LT |
6446 | if (status) |
6447 | goto out; | |
bf269551 | 6448 | status = decode_lock(xdr, res); |
1da177e4 LT |
6449 | out: |
6450 | return status; | |
6451 | } | |
6452 | ||
6453 | /* | |
6454 | * Decode LOCKT response | |
6455 | */ | |
bf269551 CL |
6456 | static int nfs4_xdr_dec_lockt(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
6457 | struct nfs_lockt_res *res) | |
1da177e4 | 6458 | { |
1da177e4 LT |
6459 | struct compound_hdr hdr; |
6460 | int status; | |
6461 | ||
bf269551 | 6462 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc AA |
6463 | if (status) |
6464 | goto out; | |
bf269551 | 6465 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
1da177e4 LT |
6466 | if (status) |
6467 | goto out; | |
bf269551 | 6468 | status = decode_putfh(xdr); |
1da177e4 LT |
6469 | if (status) |
6470 | goto out; | |
bf269551 | 6471 | status = decode_lockt(xdr, res); |
1da177e4 LT |
6472 | out: |
6473 | return status; | |
6474 | } | |
6475 | ||
6476 | /* | |
6477 | * Decode LOCKU response | |
6478 | */ | |
bf269551 CL |
6479 | static int nfs4_xdr_dec_locku(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
6480 | struct nfs_locku_res *res) | |
1da177e4 | 6481 | { |
1da177e4 LT |
6482 | struct compound_hdr hdr; |
6483 | int status; | |
6484 | ||
bf269551 | 6485 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc AA |
6486 | if (status) |
6487 | goto out; | |
bf269551 | 6488 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
1da177e4 LT |
6489 | if (status) |
6490 | goto out; | |
bf269551 | 6491 | status = decode_putfh(xdr); |
1da177e4 LT |
6492 | if (status) |
6493 | goto out; | |
bf269551 | 6494 | status = decode_locku(xdr, res); |
1da177e4 LT |
6495 | out: |
6496 | return status; | |
6497 | } | |
6498 | ||
bf269551 CL |
6499 | static int nfs4_xdr_dec_release_lockowner(struct rpc_rqst *rqstp, |
6500 | struct xdr_stream *xdr, void *dummy) | |
d3c7b7cc | 6501 | { |
d3c7b7cc TM |
6502 | struct compound_hdr hdr; |
6503 | int status; | |
6504 | ||
bf269551 | 6505 | status = decode_compound_hdr(xdr, &hdr); |
d3c7b7cc | 6506 | if (!status) |
bf269551 | 6507 | status = decode_release_lockowner(xdr); |
d3c7b7cc TM |
6508 | return status; |
6509 | } | |
6510 | ||
1da177e4 LT |
6511 | /* |
6512 | * Decode READLINK response | |
6513 | */ | |
bf269551 CL |
6514 | static int nfs4_xdr_dec_readlink(struct rpc_rqst *rqstp, |
6515 | struct xdr_stream *xdr, | |
f50c7000 | 6516 | struct nfs4_readlink_res *res) |
1da177e4 | 6517 | { |
1da177e4 LT |
6518 | struct compound_hdr hdr; |
6519 | int status; | |
6520 | ||
bf269551 | 6521 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc AA |
6522 | if (status) |
6523 | goto out; | |
bf269551 | 6524 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
1da177e4 LT |
6525 | if (status) |
6526 | goto out; | |
bf269551 | 6527 | status = decode_putfh(xdr); |
1da177e4 LT |
6528 | if (status) |
6529 | goto out; | |
bf269551 | 6530 | status = decode_readlink(xdr, rqstp); |
1da177e4 LT |
6531 | out: |
6532 | return status; | |
6533 | } | |
6534 | ||
6535 | /* | |
6536 | * Decode READDIR response | |
6537 | */ | |
bf269551 CL |
6538 | static int nfs4_xdr_dec_readdir(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
6539 | struct nfs4_readdir_res *res) | |
1da177e4 | 6540 | { |
1da177e4 LT |
6541 | struct compound_hdr hdr; |
6542 | int status; | |
6543 | ||
bf269551 | 6544 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc AA |
6545 | if (status) |
6546 | goto out; | |
bf269551 | 6547 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
1da177e4 LT |
6548 | if (status) |
6549 | goto out; | |
bf269551 | 6550 | status = decode_putfh(xdr); |
1da177e4 LT |
6551 | if (status) |
6552 | goto out; | |
bf269551 | 6553 | status = decode_readdir(xdr, rqstp, res); |
1da177e4 LT |
6554 | out: |
6555 | return status; | |
6556 | } | |
6557 | ||
6558 | /* | |
6559 | * Decode Read response | |
6560 | */ | |
bf269551 | 6561 | static int nfs4_xdr_dec_read(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
9137bdf3 | 6562 | struct nfs_pgio_res *res) |
1da177e4 | 6563 | { |
1da177e4 LT |
6564 | struct compound_hdr hdr; |
6565 | int status; | |
6566 | ||
bf269551 | 6567 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc AA |
6568 | if (status) |
6569 | goto out; | |
bf269551 | 6570 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
1da177e4 LT |
6571 | if (status) |
6572 | goto out; | |
bf269551 | 6573 | status = decode_putfh(xdr); |
1da177e4 LT |
6574 | if (status) |
6575 | goto out; | |
bf269551 | 6576 | status = decode_read(xdr, rqstp, res); |
1da177e4 LT |
6577 | if (!status) |
6578 | status = res->count; | |
6579 | out: | |
6580 | return status; | |
6581 | } | |
6582 | ||
6583 | /* | |
6584 | * Decode WRITE response | |
6585 | */ | |
bf269551 | 6586 | static int nfs4_xdr_dec_write(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
9137bdf3 | 6587 | struct nfs_pgio_res *res) |
1da177e4 | 6588 | { |
1da177e4 LT |
6589 | struct compound_hdr hdr; |
6590 | int status; | |
6591 | ||
bf269551 | 6592 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc AA |
6593 | if (status) |
6594 | goto out; | |
bf269551 | 6595 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
1da177e4 LT |
6596 | if (status) |
6597 | goto out; | |
bf269551 | 6598 | status = decode_putfh(xdr); |
1da177e4 LT |
6599 | if (status) |
6600 | goto out; | |
bf269551 | 6601 | status = decode_write(xdr, res); |
4f9838c7 TM |
6602 | if (status) |
6603 | goto out; | |
7ffd1064 | 6604 | if (res->fattr) |
6926afd1 | 6605 | decode_getfattr(xdr, res->fattr, res->server); |
1da177e4 LT |
6606 | if (!status) |
6607 | status = res->count; | |
6608 | out: | |
6609 | return status; | |
6610 | } | |
6611 | ||
6612 | /* | |
6613 | * Decode COMMIT response | |
6614 | */ | |
bf269551 | 6615 | static int nfs4_xdr_dec_commit(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
0b7c0153 | 6616 | struct nfs_commitres *res) |
1da177e4 | 6617 | { |
1da177e4 LT |
6618 | struct compound_hdr hdr; |
6619 | int status; | |
6620 | ||
bf269551 | 6621 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc AA |
6622 | if (status) |
6623 | goto out; | |
bf269551 | 6624 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
1da177e4 LT |
6625 | if (status) |
6626 | goto out; | |
bf269551 | 6627 | status = decode_putfh(xdr); |
1da177e4 LT |
6628 | if (status) |
6629 | goto out; | |
bf269551 | 6630 | status = decode_commit(xdr, res); |
1da177e4 LT |
6631 | out: |
6632 | return status; | |
6633 | } | |
6634 | ||
6635 | /* | |
8b173218 | 6636 | * Decode FSINFO response |
1da177e4 | 6637 | */ |
bf269551 | 6638 | static int nfs4_xdr_dec_fsinfo(struct rpc_rqst *req, struct xdr_stream *xdr, |
3dda5e43 | 6639 | struct nfs4_fsinfo_res *res) |
1da177e4 | 6640 | { |
1da177e4 LT |
6641 | struct compound_hdr hdr; |
6642 | int status; | |
6643 | ||
bf269551 | 6644 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc | 6645 | if (!status) |
bf269551 | 6646 | status = decode_sequence(xdr, &res->seq_res, req); |
1da177e4 | 6647 | if (!status) |
bf269551 | 6648 | status = decode_putfh(xdr); |
1da177e4 | 6649 | if (!status) |
bf269551 | 6650 | status = decode_fsinfo(xdr, res->fsinfo); |
1da177e4 LT |
6651 | return status; |
6652 | } | |
6653 | ||
6654 | /* | |
8b173218 | 6655 | * Decode PATHCONF response |
1da177e4 | 6656 | */ |
bf269551 | 6657 | static int nfs4_xdr_dec_pathconf(struct rpc_rqst *req, struct xdr_stream *xdr, |
d45b2989 | 6658 | struct nfs4_pathconf_res *res) |
1da177e4 | 6659 | { |
1da177e4 LT |
6660 | struct compound_hdr hdr; |
6661 | int status; | |
6662 | ||
bf269551 | 6663 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc | 6664 | if (!status) |
bf269551 | 6665 | status = decode_sequence(xdr, &res->seq_res, req); |
1da177e4 | 6666 | if (!status) |
bf269551 | 6667 | status = decode_putfh(xdr); |
1da177e4 | 6668 | if (!status) |
bf269551 | 6669 | status = decode_pathconf(xdr, res->pathconf); |
1da177e4 LT |
6670 | return status; |
6671 | } | |
6672 | ||
6673 | /* | |
8b173218 | 6674 | * Decode STATFS response |
1da177e4 | 6675 | */ |
bf269551 | 6676 | static int nfs4_xdr_dec_statfs(struct rpc_rqst *req, struct xdr_stream *xdr, |
24ad148a | 6677 | struct nfs4_statfs_res *res) |
1da177e4 | 6678 | { |
1da177e4 LT |
6679 | struct compound_hdr hdr; |
6680 | int status; | |
6681 | ||
bf269551 | 6682 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc | 6683 | if (!status) |
bf269551 | 6684 | status = decode_sequence(xdr, &res->seq_res, req); |
1da177e4 | 6685 | if (!status) |
bf269551 | 6686 | status = decode_putfh(xdr); |
1da177e4 | 6687 | if (!status) |
bf269551 | 6688 | status = decode_statfs(xdr, res->fsstat); |
1da177e4 LT |
6689 | return status; |
6690 | } | |
6691 | ||
6692 | /* | |
8b173218 | 6693 | * Decode GETATTR_BITMAP response |
1da177e4 | 6694 | */ |
bf269551 CL |
6695 | static int nfs4_xdr_dec_server_caps(struct rpc_rqst *req, |
6696 | struct xdr_stream *xdr, | |
6697 | struct nfs4_server_caps_res *res) | |
1da177e4 | 6698 | { |
1da177e4 LT |
6699 | struct compound_hdr hdr; |
6700 | int status; | |
6701 | ||
bf269551 | 6702 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc AA |
6703 | if (status) |
6704 | goto out; | |
bf269551 | 6705 | status = decode_sequence(xdr, &res->seq_res, req); |
9b7b9fcc | 6706 | if (status) |
1da177e4 | 6707 | goto out; |
bf269551 CL |
6708 | status = decode_putfh(xdr); |
6709 | if (status) | |
1da177e4 | 6710 | goto out; |
bf269551 | 6711 | status = decode_server_caps(xdr, res); |
1da177e4 LT |
6712 | out: |
6713 | return status; | |
6714 | } | |
6715 | ||
6716 | /* | |
6717 | * Decode RENEW response | |
6718 | */ | |
bf269551 CL |
6719 | static int nfs4_xdr_dec_renew(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
6720 | void *__unused) | |
1da177e4 | 6721 | { |
1da177e4 LT |
6722 | struct compound_hdr hdr; |
6723 | int status; | |
6724 | ||
bf269551 | 6725 | status = decode_compound_hdr(xdr, &hdr); |
1da177e4 | 6726 | if (!status) |
bf269551 | 6727 | status = decode_renew(xdr); |
1da177e4 LT |
6728 | return status; |
6729 | } | |
6730 | ||
6731 | /* | |
8b173218 | 6732 | * Decode SETCLIENTID response |
1da177e4 | 6733 | */ |
bf269551 CL |
6734 | static int nfs4_xdr_dec_setclientid(struct rpc_rqst *req, |
6735 | struct xdr_stream *xdr, | |
6736 | struct nfs4_setclientid_res *res) | |
1da177e4 | 6737 | { |
1da177e4 LT |
6738 | struct compound_hdr hdr; |
6739 | int status; | |
6740 | ||
bf269551 | 6741 | status = decode_compound_hdr(xdr, &hdr); |
1da177e4 | 6742 | if (!status) |
bf269551 | 6743 | status = decode_setclientid(xdr, res); |
1da177e4 LT |
6744 | return status; |
6745 | } | |
6746 | ||
6747 | /* | |
8b173218 | 6748 | * Decode SETCLIENTID_CONFIRM response |
1da177e4 | 6749 | */ |
bf269551 | 6750 | static int nfs4_xdr_dec_setclientid_confirm(struct rpc_rqst *req, |
83ca7f5a | 6751 | struct xdr_stream *xdr) |
1da177e4 | 6752 | { |
1da177e4 LT |
6753 | struct compound_hdr hdr; |
6754 | int status; | |
6755 | ||
bf269551 | 6756 | status = decode_compound_hdr(xdr, &hdr); |
1da177e4 | 6757 | if (!status) |
bf269551 | 6758 | status = decode_setclientid_confirm(xdr); |
1da177e4 LT |
6759 | return status; |
6760 | } | |
6761 | ||
6762 | /* | |
8b173218 | 6763 | * Decode DELEGRETURN response |
1da177e4 | 6764 | */ |
bf269551 CL |
6765 | static int nfs4_xdr_dec_delegreturn(struct rpc_rqst *rqstp, |
6766 | struct xdr_stream *xdr, | |
6767 | struct nfs4_delegreturnres *res) | |
1da177e4 | 6768 | { |
1da177e4 LT |
6769 | struct compound_hdr hdr; |
6770 | int status; | |
6771 | ||
bf269551 | 6772 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc AA |
6773 | if (status) |
6774 | goto out; | |
bf269551 | 6775 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
9b7b9fcc | 6776 | if (status) |
fa178f29 | 6777 | goto out; |
bf269551 | 6778 | status = decode_putfh(xdr); |
fa178f29 TM |
6779 | if (status != 0) |
6780 | goto out; | |
e144cbcc | 6781 | status = decode_getfattr(xdr, res->fattr, res->server); |
556ae3bb JL |
6782 | if (status != 0) |
6783 | goto out; | |
e144cbcc | 6784 | status = decode_delegreturn(xdr); |
fa178f29 | 6785 | out: |
1da177e4 LT |
6786 | return status; |
6787 | } | |
6788 | ||
683b57b4 | 6789 | /* |
8b173218 | 6790 | * Decode FS_LOCATIONS response |
683b57b4 | 6791 | */ |
bf269551 CL |
6792 | static int nfs4_xdr_dec_fs_locations(struct rpc_rqst *req, |
6793 | struct xdr_stream *xdr, | |
22958463 | 6794 | struct nfs4_fs_locations_res *res) |
683b57b4 | 6795 | { |
683b57b4 TM |
6796 | struct compound_hdr hdr; |
6797 | int status; | |
6798 | ||
bf269551 | 6799 | status = decode_compound_hdr(xdr, &hdr); |
9b7b9fcc AA |
6800 | if (status) |
6801 | goto out; | |
bf269551 | 6802 | status = decode_sequence(xdr, &res->seq_res, req); |
9b7b9fcc | 6803 | if (status) |
683b57b4 | 6804 | goto out; |
bf269551 CL |
6805 | status = decode_putfh(xdr); |
6806 | if (status) | |
683b57b4 | 6807 | goto out; |
b03d735b CL |
6808 | if (res->migration) { |
6809 | xdr_enter_page(xdr, PAGE_SIZE); | |
6810 | status = decode_getfattr_generic(xdr, | |
6811 | &res->fs_locations->fattr, | |
8b7e3f49 | 6812 | NULL, res->fs_locations, |
aa9c2669 | 6813 | NULL, res->fs_locations->server); |
b03d735b CL |
6814 | if (status) |
6815 | goto out; | |
6816 | if (res->renew) | |
6817 | status = decode_renew(xdr); | |
6818 | } else { | |
6819 | status = decode_lookup(xdr); | |
6820 | if (status) | |
6821 | goto out; | |
6822 | xdr_enter_page(xdr, PAGE_SIZE); | |
6823 | status = decode_getfattr_generic(xdr, | |
6824 | &res->fs_locations->fattr, | |
6825 | NULL, res->fs_locations, | |
6826 | NULL, res->fs_locations->server); | |
6827 | } | |
683b57b4 TM |
6828 | out: |
6829 | return status; | |
6830 | } | |
6831 | ||
5a5ea0d4 BS |
6832 | /* |
6833 | * Decode SECINFO response | |
6834 | */ | |
6835 | static int nfs4_xdr_dec_secinfo(struct rpc_rqst *rqstp, | |
6836 | struct xdr_stream *xdr, | |
6837 | struct nfs4_secinfo_res *res) | |
6838 | { | |
6839 | struct compound_hdr hdr; | |
6840 | int status; | |
6841 | ||
6842 | status = decode_compound_hdr(xdr, &hdr); | |
6843 | if (status) | |
6844 | goto out; | |
6845 | status = decode_sequence(xdr, &res->seq_res, rqstp); | |
6846 | if (status) | |
6847 | goto out; | |
6848 | status = decode_putfh(xdr); | |
6849 | if (status) | |
6850 | goto out; | |
6851 | status = decode_secinfo(xdr, res); | |
5a5ea0d4 BS |
6852 | out: |
6853 | return status; | |
6854 | } | |
6855 | ||
44c99933 CL |
6856 | /* |
6857 | * Decode FSID_PRESENT response | |
6858 | */ | |
6859 | static int nfs4_xdr_dec_fsid_present(struct rpc_rqst *rqstp, | |
6860 | struct xdr_stream *xdr, | |
6861 | struct nfs4_fsid_present_res *res) | |
6862 | { | |
6863 | struct compound_hdr hdr; | |
6864 | int status; | |
6865 | ||
6866 | status = decode_compound_hdr(xdr, &hdr); | |
6867 | if (status) | |
6868 | goto out; | |
6869 | status = decode_sequence(xdr, &res->seq_res, rqstp); | |
6870 | if (status) | |
6871 | goto out; | |
6872 | status = decode_putfh(xdr); | |
6873 | if (status) | |
6874 | goto out; | |
6875 | status = decode_getfh(xdr, res->fh); | |
6876 | if (status) | |
6877 | goto out; | |
6878 | if (res->renew) | |
6879 | status = decode_renew(xdr); | |
6880 | out: | |
6881 | return status; | |
6882 | } | |
6883 | ||
99fe60d0 | 6884 | #if defined(CONFIG_NFS_V4_1) |
7c44f1ae WAA |
6885 | /* |
6886 | * Decode BIND_CONN_TO_SESSION response | |
6887 | */ | |
6888 | static int nfs4_xdr_dec_bind_conn_to_session(struct rpc_rqst *rqstp, | |
6889 | struct xdr_stream *xdr, | |
6890 | void *res) | |
6891 | { | |
6892 | struct compound_hdr hdr; | |
6893 | int status; | |
6894 | ||
6895 | status = decode_compound_hdr(xdr, &hdr); | |
6896 | if (!status) | |
6897 | status = decode_bind_conn_to_session(xdr, res); | |
6898 | return status; | |
6899 | } | |
6900 | ||
99fe60d0 | 6901 | /* |
8b173218 | 6902 | * Decode EXCHANGE_ID response |
99fe60d0 | 6903 | */ |
bf269551 CL |
6904 | static int nfs4_xdr_dec_exchange_id(struct rpc_rqst *rqstp, |
6905 | struct xdr_stream *xdr, | |
99fe60d0 BH |
6906 | void *res) |
6907 | { | |
99fe60d0 BH |
6908 | struct compound_hdr hdr; |
6909 | int status; | |
6910 | ||
bf269551 | 6911 | status = decode_compound_hdr(xdr, &hdr); |
99fe60d0 | 6912 | if (!status) |
bf269551 | 6913 | status = decode_exchange_id(xdr, res); |
99fe60d0 BH |
6914 | return status; |
6915 | } | |
2050f0cc | 6916 | |
fc931582 | 6917 | /* |
8b173218 | 6918 | * Decode CREATE_SESSION response |
fc931582 | 6919 | */ |
bf269551 CL |
6920 | static int nfs4_xdr_dec_create_session(struct rpc_rqst *rqstp, |
6921 | struct xdr_stream *xdr, | |
fc931582 AA |
6922 | struct nfs41_create_session_res *res) |
6923 | { | |
fc931582 AA |
6924 | struct compound_hdr hdr; |
6925 | int status; | |
6926 | ||
bf269551 | 6927 | status = decode_compound_hdr(xdr, &hdr); |
fc931582 | 6928 | if (!status) |
bf269551 | 6929 | status = decode_create_session(xdr, res); |
fc931582 AA |
6930 | return status; |
6931 | } | |
6932 | ||
0f3e66c6 | 6933 | /* |
8b173218 | 6934 | * Decode DESTROY_SESSION response |
0f3e66c6 | 6935 | */ |
bf269551 CL |
6936 | static int nfs4_xdr_dec_destroy_session(struct rpc_rqst *rqstp, |
6937 | struct xdr_stream *xdr, | |
6938 | void *res) | |
0f3e66c6 | 6939 | { |
0f3e66c6 AA |
6940 | struct compound_hdr hdr; |
6941 | int status; | |
6942 | ||
bf269551 | 6943 | status = decode_compound_hdr(xdr, &hdr); |
0f3e66c6 | 6944 | if (!status) |
bf269551 | 6945 | status = decode_destroy_session(xdr, res); |
0f3e66c6 AA |
6946 | return status; |
6947 | } | |
6948 | ||
66245539 TM |
6949 | /* |
6950 | * Decode DESTROY_CLIENTID response | |
6951 | */ | |
6952 | static int nfs4_xdr_dec_destroy_clientid(struct rpc_rqst *rqstp, | |
6953 | struct xdr_stream *xdr, | |
6954 | void *res) | |
6955 | { | |
6956 | struct compound_hdr hdr; | |
6957 | int status; | |
6958 | ||
6959 | status = decode_compound_hdr(xdr, &hdr); | |
6960 | if (!status) | |
6961 | status = decode_destroy_clientid(xdr, res); | |
6962 | return status; | |
6963 | } | |
6964 | ||
fc01cea9 | 6965 | /* |
8b173218 | 6966 | * Decode SEQUENCE response |
fc01cea9 | 6967 | */ |
bf269551 CL |
6968 | static int nfs4_xdr_dec_sequence(struct rpc_rqst *rqstp, |
6969 | struct xdr_stream *xdr, | |
fc01cea9 AA |
6970 | struct nfs4_sequence_res *res) |
6971 | { | |
fc01cea9 AA |
6972 | struct compound_hdr hdr; |
6973 | int status; | |
6974 | ||
bf269551 | 6975 | status = decode_compound_hdr(xdr, &hdr); |
fc01cea9 | 6976 | if (!status) |
bf269551 | 6977 | status = decode_sequence(xdr, res, rqstp); |
fc01cea9 AA |
6978 | return status; |
6979 | } | |
6980 | ||
2050f0cc | 6981 | /* |
8b173218 | 6982 | * Decode GET_LEASE_TIME response |
2050f0cc | 6983 | */ |
bf269551 CL |
6984 | static int nfs4_xdr_dec_get_lease_time(struct rpc_rqst *rqstp, |
6985 | struct xdr_stream *xdr, | |
2050f0cc AA |
6986 | struct nfs4_get_lease_time_res *res) |
6987 | { | |
2050f0cc AA |
6988 | struct compound_hdr hdr; |
6989 | int status; | |
6990 | ||
bf269551 | 6991 | status = decode_compound_hdr(xdr, &hdr); |
2050f0cc | 6992 | if (!status) |
bf269551 | 6993 | status = decode_sequence(xdr, &res->lr_seq_res, rqstp); |
2050f0cc | 6994 | if (!status) |
bf269551 | 6995 | status = decode_putrootfh(xdr); |
2050f0cc | 6996 | if (!status) |
bf269551 | 6997 | status = decode_fsinfo(xdr, res->lr_fsinfo); |
2050f0cc AA |
6998 | return status; |
6999 | } | |
18019753 RL |
7000 | |
7001 | /* | |
7002 | * Decode RECLAIM_COMPLETE response | |
7003 | */ | |
bf269551 CL |
7004 | static int nfs4_xdr_dec_reclaim_complete(struct rpc_rqst *rqstp, |
7005 | struct xdr_stream *xdr, | |
18019753 RL |
7006 | struct nfs41_reclaim_complete_res *res) |
7007 | { | |
18019753 RL |
7008 | struct compound_hdr hdr; |
7009 | int status; | |
7010 | ||
bf269551 | 7011 | status = decode_compound_hdr(xdr, &hdr); |
18019753 | 7012 | if (!status) |
bf269551 | 7013 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
18019753 | 7014 | if (!status) |
8ee2b78a | 7015 | status = decode_reclaim_complete(xdr, NULL); |
18019753 RL |
7016 | return status; |
7017 | } | |
b1f69b75 AA |
7018 | |
7019 | /* | |
7020 | * Decode GETDEVINFO response | |
7021 | */ | |
bf269551 CL |
7022 | static int nfs4_xdr_dec_getdeviceinfo(struct rpc_rqst *rqstp, |
7023 | struct xdr_stream *xdr, | |
b1f69b75 AA |
7024 | struct nfs4_getdeviceinfo_res *res) |
7025 | { | |
b1f69b75 AA |
7026 | struct compound_hdr hdr; |
7027 | int status; | |
7028 | ||
bf269551 | 7029 | status = decode_compound_hdr(xdr, &hdr); |
b1f69b75 AA |
7030 | if (status != 0) |
7031 | goto out; | |
bf269551 | 7032 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
b1f69b75 AA |
7033 | if (status != 0) |
7034 | goto out; | |
bf269551 | 7035 | status = decode_getdeviceinfo(xdr, res->pdev); |
b1f69b75 AA |
7036 | out: |
7037 | return status; | |
7038 | } | |
7039 | ||
7040 | /* | |
7041 | * Decode LAYOUTGET response | |
7042 | */ | |
bf269551 CL |
7043 | static int nfs4_xdr_dec_layoutget(struct rpc_rqst *rqstp, |
7044 | struct xdr_stream *xdr, | |
b1f69b75 AA |
7045 | struct nfs4_layoutget_res *res) |
7046 | { | |
b1f69b75 AA |
7047 | struct compound_hdr hdr; |
7048 | int status; | |
7049 | ||
bf269551 | 7050 | status = decode_compound_hdr(xdr, &hdr); |
b1f69b75 AA |
7051 | if (status) |
7052 | goto out; | |
bf269551 | 7053 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
b1f69b75 AA |
7054 | if (status) |
7055 | goto out; | |
bf269551 | 7056 | status = decode_putfh(xdr); |
b1f69b75 AA |
7057 | if (status) |
7058 | goto out; | |
bf269551 | 7059 | status = decode_layoutget(xdr, rqstp, res); |
b1f69b75 AA |
7060 | out: |
7061 | return status; | |
7062 | } | |
863a3c6c | 7063 | |
cbe82603 BH |
7064 | /* |
7065 | * Decode LAYOUTRETURN response | |
7066 | */ | |
7067 | static int nfs4_xdr_dec_layoutreturn(struct rpc_rqst *rqstp, | |
7068 | struct xdr_stream *xdr, | |
7069 | struct nfs4_layoutreturn_res *res) | |
7070 | { | |
7071 | struct compound_hdr hdr; | |
7072 | int status; | |
7073 | ||
7074 | status = decode_compound_hdr(xdr, &hdr); | |
7075 | if (status) | |
7076 | goto out; | |
7077 | status = decode_sequence(xdr, &res->seq_res, rqstp); | |
7078 | if (status) | |
7079 | goto out; | |
7080 | status = decode_putfh(xdr); | |
7081 | if (status) | |
7082 | goto out; | |
7083 | status = decode_layoutreturn(xdr, res); | |
7084 | out: | |
7085 | return status; | |
7086 | } | |
7087 | ||
863a3c6c AA |
7088 | /* |
7089 | * Decode LAYOUTCOMMIT response | |
7090 | */ | |
7091 | static int nfs4_xdr_dec_layoutcommit(struct rpc_rqst *rqstp, | |
7092 | struct xdr_stream *xdr, | |
7093 | struct nfs4_layoutcommit_res *res) | |
7094 | { | |
7095 | struct compound_hdr hdr; | |
7096 | int status; | |
7097 | ||
7098 | status = decode_compound_hdr(xdr, &hdr); | |
7099 | if (status) | |
7100 | goto out; | |
7101 | status = decode_sequence(xdr, &res->seq_res, rqstp); | |
7102 | if (status) | |
7103 | goto out; | |
7104 | status = decode_putfh(xdr); | |
7105 | if (status) | |
7106 | goto out; | |
7107 | status = decode_layoutcommit(xdr, rqstp, res); | |
7108 | if (status) | |
7109 | goto out; | |
6926afd1 | 7110 | decode_getfattr(xdr, res->fattr, res->server); |
863a3c6c AA |
7111 | out: |
7112 | return status; | |
7113 | } | |
fca78d6d BS |
7114 | |
7115 | /* | |
7116 | * Decode SECINFO_NO_NAME response | |
7117 | */ | |
7118 | static int nfs4_xdr_dec_secinfo_no_name(struct rpc_rqst *rqstp, | |
7119 | struct xdr_stream *xdr, | |
7120 | struct nfs4_secinfo_res *res) | |
7121 | { | |
7122 | struct compound_hdr hdr; | |
7123 | int status; | |
7124 | ||
7125 | status = decode_compound_hdr(xdr, &hdr); | |
7126 | if (status) | |
7127 | goto out; | |
7128 | status = decode_sequence(xdr, &res->seq_res, rqstp); | |
7129 | if (status) | |
7130 | goto out; | |
7131 | status = decode_putrootfh(xdr); | |
7132 | if (status) | |
7133 | goto out; | |
31e4dda4 | 7134 | status = decode_secinfo_no_name(xdr, res); |
fca78d6d BS |
7135 | out: |
7136 | return status; | |
7137 | } | |
7d974794 BS |
7138 | |
7139 | /* | |
7140 | * Decode TEST_STATEID response | |
7141 | */ | |
7142 | static int nfs4_xdr_dec_test_stateid(struct rpc_rqst *rqstp, | |
7143 | struct xdr_stream *xdr, | |
7144 | struct nfs41_test_stateid_res *res) | |
7145 | { | |
7146 | struct compound_hdr hdr; | |
7147 | int status; | |
7148 | ||
7149 | status = decode_compound_hdr(xdr, &hdr); | |
7150 | if (status) | |
7151 | goto out; | |
7152 | status = decode_sequence(xdr, &res->seq_res, rqstp); | |
7153 | if (status) | |
7154 | goto out; | |
7155 | status = decode_test_stateid(xdr, res); | |
7156 | out: | |
7157 | return status; | |
7158 | } | |
9aeda35f BS |
7159 | |
7160 | /* | |
7161 | * Decode FREE_STATEID response | |
7162 | */ | |
7163 | static int nfs4_xdr_dec_free_stateid(struct rpc_rqst *rqstp, | |
7164 | struct xdr_stream *xdr, | |
7165 | struct nfs41_free_stateid_res *res) | |
7166 | { | |
7167 | struct compound_hdr hdr; | |
7168 | int status; | |
7169 | ||
7170 | status = decode_compound_hdr(xdr, &hdr); | |
7171 | if (status) | |
7172 | goto out; | |
7173 | status = decode_sequence(xdr, &res->seq_res, rqstp); | |
7174 | if (status) | |
7175 | goto out; | |
7176 | status = decode_free_stateid(xdr, res); | |
7177 | out: | |
7178 | return status; | |
7179 | } | |
99fe60d0 BH |
7180 | #endif /* CONFIG_NFS_V4_1 */ |
7181 | ||
573c4e1e CL |
7182 | /** |
7183 | * nfs4_decode_dirent - Decode a single NFSv4 directory entry stored in | |
7184 | * the local page cache. | |
7185 | * @xdr: XDR stream where entry resides | |
7186 | * @entry: buffer to fill in with entry data | |
7187 | * @plus: boolean indicating whether this should be a readdirplus entry | |
7188 | * | |
7189 | * Returns zero if successful, otherwise a negative errno value is | |
7190 | * returned. | |
7191 | * | |
7192 | * This function is not invoked during READDIR reply decoding, but | |
7193 | * rather whenever an application invokes the getdents(2) system call | |
7194 | * on a directory already in our cache. | |
7195 | */ | |
7196 | int nfs4_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, | |
7197 | int plus) | |
1da177e4 | 7198 | { |
256e48bb | 7199 | unsigned int savep; |
dae100c2 | 7200 | uint32_t bitmap[3] = {0}; |
1da177e4 | 7201 | uint32_t len; |
babddc72 BS |
7202 | __be32 *p = xdr_inline_decode(xdr, 4); |
7203 | if (unlikely(!p)) | |
7204 | goto out_overflow; | |
c08e76d0 | 7205 | if (*p == xdr_zero) { |
babddc72 BS |
7206 | p = xdr_inline_decode(xdr, 4); |
7207 | if (unlikely(!p)) | |
7208 | goto out_overflow; | |
c08e76d0 | 7209 | if (*p == xdr_zero) |
573c4e1e | 7210 | return -EAGAIN; |
1da177e4 | 7211 | entry->eof = 1; |
573c4e1e | 7212 | return -EBADCOOKIE; |
1da177e4 LT |
7213 | } |
7214 | ||
babddc72 BS |
7215 | p = xdr_inline_decode(xdr, 12); |
7216 | if (unlikely(!p)) | |
7217 | goto out_overflow; | |
1da177e4 LT |
7218 | entry->prev_cookie = entry->cookie; |
7219 | p = xdr_decode_hyper(p, &entry->cookie); | |
c08e76d0 | 7220 | entry->len = be32_to_cpup(p); |
babddc72 | 7221 | |
9af8c222 | 7222 | p = xdr_inline_decode(xdr, entry->len); |
babddc72 BS |
7223 | if (unlikely(!p)) |
7224 | goto out_overflow; | |
1da177e4 | 7225 | entry->name = (const char *) p; |
1da177e4 LT |
7226 | |
7227 | /* | |
7228 | * In case the server doesn't return an inode number, | |
7229 | * we fake one here. (We don't use inode number 0, | |
7230 | * since glibc seems to choke on it...) | |
7231 | */ | |
7232 | entry->ino = 1; | |
4f082222 | 7233 | entry->fattr->valid = 0; |
1da177e4 | 7234 | |
9af8c222 TM |
7235 | if (decode_attr_bitmap(xdr, bitmap) < 0) |
7236 | goto out_overflow; | |
7237 | ||
256e48bb | 7238 | if (decode_attr_length(xdr, &len, &savep) < 0) |
9af8c222 TM |
7239 | goto out_overflow; |
7240 | ||
573c4e1e | 7241 | if (decode_getfattr_attrs(xdr, bitmap, entry->fattr, entry->fh, |
aa9c2669 | 7242 | NULL, entry->label, entry->server) < 0) |
9af8c222 | 7243 | goto out_overflow; |
28331a46 TM |
7244 | if (entry->fattr->valid & NFS_ATTR_FATTR_MOUNTED_ON_FILEID) |
7245 | entry->ino = entry->fattr->mounted_on_fileid; | |
7246 | else if (entry->fattr->valid & NFS_ATTR_FATTR_FILEID) | |
9af8c222 TM |
7247 | entry->ino = entry->fattr->fileid; |
7248 | ||
0b26a0bf TM |
7249 | entry->d_type = DT_UNKNOWN; |
7250 | if (entry->fattr->valid & NFS_ATTR_FATTR_TYPE) | |
7251 | entry->d_type = nfs_umode_to_dtype(entry->fattr->mode); | |
7252 | ||
573c4e1e | 7253 | return 0; |
babddc72 BS |
7254 | |
7255 | out_overflow: | |
7256 | print_overflow_msg(__func__, xdr); | |
573c4e1e | 7257 | return -EAGAIN; |
1da177e4 LT |
7258 | } |
7259 | ||
7260 | /* | |
7261 | * We need to translate between nfs status return values and | |
7262 | * the local errno values which may not be the same. | |
7263 | */ | |
7264 | static struct { | |
7265 | int stat; | |
7266 | int errno; | |
7267 | } nfs_errtbl[] = { | |
7268 | { NFS4_OK, 0 }, | |
856dff3d BH |
7269 | { NFS4ERR_PERM, -EPERM }, |
7270 | { NFS4ERR_NOENT, -ENOENT }, | |
7271 | { NFS4ERR_IO, -errno_NFSERR_IO}, | |
7272 | { NFS4ERR_NXIO, -ENXIO }, | |
7273 | { NFS4ERR_ACCESS, -EACCES }, | |
7274 | { NFS4ERR_EXIST, -EEXIST }, | |
7275 | { NFS4ERR_XDEV, -EXDEV }, | |
7276 | { NFS4ERR_NOTDIR, -ENOTDIR }, | |
7277 | { NFS4ERR_ISDIR, -EISDIR }, | |
7278 | { NFS4ERR_INVAL, -EINVAL }, | |
7279 | { NFS4ERR_FBIG, -EFBIG }, | |
7280 | { NFS4ERR_NOSPC, -ENOSPC }, | |
7281 | { NFS4ERR_ROFS, -EROFS }, | |
7282 | { NFS4ERR_MLINK, -EMLINK }, | |
7283 | { NFS4ERR_NAMETOOLONG, -ENAMETOOLONG }, | |
7284 | { NFS4ERR_NOTEMPTY, -ENOTEMPTY }, | |
7285 | { NFS4ERR_DQUOT, -EDQUOT }, | |
7286 | { NFS4ERR_STALE, -ESTALE }, | |
7287 | { NFS4ERR_BADHANDLE, -EBADHANDLE }, | |
856dff3d BH |
7288 | { NFS4ERR_BAD_COOKIE, -EBADCOOKIE }, |
7289 | { NFS4ERR_NOTSUPP, -ENOTSUPP }, | |
7290 | { NFS4ERR_TOOSMALL, -ETOOSMALL }, | |
fdcb4577 | 7291 | { NFS4ERR_SERVERFAULT, -EREMOTEIO }, |
856dff3d BH |
7292 | { NFS4ERR_BADTYPE, -EBADTYPE }, |
7293 | { NFS4ERR_LOCKED, -EAGAIN }, | |
856dff3d BH |
7294 | { NFS4ERR_SYMLINK, -ELOOP }, |
7295 | { NFS4ERR_OP_ILLEGAL, -EOPNOTSUPP }, | |
7296 | { NFS4ERR_DEADLOCK, -EDEADLK }, | |
856dff3d | 7297 | { -1, -EIO } |
1da177e4 LT |
7298 | }; |
7299 | ||
7300 | /* | |
7301 | * Convert an NFS error code to a local one. | |
7302 | * This one is used jointly by NFSv2 and NFSv3. | |
7303 | */ | |
7304 | static int | |
0a8ea437 | 7305 | nfs4_stat_to_errno(int stat) |
1da177e4 LT |
7306 | { |
7307 | int i; | |
7308 | for (i = 0; nfs_errtbl[i].stat != -1; i++) { | |
7309 | if (nfs_errtbl[i].stat == stat) | |
7310 | return nfs_errtbl[i].errno; | |
7311 | } | |
7312 | if (stat <= 10000 || stat > 10100) { | |
7313 | /* The server is looney tunes. */ | |
fdcb4577 | 7314 | return -EREMOTEIO; |
1da177e4 LT |
7315 | } |
7316 | /* If we cannot translate the error, the recovery routines should | |
7317 | * handle it. | |
7318 | * Note: remaining NFSv4 error codes have values > 10000, so should | |
7319 | * not conflict with native Linux error codes. | |
7320 | */ | |
856dff3d | 7321 | return -stat; |
1da177e4 LT |
7322 | } |
7323 | ||
1c6dcbe5 AS |
7324 | #ifdef CONFIG_NFS_V4_2 |
7325 | #include "nfs42xdr.c" | |
7326 | #endif /* CONFIG_NFS_V4_2 */ | |
7327 | ||
1da177e4 LT |
7328 | #define PROC(proc, argtype, restype) \ |
7329 | [NFSPROC4_CLNT_##proc] = { \ | |
7330 | .p_proc = NFSPROC4_COMPOUND, \ | |
9f06c719 | 7331 | .p_encode = (kxdreproc_t)nfs4_xdr_##argtype, \ |
bf269551 | 7332 | .p_decode = (kxdrdproc_t)nfs4_xdr_##restype, \ |
2bea90d4 CL |
7333 | .p_arglen = NFS4_##argtype##_sz, \ |
7334 | .p_replen = NFS4_##restype##_sz, \ | |
cc0175c1 CL |
7335 | .p_statidx = NFSPROC4_CLNT_##proc, \ |
7336 | .p_name = #proc, \ | |
05d564fe | 7337 | } |
1da177e4 LT |
7338 | |
7339 | struct rpc_procinfo nfs4_procedures[] = { | |
7d93bd71 CL |
7340 | PROC(READ, enc_read, dec_read), |
7341 | PROC(WRITE, enc_write, dec_write), | |
7342 | PROC(COMMIT, enc_commit, dec_commit), | |
7343 | PROC(OPEN, enc_open, dec_open), | |
7344 | PROC(OPEN_CONFIRM, enc_open_confirm, dec_open_confirm), | |
7345 | PROC(OPEN_NOATTR, enc_open_noattr, dec_open_noattr), | |
7346 | PROC(OPEN_DOWNGRADE, enc_open_downgrade, dec_open_downgrade), | |
7347 | PROC(CLOSE, enc_close, dec_close), | |
7348 | PROC(SETATTR, enc_setattr, dec_setattr), | |
7349 | PROC(FSINFO, enc_fsinfo, dec_fsinfo), | |
7350 | PROC(RENEW, enc_renew, dec_renew), | |
7351 | PROC(SETCLIENTID, enc_setclientid, dec_setclientid), | |
7352 | PROC(SETCLIENTID_CONFIRM, enc_setclientid_confirm, dec_setclientid_confirm), | |
7353 | PROC(LOCK, enc_lock, dec_lock), | |
7354 | PROC(LOCKT, enc_lockt, dec_lockt), | |
7355 | PROC(LOCKU, enc_locku, dec_locku), | |
7356 | PROC(ACCESS, enc_access, dec_access), | |
7357 | PROC(GETATTR, enc_getattr, dec_getattr), | |
7358 | PROC(LOOKUP, enc_lookup, dec_lookup), | |
7359 | PROC(LOOKUP_ROOT, enc_lookup_root, dec_lookup_root), | |
7360 | PROC(REMOVE, enc_remove, dec_remove), | |
7361 | PROC(RENAME, enc_rename, dec_rename), | |
7362 | PROC(LINK, enc_link, dec_link), | |
7363 | PROC(SYMLINK, enc_symlink, dec_symlink), | |
7364 | PROC(CREATE, enc_create, dec_create), | |
7365 | PROC(PATHCONF, enc_pathconf, dec_pathconf), | |
7366 | PROC(STATFS, enc_statfs, dec_statfs), | |
7367 | PROC(READLINK, enc_readlink, dec_readlink), | |
7368 | PROC(READDIR, enc_readdir, dec_readdir), | |
7369 | PROC(SERVER_CAPS, enc_server_caps, dec_server_caps), | |
7370 | PROC(DELEGRETURN, enc_delegreturn, dec_delegreturn), | |
7371 | PROC(GETACL, enc_getacl, dec_getacl), | |
7372 | PROC(SETACL, enc_setacl, dec_setacl), | |
7373 | PROC(FS_LOCATIONS, enc_fs_locations, dec_fs_locations), | |
7374 | PROC(RELEASE_LOCKOWNER, enc_release_lockowner, dec_release_lockowner), | |
5a5ea0d4 | 7375 | PROC(SECINFO, enc_secinfo, dec_secinfo), |
44c99933 | 7376 | PROC(FSID_PRESENT, enc_fsid_present, dec_fsid_present), |
99fe60d0 | 7377 | #if defined(CONFIG_NFS_V4_1) |
7d93bd71 CL |
7378 | PROC(EXCHANGE_ID, enc_exchange_id, dec_exchange_id), |
7379 | PROC(CREATE_SESSION, enc_create_session, dec_create_session), | |
7380 | PROC(DESTROY_SESSION, enc_destroy_session, dec_destroy_session), | |
7381 | PROC(SEQUENCE, enc_sequence, dec_sequence), | |
7382 | PROC(GET_LEASE_TIME, enc_get_lease_time, dec_get_lease_time), | |
7383 | PROC(RECLAIM_COMPLETE, enc_reclaim_complete, dec_reclaim_complete), | |
7384 | PROC(GETDEVICEINFO, enc_getdeviceinfo, dec_getdeviceinfo), | |
7385 | PROC(LAYOUTGET, enc_layoutget, dec_layoutget), | |
863a3c6c | 7386 | PROC(LAYOUTCOMMIT, enc_layoutcommit, dec_layoutcommit), |
cbe82603 | 7387 | PROC(LAYOUTRETURN, enc_layoutreturn, dec_layoutreturn), |
fca78d6d | 7388 | PROC(SECINFO_NO_NAME, enc_secinfo_no_name, dec_secinfo_no_name), |
7d974794 | 7389 | PROC(TEST_STATEID, enc_test_stateid, dec_test_stateid), |
9aeda35f | 7390 | PROC(FREE_STATEID, enc_free_stateid, dec_free_stateid), |
ad24ecfb TM |
7391 | PROC(BIND_CONN_TO_SESSION, |
7392 | enc_bind_conn_to_session, dec_bind_conn_to_session), | |
66245539 | 7393 | PROC(DESTROY_CLIENTID, enc_destroy_clientid, dec_destroy_clientid), |
99fe60d0 | 7394 | #endif /* CONFIG_NFS_V4_1 */ |
1c6dcbe5 AS |
7395 | #ifdef CONFIG_NFS_V4_2 |
7396 | PROC(SEEK, enc_seek, dec_seek), | |
7397 | #endif /* CONFIG_NFS_V4_2 */ | |
1da177e4 LT |
7398 | }; |
7399 | ||
a613fa16 | 7400 | const struct rpc_version nfs_version4 = { |
1da177e4 | 7401 | .number = 4, |
e8c96f8c | 7402 | .nrprocs = ARRAY_SIZE(nfs4_procedures), |
1da177e4 LT |
7403 | .procs = nfs4_procedures |
7404 | }; | |
7405 | ||
7406 | /* | |
7407 | * Local variables: | |
7408 | * c-basic-offset: 8 | |
7409 | * End: | |
7410 | */ |