| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | *  linux/fs/nfs/proc.c | 
|  | 3 | * | 
|  | 4 | *  Copyright (C) 1992, 1993, 1994  Rick Sladkey | 
|  | 5 | * | 
|  | 6 | *  OS-independent nfs remote procedure call functions | 
|  | 7 | * | 
|  | 8 | *  Tuned by Alan Cox <A.Cox@swansea.ac.uk> for >3K buffers | 
|  | 9 | *  so at last we can have decent(ish) throughput off a | 
|  | 10 | *  Sun server. | 
|  | 11 | * | 
|  | 12 | *  Coding optimized and cleaned up by Florian La Roche. | 
|  | 13 | *  Note: Error returns are optimized for NFS_OK, which isn't translated via | 
|  | 14 | *  nfs_stat_to_errno(), but happens to be already the right return code. | 
|  | 15 | * | 
|  | 16 | *  Also, the code currently doesn't check the size of the packet, when | 
|  | 17 | *  it decodes the packet. | 
|  | 18 | * | 
|  | 19 | *  Feel free to fix it and mail me the diffs if it worries you. | 
|  | 20 | * | 
|  | 21 | *  Completely rewritten to support the new RPC call interface; | 
|  | 22 | *  rewrote and moved the entire XDR stuff to xdr.c | 
|  | 23 | *  --Olaf Kirch June 1996 | 
|  | 24 | * | 
|  | 25 | *  The code below initializes all auto variables explicitly, otherwise | 
|  | 26 | *  it will fail to work as a module (gcc generates a memset call for an | 
|  | 27 | *  incomplete struct). | 
|  | 28 | */ | 
|  | 29 |  | 
|  | 30 | #include <linux/types.h> | 
|  | 31 | #include <linux/param.h> | 
|  | 32 | #include <linux/slab.h> | 
|  | 33 | #include <linux/time.h> | 
|  | 34 | #include <linux/mm.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | #include <linux/errno.h> | 
|  | 36 | #include <linux/string.h> | 
|  | 37 | #include <linux/in.h> | 
|  | 38 | #include <linux/pagemap.h> | 
|  | 39 | #include <linux/sunrpc/clnt.h> | 
|  | 40 | #include <linux/nfs.h> | 
|  | 41 | #include <linux/nfs2.h> | 
|  | 42 | #include <linux/nfs_fs.h> | 
|  | 43 | #include <linux/nfs_page.h> | 
|  | 44 | #include <linux/lockd/bind.h> | 
| David Howells | f7b422b | 2006-06-09 09:34:33 -0400 | [diff] [blame] | 45 | #include "internal.h" | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 |  | 
|  | 47 | #define NFSDBG_FACILITY		NFSDBG_PROC | 
|  | 48 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | /* | 
|  | 50 | * Bare-bones access to getattr: this is for nfs_read_super. | 
|  | 51 | */ | 
|  | 52 | static int | 
|  | 53 | nfs_proc_get_root(struct nfs_server *server, struct nfs_fh *fhandle, | 
|  | 54 | struct nfs_fsinfo *info) | 
|  | 55 | { | 
|  | 56 | struct nfs_fattr *fattr = info->fattr; | 
|  | 57 | struct nfs2_fsstat fsinfo; | 
| Chuck Lever | dead28d | 2006-03-20 13:44:23 -0500 | [diff] [blame] | 58 | struct rpc_message msg = { | 
|  | 59 | .rpc_proc	= &nfs_procedures[NFSPROC_GETATTR], | 
|  | 60 | .rpc_argp	= fhandle, | 
|  | 61 | .rpc_resp	= fattr, | 
|  | 62 | }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | int status; | 
|  | 64 |  | 
| Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 65 | dprintk("%s: call getattr\n", __func__); | 
| Trond Myklebust | 0e574af | 2005-10-27 22:12:38 -0400 | [diff] [blame] | 66 | nfs_fattr_init(fattr); | 
| EG Keizer | 37ca8f5 | 2008-08-19 16:34:36 -0400 | [diff] [blame] | 67 | status = rpc_call_sync(server->client, &msg, 0); | 
|  | 68 | /* Retry with default authentication if different */ | 
|  | 69 | if (status && server->nfs_client->cl_rpcclient != server->client) | 
|  | 70 | status = rpc_call_sync(server->nfs_client->cl_rpcclient, &msg, 0); | 
| Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 71 | dprintk("%s: reply getattr: %d\n", __func__, status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | if (status) | 
|  | 73 | return status; | 
| Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 74 | dprintk("%s: call statfs\n", __func__); | 
| Chuck Lever | dead28d | 2006-03-20 13:44:23 -0500 | [diff] [blame] | 75 | msg.rpc_proc = &nfs_procedures[NFSPROC_STATFS]; | 
|  | 76 | msg.rpc_resp = &fsinfo; | 
| EG Keizer | 37ca8f5 | 2008-08-19 16:34:36 -0400 | [diff] [blame] | 77 | status = rpc_call_sync(server->client, &msg, 0); | 
|  | 78 | /* Retry with default authentication if different */ | 
|  | 79 | if (status && server->nfs_client->cl_rpcclient != server->client) | 
|  | 80 | status = rpc_call_sync(server->nfs_client->cl_rpcclient, &msg, 0); | 
| Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 81 | dprintk("%s: reply statfs: %d\n", __func__, status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | if (status) | 
|  | 83 | return status; | 
|  | 84 | info->rtmax  = NFS_MAXDATA; | 
|  | 85 | info->rtpref = fsinfo.tsize; | 
|  | 86 | info->rtmult = fsinfo.bsize; | 
|  | 87 | info->wtmax  = NFS_MAXDATA; | 
|  | 88 | info->wtpref = fsinfo.tsize; | 
|  | 89 | info->wtmult = fsinfo.bsize; | 
|  | 90 | info->dtpref = fsinfo.tsize; | 
|  | 91 | info->maxfilesize = 0x7FFFFFFF; | 
|  | 92 | info->lease_time = 0; | 
|  | 93 | return 0; | 
|  | 94 | } | 
|  | 95 |  | 
|  | 96 | /* | 
|  | 97 | * One function for each procedure in the NFS protocol. | 
|  | 98 | */ | 
|  | 99 | static int | 
|  | 100 | nfs_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle, | 
|  | 101 | struct nfs_fattr *fattr) | 
|  | 102 | { | 
| Chuck Lever | dead28d | 2006-03-20 13:44:23 -0500 | [diff] [blame] | 103 | struct rpc_message msg = { | 
|  | 104 | .rpc_proc	= &nfs_procedures[NFSPROC_GETATTR], | 
|  | 105 | .rpc_argp	= fhandle, | 
|  | 106 | .rpc_resp	= fattr, | 
|  | 107 | }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | int	status; | 
|  | 109 |  | 
|  | 110 | dprintk("NFS call  getattr\n"); | 
| Trond Myklebust | 0e574af | 2005-10-27 22:12:38 -0400 | [diff] [blame] | 111 | nfs_fattr_init(fattr); | 
| Chuck Lever | dead28d | 2006-03-20 13:44:23 -0500 | [diff] [blame] | 112 | status = rpc_call_sync(server->client, &msg, 0); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | dprintk("NFS reply getattr: %d\n", status); | 
|  | 114 | return status; | 
|  | 115 | } | 
|  | 116 |  | 
|  | 117 | static int | 
|  | 118 | nfs_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr, | 
|  | 119 | struct iattr *sattr) | 
|  | 120 | { | 
|  | 121 | struct inode *inode = dentry->d_inode; | 
|  | 122 | struct nfs_sattrargs	arg = { | 
|  | 123 | .fh	= NFS_FH(inode), | 
|  | 124 | .sattr	= sattr | 
|  | 125 | }; | 
| Chuck Lever | dead28d | 2006-03-20 13:44:23 -0500 | [diff] [blame] | 126 | struct rpc_message msg = { | 
|  | 127 | .rpc_proc	= &nfs_procedures[NFSPROC_SETATTR], | 
|  | 128 | .rpc_argp	= &arg, | 
|  | 129 | .rpc_resp	= fattr, | 
|  | 130 | }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | int	status; | 
|  | 132 |  | 
| Trond Myklebust | cf3fff5 | 2006-01-03 09:55:53 +0100 | [diff] [blame] | 133 | /* Mask out the non-modebit related stuff from attr->ia_mode */ | 
|  | 134 | sattr->ia_mode &= S_IALLUGO; | 
|  | 135 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | dprintk("NFS call  setattr\n"); | 
| Trond Myklebust | 659bfcd | 2008-06-10 19:39:41 -0400 | [diff] [blame] | 137 | if (sattr->ia_valid & ATTR_FILE) | 
|  | 138 | msg.rpc_cred = nfs_file_cred(sattr->ia_file); | 
| Trond Myklebust | 0e574af | 2005-10-27 22:12:38 -0400 | [diff] [blame] | 139 | nfs_fattr_init(fattr); | 
| Chuck Lever | dead28d | 2006-03-20 13:44:23 -0500 | [diff] [blame] | 140 | status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0); | 
| Trond Myklebust | 65e4308 | 2005-08-16 11:49:44 -0400 | [diff] [blame] | 141 | if (status == 0) | 
|  | 142 | nfs_setattr_update_inode(inode, sattr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | dprintk("NFS reply setattr: %d\n", status); | 
|  | 144 | return status; | 
|  | 145 | } | 
|  | 146 |  | 
|  | 147 | static int | 
|  | 148 | nfs_proc_lookup(struct inode *dir, struct qstr *name, | 
|  | 149 | struct nfs_fh *fhandle, struct nfs_fattr *fattr) | 
|  | 150 | { | 
|  | 151 | struct nfs_diropargs	arg = { | 
|  | 152 | .fh		= NFS_FH(dir), | 
|  | 153 | .name		= name->name, | 
|  | 154 | .len		= name->len | 
|  | 155 | }; | 
|  | 156 | struct nfs_diropok	res = { | 
|  | 157 | .fh		= fhandle, | 
|  | 158 | .fattr		= fattr | 
|  | 159 | }; | 
| Chuck Lever | dead28d | 2006-03-20 13:44:23 -0500 | [diff] [blame] | 160 | struct rpc_message msg = { | 
|  | 161 | .rpc_proc	= &nfs_procedures[NFSPROC_LOOKUP], | 
|  | 162 | .rpc_argp	= &arg, | 
|  | 163 | .rpc_resp	= &res, | 
|  | 164 | }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 165 | int			status; | 
|  | 166 |  | 
|  | 167 | dprintk("NFS call  lookup %s\n", name->name); | 
| Trond Myklebust | 0e574af | 2005-10-27 22:12:38 -0400 | [diff] [blame] | 168 | nfs_fattr_init(fattr); | 
| Chuck Lever | dead28d | 2006-03-20 13:44:23 -0500 | [diff] [blame] | 169 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 170 | dprintk("NFS reply lookup: %d\n", status); | 
|  | 171 | return status; | 
|  | 172 | } | 
|  | 173 |  | 
|  | 174 | static int nfs_proc_readlink(struct inode *inode, struct page *page, | 
|  | 175 | unsigned int pgbase, unsigned int pglen) | 
|  | 176 | { | 
|  | 177 | struct nfs_readlinkargs	args = { | 
|  | 178 | .fh		= NFS_FH(inode), | 
|  | 179 | .pgbase		= pgbase, | 
|  | 180 | .pglen		= pglen, | 
|  | 181 | .pages		= &page | 
|  | 182 | }; | 
| Chuck Lever | dead28d | 2006-03-20 13:44:23 -0500 | [diff] [blame] | 183 | struct rpc_message msg = { | 
|  | 184 | .rpc_proc	= &nfs_procedures[NFSPROC_READLINK], | 
|  | 185 | .rpc_argp	= &args, | 
|  | 186 | }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 | int			status; | 
|  | 188 |  | 
|  | 189 | dprintk("NFS call  readlink\n"); | 
| Chuck Lever | dead28d | 2006-03-20 13:44:23 -0500 | [diff] [blame] | 190 | status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 191 | dprintk("NFS reply readlink: %d\n", status); | 
|  | 192 | return status; | 
|  | 193 | } | 
|  | 194 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 195 | static int | 
|  | 196 | nfs_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr, | 
| Trond Myklebust | 02a913a | 2005-10-18 14:20:17 -0700 | [diff] [blame] | 197 | int flags, struct nameidata *nd) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | { | 
|  | 199 | struct nfs_fh		fhandle; | 
|  | 200 | struct nfs_fattr	fattr; | 
|  | 201 | struct nfs_createargs	arg = { | 
|  | 202 | .fh		= NFS_FH(dir), | 
|  | 203 | .name		= dentry->d_name.name, | 
|  | 204 | .len		= dentry->d_name.len, | 
|  | 205 | .sattr		= sattr | 
|  | 206 | }; | 
|  | 207 | struct nfs_diropok	res = { | 
|  | 208 | .fh		= &fhandle, | 
|  | 209 | .fattr		= &fattr | 
|  | 210 | }; | 
| Chuck Lever | dead28d | 2006-03-20 13:44:23 -0500 | [diff] [blame] | 211 | struct rpc_message msg = { | 
|  | 212 | .rpc_proc	= &nfs_procedures[NFSPROC_CREATE], | 
|  | 213 | .rpc_argp	= &arg, | 
|  | 214 | .rpc_resp	= &res, | 
|  | 215 | }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 216 | int			status; | 
|  | 217 |  | 
| Trond Myklebust | 0e574af | 2005-10-27 22:12:38 -0400 | [diff] [blame] | 218 | nfs_fattr_init(&fattr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 219 | dprintk("NFS call  create %s\n", dentry->d_name.name); | 
| Chuck Lever | dead28d | 2006-03-20 13:44:23 -0500 | [diff] [blame] | 220 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); | 
| Trond Myklebust | bad2a52 | 2007-10-20 13:07:21 -0400 | [diff] [blame] | 221 | nfs_mark_for_revalidate(dir); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 222 | if (status == 0) | 
|  | 223 | status = nfs_instantiate(dentry, &fhandle, &fattr); | 
|  | 224 | dprintk("NFS reply create: %d\n", status); | 
|  | 225 | return status; | 
|  | 226 | } | 
|  | 227 |  | 
|  | 228 | /* | 
|  | 229 | * In NFSv2, mknod is grafted onto the create call. | 
|  | 230 | */ | 
|  | 231 | static int | 
|  | 232 | nfs_proc_mknod(struct inode *dir, struct dentry *dentry, struct iattr *sattr, | 
|  | 233 | dev_t rdev) | 
|  | 234 | { | 
|  | 235 | struct nfs_fh fhandle; | 
|  | 236 | struct nfs_fattr fattr; | 
|  | 237 | struct nfs_createargs	arg = { | 
|  | 238 | .fh		= NFS_FH(dir), | 
|  | 239 | .name		= dentry->d_name.name, | 
|  | 240 | .len		= dentry->d_name.len, | 
|  | 241 | .sattr		= sattr | 
|  | 242 | }; | 
|  | 243 | struct nfs_diropok	res = { | 
|  | 244 | .fh		= &fhandle, | 
|  | 245 | .fattr		= &fattr | 
|  | 246 | }; | 
| Chuck Lever | dead28d | 2006-03-20 13:44:23 -0500 | [diff] [blame] | 247 | struct rpc_message msg = { | 
|  | 248 | .rpc_proc	= &nfs_procedures[NFSPROC_CREATE], | 
|  | 249 | .rpc_argp	= &arg, | 
|  | 250 | .rpc_resp	= &res, | 
|  | 251 | }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 252 | int status, mode; | 
|  | 253 |  | 
|  | 254 | dprintk("NFS call  mknod %s\n", dentry->d_name.name); | 
|  | 255 |  | 
|  | 256 | mode = sattr->ia_mode; | 
|  | 257 | if (S_ISFIFO(mode)) { | 
|  | 258 | sattr->ia_mode = (mode & ~S_IFMT) | S_IFCHR; | 
|  | 259 | sattr->ia_valid &= ~ATTR_SIZE; | 
|  | 260 | } else if (S_ISCHR(mode) || S_ISBLK(mode)) { | 
|  | 261 | sattr->ia_valid |= ATTR_SIZE; | 
|  | 262 | sattr->ia_size = new_encode_dev(rdev);/* get out your barf bag */ | 
|  | 263 | } | 
|  | 264 |  | 
| Trond Myklebust | 0e574af | 2005-10-27 22:12:38 -0400 | [diff] [blame] | 265 | nfs_fattr_init(&fattr); | 
| Chuck Lever | dead28d | 2006-03-20 13:44:23 -0500 | [diff] [blame] | 266 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); | 
| Trond Myklebust | decf491 | 2005-10-27 22:12:39 -0400 | [diff] [blame] | 267 | nfs_mark_for_revalidate(dir); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 268 |  | 
|  | 269 | if (status == -EINVAL && S_ISFIFO(mode)) { | 
|  | 270 | sattr->ia_mode = mode; | 
| Trond Myklebust | 0e574af | 2005-10-27 22:12:38 -0400 | [diff] [blame] | 271 | nfs_fattr_init(&fattr); | 
| Chuck Lever | dead28d | 2006-03-20 13:44:23 -0500 | [diff] [blame] | 272 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 273 | } | 
|  | 274 | if (status == 0) | 
|  | 275 | status = nfs_instantiate(dentry, &fhandle, &fattr); | 
|  | 276 | dprintk("NFS reply mknod: %d\n", status); | 
|  | 277 | return status; | 
|  | 278 | } | 
|  | 279 |  | 
|  | 280 | static int | 
|  | 281 | nfs_proc_remove(struct inode *dir, struct qstr *name) | 
|  | 282 | { | 
| Trond Myklebust | 4fdc17b | 2007-07-14 15:39:57 -0400 | [diff] [blame] | 283 | struct nfs_removeargs arg = { | 
|  | 284 | .fh = NFS_FH(dir), | 
|  | 285 | .name.len = name->len, | 
|  | 286 | .name.name = name->name, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 287 | }; | 
| Trond Myklebust | 4fdc17b | 2007-07-14 15:39:57 -0400 | [diff] [blame] | 288 | struct rpc_message msg = { | 
|  | 289 | .rpc_proc = &nfs_procedures[NFSPROC_REMOVE], | 
|  | 290 | .rpc_argp = &arg, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | }; | 
|  | 292 | int			status; | 
|  | 293 |  | 
|  | 294 | dprintk("NFS call  remove %s\n", name->name); | 
|  | 295 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); | 
| Trond Myklebust | decf491 | 2005-10-27 22:12:39 -0400 | [diff] [blame] | 296 | nfs_mark_for_revalidate(dir); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 |  | 
|  | 298 | dprintk("NFS reply remove: %d\n", status); | 
|  | 299 | return status; | 
|  | 300 | } | 
|  | 301 |  | 
| Trond Myklebust | e4eff1a | 2007-07-14 15:39:58 -0400 | [diff] [blame] | 302 | static void | 
|  | 303 | nfs_proc_unlink_setup(struct rpc_message *msg, struct inode *dir) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 305 | msg->rpc_proc = &nfs_procedures[NFSPROC_REMOVE]; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | } | 
|  | 307 |  | 
| Trond Myklebust | e4eff1a | 2007-07-14 15:39:58 -0400 | [diff] [blame] | 308 | static int nfs_proc_unlink_done(struct rpc_task *task, struct inode *dir) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 309 | { | 
| Trond Myklebust | e4eff1a | 2007-07-14 15:39:58 -0400 | [diff] [blame] | 310 | nfs_mark_for_revalidate(dir); | 
|  | 311 | return 1; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 312 | } | 
|  | 313 |  | 
|  | 314 | static int | 
|  | 315 | nfs_proc_rename(struct inode *old_dir, struct qstr *old_name, | 
|  | 316 | struct inode *new_dir, struct qstr *new_name) | 
|  | 317 | { | 
|  | 318 | struct nfs_renameargs	arg = { | 
|  | 319 | .fromfh		= NFS_FH(old_dir), | 
|  | 320 | .fromname	= old_name->name, | 
|  | 321 | .fromlen	= old_name->len, | 
|  | 322 | .tofh		= NFS_FH(new_dir), | 
|  | 323 | .toname		= new_name->name, | 
|  | 324 | .tolen		= new_name->len | 
|  | 325 | }; | 
| Chuck Lever | dead28d | 2006-03-20 13:44:23 -0500 | [diff] [blame] | 326 | struct rpc_message msg = { | 
|  | 327 | .rpc_proc	= &nfs_procedures[NFSPROC_RENAME], | 
|  | 328 | .rpc_argp	= &arg, | 
|  | 329 | }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 330 | int			status; | 
|  | 331 |  | 
|  | 332 | dprintk("NFS call  rename %s -> %s\n", old_name->name, new_name->name); | 
| Chuck Lever | dead28d | 2006-03-20 13:44:23 -0500 | [diff] [blame] | 333 | status = rpc_call_sync(NFS_CLIENT(old_dir), &msg, 0); | 
| Trond Myklebust | decf491 | 2005-10-27 22:12:39 -0400 | [diff] [blame] | 334 | nfs_mark_for_revalidate(old_dir); | 
|  | 335 | nfs_mark_for_revalidate(new_dir); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 336 | dprintk("NFS reply rename: %d\n", status); | 
|  | 337 | return status; | 
|  | 338 | } | 
|  | 339 |  | 
|  | 340 | static int | 
|  | 341 | nfs_proc_link(struct inode *inode, struct inode *dir, struct qstr *name) | 
|  | 342 | { | 
|  | 343 | struct nfs_linkargs	arg = { | 
|  | 344 | .fromfh		= NFS_FH(inode), | 
|  | 345 | .tofh		= NFS_FH(dir), | 
|  | 346 | .toname		= name->name, | 
|  | 347 | .tolen		= name->len | 
|  | 348 | }; | 
| Chuck Lever | dead28d | 2006-03-20 13:44:23 -0500 | [diff] [blame] | 349 | struct rpc_message msg = { | 
|  | 350 | .rpc_proc	= &nfs_procedures[NFSPROC_LINK], | 
|  | 351 | .rpc_argp	= &arg, | 
|  | 352 | }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 353 | int			status; | 
|  | 354 |  | 
|  | 355 | dprintk("NFS call  link %s\n", name->name); | 
| Chuck Lever | dead28d | 2006-03-20 13:44:23 -0500 | [diff] [blame] | 356 | status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0); | 
| Trond Myklebust | 5ba7cc4 | 2005-12-03 15:20:17 -0500 | [diff] [blame] | 357 | nfs_mark_for_revalidate(inode); | 
| Trond Myklebust | decf491 | 2005-10-27 22:12:39 -0400 | [diff] [blame] | 358 | nfs_mark_for_revalidate(dir); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 359 | dprintk("NFS reply link: %d\n", status); | 
|  | 360 | return status; | 
|  | 361 | } | 
|  | 362 |  | 
|  | 363 | static int | 
| Chuck Lever | 94a6d75 | 2006-08-22 20:06:23 -0400 | [diff] [blame] | 364 | nfs_proc_symlink(struct inode *dir, struct dentry *dentry, struct page *page, | 
|  | 365 | unsigned int len, struct iattr *sattr) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 366 | { | 
| Chuck Lever | 4f390c1 | 2006-08-22 20:06:22 -0400 | [diff] [blame] | 367 | struct nfs_fh fhandle; | 
|  | 368 | struct nfs_fattr fattr; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 369 | struct nfs_symlinkargs	arg = { | 
|  | 370 | .fromfh		= NFS_FH(dir), | 
| Chuck Lever | 4f390c1 | 2006-08-22 20:06:22 -0400 | [diff] [blame] | 371 | .fromname	= dentry->d_name.name, | 
|  | 372 | .fromlen	= dentry->d_name.len, | 
| Chuck Lever | 94a6d75 | 2006-08-22 20:06:23 -0400 | [diff] [blame] | 373 | .pages		= &page, | 
|  | 374 | .pathlen	= len, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 375 | .sattr		= sattr | 
|  | 376 | }; | 
| Chuck Lever | dead28d | 2006-03-20 13:44:23 -0500 | [diff] [blame] | 377 | struct rpc_message msg = { | 
|  | 378 | .rpc_proc	= &nfs_procedures[NFSPROC_SYMLINK], | 
|  | 379 | .rpc_argp	= &arg, | 
|  | 380 | }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 381 | int			status; | 
|  | 382 |  | 
| Chuck Lever | 94a6d75 | 2006-08-22 20:06:23 -0400 | [diff] [blame] | 383 | if (len > NFS2_MAXPATHLEN) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 384 | return -ENAMETOOLONG; | 
| Chuck Lever | 4f390c1 | 2006-08-22 20:06:22 -0400 | [diff] [blame] | 385 |  | 
| Chuck Lever | 94a6d75 | 2006-08-22 20:06:23 -0400 | [diff] [blame] | 386 | dprintk("NFS call  symlink %s\n", dentry->d_name.name); | 
|  | 387 |  | 
| Chuck Lever | dead28d | 2006-03-20 13:44:23 -0500 | [diff] [blame] | 388 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); | 
| Trond Myklebust | decf491 | 2005-10-27 22:12:39 -0400 | [diff] [blame] | 389 | nfs_mark_for_revalidate(dir); | 
| Chuck Lever | 4f390c1 | 2006-08-22 20:06:22 -0400 | [diff] [blame] | 390 |  | 
|  | 391 | /* | 
|  | 392 | * V2 SYMLINK requests don't return any attributes.  Setting the | 
|  | 393 | * filehandle size to zero indicates to nfs_instantiate that it | 
|  | 394 | * should fill in the data with a LOOKUP call on the wire. | 
|  | 395 | */ | 
|  | 396 | if (status == 0) { | 
|  | 397 | nfs_fattr_init(&fattr); | 
|  | 398 | fhandle.size = 0; | 
|  | 399 | status = nfs_instantiate(dentry, &fhandle, &fattr); | 
|  | 400 | } | 
|  | 401 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 402 | dprintk("NFS reply symlink: %d\n", status); | 
|  | 403 | return status; | 
|  | 404 | } | 
|  | 405 |  | 
|  | 406 | static int | 
|  | 407 | nfs_proc_mkdir(struct inode *dir, struct dentry *dentry, struct iattr *sattr) | 
|  | 408 | { | 
|  | 409 | struct nfs_fh fhandle; | 
|  | 410 | struct nfs_fattr fattr; | 
|  | 411 | struct nfs_createargs	arg = { | 
|  | 412 | .fh		= NFS_FH(dir), | 
|  | 413 | .name		= dentry->d_name.name, | 
|  | 414 | .len		= dentry->d_name.len, | 
|  | 415 | .sattr		= sattr | 
|  | 416 | }; | 
|  | 417 | struct nfs_diropok	res = { | 
|  | 418 | .fh		= &fhandle, | 
|  | 419 | .fattr		= &fattr | 
|  | 420 | }; | 
| Chuck Lever | dead28d | 2006-03-20 13:44:23 -0500 | [diff] [blame] | 421 | struct rpc_message msg = { | 
|  | 422 | .rpc_proc	= &nfs_procedures[NFSPROC_MKDIR], | 
|  | 423 | .rpc_argp	= &arg, | 
|  | 424 | .rpc_resp	= &res, | 
|  | 425 | }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 426 | int			status; | 
|  | 427 |  | 
|  | 428 | dprintk("NFS call  mkdir %s\n", dentry->d_name.name); | 
| Trond Myklebust | 0e574af | 2005-10-27 22:12:38 -0400 | [diff] [blame] | 429 | nfs_fattr_init(&fattr); | 
| Chuck Lever | dead28d | 2006-03-20 13:44:23 -0500 | [diff] [blame] | 430 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); | 
| Trond Myklebust | decf491 | 2005-10-27 22:12:39 -0400 | [diff] [blame] | 431 | nfs_mark_for_revalidate(dir); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 432 | if (status == 0) | 
|  | 433 | status = nfs_instantiate(dentry, &fhandle, &fattr); | 
|  | 434 | dprintk("NFS reply mkdir: %d\n", status); | 
|  | 435 | return status; | 
|  | 436 | } | 
|  | 437 |  | 
|  | 438 | static int | 
|  | 439 | nfs_proc_rmdir(struct inode *dir, struct qstr *name) | 
|  | 440 | { | 
|  | 441 | struct nfs_diropargs	arg = { | 
|  | 442 | .fh		= NFS_FH(dir), | 
|  | 443 | .name		= name->name, | 
|  | 444 | .len		= name->len | 
|  | 445 | }; | 
| Chuck Lever | dead28d | 2006-03-20 13:44:23 -0500 | [diff] [blame] | 446 | struct rpc_message msg = { | 
|  | 447 | .rpc_proc	= &nfs_procedures[NFSPROC_RMDIR], | 
|  | 448 | .rpc_argp	= &arg, | 
|  | 449 | }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 | int			status; | 
|  | 451 |  | 
|  | 452 | dprintk("NFS call  rmdir %s\n", name->name); | 
| Chuck Lever | dead28d | 2006-03-20 13:44:23 -0500 | [diff] [blame] | 453 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); | 
| Trond Myklebust | decf491 | 2005-10-27 22:12:39 -0400 | [diff] [blame] | 454 | nfs_mark_for_revalidate(dir); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 455 | dprintk("NFS reply rmdir: %d\n", status); | 
|  | 456 | return status; | 
|  | 457 | } | 
|  | 458 |  | 
|  | 459 | /* | 
|  | 460 | * The READDIR implementation is somewhat hackish - we pass a temporary | 
|  | 461 | * buffer to the encode function, which installs it in the receive | 
|  | 462 | * the receive iovec. The decode function just parses the reply to make | 
|  | 463 | * sure it is syntactically correct; the entries itself are decoded | 
|  | 464 | * from nfs_readdir by calling the decode_entry function directly. | 
|  | 465 | */ | 
|  | 466 | static int | 
|  | 467 | nfs_proc_readdir(struct dentry *dentry, struct rpc_cred *cred, | 
|  | 468 | u64 cookie, struct page *page, unsigned int count, int plus) | 
|  | 469 | { | 
|  | 470 | struct inode		*dir = dentry->d_inode; | 
|  | 471 | struct nfs_readdirargs	arg = { | 
|  | 472 | .fh		= NFS_FH(dir), | 
|  | 473 | .cookie		= cookie, | 
|  | 474 | .count		= count, | 
| Chuck Lever | dead28d | 2006-03-20 13:44:23 -0500 | [diff] [blame] | 475 | .pages		= &page, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 476 | }; | 
|  | 477 | struct rpc_message	msg = { | 
|  | 478 | .rpc_proc	= &nfs_procedures[NFSPROC_READDIR], | 
|  | 479 | .rpc_argp	= &arg, | 
| Chuck Lever | dead28d | 2006-03-20 13:44:23 -0500 | [diff] [blame] | 480 | .rpc_cred	= cred, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 481 | }; | 
|  | 482 | int			status; | 
|  | 483 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 484 | dprintk("NFS call  readdir %d\n", (unsigned int)cookie); | 
|  | 485 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); | 
|  | 486 |  | 
| Trond Myklebust | c481299 | 2007-09-28 17:11:45 -0400 | [diff] [blame] | 487 | nfs_invalidate_atime(dir); | 
|  | 488 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 489 | dprintk("NFS reply readdir: %d\n", status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 490 | return status; | 
|  | 491 | } | 
|  | 492 |  | 
|  | 493 | static int | 
|  | 494 | nfs_proc_statfs(struct nfs_server *server, struct nfs_fh *fhandle, | 
|  | 495 | struct nfs_fsstat *stat) | 
|  | 496 | { | 
|  | 497 | struct nfs2_fsstat fsinfo; | 
| Chuck Lever | dead28d | 2006-03-20 13:44:23 -0500 | [diff] [blame] | 498 | struct rpc_message msg = { | 
|  | 499 | .rpc_proc	= &nfs_procedures[NFSPROC_STATFS], | 
|  | 500 | .rpc_argp	= fhandle, | 
|  | 501 | .rpc_resp	= &fsinfo, | 
|  | 502 | }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 503 | int	status; | 
|  | 504 |  | 
|  | 505 | dprintk("NFS call  statfs\n"); | 
| Trond Myklebust | 0e574af | 2005-10-27 22:12:38 -0400 | [diff] [blame] | 506 | nfs_fattr_init(stat->fattr); | 
| Chuck Lever | dead28d | 2006-03-20 13:44:23 -0500 | [diff] [blame] | 507 | status = rpc_call_sync(server->client, &msg, 0); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 508 | dprintk("NFS reply statfs: %d\n", status); | 
|  | 509 | if (status) | 
|  | 510 | goto out; | 
|  | 511 | stat->tbytes = (u64)fsinfo.blocks * fsinfo.bsize; | 
|  | 512 | stat->fbytes = (u64)fsinfo.bfree  * fsinfo.bsize; | 
|  | 513 | stat->abytes = (u64)fsinfo.bavail * fsinfo.bsize; | 
|  | 514 | stat->tfiles = 0; | 
|  | 515 | stat->ffiles = 0; | 
|  | 516 | stat->afiles = 0; | 
|  | 517 | out: | 
|  | 518 | return status; | 
|  | 519 | } | 
|  | 520 |  | 
|  | 521 | static int | 
|  | 522 | nfs_proc_fsinfo(struct nfs_server *server, struct nfs_fh *fhandle, | 
|  | 523 | struct nfs_fsinfo *info) | 
|  | 524 | { | 
|  | 525 | struct nfs2_fsstat fsinfo; | 
| Chuck Lever | dead28d | 2006-03-20 13:44:23 -0500 | [diff] [blame] | 526 | struct rpc_message msg = { | 
|  | 527 | .rpc_proc	= &nfs_procedures[NFSPROC_STATFS], | 
|  | 528 | .rpc_argp	= fhandle, | 
|  | 529 | .rpc_resp	= &fsinfo, | 
|  | 530 | }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 531 | int	status; | 
|  | 532 |  | 
|  | 533 | dprintk("NFS call  fsinfo\n"); | 
| Trond Myklebust | 0e574af | 2005-10-27 22:12:38 -0400 | [diff] [blame] | 534 | nfs_fattr_init(info->fattr); | 
| Chuck Lever | dead28d | 2006-03-20 13:44:23 -0500 | [diff] [blame] | 535 | status = rpc_call_sync(server->client, &msg, 0); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 536 | dprintk("NFS reply fsinfo: %d\n", status); | 
|  | 537 | if (status) | 
|  | 538 | goto out; | 
|  | 539 | info->rtmax  = NFS_MAXDATA; | 
|  | 540 | info->rtpref = fsinfo.tsize; | 
|  | 541 | info->rtmult = fsinfo.bsize; | 
|  | 542 | info->wtmax  = NFS_MAXDATA; | 
|  | 543 | info->wtpref = fsinfo.tsize; | 
|  | 544 | info->wtmult = fsinfo.bsize; | 
|  | 545 | info->dtpref = fsinfo.tsize; | 
|  | 546 | info->maxfilesize = 0x7FFFFFFF; | 
|  | 547 | info->lease_time = 0; | 
|  | 548 | out: | 
|  | 549 | return status; | 
|  | 550 | } | 
|  | 551 |  | 
|  | 552 | static int | 
|  | 553 | nfs_proc_pathconf(struct nfs_server *server, struct nfs_fh *fhandle, | 
|  | 554 | struct nfs_pathconf *info) | 
|  | 555 | { | 
|  | 556 | info->max_link = 0; | 
|  | 557 | info->max_namelen = NFS2_MAXNAMLEN; | 
|  | 558 | return 0; | 
|  | 559 | } | 
|  | 560 |  | 
| Trond Myklebust | ec06c09 | 2006-03-20 13:44:27 -0500 | [diff] [blame] | 561 | static int nfs_read_done(struct rpc_task *task, struct nfs_read_data *data) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 562 | { | 
| Trond Myklebust | 8850df9 | 2007-09-28 17:20:07 -0400 | [diff] [blame] | 563 | nfs_invalidate_atime(data->inode); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 564 | if (task->tk_status >= 0) { | 
|  | 565 | nfs_refresh_inode(data->inode, data->res.fattr); | 
|  | 566 | /* Emulate the eof flag, which isn't normally needed in NFSv2 | 
|  | 567 | * as it is guaranteed to always return the file attributes | 
|  | 568 | */ | 
|  | 569 | if (data->args.offset + data->args.count >= data->res.fattr->size) | 
|  | 570 | data->res.eof = 1; | 
|  | 571 | } | 
| Trond Myklebust | ec06c09 | 2006-03-20 13:44:27 -0500 | [diff] [blame] | 572 | return 0; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 573 | } | 
|  | 574 |  | 
| Trond Myklebust | bdc7f02 | 2007-07-14 15:40:00 -0400 | [diff] [blame] | 575 | static void nfs_proc_read_setup(struct nfs_read_data *data, struct rpc_message *msg) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 576 | { | 
| Trond Myklebust | bdc7f02 | 2007-07-14 15:40:00 -0400 | [diff] [blame] | 577 | msg->rpc_proc = &nfs_procedures[NFSPROC_READ]; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 578 | } | 
|  | 579 |  | 
| Trond Myklebust | 788e7a8 | 2006-03-20 13:44:27 -0500 | [diff] [blame] | 580 | static int nfs_write_done(struct rpc_task *task, struct nfs_write_data *data) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 581 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 582 | if (task->tk_status >= 0) | 
| Trond Myklebust | 70ca885 | 2007-09-30 15:21:24 -0400 | [diff] [blame] | 583 | nfs_post_op_update_inode_force_wcc(data->inode, data->res.fattr); | 
| Trond Myklebust | 788e7a8 | 2006-03-20 13:44:27 -0500 | [diff] [blame] | 584 | return 0; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 585 | } | 
|  | 586 |  | 
| Trond Myklebust | bdc7f02 | 2007-07-14 15:40:00 -0400 | [diff] [blame] | 587 | static void nfs_proc_write_setup(struct nfs_write_data *data, struct rpc_message *msg) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 588 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 589 | /* Note: NFSv2 ignores @stable and always uses NFS_FILE_SYNC */ | 
|  | 590 | data->args.stable = NFS_FILE_SYNC; | 
| Trond Myklebust | bdc7f02 | 2007-07-14 15:40:00 -0400 | [diff] [blame] | 591 | msg->rpc_proc = &nfs_procedures[NFSPROC_WRITE]; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 592 | } | 
|  | 593 |  | 
|  | 594 | static void | 
| Trond Myklebust | bdc7f02 | 2007-07-14 15:40:00 -0400 | [diff] [blame] | 595 | nfs_proc_commit_setup(struct nfs_write_data *data, struct rpc_message *msg) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 596 | { | 
|  | 597 | BUG(); | 
|  | 598 | } | 
|  | 599 |  | 
|  | 600 | static int | 
|  | 601 | nfs_proc_lock(struct file *filp, int cmd, struct file_lock *fl) | 
|  | 602 | { | 
| Chuck Lever | 1093a60 | 2008-01-11 17:09:59 -0500 | [diff] [blame] | 603 | struct inode *inode = filp->f_path.dentry->d_inode; | 
|  | 604 |  | 
|  | 605 | return nlmclnt_proc(NFS_SERVER(inode)->nlm_host, cmd, fl); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 606 | } | 
|  | 607 |  | 
| Trond Myklebust | 2116271 | 2008-05-20 19:34:39 -0400 | [diff] [blame] | 608 | /* Helper functions for NFS lock bounds checking */ | 
|  | 609 | #define NFS_LOCK32_OFFSET_MAX ((__s32)0x7fffffffUL) | 
|  | 610 | static int nfs_lock_check_bounds(const struct file_lock *fl) | 
|  | 611 | { | 
|  | 612 | __s32 start, end; | 
|  | 613 |  | 
|  | 614 | start = (__s32)fl->fl_start; | 
|  | 615 | if ((loff_t)start != fl->fl_start) | 
|  | 616 | goto out_einval; | 
|  | 617 |  | 
|  | 618 | if (fl->fl_end != OFFSET_MAX) { | 
|  | 619 | end = (__s32)fl->fl_end; | 
|  | 620 | if ((loff_t)end != fl->fl_end) | 
|  | 621 | goto out_einval; | 
|  | 622 | } else | 
|  | 623 | end = NFS_LOCK32_OFFSET_MAX; | 
|  | 624 |  | 
|  | 625 | if (start < 0 || start > end) | 
|  | 626 | goto out_einval; | 
|  | 627 | return 0; | 
|  | 628 | out_einval: | 
|  | 629 | return -EINVAL; | 
|  | 630 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 631 |  | 
| David Howells | 509de81 | 2006-08-22 20:06:11 -0400 | [diff] [blame] | 632 | const struct nfs_rpc_ops nfs_v2_clientops = { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 633 | .version	= 2,		       /* protocol version */ | 
|  | 634 | .dentry_ops	= &nfs_dentry_operations, | 
|  | 635 | .dir_inode_ops	= &nfs_dir_inode_operations, | 
| J. Bruce Fields | 92cfc62 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 636 | .file_inode_ops	= &nfs_file_inode_operations, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 637 | .getroot	= nfs_proc_get_root, | 
|  | 638 | .getattr	= nfs_proc_getattr, | 
|  | 639 | .setattr	= nfs_proc_setattr, | 
|  | 640 | .lookup		= nfs_proc_lookup, | 
|  | 641 | .access		= NULL,		       /* access */ | 
|  | 642 | .readlink	= nfs_proc_readlink, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 643 | .create		= nfs_proc_create, | 
|  | 644 | .remove		= nfs_proc_remove, | 
|  | 645 | .unlink_setup	= nfs_proc_unlink_setup, | 
|  | 646 | .unlink_done	= nfs_proc_unlink_done, | 
|  | 647 | .rename		= nfs_proc_rename, | 
|  | 648 | .link		= nfs_proc_link, | 
|  | 649 | .symlink	= nfs_proc_symlink, | 
|  | 650 | .mkdir		= nfs_proc_mkdir, | 
|  | 651 | .rmdir		= nfs_proc_rmdir, | 
|  | 652 | .readdir	= nfs_proc_readdir, | 
|  | 653 | .mknod		= nfs_proc_mknod, | 
|  | 654 | .statfs		= nfs_proc_statfs, | 
|  | 655 | .fsinfo		= nfs_proc_fsinfo, | 
|  | 656 | .pathconf	= nfs_proc_pathconf, | 
|  | 657 | .decode_dirent	= nfs_decode_dirent, | 
|  | 658 | .read_setup	= nfs_proc_read_setup, | 
| Trond Myklebust | ec06c09 | 2006-03-20 13:44:27 -0500 | [diff] [blame] | 659 | .read_done	= nfs_read_done, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 660 | .write_setup	= nfs_proc_write_setup, | 
| Trond Myklebust | 788e7a8 | 2006-03-20 13:44:27 -0500 | [diff] [blame] | 661 | .write_done	= nfs_write_done, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 662 | .commit_setup	= nfs_proc_commit_setup, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 663 | .lock		= nfs_proc_lock, | 
| Trond Myklebust | 2116271 | 2008-05-20 19:34:39 -0400 | [diff] [blame] | 664 | .lock_check_bounds = nfs_lock_check_bounds, | 
| Trond Myklebust | 7fe5c39 | 2009-03-19 15:35:50 -0400 | [diff] [blame] | 665 | .close_context	= nfs_close_context, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 666 | }; |