Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp3447650ybd; Fri, 28 Jun 2019 08:47:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqxMvkxFxOwkooPlD4qYJYDN7tpgt8+H+jAx970Ed2FFh4Qkl5Dzim4NvTapS70Y7S56JPPt X-Received: by 2002:a17:902:968c:: with SMTP id n12mr13035109plp.59.1561736868651; Fri, 28 Jun 2019 08:47:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561736868; cv=none; d=google.com; s=arc-20160816; b=k777XIomsu4MKccyz8C04vHmIH2y9a65o1XUVVvdmv9GZhZmS4Bk+FszkYGONZsacH +bnt6jT/OLeh0C5qkcJsnYryQFRkMoZHPRbVtKCRW0VIzH+Lxbh6JTgwKFSxjega+Cxr 6r0eGkfPACICtYbegcaeD2/aJrqZkjZKEbUea51YzuWBERD6s7pxENLaSmsmv+JK9sD2 a4Yrb59CVuokEXMW8ghHh9YLOdlRYyBx3VoBkNulp/ytzkQzmxhIe6lJiZGm7+9n5eik uOrZ0l5yq66RSBxamxIrtMcIUcVXrdohofG+kwN2mBfQynvWjW5mHCdRg9o1Rm1558Od hiSQ== 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=cYwNw5wB3IPB8tbDyY88jqwgiN+FV+z8ArUoz+jHHvA=; b=kIcsbR7zfKU2xS+2306jv/lNFDdNt0w578Gva/nHv9k/W4SJ0OQD2JrvC/cwa1IY3E Ms8kEWRG3OZV7yw4UENeI8dpEb35hVxOx6rcMZBensU3i95Hd/y2KPbVKx20DgcSLn2M HS16j9H3CGkTzkFa1UrXEcaA00dI6fmO7nrxJRn9o+0AUOrnC36SmxmpXbT0Fs9/i4MP NVtjjtg9bzrkU+H2Jq9lKIcRtH6K6gZCdgyB6UDNltWUcvEqWd63BZ6Z73ZyXtypu+AB JWYh0VPV8yoQFgjL96N90qt8gRhozl9GYxBVy8Fpkq1aed4nAXwvZ3Wsp3bl0wZiimAP PeGQ== 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 j10si2235128pgh.239.2019.06.28.08.47.32; Fri, 28 Jun 2019 08:47:48 -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 S1726913AbfF1Ppo (ORCPT + 99 others); Fri, 28 Jun 2019 11:45:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46420 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726716AbfF1Ppo (ORCPT ); Fri, 28 Jun 2019 11:45:44 -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 DB60B3092652; Fri, 28 Jun 2019 15:45:38 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-120-219.rdu2.redhat.com [10.10.120.219]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5DEAA5D704; Fri, 28 Jun 2019 15:45:36 +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 11/11] fsinfo: proc - add sb operation fsinfo() [ver #15] From: David Howells To: viro@zeniv.linux.org.uk Cc: dhowells@redhat.com, raven@themaw.net, mszeredi@redhat.com, christian@brauner.io, linux-api@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Date: Fri, 28 Jun 2019 16:45:35 +0100 Message-ID: <156173673559.14042.17529988400865163194.stgit@warthog.procyon.org.uk> In-Reply-To: <156173661696.14042.17822154531324224780.stgit@warthog.procyon.org.uk> References: <156173661696.14042.17822154531324224780.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.43]); Fri, 28 Jun 2019 15:45:43 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ian Kent The new fsinfo() system call adds a new super block operation ->fsinfo() which is used by file systems to provide file system specific information for fsinfo() requests. The fsinfo() request FSINFO_ATTR_PARAMETERS provides the same function as sb operation ->show_options() so it needs to be implemented by any file system that provides ->show_options() as a minimum. Also add a simple FSINFO_ATTR_CAPABILITIES implementation. Signed-off-by: Ian Kent Signed-off-by: David Howells --- fs/proc/inode.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/fs/proc/inode.c b/fs/proc/inode.c index 5f8d215b3fd0..28c287aff6aa 100644 --- a/fs/proc/inode.c +++ b/fs/proc/inode.c @@ -24,6 +24,7 @@ #include #include #include +#include #include @@ -115,6 +116,39 @@ static int proc_show_options(struct seq_file *seq, struct dentry *root) return 0; } +#ifdef CONFIG_FSINFO +/* + * Get filesystem information. + */ +static int proc_fsinfo(struct path *path, struct fsinfo_kparams *params) +{ + struct super_block *sb = path->dentry->d_sb; + struct pid_namespace *pid = sb->s_fs_info; + struct fsinfo_capabilities *caps; + + switch (params->request) { + case FSINFO_ATTR_CAPABILITIES: + caps = params->buffer; + fsinfo_set_cap(caps, FSINFO_CAP_IS_KERNEL_FS); + fsinfo_set_cap(caps, FSINFO_CAP_NOT_PERSISTENT); + return sizeof(*caps); + + case FSINFO_ATTR_PARAMETERS: + fsinfo_note_sb_params(params, sb->s_flags); + if (!gid_eq(pid->pid_gid, GLOBAL_ROOT_GID)) + fsinfo_note_paramf(params, "gid", "%u", + from_kgid_munged(&init_user_ns, pid->pid_gid)); + if (pid->hide_pid != HIDEPID_OFF) + fsinfo_note_paramf(params, "hidepid", + "%u", pid->hide_pid); + return params->usage; + + default: + return generic_fsinfo(path, params); + } +} +#endif /* CONFIG_FSINFO */ + const struct super_operations proc_sops = { .alloc_inode = proc_alloc_inode, .free_inode = proc_free_inode, @@ -122,6 +156,9 @@ const struct super_operations proc_sops = { .evict_inode = proc_evict_inode, .statfs = simple_statfs, .show_options = proc_show_options, +#ifdef CONFIG_FSINFO + .fsinfo = proc_fsinfo, +#endif }; enum {BIAS = -1U<<31};