From patchwork Mon Sep 12 19:29:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 9327825 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B7CE760231 for ; Mon, 12 Sep 2016 19:30:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A7E8D28E9A for ; Mon, 12 Sep 2016 19:30:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9C6FA28E9B; Mon, 12 Sep 2016 19:30:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F0A128E6E for ; Mon, 12 Sep 2016 19:30:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932548AbcILT3n (ORCPT ); Mon, 12 Sep 2016 15:29:43 -0400 Received: from mail-wm0-f47.google.com ([74.125.82.47]:36177 "EHLO mail-wm0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932511AbcILT3j (ORCPT ); Mon, 12 Sep 2016 15:29:39 -0400 Received: by mail-wm0-f47.google.com with SMTP id b187so152082888wme.1 for ; Mon, 12 Sep 2016 12:29:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=hqYAI4weABa4TjGCWNB8kAxriYVKP8mpDN2+aJnbeoY=; b=m0SS+q/8KVndo12Oyqji2DAih7hwXvxrkNs5L3aJUWVQZpqow3i5JsZBBKvpcMRmE9 k5Qk3X1sFy+mC30l8qoIJ4kBJcUi4zKWW4f/WZ5HXR9/c4mvbd8hmZ3SkkHQbTeHjeoH cT4bMKOJ1ZgbVHOUa98JBBhqoFKBV4se+DgqicTK1vvenViaKER1VR6HmGx70Zzuu6aG i4xh3f/AehUHdAw27wiDD5l55baO9D9wYjIiab6oBy7kpHrhSpcBylgU5Ev8hNYrae/l 0SPGKR+Am2BAF21I5bzDS1b4CYl5V/6UHNtEKXVbf4+gX9a25sbE0tZ45DVc7eEcJCEb hUEw== X-Gm-Message-State: AE9vXwPirSstfNNqAAFIsd2+9J/2aq5dz9PDRQlOs367p5W9s1Gx6CYLZIDMYrLCPKC3Uvt7 X-Received: by 10.28.72.10 with SMTP id v10mr1480098wma.52.1473708577923; Mon, 12 Sep 2016 12:29:37 -0700 (PDT) Received: from veci.piliscsaba.szeredi.hu (pool-dsl-2c-0018.externet.hu. [217.173.44.24]) by smtp.gmail.com with ESMTPSA id f8sm19250418wjh.45.2016.09.12.12.29.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Sep 2016 12:29:37 -0700 (PDT) From: Miklos Szeredi To: linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Al Viro Subject: [PATCH 11/17] vfs: replace calling i_op->readlink with vfs_readlink() Date: Mon, 12 Sep 2016 21:29:13 +0200 Message-Id: <1473708559-12714-12-git-send-email-mszeredi@redhat.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1473708559-12714-1-git-send-email-mszeredi@redhat.com> References: <1473708559-12714-1-git-send-email-mszeredi@redhat.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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,