From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Subject: [PATCH 37/38] vfs: Allow fsinfo() to query what's in an fs_context [ver #10] From: David Howells To: viro@zeniv.linux.org.uk Cc: torvalds@linux-foundation.org, dhowells@redhat.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Date: Fri, 27 Jul 2018 18:35:29 +0100 Message-ID: <153271292981.9458.14024775561160883433.stgit@warthog.procyon.org.uk> In-Reply-To: <153271267980.9458.7640156373438016898.stgit@warthog.procyon.org.uk> References: <153271267980.9458.7640156373438016898.stgit@warthog.procyon.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: Allow fsinfo() to be used to query the filesystem attached to an fs_context once a superblock has been created or if it comes from fspick(). This is done with something like: fd = fsopen("ext4", 0); ... fsconfig(fd, fsconfig_cmd_create, ...); fsinfo(fd, NULL, ...); Signed-off-by: David Howells --- fs/statfs.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/fs/statfs.c b/fs/statfs.c index caf0773957e9..480ac4be8c2a 100644 --- a/fs/statfs.c +++ b/fs/statfs.c @@ -669,13 +669,40 @@ static int vfs_fsinfo_path(int dfd, const char __user *filename, return ret; } +static int vfs_fsinfo_fscontext(struct fs_context *fc, + struct fsinfo_kparams *params) +{ + int ret; + + if (fc->ops == &legacy_fs_context_ops) + return -EOPNOTSUPP; + + ret = mutex_lock_interruptible(&fc->uapi_mutex); + if (ret < 0) + return ret; + + ret = -EIO; + if (fc->root) { + struct path path = { .dentry = fc->root }; + + ret = vfs_fsinfo(&path, params); + } + + mutex_unlock(&fc->uapi_mutex); + return ret; +} + static int vfs_fsinfo_fd(unsigned int fd, struct fsinfo_kparams *params) { struct fd f = fdget_raw(fd); int ret = -EBADF; if (f.file) { - ret = vfs_fsinfo(&f.file->f_path, params); + if (f.file->f_op == &fscontext_fops) + ret = vfs_fsinfo_fscontext(f.file->private_data, + params); + else + ret = vfs_fsinfo(&f.file->f_path, params); fdput(f); } return ret;