From 16874d8dedd00f05280f09c87ae2ea72d3f750eb Mon Sep 17 00:00:00 2001
From: ballen4705 <ballen4705@4ea69e1a-61f1-4043-bf83-b5c94c648137>
Date: Mon, 21 Oct 2002 16:11:58 +0000
Subject: [PATCH] Fixed broken logic in detection of normal busy error on
 captive self test ioctl

git-svn-id: https://smartmontools.svn.sourceforge.net/svnroot/smartmontools/trunk@74 4ea69e1a-61f1-4043-bf83-b5c94c648137
---
 sm5/atacmds.c   | 5 +++--
 sm5/atacmds.cpp | 5 +++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/sm5/atacmds.c b/sm5/atacmds.c
index 36b5a598f..fb672d84a 100644
--- a/sm5/atacmds.c
+++ b/sm5/atacmds.c
@@ -1,4 +1,4 @@
-//  $Id: atacmds.c,v 1.13 2002/10/21 16:00:47 ballen4705 Exp $
+//  $Id: atacmds.c,v 1.14 2002/10/21 16:11:58 ballen4705 Exp $
 /*
  * atacmds.c
  * 
@@ -549,7 +549,8 @@ int ataSmartTest(int device, int testtype){
   printf("Sending command: \"%s\".\n",cmdmsg);
 
   // Now send the command to test
-  if ((errornum=ioctl(device , HDIO_DRIVE_CMD, parms)) && errornum!=EIO){
+  errornum=ioctl(device, HDIO_DRIVE_CMD, parms);
+  if (!(errornum && errno==EIO && (testtype=SHORT_CAPTIVE_SELF_TEST || testtype==EXTEND_CAPTIVE_SELF_TEST))){
     char errormsg[128];
     sprintf(errormsg,"Command \"%s\" failed.",cmdmsg); 
     perror (errormsg);
diff --git a/sm5/atacmds.cpp b/sm5/atacmds.cpp
index 7e9dccd44..5c0ee3d28 100644
--- a/sm5/atacmds.cpp
+++ b/sm5/atacmds.cpp
@@ -1,4 +1,4 @@
-//  $Id: atacmds.cpp,v 1.13 2002/10/21 16:00:47 ballen4705 Exp $
+//  $Id: atacmds.cpp,v 1.14 2002/10/21 16:11:58 ballen4705 Exp $
 /*
  * atacmds.c
  * 
@@ -549,7 +549,8 @@ int ataSmartTest(int device, int testtype){
   printf("Sending command: \"%s\".\n",cmdmsg);
 
   // Now send the command to test
-  if ((errornum=ioctl(device , HDIO_DRIVE_CMD, parms)) && errornum!=EIO){
+  errornum=ioctl(device, HDIO_DRIVE_CMD, parms);
+  if (!(errornum && errno==EIO && (testtype=SHORT_CAPTIVE_SELF_TEST || testtype==EXTEND_CAPTIVE_SELF_TEST))){
     char errormsg[128];
     sprintf(errormsg,"Command \"%s\" failed.",cmdmsg); 
     perror (errormsg);
-- 
GitLab