From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Aneesh Kumar K.V" Subject: [PATCH -V6 4/8] vfs: Add freadlink syscall Date: Tue, 27 Apr 2010 21:43:46 +0530 Message-ID: <1272384830-22670-5-git-send-email-aneesh.kumar@linux.vnet.ibm.com> References: <1272384830-22670-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com> Cc: linux-fsdevel@vger.kernel.org, sfrench@us.ibm.com, "Aneesh Kumar K.V" To: hch@infradead.org, viro@zeniv.linux.org.uk, adilger@sun.com, corbet@lwn.net, serue@us.ibm.com, neilb@suse.de Return-path: Received: from e28smtp08.in.ibm.com ([122.248.162.8]:59341 "EHLO e28smtp08.in.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755627Ab0D0QOC (ORCPT ); Tue, 27 Apr 2010 12:14:02 -0400 Received: from d28relay05.in.ibm.com (d28relay05.in.ibm.com [9.184.220.62]) by e28smtp08.in.ibm.com (8.14.3/8.13.1) with ESMTP id o3RFHE3e024471 for ; Tue, 27 Apr 2010 20:47:14 +0530 Received: from d28av05.in.ibm.com (d28av05.in.ibm.com [9.184.220.67]) by d28relay05.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o3RGE0JS2363506 for ; Tue, 27 Apr 2010 21:44:00 +0530 Received: from d28av05.in.ibm.com (loopback [127.0.0.1]) by d28av05.in.ibm.com (8.14.3/8.13.1/NCO v10.0 AVout) with ESMTP id o3RGDxuc005205 for ; Wed, 28 Apr 2010 02:14:00 +1000 In-Reply-To: <1272384830-22670-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: This enables to use open-by-handle and then get the link target details of a symlink using the fd returned by handle Signed-off-by: Aneesh Kumar K.V --- fs/stat.c | 27 +++++++++++++++++++++++++++ 1 files changed, 27 insertions(+), 0 deletions(-) diff --git a/fs/stat.c b/fs/stat.c index c4ecd52..0fbab00 100644 --- a/fs/stat.c +++ b/fs/stat.c @@ -314,6 +314,33 @@ SYSCALL_DEFINE3(readlink, const char __user *, path, char __user *, buf, return sys_readlinkat(AT_FDCWD, path, buf, bufsiz); } +SYSCALL_DEFINE3(freadlink, int, fd, char __user *, buf, + int, bufsiz) +{ + int fput_needed; + struct file *file; + int error = -EBADF; + struct inode *inode; + + file = fget_light(fd, &fput_needed); + if (!file) + return error; + + inode = file->f_path.dentry->d_inode; + error = -EINVAL; + if (inode->i_op->readlink) { + error = security_inode_readlink(file->f_path.dentry); + if (!error) { + touch_atime(file->f_path.mnt, file->f_path.dentry); + error = inode->i_op->readlink(file->f_path.dentry, + buf, bufsiz); + } + } + fput_light(file, fput_needed); + return error; +} + + /* ---------- LFS-64 ----------- */ #ifdef __ARCH_WANT_STAT64 -- 1.7.0.4.360.g11766c