summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2008-08-22 03:19:03 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2008-08-22 03:19:03 +0000
commit6f3d5aa54038723b3d634d7ac5f8f2e6be8951fa (patch)
treed20fe323a78ddea6a1cb92ae4a2ec892efd21a2c /sys
parent19e5394fedd311959a3fe3f3ab1f6ca18a0a0bdf (diff)
simplification, and repair findblkmajor for name## lookups; ok krw
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/subr_disk.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/sys/kern/subr_disk.c b/sys/kern/subr_disk.c
index 41deb07f29b..cb0d89338fd 100644
--- a/sys/kern/subr_disk.c
+++ b/sys/kern/subr_disk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_disk.c,v 1.80 2008/08/08 23:49:53 krw Exp $ */
+/* $OpenBSD: subr_disk.c,v 1.81 2008/08/22 03:19:02 deraadt Exp $ */
/* $NetBSD: subr_disk.c,v 1.17 1996/03/16 23:17:08 christos Exp $ */
/*
@@ -1016,8 +1016,8 @@ struct device *
parsedisk(char *str, int len, int defpart, dev_t *devp)
{
struct device *dv;
+ int majdev, part = defpart;
char c;
- int majdev, part;
if (len == 0)
return (NULL);
@@ -1025,9 +1025,7 @@ parsedisk(char *str, int len, int defpart, dev_t *devp)
if (c >= 'a' && (c - 'a') < MAXPARTITIONS) {
part = c - 'a';
len -= 1;
- } else
- part = defpart;
-
+ }
TAILQ_FOREACH(dv, &alldevs, dv_list) {
if (dv->dv_class == DV_DISK &&
@@ -1257,11 +1255,17 @@ extern struct nam2blk nam2blk[];
int
findblkmajor(struct device *dv)
{
- char *name = dv->dv_xname;
+ char buf[16], *p;
int i;
+ if (strlcpy(buf, dv->dv_xname, sizeof buf) >= sizeof buf)
+ return (-1);
+ for (p = buf; *p; p++)
+ if (*p >= '0' && *p <= '9')
+ *p = '\0';
+
for (i = 0; nam2blk[i].name; i++)
- if (!strncmp(name, nam2blk[i].name, strlen(nam2blk[i].name)))
+ if (!strcmp(buf, nam2blk[i].name))
return (nam2blk[i].maj);
return (-1);
}