From: tangmeng <tangmeng@uniontech.com>
To: mcgrof@kernel.org, keescook@chromium.org, yzaikin@google.com
Cc: linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-fsdevel@vger.kernel.org, nizhen@uniontech.com,
zhanglianjie@uniontech.com, nixiaoming@huawei.com,
tangmeng <tangmeng@uniontech.com>
Subject: [PATCH 03/11] kernel/kmod: move modprobe sysctl to its own file
Date: Sun, 20 Feb 2022 14:00:29 +0800 [thread overview]
Message-ID: <20220220060029.13434-1-tangmeng@uniontech.com> (raw)
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 modprobe sysctl to its own file,
kernel/kmod.c.
Signed-off-by: tangmeng <tangmeng@uniontech.com>
---
include/linux/kmod.h | 3 ---
kernel/kmod.c | 23 ++++++++++++++++++++++-
kernel/sysctl.c | 7 -------
3 files changed, 22 insertions(+), 11 deletions(-)
diff --git a/include/linux/kmod.h b/include/linux/kmod.h
index 68f69362d427..9a07c3215389 100644
--- a/include/linux/kmod.h
+++ b/include/linux/kmod.h
@@ -14,10 +14,7 @@
#include <linux/workqueue.h>
#include <linux/sysctl.h>
-#define KMOD_PATH_LEN 256
-
#ifdef CONFIG_MODULES
-extern char modprobe_path[]; /* for sysctl */
/* modprobe exit status on success, -ve on error. Return value
* usually useless though. */
extern __printf(2, 3)
diff --git a/kernel/kmod.c b/kernel/kmod.c
index b717134ebe17..54df92abb8dd 100644
--- a/kernel/kmod.c
+++ b/kernel/kmod.c
@@ -55,10 +55,31 @@ static DECLARE_WAIT_QUEUE_HEAD(kmod_wq);
*/
#define MAX_KMOD_ALL_BUSY_TIMEOUT 5
+#define KMOD_PATH_LEN 256
/*
modprobe_path is set via /proc/sys.
*/
-char modprobe_path[KMOD_PATH_LEN] = CONFIG_MODPROBE_PATH;
+static char modprobe_path[KMOD_PATH_LEN] = CONFIG_MODPROBE_PATH;
+
+#ifdef CONFIG_SYSCTL
+static struct ctl_table kern_modprobe_table[] = {
+ {
+ .procname = "modprobe",
+ .data = &modprobe_path,
+ .maxlen = KMOD_PATH_LEN,
+ .mode = 0644,
+ .proc_handler = proc_dostring,
+ },
+ { }
+};
+
+static __init int kernel_modprobe_sysctls_init(void)
+{
+ register_sysctl_init("kernel", kern_modprobe_table);
+ return 0;
+}
+late_initcall(kernel_modprobe_sysctls_init);
+#endif /* CONFIG_SYSCTL */
static void free_modprobe_argv(struct subprocess_info *info)
{
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index b41138d64e5e..126d47e8224d 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -1791,13 +1791,6 @@ static struct ctl_table kern_table[] = {
},
#endif
#ifdef CONFIG_MODULES
- {
- .procname = "modprobe",
- .data = &modprobe_path,
- .maxlen = KMOD_PATH_LEN,
- .mode = 0644,
- .proc_handler = proc_dostring,
- },
{
.procname = "modules_disabled",
.data = &modules_disabled,
--
2.20.1
reply other threads:[~2022-02-20 6:01 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220220060029.13434-1-tangmeng@uniontech.com \
--to=tangmeng@uniontech.com \
--cc=keescook@chromium.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-modules@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=nixiaoming@huawei.com \
--cc=nizhen@uniontech.com \
--cc=yzaikin@google.com \
--cc=zhanglianjie@uniontech.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®