]>
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 | ||
29 | /* from readme.c */ | |
30 | mapping_t pers[] = { | |
df0d4ea0 | 31 | { "linear", LEVEL_LINEAR}, |
98c6faba NB |
32 | { "raid0", 0}, |
33 | { "0", 0}, | |
34 | { "stripe", 0}, | |
35 | { "raid1", 1}, | |
36 | { "1", 1}, | |
37 | { "mirror", 1}, | |
38 | { "raid4", 4}, | |
39 | { "4", 4}, | |
40 | { "raid5", 5}, | |
41 | { "5", 5}, | |
df0d4ea0 N |
42 | { "multipath", LEVEL_MULTIPATH}, |
43 | { "mp", LEVEL_MULTIPATH}, | |
b5e64645 NB |
44 | { "raid6", 6}, |
45 | { "6", 6}, | |
46 | { "raid10", 10}, | |
47 | { "10", 10}, | |
98c6faba NB |
48 | { NULL, 0} |
49 | }; | |
50 | ||
b5e64645 | 51 | #ifndef MDASSEMBLE_AUTO |
b56c3630 | 52 | /* from mdopen.c */ |
7f91af49 | 53 | int open_mddev(char *dev, int report_errors/*unused*/) |
98c6faba | 54 | { |
fb97b4d6 | 55 | int mdfd = open(dev, O_RDWR); |
98c6faba NB |
56 | if (mdfd < 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", | |
61 | dev); | |
62 | close(mdfd); | |
63 | mdfd = -1; | |
64 | } | |
65 | return mdfd; | |
66 | } | |
69207ff6 N |
67 | int create_mddev(char *dev, char *name, int autof/*unused*/, int trustworthy, |
68 | char *chosen) | |
7f91af49 N |
69 | { |
70 | return open_mddev(dev, 0); | |
71 | } | |
b5e64645 | 72 | #endif |
a04d5763 N |
73 | int map_update(struct map_ent **mpp, int devnum, char *metadata, |
74 | int *uuid, char *path) | |
75 | { | |
76 | return 0; | |
77 | } | |
f2e55ecc N |
78 | struct map_ent *map_by_name(struct map_ent **mpp, char *name) |
79 | { | |
80 | return NULL; | |
81 | } | |
98c6faba | 82 | |
98c6faba NB |
83 | int rv; |
84 | int mdfd = -1; | |
85 | int runstop = 0; | |
86 | int readonly = 0; | |
87 | int verbose = 0; | |
88 | int force = 0; | |
89 | ||
b56c3630 | 90 | int main(int argc, char *argv[]) { |
fa56eddb | 91 | struct mddev_ident *array_list = conf_get_ident(NULL); |
98c6faba NB |
92 | if (!array_list) { |
93 | fprintf(stderr, Name ": No arrays found in config file\n"); | |
94 | rv = 1; | |
95 | } else | |
96 | for (; array_list; array_list = array_list->next) { | |
97 | mdu_array_info_t array; | |
112cace6 N |
98 | if (strcasecmp(array_list->devname, "<ignore>") == 0) |
99 | continue; | |
7f91af49 N |
100 | mdfd = open_mddev(array_list->devname, 0); |
101 | if (mdfd >= 0 && ioctl(mdfd, GET_ARRAY_INFO, &array) == 0) { | |
435d4ebb | 102 | rv |= Manage_ro(array_list->devname, mdfd, -1); /* make it readwrite */ |
7f91af49 | 103 | continue; |
435d4ebb | 104 | } |
7f91af49 N |
105 | if (mdfd >= 0) |
106 | close(mdfd); | |
107 | rv |= Assemble(array_list->st, array_list->devname, | |
71204a50 | 108 | array_list, NULL, NULL, 0, |
0ac91628 N |
109 | readonly, runstop, NULL, NULL, 0, |
110 | verbose, force); | |
98c6faba | 111 | } |
b56c3630 | 112 | return rv; |
98c6faba | 113 | } |