Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp2498347ybd; Mon, 24 Jun 2019 07:28:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqzF/J7rVUulK+sXWqecA3J0oUUFfYZimbVzh9J/gh/YsFAUPdlGP7JBY3b9nc197MYyT1T8 X-Received: by 2002:a17:902:74c7:: with SMTP id f7mr12743080plt.329.1561386498977; Mon, 24 Jun 2019 07:28:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561386498; cv=none; d=google.com; s=arc-20160816; b=0zQ3IM8B/wYu0Wq6eVzTJI/f+LkBTqSJ3cUgeB4bAZD3eEfwmq9RVqFBPSwmUSceEy 3Oxx44ajVXo+n2QR4rHTDIX18HuOwNcqg+iRzsfWudLJtBbTEYbhFzInr3ugrw2I9gOR 91MZthQXcqW8Q1Spmp9JXlO4h1qJDHUfPgPRG2oSETrauhKpXzgbnRFvsuAFXFnRwnCw xLAjDcSbuY7KmRY60Rycc0dAgOlEt/rrZxgFoaSode/fTCkK+ad4OiqmdCxvLgu7QK3w j7XWBA2vw9VLgh1euXwwArX/TazPNPVqdCFI7nYKzLMxiFcLpEsKdWAzERaO28YjZZ4n ZGOg== 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=ijAkuiSBWvbvDEKqaU/431qUJ6G5xhiSpWZ439eDnC8=; b=k7HZmxjinnDo1OxJ6wgKUrC+bbqGYIO+y4A4Kk6YDMW/Ux5vSz7ANCOWSaTlic37af UPz9AeW5pKdWMISNvEY/LHR43HoyoEl0YrXGj1fVZ9nMZxVHk9Fu21xNK2BvIvSYM0QS +7RdXjK/rz+kauTbELZZMbr3TBS7IiqsoKga7tXukL0k7kqc+ifMe+mtnmzxS8ycxHWX 6VfJ1bWVpPBPUVtbsipcjDyKbaVT8x5A1t1Bd+dFTPUk0TJSWJz6Tx8SrLNkXSKsBYAe SIjaAwl2E/huoY/Y2X9yLtKhIiyHbEQxge9ttbU1CCGyyCdzq9PolaUfrZ7130zBe5ac TVcw== 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 t2si9829534ply.133.2019.06.24.07.28.03; Mon, 24 Jun 2019 07:28:18 -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 S1727263AbfFXOL6 (ORCPT + 99 others); Mon, 24 Jun 2019 10:11:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54544 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726891AbfFXOL5 (ORCPT ); Mon, 24 Jun 2019 10:11:57 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E61696EB81; Mon, 24 Jun 2019 14:11:56 +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 96E3619C6A; Mon, 24 Jun 2019 14:11:55 +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 21/25] fsinfo: devpts - 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:54 +0100 Message-ID: <156138551486.25627.9996141646216300722.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.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 24 Jun 2019 14:11:57 +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/devpts/inode.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c index 3aa73a2ec2f1..6f0eb69f7cbb 100644 --- a/fs/devpts/inode.c +++ b/fs/devpts/inode.c @@ -28,6 +28,7 @@ #include #include #include +#include #define DEVPTS_DEFAULT_MODE 0600 /* @@ -401,9 +402,51 @@ static int devpts_show_options(struct seq_file *seq, struct dentry *root) return 0; } +#ifdef CONFIG_FSINFO +/* + * Get filesystem information. + */ +static int devpts_fsinfo(struct path *path, struct fsinfo_kparams *params) +{ + struct pts_fs_info *fsi = DEVPTS_SB(path->dentry->d_sb); + struct pts_mount_opts *opts = &fsi->mount_opts; + 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); + fsinfo_set_cap(caps, FSINFO_CAP_UIDS); + fsinfo_set_cap(caps, FSINFO_CAP_GIDS); + return sizeof(*caps); + + case FSINFO_ATTR_PARAMETERS: + fsinfo_note_sb_params(params, path->dentry->d_sb->s_flags); + if (opts->setuid) + fsinfo_note_paramf(params, "uid", "%u", + from_kuid_munged(&init_user_ns, opts->uid)); + if (opts->setgid) + fsinfo_note_paramf(params, "gid", "%u", + from_kgid_munged(&init_user_ns, opts->gid)); + fsinfo_note_paramf(params, "mode", "%03o", opts->mode); + fsinfo_note_paramf(params, "ptmxmode", "%03o", opts->ptmxmode); + if (opts->max < NR_UNIX98_PTY_MAX) + fsinfo_note_paramf(params, "max", "%d", opts->max); + return params->usage; + + default: + return generic_fsinfo(path, params); + } +} +#endif /* CONFIG_FSINFO */ + static const struct super_operations devpts_sops = { .statfs = simple_statfs, .show_options = devpts_show_options, +#ifdef CONFIG_FSINFO + .fsinfo = devpts_fsinfo, +#endif }; static int devpts_fill_super(struct super_block *s, struct fs_context *fc)