I am rehosting a program from tru64 to linux. I can't find a replacement for getsysinfo(GSI_BOOTEDFILE,...) in C man getsysinfo
How can I get the name of the file from which the currently running kernel was booted under S开发者_JS百科USE11 in C? I am out of solution. Thank you
There is /proc/version
and /proc/cmdline
which will tell you the version information of the running kernel and what options were passed to it on its command-line.
Between these two files you should be able to figure out which kernel is running, unless for some reason you have several kernel files of the same version lying about.
There's no general way of doing this, and it's not always possible -- for instance, if the machine is PXE booted, or if it's an embedded system, the kernel may not exist on disk at all. On an x86 system, you can make a guess by attempting to parse the lilo/grub config, but this won't give reliable results.
精彩评论