]>
git.ipfire.org Git - thirdparty/mdadm.git/blob - Examine.c
2 * mdctl - manage Linux "md" devices aka RAID arrays.
4 * Copyright (C) 2001 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
34 int Examine(char *dev
)
37 /* Read the raid superblock from a device and
38 * display important content.
40 * If cannot be found, print reason: too small, bad magic
43 * version, ctime, level, size, raid+spare+
50 int fd
= open(dev
, O_RDONLY
, 0);
58 fprintf(stderr
,Name
": cannot open %s: %s\n",
59 dev
, strerror(errno
));
63 rv
= load_super(fd
, &super
);
67 fprintf(stderr
, Name
": cannot find device size for %s: %s\n",
68 dev
, strerror(errno
));
71 /* fprintf(stderr, Name ": %s is too small for md: size is %ld sectors\n",
74 fprintf(stderr
, Name
": %s is too small for md\n",
78 fprintf(stderr
, Name
": Cannot seek to superblock on %s: %s\n",
79 dev
, strerror(errno
));
82 fprintf(stderr
, Name
": Cannot read superblock on %s\n",
86 fprintf(stderr
, Name
": No super block found on %s (Expected magic %08x, got %08x)\n",
87 dev
, MD_SB_MAGIC
, super
.md_magic
);
90 fprintf(stderr
, Name
": Cannot interpret superblock on %s - version is %d\n",
91 dev
, super
.major_version
);
95 /* Ok, its good enough to try, though the checksum could be wrong */
97 printf(" Magic : %08x\n", super
.md_magic
);
98 printf(" Version : %02d.%02d.%02d\n", super
.major_version
, super
.minor_version
,
100 if (super
.minor_version
>= 90)
101 printf(" UUID : %08x:%08x:%08x:%08x\n", super
.set_uuid0
, super
.set_uuid1
,
102 super
.set_uuid2
, super
.set_uuid3
);
104 printf(" UUID : %08x\n", super
.set_uuid0
);
107 printf(" Creation Time : %.24s\n", ctime(&atime
));
108 c
=map_num(pers
, super
.level
);
109 printf(" Raid Level : %s\n", c
?c
:"-unknown-");
110 printf(" Size : %d\n", super
.size
);
111 printf(" Raid Disks : %d\n", super
.raid_disks
);
112 printf(" Total Disks : %d\n", super
.nr_disks
);
113 printf("Preferred Minor : %d\n", super
.md_minor
);
116 printf(" Update Time : %.24s\n", ctime(&atime
));
117 printf(" State : %s, %serrors\n",
118 (super
.state
&(1<<MD_SB_CLEAN
))?"clean":"dirty",
119 (super
.state
&(1<<MD_SB_ERRORS
))?"":"no-");
120 printf(" Active Drives : %d\n", super
.active_disks
);
121 printf(" Working Drives : %d\n", super
.working_disks
);
122 printf(" Failed Drives : %d\n", super
.failed_disks
);
123 printf(" Spare Drives : %d\n", super
.spare_disks
);
124 printf(" - checksum not checked yet - \n");
125 printf(" Events : %d.%d\n", super
.events_hi
, super
.events_lo
);
127 if (super
.level
== 5) {
128 c
= map_num(r5layout
, super
.layout
);
129 printf(" Layout : %s\n", c
?c
:"-unknown-");
131 printf(" Chunk Size : %dK\n", super
.chunk_size
/1024);
133 printf(" Number Major Minor RaidDisk State\n");
134 for (d
= -1; d
<(signed int)super
.nr_disks
; d
++) {
137 if (d
>=0) dp
= &super
.disks
[d
];
138 else dp
= &super
.this_disk
;
139 sprintf(nb
, "%4d", d
);
140 printf("%4s %5d %5d %5d %5d ", d
< 0 ? "this" : nb
,
141 dp
->number
, dp
->major
, dp
->minor
, dp
->raid_disk
);
142 if (dp
->state
& (1<<MD_DISK_FAULTY
)) printf(" faulty");
143 if (dp
->state
& (1<<MD_DISK_ACTIVE
)) printf(" active");
144 if (dp
->state
& (1<<MD_DISK_SYNC
)) printf(" sync");
145 if (dp
->state
& (1<<MD_DISK_REMOVED
)) printf(" removed");