]>
git.ipfire.org Git - thirdparty/mdadm.git/blob - Detail.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
34 int Detail(char *dev
, int brief
)
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
;
52 fprintf(stderr
, Name
": cannot open %s: %s\n",
53 dev
, strerror(errno
));
56 vers
= md_get_version(fd
);
58 fprintf(stderr
, Name
": %s does not appear to be an md device\n",
64 fprintf(stderr
, Name
": cannot get detail for md device %s: driver version too old.\n",
69 if (ioctl(fd
, GET_ARRAY_INFO
, &array
)<0) {
71 fprintf(stderr
, Name
": md device %s does not appear to be active.\n",
74 fprintf(stderr
, Name
": cannot get array detail for %s: %s\n",
75 dev
, strerror(errno
));
79 /* Ok, we have some info to print... */
80 c
= map_num(pers
, array
.level
);
82 printf("ARRAY %s level=%s disks=%d", dev
, c
?c
:"-unknown-",array
.raid_disks
);
85 long long larray_size
;
86 if (ioctl(fd
, BLKGETSIZE64
, &larray_size
)==0)
88 else if (ioctl(fd
, BLKGETSIZE
, &array_size
)==0)
89 larray_size
= array_size
<<9;
93 printf(" Version : %02d.%02d.%02d\n",
94 array
.major_version
, array
.minor_version
, array
.patch_version
);
96 printf(" Creation Time : %.24s\n", ctime(&atime
));
97 printf(" Raid Level : %s\n", c
?c
:"-unknown-");
99 printf(" Array Size : %ld%s\n", (long)(larray_size
>>10), human_size(larray_size
));
100 if (array
.level
>= 1)
101 printf(" Device Size : %d%s\n", array
.size
, human_size((long long)array
.size
<<10));
102 printf(" Raid Disks : %d\n", array
.raid_disks
);
103 printf(" Total Disks : %d\n", array
.nr_disks
);
104 printf("Preferred Minor : %d\n", array
.md_minor
);
105 printf(" Persistance : Superblock is %spersistant\n",
106 array
.not_persistent
?"not ":"");
109 printf(" Update Time : %.24s\n", ctime(&atime
));
110 printf(" State : %s, %serrors\n",
111 (array
.state
&(1<<MD_SB_CLEAN
))?"clean":"dirty",
112 (array
.state
&(1<<MD_SB_ERRORS
))?"":"no-");
113 printf(" Active Drives : %d\n", array
.active_disks
);
114 printf(" Working Drives : %d\n", array
.working_disks
);
115 printf(" Failed Drives : %d\n", array
.failed_disks
);
116 printf(" Spare Drives : %d\n", array
.spare_disks
);
118 if (array
.level
== 5) {
119 c
= map_num(r5layout
, array
.layout
);
120 printf(" Layout : %s\n", c
?c
:"-unknown-");
122 switch (array
.level
) {
126 printf(" Chunk Size : %dK\n", array
.chunk_size
/1024);
129 printf(" Rounding : %dK\n", array
.chunk_size
/1024);
135 printf(" Number Major Minor RaidDisk State\n");
137 for (d
= 0; d
<array
.raid_disks
+array
.spare_disks
; d
++) {
138 mdu_disk_info_t disk
;
141 if (ioctl(fd
, GET_DISK_INFO
, &disk
) < 0) {
142 fprintf(stderr
, Name
": cannot get disk detail for disk %d: %s\n",
147 printf(" %5d %5d %5d %5d ",
148 disk
.number
, disk
.major
, disk
.minor
, disk
.raid_disk
);
149 if (disk
.state
& (1<<MD_DISK_FAULTY
)) printf(" faulty");
150 if (disk
.state
& (1<<MD_DISK_ACTIVE
)) printf(" active");
151 if (disk
.state
& (1<<MD_DISK_SYNC
)) printf(" sync");
152 if (disk
.state
& (1<<MD_DISK_REMOVED
)) printf(" removed");
154 if ((dv
=map_dev(disk
.major
, disk
.minor
))) {
155 if (!brief
) printf(" %s", dv
);
157 /* try to read the superblock from this device
160 int fd
= open(dv
, O_RDONLY
);
162 load_super(fd
, &super
) ==0 &&
163 super
.ctime
== array
.ctime
&&
164 super
.level
== array
.level
)
168 if (!brief
) printf("\n");
171 if (brief
) printf(" UUID=");
172 else printf(" UUID : ");
173 if (super
.minor_version
>= 90)
174 printf("%08x:%08x:%08x:%08x", super
.set_uuid0
, super
.set_uuid1
,
175 super
.set_uuid2
, super
.set_uuid3
);
177 printf("%08x", super
.set_uuid0
);
178 if (!brief
) printf("\n");
180 if (brief
) printf("\n");