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