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