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