From 28f7bbe1f362f59dd11ca8fe28737c20b11d1a82 Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Fri, 24 Sep 2010 00:11:16 +0000 Subject: Now that HW_DISKNAMES returns xx0: or xx0:uid entries, we must truncate the : and uid components out -- otherwise these two programs will work poorly. --- sbin/raidctl/raidctl.c | 7 ++++++- usr.bin/vmstat/dkstats.c | 15 +++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/sbin/raidctl/raidctl.c b/sbin/raidctl/raidctl.c index 7f8c492e0a1..4251d81765d 100644 --- a/sbin/raidctl/raidctl.c +++ b/sbin/raidctl/raidctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: raidctl.c,v 1.30 2009/11/12 15:29:24 deraadt Exp $ */ +/* $OpenBSD: raidctl.c,v 1.31 2010/09/24 00:11:15 deraadt Exp $ */ /* $NetBSD: raidctl.c,v 1.27 2001/07/10 01:30:52 lukem Exp $ */ /*- @@ -1203,6 +1203,11 @@ get_all_devices(char ***diskarray, const char *genericname) i = 0; fp = disks; while ((p = strsep(&fp, ",")) != NULL) { + char *q = strchr(p, ':'); + + if (q) + *q = '\0'; + if (strstr((const char*)p, genericname) != NULL) { if (asprintf(&(*diskarray)[i++], "/dev/%s%c", p, 'a' + getrawpartition()) == -1) diff --git a/usr.bin/vmstat/dkstats.c b/usr.bin/vmstat/dkstats.c index f7877d52c4b..fbc0ddce74f 100644 --- a/usr.bin/vmstat/dkstats.c +++ b/usr.bin/vmstat/dkstats.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dkstats.c,v 1.34 2010/07/20 19:43:19 lum Exp $ */ +/* $OpenBSD: dkstats.c,v 1.35 2010/09/24 00:11:15 deraadt Exp $ */ /* $NetBSD: dkstats.c,v 1.1 1996/05/10 23:19:27 thorpej Exp $ */ /* @@ -198,8 +198,14 @@ dkreadstats(void) if (sysctl(mib, 2, disknames, &size, NULL, 0) < 0) err(1, "can't get hw.disknames"); bufpp = disknames; - for (i = 0; i < dk_ndrive && (name = strsep(&bufpp, ",")) != NULL; i++) + for (i = 0; i < dk_ndrive && + (name = strsep(&bufpp, ",")) != NULL; i++) dk_name[i] = name; + for (i = 0; i < dk_ndrive; i++) { + char *p = strchr(dk_name[i], ':'); + if (p) + *p = '\0'; + } disknames = cur.dk_name[0]; /* To free old names. */ if (dk_ndrive < cur.dk_ndrive) { @@ -528,6 +534,11 @@ dkinit(int sel) cur.dk_name[i] = name; cur.dk_select[i] = sel; } + for (i = 0; i < dk_ndrive; i++) { + char *p = strchr(cur.dk_name[i], ':'); + if (p) + *p = '\0'; + } } else { #if !defined(NOKVM) p = dk_drivehead; -- cgit v1.2.3