summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortron <tron@NetBSD.org>2001-11-08 07:44:32 +0000
committertron <tron@NetBSD.org>2001-11-08 07:44:32 +0000
commit316d7126f6540b109949544f4d5a145ae5c945be (patch)
tree85fc9b2f737eacb536eb26c7afd57039682ddc31
parent9cc2cb211f8bec9368866898d4c005270f963e53 (diff)
Try to open the file before configuring a vnode disk device to avoid silly
error messages when the file cannot be opened for some reason. This fixes PR bin/12445 by <knotwell@ix.netcom.com>.
-rw-r--r--usr.sbin/vnconfig/vnconfig.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/usr.sbin/vnconfig/vnconfig.c b/usr.sbin/vnconfig/vnconfig.c
index 169710bfd96..130f3619cb8 100644
--- a/usr.sbin/vnconfig/vnconfig.c
+++ b/usr.sbin/vnconfig/vnconfig.c
@@ -1,4 +1,4 @@
-/* $NetBSD: vnconfig.c,v 1.22 2001/11/08 02:14:09 christos Exp $ */
+/* $NetBSD: vnconfig.c,v 1.23 2001/11/08 07:44:32 tron Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -205,21 +205,29 @@ config(dev, file, geom, action)
* Configure the device
*/
if (action == VND_CONFIG) {
- rv = ioctl(fd, VNDIOCSET, &vndio);
- if (rv)
- warn("%s: VNDIOCSET", rdev);
- else if (verbose) {
- printf("%s: %d bytes on %s", rdev, vndio.vnd_size,
- file);
- if (vndio.vnd_flags & VNDIOF_HASGEOM)
- printf(" using geometry %d/%d/%d/%d",
- vndio.vnd_geom.vng_secsize,
- vndio.vnd_geom.vng_nsectors,
- vndio.vnd_geom.vng_ntracks,
+ int ffd;
+
+ ffd = open(file, O_RDWR);
+ if (ffd < 0)
+ warn("%s", file);
+ else {
+ (void) close(ffd);
+
+ rv = ioctl(fd, VNDIOCSET, &vndio);
+ if (rv)
+ warn("%s: VNDIOCSET", rdev);
+ else if (verbose) {
+ printf("%s: %d bytes on %s", rdev,
+ vndio.vnd_size, file);
+ if (vndio.vnd_flags & VNDIOF_HASGEOM)
+ printf(" using geometry %d/%d/%d/%d",
+ vndio.vnd_geom.vng_secsize,
+ vndio.vnd_geom.vng_nsectors,
+ vndio.vnd_geom.vng_ntracks,
vndio.vnd_geom.vng_ncylinders);
- printf("\n");
+ printf("\n");
+ }
}
-
}
(void) close(fd);