summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGordon Willem Klok <gwk@cvs.openbsd.org>2007-02-12 19:53:37 +0000
committerGordon Willem Klok <gwk@cvs.openbsd.org>2007-02-12 19:53:37 +0000
commitb101aacfe0089acbe8f6506bde82010caaab15d3 (patch)
treec35958dd05c5b3617224085c1554df5de57e3997
parent471640f284c838e73ac07c80ad019d6cb59918fe (diff)
Fix the hw.vendor/product sysctls on sparc64, handle the cases where
banner-name begins with "SUNW," and make a copy of the platform_type buffer before chopping it up, so other/future users of platform_type dont get a rude shock. deraadt asked for this a 100 million years ago before 4.0. tested by pyr, brad, and kettenis. ok kettenis@
-rw-r--r--sys/arch/sparc64/sparc64/autoconf.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/sys/arch/sparc64/sparc64/autoconf.c b/sys/arch/sparc64/sparc64/autoconf.c
index 2fd2316d9dc..f893839679f 100644
--- a/sys/arch/sparc64/sparc64/autoconf.c
+++ b/sys/arch/sparc64/sparc64/autoconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: autoconf.c,v 1.58 2006/11/28 16:56:50 dlg Exp $ */
+/* $OpenBSD: autoconf.c,v 1.59 2007/02/12 19:53:36 gwk Exp $ */
/* $NetBSD: autoconf.c,v 1.51 2001/07/24 19:32:11 eeh Exp $ */
/*
@@ -1024,14 +1024,19 @@ extern bus_space_tag_t mainbus_space_tag;
OF_getprop(findroot(), "name", platform_type,
sizeof(platform_type));
printf(": %s\n", platform_type);
- if (len > 0) {
- hw_vendor = platform_type;
- if ((p = memchr(hw_vendor, ' ', len)) != NULL) {
+
+ hw_vendor = malloc(sizeof(platform_type), M_DEVBUF, M_NOWAIT);
+ if (len > 0 && hw_vendor != NULL) {
+ strlcpy(hw_vendor, platform_type, sizeof(platform_type));
+ if ((strncmp(hw_vendor, "SUNW,", 5)) == 0) {
+ p = hw_prod = hw_vendor + 5;
+ hw_vendor = "Sun";
+ } else if ((p = memchr(hw_vendor, ' ', len)) != NULL) {
*p = '\0';
hw_prod = ++p;
- if ((p = memchr(p, '(', len - (p - hw_vendor))) != NULL)
- *p = '\0';
}
+ if ((p = memchr(hw_prod, '(', len - (p - hw_prod))) != NULL)
+ *p = '\0';
}
/*
@@ -1053,7 +1058,7 @@ extern bus_space_tag_t mainbus_space_tag;
/* the first early device to be configured is the cpu */
{
/* XXX - what to do on multiprocessor machines? */
-
+
for (node = OF_child(node); node; node = OF_peer(node)) {
if (OF_getprop(node, "device_type",
buf, sizeof(buf)) <= 0)