nfsproc.c (03ab8e6297acd1bc0eedaa050e2a1635c576fd11) nfsproc.c (7fe2a71dda349a1afa75781f0cc7975be9784d15)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Process version 2 NFS requests.
4 *
5 * Copyright (C) 1995-1997 Olaf Kirch <okir@monad.swb.de>
6 */
7
8#include <linux/namei.h>

--- 37 unchanged lines hidden (view full) ---

46 * N.B. After this call resp->fh needs an fh_put
47 */
48static __be32
49nfsd_proc_setattr(struct svc_rqst *rqstp)
50{
51 struct nfsd_sattrargs *argp = rqstp->rq_argp;
52 struct nfsd_attrstat *resp = rqstp->rq_resp;
53 struct iattr *iap = &argp->attrs;
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Process version 2 NFS requests.
4 *
5 * Copyright (C) 1995-1997 Olaf Kirch <okir@monad.swb.de>
6 */
7
8#include <linux/namei.h>

--- 37 unchanged lines hidden (view full) ---

46 * N.B. After this call resp->fh needs an fh_put
47 */
48static __be32
49nfsd_proc_setattr(struct svc_rqst *rqstp)
50{
51 struct nfsd_sattrargs *argp = rqstp->rq_argp;
52 struct nfsd_attrstat *resp = rqstp->rq_resp;
53 struct iattr *iap = &argp->attrs;
54 struct nfsd_attrs attrs = {
55 .na_iattr = iap,
56 };
54 struct svc_fh *fhp;
55
56 dprintk("nfsd: SETATTR %s, valid=%x, size=%ld\n",
57 SVCFH_fmt(&argp->fh),
58 argp->attrs.ia_valid, (long) argp->attrs.ia_size);
59
60 fhp = fh_copy(&resp->fh, &argp->fh);
61

--- 33 unchanged lines hidden (view full) ---

95 * Turn off ATTR_[AM]TIME_SET but leave ATTR_[AM]TIME.
96 * This will cause notify_change to set these times
97 * to "now"
98 */
99 iap->ia_valid &= ~BOTH_TIME_SET;
100 }
101 }
102
57 struct svc_fh *fhp;
58
59 dprintk("nfsd: SETATTR %s, valid=%x, size=%ld\n",
60 SVCFH_fmt(&argp->fh),
61 argp->attrs.ia_valid, (long) argp->attrs.ia_size);
62
63 fhp = fh_copy(&resp->fh, &argp->fh);
64

--- 33 unchanged lines hidden (view full) ---

98 * Turn off ATTR_[AM]TIME_SET but leave ATTR_[AM]TIME.
99 * This will cause notify_change to set these times
100 * to "now"
101 */
102 iap->ia_valid &= ~BOTH_TIME_SET;
103 }
104 }
105
103 resp->status = nfsd_setattr(rqstp, fhp, iap, 0, (time64_t)0);
106 resp->status = nfsd_setattr(rqstp, fhp, &attrs, 0, (time64_t)0);
104 if (resp->status != nfs_ok)
105 goto out;
106
107 resp->status = fh_getattr(&resp->fh, &resp->stat);
108out:
109 return rpc_success;
110}
111

--- 143 unchanged lines hidden (view full) ---

255static __be32
256nfsd_proc_create(struct svc_rqst *rqstp)
257{
258 struct nfsd_createargs *argp = rqstp->rq_argp;
259 struct nfsd_diropres *resp = rqstp->rq_resp;
260 svc_fh *dirfhp = &argp->fh;
261 svc_fh *newfhp = &resp->fh;
262 struct iattr *attr = &argp->attrs;
107 if (resp->status != nfs_ok)
108 goto out;
109
110 resp->status = fh_getattr(&resp->fh, &resp->stat);
111out:
112 return rpc_success;
113}
114

--- 143 unchanged lines hidden (view full) ---

258static __be32
259nfsd_proc_create(struct svc_rqst *rqstp)
260{
261 struct nfsd_createargs *argp = rqstp->rq_argp;
262 struct nfsd_diropres *resp = rqstp->rq_resp;
263 svc_fh *dirfhp = &argp->fh;
264 svc_fh *newfhp = &resp->fh;
265 struct iattr *attr = &argp->attrs;
266 struct nfsd_attrs attrs = {
267 .na_iattr = attr,
268 };
263 struct inode *inode;
264 struct dentry *dchild;
265 int type, mode;
266 int hosterr;
267 dev_t rdev = 0, wanted = new_decode_dev(attr->ia_size);
268
269 dprintk("nfsd: CREATE %s %.*s\n",
270 SVCFH_fmt(dirfhp), argp->len, argp->name);

--- 109 unchanged lines hidden (view full) ---

380 if (inode && inode_wrong_type(inode, type))
381 goto out_unlock;
382 }
383
384 resp->status = nfs_ok;
385 if (!inode) {
386 /* File doesn't exist. Create it and set attrs */
387 resp->status = nfsd_create_locked(rqstp, dirfhp, argp->name,
269 struct inode *inode;
270 struct dentry *dchild;
271 int type, mode;
272 int hosterr;
273 dev_t rdev = 0, wanted = new_decode_dev(attr->ia_size);
274
275 dprintk("nfsd: CREATE %s %.*s\n",
276 SVCFH_fmt(dirfhp), argp->len, argp->name);

--- 109 unchanged lines hidden (view full) ---

386 if (inode && inode_wrong_type(inode, type))
387 goto out_unlock;
388 }
389
390 resp->status = nfs_ok;
391 if (!inode) {
392 /* File doesn't exist. Create it and set attrs */
393 resp->status = nfsd_create_locked(rqstp, dirfhp, argp->name,
388 argp->len, attr, type, rdev,
394 argp->len, &attrs, type, rdev,
389 newfhp);
390 } else if (type == S_IFREG) {
391 dprintk("nfsd: existing %s, valid=%x, size=%ld\n",
392 argp->name, attr->ia_valid, (long) attr->ia_size);
393 /* File already exists. We ignore all attributes except
394 * size, so that creat() behaves exactly like
395 * open(..., O_CREAT|O_TRUNC|O_WRONLY).
396 */
397 attr->ia_valid &= ATTR_SIZE;
398 if (attr->ia_valid)
395 newfhp);
396 } else if (type == S_IFREG) {
397 dprintk("nfsd: existing %s, valid=%x, size=%ld\n",
398 argp->name, attr->ia_valid, (long) attr->ia_size);
399 /* File already exists. We ignore all attributes except
400 * size, so that creat() behaves exactly like
401 * open(..., O_CREAT|O_TRUNC|O_WRONLY).
402 */
403 attr->ia_valid &= ATTR_SIZE;
404 if (attr->ia_valid)
399 resp->status = nfsd_setattr(rqstp, newfhp, attr, 0,
405 resp->status = nfsd_setattr(rqstp, newfhp, &attrs, 0,
400 (time64_t)0);
401 }
402
403out_unlock:
404 /* We don't really need to unlock, as fh_put does it. */
405 fh_unlock(dirfhp);
406 fh_drop_write(dirfhp);
407done:

--- 98 unchanged lines hidden (view full) ---

506 * Make directory. This operation is not idempotent.
507 * N.B. After this call resp->fh needs an fh_put
508 */
509static __be32
510nfsd_proc_mkdir(struct svc_rqst *rqstp)
511{
512 struct nfsd_createargs *argp = rqstp->rq_argp;
513 struct nfsd_diropres *resp = rqstp->rq_resp;
406 (time64_t)0);
407 }
408
409out_unlock:
410 /* We don't really need to unlock, as fh_put does it. */
411 fh_unlock(dirfhp);
412 fh_drop_write(dirfhp);
413done:

--- 98 unchanged lines hidden (view full) ---

512 * Make directory. This operation is not idempotent.
513 * N.B. After this call resp->fh needs an fh_put
514 */
515static __be32
516nfsd_proc_mkdir(struct svc_rqst *rqstp)
517{
518 struct nfsd_createargs *argp = rqstp->rq_argp;
519 struct nfsd_diropres *resp = rqstp->rq_resp;
520 struct nfsd_attrs attrs = {
521 .na_iattr = &argp->attrs,
522 };
514
515 dprintk("nfsd: MKDIR %s %.*s\n", SVCFH_fmt(&argp->fh), argp->len, argp->name);
516
517 if (resp->fh.fh_dentry) {
518 printk(KERN_WARNING
519 "nfsd_proc_mkdir: response already verified??\n");
520 }
521
522 argp->attrs.ia_valid &= ~ATTR_SIZE;
523 fh_init(&resp->fh, NFS_FHSIZE);
524 resp->status = nfsd_create(rqstp, &argp->fh, argp->name, argp->len,
523
524 dprintk("nfsd: MKDIR %s %.*s\n", SVCFH_fmt(&argp->fh), argp->len, argp->name);
525
526 if (resp->fh.fh_dentry) {
527 printk(KERN_WARNING
528 "nfsd_proc_mkdir: response already verified??\n");
529 }
530
531 argp->attrs.ia_valid &= ~ATTR_SIZE;
532 fh_init(&resp->fh, NFS_FHSIZE);
533 resp->status = nfsd_create(rqstp, &argp->fh, argp->name, argp->len,
525 &argp->attrs, S_IFDIR, 0, &resp->fh);
534 &attrs, S_IFDIR, 0, &resp->fh);
526 fh_put(&argp->fh);
527 if (resp->status != nfs_ok)
528 goto out;
529
530 resp->status = fh_getattr(&resp->fh, &resp->stat);
531out:
532 return rpc_success;
533}

--- 359 unchanged lines hidden ---
535 fh_put(&argp->fh);
536 if (resp->status != nfs_ok)
537 goto out;
538
539 resp->status = fh_getattr(&resp->fh, &resp->stat);
540out:
541 return rpc_success;
542}

--- 359 unchanged lines hidden ---