aboutsummaryrefslogtreecommitdiff
path: root/archive
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2007-06-27 02:56:10 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2007-06-27 02:56:10 +0000
commit4996eb9a33d3f74377625fcce22c5462d0708018 (patch)
tree4b4babecd18a48b4ce7e33d7b44b33f5f9b801f9 /archive
parent6e64b86f968c387672eac691acad20f91b4bd526 (diff)
downloadsg3_utils-4996eb9a33d3f74377625fcce22c5462d0708018.tar.gz
To prepare to load sg3_utils-1.04 into trunk/, perform 7 renames.
* trunk//examples/scsi_inquiry.c: Renamed from trunk//scsi_inquiry.c. * trunk//archive/sg_debug.c: Renamed from trunk//sg_debug.c. * trunk//examples/sg_simple1.c: Renamed from trunk//sg_simple1.c. * trunk//examples/sg_simple16.c: Renamed from trunk//sg_simple16.c. * trunk//examples/sg_simple2.c: Renamed from trunk//sg_simple2.c. * trunk//examples/sg_simple3.c: Renamed from trunk//sg_simple3.c. * trunk//examples/sg_simple4.c: Renamed from trunk//sg_simple4.c. git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@31 6180dd3e-e324-4e3e-922d-17de1ae2f315
Diffstat (limited to 'archive')
-rw-r--r--archive/sg_debug.c71
1 files changed, 71 insertions, 0 deletions
diff --git a/archive/sg_debug.c b/archive/sg_debug.c
new file mode 100644
index 00000000..fb044feb
--- /dev/null
+++ b/archive/sg_debug.c
@@ -0,0 +1,71 @@
+#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 "sg_include.h"
+
+
+/* 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.55 (20020115)
+*/
+
+#define EBUFF_SZ 256
+
+
+int main(int argc, char * argv[])
+{
+ int fd, res, debug, t;
+ char ebuff[EBUFF_SZ];
+
+ 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 {
+ snprintf(ebuff, EBUFF_SZ, "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("System is using sg version 3 driver. Hence the user can");
+ printf(" execute:\n 'cat /proc/scsi/sg/debug' themselves. ");
+ printf("Here is an example:\n");
+ system("cat /proc/scsi/sg/debug");
+ 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) {
+ snprintf(ebuff, EBUFF_SZ, "sg_debug: trying to close %s ", argv[1]);
+ perror(ebuff);
+ return 1;
+ }
+ return 0;
+}