Re: obtaining linux kernel command line from a module

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 21 May 2010, at 12:37 PM, Bernd Petrovitsch wrote:

> On Fre, 2010-05-21 at 12:18 +0200, Jason Nymble wrote:
>> On 21 May 2010, at 12:08 PM, Jason Nymble wrote:
>>> On 21 May 2010, at 12:07 PM, Jason Nymble wrote:
>>> 
>>>> Is there a way (e.g. exported variable or kernel API) for a kernel module to obtain the linux kernel command line? i.e. the contents as seen from userspace by 'cat /proc/cmdline'
>>> 
>>> I see linux/init.h has:
>>> extern char __initdata boot_command_line[];
>>> 
>>> Will try that...
>> 
>> Does not work, neither does saved_command_line, presumably because neither of them are exported (get "Unknown symbol in module" when loading the module)... linux/fs/proc/cmdline.c provides /proc/cmdline, and that just prints saved_command_line variable, but presumably it can use that variable since its not dynamically loaded kernel module.
>> 
>> Any bright ideas?
> 
> Why do you want to look at the kernel commandline in the first place?
> Module parameters come at module loading time.

I reserve some memory (using memmap param) on the linux kernel command line, and would like to not have to duplicate this parameter when loading the module (could be scripted by parsing /proc/cmdline of course, but would like to be able to just modprobe the module without requiring params or scripts).

Another alternative to snarfing the Linux cmdline params would be to somehow programmatically walk the memory map (the one printed out at the beginning of dmesg) and try to determine the reserved region in question (there are several others though too). I've been trying to figure out too how to walk this, if somebody knows the answer to that, it would be potentially even better than getting the cmd line.

> 
> Other than that the not-so-bright "idea": Send a patch to export
> saved_command_line (including a good reason to export it to modules) to
> LKML and see what people say to it.

My feeling is if it hasn't been exported now, after existing for many years, there is obviously no general need for it and such a patch will probably not be accepted.


--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux