From 0b81e841f1632c860d3c7627fa18872d7b0f6337 Mon Sep 17 00:00:00 2001 From: mtaylor Date: Mon, 30 Aug 1999 20:49:31 +0000 Subject: Make vnconfig's device argument not require a leading "/dev/", ala "ccdconfig". Cleanup a few "-Wall -O" warnings. Make "usage()" agree with man page. --- usr.sbin/vnconfig/vnconfig.8 | 6 +++--- usr.sbin/vnconfig/vnconfig.c | 20 ++++++++++++++++---- 2 files changed, 19 insertions(+), 7 deletions(-) (limited to 'usr.sbin/vnconfig') diff --git a/usr.sbin/vnconfig/vnconfig.8 b/usr.sbin/vnconfig/vnconfig.8 index ea68e53..85ced18 100644 --- a/usr.sbin/vnconfig/vnconfig.8 +++ b/usr.sbin/vnconfig/vnconfig.8 @@ -185,18 +185,18 @@ option. .El .Sh EXAMPLES .Pp -.Dl vnconfig /dev/vn0c /tmp/diskimage +.Dl vnconfig vn0c /tmp/diskimage .Pp Configures the vnode disk .Pa vn0c . .Pp -.Dl vnconfig -e /dev/vn0c /var/swapfile swap +.Dl vnconfig -e vn0c /var/swapfile swap .Pp Configures .Pa vn0c and enables swapping on it. .Pp -.Dl vnconfig -d /dev/vn0c myfilesystem mount=/mnt +.Dl vnconfig -d vn0c myfilesystem mount=/mnt .Pp Unmounts (disables) .Pa vn0c . diff --git a/usr.sbin/vnconfig/vnconfig.c b/usr.sbin/vnconfig/vnconfig.c index 04ace1e..ce1f7ea 100644 --- a/usr.sbin/vnconfig/vnconfig.c +++ b/usr.sbin/vnconfig/vnconfig.c @@ -46,6 +46,7 @@ static const char rcsid[] = "$FreeBSD$"; #endif /* not lint */ +#include #include #include #include @@ -54,6 +55,7 @@ static const char rcsid[] = #include #include #include +#include #include #include #include @@ -236,6 +238,14 @@ config(vnp) 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] != '.') + (void)asprintf(&vnp->dev, "/dev/%s", vnp->dev); dev = vnp->dev; file = vnp->file; flags = vnp->flags; @@ -318,7 +328,7 @@ config(vnp) 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 +342,7 @@ config(vnp) 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); } /* @@ -482,8 +492,10 @@ rawdevice(dev) static void usage() { - fprintf(stderr, -"usage: vnconfig [-acdefguv] [-s option] [-r option] [special-device file]\n"); + fprintf(stderr, "%s\n%s\n%s\n", + "usage: vnconfig [-cdeguv] [-s option] [-r option] [-S value] special_file", + " [regular_file] [feature]", + " vnconfig -a [-cdeguv] [-s option] [-r option] [-f config_file]"); exit(1); } -- cgit v1.1