DF-2497 / atastat.c
/* * atastat.c -- issue a real IOCATARAIDSTATUS ioctl on /dev/ata * (DF-2496 test21 helper; run as root: ./atastat <lun>) */ #include <sys/types.h> #include <sys/ioctl.h> #include <sys/nata.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <string.h> int main(int argc, char **argv) { struct ata_ioc_raid_status st; int fd; if (argc < 2) { fprintf(stderr, "usage: atastat <lun>\n"); exit(1); } fd = open("/dev/ata", O_RDONLY); if (fd < 0) { perror("open /dev/ata"); exit(1); } memset(&st, 0, sizeof(st)); st.lun = atoi(argv[1]); printf("atastat: ioctl IOCATARAIDSTATUS lun=%d ...\n", st.lun); if (ioctl(fd, IOCATARAIDSTATUS, &st) < 0) { perror("ioctl"); close(fd); exit(1); } printf("atastat: ok type=%u total_disks=%u interleave=%u " "status=%u progress=%u\n", st.type, st.total_disks, st.interleave, st.status, st.progress); close(fd); exit(0); } |