Fix vinum for both devfs and non-devfs systems.
userland tool: Use the vfs.devfs.generation sysctl to test for devfs presense (thanks phk!) when devfs is active it will not try to create the device nodes in /dev and therefore will not complain about the failure to do so. Revert the change in the #define for VINUM_DIR in the kernel header so that vinum can find its device nodes. Replace perror() with vinum_perror() to print file/line when DEVBUG is defined (not defined by default). kernel: Don't use the #define names for the "superdev" creation since they will be prepended by "/dev/" (based on VINUM_DIR), instead use string constants. Create both debug and non-debug "superdev" nodes in the devfs. Problem noticed and fix tested by: Martin Blapp <mblapp@fuchur.lan.attic.ch>
This commit is contained in:
parent
eb60c63ed2
commit
729d4f1db0
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=72777
@ -5,6 +5,10 @@ SRCS= v.c list.c vinumparser.c vinumutil.c vext.h commands.c
|
||||
MAN8= vinum.8
|
||||
|
||||
CFLAGS+= -I${.CURDIR}/../../sys -Wall -DVINUMDEBUG
|
||||
|
||||
# Print __FILE__ and __LINE__ when doing perror()
|
||||
#CFLAGS+= -DDEVBUG
|
||||
|
||||
DPADD= ${LIBREADLINE} ${LIBTERMCAP} ${LIBDEVSTAT}
|
||||
LDADD= -lreadline -ltermcap -ldevstat
|
||||
|
||||
|
@ -36,7 +36,7 @@
|
||||
* otherwise) arising in any way out of the use of this software, even if
|
||||
* advised of the possibility of such damage.
|
||||
*
|
||||
* $Id: commands.c,v 1.12 2000/03/01 03:03:53 grog Exp grog $
|
||||
* $Id: commands.c,v 1.36 2000/12/20 05:05:39 grog Exp $
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
@ -127,7 +127,7 @@ vinum_create(int argc, char *argv[], char *arg0[])
|
||||
|
||||
if (configline == NULL) {
|
||||
if (ferror(dfd))
|
||||
perror("Can't read config file");
|
||||
vinum_perror("Can't read config file");
|
||||
break;
|
||||
}
|
||||
file_line++; /* count the lines */
|
||||
@ -156,7 +156,7 @@ vinum_create(int argc, char *argv[], char *arg0[])
|
||||
ioctltype = 0; /* saveconfig after update */
|
||||
error = ioctl(superdev, VINUM_SAVECONFIG, &ioctltype); /* save the config to disk */
|
||||
if (error != 0)
|
||||
perror("Can't save Vinum config");
|
||||
vinum_perror("Can't save Vinum config");
|
||||
make_devices();
|
||||
listconfig();
|
||||
checkupdates(); /* make sure we're updating */
|
||||
@ -191,11 +191,11 @@ vinum_read(int argc, char *argv[], char *arg0[])
|
||||
fprintf(stdout, "** %s: %s\n", reply->msg, strerror(reply->error));
|
||||
error = ioctl(superdev, VINUM_RELEASECONFIG, NULL); /* save the config to disk */
|
||||
if (error != 0)
|
||||
perror("Can't save Vinum config");
|
||||
vinum_perror("Can't save Vinum config");
|
||||
} else {
|
||||
error = ioctl(superdev, VINUM_RELEASECONFIG, NULL); /* save the config to disk */
|
||||
if (error != 0)
|
||||
perror("Can't save Vinum config");
|
||||
vinum_perror("Can't save Vinum config");
|
||||
make_devices();
|
||||
}
|
||||
checkupdates(); /* make sure we're updating */
|
||||
@ -287,7 +287,7 @@ vinum_resetconfig(int argc, char *argv[], char *arg0[])
|
||||
if (errno == EBUSY)
|
||||
fprintf(stderr, "Can't reset configuration: objects are in use\n");
|
||||
else
|
||||
perror("Can't find vinum config");
|
||||
vinum_perror("Can't find vinum config");
|
||||
} else {
|
||||
make_devices(); /* recreate the /dev/vinum hierarchy */
|
||||
printf("\b Vinum configuration obliterated\n");
|
||||
@ -532,7 +532,7 @@ vinum_start(int argc, char *argv[], char *arg0[])
|
||||
|
||||
tokens = 0; /* no tokens yet */
|
||||
if (getdevs(&statinfo) < 0) { /* find out what devices we have */
|
||||
perror("Can't get device list");
|
||||
vinum_perror("Can't get device list");
|
||||
return;
|
||||
}
|
||||
namelist[0] = '\0'; /* start with empty namelist */
|
||||
@ -707,7 +707,7 @@ vinum_stop(int argc, char *argv[], char *arg0[])
|
||||
fileid = kldfind(VINUMMOD);
|
||||
if ((fileid < 0) /* no go */
|
||||
||(kldunload(fileid) < 0))
|
||||
perror("Can't unload " VINUMMOD);
|
||||
vinum_perror("Can't unload " VINUMMOD);
|
||||
else {
|
||||
fprintf(stderr, VINUMMOD " unloaded\n");
|
||||
exit(0);
|
||||
@ -716,7 +716,7 @@ vinum_stop(int argc, char *argv[], char *arg0[])
|
||||
/* If we got here, the stop failed. Reopen the superdevice. */
|
||||
superdev = open(VINUM_SUPERDEV_NAME, O_RDWR); /* reopen vinum superdevice */
|
||||
if (superdev < 0) {
|
||||
perror("Can't reopen Vinum superdevice");
|
||||
vinum_perror("Can't reopen Vinum superdevice");
|
||||
exit(1);
|
||||
}
|
||||
} else { /* stop specified objects */
|
||||
@ -873,7 +873,7 @@ vinum_resetstats(int argc, char *argv[], char *argv0[])
|
||||
enum objecttype type;
|
||||
|
||||
if (ioctl(superdev, VINUM_GETCONFIG, &vinum_conf) < 0) {
|
||||
perror("Can't get vinum config");
|
||||
vinum_perror("Can't get vinum config");
|
||||
return;
|
||||
}
|
||||
if (argc == 0) {
|
||||
@ -935,7 +935,7 @@ vinum_attach(int argc, char *argv[], char *argv0[])
|
||||
return;
|
||||
}
|
||||
if (ioctl(superdev, VINUM_GETCONFIG, &vinum_conf) < 0) {
|
||||
perror("Can't get vinum config");
|
||||
vinum_perror("Can't get vinum config");
|
||||
return;
|
||||
}
|
||||
msg.index = find_object(objname, &msg.type); /* find the object to attach */
|
||||
@ -1057,7 +1057,7 @@ vinum_detach(int argc, char *argv[], char *argv0[])
|
||||
return;
|
||||
}
|
||||
if (ioctl(superdev, VINUM_GETCONFIG, &vinum_conf) < 0) {
|
||||
perror("Can't get vinum config");
|
||||
vinum_perror("Can't get vinum config");
|
||||
return;
|
||||
}
|
||||
msg.index = find_object(argv[0], &msg.type); /* find the object to detach */
|
||||
@ -1197,7 +1197,7 @@ vinum_rename(int argc, char *argv[], char *argv0[])
|
||||
return;
|
||||
}
|
||||
if (ioctl(superdev, VINUM_GETCONFIG, &vinum_conf) < 0) {
|
||||
perror("Can't get vinum config");
|
||||
vinum_perror("Can't get vinum config");
|
||||
return;
|
||||
}
|
||||
vinum_rename_2(argv[0], argv[1]);
|
||||
@ -1227,7 +1227,7 @@ vinum_mv(int argc, char *argv[], char *argv0[])
|
||||
}
|
||||
/* Get current config */
|
||||
if (ioctl(superdev, VINUM_GETCONFIG, &vinum_conf) < 0) {
|
||||
perror("Cannot get vinum config\n");
|
||||
vinum_perror("Cannot get vinum config\n");
|
||||
return;
|
||||
}
|
||||
/* Get our destination */
|
||||
@ -1616,7 +1616,7 @@ vinum_concat(int argc, char *argv[], char *argv0[])
|
||||
ioctltype = 0; /* saveconfig after update */
|
||||
error = ioctl(superdev, VINUM_SAVECONFIG, &ioctltype); /* save the config to disk */
|
||||
if (error != 0)
|
||||
perror("Can't save Vinum config");
|
||||
vinum_perror("Can't save Vinum config");
|
||||
find_object(objectname, &type); /* find the index of the volume */
|
||||
make_vol_dev(vol.volno, 1); /* and create the devices */
|
||||
if (vflag) {
|
||||
@ -1761,7 +1761,7 @@ vinum_stripe(int argc, char *argv[], char *argv0[])
|
||||
ioctltype = 0; /* saveconfig after update */
|
||||
error = ioctl(superdev, VINUM_SAVECONFIG, &ioctltype); /* save the config to disk */
|
||||
if (error != 0)
|
||||
perror("Can't save Vinum config");
|
||||
vinum_perror("Can't save Vinum config");
|
||||
find_object(objectname, &type); /* find the index of the volume */
|
||||
make_vol_dev(vol.volno, 1); /* and create the devices */
|
||||
if (vflag) {
|
||||
@ -1905,7 +1905,7 @@ vinum_raid4(int argc, char *argv[], char *argv0[])
|
||||
ioctltype = 0; /* saveconfig after update */
|
||||
error = ioctl(superdev, VINUM_SAVECONFIG, &ioctltype); /* save the config to disk */
|
||||
if (error != 0)
|
||||
perror("Can't save Vinum config");
|
||||
vinum_perror("Can't save Vinum config");
|
||||
find_object(objectname, &type); /* find the index of the volume */
|
||||
make_vol_dev(vol.volno, 1); /* and create the devices */
|
||||
if (vflag) {
|
||||
@ -2049,7 +2049,7 @@ vinum_raid5(int argc, char *argv[], char *argv0[])
|
||||
ioctltype = 0; /* saveconfig after update */
|
||||
error = ioctl(superdev, VINUM_SAVECONFIG, &ioctltype); /* save the config to disk */
|
||||
if (error != 0)
|
||||
perror("Can't save Vinum config");
|
||||
vinum_perror("Can't save Vinum config");
|
||||
find_object(objectname, &type); /* find the index of the volume */
|
||||
make_vol_dev(vol.volno, 1); /* and create the devices */
|
||||
if (vflag) {
|
||||
@ -2224,7 +2224,7 @@ vinum_mirror(int argc, char *argv[], char *argv0[])
|
||||
ioctltype = 0; /* saveconfig after update */
|
||||
error = ioctl(superdev, VINUM_SAVECONFIG, &ioctltype); /* save the config to disk */
|
||||
if (error != 0)
|
||||
perror("Can't save Vinum config");
|
||||
vinum_perror("Can't save Vinum config");
|
||||
find_object(objectname, &type); /* find the index of the volume */
|
||||
make_vol_dev(vol.volno, 1); /* and create the devices */
|
||||
if (vflag) {
|
||||
|
@ -39,7 +39,7 @@
|
||||
* otherwise) arising in any way out of the use of this software, even if
|
||||
* advised of the possibility of such damage.
|
||||
*
|
||||
* $Id: list.c,v 1.25 2000/12/20 03:38:43 grog Exp grog $
|
||||
* $Id: list.c,v 1.30 2001/01/14 11:42:19 grog Exp $
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
@ -273,7 +273,7 @@ vinum_ld(int argc, char *argv[], char *argv0[])
|
||||
enum objecttype type;
|
||||
|
||||
if (ioctl(superdev, VINUM_GETCONFIG, &vinum_conf) < 0) {
|
||||
perror("Can't get vinum config");
|
||||
vinum_perror("Can't get vinum config");
|
||||
return;
|
||||
}
|
||||
if (argc == 0) {
|
||||
@ -398,7 +398,7 @@ vinum_lv(int argc, char *argv[], char *argv0[])
|
||||
enum objecttype type;
|
||||
|
||||
if (ioctl(superdev, VINUM_GETCONFIG, &vinum_conf) < 0) {
|
||||
perror("Can't get vinum config");
|
||||
vinum_perror("Can't get vinum config");
|
||||
return;
|
||||
}
|
||||
if (argc == 0)
|
||||
@ -565,7 +565,7 @@ vinum_lp(int argc, char *argv[], char *argv0[])
|
||||
enum objecttype type;
|
||||
|
||||
if (ioctl(superdev, VINUM_GETCONFIG, &vinum_conf) < 0) {
|
||||
perror("Can't get vinum config");
|
||||
vinum_perror("Can't get vinum config");
|
||||
return;
|
||||
}
|
||||
if (argc == 0) {
|
||||
@ -768,7 +768,7 @@ vinum_ls(int argc, char *argv[], char *argv0[])
|
||||
enum objecttype type;
|
||||
|
||||
if (ioctl(superdev, VINUM_GETCONFIG, &vinum_conf) < 0) {
|
||||
perror("Can't get vinum config");
|
||||
vinum_perror("Can't get vinum config");
|
||||
return;
|
||||
}
|
||||
if (argc == 0) {
|
||||
@ -793,7 +793,7 @@ void
|
||||
listconfig()
|
||||
{
|
||||
if (ioctl(superdev, VINUM_GETCONFIG, &vinum_conf) < 0) {
|
||||
perror("Can't get vinum config");
|
||||
vinum_perror("Can't get vinum config");
|
||||
return;
|
||||
}
|
||||
printf("%d drives:\n", vinum_conf.drives_used);
|
||||
@ -841,12 +841,12 @@ vinum_info(int argc, char *argv[], char *argv0[])
|
||||
#endif
|
||||
|
||||
if (ioctl(superdev, VINUM_GETCONFIG, &vinum_conf) < 0) {
|
||||
perror("Can't get vinum config");
|
||||
vinum_perror("Can't get vinum config");
|
||||
return;
|
||||
}
|
||||
printf("Flags: 0x%x\n", vinum_conf.flags);
|
||||
if (ioctl(superdev, VINUM_MEMINFO, &meminfo) < 0) {
|
||||
perror("Can't get information");
|
||||
vinum_perror("Can't get information");
|
||||
return;
|
||||
}
|
||||
printf("Total of %d blocks malloced, total memory: %d\nMaximum allocs: %8d, malloc table at 0x%08x\n",
|
||||
@ -862,7 +862,7 @@ vinum_info(int argc, char *argv[], char *argv0[])
|
||||
for (i = 0; i < meminfo.mallocs; i++) {
|
||||
malloced.seq = i;
|
||||
if (ioctl(superdev, VINUM_MALLOCINFO, &malloced) < 0) {
|
||||
perror("Can't get information");
|
||||
vinum_perror("Can't get information");
|
||||
return;
|
||||
}
|
||||
if (!(i & 63))
|
||||
@ -881,7 +881,7 @@ vinum_info(int argc, char *argv[], char *argv0[])
|
||||
for (i = RQINFO_SIZE - 1; i >= 0; i--) { /* go through the request list in order */
|
||||
*((int *) &rq) = i;
|
||||
if (ioctl(superdev, VINUM_RQINFO, &rq) < 0) {
|
||||
perror("Can't get information");
|
||||
vinum_perror("Can't get information");
|
||||
return;
|
||||
}
|
||||
/* Compress devminor into something printable. */
|
||||
@ -1067,7 +1067,7 @@ printconfig(FILE * of, char *comment)
|
||||
struct drive drive;
|
||||
|
||||
if (ioctl(superdev, VINUM_GETCONFIG, &vinum_conf) < 0) {
|
||||
perror("Can't get vinum config");
|
||||
vinum_perror("Can't get vinum config");
|
||||
return;
|
||||
}
|
||||
uname(&uname_s); /* get our system name */
|
||||
@ -1158,7 +1158,7 @@ list_defective_objects()
|
||||
int heading_needed = 1;
|
||||
|
||||
if (ioctl(superdev, VINUM_GETCONFIG, &vinum_conf) < 0) {
|
||||
perror("Can't get vinum config");
|
||||
vinum_perror("Can't get vinum config");
|
||||
return;
|
||||
}
|
||||
for (o = 0; o < vinum_conf.drives_allocated; o++) {
|
||||
@ -1237,7 +1237,7 @@ vinum_dumpconfig(int argc, char *argv[], char *argv0[])
|
||||
|
||||
tokens = 0; /* no tokens yet */
|
||||
if (getdevs(&statinfo) < 0) { /* find out what devices we have */
|
||||
perror("Can't get device list");
|
||||
vinum_perror("Can't get device list");
|
||||
return;
|
||||
}
|
||||
namelist[0] = '\0'; /* start with empty namelist */
|
||||
|
@ -36,7 +36,7 @@
|
||||
* otherwise) arising in any way out of the use of this software, even if
|
||||
* advised of the possibility of such damage.
|
||||
*
|
||||
* $Id: v.c,v 1.30 2000/05/07 04:20:53 grog Exp grog $
|
||||
* $Id: v.c,v 1.30 2000/09/03 01:29:29 grog Exp $
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
@ -62,6 +62,7 @@
|
||||
#include <sys/linker.h>
|
||||
#include <sys/module.h>
|
||||
#include <sys/resource.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
FILE *cf; /* config file handle */
|
||||
FILE *history; /* history file */
|
||||
@ -116,7 +117,7 @@ main(int argc, char *argv[], char *envp[])
|
||||
if (modfind(VINUMMOD) < 0) {
|
||||
/* need to load the vinum module */
|
||||
if (kldload(VINUMMOD) < 0 || modfind(VINUMMOD) < 0) {
|
||||
perror(VINUMMOD ": Kernel module not available");
|
||||
vinum_perror(VINUMMOD ": Kernel module not available");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -179,7 +180,7 @@ main(int argc, char *argv[], char *envp[])
|
||||
} 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);
|
||||
vinum_perror("Can't open " VINUM_SUPERDEV_NAME);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -500,7 +501,7 @@ find_drive_by_devname(char *name)
|
||||
int driveno;
|
||||
|
||||
if (ioctl(superdev, VINUM_GETCONFIG, &vinum_conf) < 0) {
|
||||
perror("Can't get vinum config");
|
||||
vinum_perror("Can't get vinum config");
|
||||
return NULL;
|
||||
}
|
||||
for (driveno = 0; driveno < vinum_conf.drives_allocated; driveno++) {
|
||||
@ -512,6 +513,8 @@ find_drive_by_devname(char *name)
|
||||
return NULL; /* no drive of that name */
|
||||
}
|
||||
|
||||
static int devfs_is_active = 0;
|
||||
|
||||
/* Create the device nodes for vinum objects */
|
||||
void
|
||||
make_devices(void)
|
||||
@ -521,11 +524,16 @@ make_devices(void)
|
||||
int sdno;
|
||||
int driveno;
|
||||
|
||||
if (access("/dev", W_OK) < 0) { /* can't access /dev to write? */
|
||||
if (sysctlbyname("vfs.devfs.generation", NULL, NULL, NULL, 0) == 0)
|
||||
devfs_is_active = 1;
|
||||
else
|
||||
devfs_is_active = 0;
|
||||
|
||||
if (!devfs_is_active && access("/dev", W_OK) < 0) { /* can't access /dev to write? */
|
||||
if (errno == EROFS) /* because it's read-only, */
|
||||
fprintf(stderr, VINUMMOD ": /dev is mounted read-only, not rebuilding " VINUM_DIR "\n");
|
||||
else
|
||||
perror(VINUMMOD ": Can't write to /dev");
|
||||
vinum_perror(VINUMMOD ": Can't write to /dev");
|
||||
return;
|
||||
}
|
||||
if (history) {
|
||||
@ -535,31 +543,37 @@ make_devices(void)
|
||||
if (superdev >= 0) /* super device open */
|
||||
close(superdev);
|
||||
|
||||
system("rm -rf " VINUM_DIR); /* remove the old directories */
|
||||
system("mkdir -p " VINUM_DIR "/drive " /* and make them again */
|
||||
if (!devfs_is_active) {
|
||||
system("rm -rf " VINUM_DIR); /* remove the old directories */
|
||||
system("mkdir -p " VINUM_DIR "/drive " /* and make them again */
|
||||
VINUM_DIR "/plex "
|
||||
VINUM_DIR "/sd "
|
||||
VINUM_DIR "/vol");
|
||||
}
|
||||
|
||||
if (mknod(VINUM_SUPERDEV_NAME,
|
||||
if (!devfs_is_active && mknod(VINUM_SUPERDEV_NAME,
|
||||
S_IRUSR | S_IWUSR | S_IFCHR, /* user only */
|
||||
makedev(VINUM_CDEV_MAJOR, VINUM_SUPERDEV)) < 0)
|
||||
fprintf(stderr, "Can't create %s: %s\n", VINUM_SUPERDEV_NAME, strerror(errno));
|
||||
|
||||
if (mknod(VINUM_WRONGSUPERDEV_NAME,
|
||||
if (!devfs_is_active && mknod(VINUM_WRONGSUPERDEV_NAME,
|
||||
S_IRUSR | S_IWUSR | S_IFCHR, /* user only */
|
||||
makedev(VINUM_CDEV_MAJOR, 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 (superdev < 0) {
|
||||
perror(VINUM_SUPERDEV_NAME);
|
||||
return;
|
||||
}
|
||||
|
||||
if (mknod(VINUM_DAEMON_DEV_NAME, /* daemon super device */
|
||||
if (!devfs_is_active && mknod(VINUM_DAEMON_DEV_NAME, /* daemon super device */
|
||||
S_IRUSR | S_IWUSR | S_IFCHR, /* user only */
|
||||
makedev(VINUM_CDEV_MAJOR, VINUM_DAEMON_DEV)) < 0)
|
||||
fprintf(stderr, "Can't create %s: %s\n", VINUM_DAEMON_DEV_NAME, strerror(errno));
|
||||
|
||||
if (ioctl(superdev, VINUM_GETCONFIG, &vinum_conf) < 0) {
|
||||
perror("Can't get vinum config");
|
||||
vinum_perror("Can't get vinum config");
|
||||
return;
|
||||
}
|
||||
for (volno = 0; volno < vinum_conf.volumes_allocated; volno++)
|
||||
@ -576,7 +590,7 @@ make_devices(void)
|
||||
char filename[PATH_MAX]; /* for forming file names */
|
||||
|
||||
get_drive_info(&drive, driveno);
|
||||
if (drive.state > drive_referenced) {
|
||||
if (!devfs_is_active && drive.state > drive_referenced) {
|
||||
sprintf(filename, "ln -s %s " VINUM_DIR "/drive/%s", drive.devicename, drive.label.name);
|
||||
system(filename);
|
||||
}
|
||||
@ -595,6 +609,7 @@ make_vol_dev(int volno, int recurse)
|
||||
if (vol.state != volume_unallocated) { /* we could have holes in our lists */
|
||||
voldev = VINUMDEV(volno, 0, 0, VINUM_VOLUME_TYPE); /* create a device number */
|
||||
|
||||
if (!devfs_is_active) {
|
||||
/* Create /dev/vinum/<myvol> */
|
||||
sprintf(filename, VINUM_DIR "/%s", vol.name);
|
||||
if (mknod(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IFCHR, voldev) < 0)
|
||||
@ -611,6 +626,7 @@ make_vol_dev(int volno, int recurse)
|
||||
if (mkdir(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IXOTH) < 0)
|
||||
fprintf(stderr, "Can't create %s: %s\n", filename, strerror(errno));
|
||||
}
|
||||
}
|
||||
if (recurse)
|
||||
for (plexno = 0; plexno < vol.plexes; plexno++)
|
||||
make_plex_dev(plex.plexno, recurse);
|
||||
@ -634,7 +650,7 @@ make_plex_dev(int plexno, int recurse)
|
||||
|
||||
/* /dev/vinum/plex/<plex> */
|
||||
sprintf(filename, VINUM_DIR "/plex/%s", plex.name);
|
||||
if (mknod(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IFCHR, plexdev) < 0)
|
||||
if (!devfs_is_active && mknod(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IFCHR, plexdev) < 0)
|
||||
fprintf(stderr, "Can't create %s: %s\n", filename, strerror(errno));
|
||||
|
||||
if (plex.volno >= 0) {
|
||||
@ -643,12 +659,12 @@ make_plex_dev(int plexno, int recurse)
|
||||
|
||||
/* Create device /dev/vinum/vol/<vol>.plex/<plex> */
|
||||
sprintf(filename, VINUM_DIR "/vol/%s.plex/%s", vol.name, plex.name);
|
||||
if (mknod(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IFCHR, plexdev) < 0)
|
||||
if (!devfs_is_active && mknod(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IFCHR, plexdev) < 0)
|
||||
fprintf(stderr, "Can't create %s: %s\n", filename, strerror(errno));
|
||||
|
||||
/* Create directory /dev/vinum/vol/<vol>.plex/<plex>.sd */
|
||||
sprintf(filename, VINUM_DIR "/vol/%s.plex/%s.sd", vol.name, plex.name);
|
||||
if (mkdir(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IXOTH) < 0)
|
||||
if (!devfs_is_active && mkdir(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IXOTH) < 0)
|
||||
fprintf(stderr, "Can't create %s: %s\n", filename, strerror(errno));
|
||||
}
|
||||
if (recurse) {
|
||||
@ -673,7 +689,7 @@ make_sd_dev(int sdno)
|
||||
|
||||
/* /dev/vinum/sd/<sd> */
|
||||
sprintf(filename, VINUM_DIR "/sd/%s", sd.name);
|
||||
if (mknod(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IFCHR, sddev) < 0)
|
||||
if (!devfs_is_active && mknod(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IFCHR, sddev) < 0)
|
||||
fprintf(stderr, "Can't create %s: %s\n", filename, strerror(errno));
|
||||
}
|
||||
}
|
||||
@ -697,7 +713,7 @@ find_object(const char *name, enum objecttype *type)
|
||||
int object;
|
||||
|
||||
if (ioctl(superdev, VINUM_GETCONFIG, &vinum_conf) < 0) {
|
||||
perror("Can't get vinum config");
|
||||
vinum_perror("Can't get vinum config");
|
||||
*type = invalid_object;
|
||||
return -1;
|
||||
}
|
||||
@ -824,7 +840,7 @@ start_daemon(void)
|
||||
close(superdev); /* this is the wrong device */
|
||||
superdev = open(VINUM_DAEMON_DEV_NAME, O_RDWR); /* open deamon superdevice */
|
||||
if (superdev < 0) {
|
||||
perror("Can't open " VINUM_DAEMON_DEV_NAME);
|
||||
vinum_perror("Can't open " VINUM_DAEMON_DEV_NAME);
|
||||
exit(1);
|
||||
}
|
||||
error = daemon(0, 0); /* this will fork again, but who's counting? */
|
||||
|
@ -35,7 +35,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* $Id: vext.h,v 1.17 2000/05/07 04:17:12 grog Exp grog $
|
||||
* $Id: vext.h,v 1.18 2000/06/02 03:55:01 grog Exp $
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
@ -176,3 +176,14 @@ extern int file_line; /* and line in input file (yes, this is tacky) */
|
||||
extern char buffer[]; /* buffer to read in to */
|
||||
|
||||
#define min(a, b) a < b? a: b
|
||||
|
||||
#ifdef DEVBUG
|
||||
#define vinum_perror(str) \
|
||||
do { \
|
||||
fprintf(stderr, "%s:%d> ", __FILE__, __LINE__); \
|
||||
perror(str); \
|
||||
} while (0)
|
||||
#else
|
||||
#define vinum_perror(str) perror(str)
|
||||
#endif
|
||||
|
||||
|
@ -34,7 +34,7 @@
|
||||
.\" otherwise) arising in any way out of the use of this software, even if
|
||||
.\" advised of the possibility of such damage.
|
||||
.\"
|
||||
.\" $Id: vinum.8,v 1.13 2000/01/03 03:12:56 grog Exp grog $
|
||||
.\" $Id: vinum.8,v 1.48 2001/01/15 22:15:05 grog Exp $
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd December 20, 2000
|
||||
|
@ -70,6 +70,7 @@ struct _vinum_conf vinum_conf; /* configuration information */
|
||||
|
||||
dev_t vinum_daemon_dev;
|
||||
dev_t vinum_super_dev;
|
||||
dev_t vinum_debug_super_dev;
|
||||
|
||||
/*
|
||||
* Called by main() during pseudo-device attachment. All we need
|
||||
@ -91,10 +92,15 @@ vinumattach(void *dummy)
|
||||
dqend = NULL;
|
||||
|
||||
cdevsw_add(&vinum_cdevsw); /* add the cdevsw entry */
|
||||
|
||||
vinum_daemon_dev = make_dev(&vinum_cdevsw, VINUM_DAEMON_DEV,
|
||||
UID_ROOT, GID_WHEEL, S_IRUSR|S_IWUSR, VINUM_DAEMON_DEV_NAME); /* daemon device */
|
||||
vinum_super_dev = make_dev(&vinum_cdevsw, VINUM_SUPERDEV,
|
||||
UID_ROOT, GID_WHEEL, S_IRUSR|S_IWUSR, VINUM_SUPERDEV_NAME); /* daemon device */
|
||||
UID_ROOT, GID_WHEEL, S_IRUSR|S_IWUSR, "vinum/controld");
|
||||
vinum_debug_super_dev = make_dev(&vinum_cdevsw,
|
||||
VINUMMINOR (1, 0, 0, VINUM_SUPERDEV_TYPE),
|
||||
UID_ROOT, GID_WHEEL, S_IRUSR|S_IWUSR, "vinum/Control");
|
||||
vinum_super_dev = make_dev(&vinum_cdevsw,
|
||||
VINUMMINOR (2, 0, 0, VINUM_SUPERDEV_TYPE),
|
||||
UID_ROOT, GID_WHEEL, S_IRUSR|S_IWUSR, "vinum/control");
|
||||
|
||||
/* allocate space: drives... */
|
||||
DRIVE = (struct drive *) Malloc(sizeof(struct drive) * INITIAL_DRIVES);
|
||||
@ -257,6 +263,7 @@ vinum_modevent(module_t mod, modeventtype_t type, void *unused)
|
||||
#endif
|
||||
destroy_dev(vinum_daemon_dev); /* daemon device */
|
||||
destroy_dev(vinum_super_dev);
|
||||
destroy_dev(vinum_debug_super_dev);
|
||||
cdevsw_remove(&vinum_cdevsw);
|
||||
log(LOG_INFO, "vinum: unloaded\n"); /* tell the world */
|
||||
return 0;
|
||||
|
@ -216,7 +216,7 @@ struct devcode {
|
||||
unsigned signbit:1; /* to make 32 bits */
|
||||
};
|
||||
|
||||
#define VINUM_DIR "vinum"
|
||||
#define VINUM_DIR "/dev/vinum"
|
||||
|
||||
/*
|
||||
* These definitions help catch
|
||||
|
Loading…
Reference in New Issue
Block a user