diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index 7f8688679454..70af8c0aa98f 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1,4 +1,4 @@ -/* $NetBSD: kern_sysctl.c,v 1.130 2003/03/05 11:46:49 dsl Exp $ */ +/* $NetBSD: kern_sysctl.c,v 1.131 2003/03/06 20:33:00 thorpej Exp $ */ /*- * Copyright (c) 1982, 1986, 1989, 1993 @@ -43,7 +43,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_sysctl.c,v 1.130 2003/03/05 11:46:49 dsl Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_sysctl.c,v 1.131 2003/03/06 20:33:00 thorpej Exp $"); #include "opt_ddb.h" #include "opt_insecure.h" @@ -692,15 +692,31 @@ hw_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, case HW_BYTEORDER: return (sysctl_rdint(oldp, oldlenp, newp, BYTE_ORDER)); case HW_PHYSMEM: - return (sysctl_rdint(oldp, oldlenp, newp, ctob(physmem))); - case HW_PHYSPAGES: - return (sysctl_rdquad(oldp, oldlenp, newp, physmem)); - case HW_USERMEM: - return (sysctl_rdint(oldp, oldlenp, newp, - ctob(physmem - uvmexp.wired))); - case HW_USERPAGES: + { + u_int rval; + + if ((u_int)physmem > (UINT_MAX / PAGE_SIZE)) + rval = UINT_MAX; + else + rval = physmem * PAGE_SIZE; + return (sysctl_rdint(oldp, oldlenp, newp, rval)); + } + case HW_PHYSMEM64: return (sysctl_rdquad(oldp, oldlenp, newp, - physmem - uvmexp.wired)); + (u_quad_t)physmem * PAGE_SIZE)); + case HW_USERMEM: + { + u_int rval; + + if ((u_int)(physmem - uvmexp.wired) > (UINT_MAX / PAGE_SIZE)) + rval = UINT_MAX; + else + rval = (physmem - uvmexp.wired) * PAGE_SIZE; + return (sysctl_rdint(oldp, oldlenp, newp, rval)); + } + case HW_USERMEM64: + return (sysctl_rdquad(oldp, oldlenp, newp, + (u_quad_t)(physmem - uvmexp.wired) * PAGE_SIZE)); case HW_PAGESIZE: return (sysctl_rdint(oldp, oldlenp, newp, PAGE_SIZE)); case HW_ALIGNBYTES: diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h index 732a2e4d15fc..849bdf3fad93 100644 --- a/sys/sys/sysctl.h +++ b/sys/sys/sysctl.h @@ -1,4 +1,4 @@ -/* $NetBSD: sysctl.h,v 1.92 2003/03/01 05:41:55 atatat Exp $ */ +/* $NetBSD: sysctl.h,v 1.93 2003/03/06 20:32:59 thorpej Exp $ */ /* * Copyright (c) 1989, 1993 @@ -532,8 +532,8 @@ struct kinfo_lwp { #define HW_MACHINE_ARCH 10 /* string: machine architecture */ #define HW_ALIGNBYTES 11 /* int: ALIGNBYTES for the kernel */ #define HW_CNMAGIC 12 /* string: console magic sequence(s) */ -#define HW_PHYSPAGES 13 /* quad: total memory (pages) */ -#define HW_USERPAGES 14 /* quad: non-kernel memory (pages) */ +#define HW_PHYSMEM64 13 /* quad: total memory (bytes) */ +#define HW_USERMEM64 14 /* quad: non-kernel memory (bytes) */ #define HW_MAXID 15 /* number of valid hw ids */ #define CTL_HW_NAMES { \ @@ -550,8 +550,8 @@ struct kinfo_lwp { { "machine_arch", CTLTYPE_STRING }, \ { "alignbytes", CTLTYPE_INT }, \ { "cnmagic", CTLTYPE_STRING }, \ - { "physpages", CTLTYPE_QUAD }, \ - { "userpages", CTLTYPE_QUAD }, \ + { "physmem64", CTLTYPE_QUAD }, \ + { "usermem64", CTLTYPE_QUAD }, \ } /*