summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2011-01-29 03:43:14 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2011-01-29 03:43:14 +0000
commit3d678aeebaa57ca3cb3d7104dc70616eb5e6371d (patch)
tree72c22816856a2d06ba8998b2a587a56120a264a5
parentaee3e2bf5763658c0df3ab7a6c16de7331a197f9 (diff)
no need for fopen, when opendev gives us a perfectly good fd.
from "maurice"
-rw-r--r--sbin/mount_vnd/mount_vnd.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/sbin/mount_vnd/mount_vnd.c b/sbin/mount_vnd/mount_vnd.c
index fb4057e78d4..fe9860fb9f5 100644
--- a/sbin/mount_vnd/mount_vnd.c
+++ b/sbin/mount_vnd/mount_vnd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mount_vnd.c,v 1.9 2010/04/12 01:44:08 tedu Exp $ */
+/* $OpenBSD: mount_vnd.c,v 1.10 2011/01/29 03:43:13 tedu Exp $ */
/*
* Copyright (c) 1993 University of Utah.
* Copyright (c) 1990, 1993
@@ -296,17 +296,14 @@ config(char *dev, char *file, int action, struct disklabel *dp, char *key,
size_t keylen)
{
struct vnd_ioctl vndio;
- FILE *f;
char *rdev;
- int rv = -1;
+ int fd, rv = -1;
- if (opendev(dev, O_RDONLY, OPENDEV_PART, &rdev) < 0)
+ if ((fd = opendev(dev, O_RDONLY, OPENDEV_PART, &rdev)) < 0) {
err(4, "%s", rdev);
- f = fopen(rdev, "r");
- if (f == NULL) {
- warn("%s", rdev);
goto out;
}
+
vndio.vnd_file = file;
vndio.vnd_secsize = (dp && dp->d_secsize) ? dp->d_secsize : DEV_BSIZE;
vndio.vnd_nsectors = (dp && dp->d_nsectors) ? dp->d_nsectors : 100;
@@ -318,7 +315,7 @@ config(char *dev, char *file, int action, struct disklabel *dp, char *key,
* Clear (un-configure) the device
*/
if (action == VND_UNCONFIG) {
- rv = ioctl(fileno(f), VNDIOCCLR, &vndio);
+ rv = ioctl(fd, VNDIOCCLR, &vndio);
if (rv)
warn("VNDIOCCLR");
else if (verbose)
@@ -328,7 +325,7 @@ config(char *dev, char *file, int action, struct disklabel *dp, char *key,
* Configure the device
*/
if (action == VND_CONFIG) {
- rv = ioctl(fileno(f), VNDIOCSET, &vndio);
+ rv = ioctl(fd, VNDIOCSET, &vndio);
if (rv)
warn("VNDIOCSET");
else if (verbose)
@@ -336,7 +333,7 @@ config(char *dev, char *file, int action, struct disklabel *dp, char *key,
file);
}
- fclose(f);
+ close(fd);
fflush(stdout);
out:
if (key)