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