[PATCH] nfsd: vfs.c endianness annotations
don't use the same variable to store NFS and host error values Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Acked-by: Trond Myklebust <trond.myklebust@fys.uio.no> Acked-by: Neil Brown <neilb@suse.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
parent
2ebbc012a9
commit
6264d69d7d
299
fs/nfsd/vfs.c
299
fs/nfsd/vfs.c
@ -110,7 +110,7 @@ nfsd_cross_mnt(struct svc_rqst *rqstp, struct dentry **dpp,
|
|||||||
struct dentry *dentry = *dpp;
|
struct dentry *dentry = *dpp;
|
||||||
struct vfsmount *mnt = mntget(exp->ex_mnt);
|
struct vfsmount *mnt = mntget(exp->ex_mnt);
|
||||||
struct dentry *mounts = dget(dentry);
|
struct dentry *mounts = dget(dentry);
|
||||||
int err = nfs_ok;
|
int err = 0;
|
||||||
|
|
||||||
while (follow_down(&mnt,&mounts)&&d_mountpoint(mounts));
|
while (follow_down(&mnt,&mounts)&&d_mountpoint(mounts));
|
||||||
|
|
||||||
@ -148,14 +148,15 @@ out:
|
|||||||
* clients and is explicitly disallowed for NFSv3
|
* clients and is explicitly disallowed for NFSv3
|
||||||
* NeilBrown <neilb@cse.unsw.edu.au>
|
* NeilBrown <neilb@cse.unsw.edu.au>
|
||||||
*/
|
*/
|
||||||
int
|
__be32
|
||||||
nfsd_lookup(struct svc_rqst *rqstp, struct svc_fh *fhp, const char *name,
|
nfsd_lookup(struct svc_rqst *rqstp, struct svc_fh *fhp, const char *name,
|
||||||
int len, struct svc_fh *resfh)
|
int len, struct svc_fh *resfh)
|
||||||
{
|
{
|
||||||
struct svc_export *exp;
|
struct svc_export *exp;
|
||||||
struct dentry *dparent;
|
struct dentry *dparent;
|
||||||
struct dentry *dentry;
|
struct dentry *dentry;
|
||||||
int err;
|
__be32 err;
|
||||||
|
int host_err;
|
||||||
|
|
||||||
dprintk("nfsd: nfsd_lookup(fh %s, %.*s)\n", SVCFH_fmt(fhp), len,name);
|
dprintk("nfsd: nfsd_lookup(fh %s, %.*s)\n", SVCFH_fmt(fhp), len,name);
|
||||||
|
|
||||||
@ -193,7 +194,7 @@ nfsd_lookup(struct svc_rqst *rqstp, struct svc_fh *fhp, const char *name,
|
|||||||
exp2 = exp_parent(exp->ex_client, mnt, dentry,
|
exp2 = exp_parent(exp->ex_client, mnt, dentry,
|
||||||
&rqstp->rq_chandle);
|
&rqstp->rq_chandle);
|
||||||
if (IS_ERR(exp2)) {
|
if (IS_ERR(exp2)) {
|
||||||
err = PTR_ERR(exp2);
|
host_err = PTR_ERR(exp2);
|
||||||
dput(dentry);
|
dput(dentry);
|
||||||
mntput(mnt);
|
mntput(mnt);
|
||||||
goto out_nfserr;
|
goto out_nfserr;
|
||||||
@ -210,14 +211,14 @@ nfsd_lookup(struct svc_rqst *rqstp, struct svc_fh *fhp, const char *name,
|
|||||||
} else {
|
} else {
|
||||||
fh_lock(fhp);
|
fh_lock(fhp);
|
||||||
dentry = lookup_one_len(name, dparent, len);
|
dentry = lookup_one_len(name, dparent, len);
|
||||||
err = PTR_ERR(dentry);
|
host_err = PTR_ERR(dentry);
|
||||||
if (IS_ERR(dentry))
|
if (IS_ERR(dentry))
|
||||||
goto out_nfserr;
|
goto out_nfserr;
|
||||||
/*
|
/*
|
||||||
* check if we have crossed a mount point ...
|
* check if we have crossed a mount point ...
|
||||||
*/
|
*/
|
||||||
if (d_mountpoint(dentry)) {
|
if (d_mountpoint(dentry)) {
|
||||||
if ((err = nfsd_cross_mnt(rqstp, &dentry, &exp))) {
|
if ((host_err = nfsd_cross_mnt(rqstp, &dentry, &exp))) {
|
||||||
dput(dentry);
|
dput(dentry);
|
||||||
goto out_nfserr;
|
goto out_nfserr;
|
||||||
}
|
}
|
||||||
@ -236,7 +237,7 @@ out:
|
|||||||
return err;
|
return err;
|
||||||
|
|
||||||
out_nfserr:
|
out_nfserr:
|
||||||
err = nfserrno(err);
|
err = nfserrno(host_err);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,7 +245,7 @@ out_nfserr:
|
|||||||
* Set various file attributes.
|
* Set various file attributes.
|
||||||
* N.B. After this call fhp needs an fh_put
|
* N.B. After this call fhp needs an fh_put
|
||||||
*/
|
*/
|
||||||
int
|
__be32
|
||||||
nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
|
nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
|
||||||
int check_guard, time_t guardtime)
|
int check_guard, time_t guardtime)
|
||||||
{
|
{
|
||||||
@ -253,7 +254,8 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
|
|||||||
int accmode = MAY_SATTR;
|
int accmode = MAY_SATTR;
|
||||||
int ftype = 0;
|
int ftype = 0;
|
||||||
int imode;
|
int imode;
|
||||||
int err;
|
__be32 err;
|
||||||
|
int host_err;
|
||||||
int size_change = 0;
|
int size_change = 0;
|
||||||
|
|
||||||
if (iap->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_SIZE))
|
if (iap->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_SIZE))
|
||||||
@ -319,19 +321,19 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
|
|||||||
* If we are changing the size of the file, then
|
* If we are changing the size of the file, then
|
||||||
* we need to break all leases.
|
* we need to break all leases.
|
||||||
*/
|
*/
|
||||||
err = break_lease(inode, FMODE_WRITE | O_NONBLOCK);
|
host_err = break_lease(inode, FMODE_WRITE | O_NONBLOCK);
|
||||||
if (err == -EWOULDBLOCK)
|
if (host_err == -EWOULDBLOCK)
|
||||||
err = -ETIMEDOUT;
|
host_err = -ETIMEDOUT;
|
||||||
if (err) /* ENOMEM or EWOULDBLOCK */
|
if (host_err) /* ENOMEM or EWOULDBLOCK */
|
||||||
goto out_nfserr;
|
goto out_nfserr;
|
||||||
|
|
||||||
err = get_write_access(inode);
|
host_err = get_write_access(inode);
|
||||||
if (err)
|
if (host_err)
|
||||||
goto out_nfserr;
|
goto out_nfserr;
|
||||||
|
|
||||||
size_change = 1;
|
size_change = 1;
|
||||||
err = locks_verify_truncate(inode, NULL, iap->ia_size);
|
host_err = locks_verify_truncate(inode, NULL, iap->ia_size);
|
||||||
if (err) {
|
if (host_err) {
|
||||||
put_write_access(inode);
|
put_write_access(inode);
|
||||||
goto out_nfserr;
|
goto out_nfserr;
|
||||||
}
|
}
|
||||||
@ -357,8 +359,8 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
|
|||||||
err = nfserr_notsync;
|
err = nfserr_notsync;
|
||||||
if (!check_guard || guardtime == inode->i_ctime.tv_sec) {
|
if (!check_guard || guardtime == inode->i_ctime.tv_sec) {
|
||||||
fh_lock(fhp);
|
fh_lock(fhp);
|
||||||
err = notify_change(dentry, iap);
|
host_err = notify_change(dentry, iap);
|
||||||
err = nfserrno(err);
|
err = nfserrno(host_err);
|
||||||
fh_unlock(fhp);
|
fh_unlock(fhp);
|
||||||
}
|
}
|
||||||
if (size_change)
|
if (size_change)
|
||||||
@ -370,7 +372,7 @@ out:
|
|||||||
return err;
|
return err;
|
||||||
|
|
||||||
out_nfserr:
|
out_nfserr:
|
||||||
err = nfserrno(err);
|
err = nfserrno(host_err);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -420,11 +422,12 @@ out:
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
__be32
|
||||||
nfsd4_set_nfs4_acl(struct svc_rqst *rqstp, struct svc_fh *fhp,
|
nfsd4_set_nfs4_acl(struct svc_rqst *rqstp, struct svc_fh *fhp,
|
||||||
struct nfs4_acl *acl)
|
struct nfs4_acl *acl)
|
||||||
{
|
{
|
||||||
int error;
|
__be32 error;
|
||||||
|
int host_error;
|
||||||
struct dentry *dentry;
|
struct dentry *dentry;
|
||||||
struct inode *inode;
|
struct inode *inode;
|
||||||
struct posix_acl *pacl = NULL, *dpacl = NULL;
|
struct posix_acl *pacl = NULL, *dpacl = NULL;
|
||||||
@ -440,20 +443,20 @@ nfsd4_set_nfs4_acl(struct svc_rqst *rqstp, struct svc_fh *fhp,
|
|||||||
if (S_ISDIR(inode->i_mode))
|
if (S_ISDIR(inode->i_mode))
|
||||||
flags = NFS4_ACL_DIR;
|
flags = NFS4_ACL_DIR;
|
||||||
|
|
||||||
error = nfs4_acl_nfsv4_to_posix(acl, &pacl, &dpacl, flags);
|
host_error = nfs4_acl_nfsv4_to_posix(acl, &pacl, &dpacl, flags);
|
||||||
if (error == -EINVAL) {
|
if (host_error == -EINVAL) {
|
||||||
error = nfserr_attrnotsupp;
|
error = nfserr_attrnotsupp;
|
||||||
goto out;
|
goto out;
|
||||||
} else if (error < 0)
|
} else if (host_error < 0)
|
||||||
goto out_nfserr;
|
goto out_nfserr;
|
||||||
|
|
||||||
error = set_nfsv4_acl_one(dentry, pacl, POSIX_ACL_XATTR_ACCESS);
|
host_error = set_nfsv4_acl_one(dentry, pacl, POSIX_ACL_XATTR_ACCESS);
|
||||||
if (error < 0)
|
if (host_error < 0)
|
||||||
goto out_nfserr;
|
goto out_nfserr;
|
||||||
|
|
||||||
if (S_ISDIR(inode->i_mode)) {
|
if (S_ISDIR(inode->i_mode)) {
|
||||||
error = set_nfsv4_acl_one(dentry, dpacl, POSIX_ACL_XATTR_DEFAULT);
|
host_error = set_nfsv4_acl_one(dentry, dpacl, POSIX_ACL_XATTR_DEFAULT);
|
||||||
if (error < 0)
|
if (host_error < 0)
|
||||||
goto out_nfserr;
|
goto out_nfserr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -464,7 +467,7 @@ out:
|
|||||||
posix_acl_release(dpacl);
|
posix_acl_release(dpacl);
|
||||||
return (error);
|
return (error);
|
||||||
out_nfserr:
|
out_nfserr:
|
||||||
error = nfserrno(error);
|
error = nfserrno(host_error);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -571,14 +574,14 @@ static struct accessmap nfs3_anyaccess[] = {
|
|||||||
{ 0, 0 }
|
{ 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
__be32
|
||||||
nfsd_access(struct svc_rqst *rqstp, struct svc_fh *fhp, u32 *access, u32 *supported)
|
nfsd_access(struct svc_rqst *rqstp, struct svc_fh *fhp, u32 *access, u32 *supported)
|
||||||
{
|
{
|
||||||
struct accessmap *map;
|
struct accessmap *map;
|
||||||
struct svc_export *export;
|
struct svc_export *export;
|
||||||
struct dentry *dentry;
|
struct dentry *dentry;
|
||||||
u32 query, result = 0, sresult = 0;
|
u32 query, result = 0, sresult = 0;
|
||||||
unsigned int error;
|
__be32 error;
|
||||||
|
|
||||||
error = fh_verify(rqstp, fhp, 0, MAY_NOP);
|
error = fh_verify(rqstp, fhp, 0, MAY_NOP);
|
||||||
if (error)
|
if (error)
|
||||||
@ -598,7 +601,7 @@ nfsd_access(struct svc_rqst *rqstp, struct svc_fh *fhp, u32 *access, u32 *suppor
|
|||||||
query = *access;
|
query = *access;
|
||||||
for (; map->access; map++) {
|
for (; map->access; map++) {
|
||||||
if (map->access & query) {
|
if (map->access & query) {
|
||||||
unsigned int err2;
|
__be32 err2;
|
||||||
|
|
||||||
sresult |= map->access;
|
sresult |= map->access;
|
||||||
|
|
||||||
@ -637,13 +640,15 @@ nfsd_access(struct svc_rqst *rqstp, struct svc_fh *fhp, u32 *access, u32 *suppor
|
|||||||
* The access argument indicates the type of open (read/write/lock)
|
* The access argument indicates the type of open (read/write/lock)
|
||||||
* N.B. After this call fhp needs an fh_put
|
* N.B. After this call fhp needs an fh_put
|
||||||
*/
|
*/
|
||||||
int
|
__be32
|
||||||
nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, int type,
|
nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, int type,
|
||||||
int access, struct file **filp)
|
int access, struct file **filp)
|
||||||
{
|
{
|
||||||
struct dentry *dentry;
|
struct dentry *dentry;
|
||||||
struct inode *inode;
|
struct inode *inode;
|
||||||
int flags = O_RDONLY|O_LARGEFILE, err;
|
int flags = O_RDONLY|O_LARGEFILE;
|
||||||
|
__be32 err;
|
||||||
|
int host_err;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If we get here, then the client has already done an "open",
|
* If we get here, then the client has already done an "open",
|
||||||
@ -673,10 +678,10 @@ nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, int type,
|
|||||||
* Check to see if there are any leases on this file.
|
* Check to see if there are any leases on this file.
|
||||||
* This may block while leases are broken.
|
* This may block while leases are broken.
|
||||||
*/
|
*/
|
||||||
err = break_lease(inode, O_NONBLOCK | ((access & MAY_WRITE) ? FMODE_WRITE : 0));
|
host_err = break_lease(inode, O_NONBLOCK | ((access & MAY_WRITE) ? FMODE_WRITE : 0));
|
||||||
if (err == -EWOULDBLOCK)
|
if (host_err == -EWOULDBLOCK)
|
||||||
err = -ETIMEDOUT;
|
host_err = -ETIMEDOUT;
|
||||||
if (err) /* NOMEM or WOULDBLOCK */
|
if (host_err) /* NOMEM or WOULDBLOCK */
|
||||||
goto out_nfserr;
|
goto out_nfserr;
|
||||||
|
|
||||||
if (access & MAY_WRITE) {
|
if (access & MAY_WRITE) {
|
||||||
@ -689,10 +694,9 @@ nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, int type,
|
|||||||
}
|
}
|
||||||
*filp = dentry_open(dget(dentry), mntget(fhp->fh_export->ex_mnt), flags);
|
*filp = dentry_open(dget(dentry), mntget(fhp->fh_export->ex_mnt), flags);
|
||||||
if (IS_ERR(*filp))
|
if (IS_ERR(*filp))
|
||||||
err = PTR_ERR(*filp);
|
host_err = PTR_ERR(*filp);
|
||||||
out_nfserr:
|
out_nfserr:
|
||||||
if (err)
|
err = nfserrno(host_err);
|
||||||
err = nfserrno(err);
|
|
||||||
out:
|
out:
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@ -830,14 +834,15 @@ nfsd_read_actor(read_descriptor_t *desc, struct page *page, unsigned long offset
|
|||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static __be32
|
||||||
nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
|
nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
|
||||||
loff_t offset, struct kvec *vec, int vlen, unsigned long *count)
|
loff_t offset, struct kvec *vec, int vlen, unsigned long *count)
|
||||||
{
|
{
|
||||||
struct inode *inode;
|
struct inode *inode;
|
||||||
struct raparms *ra;
|
struct raparms *ra;
|
||||||
mm_segment_t oldfs;
|
mm_segment_t oldfs;
|
||||||
int err;
|
__be32 err;
|
||||||
|
int host_err;
|
||||||
|
|
||||||
err = nfserr_perm;
|
err = nfserr_perm;
|
||||||
inode = file->f_dentry->d_inode;
|
inode = file->f_dentry->d_inode;
|
||||||
@ -855,12 +860,12 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
|
|||||||
|
|
||||||
if (file->f_op->sendfile && rqstp->rq_sendfile_ok) {
|
if (file->f_op->sendfile && rqstp->rq_sendfile_ok) {
|
||||||
rqstp->rq_resused = 1;
|
rqstp->rq_resused = 1;
|
||||||
err = file->f_op->sendfile(file, &offset, *count,
|
host_err = file->f_op->sendfile(file, &offset, *count,
|
||||||
nfsd_read_actor, rqstp);
|
nfsd_read_actor, rqstp);
|
||||||
} else {
|
} else {
|
||||||
oldfs = get_fs();
|
oldfs = get_fs();
|
||||||
set_fs(KERNEL_DS);
|
set_fs(KERNEL_DS);
|
||||||
err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
|
host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
|
||||||
set_fs(oldfs);
|
set_fs(oldfs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -874,13 +879,13 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
|
|||||||
spin_unlock(&rab->pb_lock);
|
spin_unlock(&rab->pb_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err >= 0) {
|
if (host_err >= 0) {
|
||||||
nfsdstats.io_read += err;
|
nfsdstats.io_read += host_err;
|
||||||
*count = err;
|
*count = host_err;
|
||||||
err = 0;
|
err = 0;
|
||||||
fsnotify_access(file->f_dentry);
|
fsnotify_access(file->f_dentry);
|
||||||
} else
|
} else
|
||||||
err = nfserrno(err);
|
err = nfserrno(host_err);
|
||||||
out:
|
out:
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@ -895,7 +900,7 @@ static void kill_suid(struct dentry *dentry)
|
|||||||
mutex_unlock(&dentry->d_inode->i_mutex);
|
mutex_unlock(&dentry->d_inode->i_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static __be32
|
||||||
nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
|
nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
|
||||||
loff_t offset, struct kvec *vec, int vlen,
|
loff_t offset, struct kvec *vec, int vlen,
|
||||||
unsigned long cnt, int *stablep)
|
unsigned long cnt, int *stablep)
|
||||||
@ -904,7 +909,8 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
|
|||||||
struct dentry *dentry;
|
struct dentry *dentry;
|
||||||
struct inode *inode;
|
struct inode *inode;
|
||||||
mm_segment_t oldfs;
|
mm_segment_t oldfs;
|
||||||
int err = 0;
|
__be32 err = 0;
|
||||||
|
int host_err;
|
||||||
int stable = *stablep;
|
int stable = *stablep;
|
||||||
|
|
||||||
#ifdef MSNFS
|
#ifdef MSNFS
|
||||||
@ -940,18 +946,18 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
|
|||||||
|
|
||||||
/* Write the data. */
|
/* Write the data. */
|
||||||
oldfs = get_fs(); set_fs(KERNEL_DS);
|
oldfs = get_fs(); set_fs(KERNEL_DS);
|
||||||
err = vfs_writev(file, (struct iovec __user *)vec, vlen, &offset);
|
host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &offset);
|
||||||
set_fs(oldfs);
|
set_fs(oldfs);
|
||||||
if (err >= 0) {
|
if (host_err >= 0) {
|
||||||
nfsdstats.io_write += cnt;
|
nfsdstats.io_write += cnt;
|
||||||
fsnotify_modify(file->f_dentry);
|
fsnotify_modify(file->f_dentry);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* clear setuid/setgid flag after write */
|
/* clear setuid/setgid flag after write */
|
||||||
if (err >= 0 && (inode->i_mode & (S_ISUID | S_ISGID)))
|
if (host_err >= 0 && (inode->i_mode & (S_ISUID | S_ISGID)))
|
||||||
kill_suid(dentry);
|
kill_suid(dentry);
|
||||||
|
|
||||||
if (err >= 0 && stable) {
|
if (host_err >= 0 && stable) {
|
||||||
static ino_t last_ino;
|
static ino_t last_ino;
|
||||||
static dev_t last_dev;
|
static dev_t last_dev;
|
||||||
|
|
||||||
@ -977,7 +983,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
|
|||||||
|
|
||||||
if (inode->i_state & I_DIRTY) {
|
if (inode->i_state & I_DIRTY) {
|
||||||
dprintk("nfsd: write sync %d\n", current->pid);
|
dprintk("nfsd: write sync %d\n", current->pid);
|
||||||
err=nfsd_sync(file);
|
host_err=nfsd_sync(file);
|
||||||
}
|
}
|
||||||
#if 0
|
#if 0
|
||||||
wake_up(&inode->i_wait);
|
wake_up(&inode->i_wait);
|
||||||
@ -987,11 +993,11 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
|
|||||||
last_dev = inode->i_sb->s_dev;
|
last_dev = inode->i_sb->s_dev;
|
||||||
}
|
}
|
||||||
|
|
||||||
dprintk("nfsd: write complete err=%d\n", err);
|
dprintk("nfsd: write complete host_err=%d\n", host_err);
|
||||||
if (err >= 0)
|
if (host_err >= 0)
|
||||||
err = 0;
|
err = 0;
|
||||||
else
|
else
|
||||||
err = nfserrno(err);
|
err = nfserrno(host_err);
|
||||||
out:
|
out:
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@ -1001,12 +1007,12 @@ out:
|
|||||||
* on entry. On return, *count contains the number of bytes actually read.
|
* on entry. On return, *count contains the number of bytes actually read.
|
||||||
* N.B. After this call fhp needs an fh_put
|
* N.B. After this call fhp needs an fh_put
|
||||||
*/
|
*/
|
||||||
int
|
__be32
|
||||||
nfsd_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
|
nfsd_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
|
||||||
loff_t offset, struct kvec *vec, int vlen,
|
loff_t offset, struct kvec *vec, int vlen,
|
||||||
unsigned long *count)
|
unsigned long *count)
|
||||||
{
|
{
|
||||||
int err;
|
__be32 err;
|
||||||
|
|
||||||
if (file) {
|
if (file) {
|
||||||
err = nfsd_permission(fhp->fh_export, fhp->fh_dentry,
|
err = nfsd_permission(fhp->fh_export, fhp->fh_dentry,
|
||||||
@ -1030,12 +1036,12 @@ out:
|
|||||||
* The stable flag requests synchronous writes.
|
* The stable flag requests synchronous writes.
|
||||||
* N.B. After this call fhp needs an fh_put
|
* N.B. After this call fhp needs an fh_put
|
||||||
*/
|
*/
|
||||||
int
|
__be32
|
||||||
nfsd_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
|
nfsd_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
|
||||||
loff_t offset, struct kvec *vec, int vlen, unsigned long cnt,
|
loff_t offset, struct kvec *vec, int vlen, unsigned long cnt,
|
||||||
int *stablep)
|
int *stablep)
|
||||||
{
|
{
|
||||||
int err = 0;
|
__be32 err = 0;
|
||||||
|
|
||||||
if (file) {
|
if (file) {
|
||||||
err = nfsd_permission(fhp->fh_export, fhp->fh_dentry,
|
err = nfsd_permission(fhp->fh_export, fhp->fh_dentry,
|
||||||
@ -1067,12 +1073,12 @@ out:
|
|||||||
* Unfortunately we cannot lock the file to make sure we return full WCC
|
* Unfortunately we cannot lock the file to make sure we return full WCC
|
||||||
* data to the client, as locking happens lower down in the filesystem.
|
* data to the client, as locking happens lower down in the filesystem.
|
||||||
*/
|
*/
|
||||||
int
|
__be32
|
||||||
nfsd_commit(struct svc_rqst *rqstp, struct svc_fh *fhp,
|
nfsd_commit(struct svc_rqst *rqstp, struct svc_fh *fhp,
|
||||||
loff_t offset, unsigned long count)
|
loff_t offset, unsigned long count)
|
||||||
{
|
{
|
||||||
struct file *file;
|
struct file *file;
|
||||||
int err;
|
__be32 err;
|
||||||
|
|
||||||
if ((u64)count > ~(u64)offset)
|
if ((u64)count > ~(u64)offset)
|
||||||
return nfserr_inval;
|
return nfserr_inval;
|
||||||
@ -1100,14 +1106,15 @@ nfsd_commit(struct svc_rqst *rqstp, struct svc_fh *fhp,
|
|||||||
*
|
*
|
||||||
* N.B. Every call to nfsd_create needs an fh_put for _both_ fhp and resfhp
|
* N.B. Every call to nfsd_create needs an fh_put for _both_ fhp and resfhp
|
||||||
*/
|
*/
|
||||||
int
|
__be32
|
||||||
nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp,
|
nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp,
|
||||||
char *fname, int flen, struct iattr *iap,
|
char *fname, int flen, struct iattr *iap,
|
||||||
int type, dev_t rdev, struct svc_fh *resfhp)
|
int type, dev_t rdev, struct svc_fh *resfhp)
|
||||||
{
|
{
|
||||||
struct dentry *dentry, *dchild = NULL;
|
struct dentry *dentry, *dchild = NULL;
|
||||||
struct inode *dirp;
|
struct inode *dirp;
|
||||||
int err;
|
__be32 err;
|
||||||
|
int host_err;
|
||||||
|
|
||||||
err = nfserr_perm;
|
err = nfserr_perm;
|
||||||
if (!flen)
|
if (!flen)
|
||||||
@ -1134,7 +1141,7 @@ nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp,
|
|||||||
/* called from nfsd_proc_mkdir, or possibly nfsd3_proc_create */
|
/* called from nfsd_proc_mkdir, or possibly nfsd3_proc_create */
|
||||||
fh_lock_nested(fhp, I_MUTEX_PARENT);
|
fh_lock_nested(fhp, I_MUTEX_PARENT);
|
||||||
dchild = lookup_one_len(fname, dentry, flen);
|
dchild = lookup_one_len(fname, dentry, flen);
|
||||||
err = PTR_ERR(dchild);
|
host_err = PTR_ERR(dchild);
|
||||||
if (IS_ERR(dchild))
|
if (IS_ERR(dchild))
|
||||||
goto out_nfserr;
|
goto out_nfserr;
|
||||||
err = fh_compose(resfhp, fhp->fh_export, dchild, fhp);
|
err = fh_compose(resfhp, fhp->fh_export, dchild, fhp);
|
||||||
@ -1173,22 +1180,22 @@ nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp,
|
|||||||
err = nfserr_perm;
|
err = nfserr_perm;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case S_IFREG:
|
case S_IFREG:
|
||||||
err = vfs_create(dirp, dchild, iap->ia_mode, NULL);
|
host_err = vfs_create(dirp, dchild, iap->ia_mode, NULL);
|
||||||
break;
|
break;
|
||||||
case S_IFDIR:
|
case S_IFDIR:
|
||||||
err = vfs_mkdir(dirp, dchild, iap->ia_mode);
|
host_err = vfs_mkdir(dirp, dchild, iap->ia_mode);
|
||||||
break;
|
break;
|
||||||
case S_IFCHR:
|
case S_IFCHR:
|
||||||
case S_IFBLK:
|
case S_IFBLK:
|
||||||
case S_IFIFO:
|
case S_IFIFO:
|
||||||
case S_IFSOCK:
|
case S_IFSOCK:
|
||||||
err = vfs_mknod(dirp, dchild, iap->ia_mode, rdev);
|
host_err = vfs_mknod(dirp, dchild, iap->ia_mode, rdev);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printk("nfsd: bad file type %o in nfsd_create\n", type);
|
printk("nfsd: bad file type %o in nfsd_create\n", type);
|
||||||
err = -EINVAL;
|
host_err = -EINVAL;
|
||||||
}
|
}
|
||||||
if (err < 0)
|
if (host_err < 0)
|
||||||
goto out_nfserr;
|
goto out_nfserr;
|
||||||
|
|
||||||
if (EX_ISSYNC(fhp->fh_export)) {
|
if (EX_ISSYNC(fhp->fh_export)) {
|
||||||
@ -1203,7 +1210,7 @@ nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp,
|
|||||||
* directories via NFS.
|
* directories via NFS.
|
||||||
*/
|
*/
|
||||||
if ((iap->ia_valid &= ~(ATTR_UID|ATTR_GID|ATTR_MODE)) != 0) {
|
if ((iap->ia_valid &= ~(ATTR_UID|ATTR_GID|ATTR_MODE)) != 0) {
|
||||||
int err2 = nfsd_setattr(rqstp, resfhp, iap, 0, (time_t)0);
|
__be32 err2 = nfsd_setattr(rqstp, resfhp, iap, 0, (time_t)0);
|
||||||
if (err2)
|
if (err2)
|
||||||
err = err2;
|
err = err2;
|
||||||
}
|
}
|
||||||
@ -1218,7 +1225,7 @@ out:
|
|||||||
return err;
|
return err;
|
||||||
|
|
||||||
out_nfserr:
|
out_nfserr:
|
||||||
err = nfserrno(err);
|
err = nfserrno(host_err);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1226,7 +1233,7 @@ out_nfserr:
|
|||||||
/*
|
/*
|
||||||
* NFSv3 version of nfsd_create
|
* NFSv3 version of nfsd_create
|
||||||
*/
|
*/
|
||||||
int
|
__be32
|
||||||
nfsd_create_v3(struct svc_rqst *rqstp, struct svc_fh *fhp,
|
nfsd_create_v3(struct svc_rqst *rqstp, struct svc_fh *fhp,
|
||||||
char *fname, int flen, struct iattr *iap,
|
char *fname, int flen, struct iattr *iap,
|
||||||
struct svc_fh *resfhp, int createmode, u32 *verifier,
|
struct svc_fh *resfhp, int createmode, u32 *verifier,
|
||||||
@ -1234,7 +1241,8 @@ nfsd_create_v3(struct svc_rqst *rqstp, struct svc_fh *fhp,
|
|||||||
{
|
{
|
||||||
struct dentry *dentry, *dchild = NULL;
|
struct dentry *dentry, *dchild = NULL;
|
||||||
struct inode *dirp;
|
struct inode *dirp;
|
||||||
int err;
|
__be32 err;
|
||||||
|
int host_err;
|
||||||
__u32 v_mtime=0, v_atime=0;
|
__u32 v_mtime=0, v_atime=0;
|
||||||
int v_mode=0;
|
int v_mode=0;
|
||||||
|
|
||||||
@ -1264,7 +1272,7 @@ nfsd_create_v3(struct svc_rqst *rqstp, struct svc_fh *fhp,
|
|||||||
* Compose the response file handle.
|
* Compose the response file handle.
|
||||||
*/
|
*/
|
||||||
dchild = lookup_one_len(fname, dentry, flen);
|
dchild = lookup_one_len(fname, dentry, flen);
|
||||||
err = PTR_ERR(dchild);
|
host_err = PTR_ERR(dchild);
|
||||||
if (IS_ERR(dchild))
|
if (IS_ERR(dchild))
|
||||||
goto out_nfserr;
|
goto out_nfserr;
|
||||||
|
|
||||||
@ -1320,8 +1328,8 @@ nfsd_create_v3(struct svc_rqst *rqstp, struct svc_fh *fhp,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = vfs_create(dirp, dchild, iap->ia_mode, NULL);
|
host_err = vfs_create(dirp, dchild, iap->ia_mode, NULL);
|
||||||
if (err < 0)
|
if (host_err < 0)
|
||||||
goto out_nfserr;
|
goto out_nfserr;
|
||||||
|
|
||||||
if (EX_ISSYNC(fhp->fh_export)) {
|
if (EX_ISSYNC(fhp->fh_export)) {
|
||||||
@ -1350,7 +1358,7 @@ nfsd_create_v3(struct svc_rqst *rqstp, struct svc_fh *fhp,
|
|||||||
*/
|
*/
|
||||||
set_attr:
|
set_attr:
|
||||||
if ((iap->ia_valid &= ~(ATTR_UID|ATTR_GID)) != 0) {
|
if ((iap->ia_valid &= ~(ATTR_UID|ATTR_GID)) != 0) {
|
||||||
int err2 = nfsd_setattr(rqstp, resfhp, iap, 0, (time_t)0);
|
__be32 err2 = nfsd_setattr(rqstp, resfhp, iap, 0, (time_t)0);
|
||||||
if (err2)
|
if (err2)
|
||||||
err = err2;
|
err = err2;
|
||||||
}
|
}
|
||||||
@ -1368,7 +1376,7 @@ nfsd_create_v3(struct svc_rqst *rqstp, struct svc_fh *fhp,
|
|||||||
return err;
|
return err;
|
||||||
|
|
||||||
out_nfserr:
|
out_nfserr:
|
||||||
err = nfserrno(err);
|
err = nfserrno(host_err);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_NFSD_V3 */
|
#endif /* CONFIG_NFSD_V3 */
|
||||||
@ -1378,13 +1386,14 @@ nfsd_create_v3(struct svc_rqst *rqstp, struct svc_fh *fhp,
|
|||||||
* fits into the buffer. On return, it contains the true length.
|
* fits into the buffer. On return, it contains the true length.
|
||||||
* N.B. After this call fhp needs an fh_put
|
* N.B. After this call fhp needs an fh_put
|
||||||
*/
|
*/
|
||||||
int
|
__be32
|
||||||
nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
|
nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
|
||||||
{
|
{
|
||||||
struct dentry *dentry;
|
struct dentry *dentry;
|
||||||
struct inode *inode;
|
struct inode *inode;
|
||||||
mm_segment_t oldfs;
|
mm_segment_t oldfs;
|
||||||
int err;
|
__be32 err;
|
||||||
|
int host_err;
|
||||||
|
|
||||||
err = fh_verify(rqstp, fhp, S_IFLNK, MAY_NOP);
|
err = fh_verify(rqstp, fhp, S_IFLNK, MAY_NOP);
|
||||||
if (err)
|
if (err)
|
||||||
@ -1403,18 +1412,18 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
oldfs = get_fs(); set_fs(KERNEL_DS);
|
oldfs = get_fs(); set_fs(KERNEL_DS);
|
||||||
err = inode->i_op->readlink(dentry, buf, *lenp);
|
host_err = inode->i_op->readlink(dentry, buf, *lenp);
|
||||||
set_fs(oldfs);
|
set_fs(oldfs);
|
||||||
|
|
||||||
if (err < 0)
|
if (host_err < 0)
|
||||||
goto out_nfserr;
|
goto out_nfserr;
|
||||||
*lenp = err;
|
*lenp = host_err;
|
||||||
err = 0;
|
err = 0;
|
||||||
out:
|
out:
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
out_nfserr:
|
out_nfserr:
|
||||||
err = nfserrno(err);
|
err = nfserrno(host_err);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1422,7 +1431,7 @@ out_nfserr:
|
|||||||
* Create a symlink and look up its inode
|
* Create a symlink and look up its inode
|
||||||
* N.B. After this call _both_ fhp and resfhp need an fh_put
|
* N.B. After this call _both_ fhp and resfhp need an fh_put
|
||||||
*/
|
*/
|
||||||
int
|
__be32
|
||||||
nfsd_symlink(struct svc_rqst *rqstp, struct svc_fh *fhp,
|
nfsd_symlink(struct svc_rqst *rqstp, struct svc_fh *fhp,
|
||||||
char *fname, int flen,
|
char *fname, int flen,
|
||||||
char *path, int plen,
|
char *path, int plen,
|
||||||
@ -1430,7 +1439,8 @@ nfsd_symlink(struct svc_rqst *rqstp, struct svc_fh *fhp,
|
|||||||
struct iattr *iap)
|
struct iattr *iap)
|
||||||
{
|
{
|
||||||
struct dentry *dentry, *dnew;
|
struct dentry *dentry, *dnew;
|
||||||
int err, cerr;
|
__be32 err, cerr;
|
||||||
|
int host_err;
|
||||||
umode_t mode;
|
umode_t mode;
|
||||||
|
|
||||||
err = nfserr_noent;
|
err = nfserr_noent;
|
||||||
@ -1446,7 +1456,7 @@ nfsd_symlink(struct svc_rqst *rqstp, struct svc_fh *fhp,
|
|||||||
fh_lock(fhp);
|
fh_lock(fhp);
|
||||||
dentry = fhp->fh_dentry;
|
dentry = fhp->fh_dentry;
|
||||||
dnew = lookup_one_len(fname, dentry, flen);
|
dnew = lookup_one_len(fname, dentry, flen);
|
||||||
err = PTR_ERR(dnew);
|
host_err = PTR_ERR(dnew);
|
||||||
if (IS_ERR(dnew))
|
if (IS_ERR(dnew))
|
||||||
goto out_nfserr;
|
goto out_nfserr;
|
||||||
|
|
||||||
@ -1458,21 +1468,21 @@ nfsd_symlink(struct svc_rqst *rqstp, struct svc_fh *fhp,
|
|||||||
if (unlikely(path[plen] != 0)) {
|
if (unlikely(path[plen] != 0)) {
|
||||||
char *path_alloced = kmalloc(plen+1, GFP_KERNEL);
|
char *path_alloced = kmalloc(plen+1, GFP_KERNEL);
|
||||||
if (path_alloced == NULL)
|
if (path_alloced == NULL)
|
||||||
err = -ENOMEM;
|
host_err = -ENOMEM;
|
||||||
else {
|
else {
|
||||||
strncpy(path_alloced, path, plen);
|
strncpy(path_alloced, path, plen);
|
||||||
path_alloced[plen] = 0;
|
path_alloced[plen] = 0;
|
||||||
err = vfs_symlink(dentry->d_inode, dnew, path_alloced, mode);
|
host_err = vfs_symlink(dentry->d_inode, dnew, path_alloced, mode);
|
||||||
kfree(path_alloced);
|
kfree(path_alloced);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
err = vfs_symlink(dentry->d_inode, dnew, path, mode);
|
host_err = vfs_symlink(dentry->d_inode, dnew, path, mode);
|
||||||
|
|
||||||
if (!err)
|
if (!host_err) {
|
||||||
if (EX_ISSYNC(fhp->fh_export))
|
if (EX_ISSYNC(fhp->fh_export))
|
||||||
err = nfsd_sync_dir(dentry);
|
host_err = nfsd_sync_dir(dentry);
|
||||||
if (err)
|
}
|
||||||
err = nfserrno(err);
|
err = nfserrno(host_err);
|
||||||
fh_unlock(fhp);
|
fh_unlock(fhp);
|
||||||
|
|
||||||
cerr = fh_compose(resfhp, fhp->fh_export, dnew, fhp);
|
cerr = fh_compose(resfhp, fhp->fh_export, dnew, fhp);
|
||||||
@ -1482,7 +1492,7 @@ out:
|
|||||||
return err;
|
return err;
|
||||||
|
|
||||||
out_nfserr:
|
out_nfserr:
|
||||||
err = nfserrno(err);
|
err = nfserrno(host_err);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1490,13 +1500,14 @@ out_nfserr:
|
|||||||
* Create a hardlink
|
* Create a hardlink
|
||||||
* N.B. After this call _both_ ffhp and tfhp need an fh_put
|
* N.B. After this call _both_ ffhp and tfhp need an fh_put
|
||||||
*/
|
*/
|
||||||
int
|
__be32
|
||||||
nfsd_link(struct svc_rqst *rqstp, struct svc_fh *ffhp,
|
nfsd_link(struct svc_rqst *rqstp, struct svc_fh *ffhp,
|
||||||
char *name, int len, struct svc_fh *tfhp)
|
char *name, int len, struct svc_fh *tfhp)
|
||||||
{
|
{
|
||||||
struct dentry *ddir, *dnew, *dold;
|
struct dentry *ddir, *dnew, *dold;
|
||||||
struct inode *dirp, *dest;
|
struct inode *dirp, *dest;
|
||||||
int err;
|
__be32 err;
|
||||||
|
int host_err;
|
||||||
|
|
||||||
err = fh_verify(rqstp, ffhp, S_IFDIR, MAY_CREATE);
|
err = fh_verify(rqstp, ffhp, S_IFDIR, MAY_CREATE);
|
||||||
if (err)
|
if (err)
|
||||||
@ -1517,24 +1528,25 @@ nfsd_link(struct svc_rqst *rqstp, struct svc_fh *ffhp,
|
|||||||
dirp = ddir->d_inode;
|
dirp = ddir->d_inode;
|
||||||
|
|
||||||
dnew = lookup_one_len(name, ddir, len);
|
dnew = lookup_one_len(name, ddir, len);
|
||||||
err = PTR_ERR(dnew);
|
host_err = PTR_ERR(dnew);
|
||||||
if (IS_ERR(dnew))
|
if (IS_ERR(dnew))
|
||||||
goto out_nfserr;
|
goto out_nfserr;
|
||||||
|
|
||||||
dold = tfhp->fh_dentry;
|
dold = tfhp->fh_dentry;
|
||||||
dest = dold->d_inode;
|
dest = dold->d_inode;
|
||||||
|
|
||||||
err = vfs_link(dold, dirp, dnew);
|
host_err = vfs_link(dold, dirp, dnew);
|
||||||
if (!err) {
|
if (!host_err) {
|
||||||
if (EX_ISSYNC(ffhp->fh_export)) {
|
if (EX_ISSYNC(ffhp->fh_export)) {
|
||||||
err = nfserrno(nfsd_sync_dir(ddir));
|
err = nfserrno(nfsd_sync_dir(ddir));
|
||||||
write_inode_now(dest, 1);
|
write_inode_now(dest, 1);
|
||||||
}
|
}
|
||||||
|
err = 0;
|
||||||
} else {
|
} else {
|
||||||
if (err == -EXDEV && rqstp->rq_vers == 2)
|
if (host_err == -EXDEV && rqstp->rq_vers == 2)
|
||||||
err = nfserr_acces;
|
err = nfserr_acces;
|
||||||
else
|
else
|
||||||
err = nfserrno(err);
|
err = nfserrno(host_err);
|
||||||
}
|
}
|
||||||
|
|
||||||
dput(dnew);
|
dput(dnew);
|
||||||
@ -1544,7 +1556,7 @@ out:
|
|||||||
return err;
|
return err;
|
||||||
|
|
||||||
out_nfserr:
|
out_nfserr:
|
||||||
err = nfserrno(err);
|
err = nfserrno(host_err);
|
||||||
goto out_unlock;
|
goto out_unlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1552,13 +1564,14 @@ out_nfserr:
|
|||||||
* Rename a file
|
* Rename a file
|
||||||
* N.B. After this call _both_ ffhp and tfhp need an fh_put
|
* N.B. After this call _both_ ffhp and tfhp need an fh_put
|
||||||
*/
|
*/
|
||||||
int
|
__be32
|
||||||
nfsd_rename(struct svc_rqst *rqstp, struct svc_fh *ffhp, char *fname, int flen,
|
nfsd_rename(struct svc_rqst *rqstp, struct svc_fh *ffhp, char *fname, int flen,
|
||||||
struct svc_fh *tfhp, char *tname, int tlen)
|
struct svc_fh *tfhp, char *tname, int tlen)
|
||||||
{
|
{
|
||||||
struct dentry *fdentry, *tdentry, *odentry, *ndentry, *trap;
|
struct dentry *fdentry, *tdentry, *odentry, *ndentry, *trap;
|
||||||
struct inode *fdir, *tdir;
|
struct inode *fdir, *tdir;
|
||||||
int err;
|
__be32 err;
|
||||||
|
int host_err;
|
||||||
|
|
||||||
err = fh_verify(rqstp, ffhp, S_IFDIR, MAY_REMOVE);
|
err = fh_verify(rqstp, ffhp, S_IFDIR, MAY_REMOVE);
|
||||||
if (err)
|
if (err)
|
||||||
@ -1589,22 +1602,22 @@ nfsd_rename(struct svc_rqst *rqstp, struct svc_fh *ffhp, char *fname, int flen,
|
|||||||
fill_pre_wcc(tfhp);
|
fill_pre_wcc(tfhp);
|
||||||
|
|
||||||
odentry = lookup_one_len(fname, fdentry, flen);
|
odentry = lookup_one_len(fname, fdentry, flen);
|
||||||
err = PTR_ERR(odentry);
|
host_err = PTR_ERR(odentry);
|
||||||
if (IS_ERR(odentry))
|
if (IS_ERR(odentry))
|
||||||
goto out_nfserr;
|
goto out_nfserr;
|
||||||
|
|
||||||
err = -ENOENT;
|
host_err = -ENOENT;
|
||||||
if (!odentry->d_inode)
|
if (!odentry->d_inode)
|
||||||
goto out_dput_old;
|
goto out_dput_old;
|
||||||
err = -EINVAL;
|
host_err = -EINVAL;
|
||||||
if (odentry == trap)
|
if (odentry == trap)
|
||||||
goto out_dput_old;
|
goto out_dput_old;
|
||||||
|
|
||||||
ndentry = lookup_one_len(tname, tdentry, tlen);
|
ndentry = lookup_one_len(tname, tdentry, tlen);
|
||||||
err = PTR_ERR(ndentry);
|
host_err = PTR_ERR(ndentry);
|
||||||
if (IS_ERR(ndentry))
|
if (IS_ERR(ndentry))
|
||||||
goto out_dput_old;
|
goto out_dput_old;
|
||||||
err = -ENOTEMPTY;
|
host_err = -ENOTEMPTY;
|
||||||
if (ndentry == trap)
|
if (ndentry == trap)
|
||||||
goto out_dput_new;
|
goto out_dput_new;
|
||||||
|
|
||||||
@ -1612,14 +1625,14 @@ nfsd_rename(struct svc_rqst *rqstp, struct svc_fh *ffhp, char *fname, int flen,
|
|||||||
if ((ffhp->fh_export->ex_flags & NFSEXP_MSNFS) &&
|
if ((ffhp->fh_export->ex_flags & NFSEXP_MSNFS) &&
|
||||||
((atomic_read(&odentry->d_count) > 1)
|
((atomic_read(&odentry->d_count) > 1)
|
||||||
|| (atomic_read(&ndentry->d_count) > 1))) {
|
|| (atomic_read(&ndentry->d_count) > 1))) {
|
||||||
err = -EPERM;
|
host_err = -EPERM;
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
err = vfs_rename(fdir, odentry, tdir, ndentry);
|
host_err = vfs_rename(fdir, odentry, tdir, ndentry);
|
||||||
if (!err && EX_ISSYNC(tfhp->fh_export)) {
|
if (!host_err && EX_ISSYNC(tfhp->fh_export)) {
|
||||||
err = nfsd_sync_dir(tdentry);
|
host_err = nfsd_sync_dir(tdentry);
|
||||||
if (!err)
|
if (!host_err)
|
||||||
err = nfsd_sync_dir(fdentry);
|
host_err = nfsd_sync_dir(fdentry);
|
||||||
}
|
}
|
||||||
|
|
||||||
out_dput_new:
|
out_dput_new:
|
||||||
@ -1627,8 +1640,7 @@ nfsd_rename(struct svc_rqst *rqstp, struct svc_fh *ffhp, char *fname, int flen,
|
|||||||
out_dput_old:
|
out_dput_old:
|
||||||
dput(odentry);
|
dput(odentry);
|
||||||
out_nfserr:
|
out_nfserr:
|
||||||
if (err)
|
err = nfserrno(host_err);
|
||||||
err = nfserrno(err);
|
|
||||||
|
|
||||||
/* we cannot reply on fh_unlock on the two filehandles,
|
/* we cannot reply on fh_unlock on the two filehandles,
|
||||||
* as that would do the wrong thing if the two directories
|
* as that would do the wrong thing if the two directories
|
||||||
@ -1647,13 +1659,14 @@ out:
|
|||||||
* Unlink a file or directory
|
* Unlink a file or directory
|
||||||
* N.B. After this call fhp needs an fh_put
|
* N.B. After this call fhp needs an fh_put
|
||||||
*/
|
*/
|
||||||
int
|
__be32
|
||||||
nfsd_unlink(struct svc_rqst *rqstp, struct svc_fh *fhp, int type,
|
nfsd_unlink(struct svc_rqst *rqstp, struct svc_fh *fhp, int type,
|
||||||
char *fname, int flen)
|
char *fname, int flen)
|
||||||
{
|
{
|
||||||
struct dentry *dentry, *rdentry;
|
struct dentry *dentry, *rdentry;
|
||||||
struct inode *dirp;
|
struct inode *dirp;
|
||||||
int err;
|
__be32 err;
|
||||||
|
int host_err;
|
||||||
|
|
||||||
err = nfserr_acces;
|
err = nfserr_acces;
|
||||||
if (!flen || isdotent(fname, flen))
|
if (!flen || isdotent(fname, flen))
|
||||||
@ -1667,7 +1680,7 @@ nfsd_unlink(struct svc_rqst *rqstp, struct svc_fh *fhp, int type,
|
|||||||
dirp = dentry->d_inode;
|
dirp = dentry->d_inode;
|
||||||
|
|
||||||
rdentry = lookup_one_len(fname, dentry, flen);
|
rdentry = lookup_one_len(fname, dentry, flen);
|
||||||
err = PTR_ERR(rdentry);
|
host_err = PTR_ERR(rdentry);
|
||||||
if (IS_ERR(rdentry))
|
if (IS_ERR(rdentry))
|
||||||
goto out_nfserr;
|
goto out_nfserr;
|
||||||
|
|
||||||
@ -1684,22 +1697,23 @@ nfsd_unlink(struct svc_rqst *rqstp, struct svc_fh *fhp, int type,
|
|||||||
#ifdef MSNFS
|
#ifdef MSNFS
|
||||||
if ((fhp->fh_export->ex_flags & NFSEXP_MSNFS) &&
|
if ((fhp->fh_export->ex_flags & NFSEXP_MSNFS) &&
|
||||||
(atomic_read(&rdentry->d_count) > 1)) {
|
(atomic_read(&rdentry->d_count) > 1)) {
|
||||||
err = -EPERM;
|
host_err = -EPERM;
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
err = vfs_unlink(dirp, rdentry);
|
host_err = vfs_unlink(dirp, rdentry);
|
||||||
} else { /* It's RMDIR */
|
} else { /* It's RMDIR */
|
||||||
err = vfs_rmdir(dirp, rdentry);
|
host_err = vfs_rmdir(dirp, rdentry);
|
||||||
}
|
}
|
||||||
|
|
||||||
dput(rdentry);
|
dput(rdentry);
|
||||||
|
|
||||||
if (err == 0 &&
|
if (host_err)
|
||||||
EX_ISSYNC(fhp->fh_export))
|
goto out_nfserr;
|
||||||
err = nfsd_sync_dir(dentry);
|
if (EX_ISSYNC(fhp->fh_export))
|
||||||
|
host_err = nfsd_sync_dir(dentry);
|
||||||
|
|
||||||
out_nfserr:
|
out_nfserr:
|
||||||
err = nfserrno(err);
|
err = nfserrno(host_err);
|
||||||
out:
|
out:
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@ -1708,11 +1722,12 @@ out:
|
|||||||
* Read entries from a directory.
|
* Read entries from a directory.
|
||||||
* The NFSv3/4 verifier we ignore for now.
|
* The NFSv3/4 verifier we ignore for now.
|
||||||
*/
|
*/
|
||||||
int
|
__be32
|
||||||
nfsd_readdir(struct svc_rqst *rqstp, struct svc_fh *fhp, loff_t *offsetp,
|
nfsd_readdir(struct svc_rqst *rqstp, struct svc_fh *fhp, loff_t *offsetp,
|
||||||
struct readdir_cd *cdp, encode_dent_fn func)
|
struct readdir_cd *cdp, encode_dent_fn func)
|
||||||
{
|
{
|
||||||
int err;
|
__be32 err;
|
||||||
|
int host_err;
|
||||||
struct file *file;
|
struct file *file;
|
||||||
loff_t offset = *offsetp;
|
loff_t offset = *offsetp;
|
||||||
|
|
||||||
@ -1734,10 +1749,10 @@ nfsd_readdir(struct svc_rqst *rqstp, struct svc_fh *fhp, loff_t *offsetp,
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
cdp->err = nfserr_eof; /* will be cleared on successful read */
|
cdp->err = nfserr_eof; /* will be cleared on successful read */
|
||||||
err = vfs_readdir(file, (filldir_t) func, cdp);
|
host_err = vfs_readdir(file, (filldir_t) func, cdp);
|
||||||
} while (err >=0 && cdp->err == nfs_ok);
|
} while (host_err >=0 && cdp->err == nfs_ok);
|
||||||
if (err)
|
if (host_err)
|
||||||
err = nfserrno(err);
|
err = nfserrno(host_err);
|
||||||
else
|
else
|
||||||
err = cdp->err;
|
err = cdp->err;
|
||||||
*offsetp = vfs_llseek(file, 0, 1);
|
*offsetp = vfs_llseek(file, 0, 1);
|
||||||
@ -1754,10 +1769,10 @@ out:
|
|||||||
* Get file system stats
|
* Get file system stats
|
||||||
* N.B. After this call fhp needs an fh_put
|
* N.B. After this call fhp needs an fh_put
|
||||||
*/
|
*/
|
||||||
int
|
__be32
|
||||||
nfsd_statfs(struct svc_rqst *rqstp, struct svc_fh *fhp, struct kstatfs *stat)
|
nfsd_statfs(struct svc_rqst *rqstp, struct svc_fh *fhp, struct kstatfs *stat)
|
||||||
{
|
{
|
||||||
int err = fh_verify(rqstp, fhp, 0, MAY_NOP);
|
__be32 err = fh_verify(rqstp, fhp, 0, MAY_NOP);
|
||||||
if (!err && vfs_statfs(fhp->fh_dentry,stat))
|
if (!err && vfs_statfs(fhp->fh_dentry,stat))
|
||||||
err = nfserr_io;
|
err = nfserr_io;
|
||||||
return err;
|
return err;
|
||||||
@ -1766,7 +1781,7 @@ nfsd_statfs(struct svc_rqst *rqstp, struct svc_fh *fhp, struct kstatfs *stat)
|
|||||||
/*
|
/*
|
||||||
* Check for a user's access permissions to this inode.
|
* Check for a user's access permissions to this inode.
|
||||||
*/
|
*/
|
||||||
int
|
__be32
|
||||||
nfsd_permission(struct svc_export *exp, struct dentry *dentry, int acc)
|
nfsd_permission(struct svc_export *exp, struct dentry *dentry, int acc)
|
||||||
{
|
{
|
||||||
struct inode *inode = dentry->d_inode;
|
struct inode *inode = dentry->d_inode;
|
||||||
|
@ -72,57 +72,57 @@ int nfsd_racache_init(int);
|
|||||||
void nfsd_racache_shutdown(void);
|
void nfsd_racache_shutdown(void);
|
||||||
int nfsd_cross_mnt(struct svc_rqst *rqstp, struct dentry **dpp,
|
int nfsd_cross_mnt(struct svc_rqst *rqstp, struct dentry **dpp,
|
||||||
struct svc_export **expp);
|
struct svc_export **expp);
|
||||||
int nfsd_lookup(struct svc_rqst *, struct svc_fh *,
|
__be32 nfsd_lookup(struct svc_rqst *, struct svc_fh *,
|
||||||
const char *, int, struct svc_fh *);
|
const char *, int, struct svc_fh *);
|
||||||
int nfsd_setattr(struct svc_rqst *, struct svc_fh *,
|
__be32 nfsd_setattr(struct svc_rqst *, struct svc_fh *,
|
||||||
struct iattr *, int, time_t);
|
struct iattr *, int, time_t);
|
||||||
#ifdef CONFIG_NFSD_V4
|
#ifdef CONFIG_NFSD_V4
|
||||||
int nfsd4_set_nfs4_acl(struct svc_rqst *, struct svc_fh *,
|
__be32 nfsd4_set_nfs4_acl(struct svc_rqst *, struct svc_fh *,
|
||||||
struct nfs4_acl *);
|
struct nfs4_acl *);
|
||||||
int nfsd4_get_nfs4_acl(struct svc_rqst *, struct dentry *, struct nfs4_acl **);
|
int nfsd4_get_nfs4_acl(struct svc_rqst *, struct dentry *, struct nfs4_acl **);
|
||||||
#endif /* CONFIG_NFSD_V4 */
|
#endif /* CONFIG_NFSD_V4 */
|
||||||
int nfsd_create(struct svc_rqst *, struct svc_fh *,
|
__be32 nfsd_create(struct svc_rqst *, struct svc_fh *,
|
||||||
char *name, int len, struct iattr *attrs,
|
char *name, int len, struct iattr *attrs,
|
||||||
int type, dev_t rdev, struct svc_fh *res);
|
int type, dev_t rdev, struct svc_fh *res);
|
||||||
#ifdef CONFIG_NFSD_V3
|
#ifdef CONFIG_NFSD_V3
|
||||||
int nfsd_access(struct svc_rqst *, struct svc_fh *, u32 *, u32 *);
|
__be32 nfsd_access(struct svc_rqst *, struct svc_fh *, u32 *, u32 *);
|
||||||
int nfsd_create_v3(struct svc_rqst *, struct svc_fh *,
|
__be32 nfsd_create_v3(struct svc_rqst *, struct svc_fh *,
|
||||||
char *name, int len, struct iattr *attrs,
|
char *name, int len, struct iattr *attrs,
|
||||||
struct svc_fh *res, int createmode,
|
struct svc_fh *res, int createmode,
|
||||||
u32 *verifier, int *truncp);
|
u32 *verifier, int *truncp);
|
||||||
int nfsd_commit(struct svc_rqst *, struct svc_fh *,
|
__be32 nfsd_commit(struct svc_rqst *, struct svc_fh *,
|
||||||
loff_t, unsigned long);
|
loff_t, unsigned long);
|
||||||
#endif /* CONFIG_NFSD_V3 */
|
#endif /* CONFIG_NFSD_V3 */
|
||||||
int nfsd_open(struct svc_rqst *, struct svc_fh *, int,
|
__be32 nfsd_open(struct svc_rqst *, struct svc_fh *, int,
|
||||||
int, struct file **);
|
int, struct file **);
|
||||||
void nfsd_close(struct file *);
|
void nfsd_close(struct file *);
|
||||||
int nfsd_read(struct svc_rqst *, struct svc_fh *, struct file *,
|
__be32 nfsd_read(struct svc_rqst *, struct svc_fh *, struct file *,
|
||||||
loff_t, struct kvec *, int, unsigned long *);
|
loff_t, struct kvec *, int, unsigned long *);
|
||||||
int nfsd_write(struct svc_rqst *, struct svc_fh *,struct file *,
|
__be32 nfsd_write(struct svc_rqst *, struct svc_fh *,struct file *,
|
||||||
loff_t, struct kvec *,int, unsigned long, int *);
|
loff_t, struct kvec *,int, unsigned long, int *);
|
||||||
int nfsd_readlink(struct svc_rqst *, struct svc_fh *,
|
__be32 nfsd_readlink(struct svc_rqst *, struct svc_fh *,
|
||||||
char *, int *);
|
char *, int *);
|
||||||
int nfsd_symlink(struct svc_rqst *, struct svc_fh *,
|
__be32 nfsd_symlink(struct svc_rqst *, struct svc_fh *,
|
||||||
char *name, int len, char *path, int plen,
|
char *name, int len, char *path, int plen,
|
||||||
struct svc_fh *res, struct iattr *);
|
struct svc_fh *res, struct iattr *);
|
||||||
int nfsd_link(struct svc_rqst *, struct svc_fh *,
|
__be32 nfsd_link(struct svc_rqst *, struct svc_fh *,
|
||||||
char *, int, struct svc_fh *);
|
char *, int, struct svc_fh *);
|
||||||
int nfsd_rename(struct svc_rqst *,
|
__be32 nfsd_rename(struct svc_rqst *,
|
||||||
struct svc_fh *, char *, int,
|
struct svc_fh *, char *, int,
|
||||||
struct svc_fh *, char *, int);
|
struct svc_fh *, char *, int);
|
||||||
int nfsd_remove(struct svc_rqst *,
|
__be32 nfsd_remove(struct svc_rqst *,
|
||||||
struct svc_fh *, char *, int);
|
struct svc_fh *, char *, int);
|
||||||
int nfsd_unlink(struct svc_rqst *, struct svc_fh *, int type,
|
__be32 nfsd_unlink(struct svc_rqst *, struct svc_fh *, int type,
|
||||||
char *name, int len);
|
char *name, int len);
|
||||||
int nfsd_truncate(struct svc_rqst *, struct svc_fh *,
|
int nfsd_truncate(struct svc_rqst *, struct svc_fh *,
|
||||||
unsigned long size);
|
unsigned long size);
|
||||||
int nfsd_readdir(struct svc_rqst *, struct svc_fh *,
|
__be32 nfsd_readdir(struct svc_rqst *, struct svc_fh *,
|
||||||
loff_t *, struct readdir_cd *, encode_dent_fn);
|
loff_t *, struct readdir_cd *, encode_dent_fn);
|
||||||
int nfsd_statfs(struct svc_rqst *, struct svc_fh *,
|
__be32 nfsd_statfs(struct svc_rqst *, struct svc_fh *,
|
||||||
struct kstatfs *);
|
struct kstatfs *);
|
||||||
|
|
||||||
int nfsd_notify_change(struct inode *, struct iattr *);
|
int nfsd_notify_change(struct inode *, struct iattr *);
|
||||||
int nfsd_permission(struct svc_export *, struct dentry *, int);
|
__be32 nfsd_permission(struct svc_export *, struct dentry *, int);
|
||||||
int nfsd_sync_dir(struct dentry *dp);
|
int nfsd_sync_dir(struct dentry *dp);
|
||||||
|
|
||||||
#if defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL)
|
#if defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL)
|
||||||
|
Loading…
Reference in New Issue
Block a user