]> git.proxmox.com Git - mirror_smartmontools-debian.git/blobdiff - os_linux.cpp
Imported Upstream version 5.38+svn2956
[mirror_smartmontools-debian.git] / os_linux.cpp
index f6d9f2d35f87b0020fd2ddac11ea70fad24f1f43..5635eaa01454552dcd1608f1638e26e80a8d6697 100644 (file)
@@ -90,7 +90,7 @@
 
 #define ARGUSED(x) ((void)(x))
 
-const char *os_XXXX_c_cvsid="$Id: os_linux.cpp 2915 2009-09-18 21:17:37Z chrfranke $" \
+const char *os_XXXX_c_cvsid="$Id: os_linux.cpp 2951 2009-10-08 23:43:46Z samm2 $" \
 ATACMDS_H_CVSID CONFIG_H_CVSID INT64_H_CVSID OS_LINUX_H_CVSID SCSICMDS_H_CVSID UTILITY_H_CVSID;
 
 /* for passing global control variables */
@@ -951,6 +951,7 @@ bool linux_megaraid_device::open()
   char line[128];
   int   mjr, n1;
   FILE *fp;
+  int report = con->reportscsiioctl; 
 
   if (!linux_smart_device::open())
     return false;
@@ -963,7 +964,7 @@ bool linux_megaraid_device::open()
   else if (ioctl(get_fd(), SCSI_IOCTL_GET_BUS_NUMBER, &m_hba) != 0) {
     int err = errno;
     linux_smart_device::close();
-    return set_err(err, "can't get hba");
+    return set_err(err, "can't get bus number");
   }
 
   /* Perform mknod of device ioctl node */
@@ -972,13 +973,15 @@ bool linux_megaraid_device::open()
        n1=0;
        if (sscanf(line, "%d megaraid_sas_ioctl%n", &mjr, &n1) == 1 && n1 == 22) {
           n1=mknod("/dev/megaraid_sas_ioctl_node", S_IFCHR, makedev(mjr, 0));
-          printf("Creating /dev/megaraid_sas_ioctl_node = %d\n", n1 >= 0 ? 0 : errno);
+          if(report > 0)
+            printf("Creating /dev/megaraid_sas_ioctl_node = %d\n", n1 >= 0 ? 0 : errno);
           if (n1 >= 0 || errno == EEXIST)
              break;
        }
        else if (sscanf(line, "%d megadev%n", &mjr, &n1) == 1 && n1 == 11) {
           n1=mknod("/dev/megadev0", S_IFCHR, makedev(mjr, 0));
-          printf("Creating /dev/megadev0 = %d\n", n1 >= 0 ? 0 : errno);
+          if(report > 0)
+            printf("Creating /dev/megadev0 = %d\n", n1 >= 0 ? 0 : errno);
           if (n1 >= 0 || errno == EEXIST)
              break;
        }
@@ -1043,7 +1046,18 @@ bool linux_megaraid_device::scsi_pass_through(scsi_cmnd_io *iop)
   if (iop->cmnd[0] == 0x00)
     return true;
   if (iop->cmnd[0] == 0x85 && iop->cmnd[1] == 0x06) {
-    pout("Rejecting SMART/ATA command to controller\n");
+    if(report > 0)
+      pout("Rejecting SMART/ATA command to controller\n");
+    // Emulate SMART STATUS CHECK drive reply
+    // smartctl fail to work without this
+    if(iop->cmnd[2]==0x2c) {
+      iop->resp_sense_len=22;
+      iop->sensep[0]=0x72; // response code
+      iop->sensep[7]=0x0e; // no idea what it is, copied from sat device answer
+      iop->sensep[8]=0x09; // 
+      iop->sensep[17]=0x4f; // lm
+      iop->sensep[19]=0xc2; // lh
+    }
     return true;
   }
 
@@ -2666,7 +2680,13 @@ smart_device * linux_scsi_device::autodetect_open()
                       "you may need to replace %s with /dev/twaN or /dev/tweN", get_dev_name());
       return this;
     }
-
+    // DELL?
+    if (!memcmp(req_buff + 8, "DELL    PERC", 12) || !memcmp(req_buff + 8, "MegaRAID", 8)) {
+      close();
+      set_err(EINVAL, "DELL or MegaRaid controller, please try adding '-d megaraid,N'");
+      return this;
+    }
+    
     // Marvell ?
     if (len >= 42 && !memcmp(req_buff + 36, "MVSATA", 6)) {
       //pout("Device %s: using '-d marvell' for ATA disk with Marvell driver\n", get_dev_name());