diff --git a/sm5/scsicmds.c b/sm5/scsicmds.c
index 155d3a74454f8d6d994424008d3c41786be0362a..b963f65bf43dfd270193931ed507bfbe5991e635 100644
--- a/sm5/scsicmds.c
+++ b/sm5/scsicmds.c
@@ -46,7 +46,7 @@
 #include "utility.h"
 #include "extern.h"
 
-const char *scsicmds_c_cvsid="$Id: scsicmds.c,v 1.65 2003/11/20 01:02:27 dpgilbert Exp $" EXTERN_H_CVSID SCSICMDS_H_CVSID;
+const char *scsicmds_c_cvsid="$Id: scsicmds.c,v 1.66 2003/12/02 03:24:17 dpgilbert Exp $" EXTERN_H_CVSID SCSICMDS_H_CVSID;
 
 /* for passing global control variables */
 extern smartmonctrl *con;
@@ -1743,6 +1743,31 @@ int scsiCountFailedSelfTests(int fd, int noisy)
     return (fail_hour << 8) + fails;
 }
 
+/* Returns 0 if able to read self test log page; then outputs 1 into
+   *inProgress if self test still in progress, else outputs 0. */
+int scsiSelfTestInProgress(int fd, int * inProgress)
+{
+    int num;
+    UINT8 * ucp;
+    unsigned char resp[LOG_RESP_SELF_TEST_LEN];
+
+    if (scsiLogSense(fd, SELFTEST_RESULTS_LPAGE, resp, 
+                     LOG_RESP_SELF_TEST_LEN, 0))
+        return -1;
+    if (resp[0] != SELFTEST_RESULTS_LPAGE)
+        return -1;
+    // compute page length
+    num = (resp[2] << 8) + resp[3];
+    // Log sense page length 0x190 bytes
+    if (num != 0x190) {
+        return -1;
+    }
+    ucp = resp + 4;
+    if (inProgress)
+        *inProgress = (0xf == (ucp[4] & 0xf)) ? 1 : 0;
+    return 0;
+}
+
 /* Returns a negative value if failed to fetch Contol mode page or it was
    malformed. Returns 0 if GLTSD bit is zero and returns 1 if the GLTSD
    bit is set. Examines default mode page when current==0 else examines
diff --git a/sm5/scsicmds.cpp b/sm5/scsicmds.cpp
index 44177840c3cd96a1f7fa3839dcd470bd6be14be4..0240767ecc4907bd3762eec08ddf87343a2e3c9a 100644
--- a/sm5/scsicmds.cpp
+++ b/sm5/scsicmds.cpp
@@ -46,7 +46,7 @@
 #include "utility.h"
 #include "extern.h"
 
-const char *scsicmds_c_cvsid="$Id: scsicmds.cpp,v 1.65 2003/11/20 01:02:27 dpgilbert Exp $" EXTERN_H_CVSID SCSICMDS_H_CVSID;
+const char *scsicmds_c_cvsid="$Id: scsicmds.cpp,v 1.66 2003/12/02 03:24:17 dpgilbert Exp $" EXTERN_H_CVSID SCSICMDS_H_CVSID;
 
 /* for passing global control variables */
 extern smartmonctrl *con;
@@ -1743,6 +1743,31 @@ int scsiCountFailedSelfTests(int fd, int noisy)
     return (fail_hour << 8) + fails;
 }
 
+/* Returns 0 if able to read self test log page; then outputs 1 into
+   *inProgress if self test still in progress, else outputs 0. */
+int scsiSelfTestInProgress(int fd, int * inProgress)
+{
+    int num;
+    UINT8 * ucp;
+    unsigned char resp[LOG_RESP_SELF_TEST_LEN];
+
+    if (scsiLogSense(fd, SELFTEST_RESULTS_LPAGE, resp, 
+                     LOG_RESP_SELF_TEST_LEN, 0))
+        return -1;
+    if (resp[0] != SELFTEST_RESULTS_LPAGE)
+        return -1;
+    // compute page length
+    num = (resp[2] << 8) + resp[3];
+    // Log sense page length 0x190 bytes
+    if (num != 0x190) {
+        return -1;
+    }
+    ucp = resp + 4;
+    if (inProgress)
+        *inProgress = (0xf == (ucp[4] & 0xf)) ? 1 : 0;
+    return 0;
+}
+
 /* Returns a negative value if failed to fetch Contol mode page or it was
    malformed. Returns 0 if GLTSD bit is zero and returns 1 if the GLTSD
    bit is set. Examines default mode page when current==0 else examines