Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5175738ybi; Tue, 28 May 2019 08:45:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqyhy6BdpeVQiBbBI8y3vXPelYAfSN9WWktevHITTkIBggDZ3rTXkIvOT0y5q3yRVQ+As2Qa X-Received: by 2002:a65:42cd:: with SMTP id l13mr79486721pgp.72.1559058308171; Tue, 28 May 2019 08:45:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559058308; cv=none; d=google.com; s=arc-20160816; b=PBI9N/6Y5rnVz3mrY33pNHLxD/ZLtaGf6nWcFtn1LqOLuvYWE5OGrDJbca2pXk6eNM YaylLufpUP5ynl9OW/IQ++D/A0hM3Th2b9CdehH41pkDV+iSGhdhSg1vpiDEydmW1Nvr yuWDku9u7uARHO9smd0b29qqnhu3z5xAdoT2kWdLuboy7oQlXn00uCNJAXhak+4l2Ukf A5YtYDn1ZLpii6SC2uHbWVGJELYsmmTtOwHIcy0JGr9zyMPl2ChoovS53BWrBhWTjSTO gOG/Kd7lHGsNDuHbn8wC6Pvp/yWIZhIiY1f1ghD4aeOEWDITty9qglLlhFj/afUcyHxl 2Tig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:organization; bh=tXP9tZDhMGVzNef0E6wrRtmnpwJF7MEGypLGmRTjLyE=; b=YLbKNxwnYdEq6dS0Nwe8Zl4UFlQjeDixYymU8xj3P9Wb2CFnNPQlvHvenmegY3CQvt PMw0O8Gmhy+HgAml4K9DGsEdiG0kAywwQjegx/hW+1/HdQqbCu29NW9cIIRgBZpffF7I tR2EbP/EeXoZ4acVri1AhWJ37bAOAVDyUYlwZwPgcYcqMMwN5pGZdep8nXxlkUGl97Kk 0TYo9Oh+iTZgbmYyjUd/XbH9H+81EVFAnCAM4/hwje77oDo33mEvsOexO/VJbh+fhlbz Emz46gY9CCJptkMvNAXrarhsOBhLmS2XG6LkuBu300l4rL9db73rTnhCcaYZ+tUKfRcR 4WjA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q33si21248030pgm.287.2019.05.28.08.44.52; Tue, 28 May 2019 08:45:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727532AbfE1PLW (ORCPT + 99 others); Tue, 28 May 2019 11:11:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:1569 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726313AbfE1PLV (ORCPT ); Tue, 28 May 2019 11:11:21 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9AC2AC0AEE5C; Tue, 28 May 2019 15:11:21 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-125-65.rdu2.redhat.com [10.10.125.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id 25A415D772; Tue, 28 May 2019 15:11:19 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Subject: [PATCH 02/25] vfs: Allow fsinfo() to query what's in an fs_context [ver #13] From: David Howells To: viro@zeniv.linux.org.uk Cc: dhowells@redhat.com, raven@themaw.net, linux-api@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, mszeredi@redhat.com Date: Tue, 28 May 2019 16:11:19 +0100 Message-ID: <155905627927.1662.13276277442207649583.stgit@warthog.procyon.org.uk> In-Reply-To: <155905626142.1662.18430571708534506785.stgit@warthog.procyon.org.uk> References: <155905626142.1662.18430571708534506785.stgit@warthog.procyon.org.uk> User-Agent: StGit/unknown-version MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 28 May 2019 15:11:21 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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/fsinfo.c | 30 +++++++++++++++++++++++++++++- fs/statfs.c | 2 +- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/fs/fsinfo.c b/fs/fsinfo.c index f9a63410e9a2..14db881dd02d 100644 --- a/fs/fsinfo.c +++ b/fs/fsinfo.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include "internal.h" @@ -315,13 +316,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; diff --git a/fs/statfs.c b/fs/statfs.c index eea7af6f2f22..b9b63d9f4f24 100644 --- a/fs/statfs.c +++ b/fs/statfs.c @@ -86,7 +86,7 @@ int vfs_statfs(const struct path *path, struct kstatfs *buf) int error; error = statfs_by_dentry(path->dentry, buf); - if (!error) + if (!error && path->mnt) buf->f_flags = calculate_f_flags(path->mnt); return error; }