Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I access the kernel command line from a Linux kernel module?

How can I obtain the kernel command line from a Linux kernel module?

This can be achieved by reading /proc/cmdline, but it seems like there must be an easier way to access the command line from a kernel module than to open and read a file.

like image 749
Billy Avatar asked Sep 25 '26 02:09

Billy


1 Answers

Do you actually need to access the enture kernel command line, or just a few parameters?
You could prefix each salient parameter with your module's name.

my_module.my_variable=value

Then your kernel module can retrieve it using the module_param() macro, as described in Passing Command Line Arguments to a Module

like image 122
sawdust Avatar answered Sep 28 '26 02:09

sawdust