diff options
| author | christos <christos@NetBSD.org> | 2012-04-08 20:56:12 +0000 |
|---|---|---|
| committer | christos <christos@NetBSD.org> | 2012-04-08 20:56:12 +0000 |
| commit | 536bfd759bb03737809bbf50ec7916c49d841a4c (patch) | |
| tree | 46ffe9142d1171b2f3df1b0d6ce9fc34f72a772f /lib/libutil | |
| parent | 387e289ae3394c0a68bb7a081a0d3ee7a0bda1c9 (diff) | |
Fix compat code, so if we failed to make raw, return the regular path.
Diffstat (limited to 'lib/libutil')
| -rw-r--r-- | lib/libutil/getfsspecname.c | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/lib/libutil/getfsspecname.c b/lib/libutil/getfsspecname.c index 0bec1895935..f5b530be699 100644 --- a/lib/libutil/getfsspecname.c +++ b/lib/libutil/getfsspecname.c @@ -1,4 +1,4 @@ -/* $NetBSD: getfsspecname.c,v 1.2 2012/04/07 17:10:02 christos Exp $ */ +/* $NetBSD: getfsspecname.c,v 1.3 2012/04/08 20:56:12 christos Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include <sys/cdefs.h> -__RCSID("$NetBSD: getfsspecname.c,v 1.2 2012/04/07 17:10:02 christos Exp $"); +__RCSID("$NetBSD: getfsspecname.c,v 1.3 2012/04/08 20:56:12 christos Exp $"); #include <sys/types.h> #include <sys/sysctl.h> @@ -67,18 +67,15 @@ getfsspecname(char *buf, size_t bufsiz, const char *name) */ char rbuf[MAXPATHLEN]; if (name[0] == '/') { - if (getdiskrawname(rbuf, sizeof(rbuf), name) == NULL) { - savee = errno; - strlcpy(buf, "makeraw failed", bufsiz); - goto out; + if (getdiskrawname(rbuf, sizeof(rbuf), name) != NULL) { + if ((fd = open(rbuf, O_RDONLY)) == -1) { + if (errno == EBUSY) { + name = strrchr(name, '/') + 1; + goto search; + } + } else + close(fd); } - if ((fd = open(rbuf, O_RDONLY)) == -1) { - if (errno == EBUSY) { - name = strrchr(name, '/') + 1; - goto search; - } - } else - close(fd); } #endif strlcpy(buf, name, bufsiz); |
