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