1 // 从cmdline 提取 rootfsname= 的值到 val_buf
2 char val_buf[64];
3 #define ROOTFS_CMDLINE "rootfsname="
4
5 static void __init gluebi_read_cmdline (void)
6 {
7 rootfsmtd_ptr = strstr(saved_command_line, ROOTFS_CMDLINE);
8 if (rootfsmtd_ptr) {
9 sscanf(rootfsmtd_ptr, ROOTFS_CMDLINE"%s", val_buf);
10 printk("Gluebi: Found kernel commandline option 'rootfsname=%s'\n", val_buf);
11 }
12 }
1 // drivers/acpi/sysfs.c
2 static int param_get_trace_state(char *buffer, struct kernel_param *kp)
3 {
4 if (!acpi_gbl_trace_method_name)
5 return sprintf(buffer, "disable");
6 else {
7 if (acpi_gbl_trace_flags & 1)
8 return sprintf(buffer, "1");
9 else
10 return sprintf(buffer, "enable");
11 }
12 return 0;
13 }
14 static int param_set_trace_state(const char *val, struct kernel_param *kp)
15 {
16 int result = 0;
17
18 if (!strncmp(val, "enable", sizeof("enable") - 1)) {
19 result = acpi_debug_trace(trace_method_name, trace_debug_level,
20 trace_debug_layer, 0);
21 if (result)
22 result = -EBUSY;
23 goto exit;
24 }
25
26 if (!strncmp(val, "disable", sizeof("disable") - 1)) {
27 int name = 0;
28 result = acpi_debug_trace((char *)&name, trace_debug_level,
29 trace_debug_layer, 0);
30 if (result)
31 result = -EBUSY;
32 goto exit;
33 }
34
35 if (!strncmp(val, "1", 1)) {
36 result = acpi_debug_trace(trace_method_name, trace_debug_level,
37 trace_debug_layer, 1);
38 if (result)
39 result = -EBUSY;
40 goto exit;
41 }
42
43 result = -EINVAL;
44 exit:
45 return result;
46 }
47
48 // 设置 从cmdline 分析到 trace_state 参数 调用param_set_trace_state, 将值传给 buffer
49 module_param_call(trace_state, param_set_trace_state, NULL, NULL, 0);
1 // init/main.c
2
3 static int __init set_reset_devices(char *str)
4 {
5 reset_devices = 1;
6 return 1;
7 }
8
9 __setup("reset_devices", set_reset_devices);