Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp2497903ybd; Mon, 24 Jun 2019 07:27:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqz9KTi852LqKW0dO7fgH/GeabHDBi+ESpLfbgbmKpx1dO1C+tch0nJdfyd+eUSCFsrrzNxV X-Received: by 2002:a17:902:28e9:: with SMTP id f96mr99083708plb.114.1561386468224; Mon, 24 Jun 2019 07:27:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561386468; cv=none; d=google.com; s=arc-20160816; b=Da9ZpdDGY+3NXD16YU8qGwK6Z6KsXPGixYqNLpe6N0fJ+2d/Sw5mGDIZ5ybQcXB/wN yiOPXfrH5xM0BXSlk7wsfZN848K8ZxWYnohF23flVZG5E4sh1zHEIuR0K1HjlgVVPCn1 G4wcWxc1oV8FDIxLTD17utWL/XqxpqugKP+aolcYiZsfnXaXdh1Z5cv3obcAt9LpAf0O mw5CGfE/F0iNxoD648nnIuY7XV0PmZK+hVOwzfhEmausS6vhx24OZO0kiykJYuXUdbVa 7j1i1UGFu6chOsb2E8+iBtR02MfMDyVj1Qj9YP+OnVcAdMmPLA2OR66W7XohaDFm6A/P NESQ== 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=V1t1ZTNDIK8K4p9C0JuOqCczf5PEh4/YREiW53qMKh+EmqeT7yojj8Yaf7g4mcmaXi Jd/CeT5/mSE/OPLN6l+cjWJVtjJb8/b6BfUhLM5aoWNblAp83eunAFkOKep+YhCxgUvf MZHup0RvyFi7g+ZY2ZsNrQebjec+bs5umVs3aJIUzwvXbBsOsgLT/1Q7ssHCeo71lKFc VUpcfG6nA0QtoOcLIdTnbWkE9AvPklJB56pIEBpjNLCiY75k8XxcyRphssjOZJPbABum FoOOCg/K67gpdGcguIIwlqBMIG5ty8xaLqE26XXwIEPM0vZbsvsDIPdZ+QgxscGNGw6A 7yDA== 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 a25si11262774pfo.234.2019.06.24.07.27.32; Mon, 24 Jun 2019 07:27: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 S1730161AbfFXOLf (ORCPT + 99 others); Mon, 24 Jun 2019 10:11:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52678 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726690AbfFXOLf (ORCPT ); Mon, 24 Jun 2019 10:11:35 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F1D27882FB; Mon, 24 Jun 2019 14:11:34 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-120-57.rdu2.redhat.com [10.10.120.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id A1B7B60BF7; Mon, 24 Jun 2019 14:11:33 +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 18/25] fsinfo: proc - add sb operation fsinfo() [ver #14] From: David Howells To: viro@zeniv.linux.org.uk Cc: dhowells@redhat.com, raven@themaw.net, mszeredi@redhat.com, linux-api@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Date: Mon, 24 Jun 2019 15:11:32 +0100 Message-ID: <156138549291.25627.9442017015199997555.stgit@warthog.procyon.org.uk> In-Reply-To: <156138532485.25627.7459410522109581052.stgit@warthog.procyon.org.uk> References: <156138532485.25627.7459410522109581052.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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 24 Jun 2019 14:11:35 +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};