1

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 SUSE11 in C? I am out of solution. Thank you

Flo
  • 11
  • 1

2 Answers2

1

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.

Zan Lynx
  • 53,022
  • 10
  • 79
  • 131
  • If you're lucky, you might even find that `/proc/cmdline` includes a string of the form `BOOT_IMAGE=/boot/vmlinuz-2.6.32-5-686` identifying the boot filename. – caf Jun 20 '11 at 07:53
0

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.