Use struct path in struct svc_export
[pandora-kernel.git] / fs / nfsd / vfs.c
index 46934c9..46f59d5 100644 (file)
@@ -101,7 +101,7 @@ nfsd_cross_mnt(struct svc_rqst *rqstp, struct dentry **dpp,
 {
        struct svc_export *exp = *expp, *exp2 = NULL;
        struct dentry *dentry = *dpp;
-       struct vfsmount *mnt = mntget(exp->ex_mnt);
+       struct vfsmount *mnt = mntget(exp->ex_path.mnt);
        struct dentry *mounts = dget(dentry);
        int err = 0;
 
@@ -132,7 +132,7 @@ out:
 
 __be32
 nfsd_lookup_dentry(struct svc_rqst *rqstp, struct svc_fh *fhp,
-                  const char *name, int len,
+                  const char *name, unsigned int len,
                   struct svc_export **exp_ret, struct dentry **dentry_ret)
 {
        struct svc_export       *exp;
@@ -156,15 +156,15 @@ nfsd_lookup_dentry(struct svc_rqst *rqstp, struct svc_fh *fhp,
        if (isdotent(name, len)) {
                if (len==1)
                        dentry = dget(dparent);
-               else if (dparent != exp->ex_dentry) {
+               else if (dparent != exp->ex_path.dentry)
                        dentry = dget_parent(dparent);
-               } else  if (!EX_NOHIDE(exp))
+               else if (!EX_NOHIDE(exp))
                        dentry = dget(dparent); /* .. == . just like at / */
                else {
                        /* checking mountpoint crossing is very different when stepping up */
                        struct svc_export *exp2 = NULL;
                        struct dentry *dp;
-                       struct vfsmount *mnt = mntget(exp->ex_mnt);
+                       struct vfsmount *mnt = mntget(exp->ex_path.mnt);
                        dentry = dget(dparent);
                        while(dentry == mnt->mnt_root && follow_up(&mnt, &dentry))
                                ;
@@ -226,7 +226,7 @@ out_nfserr:
  */
 __be32
 nfsd_lookup(struct svc_rqst *rqstp, struct svc_fh *fhp, const char *name,
-                                       int len, struct svc_fh *resfh)
+                               unsigned int len, struct svc_fh *resfh)
 {
        struct svc_export       *exp;
        struct dentry           *dentry;
@@ -721,7 +721,8 @@ nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, int type,
 
                DQUOT_INIT(inode);
        }
-       *filp = dentry_open(dget(dentry), mntget(fhp->fh_export->ex_mnt), flags);
+       *filp = dentry_open(dget(dentry), mntget(fhp->fh_export->ex_path.mnt),
+                               flags);
        if (IS_ERR(*filp))
                host_err = PTR_ERR(*filp);
 out_nfserr:
@@ -1029,13 +1030,13 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
                if (EX_WGATHER(exp)) {
                        if (atomic_read(&inode->i_writecount) > 1
                            || (last_ino == inode->i_ino && last_dev == inode->i_sb->s_dev)) {
-                               dprintk("nfsd: write defer %d\n", current->pid);
+                               dprintk("nfsd: write defer %d\n", task_pid_nr(current));
                                msleep(10);
-                               dprintk("nfsd: write resume %d\n", current->pid);
+                               dprintk("nfsd: write resume %d\n", task_pid_nr(current));
                        }
 
                        if (inode->i_state & I_DIRTY) {
-                               dprintk("nfsd: write sync %d\n", current->pid);
+                               dprintk("nfsd: write sync %d\n", task_pid_nr(current));
                                host_err=nfsd_sync(file);
                        }
 #if 0
@@ -1151,6 +1152,26 @@ nfsd_commit(struct svc_rqst *rqstp, struct svc_fh *fhp,
 }
 #endif /* CONFIG_NFSD_V3 */
 
+__be32
+nfsd_create_setattr(struct svc_rqst *rqstp, struct svc_fh *resfhp,
+                       struct iattr *iap)
+{
+       /*
+        * Mode has already been set earlier in create:
+        */
+       iap->ia_valid &= ~ATTR_MODE;
+       /*
+        * Setting uid/gid works only for root.  Irix appears to
+        * send along the gid on create when it tries to implement
+        * setgid directories via NFS:
+        */
+       if (current->fsuid != 0)
+               iap->ia_valid &= ~(ATTR_UID|ATTR_GID);
+       if (iap->ia_valid)
+               return nfsd_setattr(rqstp, resfhp, iap, 0, (time_t)0);
+       return 0;
+}
+
 /*
  * Create a file (regular, directory, device, fifo); UNIX sockets 
  * not yet implemented.
@@ -1167,6 +1188,7 @@ nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp,
        struct dentry   *dentry, *dchild = NULL;
        struct inode    *dirp;
        __be32          err;
+       __be32          err2;
        int             host_err;
 
        err = nfserr_perm;
@@ -1257,16 +1279,9 @@ nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp,
        }
 
 
-       /* Set file attributes. Mode has already been set and
-        * setting uid/gid works only for root. Irix appears to
-        * send along the gid when it tries to implement setgid
-        * directories via NFS.
-        */
-       if ((iap->ia_valid &= ~(ATTR_UID|ATTR_GID|ATTR_MODE)) != 0) {
-               __be32 err2 = nfsd_setattr(rqstp, resfhp, iap, 0, (time_t)0);
-               if (err2)
-                       err = err2;
-       }
+       err2 = nfsd_create_setattr(rqstp, resfhp, iap);
+       if (err2)
+               err = err2;
        /*
         * Update the file handle to get the new inode info.
         */
@@ -1295,6 +1310,7 @@ nfsd_create_v3(struct svc_rqst *rqstp, struct svc_fh *fhp,
        struct dentry   *dentry, *dchild = NULL;
        struct inode    *dirp;
        __be32          err;
+       __be32          err2;
        int             host_err;
        __u32           v_mtime=0, v_atime=0;
 
@@ -1399,16 +1415,10 @@ nfsd_create_v3(struct svc_rqst *rqstp, struct svc_fh *fhp,
                iap->ia_atime.tv_nsec = 0;
        }
 
-       /* Set file attributes.
-        * Irix appears to send along the gid when it tries to
-        * implement setgid directories via NFS. Clear out all that cruft.
-        */
  set_attr:
-       if ((iap->ia_valid &= ~(ATTR_UID|ATTR_GID|ATTR_MODE)) != 0) {
-               __be32 err2 = nfsd_setattr(rqstp, resfhp, iap, 0, (time_t)0);
-               if (err2)
-                       err = err2;
-       }
+       err2 = nfsd_create_setattr(rqstp, resfhp, iap);
+       if (err2)
+               err = err2;
 
        /*
         * Update the filehandle to get the new inode info.
@@ -1453,7 +1463,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
        if (!inode->i_op || !inode->i_op->readlink)
                goto out;
 
-       touch_atime(fhp->fh_export->ex_mnt, dentry);
+       touch_atime(fhp->fh_export->ex_path.mnt, dentry);
        /* N.B. Why does this call need a get_fs()??
         * Remove the set_fs and watch the fireworks:-) --okir
         */