| .. | .. |
|---|
| 11 | 11 | #include "xdr.h" |
|---|
| 12 | 12 | #include "vfs.h" |
|---|
| 13 | 13 | |
|---|
| 14 | | -typedef struct svc_rqst svc_rqst; |
|---|
| 15 | | -typedef struct svc_buf svc_buf; |
|---|
| 16 | | - |
|---|
| 17 | 14 | #define NFSDDBG_FACILITY NFSDDBG_PROC |
|---|
| 18 | | - |
|---|
| 19 | 15 | |
|---|
| 20 | 16 | static __be32 |
|---|
| 21 | 17 | nfsd_proc_null(struct svc_rqst *rqstp) |
|---|
| 22 | 18 | { |
|---|
| 23 | | - return nfs_ok; |
|---|
| 19 | + return rpc_success; |
|---|
| 24 | 20 | } |
|---|
| 25 | 21 | |
|---|
| 26 | | -static __be32 |
|---|
| 27 | | -nfsd_return_attrs(__be32 err, struct nfsd_attrstat *resp) |
|---|
| 28 | | -{ |
|---|
| 29 | | - if (err) return err; |
|---|
| 30 | | - return fh_getattr(&resp->fh, &resp->stat); |
|---|
| 31 | | -} |
|---|
| 32 | | -static __be32 |
|---|
| 33 | | -nfsd_return_dirop(__be32 err, struct nfsd_diropres *resp) |
|---|
| 34 | | -{ |
|---|
| 35 | | - if (err) return err; |
|---|
| 36 | | - return fh_getattr(&resp->fh, &resp->stat); |
|---|
| 37 | | -} |
|---|
| 38 | 22 | /* |
|---|
| 39 | 23 | * Get a file's attributes |
|---|
| 40 | 24 | * N.B. After this call resp->fh needs an fh_put |
|---|
| .. | .. |
|---|
| 44 | 28 | { |
|---|
| 45 | 29 | struct nfsd_fhandle *argp = rqstp->rq_argp; |
|---|
| 46 | 30 | struct nfsd_attrstat *resp = rqstp->rq_resp; |
|---|
| 47 | | - __be32 nfserr; |
|---|
| 31 | + |
|---|
| 48 | 32 | dprintk("nfsd: GETATTR %s\n", SVCFH_fmt(&argp->fh)); |
|---|
| 49 | 33 | |
|---|
| 50 | 34 | fh_copy(&resp->fh, &argp->fh); |
|---|
| 51 | | - nfserr = fh_verify(rqstp, &resp->fh, 0, |
|---|
| 52 | | - NFSD_MAY_NOP | NFSD_MAY_BYPASS_GSS_ON_ROOT); |
|---|
| 53 | | - return nfsd_return_attrs(nfserr, resp); |
|---|
| 35 | + resp->status = fh_verify(rqstp, &resp->fh, 0, |
|---|
| 36 | + NFSD_MAY_NOP | NFSD_MAY_BYPASS_GSS_ON_ROOT); |
|---|
| 37 | + if (resp->status != nfs_ok) |
|---|
| 38 | + goto out; |
|---|
| 39 | + resp->status = fh_getattr(&resp->fh, &resp->stat); |
|---|
| 40 | +out: |
|---|
| 41 | + return rpc_success; |
|---|
| 54 | 42 | } |
|---|
| 55 | 43 | |
|---|
| 56 | 44 | /* |
|---|
| .. | .. |
|---|
| 64 | 52 | struct nfsd_attrstat *resp = rqstp->rq_resp; |
|---|
| 65 | 53 | struct iattr *iap = &argp->attrs; |
|---|
| 66 | 54 | struct svc_fh *fhp; |
|---|
| 67 | | - __be32 nfserr; |
|---|
| 68 | 55 | |
|---|
| 69 | 56 | dprintk("nfsd: SETATTR %s, valid=%x, size=%ld\n", |
|---|
| 70 | 57 | SVCFH_fmt(&argp->fh), |
|---|
| .. | .. |
|---|
| 94 | 81 | * Solaris, at least, doesn't seem to care what the time |
|---|
| 95 | 82 | * request is. We require it be within 30 minutes of now. |
|---|
| 96 | 83 | */ |
|---|
| 97 | | - time_t delta = iap->ia_atime.tv_sec - get_seconds(); |
|---|
| 84 | + time64_t delta = iap->ia_atime.tv_sec - ktime_get_real_seconds(); |
|---|
| 98 | 85 | |
|---|
| 99 | | - nfserr = fh_verify(rqstp, fhp, 0, NFSD_MAY_NOP); |
|---|
| 100 | | - if (nfserr) |
|---|
| 101 | | - goto done; |
|---|
| 86 | + resp->status = fh_verify(rqstp, fhp, 0, NFSD_MAY_NOP); |
|---|
| 87 | + if (resp->status != nfs_ok) |
|---|
| 88 | + goto out; |
|---|
| 102 | 89 | |
|---|
| 103 | 90 | if (delta < 0) |
|---|
| 104 | 91 | delta = -delta; |
|---|
| .. | .. |
|---|
| 113 | 100 | } |
|---|
| 114 | 101 | } |
|---|
| 115 | 102 | |
|---|
| 116 | | - nfserr = nfsd_setattr(rqstp, fhp, iap, 0, (time_t)0); |
|---|
| 117 | | -done: |
|---|
| 118 | | - return nfsd_return_attrs(nfserr, resp); |
|---|
| 103 | + resp->status = nfsd_setattr(rqstp, fhp, iap, 0, (time64_t)0); |
|---|
| 104 | + if (resp->status != nfs_ok) |
|---|
| 105 | + goto out; |
|---|
| 106 | + |
|---|
| 107 | + resp->status = fh_getattr(&resp->fh, &resp->stat); |
|---|
| 108 | +out: |
|---|
| 109 | + return rpc_success; |
|---|
| 119 | 110 | } |
|---|
| 120 | 111 | |
|---|
| 121 | 112 | /* Obsolete, replaced by MNTPROC_MNT. */ |
|---|
| 122 | 113 | static __be32 |
|---|
| 123 | 114 | nfsd_proc_root(struct svc_rqst *rqstp) |
|---|
| 124 | 115 | { |
|---|
| 125 | | - return nfs_ok; |
|---|
| 116 | + return rpc_success; |
|---|
| 126 | 117 | } |
|---|
| 127 | 118 | |
|---|
| 128 | 119 | /* |
|---|
| .. | .. |
|---|
| 136 | 127 | { |
|---|
| 137 | 128 | struct nfsd_diropargs *argp = rqstp->rq_argp; |
|---|
| 138 | 129 | struct nfsd_diropres *resp = rqstp->rq_resp; |
|---|
| 139 | | - __be32 nfserr; |
|---|
| 140 | 130 | |
|---|
| 141 | 131 | dprintk("nfsd: LOOKUP %s %.*s\n", |
|---|
| 142 | 132 | SVCFH_fmt(&argp->fh), argp->len, argp->name); |
|---|
| 143 | 133 | |
|---|
| 144 | 134 | fh_init(&resp->fh, NFS_FHSIZE); |
|---|
| 145 | | - nfserr = nfsd_lookup(rqstp, &argp->fh, argp->name, argp->len, |
|---|
| 146 | | - &resp->fh); |
|---|
| 147 | | - |
|---|
| 135 | + resp->status = nfsd_lookup(rqstp, &argp->fh, argp->name, argp->len, |
|---|
| 136 | + &resp->fh); |
|---|
| 148 | 137 | fh_put(&argp->fh); |
|---|
| 149 | | - return nfsd_return_dirop(nfserr, resp); |
|---|
| 138 | + if (resp->status != nfs_ok) |
|---|
| 139 | + goto out; |
|---|
| 140 | + |
|---|
| 141 | + resp->status = fh_getattr(&resp->fh, &resp->stat); |
|---|
| 142 | +out: |
|---|
| 143 | + return rpc_success; |
|---|
| 150 | 144 | } |
|---|
| 151 | 145 | |
|---|
| 152 | 146 | /* |
|---|
| .. | .. |
|---|
| 157 | 151 | { |
|---|
| 158 | 152 | struct nfsd_readlinkargs *argp = rqstp->rq_argp; |
|---|
| 159 | 153 | struct nfsd_readlinkres *resp = rqstp->rq_resp; |
|---|
| 160 | | - __be32 nfserr; |
|---|
| 161 | 154 | |
|---|
| 162 | 155 | dprintk("nfsd: READLINK %s\n", SVCFH_fmt(&argp->fh)); |
|---|
| 163 | 156 | |
|---|
| 164 | 157 | /* Read the symlink. */ |
|---|
| 165 | 158 | resp->len = NFS_MAXPATHLEN; |
|---|
| 166 | | - nfserr = nfsd_readlink(rqstp, &argp->fh, argp->buffer, &resp->len); |
|---|
| 159 | + resp->status = nfsd_readlink(rqstp, &argp->fh, argp->buffer, &resp->len); |
|---|
| 167 | 160 | |
|---|
| 168 | 161 | fh_put(&argp->fh); |
|---|
| 169 | | - return nfserr; |
|---|
| 162 | + return rpc_success; |
|---|
| 170 | 163 | } |
|---|
| 171 | 164 | |
|---|
| 172 | 165 | /* |
|---|
| .. | .. |
|---|
| 178 | 171 | { |
|---|
| 179 | 172 | struct nfsd_readargs *argp = rqstp->rq_argp; |
|---|
| 180 | 173 | struct nfsd_readres *resp = rqstp->rq_resp; |
|---|
| 181 | | - __be32 nfserr; |
|---|
| 174 | + u32 eof; |
|---|
| 182 | 175 | |
|---|
| 183 | 176 | dprintk("nfsd: READ %s %d bytes at %d\n", |
|---|
| 184 | 177 | SVCFH_fmt(&argp->fh), |
|---|
| .. | .. |
|---|
| 199 | 192 | svc_reserve_auth(rqstp, (19<<2) + argp->count + 4); |
|---|
| 200 | 193 | |
|---|
| 201 | 194 | resp->count = argp->count; |
|---|
| 202 | | - nfserr = nfsd_read(rqstp, fh_copy(&resp->fh, &argp->fh), |
|---|
| 203 | | - argp->offset, |
|---|
| 204 | | - rqstp->rq_vec, argp->vlen, |
|---|
| 205 | | - &resp->count); |
|---|
| 206 | | - |
|---|
| 207 | | - if (nfserr) return nfserr; |
|---|
| 208 | | - return fh_getattr(&resp->fh, &resp->stat); |
|---|
| 195 | + resp->status = nfsd_read(rqstp, fh_copy(&resp->fh, &argp->fh), |
|---|
| 196 | + argp->offset, |
|---|
| 197 | + rqstp->rq_vec, argp->vlen, |
|---|
| 198 | + &resp->count, |
|---|
| 199 | + &eof); |
|---|
| 200 | + if (resp->status == nfs_ok) |
|---|
| 201 | + resp->status = fh_getattr(&resp->fh, &resp->stat); |
|---|
| 202 | + else if (resp->status == nfserr_jukebox) |
|---|
| 203 | + return rpc_drop_reply; |
|---|
| 204 | + return rpc_success; |
|---|
| 209 | 205 | } |
|---|
| 210 | 206 | |
|---|
| 211 | 207 | /* Reserved */ |
|---|
| 212 | 208 | static __be32 |
|---|
| 213 | 209 | nfsd_proc_writecache(struct svc_rqst *rqstp) |
|---|
| 214 | 210 | { |
|---|
| 215 | | - return nfs_ok; |
|---|
| 211 | + return rpc_success; |
|---|
| 216 | 212 | } |
|---|
| 217 | 213 | |
|---|
| 218 | 214 | /* |
|---|
| .. | .. |
|---|
| 224 | 220 | { |
|---|
| 225 | 221 | struct nfsd_writeargs *argp = rqstp->rq_argp; |
|---|
| 226 | 222 | struct nfsd_attrstat *resp = rqstp->rq_resp; |
|---|
| 227 | | - __be32 nfserr; |
|---|
| 228 | 223 | unsigned long cnt = argp->len; |
|---|
| 229 | 224 | unsigned int nvecs; |
|---|
| 230 | 225 | |
|---|
| 231 | | - dprintk("nfsd: WRITE %s %d bytes at %d\n", |
|---|
| 226 | + dprintk("nfsd: WRITE %s %u bytes at %d\n", |
|---|
| 232 | 227 | SVCFH_fmt(&argp->fh), |
|---|
| 233 | 228 | argp->len, argp->offset); |
|---|
| 234 | 229 | |
|---|
| 235 | 230 | nvecs = svc_fill_write_vector(rqstp, rqstp->rq_arg.pages, |
|---|
| 236 | 231 | &argp->first, cnt); |
|---|
| 237 | | - if (!nvecs) |
|---|
| 238 | | - return nfserr_io; |
|---|
| 239 | | - nfserr = nfsd_write(rqstp, fh_copy(&resp->fh, &argp->fh), |
|---|
| 240 | | - argp->offset, rqstp->rq_vec, nvecs, |
|---|
| 241 | | - &cnt, NFS_DATA_SYNC); |
|---|
| 242 | | - return nfsd_return_attrs(nfserr, resp); |
|---|
| 232 | + if (!nvecs) { |
|---|
| 233 | + resp->status = nfserr_io; |
|---|
| 234 | + goto out; |
|---|
| 235 | + } |
|---|
| 236 | + |
|---|
| 237 | + resp->status = nfsd_write(rqstp, fh_copy(&resp->fh, &argp->fh), |
|---|
| 238 | + argp->offset, rqstp->rq_vec, nvecs, |
|---|
| 239 | + &cnt, NFS_DATA_SYNC, NULL); |
|---|
| 240 | + if (resp->status == nfs_ok) |
|---|
| 241 | + resp->status = fh_getattr(&resp->fh, &resp->stat); |
|---|
| 242 | + else if (resp->status == nfserr_jukebox) |
|---|
| 243 | + return rpc_drop_reply; |
|---|
| 244 | +out: |
|---|
| 245 | + return rpc_success; |
|---|
| 243 | 246 | } |
|---|
| 244 | 247 | |
|---|
| 245 | 248 | /* |
|---|
| .. | .. |
|---|
| 259 | 262 | struct inode *inode; |
|---|
| 260 | 263 | struct dentry *dchild; |
|---|
| 261 | 264 | int type, mode; |
|---|
| 262 | | - __be32 nfserr; |
|---|
| 263 | 265 | int hosterr; |
|---|
| 264 | 266 | dev_t rdev = 0, wanted = new_decode_dev(attr->ia_size); |
|---|
| 265 | 267 | |
|---|
| .. | .. |
|---|
| 267 | 269 | SVCFH_fmt(dirfhp), argp->len, argp->name); |
|---|
| 268 | 270 | |
|---|
| 269 | 271 | /* First verify the parent file handle */ |
|---|
| 270 | | - nfserr = fh_verify(rqstp, dirfhp, S_IFDIR, NFSD_MAY_EXEC); |
|---|
| 271 | | - if (nfserr) |
|---|
| 272 | + resp->status = fh_verify(rqstp, dirfhp, S_IFDIR, NFSD_MAY_EXEC); |
|---|
| 273 | + if (resp->status != nfs_ok) |
|---|
| 272 | 274 | goto done; /* must fh_put dirfhp even on error */ |
|---|
| 273 | 275 | |
|---|
| 274 | 276 | /* Check for NFSD_MAY_WRITE in nfsd_create if necessary */ |
|---|
| 275 | 277 | |
|---|
| 276 | | - nfserr = nfserr_exist; |
|---|
| 278 | + resp->status = nfserr_exist; |
|---|
| 277 | 279 | if (isdotent(argp->name, argp->len)) |
|---|
| 278 | 280 | goto done; |
|---|
| 279 | 281 | hosterr = fh_want_write(dirfhp); |
|---|
| 280 | 282 | if (hosterr) { |
|---|
| 281 | | - nfserr = nfserrno(hosterr); |
|---|
| 283 | + resp->status = nfserrno(hosterr); |
|---|
| 282 | 284 | goto done; |
|---|
| 283 | 285 | } |
|---|
| 284 | 286 | |
|---|
| 285 | 287 | fh_lock_nested(dirfhp, I_MUTEX_PARENT); |
|---|
| 286 | 288 | dchild = lookup_one_len(argp->name, dirfhp->fh_dentry, argp->len); |
|---|
| 287 | 289 | if (IS_ERR(dchild)) { |
|---|
| 288 | | - nfserr = nfserrno(PTR_ERR(dchild)); |
|---|
| 290 | + resp->status = nfserrno(PTR_ERR(dchild)); |
|---|
| 289 | 291 | goto out_unlock; |
|---|
| 290 | 292 | } |
|---|
| 291 | 293 | fh_init(newfhp, NFS_FHSIZE); |
|---|
| 292 | | - nfserr = fh_compose(newfhp, dirfhp->fh_export, dchild, dirfhp); |
|---|
| 293 | | - if (!nfserr && d_really_is_negative(dchild)) |
|---|
| 294 | | - nfserr = nfserr_noent; |
|---|
| 294 | + resp->status = fh_compose(newfhp, dirfhp->fh_export, dchild, dirfhp); |
|---|
| 295 | + if (!resp->status && d_really_is_negative(dchild)) |
|---|
| 296 | + resp->status = nfserr_noent; |
|---|
| 295 | 297 | dput(dchild); |
|---|
| 296 | | - if (nfserr) { |
|---|
| 297 | | - if (nfserr != nfserr_noent) |
|---|
| 298 | + if (resp->status) { |
|---|
| 299 | + if (resp->status != nfserr_noent) |
|---|
| 298 | 300 | goto out_unlock; |
|---|
| 299 | 301 | /* |
|---|
| 300 | 302 | * If the new file handle wasn't verified, we can't tell |
|---|
| 301 | 303 | * whether the file exists or not. Time to bail ... |
|---|
| 302 | 304 | */ |
|---|
| 303 | | - nfserr = nfserr_acces; |
|---|
| 305 | + resp->status = nfserr_acces; |
|---|
| 304 | 306 | if (!newfhp->fh_dentry) { |
|---|
| 305 | 307 | printk(KERN_WARNING |
|---|
| 306 | 308 | "nfsd_proc_create: file handle not verified\n"); |
|---|
| .. | .. |
|---|
| 326 | 328 | rdev = inode->i_rdev; |
|---|
| 327 | 329 | attr->ia_valid |= ATTR_SIZE; |
|---|
| 328 | 330 | |
|---|
| 329 | | - /* FALLTHROUGH */ |
|---|
| 331 | + fallthrough; |
|---|
| 330 | 332 | case S_IFIFO: |
|---|
| 331 | 333 | /* this is probably a permission check.. |
|---|
| 332 | 334 | * at least IRIX implements perm checking on |
|---|
| 333 | 335 | * echo thing > device-special-file-or-pipe |
|---|
| 334 | 336 | * by doing a CREATE with type==0 |
|---|
| 335 | 337 | */ |
|---|
| 336 | | - nfserr = nfsd_permission(rqstp, |
|---|
| 338 | + resp->status = nfsd_permission(rqstp, |
|---|
| 337 | 339 | newfhp->fh_export, |
|---|
| 338 | 340 | newfhp->fh_dentry, |
|---|
| 339 | 341 | NFSD_MAY_WRITE|NFSD_MAY_LOCAL_ACCESS); |
|---|
| 340 | | - if (nfserr && nfserr != nfserr_rofs) |
|---|
| 342 | + if (resp->status && resp->status != nfserr_rofs) |
|---|
| 341 | 343 | goto out_unlock; |
|---|
| 342 | 344 | } |
|---|
| 343 | 345 | } else |
|---|
| .. | .. |
|---|
| 373 | 375 | attr->ia_valid &= ~ATTR_SIZE; |
|---|
| 374 | 376 | |
|---|
| 375 | 377 | /* Make sure the type and device matches */ |
|---|
| 376 | | - nfserr = nfserr_exist; |
|---|
| 377 | | - if (inode && type != (inode->i_mode & S_IFMT)) |
|---|
| 378 | + resp->status = nfserr_exist; |
|---|
| 379 | + if (inode && inode_wrong_type(inode, type)) |
|---|
| 378 | 380 | goto out_unlock; |
|---|
| 379 | 381 | } |
|---|
| 380 | 382 | |
|---|
| 381 | | - nfserr = 0; |
|---|
| 383 | + resp->status = nfs_ok; |
|---|
| 382 | 384 | if (!inode) { |
|---|
| 383 | 385 | /* File doesn't exist. Create it and set attrs */ |
|---|
| 384 | | - nfserr = nfsd_create_locked(rqstp, dirfhp, argp->name, |
|---|
| 385 | | - argp->len, attr, type, rdev, newfhp); |
|---|
| 386 | + resp->status = nfsd_create_locked(rqstp, dirfhp, argp->name, |
|---|
| 387 | + argp->len, attr, type, rdev, |
|---|
| 388 | + newfhp); |
|---|
| 386 | 389 | } else if (type == S_IFREG) { |
|---|
| 387 | 390 | dprintk("nfsd: existing %s, valid=%x, size=%ld\n", |
|---|
| 388 | 391 | argp->name, attr->ia_valid, (long) attr->ia_size); |
|---|
| .. | .. |
|---|
| 392 | 395 | */ |
|---|
| 393 | 396 | attr->ia_valid &= ATTR_SIZE; |
|---|
| 394 | 397 | if (attr->ia_valid) |
|---|
| 395 | | - nfserr = nfsd_setattr(rqstp, newfhp, attr, 0, (time_t)0); |
|---|
| 398 | + resp->status = nfsd_setattr(rqstp, newfhp, attr, 0, |
|---|
| 399 | + (time64_t)0); |
|---|
| 396 | 400 | } |
|---|
| 397 | 401 | |
|---|
| 398 | 402 | out_unlock: |
|---|
| .. | .. |
|---|
| 401 | 405 | fh_drop_write(dirfhp); |
|---|
| 402 | 406 | done: |
|---|
| 403 | 407 | fh_put(dirfhp); |
|---|
| 404 | | - return nfsd_return_dirop(nfserr, resp); |
|---|
| 408 | + if (resp->status != nfs_ok) |
|---|
| 409 | + goto out; |
|---|
| 410 | + resp->status = fh_getattr(&resp->fh, &resp->stat); |
|---|
| 411 | +out: |
|---|
| 412 | + return rpc_success; |
|---|
| 405 | 413 | } |
|---|
| 406 | 414 | |
|---|
| 407 | 415 | static __be32 |
|---|
| 408 | 416 | nfsd_proc_remove(struct svc_rqst *rqstp) |
|---|
| 409 | 417 | { |
|---|
| 410 | 418 | struct nfsd_diropargs *argp = rqstp->rq_argp; |
|---|
| 411 | | - __be32 nfserr; |
|---|
| 419 | + struct nfsd_stat *resp = rqstp->rq_resp; |
|---|
| 412 | 420 | |
|---|
| 413 | 421 | dprintk("nfsd: REMOVE %s %.*s\n", SVCFH_fmt(&argp->fh), |
|---|
| 414 | 422 | argp->len, argp->name); |
|---|
| 415 | 423 | |
|---|
| 416 | 424 | /* Unlink. -SIFDIR means file must not be a directory */ |
|---|
| 417 | | - nfserr = nfsd_unlink(rqstp, &argp->fh, -S_IFDIR, argp->name, argp->len); |
|---|
| 425 | + resp->status = nfsd_unlink(rqstp, &argp->fh, -S_IFDIR, |
|---|
| 426 | + argp->name, argp->len); |
|---|
| 418 | 427 | fh_put(&argp->fh); |
|---|
| 419 | | - return nfserr; |
|---|
| 428 | + return rpc_success; |
|---|
| 420 | 429 | } |
|---|
| 421 | 430 | |
|---|
| 422 | 431 | static __be32 |
|---|
| 423 | 432 | nfsd_proc_rename(struct svc_rqst *rqstp) |
|---|
| 424 | 433 | { |
|---|
| 425 | 434 | struct nfsd_renameargs *argp = rqstp->rq_argp; |
|---|
| 426 | | - __be32 nfserr; |
|---|
| 435 | + struct nfsd_stat *resp = rqstp->rq_resp; |
|---|
| 427 | 436 | |
|---|
| 428 | 437 | dprintk("nfsd: RENAME %s %.*s -> \n", |
|---|
| 429 | 438 | SVCFH_fmt(&argp->ffh), argp->flen, argp->fname); |
|---|
| 430 | 439 | dprintk("nfsd: -> %s %.*s\n", |
|---|
| 431 | 440 | SVCFH_fmt(&argp->tfh), argp->tlen, argp->tname); |
|---|
| 432 | 441 | |
|---|
| 433 | | - nfserr = nfsd_rename(rqstp, &argp->ffh, argp->fname, argp->flen, |
|---|
| 434 | | - &argp->tfh, argp->tname, argp->tlen); |
|---|
| 442 | + resp->status = nfsd_rename(rqstp, &argp->ffh, argp->fname, argp->flen, |
|---|
| 443 | + &argp->tfh, argp->tname, argp->tlen); |
|---|
| 435 | 444 | fh_put(&argp->ffh); |
|---|
| 436 | 445 | fh_put(&argp->tfh); |
|---|
| 437 | | - return nfserr; |
|---|
| 446 | + return rpc_success; |
|---|
| 438 | 447 | } |
|---|
| 439 | 448 | |
|---|
| 440 | 449 | static __be32 |
|---|
| 441 | 450 | nfsd_proc_link(struct svc_rqst *rqstp) |
|---|
| 442 | 451 | { |
|---|
| 443 | 452 | struct nfsd_linkargs *argp = rqstp->rq_argp; |
|---|
| 444 | | - __be32 nfserr; |
|---|
| 453 | + struct nfsd_stat *resp = rqstp->rq_resp; |
|---|
| 445 | 454 | |
|---|
| 446 | 455 | dprintk("nfsd: LINK %s ->\n", |
|---|
| 447 | 456 | SVCFH_fmt(&argp->ffh)); |
|---|
| .. | .. |
|---|
| 450 | 459 | argp->tlen, |
|---|
| 451 | 460 | argp->tname); |
|---|
| 452 | 461 | |
|---|
| 453 | | - nfserr = nfsd_link(rqstp, &argp->tfh, argp->tname, argp->tlen, |
|---|
| 454 | | - &argp->ffh); |
|---|
| 462 | + resp->status = nfsd_link(rqstp, &argp->tfh, argp->tname, argp->tlen, |
|---|
| 463 | + &argp->ffh); |
|---|
| 455 | 464 | fh_put(&argp->ffh); |
|---|
| 456 | 465 | fh_put(&argp->tfh); |
|---|
| 457 | | - return nfserr; |
|---|
| 466 | + return rpc_success; |
|---|
| 458 | 467 | } |
|---|
| 459 | 468 | |
|---|
| 460 | 469 | static __be32 |
|---|
| 461 | 470 | nfsd_proc_symlink(struct svc_rqst *rqstp) |
|---|
| 462 | 471 | { |
|---|
| 463 | 472 | struct nfsd_symlinkargs *argp = rqstp->rq_argp; |
|---|
| 473 | + struct nfsd_stat *resp = rqstp->rq_resp; |
|---|
| 464 | 474 | struct svc_fh newfh; |
|---|
| 465 | | - __be32 nfserr; |
|---|
| 466 | 475 | |
|---|
| 467 | | - if (argp->tlen > NFS_MAXPATHLEN) |
|---|
| 468 | | - return nfserr_nametoolong; |
|---|
| 476 | + if (argp->tlen > NFS_MAXPATHLEN) { |
|---|
| 477 | + resp->status = nfserr_nametoolong; |
|---|
| 478 | + goto out; |
|---|
| 479 | + } |
|---|
| 469 | 480 | |
|---|
| 470 | 481 | argp->tname = svc_fill_symlink_pathname(rqstp, &argp->first, |
|---|
| 471 | 482 | page_address(rqstp->rq_arg.pages[0]), |
|---|
| 472 | 483 | argp->tlen); |
|---|
| 473 | | - if (IS_ERR(argp->tname)) |
|---|
| 474 | | - return nfserrno(PTR_ERR(argp->tname)); |
|---|
| 484 | + if (IS_ERR(argp->tname)) { |
|---|
| 485 | + resp->status = nfserrno(PTR_ERR(argp->tname)); |
|---|
| 486 | + goto out; |
|---|
| 487 | + } |
|---|
| 475 | 488 | |
|---|
| 476 | 489 | dprintk("nfsd: SYMLINK %s %.*s -> %.*s\n", |
|---|
| 477 | 490 | SVCFH_fmt(&argp->ffh), argp->flen, argp->fname, |
|---|
| 478 | 491 | argp->tlen, argp->tname); |
|---|
| 479 | 492 | |
|---|
| 480 | 493 | fh_init(&newfh, NFS_FHSIZE); |
|---|
| 481 | | - nfserr = nfsd_symlink(rqstp, &argp->ffh, argp->fname, argp->flen, |
|---|
| 482 | | - argp->tname, &newfh); |
|---|
| 494 | + resp->status = nfsd_symlink(rqstp, &argp->ffh, argp->fname, argp->flen, |
|---|
| 495 | + argp->tname, &newfh); |
|---|
| 483 | 496 | |
|---|
| 484 | 497 | kfree(argp->tname); |
|---|
| 485 | 498 | fh_put(&argp->ffh); |
|---|
| 486 | 499 | fh_put(&newfh); |
|---|
| 487 | | - return nfserr; |
|---|
| 500 | +out: |
|---|
| 501 | + return rpc_success; |
|---|
| 488 | 502 | } |
|---|
| 489 | 503 | |
|---|
| 490 | 504 | /* |
|---|
| .. | .. |
|---|
| 496 | 510 | { |
|---|
| 497 | 511 | struct nfsd_createargs *argp = rqstp->rq_argp; |
|---|
| 498 | 512 | struct nfsd_diropres *resp = rqstp->rq_resp; |
|---|
| 499 | | - __be32 nfserr; |
|---|
| 500 | 513 | |
|---|
| 501 | 514 | dprintk("nfsd: MKDIR %s %.*s\n", SVCFH_fmt(&argp->fh), argp->len, argp->name); |
|---|
| 502 | 515 | |
|---|
| .. | .. |
|---|
| 507 | 520 | |
|---|
| 508 | 521 | argp->attrs.ia_valid &= ~ATTR_SIZE; |
|---|
| 509 | 522 | fh_init(&resp->fh, NFS_FHSIZE); |
|---|
| 510 | | - nfserr = nfsd_create(rqstp, &argp->fh, argp->name, argp->len, |
|---|
| 511 | | - &argp->attrs, S_IFDIR, 0, &resp->fh); |
|---|
| 523 | + resp->status = nfsd_create(rqstp, &argp->fh, argp->name, argp->len, |
|---|
| 524 | + &argp->attrs, S_IFDIR, 0, &resp->fh); |
|---|
| 512 | 525 | fh_put(&argp->fh); |
|---|
| 513 | | - return nfsd_return_dirop(nfserr, resp); |
|---|
| 526 | + if (resp->status != nfs_ok) |
|---|
| 527 | + goto out; |
|---|
| 528 | + |
|---|
| 529 | + resp->status = fh_getattr(&resp->fh, &resp->stat); |
|---|
| 530 | +out: |
|---|
| 531 | + return rpc_success; |
|---|
| 514 | 532 | } |
|---|
| 515 | 533 | |
|---|
| 516 | 534 | /* |
|---|
| .. | .. |
|---|
| 520 | 538 | nfsd_proc_rmdir(struct svc_rqst *rqstp) |
|---|
| 521 | 539 | { |
|---|
| 522 | 540 | struct nfsd_diropargs *argp = rqstp->rq_argp; |
|---|
| 523 | | - __be32 nfserr; |
|---|
| 541 | + struct nfsd_stat *resp = rqstp->rq_resp; |
|---|
| 524 | 542 | |
|---|
| 525 | 543 | dprintk("nfsd: RMDIR %s %.*s\n", SVCFH_fmt(&argp->fh), argp->len, argp->name); |
|---|
| 526 | 544 | |
|---|
| 527 | | - nfserr = nfsd_unlink(rqstp, &argp->fh, S_IFDIR, argp->name, argp->len); |
|---|
| 545 | + resp->status = nfsd_unlink(rqstp, &argp->fh, S_IFDIR, |
|---|
| 546 | + argp->name, argp->len); |
|---|
| 528 | 547 | fh_put(&argp->fh); |
|---|
| 529 | | - return nfserr; |
|---|
| 548 | + return rpc_success; |
|---|
| 530 | 549 | } |
|---|
| 531 | 550 | |
|---|
| 532 | 551 | /* |
|---|
| .. | .. |
|---|
| 538 | 557 | struct nfsd_readdirargs *argp = rqstp->rq_argp; |
|---|
| 539 | 558 | struct nfsd_readdirres *resp = rqstp->rq_resp; |
|---|
| 540 | 559 | int count; |
|---|
| 541 | | - __be32 nfserr; |
|---|
| 542 | 560 | loff_t offset; |
|---|
| 543 | 561 | |
|---|
| 544 | 562 | dprintk("nfsd: READDIR %s %d bytes at %d\n", |
|---|
| .. | .. |
|---|
| 559 | 577 | resp->common.err = nfs_ok; |
|---|
| 560 | 578 | /* Read directory and encode entries on the fly */ |
|---|
| 561 | 579 | offset = argp->cookie; |
|---|
| 562 | | - nfserr = nfsd_readdir(rqstp, &argp->fh, &offset, |
|---|
| 563 | | - &resp->common, nfssvc_encode_entry); |
|---|
| 580 | + resp->status = nfsd_readdir(rqstp, &argp->fh, &offset, |
|---|
| 581 | + &resp->common, nfssvc_encode_entry); |
|---|
| 564 | 582 | |
|---|
| 565 | 583 | resp->count = resp->buffer - argp->buffer; |
|---|
| 566 | 584 | if (resp->offset) |
|---|
| 567 | 585 | *resp->offset = htonl(offset); |
|---|
| 568 | 586 | |
|---|
| 569 | 587 | fh_put(&argp->fh); |
|---|
| 570 | | - return nfserr; |
|---|
| 588 | + return rpc_success; |
|---|
| 571 | 589 | } |
|---|
| 572 | 590 | |
|---|
| 573 | 591 | /* |
|---|
| .. | .. |
|---|
| 578 | 596 | { |
|---|
| 579 | 597 | struct nfsd_fhandle *argp = rqstp->rq_argp; |
|---|
| 580 | 598 | struct nfsd_statfsres *resp = rqstp->rq_resp; |
|---|
| 581 | | - __be32 nfserr; |
|---|
| 582 | 599 | |
|---|
| 583 | 600 | dprintk("nfsd: STATFS %s\n", SVCFH_fmt(&argp->fh)); |
|---|
| 584 | 601 | |
|---|
| 585 | | - nfserr = nfsd_statfs(rqstp, &argp->fh, &resp->stats, |
|---|
| 586 | | - NFSD_MAY_BYPASS_GSS_ON_ROOT); |
|---|
| 602 | + resp->status = nfsd_statfs(rqstp, &argp->fh, &resp->stats, |
|---|
| 603 | + NFSD_MAY_BYPASS_GSS_ON_ROOT); |
|---|
| 587 | 604 | fh_put(&argp->fh); |
|---|
| 588 | | - return nfserr; |
|---|
| 605 | + return rpc_success; |
|---|
| 589 | 606 | } |
|---|
| 590 | 607 | |
|---|
| 591 | 608 | /* |
|---|
| .. | .. |
|---|
| 606 | 623 | .pc_argsize = sizeof(struct nfsd_void), |
|---|
| 607 | 624 | .pc_ressize = sizeof(struct nfsd_void), |
|---|
| 608 | 625 | .pc_cachetype = RC_NOCACHE, |
|---|
| 609 | | - .pc_xdrressize = ST, |
|---|
| 626 | + .pc_xdrressize = 0, |
|---|
| 610 | 627 | }, |
|---|
| 611 | 628 | [NFSPROC_GETATTR] = { |
|---|
| 612 | 629 | .pc_func = nfsd_proc_getattr, |
|---|
| 613 | 630 | .pc_decode = nfssvc_decode_fhandle, |
|---|
| 614 | 631 | .pc_encode = nfssvc_encode_attrstat, |
|---|
| 615 | | - .pc_release = nfssvc_release_fhandle, |
|---|
| 632 | + .pc_release = nfssvc_release_attrstat, |
|---|
| 616 | 633 | .pc_argsize = sizeof(struct nfsd_fhandle), |
|---|
| 617 | 634 | .pc_ressize = sizeof(struct nfsd_attrstat), |
|---|
| 618 | 635 | .pc_cachetype = RC_NOCACHE, |
|---|
| .. | .. |
|---|
| 622 | 639 | .pc_func = nfsd_proc_setattr, |
|---|
| 623 | 640 | .pc_decode = nfssvc_decode_sattrargs, |
|---|
| 624 | 641 | .pc_encode = nfssvc_encode_attrstat, |
|---|
| 625 | | - .pc_release = nfssvc_release_fhandle, |
|---|
| 642 | + .pc_release = nfssvc_release_attrstat, |
|---|
| 626 | 643 | .pc_argsize = sizeof(struct nfsd_sattrargs), |
|---|
| 627 | 644 | .pc_ressize = sizeof(struct nfsd_attrstat), |
|---|
| 628 | 645 | .pc_cachetype = RC_REPLBUFF, |
|---|
| .. | .. |
|---|
| 635 | 652 | .pc_argsize = sizeof(struct nfsd_void), |
|---|
| 636 | 653 | .pc_ressize = sizeof(struct nfsd_void), |
|---|
| 637 | 654 | .pc_cachetype = RC_NOCACHE, |
|---|
| 638 | | - .pc_xdrressize = ST, |
|---|
| 655 | + .pc_xdrressize = 0, |
|---|
| 639 | 656 | }, |
|---|
| 640 | 657 | [NFSPROC_LOOKUP] = { |
|---|
| 641 | 658 | .pc_func = nfsd_proc_lookup, |
|---|
| 642 | 659 | .pc_decode = nfssvc_decode_diropargs, |
|---|
| 643 | 660 | .pc_encode = nfssvc_encode_diropres, |
|---|
| 644 | | - .pc_release = nfssvc_release_fhandle, |
|---|
| 661 | + .pc_release = nfssvc_release_diropres, |
|---|
| 645 | 662 | .pc_argsize = sizeof(struct nfsd_diropargs), |
|---|
| 646 | 663 | .pc_ressize = sizeof(struct nfsd_diropres), |
|---|
| 647 | 664 | .pc_cachetype = RC_NOCACHE, |
|---|
| .. | .. |
|---|
| 660 | 677 | .pc_func = nfsd_proc_read, |
|---|
| 661 | 678 | .pc_decode = nfssvc_decode_readargs, |
|---|
| 662 | 679 | .pc_encode = nfssvc_encode_readres, |
|---|
| 663 | | - .pc_release = nfssvc_release_fhandle, |
|---|
| 680 | + .pc_release = nfssvc_release_readres, |
|---|
| 664 | 681 | .pc_argsize = sizeof(struct nfsd_readargs), |
|---|
| 665 | 682 | .pc_ressize = sizeof(struct nfsd_readres), |
|---|
| 666 | 683 | .pc_cachetype = RC_NOCACHE, |
|---|
| .. | .. |
|---|
| 673 | 690 | .pc_argsize = sizeof(struct nfsd_void), |
|---|
| 674 | 691 | .pc_ressize = sizeof(struct nfsd_void), |
|---|
| 675 | 692 | .pc_cachetype = RC_NOCACHE, |
|---|
| 676 | | - .pc_xdrressize = ST, |
|---|
| 693 | + .pc_xdrressize = 0, |
|---|
| 677 | 694 | }, |
|---|
| 678 | 695 | [NFSPROC_WRITE] = { |
|---|
| 679 | 696 | .pc_func = nfsd_proc_write, |
|---|
| 680 | 697 | .pc_decode = nfssvc_decode_writeargs, |
|---|
| 681 | 698 | .pc_encode = nfssvc_encode_attrstat, |
|---|
| 682 | | - .pc_release = nfssvc_release_fhandle, |
|---|
| 699 | + .pc_release = nfssvc_release_attrstat, |
|---|
| 683 | 700 | .pc_argsize = sizeof(struct nfsd_writeargs), |
|---|
| 684 | 701 | .pc_ressize = sizeof(struct nfsd_attrstat), |
|---|
| 685 | 702 | .pc_cachetype = RC_REPLBUFF, |
|---|
| .. | .. |
|---|
| 689 | 706 | .pc_func = nfsd_proc_create, |
|---|
| 690 | 707 | .pc_decode = nfssvc_decode_createargs, |
|---|
| 691 | 708 | .pc_encode = nfssvc_encode_diropres, |
|---|
| 692 | | - .pc_release = nfssvc_release_fhandle, |
|---|
| 709 | + .pc_release = nfssvc_release_diropres, |
|---|
| 693 | 710 | .pc_argsize = sizeof(struct nfsd_createargs), |
|---|
| 694 | 711 | .pc_ressize = sizeof(struct nfsd_diropres), |
|---|
| 695 | 712 | .pc_cachetype = RC_REPLBUFF, |
|---|
| .. | .. |
|---|
| 698 | 715 | [NFSPROC_REMOVE] = { |
|---|
| 699 | 716 | .pc_func = nfsd_proc_remove, |
|---|
| 700 | 717 | .pc_decode = nfssvc_decode_diropargs, |
|---|
| 701 | | - .pc_encode = nfssvc_encode_void, |
|---|
| 718 | + .pc_encode = nfssvc_encode_stat, |
|---|
| 702 | 719 | .pc_argsize = sizeof(struct nfsd_diropargs), |
|---|
| 703 | | - .pc_ressize = sizeof(struct nfsd_void), |
|---|
| 720 | + .pc_ressize = sizeof(struct nfsd_stat), |
|---|
| 704 | 721 | .pc_cachetype = RC_REPLSTAT, |
|---|
| 705 | 722 | .pc_xdrressize = ST, |
|---|
| 706 | 723 | }, |
|---|
| 707 | 724 | [NFSPROC_RENAME] = { |
|---|
| 708 | 725 | .pc_func = nfsd_proc_rename, |
|---|
| 709 | 726 | .pc_decode = nfssvc_decode_renameargs, |
|---|
| 710 | | - .pc_encode = nfssvc_encode_void, |
|---|
| 727 | + .pc_encode = nfssvc_encode_stat, |
|---|
| 711 | 728 | .pc_argsize = sizeof(struct nfsd_renameargs), |
|---|
| 712 | | - .pc_ressize = sizeof(struct nfsd_void), |
|---|
| 729 | + .pc_ressize = sizeof(struct nfsd_stat), |
|---|
| 713 | 730 | .pc_cachetype = RC_REPLSTAT, |
|---|
| 714 | 731 | .pc_xdrressize = ST, |
|---|
| 715 | 732 | }, |
|---|
| 716 | 733 | [NFSPROC_LINK] = { |
|---|
| 717 | 734 | .pc_func = nfsd_proc_link, |
|---|
| 718 | 735 | .pc_decode = nfssvc_decode_linkargs, |
|---|
| 719 | | - .pc_encode = nfssvc_encode_void, |
|---|
| 736 | + .pc_encode = nfssvc_encode_stat, |
|---|
| 720 | 737 | .pc_argsize = sizeof(struct nfsd_linkargs), |
|---|
| 721 | | - .pc_ressize = sizeof(struct nfsd_void), |
|---|
| 738 | + .pc_ressize = sizeof(struct nfsd_stat), |
|---|
| 722 | 739 | .pc_cachetype = RC_REPLSTAT, |
|---|
| 723 | 740 | .pc_xdrressize = ST, |
|---|
| 724 | 741 | }, |
|---|
| 725 | 742 | [NFSPROC_SYMLINK] = { |
|---|
| 726 | 743 | .pc_func = nfsd_proc_symlink, |
|---|
| 727 | 744 | .pc_decode = nfssvc_decode_symlinkargs, |
|---|
| 728 | | - .pc_encode = nfssvc_encode_void, |
|---|
| 745 | + .pc_encode = nfssvc_encode_stat, |
|---|
| 729 | 746 | .pc_argsize = sizeof(struct nfsd_symlinkargs), |
|---|
| 730 | | - .pc_ressize = sizeof(struct nfsd_void), |
|---|
| 747 | + .pc_ressize = sizeof(struct nfsd_stat), |
|---|
| 731 | 748 | .pc_cachetype = RC_REPLSTAT, |
|---|
| 732 | 749 | .pc_xdrressize = ST, |
|---|
| 733 | 750 | }, |
|---|
| .. | .. |
|---|
| 735 | 752 | .pc_func = nfsd_proc_mkdir, |
|---|
| 736 | 753 | .pc_decode = nfssvc_decode_createargs, |
|---|
| 737 | 754 | .pc_encode = nfssvc_encode_diropres, |
|---|
| 738 | | - .pc_release = nfssvc_release_fhandle, |
|---|
| 755 | + .pc_release = nfssvc_release_diropres, |
|---|
| 739 | 756 | .pc_argsize = sizeof(struct nfsd_createargs), |
|---|
| 740 | 757 | .pc_ressize = sizeof(struct nfsd_diropres), |
|---|
| 741 | 758 | .pc_cachetype = RC_REPLBUFF, |
|---|
| .. | .. |
|---|
| 744 | 761 | [NFSPROC_RMDIR] = { |
|---|
| 745 | 762 | .pc_func = nfsd_proc_rmdir, |
|---|
| 746 | 763 | .pc_decode = nfssvc_decode_diropargs, |
|---|
| 747 | | - .pc_encode = nfssvc_encode_void, |
|---|
| 764 | + .pc_encode = nfssvc_encode_stat, |
|---|
| 748 | 765 | .pc_argsize = sizeof(struct nfsd_diropargs), |
|---|
| 749 | | - .pc_ressize = sizeof(struct nfsd_void), |
|---|
| 766 | + .pc_ressize = sizeof(struct nfsd_stat), |
|---|
| 750 | 767 | .pc_cachetype = RC_REPLSTAT, |
|---|
| 751 | 768 | .pc_xdrressize = ST, |
|---|
| 752 | 769 | }, |
|---|