From fd20bb017ec5a272b6724d4d5dec30ec4da7df6a Mon Sep 17 00:00:00 2001 From: Greg Lehey Date: Fri, 19 Mar 1999 07:21:27 +0000 Subject: [PATCH] If we fail to open the super device, open the "wrong" device (that is, the debug superdevice when we're compiled without debug, or the normal superdevice when we're compiled with debug. If this succeeds, print an informative comment and exit. make_devices: Create both debug and normal superdevices. --- sbin/vinum/v.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/sbin/vinum/v.c b/sbin/vinum/v.c index b4aac6dbf20..66f0c688c2d 100644 --- a/sbin/vinum/v.c +++ b/sbin/vinum/v.c @@ -134,7 +134,33 @@ main(int argc, char *argv[]) superdev = open(VINUM_SUPERDEV_NAME, O_RDWR); /* open vinum superdevice */ if (superdev < 0) { /* no go */ - if (errno == ENOENT) /* we don't have our node, */ + if (errno == ENODEV) { /* not configured, */ + superdev = open(VINUM_WRONGSUPERDEV_NAME, O_RDWR); /* do we have a debug mismatch? */ + if (superdev >= 0) { /* yup! */ +#if VINUMDEBUG + fprintf(stderr, + "This program is compiled with debug support, but the kernel module does\n" + "not have debug support. This program must be matched with the kernel\n" + "module. Please alter /usr/src/sbin/" VINUMMOD "/Makefile and remove\n" + "the option -DVINUMDEBUG from the CFLAGS definition, or alternatively\n" + "edit /usr/src/sys/modules/" VINUMMOD "/Makefile and add the option\n" + "-DVINUMDEBUG to the CFLAGS definition. Then rebuild the component\n" + "of your choice with 'make clean all install'. If you rebuild the kernel\n" + "module, you must stop " VINUMMOD " and restart it\n"); +#else + fprintf(stderr, + "This program is compiled without debug support, but the kernel module\n" + "includes debug support. This program must be matched with the kernel\n" + "module. Please alter /usr/src/sbin/" VINUMMOD "/Makefile and add\n" + "the option -DVINUMDEBUG to the CFLAGS definition, or alternatively\n" + "edit /usr/src/sys/modules/" VINUMMOD "/Makefile and remove the option\n" + "-DVINUMDEBUG from the CFLAGS definition. Then rebuild the component\n" + "of your choice with 'make clean all install'. If you rebuild the kernel\n" + "module, you must stop " VINUMMOD " and restart it\n"); +#endif + return 1; + } + } else if (errno == ENOENT) /* we don't have our node, */ make_devices(); /* create them first */ if (superdev < 0) { perror("Can't open " VINUM_SUPERDEV_NAME); @@ -402,6 +428,11 @@ make_devices(void) VINUM_SUPERDEV) < 0) fprintf(stderr, "Can't create %s: %s\n", VINUM_SUPERDEV_NAME, strerror(errno)); + if (mknod(VINUM_WRONGSUPERDEV_NAME, + S_IRWXU | S_IFBLK, /* block device, user only */ + VINUM_WRONGSUPERDEV) < 0) + fprintf(stderr, "Can't create %s: %s\n", VINUM_WRONGSUPERDEV_NAME, strerror(errno)); + superdev = open(VINUM_SUPERDEV_NAME, O_RDWR); /* open the super device */ if (mknod(VINUM_DAEMON_DEV_NAME, /* daemon super device */