/** Reads kernel memory. * Seeks to the specified location in kmem, then * does a read of given amount ob bytes into target buffer. * * @param off The location to seek. * * @param target The target buffer to read into. * * @param siz Number of bytes to read. * * @return gives 1 on success and 0 on failure. */ int klookup (unsigned long off, void *target, size_t siz) { long retsiz; if (kmem < 0) return 0; if ((retsiz = klseek ((off_t) off)) != off) { snmp_log (LOG_ERR, "klookup(%lx, %p, %d): ", off, target, siz); snmp_log_perror ("klseek"); return (0); } if ((retsiz = klread (target, siz)) != siz) { if (snmp_get_do_debugging ()) { /* * these happen too often on too many architectures to print them * unless we're in debugging mode. People get very full log files. */ snmp_log (LOG_ERR, "klookup(%lx, %p, %d): ", off, target, siz); snmp_log_perror ("klread"); } return (0); } DEBUGMSGTL (("verbose:kernel:klookup", "klookup(%lx, %p, %d) succeeded", off, target, siz)); return (1); }
int klookup(unsigned long off, char *target, int siz) { long retsiz; if (kmem < 0) return 0; if ((retsiz = klseek((off_t) off)) != off) { snmp_log(LOG_ERR, "klookup(%lx, %p, %d): ", off, target, siz); snmp_log_perror("klseek"); #ifdef EXIT_ON_BAD_KLREAD exit(1); #endif return (0); } if ((retsiz = klread(target, siz)) != siz ) { if (snmp_get_do_debugging()) { /* these happen too often on too many architectures to print them unless we're in debugging mode. People get very full log files. */ snmp_log(LOG_ERR, "klookup(%lx, %p, %d): ", off, target, siz); snmp_log_perror("klread"); } #ifdef EXIT_ON_BAD_KLREAD exit(1); #endif return(0); } return (1); }