Index: raidstart.c =================================================================== RCS file: /cvs/devel/raidtools/raidstart.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- raidtools-1.00.3/raidstart.c 23 Mar 2002 16:27:05 -0000 1.2 +++ raidtools-1.00.3/raidstart.c 23 May 2003 00:38:27 -0000 1.3 @@ -96,34 +96,9 @@ return (EXIT_VERSION); } - fp = fopen(configFile, "r"); - if (fp == NULL) { - fprintf(stderr, "Couldn't open %s -- %s\n", configFile, strerror(errno)); - exit(EXIT_FAILURE); - } - if (prepare_raidlib()) return EXIT_FAILURE; - if (readwrite) { - int fd; - if (func != raidstart) { - fprintf(stderr, "Can do --readwrite only with raidstart!\n"); - return EXIT_FAILURE; - } - args = (char **)poptGetArgs(optCon); - if (!args) { - usage(namestart); - exit(EXIT_FAILURE); - } - - fd = open_or_die(*args); - - if (do_raidstart_rw (fd, *args)) - exit(EXIT_FAILURE); - exit(0); - } - if (readonly) { if (func != raidstop) { fprintf(stderr, "Can do --readonly only with raidstop!\n"); @@ -137,8 +112,60 @@ * without parsing the config */ if ((func == raidstop) || (func == raidstop_ro)) { - int fd; + if (!all) { + int fd; + + args = (char **)poptGetArgs(optCon); + if (!args) { + usage(namestart); + exit(EXIT_FAILURE); + } + + fd = open_or_die(*args); + + if (do_raidstop (fd, *args, func == raidstop ? 0:1)) + exit(EXIT_FAILURE); + exit(0); + } else { + char buf[16], *md_dev; + int md_num, fd; + + md_dev = &buf[0]; + /* scan all possible md devs we have on our one major */ + for(md_num = 0; md_num < 256; md_num++) { + sprintf(md_dev, "/dev/md%d", md_num); + fd = open(md_dev, O_RDWR); + if (fd != -1) { + struct stat s; + mdu_array_info_t info; + + fstat (fd, &s); + if (major (s.st_rdev) != MD_MAJOR || + ioctl(fd, GET_ARRAY_INFO, &info) != 0) { + close (fd); + continue; + } + + if (do_raidstop (fd, md_dev, func == raidstop ? 0:1) == 0) + fprintf (stderr, "%s: successfully stopped.\n", md_dev); + close (fd); + } + } + } + } + + fp = fopen(configFile, "r"); + if (fp == NULL) { + fprintf(stderr, "Couldn't open %s -- %s\n", configFile, strerror(errno)); + exit(EXIT_FAILURE); + } + if (readwrite) { + int fd; + if (func != raidstart) { + fprintf(stderr, "Can do --readwrite only with raidstart!\n"); + return EXIT_FAILURE; + } args = (char **)poptGetArgs(optCon); if (!args) { usage(namestart); @@ -147,7 +174,7 @@ fd = open_or_die(*args); - if (do_raidstop (fd, *args, func == raidstop ? 0:1)) + if (do_raidstart_rw (fd, *args)) exit(EXIT_FAILURE); exit(0); }