]>
git.ipfire.org Git - thirdparty/mdadm.git/blob - Query.c
2 * mdadm - manage Linux "md" devices aka RAID arrays.
4 * Copyright (C) 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
36 /* Give a brief description of the device,
37 * whether it is an md device and whether it has
40 int fd
= open(dev
, O_RDONLY
, 0);
43 int superror
, superrno
;
45 mdu_array_info_t array
;
46 unsigned long long larray_size
;
47 unsigned long array_size
;
54 fprintf(stderr
, Name
": cannot open %s: %s\n",
55 dev
, strerror(errno
));
59 vers
= md_get_version(fd
);
60 if (ioctl(fd
, GET_ARRAY_INFO
, &array
)<0)
63 superror
= load_super(fd
, &super
);
68 if (vers
>=9000 && !ioctlerr
) {
70 if (ioctl(fd
, BLKGETSIZE64
, &larray_size
)==0)
74 if (ioctl(fd
, BLKGETSIZE
, &array_size
)==0)
75 larray_size
= array_size
<<9;
81 printf("%s: is not an md array\n", dev
);
83 printf("%s: is an md device, but kernel cannot provide details\n", dev
);
84 else if (ioctlerr
== ENODEV
)
85 printf("%s: is an md device which is not active\n", dev
);
87 printf("%s: is an md device, but gives \"%s\" when queried\n",
88 dev
, strerror(ioctlerr
));
90 printf("%s: %s %s %d devices, %d spare%s. Use mdadm --detail for more detail.\n",
92 human_size_brief(larray_size
),
93 map_num(pers
, array
.level
),
95 array
.spare_disks
, array
.spare_disks
==1?"":"s");
99 printf("%s: cannot find device size: %s\n",
100 dev
, strerror(superrno
));
103 printf("%s: is too small to be an md componenet.\n",
107 printf("%s: Cannot seek to superblock: %s\n",
108 dev
, strerror(superrno
));
111 printf("%s: Cannot read md superblock.\n",
115 printf("%s: No md super block found, not an md component.\n",
119 printf("%s: md superblock present with wrong version: %d\n",
120 dev
, super
.major_version
);
123 /* array might be active... */
124 mddev
= get_md_name(super
.md_minor
);
125 disc
.number
= super
.this_disk
.number
;
126 activity
= "inactive";
127 if (mddev
&& (fd
= open(mddev
, O_RDONLY
))>=0) {
128 if (md_get_version(fd
) >= 9000 &&
129 ioctl(fd
, GET_ARRAY_INFO
, &array
)>= 0) {
130 if (ioctl(fd
, GET_DISK_INFO
, &disc
) >= 0 &&
131 MKDEV(disc
.major
,disc
.minor
) == stb
.st_rdev
)
134 activity
= "mismatch";
138 printf("%s: device %d in %d device %s %s md%d. Use mdadm --examine for more detail.\n",
140 super
.this_disk
.number
, super
.raid_disks
,
142 map_num(pers
, super
.level
),