Commit fb3ca7c4 authored by dlukes's avatar dlukes
Browse files

r3019 & r3018 reverted back to r3017 state

see ticket #33



git-svn-id: https://smartmontools.svn.sourceforge.net/svnroot/smartmontools/trunk@3020 4ea69e1a-61f1-4043-bf83-b5c94c648137
parent 91aefa23
......@@ -43,9 +43,6 @@ NOTES FOR FUTURE RELEASES: see TODO file.
<DEVELOPERS: ADDITIONS TO THE CHANGE LOG GO JUST BELOW HERE, PLEASE>
[DL] '-o on' option extended to '-o on[,N]'
the timeout is not limited to be 4 hours anymore
[CF] drivedb.h update:
- SAMSUNG SpinPoint M40/60/80 series
......
......@@ -1479,9 +1479,10 @@ int ataDisableAutoSave(ata_device * device){
// marked "OBSOLETE". It is defined in SFF-8035i Revision 2, and most
// vendors still support it for backwards compatibility. IBM documents
// it for some drives.
int ataEnableAutoOffline (ata_device * device, int timeout){
int ataEnableAutoOffline (ata_device * device){
if (smartcommandhandler(device, AUTO_OFFLINE, timeout, NULL)){
/* timer hard coded to 4 hours */
if (smartcommandhandler(device, AUTO_OFFLINE, 248, NULL)){
syserror("Error SMART Enable Automatic Offline failed");
return -1;
}
......
......@@ -735,7 +735,7 @@ int ataEnableAutoSave(ata_device * device);
int ataDisableAutoSave(ata_device * device);
/* Automatic Offline Testing */
int ataEnableAutoOffline (ata_device * device, int timeout);
int ataEnableAutoOffline (ata_device * device);
int ataDisableAutoOffline (ata_device * device);
/* S.M.A.R.T. test commands */
......
......@@ -1929,44 +1929,12 @@ int ataPrintMain (ata_device * device, const ata_print_options & options)
failuretest(OPTIONAL_CMD, returnval|=FAILSMART);
}
needupdate=1;
int atat = secs_to_atatimer(options.smart_auto_offl_timeout);
if (ataEnableAutoOffline(device, atat)){
if (ataEnableAutoOffline(device)){
pout( "Smartctl: SMART Enable Automatic Offline Failed.\n\n");
failuretest(OPTIONAL_CMD, returnval|=FAILSMART);
}
else {
pout("SMART Automatic Offline Testing Enabled");
int timeout;
timeout = atatimer_to_secs(atat);
if (timeout > 0) {
pout(" every");
if (timeout==8*3600) {
pout(" 8-12 hours");
} else {
int hours, mins;
hours = timeout / 3600;
timeout%=3600;
mins = timeout / 60;
timeout%=60;
if (hours > 0)
pout(" %d hour%s", hours, hours>1?"s":"");
if (mins > 0)
pout(" %d minute%s", mins, mins>1?"s":"");
if (timeout > 0)
pout(" %d second%s", timeout, timeout>1?"s":"");
};
};
pout(".\n");
}
else
pout("SMART Automatic Offline Testing Enabled every four hours.\n");
}
if (options.smart_auto_offl_disable) {
......
......@@ -67,7 +67,6 @@ struct ata_print_options
bool smart_disable, smart_enable;
bool smart_auto_offl_disable, smart_auto_offl_enable;
int smart_auto_offl_timeout;
bool smart_auto_save_disable, smart_auto_save_enable;
int smart_selftest_type; // OFFLINE_FULL_SCAN, ..., see atacmds.h. -1 for no test
......@@ -101,7 +100,6 @@ struct ata_print_options
sataphy(false), sataphy_reset(false),
smart_disable(false), smart_enable(false),
smart_auto_offl_disable(false), smart_auto_offl_enable(false),
smart_auto_offl_timeout(4*3600),
smart_auto_save_disable(false), smart_auto_save_enable(false),
smart_selftest_type(-1),
sct_temp_int(0), sct_temp_int_pers(false),
......
This diff is collapsed.
......@@ -362,47 +362,9 @@ const char * parse_options(int argc, char** argv,
}
break;
case 'o':
if (!strncmp(optarg,"on", 2)) {
if (!strcmp(optarg,"on")) {
ataopts.smart_auto_offl_enable = true;
ataopts.smart_auto_offl_disable = false;
if (optarg[2]=='\0') {
ataopts.smart_auto_offl_timeout = 4*3600; /* default is 4 hours */
break;
};
if (optarg[2]!=',' || optarg[3]=='\0') {
badarg = true;
break;
};
long timeout;
char *endptr;
timeout = strtol(optarg+3, &endptr, 0);
if (timeout < 1) {
badarg = true; // non-positive number
break;
};
switch (*endptr) {
case 's':
endptr++;
break;
case 'm':
timeout*=60;
endptr++;
break;
case 'h':
timeout*=3600;
endptr++;
break;
};
if (*endptr != '\0') {
badarg = true; // extra character after parameter
break;
};
ataopts.smart_auto_offl_timeout = (int)timeout;
} else if (!strcmp(optarg,"off")) {
ataopts.smart_auto_offl_disable = true;
ataopts.smart_auto_offl_enable = false;
......
......@@ -258,7 +258,6 @@ struct dev_config
bool permissive; // Ignore failed SMART commands
char autosave; // 1=disable, 2=enable Autosave Attributes
char autoofflinetest; // 1=disable, 2=enable Auto Offline Test
int autoofflinetestperiod; // seconds between two Auto Offline Test
unsigned char fix_firmwarebug; // FIX_*, see atacmds.h
bool ignorepresets; // Ignore database of -v options
bool showpresets; // Show database entry for this device
......@@ -300,7 +299,6 @@ dev_config::dev_config()
permissive(false),
autosave(0),
autoofflinetest(0),
autoofflinetestperiod(4*3600),
fix_firmwarebug(FIX_NOTSPECIFIED),
ignorepresets(false),
showpresets(false),
......@@ -1750,7 +1748,7 @@ static int ATADeviceScan(dev_config & cfg, dev_state & state, ata_device * atade
if (!isSupportAutomaticTimer(&state.smartval))
PrintOut(LOG_INFO,"Device: %s, SMART Automatic Offline Testing unsupported...\n",name);
// ... but then try anyway
if ((cfg.autoofflinetest==1)?ataDisableAutoOffline(atadev):ataEnableAutoOffline(atadev, secs_to_atatimer(cfg.autoofflinetestperiod)))
if ((cfg.autoofflinetest==1)?ataDisableAutoOffline(atadev):ataEnableAutoOffline(atadev))
PrintOut(LOG_INFO,"Device: %s, %s SMART Automatic Offline Testing failed.\n", name, what);
else
PrintOut(LOG_INFO,"Device: %s, %sd SMART Automatic Offline Testing.\n", name, what);
......@@ -3204,46 +3202,8 @@ static int ParseToken(char * token, dev_config & cfg)
// automatic offline testing enable/disable
if ((arg = strtok(NULL, delim)) == NULL) {
missingarg = 1;
} else if (!strncmp(arg, "on", 2)) {
} else if (!strcmp(arg, "on")) {
cfg.autoofflinetest = 2;
if (arg[2]=='\0') {
cfg.autoofflinetestperiod = 4*3600; /* default value */
break;
};
if (optarg[2]!=',' || optarg[3]=='\0') {
badarg = 1;
break;
};
long timeout;
char *endptr;
timeout = strtol(optarg+3, &endptr, 0);
if (timeout < 1) {
badarg = 1; // non-positive number
break;
};
switch (*endptr) {
case 's':
endptr++;
break;
case 'm':
timeout*=60;
endptr++;
break;
case 'h':
timeout*=3600;
endptr++;
break;
};
if (*endptr != '\0') {
badarg = 1; // extra character after parameter
break;
};
cfg.autoofflinetestperiod = (int)timeout;
} else if (!strcmp(arg, "off")) {
cfg.autoofflinetest = 1;
} else {
......
......@@ -779,61 +779,3 @@ int safe_snprintf(char *buf, int size, const char *fmt, ...)
#endif
// Convert seconds to ata timer scale and vice versa
//
// +---------------------+------------------------------+
// | Sector Count | Corresponding |
// | Register contents | Timeout Period |
// +---------------------+------------------------------+
// | 0 (00h) | Timeout Disabled |
// | 1 - 240 (01h-F0h) | (value * 5) seconds |
// | 241 - 251 (F1h-FBh) | ((value - 240) * 30) minutes |
// | 252 (FCh) | 21 minutes |
// | 253 (FDh) | Vendor unique period between |
// | | 8 and 12 hours |
// | 254 (FEh) | Reserved |
// | 255 (FFh) | 21 minutes 15 seconds |
// +---------------------+------------------------------+
// (Table taken from X3T10/0948D Revision 4c)
unsigned int
secs_to_atatimer(unsigned int tmo) {
if (tmo == 0)
return 0;
if (tmo < 5)
return 1;
if (tmo<=1200)
return tmo / 5;
if (tmo<1200+60)
return 240;
if (tmo<1200+75)
return 252;
if (tmo<1800)
return 255;
if (tmo <19800+1800 )
return (tmo / 1800)+240;
if (tmo < 8*3600)
return 251;
return 253;
};
unsigned int
atatimer_to_secs(unsigned int atat) {
switch (atat) {
case 0: return 0;
case 252: return 21*60;
case 253: return 8*3600;
case 254: return -1;
case 255: return 21*60+15;
};
if (atat<=240)
return(atat*5);
return((atat-240)*1800);
};
......@@ -336,6 +336,3 @@ private:
#endif
unsigned int secs_to_atatimer(unsigned int tmo);
unsigned int atatimer_to_secs(unsigned int atat);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment