]>
git.ipfire.org Git - thirdparty/mdadm.git/blob - Examine.c
2 * mdadm - manage Linux "md" devices aka RAID arrays.
4 * Copyright (C) 2001-2009 Neil Brown <neilb@suse.de>
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.
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.
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
22 * Email: <neilb@suse.de>
28 #if ! defined(__BIG_ENDIAN) && ! defined(__LITTLE_ENDIAN)
29 #error no endian defined
33 int Examine(mddev_dev_t devlist
, int brief
, int export
, int scan
,
34 int SparcAdjust
, struct supertype
*forcest
,
38 /* Read the raid superblock from a device and
39 * display important content.
41 * If cannot be found, print reason: too small, bad magic
44 * version, ctime, level, size, raid+spare+
50 * If (brief) gather devices for same array and just print a mdadm.conf line including devices=
51 * if devlist==NULL, use conf_get_devs()
65 for (; devlist
; devlist
=devlist
->next
) {
68 fd
= dev_open(devlist
->devname
, O_RDONLY
);
71 fprintf(stderr
,Name
": cannot open %s: %s\n",
72 devlist
->devname
, strerror(errno
));
79 st
= dup_super(forcest
);
83 err
= st
->ss
->load_super(st
, fd
,
88 fprintf(stderr
, Name
": No md superblock detected on %s.\n", devlist
->devname
);
99 st
->ss
->update_super(st
, NULL
, "sparc2.2",
100 devlist
->devname
, 0, 0, NULL
);
101 /* Ok, its good enough to try, though the checksum could be wrong */
103 if (brief
&& st
->ss
->brief_examine_super
== NULL
) {
105 fprintf(stderr
, Name
": No brief listing for %s on %s\n",
106 st
->ss
->name
, devlist
->devname
);
110 for (ap
=arrays
; ap
; ap
=ap
->next
) {
111 if (st
->ss
== ap
->st
->ss
&&
112 st
->ss
->compare_super(ap
->st
, st
)==0)
116 ap
= malloc(sizeof(*ap
));
117 ap
->devs
= dl_head();
122 st
->ss
->getinfo_super(st
, &ap
->info
);
124 st
->ss
->getinfo_super(st
, &ap
->info
);
125 if (!st
->loaded_container
&&
126 !(ap
->info
.disk
.state
& (1<<MD_DISK_SYNC
)))
128 d
= dl_strdup(devlist
->devname
);
131 if (st
->ss
->export_examine_super
)
132 st
->ss
->export_examine_super(st
);
134 printf("%s:\n",devlist
->devname
);
135 st
->ss
->examine_super(st
, homehost
);
136 st
->ss
->free_super(st
);
141 for (ap
=arrays
; ap
; ap
=ap
->next
) {
146 ap
->st
->ss
->brief_examine_super(ap
->st
, brief
> 1);
148 newline
+= printf(" spares=%d", ap
->spares
);
150 newline
+= printf(" devices");
151 for (d
=dl_next(ap
->devs
); d
!= ap
->devs
; d
=dl_next(d
)) {
152 printf("%c%s", sep
, d
);
156 if (ap
->st
->ss
->brief_examine_subarrays
) {
159 ap
->st
->ss
->brief_examine_subarrays(ap
->st
, brief
> 1);
161 ap
->st
->ss
->free_super(ap
->st
);
163 if (ap
->spares
|| brief
> 1)