|
|
1.1 ! root 1: /* ! 2: * get_kernel_vals(). This is code borrowed from Hal's asypatch command. ! 3: * This code will get the following values from the kernel: ! 4: * NSHMID: max number of allowable shared memory segments ! 5: * SEMMNI: max number of allowable semaphores ! 6: * NMSQID: max number of allowable message queues ! 7: * ! 8: * The name of the symbol and kernel file are passed from the calling ! 9: * function. ! 10: */ ! 11: ! 12: #include <stdio.h> ! 13: #include <coff.h> ! 14: #include <fcntl.h> ! 15: ! 16: get_krnl_vals(symbl, fname) ! 17: char *symbl, *fname; ! 18: { ! 19: ! 20: static SYMENT se; ! 21: int data; /* buffer */ ! 22: int ret; /* return status of coffpatch */ ! 23: ! 24: se._n._n_n._n_zeroes = 0; /* stuff for coffnlist */ ! 25: se._n._n_n._n_offset = sizeof(long); ! 26: se.n_type = -1; ! 27: ! 28: ret = coffnlist(fname, &se, symbl, 1); /* fill SYMENT struct */ ! 29: ! 30: /* get values from kernel for requested symbol. Abort on failure */ ! 31: ! 32: if(ret){ ! 33: ret = coffpatch(fname, &se, symbl, &data, sizeof(data), 1); ! 34: }else{ ! 35: printf("Error obtaining value for {%s} from %s!\n", ! 36: symbl, fname); ! 37: exit(1); ! 38: } ! 39: ! 40: return data; /* return value of symbol found in kernel*/ ! 41: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.