1. Summary
  2. Files
  3. Support
  4. Report Spam
  5. Create account
  6. Log in

Changeset 3249

Show
Ignore:
Timestamp:
01/31/11 20:33:37 (2 years ago)
Author:
chrfranke
Message:

smartctl: Print help message if no option is specified (ticket #39).
Don't issue any other ATA command if only '-n POWERMODE' is specified.

Location:
trunk/smartmontools
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/smartmontools/CHANGELOG

    r3248 r3249  
    4141<DEVELOPERS: ADDITIONS TO THE CHANGE LOG GO JUST BELOW HERE, PLEASE> 
    4242 
     43  [CF] smartctl: Print help message if no option is specified (ticket #39). 
     44       Don't issue any other ATA command if only '-n POWERMODE' is specified. 
     45 
    4346  [CF] smartd: Output multiple lines via separate syslog(3) calls 
    4447       (ticket #135). 
  • trunk/smartmontools/ataprint.cpp

    r3247 r3249  
    17621762int ataPrintMain (ata_device * device, const ata_print_options & options) 
    17631763{ 
    1764   int returnval = 0; 
    1765  
    17661764  // If requested, check power mode first 
    17671765  const char * powername = 0; 
     
    17731771      case -1: 
    17741772        if (errno == ENOSYS) { 
    1775           pout("CHECK POWER STATUS not implemented, ignoring -n Option\n"); break; 
     1773          pout("CHECK POWER MODE not implemented, ignoring -n option\n"); break; 
    17761774        } 
    17771775        powername = "SLEEP";   powerlimit = 2; 
     
    17841782        powername = "ACTIVE or IDLE"; break; 
    17851783      default: 
    1786         pout("CHECK POWER STATUS returned %d, not ATA compliant, ignoring -n Option\n", powermode); 
     1784        pout("CHECK POWER MODE returned unknown value 0x%02x, ignoring -n option\n", powermode); 
    17871785        break; 
    17881786    } 
     
    18251823  ); 
    18261824 
     1825  // SMART and GP log directories needed ? 
     1826  bool need_smart_logdir = options.smart_logdir; 
     1827 
     1828  bool need_gp_logdir  = ( 
     1829          options.gp_logdir 
     1830       || options.smart_ext_error_log 
     1831       || options.smart_ext_selftest_log 
     1832       || options.sataphy 
     1833  ); 
     1834 
     1835  unsigned i; 
     1836  for (i = 0; i < options.log_requests.size(); i++) { 
     1837    if (options.log_requests[i].gpl) 
     1838      need_gp_logdir = true; 
     1839    else 
     1840      need_smart_logdir = true; 
     1841  } 
     1842 
     1843  // SCT commands needed ? 
     1844  bool need_sct_support = ( 
     1845          options.sct_temp_sts 
     1846       || options.sct_temp_hist 
     1847       || options.sct_temp_int 
     1848       || options.sct_erc_get 
     1849       || options.sct_erc_set 
     1850  ); 
     1851 
     1852  // Exit if no further options specified 
     1853  if (!(   options.drive_info || need_smart_support 
     1854        || need_smart_logdir  || need_gp_logdir 
     1855        || need_sct_support                        )) { 
     1856    if (powername) 
     1857      pout("Device is in %s mode\n", powername); 
     1858    else 
     1859      pout("ATA device successfully opened\n\n" 
     1860           "Use 'smartctl -a' (or '-x') to print SMART (and more) information\n\n"); 
     1861    return 0; 
     1862  } 
     1863 
    18271864  // Start by getting Drive ID information.  We need this, to know if SMART is supported. 
     1865  int returnval = 0; 
    18281866  ata_identify_device drive; memset(&drive, 0, sizeof(drive)); 
    18291867  int retid = ataReadHDIdentity(device,&drive); 
     
    21472185  } 
    21482186 
    2149   // SMART and GP log directories needed? 
    2150   bool need_smart_logdir = ( 
    2151           options.smart_logdir 
    2152           // If GP Log is supported use smart log directory for 
    2153           // error and selftest log support check. 
    2154        || (   isGeneralPurposeLoggingCapable(&drive) 
    2155            && (   options.smart_error_log || options.smart_selftest_log 
    2156                || options.retry_error_log || options.retry_selftest_log)) 
    2157   ); 
    2158  
    2159   bool need_gp_logdir  = ( 
    2160           options.gp_logdir 
    2161        || options.smart_ext_error_log 
    2162        || options.smart_ext_selftest_log 
    2163        || options.sataphy 
    2164   ); 
    2165  
    2166   unsigned i; 
    2167   for (i = 0; i < options.log_requests.size(); i++) { 
    2168     if (options.log_requests[i].gpl) 
    2169       need_gp_logdir = true; 
    2170     else 
    2171       need_smart_logdir = true; 
    2172   } 
     2187  // If GP Log is supported use smart log directory for 
     2188  // error and selftest log support check. 
     2189  if (   isGeneralPurposeLoggingCapable(&drive) 
     2190      && (   options.smart_error_log || options.smart_selftest_log 
     2191          || options.retry_error_log || options.retry_selftest_log)) 
     2192    need_smart_logdir = true; 
    21732193 
    21742194  ata_smart_log_directory smartlogdir_buf, gplogdir_buf; 
     
    23752395  // SCT commands 
    23762396  bool sct_ok = false; 
    2377   if (   options.sct_temp_sts || options.sct_temp_hist || options.sct_temp_int 
    2378       || options.sct_erc_get  || options.sct_erc_set                          ) { 
     2397  if (need_sct_support) { 
    23792398    if (!isSCTCapable(&drive)) { 
    23802399      pout("Warning: device does not support SCT Commands\n"); 
  • trunk/smartmontools/scsiprint.cpp

    r3196 r3249  
    15711571    int res, durationSec; 
    15721572 
     1573    bool any_output = options.drive_info; 
     1574 
    15731575    res = scsiGetDriveInfo(device, &peripheral_type, options.drive_info); 
    15741576    if (res) { 
     
    15771579        else 
    15781580            failuretest(MANDATORY_CMD, returnval |= FAILID); 
     1581        any_output = true; 
    15791582    } 
    15801583 
     
    15821585        if (scsiSmartEnable(device)) 
    15831586            failuretest(MANDATORY_CMD, returnval |= FAILSMART); 
     1587        any_output = true; 
    15841588    } 
    15851589 
     
    15871591        if (scsiSmartDisable(device)) 
    15881592            failuretest(MANDATORY_CMD,returnval |= FAILSMART); 
     1593        any_output = true; 
    15891594    } 
    15901595     
     
    15941599        failuretest(OPTIONAL_CMD,returnval |= FAILSMART); 
    15951600      } 
     1601      any_output = true; 
    15961602    } 
    15971603     
     
    16011607        failuretest(OPTIONAL_CMD,returnval |= FAILSMART); 
    16021608      } 
     1609      any_output = true; 
    16031610    } 
    16041611     
     
    16241631            } 
    16251632        } 
     1633        any_output = true; 
    16261634    }    
    16271635    if (options.smart_vendor_attrib) { 
     
    16421650                scsiPrintSeagateFactoryLPage(device); 
    16431651        } 
     1652        any_output = true; 
    16441653    } 
    16451654    if (options.smart_error_log) { 
     
    16501659            pout("\n[GLTSD (Global Logging Target Save Disable) set. " 
    16511660                 "Enable Save with '-S on']\n"); 
     1661        any_output = true; 
    16521662    } 
    16531663    if (options.smart_selftest_log) { 
     
    16631673        if (0 != res) 
    16641674            failuretest(OPTIONAL_CMD, returnval|=res); 
     1675        any_output = true; 
    16651676    } 
    16661677    if (options.smart_background_log) { 
     
    16761687        if (0 != res) 
    16771688            failuretest(OPTIONAL_CMD, returnval|=res); 
     1689        any_output = true; 
    16781690    } 
    16791691    if (options.smart_default_selftest) { 
     
    16811693            return returnval | FAILSMART; 
    16821694        pout("Default Self Test Successful\n"); 
     1695        any_output = true; 
    16831696    } 
    16841697    if (options.smart_short_cap_selftest) { 
     
    16861699            return returnval | FAILSMART; 
    16871700        pout("Short Foreground Self Test Successful\n"); 
     1701        any_output = true; 
    16881702    } 
    16891703    if (options.smart_short_selftest) { 
     
    16921706        pout("Short Background Self Test has begun\n"); 
    16931707        pout("Use smartctl -X to abort test\n"); 
     1708        any_output = true; 
    16941709    } 
    16951710    if (options.smart_extend_selftest) { 
     
    17071722        } 
    17081723        pout("Use smartctl -X to abort test\n");         
     1724        any_output = true; 
    17091725    } 
    17101726    if (options.smart_extend_cap_selftest) { 
     
    17171733            return returnval | FAILSMART; 
    17181734        pout("Self Test returned without error\n"); 
     1735        any_output = true; 
    17191736    }            
    17201737    if (options.sasphy) { 
    17211738        if (scsiPrintSasPhy(device, options.sasphy_reset)) 
    17221739            return returnval | FAILSMART; 
     1740        any_output = true; 
    17231741    }            
     1742 
     1743    if (!any_output) 
     1744      pout("SCSI device successfully opened\n\n" 
     1745           "Use 'smartctl -a' (or '-x') to print SMART (and more) information\n\n"); 
     1746 
    17241747    return returnval; 
    17251748} 
  • trunk/smartmontools/smartctl.8.in

    r3203 r3249  
    544544checks when the device is in a low\-power mode. It may be used to prevent 
    545545a disk from being spun\-up by \fBsmartctl\fP. The power mode is ignored by 
    546 default. The allowed values of POWERMODE are: 
     546default.  A nonzero exit status is returned if the device is in one of the 
     547specified low\-power modes (see RETURN VALUES below). 
     548 
     549Note: If this option is used it may also be necessary to specify the device 
     550type with the \'-d\' option.  Otherwise the device may spin up due to 
     551commands issued during device type autodetection. 
     552 
     553The valid arguments to this option are: 
    547554 
    548555.I never 
     
    16711678.B smartctl \-a /dev/sdb 
    16721679.fi 
    1673 Print a large amount of SMART information for drive /dev/sda . This may 
     1680Print a large amount of SMART information for drive /dev/sdb . This may 
    16741681be a SCSI disk or an ATA (SATA) disk. 
    16751682.PP 
     
    18031810.TP 
    18041811.B Bit 1: 
    1805 Device open failed, or device did not return an IDENTIFY DEVICE structure.  
     1812Device open failed, device did not return an IDENTIFY DEVICE structure, 
     1813or device is in a low-power mode (see \'\-n\' option above). 
    18061814.TP 
    18071815.B Bit 2: