Reading VAX SID register on ultrix or 4.3bsd
Chris Torek
chris at mimsy.umd.edu
Sat Apr 23 15:32:44 AEST 1988
Make nlist a syscall? Not quite...!
The following might, however, be interesting: have a privileged program
dig out those `interesting numbers'---all the post-boot static ones,
anyway---and put them in a file, storing them at offsets derived from
the offset in /vmunix (or local equivalent).
Look Ma (Ma Bell? :-) ), a getdtablesize() C library function!:
int
read_saved_kernel_int(name)
char *name;
{
struct nlist nl[2];
int fd, rv;
nl[0].n_name = name;
nl[1].n_name = NULL;
if (nlist("/vmunix", nl)) /* something is wrong */
return (-1);
if ((fd = open("/etc/kdata", 0)) < 0)
return (-1);
(void) lseek(fd, (off_t)nl[0].n_value - (off_t)KERNBASE, L_SET);
if (read(fd, (char *)&rv, sizeof(rv)) != sizeof(rv))
rv = -1;
(void) close(fd);
return (rv);
}
int
getdtablesize()
{
return (_read_saved_kernel_int("_dtablesize"));
}
int
getcputype()
{
return (_read_saved_kernel_int("_cpu"));
}
/* ceteraque :-) */
Now all you have to do is write /etc/savekdata.
More information about the Comp.unix.wizards
mailing list