]> err.no Git - linux-2.6/blobdiff - fs/nfsd/nfsproc.c
Merge branch 'audit.b32' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/audit...
[linux-2.6] / fs / nfsd / nfsproc.c
index 757f9d2080340b1240443704dee70308945b0fb6..9ee1dab5d44adc09214469af2014735f132c50cc 100644 (file)
@@ -36,6 +36,22 @@ nfsd_proc_null(struct svc_rqst *rqstp, void *argp, void *resp)
        return nfs_ok;
 }
 
+static int
+nfsd_return_attrs(int err, struct nfsd_attrstat *resp)
+{
+       if (err) return err;
+       return nfserrno(vfs_getattr(resp->fh.fh_export->ex_mnt,
+                                   resp->fh.fh_dentry,
+                                   &resp->stat));
+}
+static int
+nfsd_return_dirop(int err, struct nfsd_diropres *resp)
+{
+       if (err) return err;
+       return nfserrno(vfs_getattr(resp->fh.fh_export->ex_mnt,
+                                   resp->fh.fh_dentry,
+                                   &resp->stat));
+}
 /*
  * Get a file's attributes
  * N.B. After this call resp->fh needs an fh_put
@@ -44,10 +60,12 @@ static int
 nfsd_proc_getattr(struct svc_rqst *rqstp, struct nfsd_fhandle  *argp,
                                          struct nfsd_attrstat *resp)
 {
+       int nfserr;
        dprintk("nfsd: GETATTR  %s\n", SVCFH_fmt(&argp->fh));
 
        fh_copy(&resp->fh, &argp->fh);
-       return fh_verify(rqstp, &resp->fh, 0, MAY_NOP);
+       nfserr = fh_verify(rqstp, &resp->fh, 0, MAY_NOP);
+       return nfsd_return_attrs(nfserr, resp);
 }
 
 /*
@@ -58,12 +76,14 @@ static int
 nfsd_proc_setattr(struct svc_rqst *rqstp, struct nfsd_sattrargs *argp,
                                          struct nfsd_attrstat  *resp)
 {
+       int nfserr;
        dprintk("nfsd: SETATTR  %s, valid=%x, size=%ld\n",
                SVCFH_fmt(&argp->fh),
                argp->attrs.ia_valid, (long) argp->attrs.ia_size);
 
        fh_copy(&resp->fh, &argp->fh);
-       return nfsd_setattr(rqstp, &resp->fh, &argp->attrs,0, (time_t)0);
+       nfserr = nfsd_setattr(rqstp, &resp->fh, &argp->attrs,0, (time_t)0);
+       return nfsd_return_attrs(nfserr, resp);
 }
 
 /*
@@ -86,7 +106,7 @@ nfsd_proc_lookup(struct svc_rqst *rqstp, struct nfsd_diropargs *argp,
                                 &resp->fh);
 
        fh_put(&argp->fh);
-       return nfserr;
+       return nfsd_return_dirop(nfserr, resp);
 }
 
 /*
@@ -126,23 +146,26 @@ nfsd_proc_read(struct svc_rqst *rqstp, struct nfsd_readargs *argp,
         * status, 17 words for fattr, and 1 word for the byte count.
         */
 
-       if (NFSSVC_MAXBLKSIZE < argp->count) {
+       if (NFSSVC_MAXBLKSIZE_V2 < argp->count) {
                printk(KERN_NOTICE
                        "oversized read request from %u.%u.%u.%u:%d (%d bytes)\n",
                                NIPQUAD(rqstp->rq_addr.sin_addr.s_addr),
                                ntohs(rqstp->rq_addr.sin_port),
                                argp->count);
-               argp->count = NFSSVC_MAXBLKSIZE;
+               argp->count = NFSSVC_MAXBLKSIZE_V2;
        }
        svc_reserve(rqstp, (19<<2) + argp->count + 4);
 
        resp->count = argp->count;
        nfserr = nfsd_read(rqstp, fh_copy(&resp->fh, &argp->fh), NULL,
                                  argp->offset,
-                                 argp->vec, argp->vlen,
+                                 rqstp->rq_vec, argp->vlen,
                                  &resp->count);
 
-       return nfserr;
+       if (nfserr) return nfserr;
+       return nfserrno(vfs_getattr(resp->fh.fh_export->ex_mnt,
+                                   resp->fh.fh_dentry,
+                                   &resp->stat));
 }
 
 /*
@@ -162,10 +185,10 @@ nfsd_proc_write(struct svc_rqst *rqstp, struct nfsd_writeargs *argp,
 
        nfserr = nfsd_write(rqstp, fh_copy(&resp->fh, &argp->fh), NULL,
                                   argp->offset,
-                                  argp->vec, argp->vlen,
+                                  rqstp->rq_vec, argp->vlen,
                                   argp->len,
                                   &stable);
-       return nfserr;
+       return nfsd_return_attrs(nfserr, resp);
 }
 
 /*
@@ -202,7 +225,7 @@ nfsd_proc_create(struct svc_rqst *rqstp, struct nfsd_createargs *argp,
        nfserr = nfserr_exist;
        if (isdotent(argp->name, argp->len))
                goto done;
-       fh_lock(dirfhp);
+       fh_lock_nested(dirfhp, I_MUTEX_PARENT);
        dchild = lookup_one_len(argp->name, dirfhp->fh_dentry, argp->len);
        if (IS_ERR(dchild)) {
                nfserr = nfserrno(PTR_ERR(dchild));
@@ -322,7 +345,7 @@ out_unlock:
 
 done:
        fh_put(dirfhp);
-       return nfserr;
+       return nfsd_return_dirop(nfserr, resp);
 }
 
 static int
@@ -425,7 +448,7 @@ nfsd_proc_mkdir(struct svc_rqst *rqstp, struct nfsd_createargs *argp,
        nfserr = nfsd_create(rqstp, &argp->fh, argp->name, argp->len,
                                    &argp->attrs, S_IFDIR, 0, &resp->fh);
        fh_put(&argp->fh);
-       return nfserr;
+       return nfsd_return_dirop(nfserr, resp);
 }
 
 /*
@@ -530,7 +553,7 @@ static struct svc_procedure         nfsd_procedures2[18] = {
   PROC(none,    void,          void,           none,           RC_NOCACHE, ST),
   PROC(lookup,  diropargs,     diropres,       fhandle,        RC_NOCACHE, ST+FH+AT),
   PROC(readlink, readlinkargs, readlinkres,    none,           RC_NOCACHE, ST+1+NFS_MAXPATHLEN/4),
-  PROC(read,    readargs,      readres,        fhandle,        RC_NOCACHE, ST+AT+1+NFSSVC_MAXBLKSIZE),
+  PROC(read,    readargs,      readres,        fhandle,        RC_NOCACHE, ST+AT+1+NFSSVC_MAXBLKSIZE_V2/4),
   PROC(none,    void,          void,           none,           RC_NOCACHE, ST),
   PROC(write,   writeargs,     attrstat,       fhandle,        RC_REPLBUFF, ST+AT),
   PROC(create,  createargs,    diropres,       fhandle,        RC_REPLBUFF, ST+FH+AT),
@@ -591,6 +614,7 @@ nfserrno (int errno)
                { nfserr_dropit, -ENOMEM },
                { nfserr_badname, -ESRCH },
                { nfserr_io, -ETXTBSY },
+               { nfserr_notsupp, -EOPNOTSUPP },
                { -1, -EIO }
        };
        int     i;