Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 26 Aug 1999 15:57:14 -0400 (EDT)
From:      "Mark J. Taylor" <mtaylor@cybernet.com>
To:        hackers@freebsd.org
Subject:   Request for review: vnconfig.c
Message-ID:  <XFMail.990826155714.mtaylor@cybernet.com>

next in thread | raw e-mail | index | archive | help

(Since this will be one of my first commits, I'd like to pass it by
as many people as possible.)


This patch makes "vnconfig" like "ccdconfig" where you don't have
to specify "/dev/xxx": it will add "/dev/" for you.  Same goes
for the "vntab" file.
Also includes "-Wall" cleanup.


[I already know about the malloc() w/o an associated free().]



Anyone opposed?  Comments?  style(9) bugs?




-Mark Taylor
NetMAX Developer
mtaylor@cybernet.com
http://www.netmax.com/



Index: vnconfig.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/vnconfig/vnconfig.c,v
retrieving revision 1.10
diff -u -r1.10 vnconfig.c
--- vnconfig.c  1999/05/16 08:09:23     1.10
+++ vnconfig.c  1999/08/26 19:48:47
@@ -46,6 +46,7 @@
        "$Id: vnconfig.c,v 1.10 1999/05/16 08:09:23 phk Exp $";
 #endif /* not lint */
 
+#include <ctype.h>
 #include <err.h>
 #include <errno.h>
 #include <stdio.h>
@@ -54,6 +55,7 @@
 #include <unistd.h>
 #include <sys/param.h>
 #include <sys/ioctl.h>
+#include <sys/linker.h>
 #include <sys/mount.h>
 #include <sys/module.h>
 #include <sys/stat.h>
@@ -236,6 +238,17 @@
        FILE *f;
        u_long l;
 
+       rv = 0;
+
+       /*
+        * Prepend "/dev/" to the specified device name, if necessary.
+        * Operate on vnp->dev because it is used later.
+        */
+       if (vnp->dev[0] != '/' && vnp->dev[0] != '.') {
+               dev = malloc(strlen(vnp->dev)+6);
+               (void)sprintf(dev, "/dev/%s", vnp->dev);
+               vnp->dev = dev;
+       }
        dev = vnp->dev;
        file = vnp->file;
        flags = vnp->flags;
@@ -318,7 +331,7 @@
                if (rv) {
                        warn("VNIO[GU]SET");
                } else if (verbose)
-                       printf("%s: flags now=%08x\n",dev,l);
+                       printf("%s: flags now=%08lx\n",dev,l);
        }
        /*
         * Reset an option
@@ -332,7 +345,7 @@
                if (rv) {
                        warn("VNIO[GU]CLEAR");
                } else if (verbose)
-                       printf("%s: flags now=%08x\n",dev,l);
+                       printf("%s: flags now=%08lx\n",dev,l);
        }
 
        /*



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?XFMail.990826155714.mtaylor>