From: deraadt Date: Sat, 21 Dec 1996 05:07:41 +0000 (+0000) Subject: use opendev() X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=36e02f674b5fbfa52ce22964e684be6d91ceb91c;p=openbsd use opendev() --- diff --git a/usr.sbin/vnconfig/Makefile b/usr.sbin/vnconfig/Makefile index d89245a48a2..289b7c25eee 100644 --- a/usr.sbin/vnconfig/Makefile +++ b/usr.sbin/vnconfig/Makefile @@ -1,6 +1,8 @@ -# $Id: Makefile,v 1.1.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 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 #include #include +#include #include @@ -52,13 +53,13 @@ #include #include #include +#include #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() {