xfs: use ->readlink to implement the readlink_by_handle ioctl

Also drop the now unused readlink_copy export.

[dchinner: use d_inode(dentry) rather than dentry->d_inode]

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
This commit is contained in:
Christoph Hellwig 2016-04-06 07:50:54 +10:00 committed by Dave Chinner
parent 2b3d1d41b4
commit bfe8804d90
2 changed files with 2 additions and 17 deletions

View File

@ -4515,7 +4515,6 @@ int readlink_copy(char __user *buffer, int buflen, const char *link)
out: out:
return len; return len;
} }
EXPORT_SYMBOL(readlink_copy);
/* /*
* A helper for ->readlink(). This should be used *ONLY* for symlinks that * A helper for ->readlink(). This should be used *ONLY* for symlinks that

View File

@ -277,7 +277,6 @@ xfs_readlink_by_handle(
{ {
struct dentry *dentry; struct dentry *dentry;
__u32 olen; __u32 olen;
void *link;
int error; int error;
if (!capable(CAP_SYS_ADMIN)) if (!capable(CAP_SYS_ADMIN))
@ -288,7 +287,7 @@ xfs_readlink_by_handle(
return PTR_ERR(dentry); return PTR_ERR(dentry);
/* Restrict this handle operation to symlinks only. */ /* Restrict this handle operation to symlinks only. */
if (!d_is_symlink(dentry)) { if (!d_inode(dentry)->i_op->readlink) {
error = -EINVAL; error = -EINVAL;
goto out_dput; goto out_dput;
} }
@ -298,21 +297,8 @@ xfs_readlink_by_handle(
goto out_dput; goto out_dput;
} }
link = kmalloc(MAXPATHLEN+1, GFP_KERNEL); error = d_inode(dentry)->i_op->readlink(dentry, hreq->ohandle, olen);
if (!link) {
error = -ENOMEM;
goto out_dput;
}
error = xfs_readlink(XFS_I(d_inode(dentry)), link);
if (error)
goto out_kfree;
error = readlink_copy(hreq->ohandle, olen, link);
if (error)
goto out_kfree;
out_kfree:
kfree(link);
out_dput: out_dput:
dput(dentry); dput(dentry);
return error; return error;