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