Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp990701imm; Wed, 1 Aug 2018 08:27:45 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcA/ZJhRSsiB11EvroaarJ2tJMgoPLR6iVfgG9IXGd8hSPgPYxWwYcR3uD7BPEqQMJX4C2B X-Received: by 2002:a17:902:bf44:: with SMTP id u4-v6mr25366555pls.84.1533137265131; Wed, 01 Aug 2018 08:27:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533137265; cv=none; d=google.com; s=arc-20160816; b=cMzZe0p73ULs4uYXkfFt4ACiQHhnA40Me1IELNLD2kZZvdgabgIo8qi3TJa+l1wWrr OpuwOOdNpPFOYsgM0V2jml3k0keMJNEXAQyOhKJ9KQb8Hmnm2hVFzKwH2wum1Ff4fkzu 5WRTagk1WEnYZodusN8O1O8xzRLdv+Z69xGcNcw9ulYBum0SV2w3j+cYRircGgnRnz6d vPuN1kNBIP/4U7Nl88zwYHjPdyvQqUOcRmqDU5bIeoFZyQBBjpIRwpmsMwrO3C1wsNGk V92Kp8KdWPeEunuPsGrwIxbgNby0jW1UZbpQjuu4i6O9HQ483SFVMAd1CM8GQuafKuVR sl4A== 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=uVSjXct6xLbp5d5ghEt1SZzYjIFB9D0v5XDS1cF0p1M=; b=uvm8Q3vLn9SKUl1V65WUkB2gLsNRAJsno1gv4pfmv7658WIsGEh4E9Ou1WUMrB0i5e dvz72/aEfaOnRJSrnS49Zv2ohGnxspEZtXqQzVxcm9RNS7qELVxiNybS7kMtyFtpdn6E AaGfDLijO7jhM8ENHtj0PVMK0X4wjDp79AXAqvay3BCbnuOgvvUXIntx9PHJFqqDpy6u vLP0iXQzind3BYQXhBK0rnL01mrq/fLgPakRRu9dJncFhKMWOlPw+ACCnQrRAcpETFie PmbKKa/Ulu3HIvcDkiYILXHR10u7xEvjqBPLVUctttWahjaGTHXw7GPxaZcTMQHnefGb 788w== 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 32-v6si15675933pgy.672.2018.08.01.08.27.29; Wed, 01 Aug 2018 08:27:45 -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 S2390048AbeHARMK (ORCPT + 99 others); Wed, 1 Aug 2018 13:12:10 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:41074 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2389690AbeHARMK (ORCPT ); Wed, 1 Aug 2018 13:12:10 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4564B8197005; Wed, 1 Aug 2018 15:25:56 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-120-116.rdu2.redhat.com [10.10.120.116]) by smtp.corp.redhat.com (Postfix) with ESMTP id 84DC5200AC23; Wed, 1 Aug 2018 15:25: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 16/33] procfs: Move proc_fill_super() to fs/proc/root.c [ver #11] From: David Howells To: viro@zeniv.linux.org.uk Cc: torvalds@linux-foundation.org, dhowells@redhat.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Date: Wed, 01 Aug 2018 16:25:55 +0100 Message-ID: <153313715505.13253.3792274913380867450.stgit@warthog.procyon.org.uk> In-Reply-To: <153313703562.13253.5766498657900728120.stgit@warthog.procyon.org.uk> References: <153313703562.13253.5766498657900728120.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.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 01 Aug 2018 15:25:56 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 01 Aug 2018 15:25:56 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.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 faf401935fa9..c5e7bbf81e10 100644 --- a/fs/proc/inode.c +++ b/fs/proc/inode.c @@ -24,7 +24,6 @@ #include #include #include -#include #include @@ -122,7 +121,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, @@ -488,49 +487,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 841b4391deb6..bfe2bea2c71d 100644 --- a/fs/proc/internal.h +++ b/fs/proc/internal.h @@ -208,13 +208,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 *); /* @@ -272,7 +271,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 28fadb0c51ab..15da85cefd3f 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) {