Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * Process version 3 NFS requests. |
| 4 | * |
| 5 | * Copyright (C) 1996, 1997, 1998 Olaf Kirch <okir@monad.swb.de> |
| 6 | */ |
| 7 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | #include <linux/fs.h> |
| 9 | #include <linux/ext2_fs.h> |
Qinghuang Feng | 12214cb | 2009-01-12 03:13:53 +0800 | [diff] [blame] | 10 | #include <linux/magic.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | |
Boaz Harrosh | 9a74af2 | 2009-12-03 20:30:56 +0200 | [diff] [blame] | 12 | #include "cache.h" |
| 13 | #include "xdr3.h" |
J. Bruce Fields | 0a3adad | 2009-11-04 18:12:35 -0500 | [diff] [blame] | 14 | #include "vfs.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | |
| 16 | #define NFSDDBG_FACILITY NFSDDBG_PROC |
| 17 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | static int nfs3_ftypes[] = { |
| 19 | 0, /* NF3NON */ |
| 20 | S_IFREG, /* NF3REG */ |
| 21 | S_IFDIR, /* NF3DIR */ |
| 22 | S_IFBLK, /* NF3BLK */ |
| 23 | S_IFCHR, /* NF3CHR */ |
| 24 | S_IFLNK, /* NF3LNK */ |
| 25 | S_IFSOCK, /* NF3SOCK */ |
| 26 | S_IFIFO, /* NF3FIFO */ |
| 27 | }; |
| 28 | |
| 29 | /* |
| 30 | * NULL call. |
| 31 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 32 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 33 | nfsd3_proc_null(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | { |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 35 | return rpc_success; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | /* |
| 39 | * Get a file's attributes |
| 40 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 41 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 42 | nfsd3_proc_getattr(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 44 | struct nfsd_fhandle *argp = rqstp->rq_argp; |
| 45 | struct nfsd3_attrstat *resp = rqstp->rq_resp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | |
| 47 | dprintk("nfsd: GETATTR(3) %s\n", |
David Shaw | a334de2 | 2006-01-06 00:19:58 -0800 | [diff] [blame] | 48 | SVCFH_fmt(&argp->fh)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | |
| 50 | fh_copy(&resp->fh, &argp->fh); |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 51 | resp->status = fh_verify(rqstp, &resp->fh, 0, |
| 52 | NFSD_MAY_NOP | NFSD_MAY_BYPASS_GSS_ON_ROOT); |
| 53 | if (resp->status != nfs_ok) |
| 54 | goto out; |
David Shaw | a334de2 | 2006-01-06 00:19:58 -0800 | [diff] [blame] | 55 | |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 56 | resp->status = fh_getattr(&resp->fh, &resp->stat); |
| 57 | out: |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 58 | return rpc_success; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | /* |
| 62 | * Set a file's attributes |
| 63 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 64 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 65 | nfsd3_proc_setattr(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 67 | struct nfsd3_sattrargs *argp = rqstp->rq_argp; |
| 68 | struct nfsd3_attrstat *resp = rqstp->rq_resp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | |
| 70 | dprintk("nfsd: SETATTR(3) %s\n", |
| 71 | SVCFH_fmt(&argp->fh)); |
| 72 | |
| 73 | fh_copy(&resp->fh, &argp->fh); |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 74 | resp->status = nfsd_setattr(rqstp, &resp->fh, &argp->attrs, |
| 75 | argp->check_guard, argp->guardtime); |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 76 | return rpc_success; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | } |
| 78 | |
| 79 | /* |
| 80 | * Look up a path name component |
| 81 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 82 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 83 | nfsd3_proc_lookup(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 85 | struct nfsd3_diropargs *argp = rqstp->rq_argp; |
| 86 | struct nfsd3_diropres *resp = rqstp->rq_resp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | |
| 88 | dprintk("nfsd: LOOKUP(3) %s %.*s\n", |
| 89 | SVCFH_fmt(&argp->fh), |
| 90 | argp->len, |
| 91 | argp->name); |
| 92 | |
| 93 | fh_copy(&resp->dirfh, &argp->fh); |
| 94 | fh_init(&resp->fh, NFS3_FHSIZE); |
| 95 | |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 96 | resp->status = nfsd_lookup(rqstp, &resp->dirfh, |
| 97 | argp->name, argp->len, |
| 98 | &resp->fh); |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 99 | return rpc_success; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | /* |
| 103 | * Check file access |
| 104 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 105 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 106 | nfsd3_proc_access(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 108 | struct nfsd3_accessargs *argp = rqstp->rq_argp; |
| 109 | struct nfsd3_accessres *resp = rqstp->rq_resp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | |
| 111 | dprintk("nfsd: ACCESS(3) %s 0x%x\n", |
| 112 | SVCFH_fmt(&argp->fh), |
| 113 | argp->access); |
| 114 | |
| 115 | fh_copy(&resp->fh, &argp->fh); |
| 116 | resp->access = argp->access; |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 117 | resp->status = nfsd_access(rqstp, &resp->fh, &resp->access, NULL); |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 118 | return rpc_success; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | } |
| 120 | |
| 121 | /* |
| 122 | * Read a symlink. |
| 123 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 124 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 125 | nfsd3_proc_readlink(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | { |
Chuck Lever | 224c1c8 | 2020-10-24 12:51:18 -0400 | [diff] [blame] | 127 | struct nfsd_fhandle *argp = rqstp->rq_argp; |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 128 | struct nfsd3_readlinkres *resp = rqstp->rq_resp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | |
| 130 | dprintk("nfsd: READLINK(3) %s\n", SVCFH_fmt(&argp->fh)); |
| 131 | |
| 132 | /* Read the symlink. */ |
| 133 | fh_copy(&resp->fh, &argp->fh); |
| 134 | resp->len = NFS3_MAXPATHLEN; |
Chuck Lever | 9a9c892 | 2020-10-22 15:18:40 -0400 | [diff] [blame] | 135 | resp->pages = rqstp->rq_next_page++; |
| 136 | resp->status = nfsd_readlink(rqstp, &resp->fh, |
| 137 | page_address(*resp->pages), &resp->len); |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 138 | return rpc_success; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | } |
| 140 | |
| 141 | /* |
| 142 | * Read a portion of a file. |
| 143 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 144 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 145 | nfsd3_proc_read(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 147 | struct nfsd3_readargs *argp = rqstp->rq_argp; |
| 148 | struct nfsd3_readres *resp = rqstp->rq_resp; |
Chuck Lever | be63bd2 | 2020-10-20 14:34:40 -0400 | [diff] [blame] | 149 | u32 max_blocksize = svc_max_payload(rqstp); |
| 150 | unsigned int len; |
| 151 | int v; |
| 152 | |
J. Bruce Fields | 18b631f | 2010-11-29 15:28:10 -0500 | [diff] [blame] | 153 | dprintk("nfsd: READ(3) %s %lu bytes at %Lu\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | SVCFH_fmt(&argp->fh), |
| 155 | (unsigned long) argp->count, |
J. Bruce Fields | 18b631f | 2010-11-29 15:28:10 -0500 | [diff] [blame] | 156 | (unsigned long long) argp->offset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | |
Chuck Lever | 0cb4d23 | 2022-02-04 15:19:34 -0500 | [diff] [blame] | 158 | argp->count = min_t(u32, argp->count, max_blocksize); |
| 159 | if (argp->offset > (u64)OFFSET_MAX) |
| 160 | argp->offset = (u64)OFFSET_MAX; |
| 161 | if (argp->offset + argp->count > (u64)OFFSET_MAX) |
| 162 | argp->count = (u64)OFFSET_MAX - argp->offset; |
| 163 | |
Chuck Lever | be63bd2 | 2020-10-20 14:34:40 -0400 | [diff] [blame] | 164 | v = 0; |
| 165 | len = argp->count; |
Chuck Lever | cc9bcda | 2020-10-22 15:23:50 -0400 | [diff] [blame] | 166 | resp->pages = rqstp->rq_next_page; |
Chuck Lever | be63bd2 | 2020-10-20 14:34:40 -0400 | [diff] [blame] | 167 | while (len > 0) { |
| 168 | struct page *page = *(rqstp->rq_next_page++); |
| 169 | |
| 170 | rqstp->rq_vec[v].iov_base = page_address(page); |
| 171 | rqstp->rq_vec[v].iov_len = min_t(unsigned int, len, PAGE_SIZE); |
| 172 | len -= rqstp->rq_vec[v].iov_len; |
| 173 | v++; |
| 174 | } |
| 175 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | /* Obtain buffer pointer for payload. |
| 177 | * 1 (status) + 22 (post_op_attr) + 1 (count) + 1 (eof) |
| 178 | * + 1 (xdr opaque byte count) = 26 |
| 179 | */ |
Chuck Lever | be63bd2 | 2020-10-20 14:34:40 -0400 | [diff] [blame] | 180 | resp->count = argp->count; |
Jeff Layton | cd123012 | 2007-05-09 02:34:50 -0700 | [diff] [blame] | 181 | svc_reserve_auth(rqstp, ((1 + NFS3_POST_OP_ATTR_WORDS + 3)<<2) + resp->count +4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | |
| 183 | fh_copy(&resp->fh, &argp->fh); |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 184 | resp->status = nfsd_read(rqstp, &resp->fh, argp->offset, |
Chuck Lever | be63bd2 | 2020-10-20 14:34:40 -0400 | [diff] [blame] | 185 | rqstp->rq_vec, v, &resp->count, &resp->eof); |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 186 | return rpc_success; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 | } |
| 188 | |
| 189 | /* |
| 190 | * Write data to a file |
| 191 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 192 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 193 | nfsd3_proc_write(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 195 | struct nfsd3_writeargs *argp = rqstp->rq_argp; |
| 196 | struct nfsd3_writeres *resp = rqstp->rq_resp; |
David Shaw | 31dec25 | 2009-03-05 20:16:14 -0500 | [diff] [blame] | 197 | unsigned long cnt = argp->len; |
Chuck Lever | 8154ef2 | 2018-03-27 10:54:07 -0400 | [diff] [blame] | 198 | unsigned int nvecs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 199 | |
J. Bruce Fields | 18b631f | 2010-11-29 15:28:10 -0500 | [diff] [blame] | 200 | dprintk("nfsd: WRITE(3) %s %d bytes at %Lu%s\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 201 | SVCFH_fmt(&argp->fh), |
| 202 | argp->len, |
J. Bruce Fields | 18b631f | 2010-11-29 15:28:10 -0500 | [diff] [blame] | 203 | (unsigned long long) argp->offset, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 204 | argp->stable? " stable" : ""); |
| 205 | |
Chuck Lever | 6260d9a | 2022-01-25 16:36:22 -0500 | [diff] [blame] | 206 | resp->status = nfserr_fbig; |
| 207 | if (argp->offset > (u64)OFFSET_MAX || |
| 208 | argp->offset + argp->len > (u64)OFFSET_MAX) |
| 209 | return rpc_success; |
| 210 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | fh_copy(&resp->fh, &argp->fh); |
| 212 | resp->committed = argp->stable; |
Chuck Lever | dae9a6c | 2021-09-30 17:06:21 -0400 | [diff] [blame] | 213 | nvecs = svc_fill_write_vector(rqstp, &argp->payload); |
Chuck Lever | 6a2f774 | 2021-12-21 11:52:06 -0500 | [diff] [blame] | 214 | |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 215 | resp->status = nfsd_write(rqstp, &resp->fh, argp->offset, |
| 216 | rqstp->rq_vec, nvecs, &cnt, |
| 217 | resp->committed, resp->verf); |
David Shaw | 31dec25 | 2009-03-05 20:16:14 -0500 | [diff] [blame] | 218 | resp->count = cnt; |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 219 | return rpc_success; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 220 | } |
| 221 | |
| 222 | /* |
| 223 | * With NFSv3, CREATE processing is a lot easier than with NFSv2. |
| 224 | * At least in theory; we'll see how it fares in practice when the |
| 225 | * first reports about SunOS compatibility problems start to pour in... |
| 226 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 227 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 228 | nfsd3_proc_create(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 229 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 230 | struct nfsd3_createargs *argp = rqstp->rq_argp; |
| 231 | struct nfsd3_diropres *resp = rqstp->rq_resp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 232 | svc_fh *dirfhp, *newfhp = NULL; |
| 233 | struct iattr *attr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 234 | |
| 235 | dprintk("nfsd: CREATE(3) %s %.*s\n", |
| 236 | SVCFH_fmt(&argp->fh), |
| 237 | argp->len, |
| 238 | argp->name); |
| 239 | |
| 240 | dirfhp = fh_copy(&resp->dirfh, &argp->fh); |
| 241 | newfhp = fh_init(&resp->fh, NFS3_FHSIZE); |
| 242 | attr = &argp->attrs; |
| 243 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 244 | /* Unfudge the mode bits */ |
| 245 | attr->ia_mode &= ~S_IFMT; |
| 246 | if (!(attr->ia_valid & ATTR_MODE)) { |
| 247 | attr->ia_valid |= ATTR_MODE; |
| 248 | attr->ia_mode = S_IFREG; |
| 249 | } else { |
| 250 | attr->ia_mode = (attr->ia_mode & ~S_IFMT) | S_IFREG; |
| 251 | } |
| 252 | |
| 253 | /* Now create the file and set attributes */ |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 254 | resp->status = do_nfsd_create(rqstp, dirfhp, argp->name, argp->len, |
| 255 | attr, newfhp, argp->createmode, |
| 256 | (u32 *)argp->verf, NULL, NULL); |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 257 | return rpc_success; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 258 | } |
| 259 | |
| 260 | /* |
| 261 | * Make directory. This operation is not idempotent. |
| 262 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 263 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 264 | nfsd3_proc_mkdir(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 265 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 266 | struct nfsd3_createargs *argp = rqstp->rq_argp; |
| 267 | struct nfsd3_diropres *resp = rqstp->rq_resp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 268 | |
| 269 | dprintk("nfsd: MKDIR(3) %s %.*s\n", |
| 270 | SVCFH_fmt(&argp->fh), |
| 271 | argp->len, |
| 272 | argp->name); |
| 273 | |
| 274 | argp->attrs.ia_valid &= ~ATTR_SIZE; |
| 275 | fh_copy(&resp->dirfh, &argp->fh); |
| 276 | fh_init(&resp->fh, NFS3_FHSIZE); |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 277 | resp->status = nfsd_create(rqstp, &resp->dirfh, argp->name, argp->len, |
| 278 | &argp->attrs, S_IFDIR, 0, &resp->fh); |
Chuck Lever | 43a9aa6 | 2010-07-06 16:53:34 -0400 | [diff] [blame] | 279 | fh_unlock(&resp->dirfh); |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 280 | return rpc_success; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 281 | } |
| 282 | |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 283 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 284 | nfsd3_proc_symlink(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 285 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 286 | struct nfsd3_symlinkargs *argp = rqstp->rq_argp; |
| 287 | struct nfsd3_diropres *resp = rqstp->rq_resp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 289 | if (argp->tlen == 0) { |
| 290 | resp->status = nfserr_inval; |
| 291 | goto out; |
| 292 | } |
| 293 | if (argp->tlen > NFS3_MAXPATHLEN) { |
| 294 | resp->status = nfserr_nametoolong; |
| 295 | goto out; |
| 296 | } |
Chuck Lever | 38a7031 | 2018-03-27 10:54:21 -0400 | [diff] [blame] | 297 | |
| 298 | argp->tname = svc_fill_symlink_pathname(rqstp, &argp->first, |
Chuck Lever | 11b4d66 | 2018-07-27 11:19:10 -0400 | [diff] [blame] | 299 | page_address(rqstp->rq_arg.pages[0]), |
Chuck Lever | 38a7031 | 2018-03-27 10:54:21 -0400 | [diff] [blame] | 300 | argp->tlen); |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 301 | if (IS_ERR(argp->tname)) { |
| 302 | resp->status = nfserrno(PTR_ERR(argp->tname)); |
| 303 | goto out; |
| 304 | } |
Chuck Lever | 38a7031 | 2018-03-27 10:54:21 -0400 | [diff] [blame] | 305 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | dprintk("nfsd: SYMLINK(3) %s %.*s -> %.*s\n", |
| 307 | SVCFH_fmt(&argp->ffh), |
| 308 | argp->flen, argp->fname, |
| 309 | argp->tlen, argp->tname); |
| 310 | |
| 311 | fh_copy(&resp->dirfh, &argp->ffh); |
| 312 | fh_init(&resp->fh, NFS3_FHSIZE); |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 313 | resp->status = nfsd_symlink(rqstp, &resp->dirfh, argp->fname, |
| 314 | argp->flen, argp->tname, &resp->fh); |
Chuck Lever | 11b4d66 | 2018-07-27 11:19:10 -0400 | [diff] [blame] | 315 | kfree(argp->tname); |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 316 | out: |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 317 | return rpc_success; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 318 | } |
| 319 | |
| 320 | /* |
| 321 | * Make socket/fifo/device. |
| 322 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 323 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 324 | nfsd3_proc_mknod(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 325 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 326 | struct nfsd3_mknodargs *argp = rqstp->rq_argp; |
| 327 | struct nfsd3_diropres *resp = rqstp->rq_resp; |
Al Viro | c4d987b | 2006-10-19 23:29:00 -0700 | [diff] [blame] | 328 | int type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 329 | dev_t rdev = 0; |
| 330 | |
| 331 | dprintk("nfsd: MKNOD(3) %s %.*s\n", |
| 332 | SVCFH_fmt(&argp->fh), |
| 333 | argp->len, |
| 334 | argp->name); |
| 335 | |
| 336 | fh_copy(&resp->dirfh, &argp->fh); |
| 337 | fh_init(&resp->fh, NFS3_FHSIZE); |
| 338 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 339 | if (argp->ftype == NF3CHR || argp->ftype == NF3BLK) { |
| 340 | rdev = MKDEV(argp->major, argp->minor); |
| 341 | if (MAJOR(rdev) != argp->major || |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 342 | MINOR(rdev) != argp->minor) { |
| 343 | resp->status = nfserr_inval; |
| 344 | goto out; |
| 345 | } |
| 346 | } else if (argp->ftype != NF3SOCK && argp->ftype != NF3FIFO) { |
Chuck Lever | 66d60e3 | 2020-10-23 10:41:12 -0400 | [diff] [blame] | 347 | resp->status = nfserr_badtype; |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 348 | goto out; |
| 349 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 350 | |
| 351 | type = nfs3_ftypes[argp->ftype]; |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 352 | resp->status = nfsd_create(rqstp, &resp->dirfh, argp->name, argp->len, |
| 353 | &argp->attrs, type, rdev, &resp->fh); |
Chuck Lever | 43a9aa6 | 2010-07-06 16:53:34 -0400 | [diff] [blame] | 354 | fh_unlock(&resp->dirfh); |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 355 | out: |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 356 | return rpc_success; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 357 | } |
| 358 | |
| 359 | /* |
| 360 | * Remove file/fifo/socket etc. |
| 361 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 362 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 363 | nfsd3_proc_remove(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 364 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 365 | struct nfsd3_diropargs *argp = rqstp->rq_argp; |
| 366 | struct nfsd3_attrstat *resp = rqstp->rq_resp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 367 | |
| 368 | dprintk("nfsd: REMOVE(3) %s %.*s\n", |
| 369 | SVCFH_fmt(&argp->fh), |
| 370 | argp->len, |
| 371 | argp->name); |
| 372 | |
| 373 | /* Unlink. -S_IFDIR means file must not be a directory */ |
| 374 | fh_copy(&resp->fh, &argp->fh); |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 375 | resp->status = nfsd_unlink(rqstp, &resp->fh, -S_IFDIR, |
| 376 | argp->name, argp->len); |
Chuck Lever | 43a9aa6 | 2010-07-06 16:53:34 -0400 | [diff] [blame] | 377 | fh_unlock(&resp->fh); |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 378 | return rpc_success; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 379 | } |
| 380 | |
| 381 | /* |
| 382 | * Remove a directory |
| 383 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 384 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 385 | nfsd3_proc_rmdir(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 386 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 387 | struct nfsd3_diropargs *argp = rqstp->rq_argp; |
| 388 | struct nfsd3_attrstat *resp = rqstp->rq_resp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 389 | |
| 390 | dprintk("nfsd: RMDIR(3) %s %.*s\n", |
| 391 | SVCFH_fmt(&argp->fh), |
| 392 | argp->len, |
| 393 | argp->name); |
| 394 | |
| 395 | fh_copy(&resp->fh, &argp->fh); |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 396 | resp->status = nfsd_unlink(rqstp, &resp->fh, S_IFDIR, |
| 397 | argp->name, argp->len); |
Chuck Lever | 43a9aa6 | 2010-07-06 16:53:34 -0400 | [diff] [blame] | 398 | fh_unlock(&resp->fh); |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 399 | return rpc_success; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 400 | } |
| 401 | |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 402 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 403 | nfsd3_proc_rename(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 404 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 405 | struct nfsd3_renameargs *argp = rqstp->rq_argp; |
| 406 | struct nfsd3_renameres *resp = rqstp->rq_resp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 407 | |
| 408 | dprintk("nfsd: RENAME(3) %s %.*s ->\n", |
| 409 | SVCFH_fmt(&argp->ffh), |
| 410 | argp->flen, |
| 411 | argp->fname); |
| 412 | dprintk("nfsd: -> %s %.*s\n", |
| 413 | SVCFH_fmt(&argp->tfh), |
| 414 | argp->tlen, |
| 415 | argp->tname); |
| 416 | |
| 417 | fh_copy(&resp->ffh, &argp->ffh); |
| 418 | fh_copy(&resp->tfh, &argp->tfh); |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 419 | resp->status = nfsd_rename(rqstp, &resp->ffh, argp->fname, argp->flen, |
| 420 | &resp->tfh, argp->tname, argp->tlen); |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 421 | return rpc_success; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 422 | } |
| 423 | |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 424 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 425 | nfsd3_proc_link(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 426 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 427 | struct nfsd3_linkargs *argp = rqstp->rq_argp; |
| 428 | struct nfsd3_linkres *resp = rqstp->rq_resp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 429 | |
| 430 | dprintk("nfsd: LINK(3) %s ->\n", |
| 431 | SVCFH_fmt(&argp->ffh)); |
| 432 | dprintk("nfsd: -> %s %.*s\n", |
| 433 | SVCFH_fmt(&argp->tfh), |
| 434 | argp->tlen, |
| 435 | argp->tname); |
| 436 | |
| 437 | fh_copy(&resp->fh, &argp->ffh); |
| 438 | fh_copy(&resp->tfh, &argp->tfh); |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 439 | resp->status = nfsd_link(rqstp, &resp->tfh, argp->tname, argp->tlen, |
| 440 | &resp->fh); |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 441 | return rpc_success; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 442 | } |
| 443 | |
Chuck Lever | 40116eb | 2020-11-17 09:50:23 -0500 | [diff] [blame] | 444 | static void nfsd3_init_dirlist_pages(struct svc_rqst *rqstp, |
| 445 | struct nfsd3_readdirres *resp, |
Chuck Lever | 53b1119 | 2021-12-16 11:12:11 -0500 | [diff] [blame] | 446 | u32 count) |
Chuck Lever | 40116eb | 2020-11-17 09:50:23 -0500 | [diff] [blame] | 447 | { |
Chuck Lever | 7f87fc2 | 2020-10-22 19:46:58 -0400 | [diff] [blame] | 448 | struct xdr_buf *buf = &resp->dirlist; |
| 449 | struct xdr_stream *xdr = &resp->xdr; |
| 450 | |
Chuck Lever | 53b1119 | 2021-12-16 11:12:11 -0500 | [diff] [blame] | 451 | count = clamp(count, (u32)(XDR_UNIT * 2), svc_max_payload(rqstp)); |
Chuck Lever | 40116eb | 2020-11-17 09:50:23 -0500 | [diff] [blame] | 452 | |
Chuck Lever | 7f87fc2 | 2020-10-22 19:46:58 -0400 | [diff] [blame] | 453 | memset(buf, 0, sizeof(*buf)); |
Chuck Lever | 40116eb | 2020-11-17 09:50:23 -0500 | [diff] [blame] | 454 | |
Chuck Lever | 7f87fc2 | 2020-10-22 19:46:58 -0400 | [diff] [blame] | 455 | /* Reserve room for the NULL ptr & eof flag (-2 words) */ |
| 456 | buf->buflen = count - XDR_UNIT * 2; |
| 457 | buf->pages = rqstp->rq_next_page; |
Chuck Lever | 53b1119 | 2021-12-16 11:12:11 -0500 | [diff] [blame] | 458 | rqstp->rq_next_page += (buf->buflen + PAGE_SIZE - 1) >> PAGE_SHIFT; |
Chuck Lever | 7f87fc2 | 2020-10-22 19:46:58 -0400 | [diff] [blame] | 459 | |
| 460 | /* This is xdr_init_encode(), but it assumes that |
| 461 | * the head kvec has already been consumed. */ |
| 462 | xdr_set_scratch_buffer(xdr, NULL, 0); |
| 463 | xdr->buf = buf; |
| 464 | xdr->page_ptr = buf->pages; |
| 465 | xdr->iov = NULL; |
| 466 | xdr->p = page_address(*buf->pages); |
Chuck Lever | 53b1119 | 2021-12-16 11:12:11 -0500 | [diff] [blame] | 467 | xdr->end = (void *)xdr->p + min_t(u32, buf->buflen, PAGE_SIZE); |
Chuck Lever | 7f87fc2 | 2020-10-22 19:46:58 -0400 | [diff] [blame] | 468 | xdr->rqst = NULL; |
Chuck Lever | 40116eb | 2020-11-17 09:50:23 -0500 | [diff] [blame] | 469 | } |
| 470 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 471 | /* |
| 472 | * Read a portion of a directory. |
| 473 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 474 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 475 | nfsd3_proc_readdir(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 476 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 477 | struct nfsd3_readdirargs *argp = rqstp->rq_argp; |
| 478 | struct nfsd3_readdirres *resp = rqstp->rq_resp; |
Chuck Lever | 0a8f37f | 2020-11-10 10:24:39 -0500 | [diff] [blame] | 479 | loff_t offset; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 480 | |
| 481 | dprintk("nfsd: READDIR(3) %s %d bytes at %d\n", |
| 482 | SVCFH_fmt(&argp->fh), |
| 483 | argp->count, (u32) argp->cookie); |
| 484 | |
Chuck Lever | 40116eb | 2020-11-17 09:50:23 -0500 | [diff] [blame] | 485 | nfsd3_init_dirlist_pages(rqstp, resp, argp->count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 486 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 487 | fh_copy(&resp->fh, &argp->fh); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 488 | resp->common.err = nfs_ok; |
Chuck Lever | 7f87fc2 | 2020-10-22 19:46:58 -0400 | [diff] [blame] | 489 | resp->cookie_offset = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 490 | resp->rqstp = rqstp; |
Chuck Lever | 0a8f37f | 2020-11-10 10:24:39 -0500 | [diff] [blame] | 491 | offset = argp->cookie; |
Chuck Lever | 0a8f37f | 2020-11-10 10:24:39 -0500 | [diff] [blame] | 492 | resp->status = nfsd_readdir(rqstp, &resp->fh, &offset, |
Chuck Lever | 7f87fc2 | 2020-10-22 19:46:58 -0400 | [diff] [blame] | 493 | &resp->common, nfs3svc_encode_entry3); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 494 | memcpy(resp->verf, argp->verf, 8); |
Chuck Lever | a161e6c | 2020-11-10 09:57:14 -0500 | [diff] [blame] | 495 | nfs3svc_encode_cookie3(resp, offset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 496 | |
Chuck Lever | 76ed0dd | 2021-01-15 09:28:44 -0500 | [diff] [blame] | 497 | /* Recycle only pages that were part of the reply */ |
| 498 | rqstp->rq_next_page = resp->xdr.page_ptr + 1; |
| 499 | |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 500 | return rpc_success; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 501 | } |
| 502 | |
| 503 | /* |
| 504 | * Read a portion of a directory, including file handles and attrs. |
| 505 | * For now, we choose to ignore the dircount parameter. |
| 506 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 507 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 508 | nfsd3_proc_readdirplus(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 509 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 510 | struct nfsd3_readdirargs *argp = rqstp->rq_argp; |
| 511 | struct nfsd3_readdirres *resp = rqstp->rq_resp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 512 | loff_t offset; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 513 | |
| 514 | dprintk("nfsd: READDIR+(3) %s %d bytes at %d\n", |
| 515 | SVCFH_fmt(&argp->fh), |
| 516 | argp->count, (u32) argp->cookie); |
| 517 | |
Chuck Lever | 40116eb | 2020-11-17 09:50:23 -0500 | [diff] [blame] | 518 | nfsd3_init_dirlist_pages(rqstp, resp, argp->count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 519 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 520 | fh_copy(&resp->fh, &argp->fh); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 521 | resp->common.err = nfs_ok; |
Chuck Lever | 7f87fc2 | 2020-10-22 19:46:58 -0400 | [diff] [blame] | 522 | resp->cookie_offset = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 523 | resp->rqstp = rqstp; |
| 524 | offset = argp->cookie; |
Rajesh Ghanekar | 18c01ab | 2014-08-01 22:17:30 -0400 | [diff] [blame] | 525 | |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 526 | resp->status = fh_verify(rqstp, &resp->fh, S_IFDIR, NFSD_MAY_NOP); |
| 527 | if (resp->status != nfs_ok) |
| 528 | goto out; |
Rajesh Ghanekar | 18c01ab | 2014-08-01 22:17:30 -0400 | [diff] [blame] | 529 | |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 530 | if (resp->fh.fh_export->ex_flags & NFSEXP_NOREADDIRPLUS) { |
| 531 | resp->status = nfserr_notsupp; |
| 532 | goto out; |
| 533 | } |
Rajesh Ghanekar | 18c01ab | 2014-08-01 22:17:30 -0400 | [diff] [blame] | 534 | |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 535 | resp->status = nfsd_readdir(rqstp, &resp->fh, &offset, |
Chuck Lever | 7f87fc2 | 2020-10-22 19:46:58 -0400 | [diff] [blame] | 536 | &resp->common, nfs3svc_encode_entryplus3); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 537 | memcpy(resp->verf, argp->verf, 8); |
Chuck Lever | a161e6c | 2020-11-10 09:57:14 -0500 | [diff] [blame] | 538 | nfs3svc_encode_cookie3(resp, offset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 539 | |
Chuck Lever | 76ed0dd | 2021-01-15 09:28:44 -0500 | [diff] [blame] | 540 | /* Recycle only pages that were part of the reply */ |
| 541 | rqstp->rq_next_page = resp->xdr.page_ptr + 1; |
| 542 | |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 543 | out: |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 544 | return rpc_success; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 545 | } |
| 546 | |
| 547 | /* |
| 548 | * Get file system stats |
| 549 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 550 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 551 | nfsd3_proc_fsstat(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 552 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 553 | struct nfsd_fhandle *argp = rqstp->rq_argp; |
| 554 | struct nfsd3_fsstatres *resp = rqstp->rq_resp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 555 | |
| 556 | dprintk("nfsd: FSSTAT(3) %s\n", |
| 557 | SVCFH_fmt(&argp->fh)); |
| 558 | |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 559 | resp->status = nfsd_statfs(rqstp, &argp->fh, &resp->stats, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 560 | fh_put(&argp->fh); |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 561 | return rpc_success; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 562 | } |
| 563 | |
| 564 | /* |
| 565 | * Get file system info |
| 566 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 567 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 568 | nfsd3_proc_fsinfo(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 569 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 570 | struct nfsd_fhandle *argp = rqstp->rq_argp; |
| 571 | struct nfsd3_fsinfores *resp = rqstp->rq_resp; |
Greg Banks | 7adae48 | 2006-10-04 02:15:47 -0700 | [diff] [blame] | 572 | u32 max_blocksize = svc_max_payload(rqstp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 573 | |
| 574 | dprintk("nfsd: FSINFO(3) %s\n", |
| 575 | SVCFH_fmt(&argp->fh)); |
| 576 | |
Greg Banks | 7adae48 | 2006-10-04 02:15:47 -0700 | [diff] [blame] | 577 | resp->f_rtmax = max_blocksize; |
| 578 | resp->f_rtpref = max_blocksize; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 579 | resp->f_rtmult = PAGE_SIZE; |
Greg Banks | 7adae48 | 2006-10-04 02:15:47 -0700 | [diff] [blame] | 580 | resp->f_wtmax = max_blocksize; |
| 581 | resp->f_wtpref = max_blocksize; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 582 | resp->f_wtmult = PAGE_SIZE; |
NeilBrown | f875a79 | 2019-03-07 09:49:46 +1100 | [diff] [blame] | 583 | resp->f_dtpref = max_blocksize; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 584 | resp->f_maxfilesize = ~(u32) 0; |
| 585 | resp->f_properties = NFS3_FSF_DEFAULT; |
| 586 | |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 587 | resp->status = fh_verify(rqstp, &argp->fh, 0, |
| 588 | NFSD_MAY_NOP | NFSD_MAY_BYPASS_GSS_ON_ROOT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 589 | |
| 590 | /* Check special features of the file system. May request |
| 591 | * different read/write sizes for file systems known to have |
| 592 | * problems with large blocks */ |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 593 | if (resp->status == nfs_ok) { |
Al Viro | fc64005 | 2016-04-10 01:33:30 -0400 | [diff] [blame] | 594 | struct super_block *sb = argp->fh.fh_dentry->d_sb; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 595 | |
| 596 | /* Note that we don't care for remote fs's here */ |
Qinghuang Feng | 12214cb | 2009-01-12 03:13:53 +0800 | [diff] [blame] | 597 | if (sb->s_magic == MSDOS_SUPER_MAGIC) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 598 | resp->f_properties = NFS3_FSF_BILLYBOY; |
| 599 | } |
| 600 | resp->f_maxfilesize = sb->s_maxbytes; |
| 601 | } |
| 602 | |
| 603 | fh_put(&argp->fh); |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 604 | return rpc_success; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 605 | } |
| 606 | |
| 607 | /* |
| 608 | * Get pathconf info for the specified file |
| 609 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 610 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 611 | nfsd3_proc_pathconf(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 612 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 613 | struct nfsd_fhandle *argp = rqstp->rq_argp; |
| 614 | struct nfsd3_pathconfres *resp = rqstp->rq_resp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 615 | |
| 616 | dprintk("nfsd: PATHCONF(3) %s\n", |
| 617 | SVCFH_fmt(&argp->fh)); |
| 618 | |
| 619 | /* Set default pathconf */ |
| 620 | resp->p_link_max = 255; /* at least */ |
| 621 | resp->p_name_max = 255; /* at least */ |
| 622 | resp->p_no_trunc = 0; |
| 623 | resp->p_chown_restricted = 1; |
| 624 | resp->p_case_insensitive = 0; |
| 625 | resp->p_case_preserving = 1; |
| 626 | |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 627 | resp->status = fh_verify(rqstp, &argp->fh, 0, NFSD_MAY_NOP); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 628 | |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 629 | if (resp->status == nfs_ok) { |
Al Viro | fc64005 | 2016-04-10 01:33:30 -0400 | [diff] [blame] | 630 | struct super_block *sb = argp->fh.fh_dentry->d_sb; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 631 | |
| 632 | /* Note that we don't care for remote fs's here */ |
| 633 | switch (sb->s_magic) { |
| 634 | case EXT2_SUPER_MAGIC: |
| 635 | resp->p_link_max = EXT2_LINK_MAX; |
| 636 | resp->p_name_max = EXT2_NAME_LEN; |
| 637 | break; |
Qinghuang Feng | 12214cb | 2009-01-12 03:13:53 +0800 | [diff] [blame] | 638 | case MSDOS_SUPER_MAGIC: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 639 | resp->p_case_insensitive = 1; |
| 640 | resp->p_case_preserving = 0; |
| 641 | break; |
| 642 | } |
| 643 | } |
| 644 | |
| 645 | fh_put(&argp->fh); |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 646 | return rpc_success; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 647 | } |
| 648 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 649 | /* |
| 650 | * Commit a file (range) to stable storage. |
| 651 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 652 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 653 | nfsd3_proc_commit(struct svc_rqst *rqstp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 654 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 655 | struct nfsd3_commitargs *argp = rqstp->rq_argp; |
| 656 | struct nfsd3_commitres *resp = rqstp->rq_resp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 657 | |
| 658 | dprintk("nfsd: COMMIT(3) %s %u@%Lu\n", |
| 659 | SVCFH_fmt(&argp->fh), |
| 660 | argp->count, |
| 661 | (unsigned long long) argp->offset); |
| 662 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 663 | fh_copy(&resp->fh, &argp->fh); |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 664 | resp->status = nfsd_commit(rqstp, &resp->fh, argp->offset, |
| 665 | argp->count, resp->verf); |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 666 | return rpc_success; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 667 | } |
| 668 | |
| 669 | |
| 670 | /* |
| 671 | * NFSv3 Server procedures. |
| 672 | * Only the results of non-idempotent operations are cached. |
| 673 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 674 | #define nfs3svc_encode_attrstatres nfs3svc_encode_attrstat |
| 675 | #define nfs3svc_encode_wccstatres nfs3svc_encode_wccstat |
| 676 | #define nfsd3_mkdirargs nfsd3_createargs |
| 677 | #define nfsd3_readdirplusargs nfsd3_readdirargs |
| 678 | #define nfsd3_fhandleargs nfsd_fhandle |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 679 | #define nfsd3_attrstatres nfsd3_attrstat |
| 680 | #define nfsd3_wccstatres nfsd3_attrstat |
| 681 | #define nfsd3_createres nfsd3_diropres |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 682 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 683 | #define ST 1 /* status*/ |
| 684 | #define FH 17 /* filehandle with length */ |
| 685 | #define AT 21 /* attributes */ |
| 686 | #define pAT (1+AT) /* post attributes - conditional */ |
| 687 | #define WC (7+pAT) /* WCC attributes */ |
| 688 | |
Christoph Hellwig | 860bda2 | 2017-05-12 16:11:49 +0200 | [diff] [blame] | 689 | static const struct svc_procedure nfsd_procedures3[22] = { |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 690 | [NFS3PROC_NULL] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 691 | .pc_func = nfsd3_proc_null, |
Chuck Lever | 788f718 | 2020-11-05 14:48:29 -0500 | [diff] [blame] | 692 | .pc_decode = nfssvc_decode_voidarg, |
| 693 | .pc_encode = nfssvc_encode_voidres, |
| 694 | .pc_argsize = sizeof(struct nfsd_voidargs), |
| 695 | .pc_ressize = sizeof(struct nfsd_voidres), |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 696 | .pc_cachetype = RC_NOCACHE, |
| 697 | .pc_xdrressize = ST, |
Chuck Lever | 2289e87 | 2020-09-17 17:22:49 -0400 | [diff] [blame] | 698 | .pc_name = "NULL", |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 699 | }, |
| 700 | [NFS3PROC_GETATTR] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 701 | .pc_func = nfsd3_proc_getattr, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 702 | .pc_decode = nfs3svc_decode_fhandleargs, |
Chuck Lever | 2c42f80 | 2020-10-21 11:58:41 -0400 | [diff] [blame] | 703 | .pc_encode = nfs3svc_encode_getattrres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 704 | .pc_release = nfs3svc_release_fhandle, |
Chuck Lever | 9575363 | 2020-10-20 14:30:02 -0400 | [diff] [blame] | 705 | .pc_argsize = sizeof(struct nfsd_fhandle), |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 706 | .pc_ressize = sizeof(struct nfsd3_attrstatres), |
| 707 | .pc_cachetype = RC_NOCACHE, |
| 708 | .pc_xdrressize = ST+AT, |
Chuck Lever | 2289e87 | 2020-09-17 17:22:49 -0400 | [diff] [blame] | 709 | .pc_name = "GETATTR", |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 710 | }, |
| 711 | [NFS3PROC_SETATTR] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 712 | .pc_func = nfsd3_proc_setattr, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 713 | .pc_decode = nfs3svc_decode_sattrargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 714 | .pc_encode = nfs3svc_encode_wccstatres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 715 | .pc_release = nfs3svc_release_fhandle, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 716 | .pc_argsize = sizeof(struct nfsd3_sattrargs), |
| 717 | .pc_ressize = sizeof(struct nfsd3_wccstatres), |
| 718 | .pc_cachetype = RC_REPLBUFF, |
| 719 | .pc_xdrressize = ST+WC, |
Chuck Lever | 2289e87 | 2020-09-17 17:22:49 -0400 | [diff] [blame] | 720 | .pc_name = "SETATTR", |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 721 | }, |
| 722 | [NFS3PROC_LOOKUP] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 723 | .pc_func = nfsd3_proc_lookup, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 724 | .pc_decode = nfs3svc_decode_diropargs, |
Chuck Lever | 5cf3533 | 2020-10-22 14:46:58 -0400 | [diff] [blame] | 725 | .pc_encode = nfs3svc_encode_lookupres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 726 | .pc_release = nfs3svc_release_fhandle2, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 727 | .pc_argsize = sizeof(struct nfsd3_diropargs), |
| 728 | .pc_ressize = sizeof(struct nfsd3_diropres), |
| 729 | .pc_cachetype = RC_NOCACHE, |
| 730 | .pc_xdrressize = ST+FH+pAT+pAT, |
Chuck Lever | 2289e87 | 2020-09-17 17:22:49 -0400 | [diff] [blame] | 731 | .pc_name = "LOOKUP", |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 732 | }, |
| 733 | [NFS3PROC_ACCESS] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 734 | .pc_func = nfsd3_proc_access, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 735 | .pc_decode = nfs3svc_decode_accessargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 736 | .pc_encode = nfs3svc_encode_accessres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 737 | .pc_release = nfs3svc_release_fhandle, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 738 | .pc_argsize = sizeof(struct nfsd3_accessargs), |
| 739 | .pc_ressize = sizeof(struct nfsd3_accessres), |
| 740 | .pc_cachetype = RC_NOCACHE, |
| 741 | .pc_xdrressize = ST+pAT+1, |
Chuck Lever | 2289e87 | 2020-09-17 17:22:49 -0400 | [diff] [blame] | 742 | .pc_name = "ACCESS", |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 743 | }, |
| 744 | [NFS3PROC_READLINK] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 745 | .pc_func = nfsd3_proc_readlink, |
Chuck Lever | 224c1c8 | 2020-10-24 12:51:18 -0400 | [diff] [blame] | 746 | .pc_decode = nfs3svc_decode_fhandleargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 747 | .pc_encode = nfs3svc_encode_readlinkres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 748 | .pc_release = nfs3svc_release_fhandle, |
Chuck Lever | 224c1c8 | 2020-10-24 12:51:18 -0400 | [diff] [blame] | 749 | .pc_argsize = sizeof(struct nfsd_fhandle), |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 750 | .pc_ressize = sizeof(struct nfsd3_readlinkres), |
| 751 | .pc_cachetype = RC_NOCACHE, |
| 752 | .pc_xdrressize = ST+pAT+1+NFS3_MAXPATHLEN/4, |
Chuck Lever | 2289e87 | 2020-09-17 17:22:49 -0400 | [diff] [blame] | 753 | .pc_name = "READLINK", |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 754 | }, |
| 755 | [NFS3PROC_READ] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 756 | .pc_func = nfsd3_proc_read, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 757 | .pc_decode = nfs3svc_decode_readargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 758 | .pc_encode = nfs3svc_encode_readres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 759 | .pc_release = nfs3svc_release_fhandle, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 760 | .pc_argsize = sizeof(struct nfsd3_readargs), |
| 761 | .pc_ressize = sizeof(struct nfsd3_readres), |
| 762 | .pc_cachetype = RC_NOCACHE, |
| 763 | .pc_xdrressize = ST+pAT+4+NFSSVC_MAXBLKSIZE/4, |
Chuck Lever | 2289e87 | 2020-09-17 17:22:49 -0400 | [diff] [blame] | 764 | .pc_name = "READ", |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 765 | }, |
| 766 | [NFS3PROC_WRITE] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 767 | .pc_func = nfsd3_proc_write, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 768 | .pc_decode = nfs3svc_decode_writeargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 769 | .pc_encode = nfs3svc_encode_writeres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 770 | .pc_release = nfs3svc_release_fhandle, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 771 | .pc_argsize = sizeof(struct nfsd3_writeargs), |
| 772 | .pc_ressize = sizeof(struct nfsd3_writeres), |
| 773 | .pc_cachetype = RC_REPLBUFF, |
| 774 | .pc_xdrressize = ST+WC+4, |
Chuck Lever | 2289e87 | 2020-09-17 17:22:49 -0400 | [diff] [blame] | 775 | .pc_name = "WRITE", |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 776 | }, |
| 777 | [NFS3PROC_CREATE] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 778 | .pc_func = nfsd3_proc_create, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 779 | .pc_decode = nfs3svc_decode_createargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 780 | .pc_encode = nfs3svc_encode_createres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 781 | .pc_release = nfs3svc_release_fhandle2, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 782 | .pc_argsize = sizeof(struct nfsd3_createargs), |
| 783 | .pc_ressize = sizeof(struct nfsd3_createres), |
| 784 | .pc_cachetype = RC_REPLBUFF, |
| 785 | .pc_xdrressize = ST+(1+FH+pAT)+WC, |
Chuck Lever | 2289e87 | 2020-09-17 17:22:49 -0400 | [diff] [blame] | 786 | .pc_name = "CREATE", |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 787 | }, |
| 788 | [NFS3PROC_MKDIR] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 789 | .pc_func = nfsd3_proc_mkdir, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 790 | .pc_decode = nfs3svc_decode_mkdirargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 791 | .pc_encode = nfs3svc_encode_createres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 792 | .pc_release = nfs3svc_release_fhandle2, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 793 | .pc_argsize = sizeof(struct nfsd3_mkdirargs), |
| 794 | .pc_ressize = sizeof(struct nfsd3_createres), |
| 795 | .pc_cachetype = RC_REPLBUFF, |
| 796 | .pc_xdrressize = ST+(1+FH+pAT)+WC, |
Chuck Lever | 2289e87 | 2020-09-17 17:22:49 -0400 | [diff] [blame] | 797 | .pc_name = "MKDIR", |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 798 | }, |
| 799 | [NFS3PROC_SYMLINK] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 800 | .pc_func = nfsd3_proc_symlink, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 801 | .pc_decode = nfs3svc_decode_symlinkargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 802 | .pc_encode = nfs3svc_encode_createres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 803 | .pc_release = nfs3svc_release_fhandle2, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 804 | .pc_argsize = sizeof(struct nfsd3_symlinkargs), |
| 805 | .pc_ressize = sizeof(struct nfsd3_createres), |
| 806 | .pc_cachetype = RC_REPLBUFF, |
| 807 | .pc_xdrressize = ST+(1+FH+pAT)+WC, |
Chuck Lever | 2289e87 | 2020-09-17 17:22:49 -0400 | [diff] [blame] | 808 | .pc_name = "SYMLINK", |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 809 | }, |
| 810 | [NFS3PROC_MKNOD] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 811 | .pc_func = nfsd3_proc_mknod, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 812 | .pc_decode = nfs3svc_decode_mknodargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 813 | .pc_encode = nfs3svc_encode_createres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 814 | .pc_release = nfs3svc_release_fhandle2, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 815 | .pc_argsize = sizeof(struct nfsd3_mknodargs), |
| 816 | .pc_ressize = sizeof(struct nfsd3_createres), |
| 817 | .pc_cachetype = RC_REPLBUFF, |
| 818 | .pc_xdrressize = ST+(1+FH+pAT)+WC, |
Chuck Lever | 2289e87 | 2020-09-17 17:22:49 -0400 | [diff] [blame] | 819 | .pc_name = "MKNOD", |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 820 | }, |
| 821 | [NFS3PROC_REMOVE] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 822 | .pc_func = nfsd3_proc_remove, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 823 | .pc_decode = nfs3svc_decode_diropargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 824 | .pc_encode = nfs3svc_encode_wccstatres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 825 | .pc_release = nfs3svc_release_fhandle, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 826 | .pc_argsize = sizeof(struct nfsd3_diropargs), |
| 827 | .pc_ressize = sizeof(struct nfsd3_wccstatres), |
| 828 | .pc_cachetype = RC_REPLBUFF, |
| 829 | .pc_xdrressize = ST+WC, |
Chuck Lever | 2289e87 | 2020-09-17 17:22:49 -0400 | [diff] [blame] | 830 | .pc_name = "REMOVE", |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 831 | }, |
| 832 | [NFS3PROC_RMDIR] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 833 | .pc_func = nfsd3_proc_rmdir, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 834 | .pc_decode = nfs3svc_decode_diropargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 835 | .pc_encode = nfs3svc_encode_wccstatres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 836 | .pc_release = nfs3svc_release_fhandle, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 837 | .pc_argsize = sizeof(struct nfsd3_diropargs), |
| 838 | .pc_ressize = sizeof(struct nfsd3_wccstatres), |
| 839 | .pc_cachetype = RC_REPLBUFF, |
| 840 | .pc_xdrressize = ST+WC, |
Chuck Lever | 2289e87 | 2020-09-17 17:22:49 -0400 | [diff] [blame] | 841 | .pc_name = "RMDIR", |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 842 | }, |
| 843 | [NFS3PROC_RENAME] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 844 | .pc_func = nfsd3_proc_rename, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 845 | .pc_decode = nfs3svc_decode_renameargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 846 | .pc_encode = nfs3svc_encode_renameres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 847 | .pc_release = nfs3svc_release_fhandle2, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 848 | .pc_argsize = sizeof(struct nfsd3_renameargs), |
| 849 | .pc_ressize = sizeof(struct nfsd3_renameres), |
| 850 | .pc_cachetype = RC_REPLBUFF, |
| 851 | .pc_xdrressize = ST+WC+WC, |
Chuck Lever | 2289e87 | 2020-09-17 17:22:49 -0400 | [diff] [blame] | 852 | .pc_name = "RENAME", |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 853 | }, |
| 854 | [NFS3PROC_LINK] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 855 | .pc_func = nfsd3_proc_link, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 856 | .pc_decode = nfs3svc_decode_linkargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 857 | .pc_encode = nfs3svc_encode_linkres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 858 | .pc_release = nfs3svc_release_fhandle2, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 859 | .pc_argsize = sizeof(struct nfsd3_linkargs), |
| 860 | .pc_ressize = sizeof(struct nfsd3_linkres), |
| 861 | .pc_cachetype = RC_REPLBUFF, |
| 862 | .pc_xdrressize = ST+pAT+WC, |
Chuck Lever | 2289e87 | 2020-09-17 17:22:49 -0400 | [diff] [blame] | 863 | .pc_name = "LINK", |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 864 | }, |
| 865 | [NFS3PROC_READDIR] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 866 | .pc_func = nfsd3_proc_readdir, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 867 | .pc_decode = nfs3svc_decode_readdirargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 868 | .pc_encode = nfs3svc_encode_readdirres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 869 | .pc_release = nfs3svc_release_fhandle, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 870 | .pc_argsize = sizeof(struct nfsd3_readdirargs), |
| 871 | .pc_ressize = sizeof(struct nfsd3_readdirres), |
| 872 | .pc_cachetype = RC_NOCACHE, |
Chuck Lever | 2289e87 | 2020-09-17 17:22:49 -0400 | [diff] [blame] | 873 | .pc_name = "READDIR", |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 874 | }, |
| 875 | [NFS3PROC_READDIRPLUS] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 876 | .pc_func = nfsd3_proc_readdirplus, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 877 | .pc_decode = nfs3svc_decode_readdirplusargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 878 | .pc_encode = nfs3svc_encode_readdirres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 879 | .pc_release = nfs3svc_release_fhandle, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 880 | .pc_argsize = sizeof(struct nfsd3_readdirplusargs), |
| 881 | .pc_ressize = sizeof(struct nfsd3_readdirres), |
| 882 | .pc_cachetype = RC_NOCACHE, |
Chuck Lever | 2289e87 | 2020-09-17 17:22:49 -0400 | [diff] [blame] | 883 | .pc_name = "READDIRPLUS", |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 884 | }, |
| 885 | [NFS3PROC_FSSTAT] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 886 | .pc_func = nfsd3_proc_fsstat, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 887 | .pc_decode = nfs3svc_decode_fhandleargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 888 | .pc_encode = nfs3svc_encode_fsstatres, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 889 | .pc_argsize = sizeof(struct nfsd3_fhandleargs), |
| 890 | .pc_ressize = sizeof(struct nfsd3_fsstatres), |
| 891 | .pc_cachetype = RC_NOCACHE, |
| 892 | .pc_xdrressize = ST+pAT+2*6+1, |
Chuck Lever | 2289e87 | 2020-09-17 17:22:49 -0400 | [diff] [blame] | 893 | .pc_name = "FSSTAT", |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 894 | }, |
| 895 | [NFS3PROC_FSINFO] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 896 | .pc_func = nfsd3_proc_fsinfo, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 897 | .pc_decode = nfs3svc_decode_fhandleargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 898 | .pc_encode = nfs3svc_encode_fsinfores, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 899 | .pc_argsize = sizeof(struct nfsd3_fhandleargs), |
| 900 | .pc_ressize = sizeof(struct nfsd3_fsinfores), |
| 901 | .pc_cachetype = RC_NOCACHE, |
| 902 | .pc_xdrressize = ST+pAT+12, |
Chuck Lever | 2289e87 | 2020-09-17 17:22:49 -0400 | [diff] [blame] | 903 | .pc_name = "FSINFO", |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 904 | }, |
| 905 | [NFS3PROC_PATHCONF] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 906 | .pc_func = nfsd3_proc_pathconf, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 907 | .pc_decode = nfs3svc_decode_fhandleargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 908 | .pc_encode = nfs3svc_encode_pathconfres, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 909 | .pc_argsize = sizeof(struct nfsd3_fhandleargs), |
| 910 | .pc_ressize = sizeof(struct nfsd3_pathconfres), |
| 911 | .pc_cachetype = RC_NOCACHE, |
| 912 | .pc_xdrressize = ST+pAT+6, |
Chuck Lever | 2289e87 | 2020-09-17 17:22:49 -0400 | [diff] [blame] | 913 | .pc_name = "PATHCONF", |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 914 | }, |
| 915 | [NFS3PROC_COMMIT] = { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 916 | .pc_func = nfsd3_proc_commit, |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 917 | .pc_decode = nfs3svc_decode_commitargs, |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 918 | .pc_encode = nfs3svc_encode_commitres, |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 919 | .pc_release = nfs3svc_release_fhandle, |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 920 | .pc_argsize = sizeof(struct nfsd3_commitargs), |
| 921 | .pc_ressize = sizeof(struct nfsd3_commitres), |
| 922 | .pc_cachetype = RC_NOCACHE, |
| 923 | .pc_xdrressize = ST+WC+2, |
Chuck Lever | 2289e87 | 2020-09-17 17:22:49 -0400 | [diff] [blame] | 924 | .pc_name = "COMMIT", |
Yu Zhiguo | b9081d9 | 2009-06-09 17:33:34 +0800 | [diff] [blame] | 925 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 926 | }; |
| 927 | |
Christoph Hellwig | 7fd38af | 2017-05-08 23:40:27 +0200 | [diff] [blame] | 928 | static unsigned int nfsd_count3[ARRAY_SIZE(nfsd_procedures3)]; |
Christoph Hellwig | e967918 | 2017-05-12 16:21:37 +0200 | [diff] [blame] | 929 | const struct svc_version nfsd_version3 = { |
| 930 | .vs_vers = 3, |
| 931 | .vs_nproc = 22, |
| 932 | .vs_proc = nfsd_procedures3, |
| 933 | .vs_dispatch = nfsd_dispatch, |
| 934 | .vs_count = nfsd_count3, |
| 935 | .vs_xdrsize = NFS3_SVC_XDRSIZE, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 936 | }; |