/
githubmirror
/
sg3_utils
Обзор
Документация
Войти
/
githubmirror
/
sg3_utils
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
release-0.91
sg_debug.c
66 строк
2 KB
Douglas Gilbert
Load sg3_utils-0.90 into trunk/.
27 июн 2007, 06:33
27 июн 2007, 06:33
d50a5ff
Код
Авторство
О чём код?
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <errno.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/fcntl.h> #include <sys/ioctl.h> #include <linux/../scsi/sg.h> /* cope with silly includes */ /* Test code for D. Gilbert's extensions to the Linux OS SCSI generic ("sg") device driver. * Copyright (C) 1999 D. Gilbert * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. This program outputs debug information to the console/log for _all_ active sg devices. Version 3.53 (990719) */ int main(int argc, char * argv[]) { int fd, res, debug, t; char ebuff[256]; if ((argc != 2) || ('-' == *argv[1])) { printf("Usage: sg_debug <sg_device>\n"); return 1; } fd = open(argv[1], O_RDONLY | O_NONBLOCK); if (fd < 0) { if (EBUSY == errno) printf("Failed trying to open %s because it is busy\n", argv[1]); else { sprintf(ebuff, "sg_debug: Error trying to open %s ", argv[1]); perror(ebuff); } return 1; } res = ioctl(fd, SG_GET_VERSION_NUM, &t); if ((res >= 0) || (t >= 30000)) { printf("For debug information try: 'cat /proc/scsi/sg/debug'\n"); return 0; } debug = 10; res = ioctl(fd, SG_SET_DEBUG, &debug); if (res < 0) { perror("sg_debug: ioctl error on SG_SET_DEBUG"); return 1; } res = close(fd); if (res < 0) { sprintf(ebuff, "sg_debug: trying to close %s ", argv[1]); perror(ebuff); return 1; } return 0; }