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