]>
git.ipfire.org Git - thirdparty/mdadm.git/blob - Examine.c
2 * mdadm - manage Linux "md" devices aka RAID arrays.
4 * Copyright (C) 2001-2002 Neil Brown <neilb@cse.unsw.edu.au>
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@cse.unsw.edu.au>
24 * School of Computer Science and Engineering
25 * The University of New South Wales
33 #if ! defined(__BIG_ENDIAN) && ! defined(__LITTLE_ENDIAN)
34 #error no endian defined
38 int Examine(mddev_dev_t devlist
, int brief
, int scan
, int SparcAdjust
, struct supertype
*forcest
)
41 /* Read the raid superblock from a device and
42 * display important content.
44 * If cannot be found, print reason: too small, bad magic
47 * version, ctime, level, size, raid+spare+
53 * If (brief) gather devices for same array and just print a mdadm.conf line including devices=
54 * if devlist==NULL, use conf_get_devs()
70 for (; devlist
; devlist
=devlist
->next
) {
71 struct supertype
*st
= forcest
;
73 fd
= dev_open(devlist
->devname
, O_RDONLY
);
76 fprintf(stderr
,Name
": cannot open %s: %s\n",
77 devlist
->devname
, strerror(errno
));
84 err
= st
->ss
->load_super(st
, fd
, &super
, (brief
||scan
)?NULL
:devlist
->devname
);
87 fprintf(stderr
, Name
": No md superblock detected on %s.\n", devlist
->devname
);
98 st
->ss
->update_super(NULL
, super
, "sparc2.2", devlist
->devname
, 0);
99 /* Ok, its good enough to try, though the checksum could be wrong */
103 for (ap
=arrays
; ap
; ap
=ap
->next
) {
104 if (st
->ss
== ap
->st
->ss
&& st
->ss
->compare_super(&ap
->super
, super
)==0)
108 ap
= malloc(sizeof(*ap
));
110 ap
->devs
= dl_head();
115 st
->ss
->getinfo_super(&ap
->info
, super
);
117 st
->ss
->getinfo_super(&ap
->info
, super
);
120 if (!(ap
->info
.disk
.state
& MD_DISK_SYNC
))
122 d
= dl_strdup(devlist
->devname
);
125 printf("%s:\n",devlist
->devname
);
126 st
->ss
->examine_super(super
);
132 for (ap
=arrays
; ap
; ap
=ap
->next
) {
135 ap
->st
->ss
->brief_examine_super(ap
->super
);
136 if (ap
->spares
) printf(" spares=%d", ap
->spares
);
139 for (d
=dl_next(ap
->devs
); d
!= ap
->devs
; d
=dl_next(d
)) {
140 printf("%c%s", sep
, d
);
146 if (ap
->spares
|| brief
> 1)