]>
Commit | Line | Data |
---|---|---|
98c6faba NB |
1 | /* |
2 | * mdassemble - assemble Linux "md" devices aka RAID arrays. | |
3 | * | |
e736b623 | 4 | * Copyright (C) 2001-2009 Neil Brown <neilb@suse.de> |
98c6faba NB |
5 | * Copyright (C) 2003 Luca Berra <bluca@vodka.it> |
6 | * | |
7 | * | |
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. | |
12 | * | |
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. | |
17 | * | |
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 | |
21 | * | |
22 | * Author: Neil Brown | |
e736b623 | 23 | * Email: <neilb@suse.de> |
98c6faba NB |
24 | */ |
25 | ||
26 | #include "mdadm.h" | |
27 | #include "md_p.h" | |
28 | ||
b5e64645 | 29 | #ifndef MDASSEMBLE_AUTO |
b56c3630 | 30 | /* from mdopen.c */ |
7f91af49 | 31 | int open_mddev(char *dev, int report_errors/*unused*/) |
98c6faba | 32 | { |
fb97b4d6 | 33 | int mdfd = open(dev, O_RDWR); |
98c6faba NB |
34 | if (mdfd < 0) |
35 | fprintf(stderr, Name ": error opening %s: %s\n", | |
36 | dev, strerror(errno)); | |
37 | else if (md_get_version(mdfd) <= 0) { | |
38 | fprintf(stderr, Name ": %s does not appear to be an md device\n", | |
39 | dev); | |
40 | close(mdfd); | |
41 | mdfd = -1; | |
42 | } | |
43 | return mdfd; | |
44 | } | |
69207ff6 N |
45 | int create_mddev(char *dev, char *name, int autof/*unused*/, int trustworthy, |
46 | char *chosen) | |
7f91af49 N |
47 | { |
48 | return open_mddev(dev, 0); | |
49 | } | |
b5e64645 | 50 | #endif |
a04d5763 N |
51 | int map_update(struct map_ent **mpp, int devnum, char *metadata, |
52 | int *uuid, char *path) | |
53 | { | |
54 | return 0; | |
55 | } | |
f2e55ecc N |
56 | struct map_ent *map_by_name(struct map_ent **mpp, char *name) |
57 | { | |
58 | return NULL; | |
59 | } | |
98c6faba | 60 | |
98c6faba NB |
61 | int rv; |
62 | int mdfd = -1; | |
63 | int runstop = 0; | |
64 | int readonly = 0; | |
65 | int verbose = 0; | |
66 | int force = 0; | |
67 | ||
b56c3630 | 68 | int main(int argc, char *argv[]) { |
fa56eddb | 69 | struct mddev_ident *array_list = conf_get_ident(NULL); |
98c6faba NB |
70 | if (!array_list) { |
71 | fprintf(stderr, Name ": No arrays found in config file\n"); | |
72 | rv = 1; | |
73 | } else | |
74 | for (; array_list; array_list = array_list->next) { | |
75 | mdu_array_info_t array; | |
112cace6 N |
76 | if (strcasecmp(array_list->devname, "<ignore>") == 0) |
77 | continue; | |
7f91af49 N |
78 | mdfd = open_mddev(array_list->devname, 0); |
79 | if (mdfd >= 0 && ioctl(mdfd, GET_ARRAY_INFO, &array) == 0) { | |
435d4ebb | 80 | rv |= Manage_ro(array_list->devname, mdfd, -1); /* make it readwrite */ |
7f91af49 | 81 | continue; |
435d4ebb | 82 | } |
7f91af49 N |
83 | if (mdfd >= 0) |
84 | close(mdfd); | |
85 | rv |= Assemble(array_list->st, array_list->devname, | |
71204a50 | 86 | array_list, NULL, NULL, 0, |
0ac91628 | 87 | readonly, runstop, NULL, NULL, 0, |
d1e02575 | 88 | verbose, force, 1); |
98c6faba | 89 | } |
b56c3630 | 90 | return rv; |
98c6faba | 91 | } |