Skip to content
Snippets Groups Projects
Commit 63450400 authored by dpgilbert's avatar dpgilbert
Browse files

remember mode sense cmd length

git-svn-id: https://smartmontools.svn.sourceforge.net/svnroot/smartmontools/trunk@1230 4ea69e1a-61f1-4043-bf83-b5c94c648137
parent 2cb52ff3
No related branches found
No related tags found
No related merge requests found
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
#define GBUF_SIZE 65535 #define GBUF_SIZE 65535
const char* scsiprint_c_cvsid="$Id: scsiprint.c,v 1.56 2003/11/14 05:29:55 dpgilbert Exp $" const char* scsiprint_c_cvsid="$Id: scsiprint.c,v 1.57 2003/11/14 11:44:26 dpgilbert Exp $"
EXTERN_H_CVSID SCSICMDS_H_CVSID SCSIPRINT_H_CVSID SMARTCTL_H_CVSID UTILITY_H_CVSID; EXTERN_H_CVSID SCSICMDS_H_CVSID SCSIPRINT_H_CVSID SMARTCTL_H_CVSID UTILITY_H_CVSID;
// control block which points to external global control variables // control block which points to external global control variables
...@@ -65,6 +65,9 @@ static int gSeagateFactoryLPage = 0; ...@@ -65,6 +65,9 @@ static int gSeagateFactoryLPage = 0;
/* Mode pages supported */ /* Mode pages supported */
static int gIecMPage = 1; /* N.B. assume it until we know otherwise */ static int gIecMPage = 1; /* N.B. assume it until we know otherwise */
/* Remember last successful mode sense/select command */
static int modese_len = 0;
static void scsiGetSupportedLogPages(int device) static void scsiGetSupportedLogPages(int device)
{ {
...@@ -113,12 +116,13 @@ void scsiGetSmartData(int device) ...@@ -113,12 +116,13 @@ void scsiGetSmartData(int device)
UINT8 asc; UINT8 asc;
UINT8 ascq; UINT8 ascq;
UINT8 currenttemp = 0; UINT8 currenttemp = 0;
UINT8 triptemp = 0;
const char * cp; const char * cp;
int err; int err;
QUIETON(con); QUIETON(con);
if ((err = scsiCheckIE(device, gSmartLPage, gTempLPage, if ((err = scsiCheckIE(device, gSmartLPage, gTempLPage, &asc,
&asc, &ascq, &currenttemp))) { &ascq, &currenttemp, &triptemp))) {
/* error message already announced */ /* error message already announced */
QUIETOFF(con); QUIETOFF(con);
return; return;
...@@ -138,6 +142,8 @@ void scsiGetSmartData(int device) ...@@ -138,6 +142,8 @@ void scsiGetSmartData(int device)
else else
pout("Current Drive Temperature: <not available>\n"); pout("Current Drive Temperature: <not available>\n");
} }
if (triptemp && !gTempLPage)
pout("Drive Trip Temperature: %d C\n", triptemp);
} }
...@@ -242,7 +248,7 @@ static void scsiPrintSeagateCacheLPage(int device) ...@@ -242,7 +248,7 @@ static void scsiPrintSeagateCacheLPage(int device)
unsigned char * xp; unsigned char * xp;
unsigned long long ull; unsigned long long ull;
pout("Vendor (Seagate) cache information\n"); pout("\nVendor (Seagate) cache information\n");
if ((err = scsiLogSense(device, SEAGATE_CACHE_LPAGE, gBuf, if ((err = scsiLogSense(device, SEAGATE_CACHE_LPAGE, gBuf,
LOG_RESP_LEN, 0))) { LOG_RESP_LEN, 0))) {
QUIETON(con); QUIETON(con);
...@@ -539,10 +545,11 @@ static int scsiPrintSelfTest(int device) ...@@ -539,10 +545,11 @@ static int scsiPrintSelfTest(int device)
pout("No self-tests have been logged\n"); pout("No self-tests have been logged\n");
else else
pout("\n"); pout("\n");
if ((0 == scsiFetchExtendedSelfTestTime(device, &durationSec)) && if ((0 == scsiFetchExtendedSelfTestTime(device, &durationSec,
(durationSec > 0)) modese_len)) && (durationSec > 0)) {
pout("Long (extended) Self Test duration: %d seconds " pout("Long (extended) Self Test duration: %d seconds "
"[%.1f minutes]\n", durationSec, durationSec / 60.0); "[%.1f minutes]\n", durationSec, durationSec / 60.0);
}
return 0; return 0;
} }
...@@ -648,7 +655,7 @@ static int scsiGetDriveInfo(int device, UINT8 * peripheral_type, int all) ...@@ -648,7 +655,7 @@ static int scsiGetDriveInfo(int device, UINT8 * peripheral_type, int all)
return 0; return 0;
} }
if ((err = scsiFetchIECmpage(device, &iec))) { if ((err = scsiFetchIECmpage(device, &iec, modese_len))) {
if (!is_tape) { if (!is_tape) {
QUIETON(con); QUIETON(con);
pout("Device does not support SMART"); pout("Device does not support SMART");
...@@ -667,7 +674,8 @@ static int scsiGetDriveInfo(int device, UINT8 * peripheral_type, int all) ...@@ -667,7 +674,8 @@ static int scsiGetDriveInfo(int device, UINT8 * peripheral_type, int all)
} }
gIecMPage = 0; gIecMPage = 0;
return 0; return 0;
} } else
modese_len = iec.modese_len;
if (!is_tape) if (!is_tape)
pout("Device supports SMART and is %s\n", pout("Device supports SMART and is %s\n",
(scsi_IsExceptionControlEnabled(&iec)) ? "Enabled" : "Disabled"); (scsi_IsExceptionControlEnabled(&iec)) ? "Enabled" : "Disabled");
...@@ -682,13 +690,15 @@ static int scsiSmartEnable(int device) ...@@ -682,13 +690,15 @@ static int scsiSmartEnable(int device)
struct scsi_iec_mode_page iec; struct scsi_iec_mode_page iec;
int err; int err;
if ((err = scsiFetchIECmpage(device, &iec))) { if ((err = scsiFetchIECmpage(device, &iec, modese_len))) {
QUIETON(con); QUIETON(con);
pout("unable to fetch IEC (SMART) mode page [%s]\n", pout("unable to fetch IEC (SMART) mode page [%s]\n",
scsiErrString(err)); scsiErrString(err));
QUIETOFF(con); QUIETOFF(con);
return 1; return 1;
} } else
modese_len = iec.modese_len;
if ((err = scsiSetExceptionControlAndWarning(device, 1, &iec))) { if ((err = scsiSetExceptionControlAndWarning(device, 1, &iec))) {
QUIETON(con); QUIETON(con);
pout("unable to enable Exception control and warning [%s]\n", pout("unable to enable Exception control and warning [%s]\n",
...@@ -697,11 +707,13 @@ static int scsiSmartEnable(int device) ...@@ -697,11 +707,13 @@ static int scsiSmartEnable(int device)
return 1; return 1;
} }
/* Need to refetch 'iec' since could be modified by previous call */ /* Need to refetch 'iec' since could be modified by previous call */
if ((err = scsiFetchIECmpage(device, &iec))) { if ((err = scsiFetchIECmpage(device, &iec, modese_len))) {
pout("unable to fetch IEC (SMART) mode page [%s]\n", pout("unable to fetch IEC (SMART) mode page [%s]\n",
scsiErrString(err)); scsiErrString(err));
return 1; return 1;
} } else
modese_len = iec.modese_len;
pout("Informational Exceptions (SMART) %s\n", pout("Informational Exceptions (SMART) %s\n",
scsi_IsExceptionControlEnabled(&iec) ? "enabled" : "disabled"); scsi_IsExceptionControlEnabled(&iec) ? "enabled" : "disabled");
pout("Temperature warning %s\n", pout("Temperature warning %s\n",
...@@ -714,13 +726,15 @@ static int scsiSmartDisable(int device) ...@@ -714,13 +726,15 @@ static int scsiSmartDisable(int device)
struct scsi_iec_mode_page iec; struct scsi_iec_mode_page iec;
int err; int err;
if ((err = scsiFetchIECmpage(device, &iec))) { if ((err = scsiFetchIECmpage(device, &iec, modese_len))) {
QUIETON(con); QUIETON(con);
pout("unable to fetch IEC (SMART) mode page [%s]\n", pout("unable to fetch IEC (SMART) mode page [%s]\n",
scsiErrString(err)); scsiErrString(err));
QUIETOFF(con); QUIETOFF(con);
return 1; return 1;
} } else
modese_len = iec.modese_len;
if ((err = scsiSetExceptionControlAndWarning(device, 0, &iec))) { if ((err = scsiSetExceptionControlAndWarning(device, 0, &iec))) {
QUIETON(con); QUIETON(con);
pout("unable to disable Exception control and warning [%s]\n", pout("unable to disable Exception control and warning [%s]\n",
...@@ -729,11 +743,13 @@ static int scsiSmartDisable(int device) ...@@ -729,11 +743,13 @@ static int scsiSmartDisable(int device)
return 1; return 1;
} }
/* Need to refetch 'iec' since could be modified by previous call */ /* Need to refetch 'iec' since could be modified by previous call */
if ((err = scsiFetchIECmpage(device, &iec))) { if ((err = scsiFetchIECmpage(device, &iec, modese_len))) {
pout("unable to fetch IEC (SMART) mode page [%s]\n", pout("unable to fetch IEC (SMART) mode page [%s]\n",
scsiErrString(err)); scsiErrString(err));
return 1; return 1;
} } else
modese_len = iec.modese_len;
pout("Informational Exceptions (SMART) %s\n", pout("Informational Exceptions (SMART) %s\n",
scsi_IsExceptionControlEnabled(&iec) ? "enabled" : "disabled"); scsi_IsExceptionControlEnabled(&iec) ? "enabled" : "disabled");
pout("Temperature warning %s\n", pout("Temperature warning %s\n",
...@@ -882,8 +898,8 @@ int scsiPrintMain(const char *dev_name, int fd) ...@@ -882,8 +898,8 @@ int scsiPrintMain(const char *dev_name, int fd)
return returnval; return returnval;
} }
pout("Extended Background Self Test has begun\n"); pout("Extended Background Self Test has begun\n");
if ((0 == scsiFetchExtendedSelfTestTime(fd, &durationSec)) && if ((0 == scsiFetchExtendedSelfTestTime(fd, &durationSec,
(durationSec > 0)) { modese_len)) && (durationSec > 0)) {
time_t t = time(NULL); time_t t = time(NULL);
t += durationSec; t += durationSec;
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
#define GBUF_SIZE 65535 #define GBUF_SIZE 65535
const char* scsiprint_c_cvsid="$Id: scsiprint.cpp,v 1.56 2003/11/14 05:29:55 dpgilbert Exp $" const char* scsiprint_c_cvsid="$Id: scsiprint.cpp,v 1.57 2003/11/14 11:44:26 dpgilbert Exp $"
EXTERN_H_CVSID SCSICMDS_H_CVSID SCSIPRINT_H_CVSID SMARTCTL_H_CVSID UTILITY_H_CVSID; EXTERN_H_CVSID SCSICMDS_H_CVSID SCSIPRINT_H_CVSID SMARTCTL_H_CVSID UTILITY_H_CVSID;
// control block which points to external global control variables // control block which points to external global control variables
...@@ -65,6 +65,9 @@ static int gSeagateFactoryLPage = 0; ...@@ -65,6 +65,9 @@ static int gSeagateFactoryLPage = 0;
/* Mode pages supported */ /* Mode pages supported */
static int gIecMPage = 1; /* N.B. assume it until we know otherwise */ static int gIecMPage = 1; /* N.B. assume it until we know otherwise */
/* Remember last successful mode sense/select command */
static int modese_len = 0;
static void scsiGetSupportedLogPages(int device) static void scsiGetSupportedLogPages(int device)
{ {
...@@ -113,12 +116,13 @@ void scsiGetSmartData(int device) ...@@ -113,12 +116,13 @@ void scsiGetSmartData(int device)
UINT8 asc; UINT8 asc;
UINT8 ascq; UINT8 ascq;
UINT8 currenttemp = 0; UINT8 currenttemp = 0;
UINT8 triptemp = 0;
const char * cp; const char * cp;
int err; int err;
QUIETON(con); QUIETON(con);
if ((err = scsiCheckIE(device, gSmartLPage, gTempLPage, if ((err = scsiCheckIE(device, gSmartLPage, gTempLPage, &asc,
&asc, &ascq, &currenttemp))) { &ascq, &currenttemp, &triptemp))) {
/* error message already announced */ /* error message already announced */
QUIETOFF(con); QUIETOFF(con);
return; return;
...@@ -138,6 +142,8 @@ void scsiGetSmartData(int device) ...@@ -138,6 +142,8 @@ void scsiGetSmartData(int device)
else else
pout("Current Drive Temperature: <not available>\n"); pout("Current Drive Temperature: <not available>\n");
} }
if (triptemp && !gTempLPage)
pout("Drive Trip Temperature: %d C\n", triptemp);
} }
...@@ -242,7 +248,7 @@ static void scsiPrintSeagateCacheLPage(int device) ...@@ -242,7 +248,7 @@ static void scsiPrintSeagateCacheLPage(int device)
unsigned char * xp; unsigned char * xp;
unsigned long long ull; unsigned long long ull;
pout("Vendor (Seagate) cache information\n"); pout("\nVendor (Seagate) cache information\n");
if ((err = scsiLogSense(device, SEAGATE_CACHE_LPAGE, gBuf, if ((err = scsiLogSense(device, SEAGATE_CACHE_LPAGE, gBuf,
LOG_RESP_LEN, 0))) { LOG_RESP_LEN, 0))) {
QUIETON(con); QUIETON(con);
...@@ -539,10 +545,11 @@ static int scsiPrintSelfTest(int device) ...@@ -539,10 +545,11 @@ static int scsiPrintSelfTest(int device)
pout("No self-tests have been logged\n"); pout("No self-tests have been logged\n");
else else
pout("\n"); pout("\n");
if ((0 == scsiFetchExtendedSelfTestTime(device, &durationSec)) && if ((0 == scsiFetchExtendedSelfTestTime(device, &durationSec,
(durationSec > 0)) modese_len)) && (durationSec > 0)) {
pout("Long (extended) Self Test duration: %d seconds " pout("Long (extended) Self Test duration: %d seconds "
"[%.1f minutes]\n", durationSec, durationSec / 60.0); "[%.1f minutes]\n", durationSec, durationSec / 60.0);
}
return 0; return 0;
} }
...@@ -648,7 +655,7 @@ static int scsiGetDriveInfo(int device, UINT8 * peripheral_type, int all) ...@@ -648,7 +655,7 @@ static int scsiGetDriveInfo(int device, UINT8 * peripheral_type, int all)
return 0; return 0;
} }
if ((err = scsiFetchIECmpage(device, &iec))) { if ((err = scsiFetchIECmpage(device, &iec, modese_len))) {
if (!is_tape) { if (!is_tape) {
QUIETON(con); QUIETON(con);
pout("Device does not support SMART"); pout("Device does not support SMART");
...@@ -667,7 +674,8 @@ static int scsiGetDriveInfo(int device, UINT8 * peripheral_type, int all) ...@@ -667,7 +674,8 @@ static int scsiGetDriveInfo(int device, UINT8 * peripheral_type, int all)
} }
gIecMPage = 0; gIecMPage = 0;
return 0; return 0;
} } else
modese_len = iec.modese_len;
if (!is_tape) if (!is_tape)
pout("Device supports SMART and is %s\n", pout("Device supports SMART and is %s\n",
(scsi_IsExceptionControlEnabled(&iec)) ? "Enabled" : "Disabled"); (scsi_IsExceptionControlEnabled(&iec)) ? "Enabled" : "Disabled");
...@@ -682,13 +690,15 @@ static int scsiSmartEnable(int device) ...@@ -682,13 +690,15 @@ static int scsiSmartEnable(int device)
struct scsi_iec_mode_page iec; struct scsi_iec_mode_page iec;
int err; int err;
if ((err = scsiFetchIECmpage(device, &iec))) { if ((err = scsiFetchIECmpage(device, &iec, modese_len))) {
QUIETON(con); QUIETON(con);
pout("unable to fetch IEC (SMART) mode page [%s]\n", pout("unable to fetch IEC (SMART) mode page [%s]\n",
scsiErrString(err)); scsiErrString(err));
QUIETOFF(con); QUIETOFF(con);
return 1; return 1;
} } else
modese_len = iec.modese_len;
if ((err = scsiSetExceptionControlAndWarning(device, 1, &iec))) { if ((err = scsiSetExceptionControlAndWarning(device, 1, &iec))) {
QUIETON(con); QUIETON(con);
pout("unable to enable Exception control and warning [%s]\n", pout("unable to enable Exception control and warning [%s]\n",
...@@ -697,11 +707,13 @@ static int scsiSmartEnable(int device) ...@@ -697,11 +707,13 @@ static int scsiSmartEnable(int device)
return 1; return 1;
} }
/* Need to refetch 'iec' since could be modified by previous call */ /* Need to refetch 'iec' since could be modified by previous call */
if ((err = scsiFetchIECmpage(device, &iec))) { if ((err = scsiFetchIECmpage(device, &iec, modese_len))) {
pout("unable to fetch IEC (SMART) mode page [%s]\n", pout("unable to fetch IEC (SMART) mode page [%s]\n",
scsiErrString(err)); scsiErrString(err));
return 1; return 1;
} } else
modese_len = iec.modese_len;
pout("Informational Exceptions (SMART) %s\n", pout("Informational Exceptions (SMART) %s\n",
scsi_IsExceptionControlEnabled(&iec) ? "enabled" : "disabled"); scsi_IsExceptionControlEnabled(&iec) ? "enabled" : "disabled");
pout("Temperature warning %s\n", pout("Temperature warning %s\n",
...@@ -714,13 +726,15 @@ static int scsiSmartDisable(int device) ...@@ -714,13 +726,15 @@ static int scsiSmartDisable(int device)
struct scsi_iec_mode_page iec; struct scsi_iec_mode_page iec;
int err; int err;
if ((err = scsiFetchIECmpage(device, &iec))) { if ((err = scsiFetchIECmpage(device, &iec, modese_len))) {
QUIETON(con); QUIETON(con);
pout("unable to fetch IEC (SMART) mode page [%s]\n", pout("unable to fetch IEC (SMART) mode page [%s]\n",
scsiErrString(err)); scsiErrString(err));
QUIETOFF(con); QUIETOFF(con);
return 1; return 1;
} } else
modese_len = iec.modese_len;
if ((err = scsiSetExceptionControlAndWarning(device, 0, &iec))) { if ((err = scsiSetExceptionControlAndWarning(device, 0, &iec))) {
QUIETON(con); QUIETON(con);
pout("unable to disable Exception control and warning [%s]\n", pout("unable to disable Exception control and warning [%s]\n",
...@@ -729,11 +743,13 @@ static int scsiSmartDisable(int device) ...@@ -729,11 +743,13 @@ static int scsiSmartDisable(int device)
return 1; return 1;
} }
/* Need to refetch 'iec' since could be modified by previous call */ /* Need to refetch 'iec' since could be modified by previous call */
if ((err = scsiFetchIECmpage(device, &iec))) { if ((err = scsiFetchIECmpage(device, &iec, modese_len))) {
pout("unable to fetch IEC (SMART) mode page [%s]\n", pout("unable to fetch IEC (SMART) mode page [%s]\n",
scsiErrString(err)); scsiErrString(err));
return 1; return 1;
} } else
modese_len = iec.modese_len;
pout("Informational Exceptions (SMART) %s\n", pout("Informational Exceptions (SMART) %s\n",
scsi_IsExceptionControlEnabled(&iec) ? "enabled" : "disabled"); scsi_IsExceptionControlEnabled(&iec) ? "enabled" : "disabled");
pout("Temperature warning %s\n", pout("Temperature warning %s\n",
...@@ -882,8 +898,8 @@ int scsiPrintMain(const char *dev_name, int fd) ...@@ -882,8 +898,8 @@ int scsiPrintMain(const char *dev_name, int fd)
return returnval; return returnval;
} }
pout("Extended Background Self Test has begun\n"); pout("Extended Background Self Test has begun\n");
if ((0 == scsiFetchExtendedSelfTestTime(fd, &durationSec)) && if ((0 == scsiFetchExtendedSelfTestTime(fd, &durationSec,
(durationSec > 0)) { modese_len)) && (durationSec > 0)) {
time_t t = time(NULL); time_t t = time(NULL);
t += durationSec; t += durationSec;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment