2 * mdassemble - assemble Linux "md" devices aka RAID arrays.
4 * Copyright (C) 2001-2002 Neil Brown <neilb@cse.unsw.edu.au>
5 * Copyright (C) 2003 Luca Berra <bluca@vodka.it>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 * Email: <neilb@cse.unsw.edu.au>
25 * School of Computer Science and Engineering
26 * The University of New South Wales
53 int open_mddev(char *dev)
55 int mdfd = open(dev, O_RDWR, 0);
57 fprintf(stderr, Name ": error opening %s: %s\n",
58 dev, strerror(errno));
59 else if (md_get_version(mdfd) <= 0) {
60 fprintf(stderr, Name ": %s does not appear to be an md device\n",
68 char *configfile = NULL;
77 mddev_ident_t array_list = conf_get_ident(configfile, NULL);
79 fprintf(stderr, Name ": No arrays found in config file\n");
82 for (; array_list; array_list = array_list->next) {
83 mdu_array_info_t array;
84 mdfd = open_mddev(array_list->devname);
89 if (ioctl(mdfd, GET_ARRAY_INFO, &array)>=0)
90 /* already assembled, skip */
92 rv |= Assemble(array_list->devname, mdfd,
93 array_list, configfile,
95 readonly, runstop, NULL, verbose, force);