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