简体   繁体   中英

Programmatically read linux kernel parameters

I am modifying a Linux driver and I'd like to programmatically read the parameters passed to kernel... in other words, my driver should act in a different way if a specific parameter is passed to Linux kernel at boot...

How can I do that?

Have I to read them from /proc/cmdline and then program my logic? Or is there an API to be called for reading and parsing kernel parameters?

Use __setup() macro. See for example __setup("ip=", ip_auto_config_setup); in net/ipv4/ipconfig.c

Linux boot time command line is copied into a global variable called saved_command_line . It is defined in init/main.c.

Just read the variable in your module.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM