Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp1292313pxb; Fri, 18 Feb 2022 04:56:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJw3KPnrGSc59ifKWNfb4GO/X7GZQVD2bMRmY0VKjGNByhp5Hg68jE4CfdV6oNJketbVUDXa X-Received: by 2002:a17:90a:8c02:b0:1b8:ed69:c2a7 with SMTP id a2-20020a17090a8c0200b001b8ed69c2a7mr8295484pjo.137.1645188977059; Fri, 18 Feb 2022 04:56:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645188977; cv=none; d=google.com; s=arc-20160816; b=DxiTIhnh8LG93T6rH9w7DE6SDVRDNL2Wb7xg67Gn07RkD3f9cjRBrR8h6Hx8k8opSq Lajm+Z0lihxKtkYzCPHgxHVRQnV2UufbTuQ/Tc9yxic90gYH26zjsrob3ybKFOkuYdXJ Cw1IRRgMxvE6MzoyukjYHVAXn6hLW6agODevNhOJ2p+30dgKfDZab7lxUDrxL9MEsD1V jiOlwuYv7o28dySNo3gwTvE1fE71Kk22QYMmbt47QI7DXWyNfVbB5E8jvdacTtOlUJc/ t55gNQMHu0j5ROqgDGWVFeFvyWE3xIfe3WZ0imVHuroJL9HyfzpJxQZxb/vO8lTg8qbJ j7xQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from; bh=3KM5ryHpFby/5vvYzOPeBSlDkbuf04DMIVYacbW/YQg=; b=owRmVu7n5ePGhOgfVWHtiYwS+nYfE9ZRhsDUprUE0M5IXt8S6McWo2v3gMvWJODGHU KNaOG+Mfb0XGKViwcCC2zPaiYNtL3cCumd97eITpAf+A+vTJJ2jPUOe/yZ+BFX8GNSX/ zurf5OyJdVT7KsGwCz0rWj2Dbs/jcOfoTv4d3cdzNHLL6bh4OJdmIV4CtOtQcdPL2/QT vdyp31N+I34/OIbt2yerUEBeqLVXVABjSyv6PHVti5thXqvWdZGgIE6UgQAawr2bkug2 in91hHIavGKzotFDauq9bVH3cFQAn3kjvoxgKERXsMjmXe1pqI2FJq/Qa4dIyxRd/iy7 dwMA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pj4si3705908pjb.41.2022.02.18.04.56.03; Fri, 18 Feb 2022 04:56:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234243AbiBRLA1 (ORCPT + 99 others); Fri, 18 Feb 2022 06:00:27 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:52946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234228AbiBRLAV (ORCPT ); Fri, 18 Feb 2022 06:00:21 -0500 Received: from smtpproxy21.qq.com (smtpbg703.qq.com [203.205.195.89]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B68F1ED621 for ; Fri, 18 Feb 2022 03:00:05 -0800 (PST) X-QQ-mid: bizesmtp67t1645181999tkqrwa4u Received: from localhost.localdomain (unknown [58.240.82.166]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 18 Feb 2022 18:59:53 +0800 (CST) X-QQ-SSF: 01400000002000B0E000B00M0000000 X-QQ-FEAT: Lrjk7Ti9kjiycnf/HJB03UJzBsueqWUhUXioFSdAl8z5DeJyXcGEgbTEWkY8Z tlSY2FaakRoz9rxks4ej69Dr5xLalOMJjc9Cp/HothRGQOPZ9KH4sygP3ietuFRK9YQzkUE CfPvhl+SxQ7OZe7hSJlZSvwNJPIixEaAXB9kTW9mbACkWlU/TgM1iE6dBjCs3Lt+rMewEoD z1BeFW4mkjpb/rYmXknsPh6ncO0R6pL7+xY1opKDZvJuTKzgHCKEpJ+xBCT9UpbG9SaF+Kq IENOVLHeq9kM3OHPVDm6LEmGRkHpDwBj9xYxJnOIHVuQ9DMKRvdzz571Wv8Jhlt2f7X845l KJ1PRox6Qj2jQVeeMVLZA7L1PLIsFKcQfd9tDsDuqK/sc8ZgvI= X-QQ-GoodBg: 2 From: tangmeng To: mcgrof@kernel.org, keescook@chromium.org, yzaikin@google.com Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, tangmeng Subject: [PATCH 5/5] kernel/do_mount_initrd: move real_root_dev sysctls to its own file Date: Fri, 18 Feb 2022 18:59:49 +0800 Message-Id: <20220218105949.13125-1-tangmeng@uniontech.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:uniontech.com:qybgforeign:qybgforeign1 X-QQ-Bgrelay: 1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org kernel/sysctl.c is a kitchen sink where everyone leaves their dirty dishes, this makes it very difficult to maintain. To help with this maintenance let's start by moving sysctls to places where they actually belong. The proc sysctl maintainers do not want to know what sysctl knobs you wish to add for your own piece of code, we just care about the core logic. All filesystem syctls now get reviewed by fs folks. This commit follows the commit of fs, move the real_root_dev sysctl to its own file, kernel/do_mount_initrd.c. Signed-off-by: tangmeng --- include/linux/initrd.h | 2 -- init/do_mounts_initrd.c | 22 +++++++++++++++++++++- kernel/sysctl.c | 9 --------- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/include/linux/initrd.h b/include/linux/initrd.h index 1bbe9af48dc3..f1a1f4c92ded 100644 --- a/include/linux/initrd.h +++ b/include/linux/initrd.h @@ -29,8 +29,6 @@ static inline void wait_for_initramfs(void) {} extern phys_addr_t phys_initrd_start; extern unsigned long phys_initrd_size; -extern unsigned int real_root_dev; - extern char __initramfs_start[]; extern unsigned long __initramfs_size; diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c index 533d81ed74d4..327962ea354c 100644 --- a/init/do_mounts_initrd.c +++ b/init/do_mounts_initrd.c @@ -14,12 +14,32 @@ unsigned long initrd_start, initrd_end; int initrd_below_start_ok; -unsigned int real_root_dev; /* do_proc_dointvec cannot handle kdev_t */ +static unsigned int real_root_dev; /* do_proc_dointvec cannot handle kdev_t */ static int __initdata mount_initrd = 1; phys_addr_t phys_initrd_start __initdata; unsigned long phys_initrd_size __initdata; +#ifdef CONFIG_SYSCTL +static struct ctl_table kern_do_mounts_initrd_table[] = { + { + .procname = "real-root-dev", + .data = &real_root_dev, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = proc_dointvec, + }, + { } +}; + +static __init int kernel_do_mounts_initrd_sysctls_init(void) +{ + register_sysctl_init("kernel", kern_do_mounts_initrd_table); + return 0; +} +late_initcall(kernel_do_mounts_initrd_sysctls_init); +#endif /* CONFIG_SYSCTL */ + static int __init no_initrd(char *str) { mount_initrd = 0; diff --git a/kernel/sysctl.c b/kernel/sysctl.c index e448f43a8988..64d368d59a58 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -1699,15 +1699,6 @@ static struct ctl_table kern_table[] = { .mode = 0644, .proc_handler = sysctl_latencytop, }, -#endif -#ifdef CONFIG_BLK_DEV_INITRD - { - .procname = "real-root-dev", - .data = &real_root_dev, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = proc_dointvec, - }, #endif { .procname = "print-fatal-signals", -- 2.20.1