From patchwork Thu Sep 10 06:42:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11766729 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A2732698 for ; Thu, 10 Sep 2020 06:52:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7A2B420882 for ; Thu, 10 Sep 2020 06:52:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="elVfkz/E" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727770AbgIJGwv (ORCPT ); Thu, 10 Sep 2020 02:52:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727775AbgIJGwd (ORCPT ); Thu, 10 Sep 2020 02:52:33 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF6CFC061756 for ; Wed, 9 Sep 2020 23:42:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=KxrkpxX4CHcXkhE7jRr1SghDc9sOD/Vra1dlxg39O8I=; b=elVfkz/EWJGcF6mYRMUQt+Dovd Cm048vrbGsUJcb/p9Hk2fxwmehhPgiBHN+BNPenk4JfUR+63nl7eMObR1ozLj3NNFyg+SnzM6bSHD /f+g3m3DzH84S9vCkm8a/bi4Qo05G3BGIFk5BrsdAuz/+QVAPRpow0OO9ufMCsdLp7Pa8aCI5ELhD dajeXI6x8qpGCSss23bjqWjwBUw3NFOeZhPm6/qsR5TPtudyExdDWcHvI5ZdjQQyHlk0Vtl/iwGcr B5C3Bu/e0niypkcL/YFfkz9h3McCcDwQNYPkDxYiH2PCpwCooRSHzB9dCw/hYlS7txIu+kPE4XTU3 sPa5RwoQ==; Received: from [2001:4bb8:184:af1:d8d0:3027:a666:4c4e] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kGGIB-0000Bn-1s; Thu, 10 Sep 2020 06:42:47 +0000 From: Christoph Hellwig To: Al Viro Cc: linux-fsdevel@vger.kernel.org Subject: [PATCH 1/5] fs: remove vfs_statx_fd Date: Thu, 10 Sep 2020 08:42:39 +0200 Message-Id: <20200910064244.346913-2-hch@lst.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200910064244.346913-1-hch@lst.de> References: <20200910064244.346913-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org vfs_statx_fd is only used to implement vfs_fstat. Remove vfs_statx_fd and just implement vfs_fstat directly. Signed-off-by: Christoph Hellwig --- fs/stat.c | 22 +++++++--------------- include/linux/fs.h | 7 +------ 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/fs/stat.c b/fs/stat.c index 44f8ad346db4ca..2683a051ce07fa 100644 --- a/fs/stat.c +++ b/fs/stat.c @@ -126,35 +126,27 @@ int vfs_getattr(const struct path *path, struct kstat *stat, EXPORT_SYMBOL(vfs_getattr); /** - * vfs_statx_fd - Get the enhanced basic attributes by file descriptor + * vfs_fstat - Get the basic attributes by file descriptor * @fd: The file descriptor referring to the file of interest * @stat: The result structure to fill in. - * @request_mask: STATX_xxx flags indicating what the caller wants - * @query_flags: Query mode (KSTAT_QUERY_FLAGS) * * This function is a wrapper around vfs_getattr(). The main difference is * that it uses a file descriptor to determine the file location. * * 0 will be returned on success, and a -ve error code if unsuccessful. */ -int vfs_statx_fd(unsigned int fd, struct kstat *stat, - u32 request_mask, unsigned int query_flags) +int vfs_fstat(int fd, struct kstat *stat) { struct fd f; - int error = -EBADF; - - if (query_flags & ~KSTAT_QUERY_FLAGS) - return -EINVAL; + int error; f = fdget_raw(fd); - if (f.file) { - error = vfs_getattr(&f.file->f_path, stat, - request_mask, query_flags); - fdput(f); - } + if (!f.file) + return -EBADF; + error = vfs_getattr(&f.file->f_path, stat, STATX_BASIC_STATS, 0); + fdput(f); return error; } -EXPORT_SYMBOL(vfs_statx_fd); static inline unsigned vfs_stat_set_lookup_flags(unsigned *lookup_flags, int flags) diff --git a/include/linux/fs.h b/include/linux/fs.h index 7519ae003a082c..bde55e637d5a12 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3166,7 +3166,7 @@ extern const struct inode_operations simple_symlink_inode_operations; extern int iterate_dir(struct file *, struct dir_context *); extern int vfs_statx(int, const char __user *, int, struct kstat *, u32); -extern int vfs_statx_fd(unsigned int, struct kstat *, u32, unsigned int); +int vfs_fstat(int fd, struct kstat *stat); static inline int vfs_stat(const char __user *filename, struct kstat *stat) { @@ -3184,11 +3184,6 @@ static inline int vfs_fstatat(int dfd, const char __user *filename, return vfs_statx(dfd, filename, flags | AT_NO_AUTOMOUNT, stat, STATX_BASIC_STATS); } -static inline int vfs_fstat(int fd, struct kstat *stat) -{ - return vfs_statx_fd(fd, stat, STATX_BASIC_STATS, 0); -} - extern const char *vfs_get_link(struct dentry *, struct delayed_call *); extern int vfs_readlink(struct dentry *, char __user *, int); From patchwork Thu Sep 10 06:42:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11766735 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 17378698 for ; Thu, 10 Sep 2020 06:53:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E010A2078E for ; Thu, 10 Sep 2020 06:53:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="JLsIF4Yp" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729785AbgIJGxB (ORCPT ); Thu, 10 Sep 2020 02:53:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726991AbgIJGwn (ORCPT ); Thu, 10 Sep 2020 02:52:43 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 131DBC061757 for ; Wed, 9 Sep 2020 23:42:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=JO41q0/wUWV3e29lw8/1jv5mxvs/Dutjv6L9E3A8Yh8=; b=JLsIF4YpzS/mOiMNlf/n0AYRsT A1CDw/ewffsqtdz546M/Huf1TjP7QTXG/pGJICOZ67UmJsMnLLdMwJb97EmkLDPZVq7FZVxigtuBQ JgTtkB9Cg6KK6Q1f0nJckMn/O7HWo2X6vFb+Kyos2G7h38A7+lYqbq7EvK1YyyR+JVLi5GrOoWz/Q lwe/BE84aUP0vkmhItYL2C9Lz1+8q5BcROBTgAhOicm6ZcrUd8YRLud8O6wtDC6fKrXMKY6BnzYJX mjjQNZGfxfN6eE7/z9M8YoosuMgy/trSMC4KFPmzEYUa06Gu6wj7WXvKsJn+jauJop0A/AotogJde 5AoAsUXg==; Received: from [2001:4bb8:184:af1:d8d0:3027:a666:4c4e] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kGGIC-0000Bv-7G; Thu, 10 Sep 2020 06:42:48 +0000 From: Christoph Hellwig To: Al Viro Cc: linux-fsdevel@vger.kernel.org Subject: [PATCH 2/5] fs: implement vfs_stat and vfs_lstat in terms of vfs_fstatat Date: Thu, 10 Sep 2020 08:42:40 +0200 Message-Id: <20200910064244.346913-3-hch@lst.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200910064244.346913-1-hch@lst.de> References: <20200910064244.346913-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Go through vfs_fstatat instead of duplicating the *stat to statx mapping three times. Signed-off-by: Christoph Hellwig --- include/linux/fs.h | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/include/linux/fs.h b/include/linux/fs.h index bde55e637d5a12..107f6a84ead8f7 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3168,21 +3168,19 @@ extern int iterate_dir(struct file *, struct dir_context *); extern int vfs_statx(int, const char __user *, int, struct kstat *, u32); int vfs_fstat(int fd, struct kstat *stat); -static inline int vfs_stat(const char __user *filename, struct kstat *stat) +static inline int vfs_fstatat(int dfd, const char __user *filename, + struct kstat *stat, int flags) { - return vfs_statx(AT_FDCWD, filename, AT_NO_AUTOMOUNT, + return vfs_statx(dfd, filename, flags | AT_NO_AUTOMOUNT, stat, STATX_BASIC_STATS); } -static inline int vfs_lstat(const char __user *name, struct kstat *stat) +static inline int vfs_stat(const char __user *filename, struct kstat *stat) { - return vfs_statx(AT_FDCWD, name, AT_SYMLINK_NOFOLLOW | AT_NO_AUTOMOUNT, - stat, STATX_BASIC_STATS); + return vfs_fstatat(AT_FDCWD, filename, stat, 0); } -static inline int vfs_fstatat(int dfd, const char __user *filename, - struct kstat *stat, int flags) +static inline int vfs_lstat(const char __user *name, struct kstat *stat) { - return vfs_statx(dfd, filename, flags | AT_NO_AUTOMOUNT, - stat, STATX_BASIC_STATS); + return vfs_fstatat(AT_FDCWD, name, stat, AT_SYMLINK_NOFOLLOW); } extern const char *vfs_get_link(struct dentry *, struct delayed_call *); From patchwork Thu Sep 10 06:42:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11766731 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 307D9698 for ; Thu, 10 Sep 2020 06:53:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0B2C220882 for ; Thu, 10 Sep 2020 06:53:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="WKmyz80t" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729779AbgIJGw4 (ORCPT ); Thu, 10 Sep 2020 02:52:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729717AbgIJGwd (ORCPT ); Thu, 10 Sep 2020 02:52:33 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0DF9C0613ED for ; Wed, 9 Sep 2020 23:42:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=5+cvC+Olnt2RYhxM/leFa/Y8/9TKxLp0Dqgd9JVP0q4=; b=WKmyz80t1EHbkiWmSYSYFKvYqs mdIoqiF5GEDIuZZbqtt86gHi0w4I11UznXEK6kxtZA4toF0Hn6HaWJ1BmobjAUyAXsCbxAfy7/2ON ZaDM9tQn6bBoGTVsirGV4pBtNt26ToCq+uFhxZ+Rel8qESnteTfJ0IXM6MdeI6BfiJPYha8zlDuQL HsHirYxpsVlRaKvRW7afj+crRC9YZoOHf0fD2JupZMzNMGT6H7Sz6MLBhixvELha2NN8tTot4HISF 0GIEKNjKrvBffmae0VLOJ4Dgo220O2IC9dvSdCf3vIT9qpNqJjFm478vjHnwxjHwGvAsdmdxswjcL 7/gwQSPg==; Received: from [2001:4bb8:184:af1:d8d0:3027:a666:4c4e] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kGGID-0000C9-Eg; Thu, 10 Sep 2020 06:42:50 +0000 From: Christoph Hellwig To: Al Viro Cc: linux-fsdevel@vger.kernel.org Subject: [PATCH 3/5] fs: move vfs_fstatat out of line Date: Thu, 10 Sep 2020 08:42:41 +0200 Message-Id: <20200910064244.346913-4-hch@lst.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200910064244.346913-1-hch@lst.de> References: <20200910064244.346913-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org This allows to keep vfs_statx static in fs/stat.c to prepare for the following changes. Signed-off-by: Christoph Hellwig --- fs/stat.c | 9 +++++++-- include/linux/fs.h | 9 ++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/fs/stat.c b/fs/stat.c index 2683a051ce07fa..ddf0176d4dbcd7 100644 --- a/fs/stat.c +++ b/fs/stat.c @@ -181,7 +181,7 @@ static inline unsigned vfs_stat_set_lookup_flags(unsigned *lookup_flags, * * 0 will be returned on success, and a -ve error code if unsuccessful. */ -int vfs_statx(int dfd, const char __user *filename, int flags, +static int vfs_statx(int dfd, const char __user *filename, int flags, struct kstat *stat, u32 request_mask) { struct path path; @@ -209,8 +209,13 @@ int vfs_statx(int dfd, const char __user *filename, int flags, out: return error; } -EXPORT_SYMBOL(vfs_statx); +int vfs_fstatat(int dfd, const char __user *filename, + struct kstat *stat, int flags) +{ + return vfs_statx(dfd, filename, flags | AT_NO_AUTOMOUNT, + stat, STATX_BASIC_STATS); +} #ifdef __ARCH_WANT_OLD_STAT diff --git a/include/linux/fs.h b/include/linux/fs.h index 107f6a84ead8f7..0678e9ca07b0ed 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3165,15 +3165,10 @@ extern const struct inode_operations simple_symlink_inode_operations; extern int iterate_dir(struct file *, struct dir_context *); -extern int vfs_statx(int, const char __user *, int, struct kstat *, u32); +int vfs_fstatat(int dfd, const char __user *filename, struct kstat *stat, + int flags); int vfs_fstat(int fd, struct kstat *stat); -static inline int vfs_fstatat(int dfd, const char __user *filename, - struct kstat *stat, int flags) -{ - return vfs_statx(dfd, filename, flags | AT_NO_AUTOMOUNT, - stat, STATX_BASIC_STATS); -} static inline int vfs_stat(const char __user *filename, struct kstat *stat) { return vfs_fstatat(AT_FDCWD, filename, stat, 0); From patchwork Thu Sep 10 06:42:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11766733 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D77DC59D for ; Thu, 10 Sep 2020 06:53:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AB5B320B1F for ; Thu, 10 Sep 2020 06:53:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="aoEtqlsS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729781AbgIJGxA (ORCPT ); Thu, 10 Sep 2020 02:53:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729719AbgIJGwd (ORCPT ); Thu, 10 Sep 2020 02:52:33 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFC25C061786 for ; Wed, 9 Sep 2020 23:42:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=G5DjZWIno3FaRn8f6l4VfdQbCAzY4Ys08lCIh0jKDVo=; b=aoEtqlsSsinCJplz6p3AAWTML+ olvdXsplSl6T6ry2+WLWxlsVt++jtmsqprzL6CgyaU3bLLNY0XCVfz1ZBtF+4f9qvS4VyDlGSy85Z kWFL9+kXjCwW7e7dkplR3IpM+5GOtqcoVH8zERjGR6Q6XTvFVBHmCOUX88YP7HJ361O09bRhdkhnq TjgO5XvvM5WfVe6zLhwEtKW3oFMWwX4/MPqDOLEgHVi1Rpt6byePK16YQ6gyK4b0NRATqvtPiOqw7 t1pMtDGUv668F+PEPSQjValLW84CxIZ/SO6hb922rnnUbvPkVW8eLUJPkqwlHC2ZEQiOjrgphhSIr 1MeB3njA==; Received: from [2001:4bb8:184:af1:d8d0:3027:a666:4c4e] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kGGIF-0000CL-Ck; Thu, 10 Sep 2020 06:42:51 +0000 From: Christoph Hellwig To: Al Viro Cc: linux-fsdevel@vger.kernel.org Subject: [PATCH 4/5] fs: remove vfs_stat_set_lookup_flags Date: Thu, 10 Sep 2020 08:42:42 +0200 Message-Id: <20200910064244.346913-5-hch@lst.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200910064244.346913-1-hch@lst.de> References: <20200910064244.346913-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org The function really obsfucates checking for valid flags and setting the lookup flags. The fact that it returns -EINVAL through and unsigned return value, which is then used as boolean really doesn't help either. Signed-off-by: Christoph Hellwig --- fs/stat.c | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/fs/stat.c b/fs/stat.c index ddf0176d4dbcd7..8acc4b14ac24c9 100644 --- a/fs/stat.c +++ b/fs/stat.c @@ -148,24 +148,6 @@ int vfs_fstat(int fd, struct kstat *stat) return error; } -static inline unsigned vfs_stat_set_lookup_flags(unsigned *lookup_flags, - int flags) -{ - if ((flags & ~(AT_SYMLINK_NOFOLLOW | AT_NO_AUTOMOUNT | - AT_EMPTY_PATH | KSTAT_QUERY_FLAGS)) != 0) - return -EINVAL; - - *lookup_flags = LOOKUP_FOLLOW | LOOKUP_AUTOMOUNT; - if (flags & AT_SYMLINK_NOFOLLOW) - *lookup_flags &= ~LOOKUP_FOLLOW; - if (flags & AT_NO_AUTOMOUNT) - *lookup_flags &= ~LOOKUP_AUTOMOUNT; - if (flags & AT_EMPTY_PATH) - *lookup_flags |= LOOKUP_EMPTY; - - return 0; -} - /** * vfs_statx - Get basic and extra attributes by filename * @dfd: A file descriptor representing the base dir for a relative filename @@ -185,11 +167,20 @@ static int vfs_statx(int dfd, const char __user *filename, int flags, struct kstat *stat, u32 request_mask) { struct path path; - int error = -EINVAL; - unsigned lookup_flags; + unsigned lookup_flags = 0; + int error; - if (vfs_stat_set_lookup_flags(&lookup_flags, flags)) + if (flags & ~(AT_SYMLINK_NOFOLLOW | AT_NO_AUTOMOUNT | AT_EMPTY_PATH | + KSTAT_QUERY_FLAGS)) return -EINVAL; + + if (!(flags & AT_SYMLINK_NOFOLLOW)) + lookup_flags |= LOOKUP_FOLLOW; + if (!(flags & AT_NO_AUTOMOUNT)) + lookup_flags |= LOOKUP_AUTOMOUNT; + if (flags & AT_EMPTY_PATH) + lookup_flags |= LOOKUP_EMPTY; + retry: error = user_path_at(dfd, filename, lookup_flags, &path); if (error) From patchwork Thu Sep 10 06:42:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11766727 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1AD93698 for ; Thu, 10 Sep 2020 06:52:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B190C20B1F for ; Thu, 10 Sep 2020 06:52:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="G/K1dJRP" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729741AbgIJGwp (ORCPT ); Thu, 10 Sep 2020 02:52:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726433AbgIJGwd (ORCPT ); Thu, 10 Sep 2020 02:52:33 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CC25C061795 for ; Wed, 9 Sep 2020 23:42:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=7DYbE5rSDH2SbBsr0roKEy5D4WXojJ2FblFU2zyIEL0=; b=G/K1dJRPaaTHB+bd13OzsuEiwh JWRJAchKVZx0et3rtRJTL4NOdpTe2r8hQGZ0YUaC+Q/kKI5PKaTFTBYAki57/rZch2Qu9zVBu2fZy /nZV3q6BXI4aaot6LXE/OrdDlAd3thDAseR1HjOn3Vph1T6omfTRBsZUsoA34lq0H19qlVqd3gcha no6UEVly6aeXL190wdkrGIRNiap5K3eGcZFXemwM+Hm9H+mu7efGxOCaNIgpcI2bcFiO7B5XdpRff hWDmbGyWFuOIZTPiUh8W9N0yTmgy1JNge/ePOlnWJzIGUWj/nkgSLGyKdjP/fRPSfJRBEAS7a+dKn N46yB1ow==; Received: from [2001:4bb8:184:af1:d8d0:3027:a666:4c4e] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kGGIG-0000CT-Ge; Thu, 10 Sep 2020 06:42:52 +0000 From: Christoph Hellwig To: Al Viro Cc: linux-fsdevel@vger.kernel.org Subject: [PATCH 5/5] fs: remove KSTAT_QUERY_FLAGS Date: Thu, 10 Sep 2020 08:42:43 +0200 Message-Id: <20200910064244.346913-6-hch@lst.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200910064244.346913-1-hch@lst.de> References: <20200910064244.346913-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org KSTAT_QUERY_FLAGS expands to AT_STATX_SYNC_TYPE, which itself already is a mask. Remove the double name, especially given that the prefix is a little confusing vs the normal AT_* flags. Signed-off-by: Christoph Hellwig --- fs/stat.c | 8 ++++---- include/linux/stat.h | 2 -- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/fs/stat.c b/fs/stat.c index 8acc4b14ac24c9..dacecdda2e7967 100644 --- a/fs/stat.c +++ b/fs/stat.c @@ -56,7 +56,7 @@ EXPORT_SYMBOL(generic_fillattr); * @path: file to get attributes from * @stat: structure to return attributes in * @request_mask: STATX_xxx flags indicating what the caller wants - * @query_flags: Query mode (KSTAT_QUERY_FLAGS) + * @query_flags: Query mode (AT_STATX_SYNC_TYPE) * * Get attributes without calling security_inode_getattr. * @@ -71,7 +71,7 @@ int vfs_getattr_nosec(const struct path *path, struct kstat *stat, memset(stat, 0, sizeof(*stat)); stat->result_mask |= STATX_BASIC_STATS; - query_flags &= KSTAT_QUERY_FLAGS; + query_flags &= AT_STATX_SYNC_TYPE; /* allow the fs to override these if it really wants to */ /* SB_NOATIME means filesystem supplies dummy atime value */ @@ -97,7 +97,7 @@ EXPORT_SYMBOL(vfs_getattr_nosec); * @path: The file of interest * @stat: Where to return the statistics * @request_mask: STATX_xxx flags indicating what the caller wants - * @query_flags: Query mode (KSTAT_QUERY_FLAGS) + * @query_flags: Query mode (AT_STATX_SYNC_TYPE) * * Ask the filesystem for a file's attributes. The caller must indicate in * request_mask and query_flags to indicate what they want. @@ -171,7 +171,7 @@ static int vfs_statx(int dfd, const char __user *filename, int flags, int error; if (flags & ~(AT_SYMLINK_NOFOLLOW | AT_NO_AUTOMOUNT | AT_EMPTY_PATH | - KSTAT_QUERY_FLAGS)) + AT_STATX_SYNC_TYPE)) return -EINVAL; if (!(flags & AT_SYMLINK_NOFOLLOW)) diff --git a/include/linux/stat.h b/include/linux/stat.h index 56614af83d4af5..fff27e60381412 100644 --- a/include/linux/stat.h +++ b/include/linux/stat.h @@ -19,8 +19,6 @@ #include #include -#define KSTAT_QUERY_FLAGS (AT_STATX_SYNC_TYPE) - struct kstat { u32 result_mask; /* What fields the user got */ umode_t mode;