@@ -638,9 +638,7 @@ static char *ecryptfs_readlink_lower(struct dentry *dentry, size_t *bufsiz)
return ERR_PTR(-ENOMEM);
old_fs = get_fs();
set_fs(get_ds());
- rc = d_inode(lower_dentry)->i_op->readlink(lower_dentry,
- (char __user *)lower_buf,
- PATH_MAX);
+ rc = vfs_readlink(lower_dentry, (char __user *)lower_buf, PATH_MAX);
set_fs(old_fs);
if (rc < 0)
goto out;
@@ -3552,10 +3552,10 @@ nfsd4_encode_readlink(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd
if (!p)
return nfserr_resource;
/*
- * XXX: By default, the ->readlink() VFS op will truncate symlinks
- * if they would overflow the buffer. Is this kosher in NFSv4? If
- * not, one easy fix is: if ->readlink() precisely fills the buffer,
- * assume that truncation occurred, and return NFS4ERR_RESOURCE.
+ * XXX: By default, vfs_readlink() will truncate symlinks if they
+ * would overflow the buffer. Is this kosher in NFSv4? If not, one
+ * easy fix is: if vfs_readlink() precisely fills the buffer, assume
+ * that truncation occurred, and return NFS4ERR_RESOURCE.
*/
nfserr = nfsd_readlink(readlink->rl_rqstp, readlink->rl_fhp,
(char *)p, &maxcount);
@@ -1450,7 +1450,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
inode = d_inode(path.dentry);
err = nfserr_inval;
- if (!inode->i_op->readlink)
+ if (!inode->i_op->get_link)
goto out;
touch_atime(&path);
@@ -1459,7 +1459,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
*/
oldfs = get_fs(); set_fs(KERNEL_DS);
- host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
+ host_err = vfs_readlink(path.dentry, (char __user *)buf, *lenp);
set_fs(oldfs);
if (host_err < 0)
@@ -175,7 +175,7 @@ static char *ovl_read_symlink(struct dentry *realdentry)
mm_segment_t old_fs;
res = -EINVAL;
- if (!inode->i_op->readlink)
+ if (!inode->i_op->get_link)
goto err;
res = -ENOMEM;
@@ -186,8 +186,7 @@ static char *ovl_read_symlink(struct dentry *realdentry)
old_fs = get_fs();
set_fs(get_ds());
/* The cast to a user pointer is valid due to the set_fs() */
- res = inode->i_op->readlink(realdentry,
- (char __user *)buf, PAGE_SIZE - 1);
+ res = vfs_readlink(realdentry, (char __user *)buf, PAGE_SIZE - 1);
set_fs(old_fs);
if (res < 0) {
free_page((unsigned long) buf);
@@ -329,12 +329,11 @@ retry:
struct inode *inode = d_backing_inode(path.dentry);
error = empty ? -ENOENT : -EINVAL;
- if (inode->i_op->readlink) {
+ if (inode->i_op->get_link) {
error = security_inode_readlink(path.dentry);
if (!error) {
touch_atime(&path);
- error = inode->i_op->readlink(path.dentry,
- buf, bufsiz);
+ error = vfs_readlink(path.dentry, buf, bufsiz);
}
}
path_put(&path);
@@ -287,7 +287,7 @@ xfs_readlink_by_handle(
return PTR_ERR(dentry);
/* Restrict this handle operation to symlinks only. */
- if (!d_inode(dentry)->i_op->readlink) {
+ if (!d_inode(dentry)->i_op->get_link) {
error = -EINVAL;
goto out_dput;
}
@@ -297,7 +297,7 @@ xfs_readlink_by_handle(
goto out_dput;
}
- error = d_inode(dentry)->i_op->readlink(dentry, hreq->ohandle, olen);
+ error = vfs_readlink(dentry, hreq->ohandle, olen);
out_dput:
dput(dentry);
@@ -2919,6 +2919,12 @@ extern int vfs_lstat(const char __user *, struct kstat *);
extern int vfs_fstat(unsigned int, struct kstat *);
extern int vfs_fstatat(int , const char __user *, struct kstat *, int);
+static inline int vfs_readlink(struct dentry *dentry, char __user *buffer,
+ int buflen)
+{
+ return generic_readlink(dentry, buffer, buflen);
+}
+
extern int __generic_block_fiemap(struct inode *inode,
struct fiemap_extent_info *fieinfo,
loff_t start, loff_t len,
At this point all ->readlink instances are set to generic_readlink. So instead of calling i_op->readlink, we can call generic_readlink directly. Add an alias for generic_readlink(): vfs_readlink(). They are exactly the same but result in consistent naming. We can get rid of generic_readlink() after the next patch. Signed-off-by: Miklos Szeredi <mszeredi@redhat.com> --- fs/ecryptfs/inode.c | 4 +--- fs/nfsd/nfs4xdr.c | 8 ++++---- fs/nfsd/vfs.c | 4 ++-- fs/overlayfs/copy_up.c | 5 ++--- fs/stat.c | 5 ++--- fs/xfs/xfs_ioctl.c | 4 ++-- include/linux/fs.h | 6 ++++++ 7 files changed, 19 insertions(+), 17 deletions(-)