mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-06 10:57:46 +00:00
fs/9p: TREADLINK bugfix
Remove v9fs_vfs_readlink_dotl function and use generic_readlink. Update v9fs_vfs_follow_link_dotl function to accommodate this change Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com> Reported-by: Dr. David Alan Gilbert <linux@treblig.org> Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com> Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
This commit is contained in:
parent
219fd58be6
commit
31b6ceac49
1 changed files with 22 additions and 36 deletions
|
@ -755,30 +755,6 @@ v9fs_vfs_mknod_dotl(struct inode *dir, struct dentry *dentry, int omode,
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
v9fs_vfs_readlink_dotl(struct dentry *dentry, char *buffer, int buflen)
|
|
||||||
{
|
|
||||||
int retval;
|
|
||||||
struct p9_fid *fid;
|
|
||||||
char *target = NULL;
|
|
||||||
|
|
||||||
P9_DPRINTK(P9_DEBUG_VFS, " %s\n", dentry->d_name.name);
|
|
||||||
retval = -EPERM;
|
|
||||||
fid = v9fs_fid_lookup(dentry);
|
|
||||||
if (IS_ERR(fid))
|
|
||||||
return PTR_ERR(fid);
|
|
||||||
|
|
||||||
retval = p9_client_readlink(fid, &target);
|
|
||||||
if (retval < 0)
|
|
||||||
return retval;
|
|
||||||
|
|
||||||
strncpy(buffer, target, buflen);
|
|
||||||
P9_DPRINTK(P9_DEBUG_VFS, "%s -> %s\n", dentry->d_name.name, buffer);
|
|
||||||
|
|
||||||
retval = strnlen(buffer, buflen);
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* v9fs_vfs_follow_link_dotl - follow a symlink path
|
* v9fs_vfs_follow_link_dotl - follow a symlink path
|
||||||
* @dentry: dentry for symlink
|
* @dentry: dentry for symlink
|
||||||
|
@ -789,23 +765,33 @@ v9fs_vfs_readlink_dotl(struct dentry *dentry, char *buffer, int buflen)
|
||||||
static void *
|
static void *
|
||||||
v9fs_vfs_follow_link_dotl(struct dentry *dentry, struct nameidata *nd)
|
v9fs_vfs_follow_link_dotl(struct dentry *dentry, struct nameidata *nd)
|
||||||
{
|
{
|
||||||
int len = 0;
|
int retval;
|
||||||
|
struct p9_fid *fid;
|
||||||
char *link = __getname();
|
char *link = __getname();
|
||||||
|
char *target;
|
||||||
|
|
||||||
P9_DPRINTK(P9_DEBUG_VFS, "%s n", dentry->d_name.name);
|
P9_DPRINTK(P9_DEBUG_VFS, "%s\n", dentry->d_name.name);
|
||||||
|
|
||||||
if (!link)
|
if (!link) {
|
||||||
link = ERR_PTR(-ENOMEM);
|
link = ERR_PTR(-ENOMEM);
|
||||||
else {
|
goto ndset;
|
||||||
len = v9fs_vfs_readlink_dotl(dentry, link, PATH_MAX);
|
|
||||||
if (len < 0) {
|
|
||||||
__putname(link);
|
|
||||||
link = ERR_PTR(len);
|
|
||||||
} else
|
|
||||||
link[min(len, PATH_MAX-1)] = 0;
|
|
||||||
}
|
}
|
||||||
|
fid = v9fs_fid_lookup(dentry);
|
||||||
|
if (IS_ERR(fid)) {
|
||||||
|
__putname(link);
|
||||||
|
link = ERR_PTR(PTR_ERR(fid));
|
||||||
|
goto ndset;
|
||||||
|
}
|
||||||
|
retval = p9_client_readlink(fid, &target);
|
||||||
|
if (!retval) {
|
||||||
|
strcpy(link, target);
|
||||||
|
kfree(target);
|
||||||
|
goto ndset;
|
||||||
|
}
|
||||||
|
__putname(link);
|
||||||
|
link = ERR_PTR(retval);
|
||||||
|
ndset:
|
||||||
nd_set_link(nd, link);
|
nd_set_link(nd, link);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -839,7 +825,7 @@ const struct inode_operations v9fs_file_inode_operations_dotl = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const struct inode_operations v9fs_symlink_inode_operations_dotl = {
|
const struct inode_operations v9fs_symlink_inode_operations_dotl = {
|
||||||
.readlink = v9fs_vfs_readlink_dotl,
|
.readlink = generic_readlink,
|
||||||
.follow_link = v9fs_vfs_follow_link_dotl,
|
.follow_link = v9fs_vfs_follow_link_dotl,
|
||||||
.put_link = v9fs_vfs_put_link,
|
.put_link = v9fs_vfs_put_link,
|
||||||
.getattr = v9fs_vfs_getattr_dotl,
|
.getattr = v9fs_vfs_getattr_dotl,
|
||||||
|
|
Loading…
Reference in a new issue