Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/fs/nfs/nfs2xdr.c |
| 3 | * |
| 4 | * XDR functions to encode/decode NFS RPC arguments and results. |
| 5 | * |
| 6 | * Copyright (C) 1992, 1993, 1994 Rick Sladkey |
| 7 | * Copyright (C) 1996 Olaf Kirch |
| 8 | * 04 Aug 1998 Ion Badulescu <ionut@cs.columbia.edu> |
| 9 | * FIFO's need special handling in NFSv2 |
| 10 | */ |
| 11 | |
| 12 | #include <linux/param.h> |
| 13 | #include <linux/time.h> |
| 14 | #include <linux/mm.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | #include <linux/errno.h> |
| 16 | #include <linux/string.h> |
| 17 | #include <linux/in.h> |
| 18 | #include <linux/pagemap.h> |
| 19 | #include <linux/proc_fs.h> |
| 20 | #include <linux/sunrpc/clnt.h> |
| 21 | #include <linux/nfs.h> |
| 22 | #include <linux/nfs2.h> |
| 23 | #include <linux/nfs_fs.h> |
Trond Myklebust | 816724e | 2006-06-24 08:41:41 -0400 | [diff] [blame] | 24 | #include "internal.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | |
| 26 | #define NFSDBG_FACILITY NFSDBG_XDR |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | /* Mapping from NFS error code to "errno" error code. */ |
| 29 | #define errno_NFSERR_IO EIO |
| 30 | |
| 31 | /* |
| 32 | * Declare the space requirements for NFS arguments and replies as |
| 33 | * number of 32bit-words |
| 34 | */ |
| 35 | #define NFS_fhandle_sz (8) |
| 36 | #define NFS_sattr_sz (8) |
| 37 | #define NFS_filename_sz (1+(NFS2_MAXNAMLEN>>2)) |
| 38 | #define NFS_path_sz (1+(NFS2_MAXPATHLEN>>2)) |
| 39 | #define NFS_fattr_sz (17) |
| 40 | #define NFS_info_sz (5) |
| 41 | #define NFS_entry_sz (NFS_filename_sz+3) |
| 42 | |
| 43 | #define NFS_diropargs_sz (NFS_fhandle_sz+NFS_filename_sz) |
Trond Myklebust | 4fdc17b | 2007-07-14 15:39:57 -0400 | [diff] [blame] | 44 | #define NFS_removeargs_sz (NFS_fhandle_sz+NFS_filename_sz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | #define NFS_sattrargs_sz (NFS_fhandle_sz+NFS_sattr_sz) |
| 46 | #define NFS_readlinkargs_sz (NFS_fhandle_sz) |
| 47 | #define NFS_readargs_sz (NFS_fhandle_sz+3) |
| 48 | #define NFS_writeargs_sz (NFS_fhandle_sz+4) |
| 49 | #define NFS_createargs_sz (NFS_diropargs_sz+NFS_sattr_sz) |
| 50 | #define NFS_renameargs_sz (NFS_diropargs_sz+NFS_diropargs_sz) |
| 51 | #define NFS_linkargs_sz (NFS_fhandle_sz+NFS_diropargs_sz) |
Chuck Lever | 94a6d75 | 2006-08-22 20:06:23 -0400 | [diff] [blame] | 52 | #define NFS_symlinkargs_sz (NFS_diropargs_sz+1+NFS_sattr_sz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | #define NFS_readdirargs_sz (NFS_fhandle_sz+2) |
| 54 | |
| 55 | #define NFS_attrstat_sz (1+NFS_fattr_sz) |
| 56 | #define NFS_diropres_sz (1+NFS_fhandle_sz+NFS_fattr_sz) |
| 57 | #define NFS_readlinkres_sz (2) |
| 58 | #define NFS_readres_sz (1+NFS_fattr_sz+1) |
| 59 | #define NFS_writeres_sz (NFS_attrstat_sz) |
| 60 | #define NFS_stat_sz (1) |
| 61 | #define NFS_readdirres_sz (1) |
| 62 | #define NFS_statfsres_sz (1+NFS_info_sz) |
| 63 | |
Chuck Lever | 25a0866 | 2010-12-14 14:54:30 +0000 | [diff] [blame^] | 64 | |
| 65 | /* |
| 66 | * While encoding arguments, set up the reply buffer in advance to |
| 67 | * receive reply data directly into the page cache. |
| 68 | */ |
| 69 | static void prepare_reply_buffer(struct rpc_rqst *req, struct page **pages, |
| 70 | unsigned int base, unsigned int len, |
| 71 | unsigned int bufsize) |
| 72 | { |
| 73 | struct rpc_auth *auth = req->rq_cred->cr_auth; |
| 74 | unsigned int replen; |
| 75 | |
| 76 | replen = RPC_REPHDRSIZE + auth->au_rslack + bufsize; |
| 77 | xdr_inline_pages(&req->rq_rcv_buf, replen << 2, pages, base, len); |
| 78 | } |
| 79 | |
| 80 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | /* |
| 82 | * Common NFS XDR functions as inlines |
| 83 | */ |
Al Viro | 9d787a7 | 2006-10-19 23:28:47 -0700 | [diff] [blame] | 84 | static inline __be32 * |
Trond Myklebust | 4fdc17b | 2007-07-14 15:39:57 -0400 | [diff] [blame] | 85 | xdr_encode_fhandle(__be32 *p, const struct nfs_fh *fhandle) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | { |
| 87 | memcpy(p, fhandle->data, NFS2_FHSIZE); |
| 88 | return p + XDR_QUADLEN(NFS2_FHSIZE); |
| 89 | } |
| 90 | |
Al Viro | 9d787a7 | 2006-10-19 23:28:47 -0700 | [diff] [blame] | 91 | static inline __be32 * |
| 92 | xdr_decode_fhandle(__be32 *p, struct nfs_fh *fhandle) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | { |
| 94 | /* NFSv2 handles have a fixed length */ |
| 95 | fhandle->size = NFS2_FHSIZE; |
| 96 | memcpy(fhandle->data, p, NFS2_FHSIZE); |
| 97 | return p + XDR_QUADLEN(NFS2_FHSIZE); |
| 98 | } |
| 99 | |
Al Viro | 9d787a7 | 2006-10-19 23:28:47 -0700 | [diff] [blame] | 100 | static inline __be32* |
Chuck Lever | 25a0866 | 2010-12-14 14:54:30 +0000 | [diff] [blame^] | 101 | xdr_encode_time(__be32 *p, const struct timespec *timep) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | { |
| 103 | *p++ = htonl(timep->tv_sec); |
| 104 | /* Convert nanoseconds into microseconds */ |
| 105 | *p++ = htonl(timep->tv_nsec ? timep->tv_nsec / 1000 : 0); |
| 106 | return p; |
| 107 | } |
| 108 | |
Al Viro | 9d787a7 | 2006-10-19 23:28:47 -0700 | [diff] [blame] | 109 | static inline __be32* |
Chuck Lever | 25a0866 | 2010-12-14 14:54:30 +0000 | [diff] [blame^] | 110 | xdr_encode_current_server_time(__be32 *p, const struct timespec *timep) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | { |
| 112 | /* |
| 113 | * Passing the invalid value useconds=1000000 is a |
| 114 | * Sun convention for "set to current server time". |
| 115 | * It's needed to make permissions checks for the |
| 116 | * "touch" program across v2 mounts to Solaris and |
| 117 | * Irix boxes work correctly. See description of |
| 118 | * sattr in section 6.1 of "NFS Illustrated" by |
| 119 | * Brent Callaghan, Addison-Wesley, ISBN 0-201-32750-5 |
| 120 | */ |
| 121 | *p++ = htonl(timep->tv_sec); |
| 122 | *p++ = htonl(1000000); |
| 123 | return p; |
| 124 | } |
| 125 | |
Al Viro | 9d787a7 | 2006-10-19 23:28:47 -0700 | [diff] [blame] | 126 | static inline __be32* |
| 127 | xdr_decode_time(__be32 *p, struct timespec *timep) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | { |
| 129 | timep->tv_sec = ntohl(*p++); |
| 130 | /* Convert microseconds into nanoseconds */ |
| 131 | timep->tv_nsec = ntohl(*p++) * 1000; |
| 132 | return p; |
| 133 | } |
| 134 | |
Al Viro | 9d787a7 | 2006-10-19 23:28:47 -0700 | [diff] [blame] | 135 | static __be32 * |
| 136 | xdr_decode_fattr(__be32 *p, struct nfs_fattr *fattr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | { |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 138 | u32 rdev, type; |
| 139 | type = ntohl(*p++); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | fattr->mode = ntohl(*p++); |
| 141 | fattr->nlink = ntohl(*p++); |
| 142 | fattr->uid = ntohl(*p++); |
| 143 | fattr->gid = ntohl(*p++); |
| 144 | fattr->size = ntohl(*p++); |
| 145 | fattr->du.nfs2.blocksize = ntohl(*p++); |
| 146 | rdev = ntohl(*p++); |
| 147 | fattr->du.nfs2.blocks = ntohl(*p++); |
Trond Myklebust | 8b4bdcf | 2006-06-09 09:34:19 -0400 | [diff] [blame] | 148 | fattr->fsid.major = ntohl(*p++); |
| 149 | fattr->fsid.minor = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 150 | fattr->fileid = ntohl(*p++); |
| 151 | p = xdr_decode_time(p, &fattr->atime); |
| 152 | p = xdr_decode_time(p, &fattr->mtime); |
| 153 | p = xdr_decode_time(p, &fattr->ctime); |
Trond Myklebust | 9e6e70f | 2009-03-11 14:10:24 -0400 | [diff] [blame] | 154 | fattr->valid |= NFS_ATTR_FATTR_V2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 | fattr->rdev = new_decode_dev(rdev); |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 156 | if (type == NFCHR && rdev == NFS2_FIFO_DEV) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | fattr->mode = (fattr->mode & ~S_IFMT) | S_IFIFO; |
| 158 | fattr->rdev = 0; |
| 159 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | return p; |
| 161 | } |
| 162 | |
Al Viro | 9d787a7 | 2006-10-19 23:28:47 -0700 | [diff] [blame] | 163 | static inline __be32 * |
| 164 | xdr_encode_sattr(__be32 *p, struct iattr *attr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 165 | { |
Al Viro | 9d787a7 | 2006-10-19 23:28:47 -0700 | [diff] [blame] | 166 | const __be32 not_set = __constant_htonl(0xFFFFFFFF); |
Trond Myklebust | eadb8c1 | 2006-01-03 09:55:54 +0100 | [diff] [blame] | 167 | |
| 168 | *p++ = (attr->ia_valid & ATTR_MODE) ? htonl(attr->ia_mode) : not_set; |
| 169 | *p++ = (attr->ia_valid & ATTR_UID) ? htonl(attr->ia_uid) : not_set; |
| 170 | *p++ = (attr->ia_valid & ATTR_GID) ? htonl(attr->ia_gid) : not_set; |
| 171 | *p++ = (attr->ia_valid & ATTR_SIZE) ? htonl(attr->ia_size) : not_set; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | |
| 173 | if (attr->ia_valid & ATTR_ATIME_SET) { |
| 174 | p = xdr_encode_time(p, &attr->ia_atime); |
| 175 | } else if (attr->ia_valid & ATTR_ATIME) { |
| 176 | p = xdr_encode_current_server_time(p, &attr->ia_atime); |
| 177 | } else { |
Trond Myklebust | eadb8c1 | 2006-01-03 09:55:54 +0100 | [diff] [blame] | 178 | *p++ = not_set; |
| 179 | *p++ = not_set; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | } |
| 181 | |
| 182 | if (attr->ia_valid & ATTR_MTIME_SET) { |
| 183 | p = xdr_encode_time(p, &attr->ia_mtime); |
| 184 | } else if (attr->ia_valid & ATTR_MTIME) { |
| 185 | p = xdr_encode_current_server_time(p, &attr->ia_mtime); |
| 186 | } else { |
Trond Myklebust | eadb8c1 | 2006-01-03 09:55:54 +0100 | [diff] [blame] | 187 | *p++ = not_set; |
| 188 | *p++ = not_set; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 | } |
| 190 | return p; |
| 191 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 192 | |
| 193 | /* |
Chuck Lever | 25a0866 | 2010-12-14 14:54:30 +0000 | [diff] [blame^] | 194 | * Encode/decode NFSv2 basic data types |
| 195 | * |
| 196 | * Basic NFSv2 data types are defined in section 2.3 of RFC 1094: |
| 197 | * "NFS: Network File System Protocol Specification". |
| 198 | * |
| 199 | * Not all basic data types have their own encoding and decoding |
| 200 | * functions. For run-time efficiency, some data types are encoded |
| 201 | * or decoded inline. |
| 202 | */ |
| 203 | |
| 204 | /* |
| 205 | * 2.3.3. fhandle |
| 206 | * |
| 207 | * typedef opaque fhandle[FHSIZE]; |
| 208 | */ |
| 209 | static void encode_fhandle(struct xdr_stream *xdr, const struct nfs_fh *fh) |
| 210 | { |
| 211 | __be32 *p; |
| 212 | |
| 213 | BUG_ON(fh->size != NFS2_FHSIZE); |
| 214 | p = xdr_reserve_space(xdr, NFS2_FHSIZE); |
| 215 | memcpy(p, fh->data, NFS2_FHSIZE); |
| 216 | } |
| 217 | |
| 218 | /* |
| 219 | * 2.3.6. sattr |
| 220 | * |
| 221 | * struct sattr { |
| 222 | * unsigned int mode; |
| 223 | * unsigned int uid; |
| 224 | * unsigned int gid; |
| 225 | * unsigned int size; |
| 226 | * timeval atime; |
| 227 | * timeval mtime; |
| 228 | * }; |
| 229 | */ |
| 230 | |
| 231 | #define NFS2_SATTR_NOT_SET (0xffffffff) |
| 232 | |
| 233 | static __be32 *xdr_time_not_set(__be32 *p) |
| 234 | { |
| 235 | *p++ = cpu_to_be32(NFS2_SATTR_NOT_SET); |
| 236 | *p++ = cpu_to_be32(NFS2_SATTR_NOT_SET); |
| 237 | return p; |
| 238 | } |
| 239 | |
| 240 | static void encode_sattr(struct xdr_stream *xdr, const struct iattr *attr) |
| 241 | { |
| 242 | __be32 *p; |
| 243 | |
| 244 | p = xdr_reserve_space(xdr, NFS_sattr_sz << 2); |
| 245 | |
| 246 | if (attr->ia_valid & ATTR_MODE) |
| 247 | *p++ = cpu_to_be32(attr->ia_mode); |
| 248 | else |
| 249 | *p++ = cpu_to_be32(NFS2_SATTR_NOT_SET); |
| 250 | if (attr->ia_valid & ATTR_UID) |
| 251 | *p++ = cpu_to_be32(attr->ia_uid); |
| 252 | else |
| 253 | *p++ = cpu_to_be32(NFS2_SATTR_NOT_SET); |
| 254 | if (attr->ia_valid & ATTR_GID) |
| 255 | *p++ = cpu_to_be32(attr->ia_gid); |
| 256 | else |
| 257 | *p++ = cpu_to_be32(NFS2_SATTR_NOT_SET); |
| 258 | if (attr->ia_valid & ATTR_SIZE) |
| 259 | *p++ = cpu_to_be32((u32)attr->ia_size); |
| 260 | else |
| 261 | *p++ = cpu_to_be32(NFS2_SATTR_NOT_SET); |
| 262 | |
| 263 | if (attr->ia_valid & ATTR_ATIME_SET) |
| 264 | p = xdr_encode_time(p, &attr->ia_atime); |
| 265 | else if (attr->ia_valid & ATTR_ATIME) |
| 266 | p = xdr_encode_current_server_time(p, &attr->ia_atime); |
| 267 | else |
| 268 | p = xdr_time_not_set(p); |
| 269 | if (attr->ia_valid & ATTR_MTIME_SET) |
| 270 | xdr_encode_time(p, &attr->ia_mtime); |
| 271 | else if (attr->ia_valid & ATTR_MTIME) |
| 272 | xdr_encode_current_server_time(p, &attr->ia_mtime); |
| 273 | else |
| 274 | xdr_time_not_set(p); |
| 275 | } |
| 276 | |
| 277 | /* |
| 278 | * 2.3.7. filename |
| 279 | * |
| 280 | * typedef string filename<MAXNAMLEN>; |
| 281 | */ |
| 282 | static void encode_filename(struct xdr_stream *xdr, |
| 283 | const char *name, u32 length) |
| 284 | { |
| 285 | __be32 *p; |
| 286 | |
| 287 | BUG_ON(length > NFS2_MAXNAMLEN); |
| 288 | p = xdr_reserve_space(xdr, 4 + length); |
| 289 | xdr_encode_opaque(p, name, length); |
| 290 | } |
| 291 | |
| 292 | /* |
| 293 | * 2.3.8. path |
| 294 | * |
| 295 | * typedef string path<MAXPATHLEN>; |
| 296 | */ |
| 297 | static void encode_path(struct xdr_stream *xdr, struct page **pages, u32 length) |
| 298 | { |
| 299 | __be32 *p; |
| 300 | |
| 301 | BUG_ON(length > NFS2_MAXPATHLEN); |
| 302 | p = xdr_reserve_space(xdr, 4); |
| 303 | *p = cpu_to_be32(length); |
| 304 | xdr_write_pages(xdr, pages, 0, length); |
| 305 | } |
| 306 | |
| 307 | /* |
| 308 | * 2.3.10. diropargs |
| 309 | * |
| 310 | * struct diropargs { |
| 311 | * fhandle dir; |
| 312 | * filename name; |
| 313 | * }; |
| 314 | */ |
| 315 | static void encode_diropargs(struct xdr_stream *xdr, const struct nfs_fh *fh, |
| 316 | const char *name, u32 length) |
| 317 | { |
| 318 | encode_fhandle(xdr, fh); |
| 319 | encode_filename(xdr, name, length); |
| 320 | } |
| 321 | |
| 322 | |
| 323 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 324 | * NFS encode functions |
| 325 | */ |
| 326 | /* |
| 327 | * Encode file handle argument |
| 328 | * GETATTR, READLINK, STATFS |
| 329 | */ |
| 330 | static int |
Al Viro | 9d787a7 | 2006-10-19 23:28:47 -0700 | [diff] [blame] | 331 | nfs_xdr_fhandle(struct rpc_rqst *req, __be32 *p, struct nfs_fh *fh) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 332 | { |
| 333 | p = xdr_encode_fhandle(p, fh); |
| 334 | req->rq_slen = xdr_adjust_iovec(req->rq_svec, p); |
| 335 | return 0; |
| 336 | } |
| 337 | |
Chuck Lever | 25a0866 | 2010-12-14 14:54:30 +0000 | [diff] [blame^] | 338 | static int nfs2_xdr_enc_fhandle(struct rpc_rqst *req, __be32 *p, |
| 339 | const struct nfs_fh *fh) |
| 340 | { |
| 341 | struct xdr_stream xdr; |
| 342 | |
| 343 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
| 344 | encode_fhandle(&xdr, fh); |
| 345 | return 0; |
| 346 | } |
| 347 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 348 | /* |
| 349 | * Encode SETATTR arguments |
| 350 | */ |
| 351 | static int |
Al Viro | 9d787a7 | 2006-10-19 23:28:47 -0700 | [diff] [blame] | 352 | nfs_xdr_sattrargs(struct rpc_rqst *req, __be32 *p, struct nfs_sattrargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 353 | { |
| 354 | p = xdr_encode_fhandle(p, args->fh); |
| 355 | p = xdr_encode_sattr(p, args->sattr); |
| 356 | req->rq_slen = xdr_adjust_iovec(req->rq_svec, p); |
| 357 | return 0; |
| 358 | } |
| 359 | |
| 360 | /* |
Chuck Lever | 25a0866 | 2010-12-14 14:54:30 +0000 | [diff] [blame^] | 361 | * 2.2.3. sattrargs |
| 362 | * |
| 363 | * struct sattrargs { |
| 364 | * fhandle file; |
| 365 | * sattr attributes; |
| 366 | * }; |
| 367 | */ |
| 368 | static int nfs2_xdr_enc_sattrargs(struct rpc_rqst *req, __be32 *p, |
| 369 | const struct nfs_sattrargs *args) |
| 370 | { |
| 371 | struct xdr_stream xdr; |
| 372 | |
| 373 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
| 374 | encode_fhandle(&xdr, args->fh); |
| 375 | encode_sattr(&xdr, args->sattr); |
| 376 | return 0; |
| 377 | } |
| 378 | |
| 379 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 380 | * Encode directory ops argument |
Trond Myklebust | 4fdc17b | 2007-07-14 15:39:57 -0400 | [diff] [blame] | 381 | * LOOKUP, RMDIR |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 382 | */ |
| 383 | static int |
Al Viro | 9d787a7 | 2006-10-19 23:28:47 -0700 | [diff] [blame] | 384 | nfs_xdr_diropargs(struct rpc_rqst *req, __be32 *p, struct nfs_diropargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 385 | { |
| 386 | p = xdr_encode_fhandle(p, args->fh); |
| 387 | p = xdr_encode_array(p, args->name, args->len); |
| 388 | req->rq_slen = xdr_adjust_iovec(req->rq_svec, p); |
| 389 | return 0; |
| 390 | } |
| 391 | |
Chuck Lever | 25a0866 | 2010-12-14 14:54:30 +0000 | [diff] [blame^] | 392 | static int nfs2_xdr_enc_diropargs(struct rpc_rqst *req, __be32 *p, |
| 393 | const struct nfs_diropargs *args) |
| 394 | { |
| 395 | struct xdr_stream xdr; |
| 396 | |
| 397 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
| 398 | encode_diropargs(&xdr, args->fh, args->name, args->len); |
| 399 | return 0; |
| 400 | } |
| 401 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 402 | /* |
Trond Myklebust | 4fdc17b | 2007-07-14 15:39:57 -0400 | [diff] [blame] | 403 | * Encode REMOVE argument |
| 404 | */ |
| 405 | static int |
| 406 | nfs_xdr_removeargs(struct rpc_rqst *req, __be32 *p, const struct nfs_removeargs *args) |
| 407 | { |
| 408 | p = xdr_encode_fhandle(p, args->fh); |
| 409 | p = xdr_encode_array(p, args->name.name, args->name.len); |
| 410 | req->rq_slen = xdr_adjust_iovec(req->rq_svec, p); |
| 411 | return 0; |
| 412 | } |
| 413 | |
Chuck Lever | 25a0866 | 2010-12-14 14:54:30 +0000 | [diff] [blame^] | 414 | static int nfs2_xdr_enc_readlinkargs(struct rpc_rqst *req, __be32 *p, |
| 415 | const struct nfs_readlinkargs *args) |
| 416 | { |
| 417 | struct xdr_stream xdr; |
| 418 | |
| 419 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
| 420 | encode_fhandle(&xdr, args->fh); |
| 421 | prepare_reply_buffer(req, args->pages, args->pgbase, |
| 422 | args->pglen, NFS_readlinkres_sz); |
| 423 | return 0; |
| 424 | } |
| 425 | |
Trond Myklebust | 4fdc17b | 2007-07-14 15:39:57 -0400 | [diff] [blame] | 426 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 427 | * Arguments to a READ call. Since we read data directly into the page |
| 428 | * cache, we also set up the reply iovec here so that iov[1] points |
| 429 | * exactly to the page we want to fetch. |
| 430 | */ |
| 431 | static int |
Al Viro | 9d787a7 | 2006-10-19 23:28:47 -0700 | [diff] [blame] | 432 | nfs_xdr_readargs(struct rpc_rqst *req, __be32 *p, struct nfs_readargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 433 | { |
Trond Myklebust | a17c215 | 2010-07-31 14:29:08 -0400 | [diff] [blame] | 434 | struct rpc_auth *auth = req->rq_cred->cr_auth; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 435 | unsigned int replen; |
| 436 | u32 offset = (u32)args->offset; |
| 437 | u32 count = args->count; |
| 438 | |
| 439 | p = xdr_encode_fhandle(p, args->fh); |
| 440 | *p++ = htonl(offset); |
| 441 | *p++ = htonl(count); |
| 442 | *p++ = htonl(count); |
| 443 | req->rq_slen = xdr_adjust_iovec(req->rq_svec, p); |
| 444 | |
| 445 | /* Inline the page array */ |
| 446 | replen = (RPC_REPHDRSIZE + auth->au_rslack + NFS_readres_sz) << 2; |
| 447 | xdr_inline_pages(&req->rq_rcv_buf, replen, |
| 448 | args->pages, args->pgbase, count); |
\"Talpey, Thomas\ | 4f22ccc | 2007-09-10 13:44:58 -0400 | [diff] [blame] | 449 | req->rq_rcv_buf.flags |= XDRBUF_READ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 | return 0; |
| 451 | } |
| 452 | |
| 453 | /* |
Chuck Lever | 25a0866 | 2010-12-14 14:54:30 +0000 | [diff] [blame^] | 454 | * 2.2.7. readargs |
| 455 | * |
| 456 | * struct readargs { |
| 457 | * fhandle file; |
| 458 | * unsigned offset; |
| 459 | * unsigned count; |
| 460 | * unsigned totalcount; |
| 461 | * }; |
| 462 | */ |
| 463 | static void encode_readargs(struct xdr_stream *xdr, |
| 464 | const struct nfs_readargs *args) |
| 465 | { |
| 466 | u32 offset = args->offset; |
| 467 | u32 count = args->count; |
| 468 | __be32 *p; |
| 469 | |
| 470 | encode_fhandle(xdr, args->fh); |
| 471 | |
| 472 | p = xdr_reserve_space(xdr, 4 + 4 + 4); |
| 473 | *p++ = cpu_to_be32(offset); |
| 474 | *p++ = cpu_to_be32(count); |
| 475 | *p = cpu_to_be32(count); |
| 476 | } |
| 477 | |
| 478 | static int nfs2_xdr_enc_readargs(struct rpc_rqst *req, __be32 *p, |
| 479 | const struct nfs_readargs *args) |
| 480 | { |
| 481 | struct xdr_stream xdr; |
| 482 | |
| 483 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
| 484 | encode_readargs(&xdr, args); |
| 485 | prepare_reply_buffer(req, args->pages, args->pgbase, |
| 486 | args->count, NFS_readres_sz); |
| 487 | req->rq_rcv_buf.flags |= XDRBUF_READ; |
| 488 | return 0; |
| 489 | } |
| 490 | |
| 491 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 492 | * Decode READ reply |
| 493 | */ |
| 494 | static int |
Al Viro | 9d787a7 | 2006-10-19 23:28:47 -0700 | [diff] [blame] | 495 | nfs_xdr_readres(struct rpc_rqst *req, __be32 *p, struct nfs_readres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 496 | { |
| 497 | struct kvec *iov = req->rq_rcv_buf.head; |
Chuck Lever | 6232dbb | 2007-10-26 13:31:52 -0400 | [diff] [blame] | 498 | size_t hdrlen; |
| 499 | u32 count, recvd; |
| 500 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 501 | |
| 502 | if ((status = ntohl(*p++))) |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 503 | return nfs_stat_to_errno(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 504 | p = xdr_decode_fattr(p, res->fattr); |
| 505 | |
| 506 | count = ntohl(*p++); |
| 507 | res->eof = 0; |
| 508 | hdrlen = (u8 *) p - (u8 *) iov->iov_base; |
| 509 | if (iov->iov_len < hdrlen) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 510 | dprintk("NFS: READ reply header overflowed:" |
Chuck Lever | 6232dbb | 2007-10-26 13:31:52 -0400 | [diff] [blame] | 511 | "length %Zu > %Zu\n", hdrlen, iov->iov_len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 512 | return -errno_NFSERR_IO; |
| 513 | } else if (iov->iov_len != hdrlen) { |
| 514 | dprintk("NFS: READ header is short. iovec will be shifted.\n"); |
| 515 | xdr_shift_buf(&req->rq_rcv_buf, iov->iov_len - hdrlen); |
| 516 | } |
| 517 | |
| 518 | recvd = req->rq_rcv_buf.len - hdrlen; |
| 519 | if (count > recvd) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 520 | dprintk("NFS: server cheating in read reply: " |
Chuck Lever | 6232dbb | 2007-10-26 13:31:52 -0400 | [diff] [blame] | 521 | "count %u > recvd %u\n", count, recvd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 522 | count = recvd; |
| 523 | } |
| 524 | |
Chuck Lever | 6232dbb | 2007-10-26 13:31:52 -0400 | [diff] [blame] | 525 | dprintk("RPC: readres OK count %u\n", count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 526 | if (count < res->count) |
| 527 | res->count = count; |
| 528 | |
| 529 | return count; |
| 530 | } |
| 531 | |
| 532 | |
| 533 | /* |
| 534 | * Write arguments. Splice the buffer to be written into the iovec. |
| 535 | */ |
| 536 | static int |
Al Viro | 9d787a7 | 2006-10-19 23:28:47 -0700 | [diff] [blame] | 537 | nfs_xdr_writeargs(struct rpc_rqst *req, __be32 *p, struct nfs_writeargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 538 | { |
| 539 | struct xdr_buf *sndbuf = &req->rq_snd_buf; |
| 540 | u32 offset = (u32)args->offset; |
| 541 | u32 count = args->count; |
| 542 | |
| 543 | p = xdr_encode_fhandle(p, args->fh); |
| 544 | *p++ = htonl(offset); |
| 545 | *p++ = htonl(offset); |
| 546 | *p++ = htonl(count); |
| 547 | *p++ = htonl(count); |
| 548 | sndbuf->len = xdr_adjust_iovec(sndbuf->head, p); |
| 549 | |
| 550 | /* Copy the page array */ |
| 551 | xdr_encode_pages(sndbuf, args->pages, args->pgbase, count); |
\"Talpey, Thomas\ | 4f22ccc | 2007-09-10 13:44:58 -0400 | [diff] [blame] | 552 | sndbuf->flags |= XDRBUF_WRITE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 553 | return 0; |
| 554 | } |
| 555 | |
| 556 | /* |
Chuck Lever | 25a0866 | 2010-12-14 14:54:30 +0000 | [diff] [blame^] | 557 | * 2.2.9. writeargs |
| 558 | * |
| 559 | * struct writeargs { |
| 560 | * fhandle file; |
| 561 | * unsigned beginoffset; |
| 562 | * unsigned offset; |
| 563 | * unsigned totalcount; |
| 564 | * nfsdata data; |
| 565 | * }; |
| 566 | */ |
| 567 | static void encode_writeargs(struct xdr_stream *xdr, |
| 568 | const struct nfs_writeargs *args) |
| 569 | { |
| 570 | u32 offset = args->offset; |
| 571 | u32 count = args->count; |
| 572 | __be32 *p; |
| 573 | |
| 574 | encode_fhandle(xdr, args->fh); |
| 575 | |
| 576 | p = xdr_reserve_space(xdr, 4 + 4 + 4 + 4); |
| 577 | *p++ = cpu_to_be32(offset); |
| 578 | *p++ = cpu_to_be32(offset); |
| 579 | *p++ = cpu_to_be32(count); |
| 580 | |
| 581 | /* nfsdata */ |
| 582 | *p = cpu_to_be32(count); |
| 583 | xdr_write_pages(xdr, args->pages, args->pgbase, count); |
| 584 | } |
| 585 | |
| 586 | static int nfs2_xdr_enc_writeargs(struct rpc_rqst *req, __be32 *p, |
| 587 | const struct nfs_writeargs *args) |
| 588 | { |
| 589 | struct xdr_stream xdr; |
| 590 | |
| 591 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
| 592 | encode_writeargs(&xdr, args); |
| 593 | xdr.buf->flags |= XDRBUF_WRITE; |
| 594 | return 0; |
| 595 | } |
| 596 | |
| 597 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 598 | * Encode create arguments |
| 599 | * CREATE, MKDIR |
| 600 | */ |
| 601 | static int |
Al Viro | 9d787a7 | 2006-10-19 23:28:47 -0700 | [diff] [blame] | 602 | nfs_xdr_createargs(struct rpc_rqst *req, __be32 *p, struct nfs_createargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 603 | { |
| 604 | p = xdr_encode_fhandle(p, args->fh); |
| 605 | p = xdr_encode_array(p, args->name, args->len); |
| 606 | p = xdr_encode_sattr(p, args->sattr); |
| 607 | req->rq_slen = xdr_adjust_iovec(req->rq_svec, p); |
| 608 | return 0; |
| 609 | } |
| 610 | |
| 611 | /* |
Chuck Lever | 25a0866 | 2010-12-14 14:54:30 +0000 | [diff] [blame^] | 612 | * 2.2.10. createargs |
| 613 | * |
| 614 | * struct createargs { |
| 615 | * diropargs where; |
| 616 | * sattr attributes; |
| 617 | * }; |
| 618 | */ |
| 619 | static int nfs2_xdr_enc_createargs(struct rpc_rqst *req, __be32 *p, |
| 620 | const struct nfs_createargs *args) |
| 621 | { |
| 622 | struct xdr_stream xdr; |
| 623 | |
| 624 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
| 625 | encode_diropargs(&xdr, args->fh, args->name, args->len); |
| 626 | encode_sattr(&xdr, args->sattr); |
| 627 | return 0; |
| 628 | } |
| 629 | |
| 630 | static int nfs2_xdr_enc_removeargs(struct rpc_rqst *req, __be32 *p, |
| 631 | const struct nfs_removeargs *args) |
| 632 | { |
| 633 | struct xdr_stream xdr; |
| 634 | |
| 635 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
| 636 | encode_diropargs(&xdr, args->fh, args->name.name, args->name.len); |
| 637 | return 0; |
| 638 | } |
| 639 | |
| 640 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 641 | * Encode RENAME arguments |
| 642 | */ |
| 643 | static int |
Al Viro | 9d787a7 | 2006-10-19 23:28:47 -0700 | [diff] [blame] | 644 | nfs_xdr_renameargs(struct rpc_rqst *req, __be32 *p, struct nfs_renameargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 645 | { |
Jeff Layton | 920769f | 2010-09-17 17:30:25 -0400 | [diff] [blame] | 646 | p = xdr_encode_fhandle(p, args->old_dir); |
| 647 | p = xdr_encode_array(p, args->old_name->name, args->old_name->len); |
| 648 | p = xdr_encode_fhandle(p, args->new_dir); |
| 649 | p = xdr_encode_array(p, args->new_name->name, args->new_name->len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 650 | req->rq_slen = xdr_adjust_iovec(req->rq_svec, p); |
| 651 | return 0; |
| 652 | } |
| 653 | |
| 654 | /* |
Chuck Lever | 25a0866 | 2010-12-14 14:54:30 +0000 | [diff] [blame^] | 655 | * 2.2.12. renameargs |
| 656 | * |
| 657 | * struct renameargs { |
| 658 | * diropargs from; |
| 659 | * diropargs to; |
| 660 | * }; |
| 661 | */ |
| 662 | static int nfs2_xdr_enc_renameargs(struct rpc_rqst *req, __be32 *p, |
| 663 | const struct nfs_renameargs *args) |
| 664 | { |
| 665 | const struct qstr *old = args->old_name; |
| 666 | const struct qstr *new = args->new_name; |
| 667 | struct xdr_stream xdr; |
| 668 | |
| 669 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
| 670 | encode_diropargs(&xdr, args->old_dir, old->name, old->len); |
| 671 | encode_diropargs(&xdr, args->new_dir, new->name, new->len); |
| 672 | return 0; |
| 673 | } |
| 674 | |
| 675 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 676 | * Encode LINK arguments |
| 677 | */ |
| 678 | static int |
Al Viro | 9d787a7 | 2006-10-19 23:28:47 -0700 | [diff] [blame] | 679 | nfs_xdr_linkargs(struct rpc_rqst *req, __be32 *p, struct nfs_linkargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 680 | { |
| 681 | p = xdr_encode_fhandle(p, args->fromfh); |
| 682 | p = xdr_encode_fhandle(p, args->tofh); |
| 683 | p = xdr_encode_array(p, args->toname, args->tolen); |
| 684 | req->rq_slen = xdr_adjust_iovec(req->rq_svec, p); |
| 685 | return 0; |
| 686 | } |
| 687 | |
| 688 | /* |
Chuck Lever | 25a0866 | 2010-12-14 14:54:30 +0000 | [diff] [blame^] | 689 | * 2.2.13. linkargs |
| 690 | * |
| 691 | * struct linkargs { |
| 692 | * fhandle from; |
| 693 | * diropargs to; |
| 694 | * }; |
| 695 | */ |
| 696 | static int nfs2_xdr_enc_linkargs(struct rpc_rqst *req, __be32 *p, |
| 697 | const struct nfs_linkargs *args) |
| 698 | { |
| 699 | struct xdr_stream xdr; |
| 700 | |
| 701 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
| 702 | encode_fhandle(&xdr, args->fromfh); |
| 703 | encode_diropargs(&xdr, args->tofh, args->toname, args->tolen); |
| 704 | return 0; |
| 705 | } |
| 706 | |
| 707 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 708 | * Encode SYMLINK arguments |
| 709 | */ |
| 710 | static int |
Al Viro | 9d787a7 | 2006-10-19 23:28:47 -0700 | [diff] [blame] | 711 | nfs_xdr_symlinkargs(struct rpc_rqst *req, __be32 *p, struct nfs_symlinkargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 712 | { |
Chuck Lever | 94a6d75 | 2006-08-22 20:06:23 -0400 | [diff] [blame] | 713 | struct xdr_buf *sndbuf = &req->rq_snd_buf; |
| 714 | size_t pad; |
| 715 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 716 | p = xdr_encode_fhandle(p, args->fromfh); |
| 717 | p = xdr_encode_array(p, args->fromname, args->fromlen); |
Chuck Lever | 94a6d75 | 2006-08-22 20:06:23 -0400 | [diff] [blame] | 718 | *p++ = htonl(args->pathlen); |
| 719 | sndbuf->len = xdr_adjust_iovec(sndbuf->head, p); |
| 720 | |
| 721 | xdr_encode_pages(sndbuf, args->pages, 0, args->pathlen); |
| 722 | |
| 723 | /* |
| 724 | * xdr_encode_pages may have added a few bytes to ensure the |
| 725 | * pathname ends on a 4-byte boundary. Start encoding the |
| 726 | * attributes after the pad bytes. |
| 727 | */ |
| 728 | pad = sndbuf->tail->iov_len; |
| 729 | if (pad > 0) |
| 730 | p++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 731 | p = xdr_encode_sattr(p, args->sattr); |
Chuck Lever | 94a6d75 | 2006-08-22 20:06:23 -0400 | [diff] [blame] | 732 | sndbuf->len += xdr_adjust_iovec(sndbuf->tail, p) - pad; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 733 | return 0; |
| 734 | } |
| 735 | |
| 736 | /* |
Chuck Lever | 25a0866 | 2010-12-14 14:54:30 +0000 | [diff] [blame^] | 737 | * 2.2.14. symlinkargs |
| 738 | * |
| 739 | * struct symlinkargs { |
| 740 | * diropargs from; |
| 741 | * path to; |
| 742 | * sattr attributes; |
| 743 | * }; |
| 744 | */ |
| 745 | static int nfs2_xdr_enc_symlinkargs(struct rpc_rqst *req, __be32 *p, |
| 746 | const struct nfs_symlinkargs *args) |
| 747 | { |
| 748 | struct xdr_stream xdr; |
| 749 | |
| 750 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
| 751 | encode_diropargs(&xdr, args->fromfh, args->fromname, args->fromlen); |
| 752 | encode_path(&xdr, args->pages, args->pathlen); |
| 753 | encode_sattr(&xdr, args->sattr); |
| 754 | return 0; |
| 755 | } |
| 756 | |
| 757 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 758 | * Encode arguments to readdir call |
| 759 | */ |
| 760 | static int |
Al Viro | 9d787a7 | 2006-10-19 23:28:47 -0700 | [diff] [blame] | 761 | nfs_xdr_readdirargs(struct rpc_rqst *req, __be32 *p, struct nfs_readdirargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 762 | { |
Trond Myklebust | a17c215 | 2010-07-31 14:29:08 -0400 | [diff] [blame] | 763 | struct rpc_auth *auth = req->rq_cred->cr_auth; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 764 | unsigned int replen; |
| 765 | u32 count = args->count; |
| 766 | |
| 767 | p = xdr_encode_fhandle(p, args->fh); |
| 768 | *p++ = htonl(args->cookie); |
| 769 | *p++ = htonl(count); /* see above */ |
| 770 | req->rq_slen = xdr_adjust_iovec(req->rq_svec, p); |
| 771 | |
| 772 | /* Inline the page array */ |
| 773 | replen = (RPC_REPHDRSIZE + auth->au_rslack + NFS_readdirres_sz) << 2; |
| 774 | xdr_inline_pages(&req->rq_rcv_buf, replen, args->pages, 0, count); |
| 775 | return 0; |
| 776 | } |
| 777 | |
| 778 | /* |
Chuck Lever | 25a0866 | 2010-12-14 14:54:30 +0000 | [diff] [blame^] | 779 | * 2.2.17. readdirargs |
| 780 | * |
| 781 | * struct readdirargs { |
| 782 | * fhandle dir; |
| 783 | * nfscookie cookie; |
| 784 | * unsigned count; |
| 785 | * }; |
| 786 | */ |
| 787 | static void encode_readdirargs(struct xdr_stream *xdr, |
| 788 | const struct nfs_readdirargs *args) |
| 789 | { |
| 790 | __be32 *p; |
| 791 | |
| 792 | encode_fhandle(xdr, args->fh); |
| 793 | |
| 794 | p = xdr_reserve_space(xdr, 4 + 4); |
| 795 | *p++ = cpu_to_be32(args->cookie); |
| 796 | *p = cpu_to_be32(args->count); |
| 797 | } |
| 798 | |
| 799 | static int nfs2_xdr_enc_readdirargs(struct rpc_rqst *req, __be32 *p, |
| 800 | const struct nfs_readdirargs *args) |
| 801 | { |
| 802 | struct xdr_stream xdr; |
| 803 | |
| 804 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
| 805 | encode_readdirargs(&xdr, args); |
| 806 | prepare_reply_buffer(req, args->pages, 0, |
| 807 | args->count, NFS_readdirres_sz); |
| 808 | return 0; |
| 809 | } |
| 810 | |
| 811 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 812 | * Decode the result of a readdir call. |
| 813 | * We're not really decoding anymore, we just leave the buffer untouched |
| 814 | * and only check that it is syntactically correct. |
| 815 | * The real decoding happens in nfs_decode_entry below, called directly |
| 816 | * from nfs_readdir for each entry. |
| 817 | */ |
| 818 | static int |
Al Viro | 9d787a7 | 2006-10-19 23:28:47 -0700 | [diff] [blame] | 819 | nfs_xdr_readdirres(struct rpc_rqst *req, __be32 *p, void *dummy) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 820 | { |
| 821 | struct xdr_buf *rcvbuf = &req->rq_rcv_buf; |
| 822 | struct kvec *iov = rcvbuf->head; |
| 823 | struct page **page; |
Chuck Lever | 6232dbb | 2007-10-26 13:31:52 -0400 | [diff] [blame] | 824 | size_t hdrlen; |
| 825 | unsigned int pglen, recvd; |
Trond Myklebust | ac39612 | 2010-11-15 20:26:22 -0500 | [diff] [blame] | 826 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 827 | |
| 828 | if ((status = ntohl(*p++))) |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 829 | return nfs_stat_to_errno(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 830 | |
| 831 | hdrlen = (u8 *) p - (u8 *) iov->iov_base; |
| 832 | if (iov->iov_len < hdrlen) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 833 | dprintk("NFS: READDIR reply header overflowed:" |
Chuck Lever | 6232dbb | 2007-10-26 13:31:52 -0400 | [diff] [blame] | 834 | "length %Zu > %Zu\n", hdrlen, iov->iov_len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 835 | return -errno_NFSERR_IO; |
| 836 | } else if (iov->iov_len != hdrlen) { |
| 837 | dprintk("NFS: READDIR header is short. iovec will be shifted.\n"); |
| 838 | xdr_shift_buf(rcvbuf, iov->iov_len - hdrlen); |
| 839 | } |
| 840 | |
| 841 | pglen = rcvbuf->page_len; |
| 842 | recvd = rcvbuf->len - hdrlen; |
| 843 | if (pglen > recvd) |
| 844 | pglen = recvd; |
| 845 | page = rcvbuf->pages; |
Trond Myklebust | ac39612 | 2010-11-15 20:26:22 -0500 | [diff] [blame] | 846 | return pglen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 847 | } |
| 848 | |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 849 | static void print_overflow_msg(const char *func, const struct xdr_stream *xdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 850 | { |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 851 | dprintk("nfs: %s: prematurely hit end of receive buffer. " |
| 852 | "Remaining buffer length is %tu words.\n", |
| 853 | func, xdr->end - xdr->p); |
| 854 | } |
| 855 | |
| 856 | __be32 * |
Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 857 | nfs_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, struct nfs_server *server, int plus) |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 858 | { |
| 859 | __be32 *p; |
| 860 | p = xdr_inline_decode(xdr, 4); |
| 861 | if (unlikely(!p)) |
| 862 | goto out_overflow; |
| 863 | if (!ntohl(*p++)) { |
| 864 | p = xdr_inline_decode(xdr, 4); |
| 865 | if (unlikely(!p)) |
| 866 | goto out_overflow; |
| 867 | if (!ntohl(*p++)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 868 | return ERR_PTR(-EAGAIN); |
| 869 | entry->eof = 1; |
| 870 | return ERR_PTR(-EBADCOOKIE); |
| 871 | } |
| 872 | |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 873 | p = xdr_inline_decode(xdr, 8); |
| 874 | if (unlikely(!p)) |
| 875 | goto out_overflow; |
| 876 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 877 | entry->ino = ntohl(*p++); |
| 878 | entry->len = ntohl(*p++); |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 879 | |
| 880 | p = xdr_inline_decode(xdr, entry->len + 4); |
| 881 | if (unlikely(!p)) |
| 882 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 883 | entry->name = (const char *) p; |
| 884 | p += XDR_QUADLEN(entry->len); |
| 885 | entry->prev_cookie = entry->cookie; |
| 886 | entry->cookie = ntohl(*p++); |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 887 | |
Trond Myklebust | 0b26a0b | 2010-11-20 14:26:44 -0500 | [diff] [blame] | 888 | entry->d_type = DT_UNKNOWN; |
| 889 | |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 890 | p = xdr_inline_peek(xdr, 8); |
| 891 | if (p != NULL) |
| 892 | entry->eof = !p[0] && p[1]; |
| 893 | else |
| 894 | entry->eof = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 895 | |
| 896 | return p; |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 897 | |
| 898 | out_overflow: |
| 899 | print_overflow_msg(__func__, xdr); |
Trond Myklebust | 463a376 | 2010-11-20 12:22:20 -0500 | [diff] [blame] | 900 | return ERR_PTR(-EAGAIN); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 901 | } |
| 902 | |
| 903 | /* |
| 904 | * NFS XDR decode functions |
| 905 | */ |
| 906 | /* |
| 907 | * Decode simple status reply |
| 908 | */ |
| 909 | static int |
Al Viro | 9d787a7 | 2006-10-19 23:28:47 -0700 | [diff] [blame] | 910 | nfs_xdr_stat(struct rpc_rqst *req, __be32 *p, void *dummy) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 911 | { |
| 912 | int status; |
| 913 | |
| 914 | if ((status = ntohl(*p++)) != 0) |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 915 | status = nfs_stat_to_errno(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 916 | return status; |
| 917 | } |
| 918 | |
| 919 | /* |
| 920 | * Decode attrstat reply |
| 921 | * GETATTR, SETATTR, WRITE |
| 922 | */ |
| 923 | static int |
Al Viro | 9d787a7 | 2006-10-19 23:28:47 -0700 | [diff] [blame] | 924 | nfs_xdr_attrstat(struct rpc_rqst *req, __be32 *p, struct nfs_fattr *fattr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 925 | { |
| 926 | int status; |
| 927 | |
| 928 | if ((status = ntohl(*p++))) |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 929 | return nfs_stat_to_errno(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 930 | xdr_decode_fattr(p, fattr); |
| 931 | return 0; |
| 932 | } |
| 933 | |
| 934 | /* |
| 935 | * Decode diropres reply |
| 936 | * LOOKUP, CREATE, MKDIR |
| 937 | */ |
| 938 | static int |
Al Viro | 9d787a7 | 2006-10-19 23:28:47 -0700 | [diff] [blame] | 939 | nfs_xdr_diropres(struct rpc_rqst *req, __be32 *p, struct nfs_diropok *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 940 | { |
| 941 | int status; |
| 942 | |
| 943 | if ((status = ntohl(*p++))) |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 944 | return nfs_stat_to_errno(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 945 | p = xdr_decode_fhandle(p, res->fh); |
| 946 | xdr_decode_fattr(p, res->fattr); |
| 947 | return 0; |
| 948 | } |
| 949 | |
| 950 | /* |
| 951 | * Encode READLINK args |
| 952 | */ |
| 953 | static int |
Al Viro | 9d787a7 | 2006-10-19 23:28:47 -0700 | [diff] [blame] | 954 | nfs_xdr_readlinkargs(struct rpc_rqst *req, __be32 *p, struct nfs_readlinkargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 955 | { |
Trond Myklebust | a17c215 | 2010-07-31 14:29:08 -0400 | [diff] [blame] | 956 | struct rpc_auth *auth = req->rq_cred->cr_auth; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 957 | unsigned int replen; |
| 958 | |
| 959 | p = xdr_encode_fhandle(p, args->fh); |
| 960 | req->rq_slen = xdr_adjust_iovec(req->rq_svec, p); |
| 961 | |
| 962 | /* Inline the page array */ |
| 963 | replen = (RPC_REPHDRSIZE + auth->au_rslack + NFS_readlinkres_sz) << 2; |
| 964 | xdr_inline_pages(&req->rq_rcv_buf, replen, args->pages, args->pgbase, args->pglen); |
| 965 | return 0; |
| 966 | } |
| 967 | |
| 968 | /* |
| 969 | * Decode READLINK reply |
| 970 | */ |
| 971 | static int |
Al Viro | 9d787a7 | 2006-10-19 23:28:47 -0700 | [diff] [blame] | 972 | nfs_xdr_readlinkres(struct rpc_rqst *req, __be32 *p, void *dummy) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 973 | { |
| 974 | struct xdr_buf *rcvbuf = &req->rq_rcv_buf; |
| 975 | struct kvec *iov = rcvbuf->head; |
Chuck Lever | 6232dbb | 2007-10-26 13:31:52 -0400 | [diff] [blame] | 976 | size_t hdrlen; |
| 977 | u32 len, recvd; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 978 | int status; |
| 979 | |
| 980 | if ((status = ntohl(*p++))) |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 981 | return nfs_stat_to_errno(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 982 | /* Convert length of symlink */ |
| 983 | len = ntohl(*p++); |
Chuck Lever | 6232dbb | 2007-10-26 13:31:52 -0400 | [diff] [blame] | 984 | if (len >= rcvbuf->page_len) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 985 | dprintk("nfs: server returned giant symlink!\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 986 | return -ENAMETOOLONG; |
| 987 | } |
| 988 | hdrlen = (u8 *) p - (u8 *) iov->iov_base; |
| 989 | if (iov->iov_len < hdrlen) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 990 | dprintk("NFS: READLINK reply header overflowed:" |
Chuck Lever | 6232dbb | 2007-10-26 13:31:52 -0400 | [diff] [blame] | 991 | "length %Zu > %Zu\n", hdrlen, iov->iov_len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 992 | return -errno_NFSERR_IO; |
| 993 | } else if (iov->iov_len != hdrlen) { |
| 994 | dprintk("NFS: READLINK header is short. iovec will be shifted.\n"); |
| 995 | xdr_shift_buf(rcvbuf, iov->iov_len - hdrlen); |
| 996 | } |
| 997 | recvd = req->rq_rcv_buf.len - hdrlen; |
| 998 | if (recvd < len) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 999 | dprintk("NFS: server cheating in readlink reply: " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1000 | "count %u > recvd %u\n", len, recvd); |
| 1001 | return -EIO; |
| 1002 | } |
| 1003 | |
Chuck Lever | b4687da | 2010-09-21 16:55:48 -0400 | [diff] [blame] | 1004 | xdr_terminate_string(rcvbuf, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1005 | return 0; |
| 1006 | } |
| 1007 | |
| 1008 | /* |
| 1009 | * Decode WRITE reply |
| 1010 | */ |
| 1011 | static int |
Al Viro | 9d787a7 | 2006-10-19 23:28:47 -0700 | [diff] [blame] | 1012 | nfs_xdr_writeres(struct rpc_rqst *req, __be32 *p, struct nfs_writeres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1013 | { |
| 1014 | res->verf->committed = NFS_FILE_SYNC; |
| 1015 | return nfs_xdr_attrstat(req, p, res->fattr); |
| 1016 | } |
| 1017 | |
| 1018 | /* |
| 1019 | * Decode STATFS reply |
| 1020 | */ |
| 1021 | static int |
Al Viro | 9d787a7 | 2006-10-19 23:28:47 -0700 | [diff] [blame] | 1022 | nfs_xdr_statfsres(struct rpc_rqst *req, __be32 *p, struct nfs2_fsstat *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1023 | { |
| 1024 | int status; |
| 1025 | |
| 1026 | if ((status = ntohl(*p++))) |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 1027 | return nfs_stat_to_errno(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1028 | |
| 1029 | res->tsize = ntohl(*p++); |
| 1030 | res->bsize = ntohl(*p++); |
| 1031 | res->blocks = ntohl(*p++); |
| 1032 | res->bfree = ntohl(*p++); |
| 1033 | res->bavail = ntohl(*p++); |
| 1034 | return 0; |
| 1035 | } |
| 1036 | |
| 1037 | /* |
| 1038 | * We need to translate between nfs status return values and |
| 1039 | * the local errno values which may not be the same. |
| 1040 | */ |
| 1041 | static struct { |
| 1042 | int stat; |
| 1043 | int errno; |
| 1044 | } nfs_errtbl[] = { |
| 1045 | { NFS_OK, 0 }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 1046 | { NFSERR_PERM, -EPERM }, |
| 1047 | { NFSERR_NOENT, -ENOENT }, |
| 1048 | { NFSERR_IO, -errno_NFSERR_IO}, |
| 1049 | { NFSERR_NXIO, -ENXIO }, |
| 1050 | /* { NFSERR_EAGAIN, -EAGAIN }, */ |
| 1051 | { NFSERR_ACCES, -EACCES }, |
| 1052 | { NFSERR_EXIST, -EEXIST }, |
| 1053 | { NFSERR_XDEV, -EXDEV }, |
| 1054 | { NFSERR_NODEV, -ENODEV }, |
| 1055 | { NFSERR_NOTDIR, -ENOTDIR }, |
| 1056 | { NFSERR_ISDIR, -EISDIR }, |
| 1057 | { NFSERR_INVAL, -EINVAL }, |
| 1058 | { NFSERR_FBIG, -EFBIG }, |
| 1059 | { NFSERR_NOSPC, -ENOSPC }, |
| 1060 | { NFSERR_ROFS, -EROFS }, |
| 1061 | { NFSERR_MLINK, -EMLINK }, |
| 1062 | { NFSERR_NAMETOOLONG, -ENAMETOOLONG }, |
| 1063 | { NFSERR_NOTEMPTY, -ENOTEMPTY }, |
| 1064 | { NFSERR_DQUOT, -EDQUOT }, |
| 1065 | { NFSERR_STALE, -ESTALE }, |
| 1066 | { NFSERR_REMOTE, -EREMOTE }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1067 | #ifdef EWFLUSH |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 1068 | { NFSERR_WFLUSH, -EWFLUSH }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1069 | #endif |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 1070 | { NFSERR_BADHANDLE, -EBADHANDLE }, |
| 1071 | { NFSERR_NOT_SYNC, -ENOTSYNC }, |
| 1072 | { NFSERR_BAD_COOKIE, -EBADCOOKIE }, |
| 1073 | { NFSERR_NOTSUPP, -ENOTSUPP }, |
| 1074 | { NFSERR_TOOSMALL, -ETOOSMALL }, |
Trond Myklebust | fdcb457 | 2010-02-08 09:32:40 -0500 | [diff] [blame] | 1075 | { NFSERR_SERVERFAULT, -EREMOTEIO }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 1076 | { NFSERR_BADTYPE, -EBADTYPE }, |
| 1077 | { NFSERR_JUKEBOX, -EJUKEBOX }, |
| 1078 | { -1, -EIO } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1079 | }; |
| 1080 | |
| 1081 | /* |
| 1082 | * Convert an NFS error code to a local one. |
| 1083 | * This one is used jointly by NFSv2 and NFSv3. |
| 1084 | */ |
| 1085 | int |
| 1086 | nfs_stat_to_errno(int stat) |
| 1087 | { |
| 1088 | int i; |
| 1089 | |
| 1090 | for (i = 0; nfs_errtbl[i].stat != -1; i++) { |
| 1091 | if (nfs_errtbl[i].stat == stat) |
| 1092 | return nfs_errtbl[i].errno; |
| 1093 | } |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 1094 | dprintk("nfs_stat_to_errno: bad nfs status return value: %d\n", stat); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1095 | return nfs_errtbl[i].errno; |
| 1096 | } |
| 1097 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1098 | #define PROC(proc, argtype, restype, timer) \ |
| 1099 | [NFSPROC_##proc] = { \ |
| 1100 | .p_proc = NFSPROC_##proc, \ |
Chuck Lever | 25a0866 | 2010-12-14 14:54:30 +0000 | [diff] [blame^] | 1101 | .p_encode = (kxdrproc_t)nfs2_xdr_enc_##argtype, \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1102 | .p_decode = (kxdrproc_t) nfs_xdr_##restype, \ |
Chuck Lever | 2bea90d | 2007-03-29 16:47:53 -0400 | [diff] [blame] | 1103 | .p_arglen = NFS_##argtype##_sz, \ |
| 1104 | .p_replen = NFS_##restype##_sz, \ |
Chuck Lever | cc0175c | 2006-03-20 13:44:22 -0500 | [diff] [blame] | 1105 | .p_timer = timer, \ |
| 1106 | .p_statidx = NFSPROC_##proc, \ |
| 1107 | .p_name = #proc, \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1108 | } |
| 1109 | struct rpc_procinfo nfs_procedures[] = { |
| 1110 | PROC(GETATTR, fhandle, attrstat, 1), |
| 1111 | PROC(SETATTR, sattrargs, attrstat, 0), |
| 1112 | PROC(LOOKUP, diropargs, diropres, 2), |
| 1113 | PROC(READLINK, readlinkargs, readlinkres, 3), |
| 1114 | PROC(READ, readargs, readres, 3), |
| 1115 | PROC(WRITE, writeargs, writeres, 4), |
| 1116 | PROC(CREATE, createargs, diropres, 0), |
Trond Myklebust | 4fdc17b | 2007-07-14 15:39:57 -0400 | [diff] [blame] | 1117 | PROC(REMOVE, removeargs, stat, 0), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1118 | PROC(RENAME, renameargs, stat, 0), |
| 1119 | PROC(LINK, linkargs, stat, 0), |
| 1120 | PROC(SYMLINK, symlinkargs, stat, 0), |
| 1121 | PROC(MKDIR, createargs, diropres, 0), |
| 1122 | PROC(RMDIR, diropargs, stat, 0), |
| 1123 | PROC(READDIR, readdirargs, readdirres, 3), |
| 1124 | PROC(STATFS, fhandle, statfsres, 0), |
| 1125 | }; |
| 1126 | |
| 1127 | struct rpc_version nfs_version2 = { |
| 1128 | .number = 2, |
Tobias Klauser | e8c96f8 | 2006-03-24 03:15:34 -0800 | [diff] [blame] | 1129 | .nrprocs = ARRAY_SIZE(nfs_procedures), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1130 | .procs = nfs_procedures |
| 1131 | }; |