Package: smartmontools
Version: 5.37-5.1~sh.1
Severity: normal
Tags: patch

Please add the following patch to the quilt series.

I have extracted it from upstream CVS and it fixes "errors" like

[   55.137389] ata1.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x2 frozen
[   55.137631] ata1.00: cmd b0/d2:f1:00:4f:c2/00:00:00:00:00/00 tag 0 cdb 0x0 
data 123392 in
[   55.137632]          res 50/00:f1:00:4f:c2/00:00:00:00:00/00 Emask 0x202 
(HSM violation)
[   55.439994] ata1: soft resetting port
[   55.590824] ata1: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
[   55.597095] ata1.00: configured for UDMA/133
[   55.597285] ata1: EH complete

upon start of smartd or usage of smartctl.

URL: 
<http://smartmontools.cvs.sourceforge.net/smartmontools/sm5/os_linux.cpp?r1=1.94&r2=1.95&view=patch>

-- Package-specific info:
Ouput of /usr/share/bug/smartmontools:
# CONFIG_IDE_TASK_IOCTL is not set

-- System Information:
Debian Release: lenny/sid
  APT prefers unstable
  APT policy: (990, 'unstable'), (500, 'testing'), (200, 'experimental')
Architecture: i386 (i686)

Kernel: Linux 2.6.23.1-302 (PREEMPT)
Locale: [EMAIL PROTECTED], [EMAIL PROTECTED] (charmap=ISO-8859-15)
Shell: /bin/sh linked to /bin/bash

Versions of packages smartmontools depends on:
ii  debianutils                   2.27       Miscellaneous utilities specific t
ii  libc6                         2.6.1-6    GNU C Library: Shared libraries
ii  libgcc1                       1:4.2.2-3  GCC support library
ii  libstdc++6                    4.2.2-3    The GNU Standard C++ Library v3
ii  lsb-base                      3.1-24     Linux Standard Base 3.1 init scrip

Versions of packages smartmontools recommends:
ii  mailx            1:8.1.2-0.20071017cvs-2 A simple mail user agent

-- no debconf information
Index: smartmontools-5.37/os_linux.cpp
===================================================================
--- smartmontools-5.37.orig/os_linux.cpp	2007-10-31 22:49:42.000000000 +0100
+++ smartmontools-5.37/os_linux.cpp	2007-10-31 22:53:19.000000000 +0100
@@ -423,14 +423,10 @@
 //   1 if the command succeeded and disk SMART status is "FAILING"
 
 
-// huge value of buffer size needed because HDIO_DRIVE_CMD assumes
-// that buff[3] is the data size.  Since the ATA_SMART_AUTOSAVE and
-// ATA_SMART_AUTO_OFFLINE use values of 0xf1 and 0xf8 we need the space.
-// Otherwise a 4+512 byte buffer would be enough.
-#define STRANGE_BUFFER_LENGTH (4+512*0xf8)
+#define BUFFER_LENGTH (4+512)
 
 int ata_command_interface(int device, smart_command_set command, int select, char *data){
-  unsigned char buff[STRANGE_BUFFER_LENGTH];
+  unsigned char buff[BUFFER_LENGTH];
   // positive: bytes to write to caller.  negative: bytes to READ from
   // caller. zero: non-data command
   int copydata=0;
@@ -447,7 +443,7 @@
   // buff[2] contains the ATA SECTOR COUNT REGISTER
   
   // clear out buff.  Large enough for HDIO_DRIVE_CMD (4+512 bytes)
-  memset(buff, 0, STRANGE_BUFFER_LENGTH);
+  memset(buff, 0, BUFFER_LENGTH);
 
   buff[0]=ATA_SMART_CMD;
   switch (command){
@@ -497,12 +493,14 @@
     buff[2]=ATA_SMART_STATUS;
     break;
   case AUTO_OFFLINE:
-    buff[2]=ATA_SMART_AUTO_OFFLINE;
-    buff[3]=select;   // YET NOTE - THIS IS A NON-DATA COMMAND!!
+    // NSECT is 241 for enable but no data transfer.  Use TASK ioctl.
+    buff[1]=ATA_SMART_AUTO_OFFLINE;
+    buff[2]=select;
     break;
   case AUTOSAVE:
-    buff[2]=ATA_SMART_AUTOSAVE;
-    buff[3]=select;   // YET NOTE - THIS IS A NON-DATA COMMAND!!
+    // NSECT is 248 for enable but no data transfer.  Use TASK ioctl.
+    buff[1]=ATA_SMART_AUTOSAVE;
+    buff[2]=select;
     break;
   case IMMEDIATE_OFFLINE:
     buff[2]=ATA_SMART_IMMEDIATE_OFFLINE;
@@ -557,7 +555,7 @@
     
   // There are two different types of ioctls().  The HDIO_DRIVE_TASK
   // one is this:
-  if (command==STATUS_CHECK){
+  if (command==STATUS_CHECK || command==AUTOSAVE || command==AUTO_OFFLINE){
     int retval;
 
     // NOT DOCUMENTED in /usr/src/linux/include/linux/hdreg.h. You
@@ -1639,13 +1637,13 @@
 int highpoint_command_interface(int device, smart_command_set command,
                                 int select, char *data)
 {
-  unsigned char hpt_buff[4*sizeof(int) + STRANGE_BUFFER_LENGTH];
+  unsigned char hpt_buff[4*sizeof(int) + BUFFER_LENGTH];
   unsigned int *hpt = (unsigned int *)hpt_buff;
   unsigned char *buff = &hpt_buff[4*sizeof(int)];
   int copydata = 0;
   const int HDIO_DRIVE_CMD_OFFSET = 4;
 
-  memset(hpt_buff, 0, 4*sizeof(int) + STRANGE_BUFFER_LENGTH);
+  memset(hpt_buff, 0, 4*sizeof(int) + BUFFER_LENGTH);
   hpt[0] = con->hpt_data[0]; // controller id
   hpt[1] = con->hpt_data[1]; // channel number
   hpt[3] = con->hpt_data[2]; // pmport number

Reply via email to