summaryrefslogtreecommitdiff
path: root/usr.sbin/vnconfig/vnconfig.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1996-12-21 05:07:44 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1996-12-21 05:07:44 +0000
commitdb3bfda7efaaf87e3193d0607526c493c82d9034 (patch)
tree4966d7e6274d966f3bcde141e57b6149633cd0b2 /usr.sbin/vnconfig/vnconfig.c
parentf8b0c3e0ad6166e2af4dcde9fb4b120ea54a559b (diff)
use opendev()
Diffstat (limited to 'usr.sbin/vnconfig/vnconfig.c')
-rw-r--r--usr.sbin/vnconfig/vnconfig.c28
1 files changed, 4 insertions, 24 deletions
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()
{