summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgrog <grog@FreeBSD.org>2003-05-04 05:13:17 +0000
committergrog <grog@FreeBSD.org>2003-05-04 05:13:17 +0000
commit7d3e9c377915430428e4eb2851b5043a385a6426 (patch)
treea1ac2378c0aabb00d27f92d5e56391b808924829
parent713f395a43be28066441a65a1a38ca94375328c1 (diff)
downloadFreeBSD-src-7d3e9c377915430428e4eb2851b5043a385a6426.zip
FreeBSD-src-7d3e9c377915430428e4eb2851b5043a385a6426.tar.gz
Rewrite of startup code:
vinum_read: Accept 0 parameters, hand an empty string to the kernel if so. Use new ioctl VINUM_READCONFIG, not VINUM_CREATE, to read config. vinum_start: When passed 0 parameters, drop the devstat kludge and call vinum_read instead. It's no longer necessary to distinguish between "start" and "read" if no parameters are passed, and probably one of them should go away.
-rw-r--r--sbin/vinum/commands.c69
1 files changed, 13 insertions, 56 deletions
diff --git a/sbin/vinum/commands.c b/sbin/vinum/commands.c
index 68f8f79..d9f9cdf 100644
--- a/sbin/vinum/commands.c
+++ b/sbin/vinum/commands.c
@@ -153,21 +153,21 @@ vinum_read(int argc, char *argv[], char *arg0[])
int i;
reply = (struct _ioctl_reply *) &buffer;
- if (argc < 1) { /* wrong arg count */
- fprintf(stderr, "usage: read drive [drive ...]\n");
- return;
- }
- strcpy(buffer, "read ");
- for (i = 0; i < argc; i++) { /* each drive name */
- strcat(buffer, argv[i]);
- strcat(buffer, " ");
+ buffer [0] = '\0'; /* make sure we don't pass anything*/
+ if (argc > 0) /* args specified, */
+ {
+ for (i = 0; i < argc; i++) /* each drive name */
+ {
+ strcat (buffer, argv [i]);
+ strcat (buffer, " ");
+ }
}
if (ioctl(superdev, VINUM_STARTCONFIG, &force)) { /* can't get config? */
fprintf(stderr, "Can't configure: %s (%d)\n", strerror(errno), errno);
return;
}
- ioctl(superdev, VINUM_CREATE, &buffer);
+ ioctl(superdev, VINUM_READCONFIG, &buffer);
if (reply->error != 0) { /* error in config */
fprintf(stdout, "** %s: %s\n", reply->msg, strerror(reply->error));
error = ioctl(superdev, VINUM_RELEASECONFIG, NULL); /* save the config to disk */
@@ -494,53 +494,10 @@ vinum_start(int argc, char *argv[], char *arg0[])
struct _ioctl_reply reply;
struct vinum_ioctl_msg *message = (struct vinum_ioctl_msg *) &reply;
- if (argc == 0) { /* start everything */
- int devs = devstat_getnumdevs(NULL);
- struct statinfo statinfo;
- char *namelist;
- char *enamelist; /* end of name list */
- int i;
- char **token; /* list of tokens */
- int tokens; /* and their number */
-
- bzero(&statinfo, sizeof(struct statinfo));
- statinfo.dinfo = malloc(devs * sizeof(struct statinfo));
- namelist = malloc(devs * (DEVSTAT_NAME_LEN + 8));
- token = malloc((devs + 1) * sizeof(char *));
- if ((statinfo.dinfo == NULL) || (namelist == NULL) || (token == NULL)) {
- fprintf(stderr, "Can't allocate memory for drive list\n");
- return;
- }
- bzero(statinfo.dinfo, sizeof(struct devinfo));
-
- tokens = 0; /* no tokens yet */
- if (devstat_getdevs(NULL, &statinfo) < 0) { /* find out what devices we have */
- perror("Can't get device list");
- return;
- }
- namelist[0] = '\0'; /* start with empty namelist */
- enamelist = namelist; /* point to the end of the list */
-
- for (i = 0; i < devs; i++) {
- struct devstat *stat = &statinfo.dinfo->devices[i];
-
- /* Submitted by Pete Carah <pete@ns.altadena.net> */
- if ((((stat->device_type & DEVSTAT_TYPE_MASK) == DEVSTAT_TYPE_DIRECT) /* disk device */
- ||((stat->device_type & DEVSTAT_TYPE_MASK) == DEVSTAT_TYPE_STORARRAY)) /* storage array */
- &&((stat->device_type & DEVSTAT_TYPE_PASS) == 0) /* and not passthrough */
- &&((stat->device_name[0] != '\0'))) { /* and it has a name */
- sprintf(enamelist, _PATH_DEV "%s%d", stat->device_name, stat->unit_number);
- token[tokens] = enamelist; /* point to it */
- tokens++; /* one more token */
- enamelist = &enamelist[strlen(enamelist) + 1]; /* and start beyond the end */
- }
- }
- free(statinfo.dinfo); /* don't need the list any more */
- vinum_read(tokens, token, &token[0]); /* start the system */
- free(namelist);
- free(token);
- list_defective_objects(); /* and list anything that's down */
- } else { /* start specified objects */
+ if (argc == 0) /* start everything */
+ /* XXX how should we do this right? */
+ vinum_read(1, NULL, NULL); /* that's what vinum_read does now */
+ else { /* start specified objects */
int index;
enum objecttype type;
OpenPOWER on IntegriCloud