summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2008-02-09 15:10:59 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2008-02-09 15:10:59 +0000
commit1b7b828bcba3260462511a413dc672cb8a4db98e (patch)
tree93cd4b2ddec508eb6d2c400cb0f68c98ba89b32a /sys
parent5d86d618d3c3b175f9627d4f59c408c6f1cfe9f2 (diff)
Introduce HW_PHYSMEM64 and HW_USERMEM64 sysctls, which don't overflow on
machines with more than 4GB of memory. Make sysctl(8) print values obtained using these sysctls for hw.physmem and hw.usermem. ok krw@, miod@
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/kern_sysctl.c8
-rw-r--r--sys/sys/sysctl.h12
2 files changed, 15 insertions, 5 deletions
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c
index a855b835c6a..0063a736d1e 100644
--- a/sys/kern/kern_sysctl.c
+++ b/sys/kern/kern_sysctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_sysctl.c,v 1.159 2007/12/23 01:59:58 dlg Exp $ */
+/* $OpenBSD: kern_sysctl.c,v 1.160 2008/02/09 15:10:58 kettenis Exp $ */
/* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */
/*-
@@ -642,6 +642,12 @@ hw_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
return (sysctl_rdstring(oldp, oldlenp, newp, hw_uuid));
else
return (EOPNOTSUPP);
+ case HW_PHYSMEM64:
+ return (sysctl_rdquad(oldp, oldlenp, newp,
+ ptoa((psize_t)physmem)));
+ case HW_USERMEM64:
+ return (sysctl_rdquad(oldp, oldlenp, newp,
+ ptoa((psize_t)physmem - uvmexp.wired)));
default:
return (EOPNOTSUPP);
}
diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h
index 9d1897e3dbe..2d2c48583fd 100644
--- a/sys/sys/sysctl.h
+++ b/sys/sys/sysctl.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: sysctl.h,v 1.91 2007/04/12 22:14:15 tedu Exp $ */
+/* $OpenBSD: sysctl.h,v 1.92 2008/02/09 15:10:58 kettenis Exp $ */
/* $NetBSD: sysctl.h,v 1.16 1996/04/09 20:55:36 cgd Exp $ */
/*
@@ -552,7 +552,9 @@ struct kinfo_proc2 {
#define HW_VERSION 16 /* string: hardware version */
#define HW_SERIALNO 17 /* string: hardware serial number */
#define HW_UUID 18 /* string: universal unique id */
-#define HW_MAXID 19 /* number of valid hw ids */
+#define HW_PHYSMEM64 19 /* quad: total memory */
+#define HW_USERMEM64 20 /* quad: non-kernel memory */
+#define HW_MAXID 21 /* number of valid hw ids */
#define CTL_HW_NAMES { \
{ 0, 0 }, \
@@ -560,8 +562,8 @@ struct kinfo_proc2 {
{ "model", CTLTYPE_STRING }, \
{ "ncpu", CTLTYPE_INT }, \
{ "byteorder", CTLTYPE_INT }, \
- { "physmem", CTLTYPE_INT }, \
- { "usermem", CTLTYPE_INT }, \
+ { "gap", 0 }, \
+ { "gap", 0 }, \
{ "pagesize", CTLTYPE_INT }, \
{ "disknames", CTLTYPE_STRING }, \
{ "diskstats", CTLTYPE_STRUCT }, \
@@ -574,6 +576,8 @@ struct kinfo_proc2 {
{ "version", CTLTYPE_STRING }, \
{ "serialno", CTLTYPE_STRING }, \
{ "uuid", CTLTYPE_STRING }, \
+ { "physmem", CTLTYPE_QUAD }, \
+ { "usermem", CTLTYPE_QUAD }, \
}
/*