2004-01-22 03:10:29 +01:00
|
|
|
/*
|
|
|
|
* mdassemble - assemble Linux "md" devices aka RAID arrays.
|
|
|
|
*
|
2009-06-02 06:35:45 +02:00
|
|
|
* Copyright (C) 2001-2009 Neil Brown <neilb@suse.de>
|
2004-01-22 03:10:29 +01:00
|
|
|
* Copyright (C) 2003 Luca Berra <bluca@vodka.it>
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
* Author: Neil Brown
|
2009-06-02 06:35:45 +02:00
|
|
|
* Email: <neilb@suse.de>
|
2004-01-22 03:10:29 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "mdadm.h"
|
|
|
|
#include "md_p.h"
|
|
|
|
|
2004-11-01 05:49:34 +01:00
|
|
|
#ifndef MDASSEMBLE_AUTO
|
2006-05-29 04:06:32 +02:00
|
|
|
/* from mdopen.c */
|
2008-11-04 00:35:37 +01:00
|
|
|
int open_mddev(char *dev, int report_errors/*unused*/)
|
2004-01-22 03:10:29 +01:00
|
|
|
{
|
2008-07-25 00:35:11 +02:00
|
|
|
int mdfd = open(dev, O_RDWR);
|
2004-01-22 03:10:29 +01:00
|
|
|
if (mdfd < 0)
|
|
|
|
fprintf(stderr, Name ": error opening %s: %s\n",
|
|
|
|
dev, strerror(errno));
|
|
|
|
else if (md_get_version(mdfd) <= 0) {
|
|
|
|
fprintf(stderr, Name ": %s does not appear to be an md device\n",
|
|
|
|
dev);
|
|
|
|
close(mdfd);
|
|
|
|
mdfd = -1;
|
|
|
|
}
|
|
|
|
return mdfd;
|
|
|
|
}
|
2008-11-04 10:50:21 +01:00
|
|
|
int create_mddev(char *dev, char *name, int autof/*unused*/, int trustworthy,
|
|
|
|
char *chosen)
|
2008-11-04 00:35:37 +01:00
|
|
|
{
|
|
|
|
return open_mddev(dev, 0);
|
|
|
|
}
|
2004-11-01 05:49:34 +01:00
|
|
|
#endif
|
2008-11-04 10:50:38 +01:00
|
|
|
int map_update(struct map_ent **mpp, int devnum, char *metadata,
|
|
|
|
int *uuid, char *path)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2008-11-04 10:51:12 +01:00
|
|
|
struct map_ent *map_by_name(struct map_ent **mpp, char *name)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
2004-01-22 03:10:29 +01:00
|
|
|
|
|
|
|
int rv;
|
|
|
|
int mdfd = -1;
|
|
|
|
int runstop = 0;
|
|
|
|
int readonly = 0;
|
|
|
|
int verbose = 0;
|
|
|
|
int force = 0;
|
|
|
|
|
2006-05-29 04:06:32 +02:00
|
|
|
int main(int argc, char *argv[]) {
|
2010-11-22 10:58:05 +01:00
|
|
|
struct mddev_ident *array_list = conf_get_ident(NULL);
|
2004-01-22 03:10:29 +01:00
|
|
|
if (!array_list) {
|
|
|
|
fprintf(stderr, Name ": No arrays found in config file\n");
|
|
|
|
rv = 1;
|
|
|
|
} else
|
|
|
|
for (; array_list; array_list = array_list->next) {
|
|
|
|
mdu_array_info_t array;
|
2009-05-11 07:17:05 +02:00
|
|
|
if (strcasecmp(array_list->devname, "<ignore>") == 0)
|
|
|
|
continue;
|
2008-11-04 00:35:37 +01:00
|
|
|
mdfd = open_mddev(array_list->devname, 0);
|
|
|
|
if (mdfd >= 0 && ioctl(mdfd, GET_ARRAY_INFO, &array) == 0) {
|
2006-10-16 07:26:53 +02:00
|
|
|
rv |= Manage_ro(array_list->devname, mdfd, -1); /* make it readwrite */
|
2008-11-04 00:35:37 +01:00
|
|
|
continue;
|
2006-10-16 07:26:53 +02:00
|
|
|
}
|
2008-11-04 00:35:37 +01:00
|
|
|
if (mdfd >= 0)
|
|
|
|
close(mdfd);
|
|
|
|
rv |= Assemble(array_list->st, array_list->devname,
|
2011-02-01 05:48:03 +01:00
|
|
|
array_list, NULL, NULL, 0,
|
2009-05-11 07:46:46 +02:00
|
|
|
readonly, runstop, NULL, NULL, 0,
|
2011-12-06 01:44:46 +01:00
|
|
|
verbose, force, 1);
|
2004-01-22 03:10:29 +01:00
|
|
|
}
|
2006-05-29 04:06:32 +02:00
|
|
|
return rv;
|
2004-01-22 03:10:29 +01:00
|
|
|
}
|