From patchwork Sat Sep 26 07:03:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11801157 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 D9477112C for ; Sat, 26 Sep 2020 07:04:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 879BA208B6 for ; Sat, 26 Sep 2020 07:04:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="BMDVGagk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728902AbgIZHEF (ORCPT ); Sat, 26 Sep 2020 03:04:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726210AbgIZHEE (ORCPT ); Sat, 26 Sep 2020 03:04:04 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E38C9C0613CE for ; Sat, 26 Sep 2020 00:04:03 -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=BMDVGagk6M89vtBF7dEk4FRyKc XpLSgw2TkgHzcgHUIa9lq5tyA8jX20FNJx7JBCvIUrubgYXL/atE4KhcmvitvHZnzwKb6RsGmD4hG 2quuDHpZkkzlNitoV3m1jcTbyqmM+dwCeyUc1TQeXPZ27JYkYKLD9zq33ZOS7vVY7p0rvfmW0PFMa kjgq1ghtYyDB22IaOJ8p2TnUqssPVr8sfjTql4WiIVu1k0HLG7PD3EO0wO0WflF1Yd+728ZgTYZUO 9RQQFCpZflhcrGUGpLGMf81YIy3LWaXcb2firDrMyFhY3dx2XYKTCREQdBLb1KtHrotGIQxhX8V1y E9kWRN4g==; Received: from [46.189.67.162] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kM4FW-0003vd-FM; Sat, 26 Sep 2020 07:04:02 +0000 From: Christoph Hellwig To: Al Viro Cc: linux-fsdevel@vger.kernel.org Subject: [PATCH 1/5] fs: remove vfs_statx_fd Date: Sat, 26 Sep 2020 09:03:57 +0200 Message-Id: <20200926070401.11816-2-hch@lst.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200926070401.11816-1-hch@lst.de> References: <20200926070401.11816-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 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 Sat Sep 26 07:03:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11801155 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 0991A112C for ; Sat, 26 Sep 2020 07:04:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D8CD9208B6 for ; Sat, 26 Sep 2020 07:04:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="EbaHj3X2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728871AbgIZHEF (ORCPT ); Sat, 26 Sep 2020 03:04:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728736AbgIZHEE (ORCPT ); Sat, 26 Sep 2020 03:04:04 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC3C1C0613D3 for ; Sat, 26 Sep 2020 00:04:04 -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=EbaHj3X2SJp3Hl1t/D3mItTxhP eEP+yyFCRjFUpQGDA/Sd6/zFz4w98b6SYNnYn5b8zX7I3xvVxHFdsOYPInJtRw0opZwdUFaodYx0h Fsc6hTCWfPtxDYdgMXHoBWLnQBaP7DipG64O04sQpkHV7pFf9FA7GrmzuGQYGmdaaooFhjFq4MEWM 1fm+GUSp8LZjG1OyrtqbnNY9uizzWPaX+IkQXXaRl9pj98wbtnjOEvoIw7ZJwDNKw6YLljn6SRMWu aqfJBtQXpcBkYNo7OFJjmAhXfFcZhNwRPJkEScMxyJXkBfCAz1YfqCL/JxeEVMA1874fof3Ojdj6S nRZy1S8A==; Received: from [46.189.67.162] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kM4FX-0003vi-8y; Sat, 26 Sep 2020 07:04:03 +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: Sat, 26 Sep 2020 09:03:58 +0200 Message-Id: <20200926070401.11816-3-hch@lst.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200926070401.11816-1-hch@lst.de> References: <20200926070401.11816-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 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 Sat Sep 26 07:03:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11801159 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 0F6026CA for ; Sat, 26 Sep 2020 07:04:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EA1EB2064B for ; Sat, 26 Sep 2020 07:04:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="Tzw0GNeU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728983AbgIZHEG (ORCPT ); Sat, 26 Sep 2020 03:04:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728974AbgIZHEF (ORCPT ); Sat, 26 Sep 2020 03:04:05 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B7FBC0613CE for ; Sat, 26 Sep 2020 00:04:05 -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=Tzw0GNeUxpjf4C2sVJlTlyj4hn 7Um1TnJueHQEt9/TZ/t6VDES1Ixsf4r7QPt7oR0DY9WD93ctmVLk+6K7POOuu7zMcx0QLiMb1mgOh ZYmBa8JGM78AICbnwYgGBxqMY3ZIOuZtI/SFpPR0XcoU3F69/Q6hTKbmxuvk5yQtFEHIA+1AX+Z4b IDxCBpLLmhmT75+/QfVUUFhNYPUL2Vke06u8Gmeg0WVowq/v/PC1Wx6Z3fsZMFKo5GnfL5FEwLOFl GzsZBTTPCqYdazo2rdaEbf9wPtAWiFWu8PEO07nyAcyn5eqKUvdAyNbJEXhpqpo6cPI0vvCtY5uj3 PFW8Vx5Q==; Received: from [46.189.67.162] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kM4FY-0003vn-2M; Sat, 26 Sep 2020 07:04:04 +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: Sat, 26 Sep 2020 09:03:59 +0200 Message-Id: <20200926070401.11816-4-hch@lst.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200926070401.11816-1-hch@lst.de> References: <20200926070401.11816-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 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 Sat Sep 26 07:04:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11801161 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 795B0112C for ; Sat, 26 Sep 2020 07:04:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5E3FE208B6 for ; Sat, 26 Sep 2020 07:04:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="P7Aoyeys" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729041AbgIZHEI (ORCPT ); Sat, 26 Sep 2020 03:04:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728991AbgIZHEG (ORCPT ); Sat, 26 Sep 2020 03:04:06 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 479D5C0613CE for ; Sat, 26 Sep 2020 00:04:06 -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=P7AoyeysmlTxqPL39jxRg4CS+A 1WYqsjKjCEUZ+QY7sJseqOZqZci0q+I6NboJp+sb8BHANZBCAIoTEona0ZL5vni51n14jD9Q+R52c NO50cKieo9FCmAE42x/O49mui+T18H8eAAM/vA+WKqvURlnVf43L/EsapIGZjWZuAZHmW64xSB/ts xoaRpX2TI97Ba6UahtHj7TFVi7cD/Y3sd8m//8L8X7eFMtERkxvHo1+VQ/DwQx3S5gmHxtLyaR3iB PQbP6SE6jVFqp4o5VRuIgi+vKAEauQ/oRtF+WrfVuFFnRXotye1lkkFCTrnwkB3N32kIEzkOkwA6S qZZFKXVA==; Received: from [46.189.67.162] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kM4FY-0003vt-Ri; Sat, 26 Sep 2020 07:04:05 +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: Sat, 26 Sep 2020 09:04:00 +0200 Message-Id: <20200926070401.11816-5-hch@lst.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200926070401.11816-1-hch@lst.de> References: <20200926070401.11816-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 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 Sat Sep 26 07:04:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11801163 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 1E2811580 for ; Sat, 26 Sep 2020 07:04:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 056EB208B6 for ; Sat, 26 Sep 2020 07:04:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="oMKLnmEL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729047AbgIZHEJ (ORCPT ); Sat, 26 Sep 2020 03:04:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729020AbgIZHEH (ORCPT ); Sat, 26 Sep 2020 03:04:07 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E205C0613D3 for ; Sat, 26 Sep 2020 00:04:07 -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=oMKLnmELB9VIuJQQdcol3XCtt8 jpKn2rrmlm4p47jh065193innZPsRLgTJhK8lE6E+SbwFICzsGnU47SrDetRcAl7pcKsEilL7i0lW vyfMaoRRHleTZ+xdA5YoHlVfl11lgYe+UxGLIo0nTC35FXXSInJPNq5NTJk+emJKXQf5+DZiJ5L7T OjT7Mhf5w3/TES/qYZ+XopHvcONpu+P9qCPWHkPOkYhQZvpD2uLexS3HUl7Pxrp6Sr9zslpwwHO1B qYKDgj5KQ63+9fLDb6+i0ty7BHQ6IKh2jSM7CuETx7aMqJUyVEaSAReZx4+FwNk55LB9bASXIzezY 4T0vB0aA==; Received: from [46.189.67.162] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kM4FZ-0003w3-Lg; Sat, 26 Sep 2020 07:04:05 +0000 From: Christoph Hellwig To: Al Viro Cc: linux-fsdevel@vger.kernel.org Subject: [PATCH 5/5] fs: remove KSTAT_QUERY_FLAGS Date: Sat, 26 Sep 2020 09:04:01 +0200 Message-Id: <20200926070401.11816-6-hch@lst.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200926070401.11816-1-hch@lst.de> References: <20200926070401.11816-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 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;