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