Source-Changes-HG archive

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

[src/netbsd-7]: src/sbin/ccdconfig Pull up following revision(s) (requested b...



details:   https://anonhg.NetBSD.org/src/rev/73158184f59e
branches:  netbsd-7
changeset: 798683:73158184f59e
user:      martin <martin%NetBSD.org@localhost>
date:      Tue Dec 09 20:18:47 2014 +0000

description:
Pull up following revision(s) (requested by mlelstv in ticket #305):
        sbin/ccdconfig/ccdconfig.c: revision 1.56
Make ccdconfig resolve wedge names.

diffstat:

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

diffs (93 lines):

diff -r 6bfa2e63928c -r 73158184f59e sbin/ccdconfig/ccdconfig.c
--- a/sbin/ccdconfig/ccdconfig.c        Tue Dec 09 20:17:16 2014 +0000
+++ b/sbin/ccdconfig/ccdconfig.c        Tue Dec 09 20:18:47 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ccdconfig.c,v 1.53.6.1 2014/08/18 12:40:36 martin Exp $        */
+/*     $NetBSD: ccdconfig.c,v 1.53.6.2 2014/12/09 20:18:47 martin 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.53.6.1 2014/08/18 12:40:36 martin Exp $");
+__RCSID("$NetBSD: ccdconfig.c,v 1.53.6.2 2014/12/09 20:18:47 martin 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