Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2954172imm; Thu, 24 May 2018 19:49:07 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoPyZOB7rVva4LrfbYG8Vue70JmdVOY2rn5nuGlP88bicgYcOkhsyqmjWP68Yhl9cWo2NU2 X-Received: by 2002:a17:902:7406:: with SMTP id g6-v6mr638853pll.90.1527216547888; Thu, 24 May 2018 19:49:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527216547; cv=none; d=google.com; s=arc-20160816; b=rZDHTP6kVi7H4WpXEEE9NmKwXuyvAWK3+pmHqITJC0oq/wdWmY1vlNraK/EWMVI0Zl 6vHtqJ3nSjlZJqlFQ3QdTnRUgHb5V0pLz9NrKMBJCjHx0zbCVd5lqr7GtG7lasWIoEeX FaEUtPPWeoowE19pGMJJihip/UExBs82NZzLubdOJoa1LLHooZjM6AaKJpJm0NPkGqgN gDKHCl3UkbvBj+LFoHs6rjmvpoFOllMoUnAFqwYlT/ns0V8BZuCc7gzF/Md8AevCAqvN oA+XOXt/YrHTU07+ro85rZsvKK+UYzTVA4FeJtBjMsLquOH2b8b6KBZfVnZXDbhsxTth 9zdQ== 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:arc-authentication-results; bh=V7pJ6HZ4pvj2YI/FwC7j6LUKw/7rVvkSJRQb4K/G+9I=; b=ArZyZlUMEsuy2FSX3WMtHyAhzDfC90TkzJFIFfe8bMQ5rnd/tc47Of533XWFBUnb33 X4VAGi+PAiZw/0p9VAs3HpQrTmWCC59Shd5QTVri8YlslZBZKONCm4DZdPrynCVQADSI yE2i31/8xTfGyQQ8A4gTk5TZaJ6ROyGI81B7PChHB6w902g6cLsQVi+THWPHvXxNkz5o S0Dp8Xjvbai+EvEDNlYj+TNmpQgbECLTwUHB4dVfRV+B0kjbdrzuNxT4Unw/WhB/zCtJ anbREo1wOqlPmYPLtQoPTLoWt4WpacUjwh5MrA9NwCFTy1uSTfJbVOf3MHT/xvkzJKU0 GFNA== 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 n11-v6si11683375pgs.404.2018.05.24.19.48.53; Thu, 24 May 2018 19:49:07 -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 S1161320AbeEYAGx (ORCPT + 99 others); Thu, 24 May 2018 20:06:53 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:59592 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S971779AbeEYAGo (ORCPT ); Thu, 24 May 2018 20:06:44 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A16E4859A9; Fri, 25 May 2018 00:06:43 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-120-255.rdu2.redhat.com [10.10.120.255]) by smtp.corp.redhat.com (Postfix) with ESMTP id DD5C42026E0E; Fri, 25 May 2018 00:06:42 +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 12/32] procfs: Move proc_fill_super() to fs/proc/root.c [ver #8] From: David Howells To: viro@zeniv.linux.org.uk Cc: dhowells@redhat.com, linux-fsdevel@vger.kernel.org, linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org Date: Fri, 25 May 2018 01:06:42 +0100 Message-ID: <152720680239.9073.7908690414300658328.stgit@warthog.procyon.org.uk> In-Reply-To: <152720672288.9073.9868393448836301272.stgit@warthog.procyon.org.uk> References: <152720672288.9073.9868393448836301272.stgit@warthog.procyon.org.uk> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Fri, 25 May 2018 00:06:43 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Fri, 25 May 2018 00:06:43 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'dhowells@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Move proc_fill_super() to fs/proc/root.c as that's where the other superblock stuff is. Signed-off-by: David Howells --- fs/proc/inode.c | 49 +------------------------------------------------ fs/proc/internal.h | 4 +--- fs/proc/root.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 49 insertions(+), 52 deletions(-) diff --git a/fs/proc/inode.c b/fs/proc/inode.c index df65431c00be..0b13cf6eb6d7 100644 --- a/fs/proc/inode.c +++ b/fs/proc/inode.c @@ -24,7 +24,6 @@ #include #include #include -#include #include @@ -123,7 +122,7 @@ static int proc_show_options(struct seq_file *seq, struct dentry *root) return 0; } -static const struct super_operations proc_sops = { +const struct super_operations proc_sops = { .alloc_inode = proc_alloc_inode, .destroy_inode = proc_destroy_inode, .drop_inode = generic_delete_inode, @@ -489,49 +488,3 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de) pde_put(de); return inode; } - -int proc_fill_super(struct super_block *s, void *data, size_t data_size, - int silent) -{ - struct pid_namespace *ns = get_pid_ns(s->s_fs_info); - struct inode *root_inode; - int ret; - - if (!proc_parse_options(data, ns)) - return -EINVAL; - - /* User space would break if executables or devices appear on proc */ - s->s_iflags |= SB_I_USERNS_VISIBLE | SB_I_NOEXEC | SB_I_NODEV; - s->s_flags |= SB_NODIRATIME | SB_NOSUID | SB_NOEXEC; - s->s_blocksize = 1024; - s->s_blocksize_bits = 10; - s->s_magic = PROC_SUPER_MAGIC; - s->s_op = &proc_sops; - s->s_time_gran = 1; - - /* - * procfs isn't actually a stacking filesystem; however, there is - * too much magic going on inside it to permit stacking things on - * top of it - */ - s->s_stack_depth = FILESYSTEM_MAX_STACK_DEPTH; - - pde_get(&proc_root); - root_inode = proc_get_inode(s, &proc_root); - if (!root_inode) { - pr_err("proc_fill_super: get root inode failed\n"); - return -ENOMEM; - } - - s->s_root = d_make_root(root_inode); - if (!s->s_root) { - pr_err("proc_fill_super: allocate dentry failed\n"); - return -ENOMEM; - } - - ret = proc_setup_self(s); - if (ret) { - return ret; - } - return proc_setup_thread_self(s); -} diff --git a/fs/proc/internal.h b/fs/proc/internal.h index c0af86a18abe..c918ec4cc0d9 100644 --- a/fs/proc/internal.h +++ b/fs/proc/internal.h @@ -200,13 +200,12 @@ struct pde_opener { struct completion *c; } __randomize_layout; extern const struct inode_operations proc_link_inode_operations; - extern const struct inode_operations proc_pid_link_inode_operations; +extern const struct super_operations proc_sops; void proc_init_kmemcache(void); void set_proc_pid_nlink(void); extern struct inode *proc_get_inode(struct super_block *, struct proc_dir_entry *); -extern int proc_fill_super(struct super_block *, void *, size_t, int); extern void proc_entry_rundown(struct proc_dir_entry *); /* @@ -264,7 +263,6 @@ static inline void proc_tty_init(void) {} * root.c */ extern struct proc_dir_entry proc_root; -extern int proc_parse_options(char *options, struct pid_namespace *pid); extern void proc_self_init(void); extern int proc_remount(struct super_block *, int *, char *, size_t); diff --git a/fs/proc/root.c b/fs/proc/root.c index 99ce06c4e1a2..2fbc177f37a8 100644 --- a/fs/proc/root.c +++ b/fs/proc/root.c @@ -23,6 +23,7 @@ #include #include #include +#include #include "internal.h" @@ -36,7 +37,7 @@ static const match_table_t tokens = { {Opt_err, NULL}, }; -int proc_parse_options(char *options, struct pid_namespace *pid) +static int proc_parse_options(char *options, struct pid_namespace *pid) { char *p; substring_t args[MAX_OPT_ARGS]; @@ -78,6 +79,51 @@ int proc_parse_options(char *options, struct pid_namespace *pid) return 1; } +static int proc_fill_super(struct super_block *s, void *data, size_t data_size, int silent) +{ + struct pid_namespace *ns = get_pid_ns(s->s_fs_info); + struct inode *root_inode; + int ret; + + if (!proc_parse_options(data, ns)) + return -EINVAL; + + /* User space would break if executables or devices appear on proc */ + s->s_iflags |= SB_I_USERNS_VISIBLE | SB_I_NOEXEC | SB_I_NODEV; + s->s_flags |= SB_NODIRATIME | SB_NOSUID | SB_NOEXEC; + s->s_blocksize = 1024; + s->s_blocksize_bits = 10; + s->s_magic = PROC_SUPER_MAGIC; + s->s_op = &proc_sops; + s->s_time_gran = 1; + + /* + * procfs isn't actually a stacking filesystem; however, there is + * too much magic going on inside it to permit stacking things on + * top of it + */ + s->s_stack_depth = FILESYSTEM_MAX_STACK_DEPTH; + + pde_get(&proc_root); + root_inode = proc_get_inode(s, &proc_root); + if (!root_inode) { + pr_err("proc_fill_super: get root inode failed\n"); + return -ENOMEM; + } + + s->s_root = d_make_root(root_inode); + if (!s->s_root) { + pr_err("proc_fill_super: allocate dentry failed\n"); + return -ENOMEM; + } + + ret = proc_setup_self(s); + if (ret) { + return ret; + } + return proc_setup_thread_self(s); +} + int proc_remount(struct super_block *sb, int *flags, char *data, size_t data_size) {