summaryrefslogtreecommitdiff
path: root/extras/multipath-tools/multipathd/checkers.c
diff options
context:
space:
mode:
authorgreg@kroah.com <greg@kroah.com>2004-03-10 22:40:39 -0800
committerGreg KH <gregkh@suse.de>2005-04-26 21:35:09 -0700
commita3b37a073d52ff01d4ef023a10f13316da4c9966 (patch)
tree349bfb87361de4b6d1990b9d5a9283d445b7ea37 /extras/multipath-tools/multipathd/checkers.c
parent49f9acf3844aa5c004b5794e919bd54166e53227 (diff)
[PATCH] Added multipath-tools 0.1.1 release
Diffstat (limited to 'extras/multipath-tools/multipathd/checkers.c')
-rw-r--r--extras/multipath-tools/multipathd/checkers.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/extras/multipath-tools/multipathd/checkers.c b/extras/multipath-tools/multipathd/checkers.c
new file mode 100644
index 0000000000..7ad32b04e9
--- /dev/null
+++ b/extras/multipath-tools/multipathd/checkers.c
@@ -0,0 +1,62 @@
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+
+#include "sg_include.h"
+
+#define TUR_CMD_LEN 6
+
+/*
+ * test IO functions : add yours here
+ *
+ * returns 0 : path gone valid
+ * returns 1 : path still failed
+ */
+
+int readsector0 (char *devnode)
+{
+ int fd, r;
+ char buf;
+
+ fd = open (devnode, O_RDONLY);
+ if (read (fd, &buf, 1) != 1)
+ r = 0;
+ else
+ r = 1;
+
+ close (fd);
+
+ return r;
+}
+
+int tur(char *devnode)
+{
+ unsigned char turCmdBlk[TUR_CMD_LEN] = { 0x00, 0, 0, 0, 0, 0 };
+ struct sg_io_hdr io_hdr;
+ unsigned char sense_buffer[32];
+ int fd;
+
+ fd = open (devnode, O_RDONLY);
+
+ memset(&io_hdr, 0, sizeof (struct sg_io_hdr));
+ io_hdr.interface_id = 'S';
+ io_hdr.cmd_len = sizeof (turCmdBlk);
+ io_hdr.mx_sb_len = sizeof (sense_buffer);
+ io_hdr.dxfer_direction = SG_DXFER_NONE;
+ io_hdr.cmdp = turCmdBlk;
+ io_hdr.sbp = sense_buffer;
+ io_hdr.timeout = 20000;
+ io_hdr.pack_id = 0;
+ if (ioctl(fd, SG_IO, &io_hdr) < 0) {
+ close(fd);
+ return 0;
+ }
+ if (io_hdr.info & SG_INFO_OK_MASK) {
+ return 0;
+ }
+ return 1;
+}