Skip to content

Commit d0d05f6

Browse files
committed
module: Move modprobe_path and modules_disabled ctl_tables into the module subsys
Move module sysctl (modprobe_path and modules_disabled) out of sysctl.c and into the modules subsystem. Make modules_disabled static as it no longer needs to be exported. Remove module.h from the includes in sysctl as it no longer uses any module exported variables. This is part of a greater effort to move ctl tables into their respective subsystems which will reduce the merge conflicts in kernel/sysctl.c. Reviewed-by: Luis Chamberlain <[email protected]> Reviewed-by: Petr Pavlu <[email protected]> Signed-off-by: Joel Granados <[email protected]>
1 parent 19272b3 commit d0d05f6

File tree

5 files changed

+32
-25
lines changed

5 files changed

+32
-25
lines changed

include/linux/kmod.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@
1414
#include <linux/workqueue.h>
1515
#include <linux/sysctl.h>
1616

17-
#define KMOD_PATH_LEN 256
18-
1917
#ifdef CONFIG_MODULES
20-
extern char modprobe_path[]; /* for sysctl */
2118
/* modprobe exit status on success, -ve on error. Return value
2219
* usually useless though. */
2320
extern __printf(2, 3)

include/linux/module.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,6 @@ struct notifier_block;
304304

305305
#ifdef CONFIG_MODULES
306306

307-
extern int modules_disabled; /* for sysctl */
308307
/* Get/put a kernel symbol (calls must be symmetric) */
309308
void *__symbol_get(const char *symbol);
310309
void *__symbol_get_gpl(const char *symbol);

kernel/module/internal.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ extern const struct kernel_symbol __stop___ksymtab_gpl[];
5858
extern const u32 __start___kcrctab[];
5959
extern const u32 __start___kcrctab_gpl[];
6060

61+
#define KMOD_PATH_LEN 256
62+
extern char modprobe_path[];
63+
6164
struct load_info {
6265
const char *name;
6366
/* pointer to module in temporary copy, freed at end of load_module() */

kernel/module/main.c

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,37 @@ static void mod_update_bounds(struct module *mod)
126126
}
127127

128128
/* Block module loading/unloading? */
129-
int modules_disabled;
129+
static int modules_disabled;
130130
core_param(nomodule, modules_disabled, bint, 0);
131131

132+
static const struct ctl_table module_sysctl_table[] = {
133+
{
134+
.procname = "modprobe",
135+
.data = &modprobe_path,
136+
.maxlen = KMOD_PATH_LEN,
137+
.mode = 0644,
138+
.proc_handler = proc_dostring,
139+
},
140+
{
141+
.procname = "modules_disabled",
142+
.data = &modules_disabled,
143+
.maxlen = sizeof(int),
144+
.mode = 0644,
145+
/* only handle a transition from default "0" to "1" */
146+
.proc_handler = proc_dointvec_minmax,
147+
.extra1 = SYSCTL_ONE,
148+
.extra2 = SYSCTL_ONE,
149+
},
150+
};
151+
152+
static int __init init_module_sysctl(void)
153+
{
154+
register_sysctl_init("kernel", module_sysctl_table);
155+
return 0;
156+
}
157+
158+
subsys_initcall(init_module_sysctl);
159+
132160
/* Waiting for a module to finish initializing? */
133161
static DECLARE_WAIT_QUEUE_HEAD(module_wq);
134162

kernel/sysctl.c

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
* Removed it and replaced it with older style, 03/23/00, Bill Wendling
2020
*/
2121

22-
#include <linux/module.h>
2322
#include <linux/sysctl.h>
2423
#include <linux/bitmap.h>
2524
#include <linux/printk.h>
@@ -1616,25 +1615,6 @@ static const struct ctl_table kern_table[] = {
16161615
.proc_handler = proc_dointvec,
16171616
},
16181617
#endif
1619-
#ifdef CONFIG_MODULES
1620-
{
1621-
.procname = "modprobe",
1622-
.data = &modprobe_path,
1623-
.maxlen = KMOD_PATH_LEN,
1624-
.mode = 0644,
1625-
.proc_handler = proc_dostring,
1626-
},
1627-
{
1628-
.procname = "modules_disabled",
1629-
.data = &modules_disabled,
1630-
.maxlen = sizeof(int),
1631-
.mode = 0644,
1632-
/* only handle a transition from default "0" to "1" */
1633-
.proc_handler = proc_dointvec_minmax,
1634-
.extra1 = SYSCTL_ONE,
1635-
.extra2 = SYSCTL_ONE,
1636-
},
1637-
#endif
16381618
#ifdef CONFIG_UEVENT_HELPER
16391619
{
16401620
.procname = "hotplug",

0 commit comments

Comments
 (0)