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