diff options
Diffstat (limited to 'usr.sbin/vnconfig')
-rw-r--r-- | usr.sbin/vnconfig/Makefile | 8 | ||||
-rw-r--r-- | usr.sbin/vnconfig/vnconfig.c | 28 |
2 files changed, 9 insertions, 27 deletions
diff --git a/usr.sbin/vnconfig/Makefile b/usr.sbin/vnconfig/Makefile index fb32170254d..289b7c25eee 100644 --- a/usr.sbin/vnconfig/Makefile +++ b/usr.sbin/vnconfig/Makefile @@ -1,6 +1,8 @@ -# $Id: Makefile,v 1.1 1995/10/18 08:48:31 deraadt Exp $ +# $Id: Makefile,v 1.2 1996/12/21 05:07:41 deraadt Exp $ -PROG= vnconfig -MAN= vnconfig.8 +PROG= vnconfig +MAN= vnconfig.8 +DPADD= ${LIBUTIL} +LDADD= -lutil .include <bsd.prog.mk> diff --git a/usr.sbin/vnconfig/vnconfig.c b/usr.sbin/vnconfig/vnconfig.c index 3bfac4273b5..00fe960f22f 100644 --- a/usr.sbin/vnconfig/vnconfig.c +++ b/usr.sbin/vnconfig/vnconfig.c @@ -44,6 +44,7 @@ #include <sys/ioctl.h> #include <sys/mount.h> #include <sys/stat.h> +#include <sys/fcntl.h> #include <dev/vndioctl.h> @@ -52,13 +53,13 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <util.h> #define VND_CONFIG 1 #define VND_UNCONFIG 2 int verbose = 0; -char *rawdevice __P((char *)); void usage __P((void)); main(argc, argv) @@ -106,7 +107,8 @@ config(dev, file, action) char *rdev; int rv; - rdev = rawdevice(dev); + if (opendev(dev, O_RDWR, OPENDEV_PART, &rdev) < 0) + err(4, "%s", rdev); f = fopen(rdev, "rw"); if (f == NULL) { warn(rdev); @@ -141,28 +143,6 @@ done: return (rv < 0); } -char * -rawdevice(dev) - char *dev; -{ - register char *rawbuf, *dp, *ep; - struct stat sb; - int len; - - len = strlen(dev); - rawbuf = malloc(len + 2); - strcpy(rawbuf, dev); - if (stat(rawbuf, &sb) != 0 || !S_ISCHR(sb.st_mode)) { - dp = rindex(rawbuf, '/'); - if (dp) { - for (ep = &rawbuf[len]; ep > dp; --ep) - *(ep+1) = *ep; - *++ep = 'r'; - } - } - return (rawbuf); -} - void usage() { |