Use raw device for configuring units. This is necessary as

having a block device opened prevents autodiscovery of wedges.
This commit is contained in:
mlelstv 2020-10-06 18:47:07 +00:00
parent 7686d3bd5e
commit 3ce6ce8d42

View File

@ -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. * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@ -33,7 +33,7 @@
#ifndef lint #ifndef lint
__COPYRIGHT("@(#) Copyright (c) 1996, 1997\ __COPYRIGHT("@(#) Copyright (c) 1996, 1997\
The NetBSD Foundation, Inc. All rights reserved."); 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 #endif
#include <sys/param.h> #include <sys/param.h>
@ -391,24 +391,38 @@ pathtounit(char *path, int *unitp)
static char * static char *
resolve_ccdname(char *name) resolve_ccdname(char *name)
{ {
char c, *path; char *path, *buf;
const char *p;
char c;
size_t len; size_t len;
int rawpart; int rawpart;
if (name[0] == '/' || name[0] == '.') { if (name[0] == '/' || name[0] == '.') {
/* Assume they gave the correct pathname. */ /* Assume they gave the correct pathname. */
return estrdup(name); path = estrdup(name);
} else {
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);
} }
len = strlen(name); /*
c = name[len - 1]; * Convert to raw device if possible.
*/
if (isdigit((unsigned char)c)) { buf = emalloc(MAXPATHLEN);
if ((rawpart = getrawpartition()) < 0) p = getdiskrawname(buf, MAXPATHLEN, path);
return NULL; if (p) {
easprintf(&path, "/dev/%s%c", name, 'a' + rawpart); free(path);
} else path = estrdup(p);
easprintf(&path, "/dev/%s", name); }
free(buf);
return path; return path;
} }
@ -562,6 +576,7 @@ dump_ccd(int argc, char **argv, int action)
continue; continue;
} }
errs += printccdinfo(i); errs += printccdinfo(i);
free(ccd);
} }
return errs; return errs;
} }