summaryrefslogtreecommitdiff
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
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@
-rw-r--r--sbin/sysctl/sysctl.c11
-rw-r--r--sys/kern/kern_sysctl.c8
-rw-r--r--sys/sys/sysctl.h12
3 files changed, 22 insertions, 9 deletions
diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c
index f860888531d..66c28433fa0 100644
--- a/sbin/sysctl/sysctl.c
+++ b/sbin/sysctl/sysctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sysctl.c,v 1.154 2007/12/14 18:34:26 deraadt Exp $ */
+/* $OpenBSD: sysctl.c,v 1.155 2008/02/09 15:10:58 kettenis Exp $ */
/* $NetBSD: sysctl.c,v 1.9 1995/09/30 07:12:50 thorpej Exp $ */
/*
@@ -40,7 +40,7 @@ static const char copyright[] =
#if 0
static const char sccsid[] = "@(#)sysctl.c 8.5 (Berkeley) 5/9/95";
#else
-static const char rcsid[] = "$OpenBSD: sysctl.c,v 1.154 2007/12/14 18:34:26 deraadt Exp $";
+static const char rcsid[] = "$OpenBSD: sysctl.c,v 1.155 2008/02/09 15:10:58 kettenis Exp $";
#endif
#endif /* not lint */
@@ -467,8 +467,11 @@ parse(char *string, int flags)
break;
case HW_PHYSMEM:
case HW_USERMEM:
- special |= UNSIGNED;
- break;
+ /*
+ * Don't print these; we'll print the 64-bit
+ * variants instead.
+ */
+ return;
}
break;
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 }, \
}
/*