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