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