diff options
-rw-r--r-- | usr.sbin/eeprom/Makefile | 4 | ||||
-rw-r--r-- | usr.sbin/eeprom/main.c | 41 |
2 files changed, 11 insertions, 34 deletions
diff --git a/usr.sbin/eeprom/Makefile b/usr.sbin/eeprom/Makefile index 325c45501eb..4515add6374 100644 --- a/usr.sbin/eeprom/Makefile +++ b/usr.sbin/eeprom/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.7 2001/12/04 19:18:31 miod Exp $ +# $OpenBSD: Makefile,v 1.8 2002/06/14 04:21:54 art Exp $ .if ${MACHINE} == "sparc" || ${MACHINE} == "sun3" || ${MACHINE} == "sparc64" PROG= eeprom @@ -10,8 +10,6 @@ SRCS= eehandlers.c getdate.c main.c . if ${MACHINE} == "sparc" || ${MACHINE} == "sparc64" SRCS+= ophandlers.c -DPADD= ${LIBKVM} -LDADD= -lkvm . endif CLEANFILES+=getdate.c y.tab.h diff --git a/usr.sbin/eeprom/main.c b/usr.sbin/eeprom/main.c index 5d836aa3d8b..8777a98d98b 100644 --- a/usr.sbin/eeprom/main.c +++ b/usr.sbin/eeprom/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.8 2002/02/16 21:28:02 millert Exp $ */ +/* $OpenBSD: main.c,v 1.9 2002/06/14 04:21:54 art Exp $ */ /* $NetBSD: main.c,v 1.3 1996/05/16 16:00:55 thorpej Exp $ */ /*- @@ -45,18 +45,12 @@ #ifdef __sparc__ #include <fcntl.h> -#include <kvm.h> #include <limits.h> -#include <nlist.h> +#include <sys/sysctl.h> +#include <machine/cpu.h> #include <machine/openpromio.h> -struct nlist nl[] = { - { "_cputyp" }, -#define SYM_CPUTYP 0 - { NULL }, -}; - static char *system = NULL; #endif /* __sparc__ */ @@ -216,34 +210,19 @@ main(argc, argv) } #ifdef __sparc__ -#define KVM_ABORT(kd, str) { \ - (void)kvm_close((kd)); \ - errx(1, "%s: %s", (str), kvm_geterr((kd))); \ -} - static int getcputype() { - char errbuf[_POSIX2_LINE_MAX]; + int mib[2]; + size_t len; int cputype; - kvm_t *kd; - - bzero(errbuf, sizeof(errbuf)); - - if ((kd = kvm_openfiles(system, NULL, NULL, O_RDONLY, errbuf)) == NULL) - errx(1, "can't open kvm: %s", errbuf); - - setegid(getgid()); - setgid(getgid()); - - if (kvm_nlist(kd, nl)) - KVM_ABORT(kd, "can't read symbol table"); - if (kvm_read(kd, nl[SYM_CPUTYP].n_value, (char *)&cputype, - sizeof(cputype)) != sizeof(cputype)) - KVM_ABORT(kd, "can't determine cpu type"); + mib[0] = CTL_MACHDEP; + mib[1] = CPU_CPUTYPE; + len = sizeof(cputype); + if (sysctl(mib, 2, &cputype, &len, NULL, 0) < 0) + err(1, "sysctl(machdep.cputype)"); - (void)kvm_close(kd); return (cputype); } #endif /* __sparc__ */ |