Module Name:    src
Committed By:   mlelstv
Date:           Tue Oct  6 18:47:08 UTC 2020

Modified Files:
        src/sbin/ccdconfig: ccdconfig.c

Log Message:
Use raw device for configuring units. This is necessary as
having a block device opened prevents autodiscovery of wedges.


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/sbin/ccdconfig/ccdconfig.c

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

Modified files:

Index: src/sbin/ccdconfig/ccdconfig.c
diff -u src/sbin/ccdconfig/ccdconfig.c:1.57 src/sbin/ccdconfig/ccdconfig.c:1.58
--- src/sbin/ccdconfig/ccdconfig.c:1.57	Sun Sep  6 02:34:30 2020
+++ src/sbin/ccdconfig/ccdconfig.c	Tue Oct  6 18:47:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ccdconfig.c,v 1.57 2020/09/06 02:34:30 mrg Exp $	*/
+/*	$NetBSD: ccdconfig.c,v 1.58 2020/10/06 18:47:07 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
 #ifndef lint
 __COPYRIGHT("@(#) Copyright (c) 1996, 1997\
  The NetBSD Foundation, Inc.  All rights reserved.");
-__RCSID("$NetBSD: ccdconfig.c,v 1.57 2020/09/06 02:34:30 mrg Exp $");
+__RCSID("$NetBSD: ccdconfig.c,v 1.58 2020/10/06 18:47:07 mlelstv Exp $");
 #endif
 
 #include <sys/param.h>
@@ -391,24 +391,38 @@ pathtounit(char *path, int *unitp)
 static char *
 resolve_ccdname(char *name)
 {
-	char c, *path;
+	char *path, *buf;
+	const char *p;
+	char c;
 	size_t len;
 	int rawpart;
 
 	if (name[0] == '/' || name[0] == '.') {
 		/* Assume they gave the correct pathname. */
-		return estrdup(name);
-	}
+		path = estrdup(name);
+	} else {
 
-	len = strlen(name);
-	c = name[len - 1];
+		len = strlen(name);
+		c = name[len - 1];
 
-	if (isdigit((unsigned char)c)) {
-		if ((rawpart = getrawpartition()) < 0)
-			return NULL;
-		easprintf(&path, "/dev/%s%c", name, 'a' + rawpart);
-	} else
-		easprintf(&path, "/dev/%s", name);
+		if (isdigit((unsigned char)c)) {
+			if ((rawpart = getrawpartition()) < 0)
+				return NULL;
+			easprintf(&path, "/dev/%s%c", name, 'a' + rawpart);
+		} else
+			easprintf(&path, "/dev/%s", name);
+	}
+
+	/*
+	 * Convert to raw device if possible.
+	 */
+	buf = emalloc(MAXPATHLEN);
+	p = getdiskrawname(buf, MAXPATHLEN, path);
+	if (p) {
+		free(path);
+		path = estrdup(p);
+	}
+	free(buf);
 
 	return path;
 }
@@ -562,6 +576,7 @@ dump_ccd(int argc, char **argv, int acti
 			continue;
 		}
 		errs += printccdinfo(i);
+		free(ccd);
 	}
 	return errs;
 }

Reply via email to