diff options
author | sos <sos@FreeBSD.org> | 2002-04-02 13:48:17 +0000 |
---|---|---|
committer | sos <sos@FreeBSD.org> | 2002-04-02 13:48:17 +0000 |
commit | 9b962a4e9b5fedc67b4a99f7e601ead5e560046a (patch) | |
tree | 130b7364b744c920bbc15c1d12ef48b5ebff5b0c /sbin/atacontrol | |
parent | 5c4e8e05b641c2b0660eec42dfa25fb9b7821e10 (diff) | |
download | FreeBSD-src-9b962a4e9b5fedc67b4a99f7e601ead5e560046a.zip FreeBSD-src-9b962a4e9b5fedc67b4a99f7e601ead5e560046a.tar.gz |
Add get-status to the ATA RAID subsystem.
Diffstat (limited to 'sbin/atacontrol')
-rw-r--r-- | sbin/atacontrol/atacontrol.8 | 5 | ||||
-rw-r--r-- | sbin/atacontrol/atacontrol.c | 67 |
2 files changed, 61 insertions, 11 deletions
diff --git a/sbin/atacontrol/atacontrol.8 b/sbin/atacontrol/atacontrol.8 index 44aad43..6ec13e2 100644 --- a/sbin/atacontrol/atacontrol.8 +++ b/sbin/atacontrol/atacontrol.8 @@ -55,6 +55,9 @@ .Ic rebuild .Ar raid .Nm +.Ic status +.Ar raid +.Nm .Ic mode .Ar channel .Op Ar mastermode slavemode @@ -124,6 +127,8 @@ reside on the first disk in the SPAN. Deletes a RAID array on a RAID capable ATA controller. .It Ic rebuild Rebuild a RAID1 array on a RAID capable ATA controller. +.It Ic status +Get the status of an ATA RAID. .It Ic mode Without the two mode arguments the current transfer modes of both devices are printed. diff --git a/sbin/atacontrol/atacontrol.c b/sbin/atacontrol/atacontrol.c index 9fe2201..43d0f95 100644 --- a/sbin/atacontrol/atacontrol.c +++ b/sbin/atacontrol/atacontrol.c @@ -248,6 +248,7 @@ main(int argc, char **argv) int chan; if (!strcmp(argv[1], "delete") || + !strcmp(argv[1], "status") || !strcmp(argv[1], "rebuild")) { if (!(sscanf(argv[2], "%d", &chan) == 1 || sscanf(argv[2], "ar%d", &chan) == 1)) @@ -300,16 +301,6 @@ main(int argc, char **argv) warn("ioctl(ATAREINIT)"); info_print(fd, iocmd.channel, 0); } - else if (!strcmp(argv[1], "rebuild") && argc == 3) { - iocmd.cmd = ATARAIDREBUILD; - if (ioctl(fd, IOCATA, &iocmd) < 0) - warn("ioctl(ATARAIDREBUILD)"); - } - else if (!strcmp(argv[1], "delete") && argc == 3) { - iocmd.cmd = ATARAIDDELETE; - if (ioctl(fd, IOCATA, &iocmd) < 0) - warn("ioctl(ATARAIDDELETE)"); - } else if (!strcmp(argv[1], "create")) { int disk, dev, offset; @@ -342,10 +333,64 @@ main(int argc, char **argv) } iocmd.u.raid_setup.total_disks = disk; if (ioctl(fd, IOCATA, &iocmd) < 0) - warn("ioctl(ATARAIDCREATE)"); + err(1, "ioctl(ATARAIDCREATE)"); else printf("ar%d created\n", iocmd.u.raid_setup.unit); } + else if (!strcmp(argv[1], "delete") && argc == 3) { + iocmd.cmd = ATARAIDDELETE; + if (ioctl(fd, IOCATA, &iocmd) < 0) + warn("ioctl(ATARAIDDELETE)"); + } + else if (!strcmp(argv[1], "rebuild") && argc == 3) { + iocmd.cmd = ATARAIDREBUILD; + if (ioctl(fd, IOCATA, &iocmd) < 0) + warn("ioctl(ATARAIDREBUILD)"); + } + else if (!strcmp(argv[1], "status") && argc == 3) { + int i; + + iocmd.cmd = ATARAIDSTATUS; + if (ioctl(fd, IOCATA, &iocmd) < 0) + err(1, "ioctl(ATARAIDSTATUS)"); + printf("ar%d: ATA ", iocmd.channel); + switch (iocmd.u.raid_status.type) { + case AR_RAID0: + printf("RAID0"); + break; + case AR_RAID1: + printf("RAID1"); + break; + case AR_RAID0 | AR_RAID1: + printf("RAID0+1"); + break; + case AR_SPAN: + printf("SPAN"); + break; + } + printf(" subdisks: "); + for (i = 0; i < iocmd.u.raid_status.total_disks; i++) { + if (iocmd.u.raid_status.disks[i] >= 0) + printf("ad%d ", iocmd.u.raid_status.disks[i]); + else + printf("DOWN "); + } + printf("status: "); + switch (iocmd.u.raid_status.status) { + case AR_READY: + printf("READY\n"); + break; + case AR_READY | AR_DEGRADED: + printf("DEGRADED\n"); + break; + case AR_READY | AR_DEGRADED | AR_REBUILDING: + printf("REBUILDING %d%% completed\n", + iocmd.u.raid_status.progress); + break; + default: + printf("BROKEN\n"); + } + } else if (!strcmp(argv[1], "mode") && (argc == 3 || argc == 5)) { if (argc == 5) { iocmd.cmd = ATASMODE; |