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