From: Miklos Szeredi <mszeredi@redhat.com>
To: linux-fsdevel@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Al Viro <viro@zeniv.linux.org.uk>
Subject: [PATCH 11/17] vfs: replace calling i_op->readlink with vfs_readlink()
Date: Mon, 12 Sep 2016 21:29:13 +0200 [thread overview]
Message-ID: <1473708559-12714-12-git-send-email-mszeredi@redhat.com> (raw)
In-Reply-To: <1473708559-12714-1-git-send-email-mszeredi@redhat.com>
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(-)
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index 9d153b6a1d72..9885a8f88260 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -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;
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 0aa0236a1429..623268f32ee2 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -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);
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index ff476e654b8f..196620e1dc71 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -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)
diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c
index 43fdc2765aea..a2d4c10dd74d 100644
--- a/fs/overlayfs/copy_up.c
+++ b/fs/overlayfs/copy_up.c
@@ -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);
diff --git a/fs/stat.c b/fs/stat.c
index bc045c7994e1..a9bf2e8db854 100644
--- a/fs/stat.c
+++ b/fs/stat.c
@@ -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);
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index 96a70fd1f5d6..e8fdac738dc4 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -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);
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 5448a9b88c41..bcb0bc774cb6 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -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,
--
2.5.5
next prev parent reply other threads:[~2016-09-12 19:29 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-12 19:29 [PATCH 00/17] clean up readlinks Miklos Szeredi
2016-09-12 19:29 ` [PATCH 01/17] bad_inode: add missing i_op initializers Miklos Szeredi
2016-09-12 19:29 ` [PATCH 02/17] ovl: use generic_readlink Miklos Szeredi
2016-09-12 19:29 ` [PATCH 03/17] proc/self: " Miklos Szeredi
2016-09-12 19:29 ` [PATCH 04/17] afs: " Miklos Szeredi
2016-09-12 19:29 ` [PATCH 05/17] bad_inode: " Miklos Szeredi
2016-09-12 19:29 ` [PATCH 06/17] vfs: remove page_readlink() Miklos Szeredi
2016-09-12 19:29 ` [PATCH 07/17] vfs: add is_following_link() helper Miklos Szeredi
2016-09-12 19:29 ` [PATCH 08/17] proc: merge proc_pid_readlink() into proc_pid_get_link() Miklos Szeredi
2016-09-12 19:29 ` [PATCH 09/17] proc: merge proc_ns_readlink() into proc_ns_get_link() Miklos Szeredi
2016-09-12 19:29 ` [PATCH 10/17] nsfs: clean up ns_get_name() interface Miklos Szeredi
2016-09-12 19:29 ` Miklos Szeredi [this message]
2016-09-12 19:29 ` [PATCH 12/17] vfs: remove ".readlink = generic_readlink" assignments Miklos Szeredi
2016-09-12 19:29 ` [PATCH 13/17] vfs: remove unused i_op->readlink Miklos Szeredi
2016-09-12 19:29 ` [PATCH 14/17] vfs: remove unused generic_readlink() Miklos Szeredi
2016-09-12 19:29 ` [PATCH 15/17] vfs: add vfs_get_link() helper Miklos Szeredi
2016-09-12 19:29 ` [PATCH 16/17] ovl: use vfs_get_link() Miklos Szeredi
2016-09-12 19:29 ` [PATCH 17/17] ecryptfs: " Miklos Szeredi
2016-09-27 3:10 ` [PATCH 00/17] clean up readlinks Al Viro
2016-09-27 9:38 ` Miklos Szeredi
2016-09-28 2:17 ` Al Viro
2016-09-28 14:47 ` Miklos Szeredi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1473708559-12714-12-git-send-email-mszeredi@redhat.com \
--to=mszeredi@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).