]>
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(struct mddev_dev
*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
) {
67 int have_container
= 0;
69 fd
= dev_open(devlist
->devname
, O_RDONLY
);
72 fprintf(stderr
,Name
": cannot open %s: %s\n",
73 devlist
->devname
, strerror(errno
));
81 st
= dup_super(forcest
);
82 else if (must_be_container(fd
)) {
83 /* might be a container */
84 st
= super_by_fd(fd
, NULL
);
90 st
->ignore_hw_compat
= 1;
92 err
= st
->ss
->load_super(st
, fd
,
95 if (err
&& st
->ss
->load_container
) {
96 err
= st
->ss
->load_container(st
, fd
,
102 st
->ignore_hw_compat
= 0;
105 fprintf(stderr
, Name
": No md superblock detected on %s.\n", devlist
->devname
);
116 st
->ss
->update_super(st
, NULL
, "sparc2.2",
117 devlist
->devname
, 0, 0, NULL
);
118 /* Ok, its good enough to try, though the checksum could be wrong */
120 if (brief
&& st
->ss
->brief_examine_super
== NULL
) {
122 fprintf(stderr
, Name
": No brief listing for %s on %s\n",
123 st
->ss
->name
, devlist
->devname
);
127 for (ap
=arrays
; ap
; ap
=ap
->next
) {
128 if (st
->ss
== ap
->st
->ss
&&
129 st
->ss
->compare_super(ap
->st
, st
)==0)
133 ap
= malloc(sizeof(*ap
));
134 ap
->devs
= dl_head();
139 st
->ss
->getinfo_super(st
, &ap
->info
, NULL
);
141 st
->ss
->getinfo_super(st
, &ap
->info
, NULL
);
142 if (!have_container
&&
143 !(ap
->info
.disk
.state
& (1<<MD_DISK_SYNC
)))
145 d
= dl_strdup(devlist
->devname
);
148 if (st
->ss
->export_examine_super
)
149 st
->ss
->export_examine_super(st
);
150 st
->ss
->free_super(st
);
152 printf("%s:\n",devlist
->devname
);
153 st
->ss
->examine_super(st
, homehost
);
154 st
->ss
->free_super(st
);
159 for (ap
=arrays
; ap
; ap
=ap
->next
) {
164 ap
->st
->ss
->brief_examine_super(ap
->st
, brief
> 1);
166 newline
+= printf(" spares=%d", ap
->spares
);
168 newline
+= printf(" devices");
169 for (d
=dl_next(ap
->devs
); d
!= ap
->devs
; d
=dl_next(d
)) {
170 printf("%c%s", sep
, d
);
174 if (ap
->st
->ss
->brief_examine_subarrays
) {
177 ap
->st
->ss
->brief_examine_subarrays(ap
->st
, brief
> 1);
179 ap
->st
->ss
->free_super(ap
->st
);
181 if (ap
->spares
|| brief
> 1)