NFSD: Finish refactoring __write_ports()
[safe/jmp/linux-2.6] / fs / nfsd / nfsproc.c
index b2c7147..e298e26 100644 (file)
@@ -41,7 +41,7 @@ static __be32
 nfsd_return_attrs(__be32 err, struct nfsd_attrstat *resp)
 {
        if (err) return err;
-       return nfserrno(vfs_getattr(resp->fh.fh_export->ex_mnt,
+       return nfserrno(vfs_getattr(resp->fh.fh_export->ex_path.mnt,
                                    resp->fh.fh_dentry,
                                    &resp->stat));
 }
@@ -49,7 +49,7 @@ static __be32
 nfsd_return_dirop(__be32 err, struct nfsd_diropres *resp)
 {
        if (err) return err;
-       return nfserrno(vfs_getattr(resp->fh.fh_export->ex_mnt,
+       return nfserrno(vfs_getattr(resp->fh.fh_export->ex_path.mnt,
                                    resp->fh.fh_dentry,
                                    &resp->stat));
 }
@@ -65,7 +65,8 @@ nfsd_proc_getattr(struct svc_rqst *rqstp, struct nfsd_fhandle  *argp,
        dprintk("nfsd: GETATTR  %s\n", SVCFH_fmt(&argp->fh));
 
        fh_copy(&resp->fh, &argp->fh);
-       nfserr = fh_verify(rqstp, &resp->fh, 0, MAY_NOP);
+       nfserr = fh_verify(rqstp, &resp->fh, 0,
+                       NFSD_MAY_NOP | NFSD_MAY_BYPASS_GSS_ON_ROOT);
        return nfsd_return_attrs(nfserr, resp);
 }
 
@@ -164,7 +165,7 @@ nfsd_proc_read(struct svc_rqst *rqstp, struct nfsd_readargs *argp,
                                  &resp->count);
 
        if (nfserr) return nfserr;
-       return nfserrno(vfs_getattr(resp->fh.fh_export->ex_mnt,
+       return nfserrno(vfs_getattr(resp->fh.fh_export->ex_path.mnt,
                                    resp->fh.fh_dentry,
                                    &resp->stat));
 }
@@ -179,6 +180,7 @@ nfsd_proc_write(struct svc_rqst *rqstp, struct nfsd_writeargs *argp,
 {
        __be32  nfserr;
        int     stable = 1;
+       unsigned long cnt = argp->len;
 
        dprintk("nfsd: WRITE    %s %d bytes at %d\n",
                SVCFH_fmt(&argp->fh),
@@ -187,7 +189,7 @@ nfsd_proc_write(struct svc_rqst *rqstp, struct nfsd_writeargs *argp,
        nfserr = nfsd_write(rqstp, fh_copy(&resp->fh, &argp->fh), NULL,
                                   argp->offset,
                                   rqstp->rq_vec, argp->vlen,
-                                  argp->len,
+                                  &cnt,
                                   &stable);
        return nfsd_return_attrs(nfserr, resp);
 }
@@ -215,11 +217,11 @@ nfsd_proc_create(struct svc_rqst *rqstp, struct nfsd_createargs *argp,
                SVCFH_fmt(dirfhp), argp->len, argp->name);
 
        /* First verify the parent file handle */
-       nfserr = fh_verify(rqstp, dirfhp, S_IFDIR, MAY_EXEC);
+       nfserr = fh_verify(rqstp, dirfhp, S_IFDIR, NFSD_MAY_EXEC);
        if (nfserr)
                goto done; /* must fh_put dirfhp even on error */
 
-       /* Check for MAY_WRITE in nfsd_create if necessary */
+       /* Check for NFSD_MAY_WRITE in nfsd_create if necessary */
 
        nfserr = nfserr_acces;
        if (!argp->len)
@@ -278,9 +280,10 @@ nfsd_proc_create(struct svc_rqst *rqstp, struct nfsd_createargs *argp,
                                         *   echo thing > device-special-file-or-pipe
                                         * by doing a CREATE with type==0
                                         */
-                                       nfserr = nfsd_permission(newfhp->fh_export,
+                                       nfserr = nfsd_permission(rqstp,
+                                                                newfhp->fh_export,
                                                                 newfhp->fh_dentry,
-                                                                MAY_WRITE|MAY_LOCAL_ACCESS);
+                                                                NFSD_MAY_WRITE|NFSD_MAY_LOCAL_ACCESS);
                                        if (nfserr && nfserr != nfserr_rofs)
                                                goto out_unlock;
                                }
@@ -520,7 +523,8 @@ nfsd_proc_statfs(struct svc_rqst * rqstp, struct nfsd_fhandle   *argp,
 
        dprintk("nfsd: STATFS   %s\n", SVCFH_fmt(&argp->fh));
 
-       nfserr = nfsd_statfs(rqstp, &argp->fh, &resp->stats);
+       nfserr = nfsd_statfs(rqstp, &argp->fh, &resp->stats,
+                       NFSD_MAY_BYPASS_GSS_ON_ROOT);
        fh_put(&argp->fh);
        return nfserr;
 }
@@ -613,11 +617,13 @@ nfserrno (int errno)
 #endif
                { nfserr_stale, -ESTALE },
                { nfserr_jukebox, -ETIMEDOUT },
+               { nfserr_jukebox, -ERESTARTSYS },
                { nfserr_dropit, -EAGAIN },
                { nfserr_dropit, -ENOMEM },
                { nfserr_badname, -ESRCH },
                { nfserr_io, -ETXTBSY },
                { nfserr_notsupp, -EOPNOTSUPP },
+               { nfserr_toosmall, -ETOOSMALL },
        };
        int     i;