]>
git.ipfire.org Git - thirdparty/mdadm.git/blob - Detail.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
37 * Print out details for an md array by using
38 * GET_ARRAY_INFO and GET_DISK_INFO ioctl calls
41 int fd
= open(dev
, O_RDONLY
, 0);
43 mdu_array_info_t array
;
49 fprintf(stderr
, Name
": cannot open %s: %s\n",
50 dev
, strerror(errno
));
53 vers
= md_get_version(fd
);
55 fprintf(stderr
, Name
": %s does not appear to be an md device\n",
61 fprintf(stderr
, Name
": cannot get detail for md device %s: driver version too old.\n",
66 if (ioctl(fd
, GET_ARRAY_INFO
, &array
)<0) {
68 fprintf(stderr
, Name
": md device %s does not appear to be active.\n",
71 fprintf(stderr
, Name
": cannot get array detail for %s: %s\n",
72 dev
, strerror(errno
));
76 /* Ok, we have some info to print... */
78 printf(" Version : %02d.%02d.%02d\n",
79 array
.major_version
, array
.minor_version
, array
.patch_version
);
81 printf(" Creation Time : %.24s\n", ctime(&atime
));
82 c
= map_num(pers
, array
.level
);
83 printf(" Raid Level : %s\n", c
?c
:"-unknown-");
84 printf(" Size : %d\n", array
.size
);
85 printf(" Raid Disks : %d\n", array
.raid_disks
);
86 printf(" Total Disks : %d\n", array
.nr_disks
);
87 printf("Preferred Minor : %d\n", array
.md_minor
);
88 printf(" Persistance : Superblock is %spersistant\n",
89 array
.not_persistent
?"not ":"");
92 printf(" Update Time : %.24s\n", ctime(&atime
));
93 printf(" State : %s, %serrors\n",
94 (array
.state
&(1<<MD_SB_CLEAN
))?"clean":"dirty",
95 (array
.state
&(1<<MD_SB_ERRORS
))?"":"no-");
96 printf(" Active Drives : %d\n", array
.active_disks
);
97 printf(" Working Drives : %d\n", array
.working_disks
);
98 printf(" Failed Drives : %d\n", array
.failed_disks
);
99 printf(" Spare Drives : %d\n", array
.spare_disks
);
101 if (array
.level
== 5) {
102 c
= map_num(r5layout
, array
.layout
);
103 printf(" Layout : %s\n", c
?c
:"-unknown-");
105 printf(" Chunk Size : %dK\n", array
.chunk_size
/1024);
107 printf(" Number Major Minor RaidDisk State\n");
108 for (d
= 0; d
<array
.nr_disks
; d
++) {
109 mdu_disk_info_t disk
;
111 if (ioctl(fd
, GET_DISK_INFO
, &disk
) < 0) {
112 fprintf(stderr
, Name
": cannot get disk detail for disk %d: %s\n",
116 printf(" %5d %5d %5d %5d ",
117 disk
.number
, disk
.major
, disk
.minor
, disk
.raid_disk
);
118 if (disk
.state
& (1<<MD_DISK_FAULTY
)) printf(" faulty");
119 if (disk
.state
& (1<<MD_DISK_ACTIVE
)) printf(" active");
120 if (disk
.state
& (1<<MD_DISK_SYNC
)) printf(" sync");
121 if (disk
.state
& (1<<MD_DISK_REMOVED
)) printf(" removed");