Operating System - HP-UX
1833322 Members
2901 Online
110051 Solutions
New Discussion

Re: how to tell which file is the kernel that is running

 
SOLVED
Go to solution
curt larson_1
Honored Contributor

Re: how to tell which file is the kernel that is running

bill a little further information.

as I stated previously, in this test I have 3 kernel files vmunix, vmunix.prev, and vm. When I said kmpath returned nothing i was booted with /stand/vm as the kernel.

kmpath does return the correct kernel file if the system is booted from vmunix or vmunix.prev.
curt larson_1
Honored Contributor

Re: how to tell which file is the kernel that is running

here is a short C program to return the boot_string from the running kernel.

1) being I'm not a C programmer, so I'll accept suggestions for improvements.

2)

a) how would i implement the ioctl statement if I had defined FILE *fp; instead of int fp; and used fopen and fclose. ie ioctl takes an int fildes.

b) how do you assign values using a pointer to a structure, ie how would you correctly do what I was trying to do in the comments.

3) my boot string is disk(8/0/19/0.6.0.0.0.0.0;0)/stand/vmunix. in C code how would i just get the "/stand/vmunix" portion.


#include
#include
#include
#include

int main(void){
struct mioc_rksym abc, *rks = &abc;
char buf[1024];
int fp;

if (( fp = open("/dev/kmem",O_RDONLY)) == NULL ) {
printf("kmem could not be opened\n);
exit(1);
}
abc.mirk_modname=NULL;
abc.mirk_sysname="boot_string";
abc.mirk_buf=buf;
abc.mirk_buflen=1023;
/*
rks->mirk_modename=NULL;
rks->mirk_sysname="boot_string";
rks->mirk_buf=buf;
rks->mirk_buflen=1023;
*/

if ( ioctl( fp, MIOC_READKSYM, *rks) != 0 ) {
perror("ioctl");
return -1;
}
printf("%s"\n",rks->mirk_buf);
if (close(fp) == EOF)
printf("kmem could not be closed\n");
}

to compile

cc file.c -o ofile