Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin/ccdconfig Make ccdconfig resolve wedge names.



details:   https://anonhg.NetBSD.org/src/rev/5dfed3bf672b
branches:  trunk
changeset: 804938:5dfed3bf672b
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Sun Dec 07 10:44:34 2014 +0000

description:
Make ccdconfig resolve wedge names.

diffstat:

 sbin/ccdconfig/ccdconfig.c |  44 ++++++++++++++++++++++++++++----------------
 1 files changed, 28 insertions(+), 16 deletions(-)

diffs (93 lines):

diff -r 79a6ecb954ce -r 5dfed3bf672b sbin/ccdconfig/ccdconfig.c
--- a/sbin/ccdconfig/ccdconfig.c        Sun Dec 07 10:05:21 2014 +0000
+++ b/sbin/ccdconfig/ccdconfig.c        Sun Dec 07 10:44:34 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ccdconfig.c,v 1.55 2014/08/17 07:05:44 apb Exp $       */
+/*     $NetBSD: ccdconfig.c,v 1.56 2014/12/07 10:44:34 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.55 2014/08/17 07:05:44 apb Exp $");
+__RCSID("$NetBSD: ccdconfig.c,v 1.56 2014/12/07 10:44:34 mlelstv Exp $");
 #endif
 
 #include <sys/param.h>
@@ -164,8 +164,10 @@
 {
        struct ccd_ioctl ccio;
        char *ccd, *cp, *cp2, **disks;
+       char buf[MAXPATHLEN];
        int noflags = 0, i, ileave, flags, j;
-       unsigned int ui;
+       unsigned int ndisks, ui;
+       int ret = 1;
 
        flags = 0;
        memset(&ccio, 0, sizeof(ccio));
@@ -235,29 +237,34 @@
 
        /* Next is the list of disks to make the ccd from. */
        disks = emalloc(argc * sizeof(char *));
-       for (ui = 0; argc != 0; ) {
-               cp = *argv++; --argc;
+       for (ndisks = 0; argc != 0; ++argv, --argc) {
+               if (getfsspecname(buf, sizeof(buf), *argv) == NULL) {
+                       warn("%s", *argv);
+                       goto error;
+               }
+
+               cp = strdup(buf);
+               if (cp == NULL) {
+                       warn("%s", cp);
+                       goto error;
+               }
+
                if ((j = checkdev(cp)) == 0)
-                       disks[ui++] = cp;
+                       disks[ndisks++] = cp;
                else {
                        warnx("%s: %s", cp, strerror(j));
-                       free(ccd);
-                       free(disks);
-                       return (1);
+                       goto error;
                }
        }
 
        /* Fill in the ccio. */
        ccio.ccio_disks = disks;
-       ccio.ccio_ndisks = ui;
+       ccio.ccio_ndisks = ndisks;
        ccio.ccio_ileave = ileave;
        ccio.ccio_flags = flags;
 
-       if (do_io(ccd, CCDIOCSET, &ccio)) {
-               free(ccd);
-               free(disks);
-               return (1);
-       }
+       if (do_io(ccd, CCDIOCSET, &ccio))
+               goto error;
 
        if (verbose) {
                printf("ccd%d: %d components ", ccio.ccio_unit,
@@ -278,9 +285,14 @@
                        printf("concatenated\n");
        }
 
+       ret = 0;
+
+error:
        free(ccd);
+       while (ndisks > 0)
+               free(disks[--ndisks]);
        free(disks);
-       return (0);
+       return (ret);
 }
 
 static int



Home | Main Index | Thread Index | Old Index