Module Name:    src
Committed By:   christos
Date:           Sun Apr  8 20:56:12 UTC 2012

Modified Files:
        src/lib/libutil: getfsspecname.c

Log Message:
Fix compat code, so if we failed to make raw, return the regular path.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libutil/getfsspecname.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/getfsspecname.c
diff -u src/lib/libutil/getfsspecname.c:1.2 src/lib/libutil/getfsspecname.c:1.3
--- src/lib/libutil/getfsspecname.c:1.2	Sat Apr  7 13:10:02 2012
+++ src/lib/libutil/getfsspecname.c	Sun Apr  8 16:56:12 2012
@@ -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, 
 		 */
 		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);

Reply via email to