info-mtools
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Mtools] Proof-of-concept SCSI support for NetBSD


From: Sergey Svishchev
Subject: [Mtools] Proof-of-concept SCSI support for NetBSD
Date: Sat, 17 May 2008 10:58:22 -0000
User-agent: Thunderbird 2.0.0.9 (X11/20071120)

Good day,

Applies cleanly to 3.9.11, builds fine, but isn't very useful -- as far as I understand, SCSI support is there for ZIP drives, and I tried to use it with an USB-attached iPod (which doesn't grok 6-byte commands).

--- scsi.c.orig 2007-05-26 09:02:56.000000000 +0000
+++ scsi.c
@@ -53,6 +53,10 @@ struct scsi_ioctl_command {
 #include <camlib.h>
 #endif

+#if defined(OS_netbsd) || defined(OS_netbsdelf)
+#include <sys/scsiio.h>
+#endif
+
 int scsi_max_length(void)
 {
 #ifdef OS_linux
@@ -270,6 +274,37 @@ int scsi_cmd(int fd, unsigned char *cdb,
          return -1;
       }
       return 0;
+#elif defined(OS_netbsd) || defined(OS_netbsdelf)
+       struct scsireq sc;
+
+       memset(&sc, 0, sizeof(sc));
+       memcpy(sc.cmd, cdb, cmdlen);
+       sc.cmdlen = cmdlen;
+       sc.databuf = data;
+       sc.datalen = len;
+       sc.senselen = 0;
+       sc.timeout = 10000;
+       switch (mode) {
+       case SCSI_IO_READ:
+         sc.flags = SCCMD_READ;
+         break;
+       case SCSI_IO_WRITE:
+         sc.flags = SCCMD_WRITE;
+         break;
+       }
+
+       if (ioctl(fd, SCIOCCOMMAND, &sc) == -1) {
+                perror("SCIOCCOMMAND ioctl");
+                return -1;
+       }
+
+       if (sc.retsts) {
+                errno = EIO;
+ fprintf(stderr, "SCSI command failed, retsts %d\n", sc.retsts);
+                return -1;
+       }
+
+        return 0;
 #else
       fprintf(stderr, "scsi_io not implemented\n");
       return -1;

--
Sergey Svishchev



reply via email to

[Prev in Thread] Current Thread [Next in Thread]