]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * mdadm - manage Linux "md" devices aka RAID arrays. | |
3 | * | |
4 | * Copyright (C) 2001-2009 Neil Brown <neilb@suse.de> | |
5 | * | |
6 | * | |
7 | * This program is free software; you can redistribute it and/or modify | |
8 | * it under the terms of the GNU General Public License as published by | |
9 | * the Free Software Foundation; either version 2 of the License, or | |
10 | * (at your option) any later version. | |
11 | * | |
12 | * This program is distributed in the hope that it will be useful, | |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | * GNU General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public License | |
18 | * along with this program; if not, write to the Free Software | |
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
20 | * | |
21 | * Author: Neil Brown | |
22 | * Email: <neilb@suse.de> | |
23 | */ | |
24 | ||
25 | #include "mdadm.h" | |
26 | #include "md_p.h" | |
27 | #include "md_u.h" | |
28 | #include <dirent.h> | |
29 | ||
30 | int Detail(char *dev, int brief, int export, int test, char *homehost) | |
31 | { | |
32 | /* | |
33 | * Print out details for an md array by using | |
34 | * GET_ARRAY_INFO and GET_DISK_INFO ioctl calls | |
35 | */ | |
36 | ||
37 | int fd = open(dev, O_RDONLY); | |
38 | int vers; | |
39 | mdu_array_info_t array; | |
40 | mdu_disk_info_t *disks; | |
41 | int next; | |
42 | int d; | |
43 | time_t atime; | |
44 | char *c; | |
45 | char *devices = NULL; | |
46 | int spares = 0; | |
47 | struct stat stb; | |
48 | int is_26 = get_linux_version() >= 2006000; | |
49 | int is_rebuilding = 0; | |
50 | int failed = 0; | |
51 | struct supertype *st; | |
52 | char *subarray = NULL; | |
53 | int max_disks = MD_SB_DISKS; /* just a default */ | |
54 | struct mdinfo *info = NULL; | |
55 | struct mdinfo *sra; | |
56 | char *member = NULL; | |
57 | char *container = NULL; | |
58 | ||
59 | int rv = test ? 4 : 1; | |
60 | int avail_disks = 0; | |
61 | char *avail; | |
62 | ||
63 | if (fd < 0) { | |
64 | fprintf(stderr, Name ": cannot open %s: %s\n", | |
65 | dev, strerror(errno)); | |
66 | return rv; | |
67 | } | |
68 | vers = md_get_version(fd); | |
69 | if (vers < 0) { | |
70 | fprintf(stderr, Name ": %s does not appear to be an md device\n", | |
71 | dev); | |
72 | close(fd); | |
73 | return rv; | |
74 | } | |
75 | if (vers < 9000) { | |
76 | fprintf(stderr, Name ": cannot get detail for md device %s: driver version too old.\n", | |
77 | dev); | |
78 | close(fd); | |
79 | return rv; | |
80 | } | |
81 | if (ioctl(fd, GET_ARRAY_INFO, &array)<0) { | |
82 | if (errno == ENODEV) | |
83 | fprintf(stderr, Name ": md device %s does not appear to be active.\n", | |
84 | dev); | |
85 | else | |
86 | fprintf(stderr, Name ": cannot get array detail for %s: %s\n", | |
87 | dev, strerror(errno)); | |
88 | close(fd); | |
89 | return rv; | |
90 | } | |
91 | sra = sysfs_read(fd, 0, GET_VERSION); | |
92 | st = super_by_fd(fd, &subarray); | |
93 | ||
94 | if (fstat(fd, &stb) != 0 && !S_ISBLK(stb.st_mode)) | |
95 | stb.st_rdev = 0; | |
96 | rv = 0; | |
97 | ||
98 | if (st) | |
99 | max_disks = st->max_devs; | |
100 | ||
101 | if (subarray) { | |
102 | /* This is a subarray of some container. | |
103 | * We want the name of the container, and the member | |
104 | */ | |
105 | int dn = st->container_dev; | |
106 | ||
107 | member = subarray; | |
108 | container = map_dev(dev2major(dn), dev2minor(dn), 1); | |
109 | } | |
110 | ||
111 | /* try to load a superblock */ | |
112 | if (st) for (d = 0; d < max_disks; d++) { | |
113 | mdu_disk_info_t disk; | |
114 | char *dv; | |
115 | int fd2; | |
116 | int err; | |
117 | disk.number = d; | |
118 | if (ioctl(fd, GET_DISK_INFO, &disk) < 0) | |
119 | continue; | |
120 | if (d >= array.raid_disks && | |
121 | disk.major == 0 && | |
122 | disk.minor == 0) | |
123 | continue; | |
124 | ||
125 | if (array.raid_disks > 0 && | |
126 | (disk.state & (1 << MD_DISK_ACTIVE)) == 0) | |
127 | continue; | |
128 | ||
129 | dv = map_dev(disk.major, disk.minor, 1); | |
130 | if (!dv) | |
131 | continue; | |
132 | ||
133 | fd2 = dev_open(dv, O_RDONLY); | |
134 | if (fd2 < 0) | |
135 | continue; | |
136 | ||
137 | if (st->sb) | |
138 | st->ss->free_super(st); | |
139 | ||
140 | err = st->ss->load_super(st, fd2, NULL); | |
141 | close(fd2); | |
142 | if (err) | |
143 | continue; | |
144 | if (info) | |
145 | free(info); | |
146 | if (subarray) | |
147 | info = st->ss->container_content(st, subarray); | |
148 | else { | |
149 | info = malloc(sizeof(*info)); | |
150 | st->ss->getinfo_super(st, info, NULL); | |
151 | } | |
152 | if (!info) | |
153 | continue; | |
154 | ||
155 | if (array.raid_disks != 0 && /* container */ | |
156 | (info->array.ctime != array.ctime || | |
157 | info->array.level != array.level)) { | |
158 | st->ss->free_super(st); | |
159 | continue; | |
160 | } | |
161 | /* some formats (imsm) have free-floating-spares | |
162 | * with a uuid of uuid_zero, they don't | |
163 | * have very good info about the rest of the | |
164 | * container, so keep searching when | |
165 | * encountering such a device. Otherwise, stop | |
166 | * after the first successful call to | |
167 | * ->load_super. | |
168 | */ | |
169 | if (memcmp(uuid_zero, | |
170 | info->uuid, | |
171 | sizeof(uuid_zero)) == 0) { | |
172 | st->ss->free_super(st); | |
173 | continue; | |
174 | } | |
175 | break; | |
176 | } | |
177 | ||
178 | /* Ok, we have some info to print... */ | |
179 | c = map_num(pers, array.level); | |
180 | ||
181 | if (export) { | |
182 | if (array.raid_disks) { | |
183 | if (c) | |
184 | printf("MD_LEVEL=%s\n", c); | |
185 | printf("MD_DEVICES=%d\n", array.raid_disks); | |
186 | } else { | |
187 | printf("MD_LEVEL=container\n"); | |
188 | printf("MD_DEVICES=%d\n", array.nr_disks); | |
189 | } | |
190 | if (container) { | |
191 | printf("MD_CONTAINER=%s\n", container); | |
192 | printf("MD_MEMBER=%s\n", member); | |
193 | } else { | |
194 | if (sra && sra->array.major_version < 0) | |
195 | printf("MD_METADATA=%s\n", sra->text_version); | |
196 | else | |
197 | printf("MD_METADATA=%d.%d\n", | |
198 | array.major_version, array.minor_version); | |
199 | } | |
200 | ||
201 | if (st && st->sb && info) { | |
202 | char nbuf[64]; | |
203 | struct map_ent *mp, *map = NULL; | |
204 | ||
205 | fname_from_uuid(st, info, nbuf, ':'); | |
206 | printf("MD_UUID=%s\n", nbuf+5); | |
207 | mp = map_by_uuid(&map, info->uuid); | |
208 | if (mp && mp->path && | |
209 | strncmp(mp->path, "/dev/md/", 8) == 0) | |
210 | printf("MD_DEVNAME=%s\n", mp->path+8); | |
211 | ||
212 | if (st->ss->export_detail_super) | |
213 | st->ss->export_detail_super(st); | |
214 | } else { | |
215 | struct map_ent *mp, *map = NULL; | |
216 | char nbuf[64]; | |
217 | mp = map_by_devnum(&map, fd2devnum(fd)); | |
218 | if (mp) { | |
219 | __fname_from_uuid(mp->uuid, 0, nbuf, ':'); | |
220 | printf("MD_UUID=%s\n", nbuf+5); | |
221 | } | |
222 | if (mp && mp->path && | |
223 | strncmp(mp->path, "/dev/md/", 8) == 0) | |
224 | printf("MD_DEVNAME=%s\n", mp->path+8); | |
225 | } | |
226 | goto out; | |
227 | } | |
228 | ||
229 | disks = malloc(max_disks * sizeof(mdu_disk_info_t)); | |
230 | for (d=0; d<max_disks; d++) { | |
231 | disks[d].state = (1<<MD_DISK_REMOVED); | |
232 | disks[d].major = disks[d].minor = 0; | |
233 | disks[d].number = disks[d].raid_disk = d; | |
234 | } | |
235 | ||
236 | next = array.raid_disks; | |
237 | for (d=0; d < max_disks; d++) { | |
238 | mdu_disk_info_t disk; | |
239 | disk.number = d; | |
240 | if (ioctl(fd, GET_DISK_INFO, &disk) < 0) { | |
241 | if (d < array.raid_disks) | |
242 | fprintf(stderr, Name ": cannot get device detail for device %d: %s\n", | |
243 | d, strerror(errno)); | |
244 | continue; | |
245 | } | |
246 | if (disk.major == 0 && disk.minor == 0) | |
247 | continue; | |
248 | if (disk.raid_disk >= 0 && disk.raid_disk < array.raid_disks) | |
249 | disks[disk.raid_disk] = disk; | |
250 | else if (next < max_disks) | |
251 | disks[next++] = disk; | |
252 | } | |
253 | ||
254 | avail = calloc(array.raid_disks, 1); | |
255 | ||
256 | for (d= 0; d < array.raid_disks; d++) { | |
257 | mdu_disk_info_t disk = disks[d]; | |
258 | ||
259 | if ((disk.state & (1<<MD_DISK_SYNC))) { | |
260 | avail_disks ++; | |
261 | avail[d] = 1; | |
262 | } | |
263 | } | |
264 | ||
265 | if (brief) { | |
266 | mdu_bitmap_file_t bmf; | |
267 | printf("ARRAY %s", dev); | |
268 | if (brief > 1) { | |
269 | if (array.raid_disks) | |
270 | printf(" level=%s num-devices=%d", | |
271 | c?c:"-unknown-", | |
272 | array.raid_disks ); | |
273 | else | |
274 | printf(" level=container num-devices=%d", | |
275 | array.nr_disks); | |
276 | } | |
277 | if (container) { | |
278 | printf(" container=%s", container); | |
279 | printf(" member=%s", member); | |
280 | } else { | |
281 | if (sra && sra->array.major_version < 0) | |
282 | printf(" metadata=%s", sra->text_version); | |
283 | else | |
284 | printf(" metadata=%d.%d", | |
285 | array.major_version, array.minor_version); | |
286 | } | |
287 | ||
288 | /* Only try GET_BITMAP_FILE for 0.90.01 and later */ | |
289 | if (vers >= 9001 && | |
290 | ioctl(fd, GET_BITMAP_FILE, &bmf) == 0 && | |
291 | bmf.pathname[0]) { | |
292 | printf(" bitmap=%s", bmf.pathname); | |
293 | } | |
294 | } else { | |
295 | mdu_bitmap_file_t bmf; | |
296 | unsigned long long larray_size; | |
297 | struct mdstat_ent *ms = mdstat_read(0, 0); | |
298 | struct mdstat_ent *e; | |
299 | int devnum = array.md_minor; | |
300 | if (major(stb.st_rdev) == (unsigned)get_mdp_major()) | |
301 | devnum = -1 - devnum; | |
302 | ||
303 | for (e=ms; e; e=e->next) | |
304 | if (e->devnum == devnum) | |
305 | break; | |
306 | if (!get_dev_size(fd, NULL, &larray_size)) | |
307 | larray_size = 0; | |
308 | ||
309 | printf("%s:\n", dev); | |
310 | ||
311 | if (container) | |
312 | printf(" Container : %s, member %s\n", container, member); | |
313 | else { | |
314 | if (sra && sra->array.major_version < 0) | |
315 | printf(" Version : %s\n", sra->text_version); | |
316 | else | |
317 | printf(" Version : %d.%d\n", | |
318 | array.major_version, array.minor_version); | |
319 | } | |
320 | ||
321 | atime = array.ctime; | |
322 | if (atime) | |
323 | printf(" Creation Time : %.24s\n", ctime(&atime)); | |
324 | if (array.raid_disks == 0) c = "container"; | |
325 | printf(" Raid Level : %s\n", c?c:"-unknown-"); | |
326 | if (larray_size) | |
327 | printf(" Array Size : %llu%s\n", (larray_size>>10), human_size(larray_size)); | |
328 | if (array.level >= 1) { | |
329 | if (array.major_version != 0 && | |
330 | (larray_size >= 0xFFFFFFFFULL|| array.size == 0)) { | |
331 | unsigned long long dsize = get_component_size(fd); | |
332 | if (dsize > 0) | |
333 | printf(" Used Dev Size : %llu%s\n", | |
334 | dsize/2, | |
335 | human_size((long long)dsize<<9)); | |
336 | else | |
337 | printf(" Used Dev Size : unknown\n"); | |
338 | } else | |
339 | printf(" Used Dev Size : %d%s\n", array.size, | |
340 | human_size((long long)array.size<<10)); | |
341 | } | |
342 | if (array.raid_disks) | |
343 | printf(" Raid Devices : %d\n", array.raid_disks); | |
344 | printf(" Total Devices : %d\n", array.nr_disks); | |
345 | if (!container && | |
346 | ((sra == NULL && array.major_version == 0) || | |
347 | (sra && sra->array.major_version == 0))) | |
348 | printf("Preferred Minor : %d\n", array.md_minor); | |
349 | if (sra == NULL || sra->array.major_version >= 0) | |
350 | printf(" Persistence : Superblock is %spersistent\n", | |
351 | array.not_persistent?"not ":""); | |
352 | printf("\n"); | |
353 | /* Only try GET_BITMAP_FILE for 0.90.01 and later */ | |
354 | if (vers >= 9001 && | |
355 | ioctl(fd, GET_BITMAP_FILE, &bmf) == 0 && | |
356 | bmf.pathname[0]) { | |
357 | printf(" Intent Bitmap : %s\n", bmf.pathname); | |
358 | printf("\n"); | |
359 | } else if (array.state & (1<<MD_SB_BITMAP_PRESENT)) | |
360 | printf(" Intent Bitmap : Internal\n\n"); | |
361 | atime = array.utime; | |
362 | if (atime) | |
363 | printf(" Update Time : %.24s\n", ctime(&atime)); | |
364 | if (array.raid_disks) { | |
365 | static char *sync_action[] = {", recovering",", resyncing",", reshaping",", checking"}; | |
366 | char *st; | |
367 | if (avail_disks == array.raid_disks) | |
368 | st = ""; | |
369 | else if (!enough(array.level, array.raid_disks, | |
370 | array.layout, 1, avail, avail_disks)) | |
371 | st = ", FAILED"; | |
372 | else | |
373 | st = ", degraded"; | |
374 | ||
375 | printf(" State : %s%s%s%s%s%s \n", | |
376 | (array.state&(1<<MD_SB_CLEAN))?"clean":"active", st, | |
377 | (!e || (e->percent < 0 && e->percent != PROCESS_PENDING && | |
378 | e->percent != PROCESS_DELAYED)) ? "" : sync_action[e->resync], | |
379 | larray_size ? "": ", Not Started", | |
380 | e->percent == PROCESS_DELAYED ? " (DELAYED)": "", | |
381 | e->percent == PROCESS_PENDING ? " (PENDING)": ""); | |
382 | } | |
383 | if (array.raid_disks) | |
384 | printf(" Active Devices : %d\n", array.active_disks); | |
385 | printf("Working Devices : %d\n", array.working_disks); | |
386 | if (array.raid_disks) { | |
387 | printf(" Failed Devices : %d\n", array.failed_disks); | |
388 | printf(" Spare Devices : %d\n", array.spare_disks); | |
389 | } | |
390 | printf("\n"); | |
391 | if (array.level == 5) { | |
392 | c = map_num(r5layout, array.layout); | |
393 | printf(" Layout : %s\n", c?c:"-unknown-"); | |
394 | } | |
395 | if (array.level == 6) { | |
396 | c = map_num(r6layout, array.layout); | |
397 | printf(" Layout : %s\n", c?c:"-unknown-"); | |
398 | } | |
399 | if (array.level == 10) { | |
400 | printf(" Layout :"); | |
401 | print_r10_layout(array.layout); | |
402 | printf("\n"); | |
403 | } | |
404 | switch (array.level) { | |
405 | case 0: | |
406 | case 4: | |
407 | case 5: | |
408 | case 10: | |
409 | case 6: | |
410 | if (array.chunk_size) | |
411 | printf(" Chunk Size : %dK\n\n", | |
412 | array.chunk_size/1024); | |
413 | break; | |
414 | case -1: | |
415 | printf(" Rounding : %dK\n\n", array.chunk_size/1024); | |
416 | break; | |
417 | default: break; | |
418 | } | |
419 | ||
420 | if (e && e->percent >= 0) { | |
421 | static char *sync_action[] = {"Rebuild", "Resync", "Reshape", "Check"}; | |
422 | printf(" %7s Status : %d%% complete\n", sync_action[e->resync], e->percent); | |
423 | is_rebuilding = 1; | |
424 | } | |
425 | free_mdstat(ms); | |
426 | ||
427 | if (st->sb && info->reshape_active) { | |
428 | #if 0 | |
429 | This is pretty boring | |
430 | printf(" Reshape pos'n : %llu%s\n", (unsigned long long) info->reshape_progress<<9, | |
431 | human_size((unsigned long long)info->reshape_progress<<9)); | |
432 | #endif | |
433 | if (info->delta_disks != 0) | |
434 | printf(" Delta Devices : %d, (%d->%d)\n", | |
435 | info->delta_disks, array.raid_disks - info->delta_disks, array.raid_disks); | |
436 | if (info->new_level != array.level) { | |
437 | char *c = map_num(pers, info->new_level); | |
438 | printf(" New Level : %s\n", c?c:"-unknown-"); | |
439 | } | |
440 | if (info->new_level != array.level || | |
441 | info->new_layout != array.layout) { | |
442 | if (info->new_level == 5) { | |
443 | char *c = map_num(r5layout, info->new_layout); | |
444 | printf(" New Layout : %s\n", | |
445 | c?c:"-unknown-"); | |
446 | } | |
447 | if (info->new_level == 6) { | |
448 | char *c = map_num(r6layout, info->new_layout); | |
449 | printf(" New Layout : %s\n", | |
450 | c?c:"-unknown-"); | |
451 | } | |
452 | if (info->new_level == 10) { | |
453 | printf(" New Layout : near=%d, %s=%d\n", | |
454 | info->new_layout&255, | |
455 | (info->new_layout&0x10000)?"offset":"far", | |
456 | (info->new_layout>>8)&255); | |
457 | } | |
458 | } | |
459 | if (info->new_chunk != array.chunk_size) | |
460 | printf(" New Chunksize : %dK\n", info->new_chunk/1024); | |
461 | printf("\n"); | |
462 | } else if (e && e->percent >= 0) | |
463 | printf("\n"); | |
464 | if (st && st->sb) | |
465 | st->ss->detail_super(st, homehost); | |
466 | ||
467 | if (array.raid_disks == 0 && sra && sra->array.major_version == -1 | |
468 | && sra->array.minor_version == -2 && sra->text_version[0] != '/') { | |
469 | /* This looks like a container. Find any active arrays | |
470 | * That claim to be a member. | |
471 | */ | |
472 | DIR *dir = opendir("/sys/block"); | |
473 | struct dirent *de; | |
474 | ||
475 | printf(" Member Arrays :"); | |
476 | ||
477 | while (dir && (de = readdir(dir)) != NULL) { | |
478 | char path[200]; | |
479 | char vbuf[1024]; | |
480 | int nlen = strlen(sra->sys_name); | |
481 | int dn; | |
482 | if (de->d_name[0] == '.') | |
483 | continue; | |
484 | sprintf(path, "/sys/block/%s/md/metadata_version", | |
485 | de->d_name); | |
486 | if (load_sys(path, vbuf) < 0) | |
487 | continue; | |
488 | if (strncmp(vbuf, "external:", 9) != 0 || | |
489 | !is_subarray(vbuf+9) || | |
490 | strncmp(vbuf+10, sra->sys_name, nlen) != 0 || | |
491 | vbuf[10+nlen] != '/') | |
492 | continue; | |
493 | dn = devname2devnum(de->d_name); | |
494 | printf(" %s", map_dev(dev2major(dn), | |
495 | dev2minor(dn), 1)); | |
496 | } | |
497 | if (dir) | |
498 | closedir(dir); | |
499 | printf("\n\n"); | |
500 | } | |
501 | ||
502 | if (array.raid_disks) | |
503 | printf(" Number Major Minor RaidDevice State\n"); | |
504 | else | |
505 | printf(" Number Major Minor RaidDevice\n"); | |
506 | } | |
507 | free(info); | |
508 | ||
509 | for (d= 0; d < max_disks; d++) { | |
510 | char *dv; | |
511 | mdu_disk_info_t disk = disks[d]; | |
512 | ||
513 | if (d >= array.raid_disks && | |
514 | disk.major == 0 && | |
515 | disk.minor == 0) | |
516 | continue; | |
517 | if (!brief) { | |
518 | if (d == array.raid_disks) printf("\n"); | |
519 | if (disk.raid_disk < 0) | |
520 | printf(" %5d %5d %5d - ", | |
521 | disk.number, disk.major, disk.minor); | |
522 | else | |
523 | printf(" %5d %5d %5d %5d ", | |
524 | disk.number, disk.major, disk.minor, disk.raid_disk); | |
525 | } | |
526 | if (!brief && array.raid_disks) { | |
527 | ||
528 | if (disk.state & (1<<MD_DISK_FAULTY)) { | |
529 | printf(" faulty"); | |
530 | if (disk.raid_disk < array.raid_disks && | |
531 | disk.raid_disk >= 0) | |
532 | failed++; | |
533 | } | |
534 | if (disk.state & (1<<MD_DISK_ACTIVE)) printf(" active"); | |
535 | if (disk.state & (1<<MD_DISK_SYNC)) printf(" sync"); | |
536 | if (disk.state & (1<<MD_DISK_REMOVED)) printf(" removed"); | |
537 | if (disk.state & (1<<MD_DISK_WRITEMOSTLY)) printf(" writemostly"); | |
538 | if ((disk.state & | |
539 | ((1<<MD_DISK_ACTIVE)|(1<<MD_DISK_SYNC)|(1<<MD_DISK_REMOVED))) | |
540 | == 0) { | |
541 | printf(" spare"); | |
542 | if (is_26) { | |
543 | if (disk.raid_disk < array.raid_disks && disk.raid_disk >= 0) | |
544 | printf(" rebuilding"); | |
545 | } else if (is_rebuilding && failed) { | |
546 | /* Taking a bit of a risk here, we remove the | |
547 | * device from the array, and then put it back. | |
548 | * If this fails, we are rebuilding | |
549 | */ | |
550 | int err = ioctl(fd, HOT_REMOVE_DISK, makedev(disk.major, disk.minor)); | |
551 | if (err == 0) ioctl(fd, HOT_ADD_DISK, makedev(disk.major, disk.minor)); | |
552 | if (err && errno == EBUSY) | |
553 | printf(" rebuilding"); | |
554 | } | |
555 | } | |
556 | } | |
557 | if (disk.state == 0) spares++; | |
558 | if (test && d < array.raid_disks | |
559 | && !(disk.state & (1<<MD_DISK_SYNC))) | |
560 | rv |= 1; | |
561 | if ((dv=map_dev(disk.major, disk.minor, 0))) { | |
562 | if (brief) { | |
563 | if (devices) { | |
564 | devices = realloc(devices, | |
565 | strlen(devices)+1+strlen(dv)+1); | |
566 | strcat(strcat(devices,","),dv); | |
567 | } else | |
568 | devices = strdup(dv); | |
569 | } else | |
570 | printf(" %s", dv); | |
571 | } | |
572 | if (!brief) printf("\n"); | |
573 | } | |
574 | if (spares && brief && array.raid_disks) printf(" spares=%d", spares); | |
575 | if (brief && st && st->sb) | |
576 | st->ss->brief_detail_super(st); | |
577 | st->ss->free_super(st); | |
578 | ||
579 | if (brief > 1 && devices) printf("\n devices=%s", devices); | |
580 | if (brief) printf("\n"); | |
581 | if (test && | |
582 | !enough(array.level, array.raid_disks, array.layout, | |
583 | 1, avail, avail_disks)) | |
584 | rv = 2; | |
585 | ||
586 | free(disks); | |
587 | out: | |
588 | close(fd); | |
589 | free(subarray); | |
590 | return rv; | |
591 | } | |
592 | ||
593 | int Detail_Platform(struct superswitch *ss, int scan, int verbose) | |
594 | { | |
595 | /* display platform capabilities for the given metadata format | |
596 | * 'scan' in this context means iterate over all metadata types | |
597 | */ | |
598 | int i; | |
599 | int err = 1; | |
600 | ||
601 | if (ss && ss->detail_platform) | |
602 | err = ss->detail_platform(verbose, 0); | |
603 | else if (ss) { | |
604 | if (verbose) | |
605 | fprintf(stderr, Name ": %s metadata is platform independent\n", | |
606 | ss->name ? : "[no name]"); | |
607 | } else if (!scan) { | |
608 | if (verbose) | |
609 | fprintf(stderr, Name ": specify a metadata type or --scan\n"); | |
610 | } | |
611 | ||
612 | if (!scan) | |
613 | return err; | |
614 | ||
615 | for (i = 0; superlist[i]; i++) { | |
616 | struct superswitch *meta = superlist[i]; | |
617 | ||
618 | if (meta == ss) | |
619 | continue; | |
620 | if (verbose) | |
621 | fprintf(stderr, Name ": checking metadata %s\n", | |
622 | meta->name ? : "[no name]"); | |
623 | if (!meta->detail_platform) { | |
624 | if (verbose) | |
625 | fprintf(stderr, Name ": %s metadata is platform independent\n", | |
626 | meta->name ? : "[no name]"); | |
627 | } else | |
628 | err |= meta->detail_platform(verbose, 0); | |
629 | } | |
630 | ||
631 | return err; | |
632 | } |