1. Summary
  2. Files
  3. Support
  4. Report Spam
  5. Create account
  6. Log in
Show
Ignore:
Timestamp:
02/11/12 14:52:17 (16 months ago)
Author:
chrfranke
Message:

smartctl: Add options '-g/e lookahead' and '-g/e wcache' to get/set
read look-ahead and write cache feature.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/smartmontools/ataprint.cpp

    r3505 r3506  
    21242124  if (!(   options.drive_info || need_smart_support 
    21252125        || need_smart_logdir  || need_gp_logdir 
    2126         || need_sct_support 
    2127         || options.get_aam || options.set_aam 
    2128         || options.get_apm || options.set_apm)) { 
     2126        || need_sct_support || options.get_set_used)) { 
    21292127    if (powername) 
    21302128      pout("Device is in %s mode\n", powername); 
     
    22472245  } 
    22482246 
     2247  // Print read look-ahead status 
     2248  if (options.get_lookahead) { 
     2249    pout("Rd look-ahead is: %s\n", 
     2250      (   (drive.command_set_2 & 0xc000) != 0x4000 // word083 
     2251       || !(drive.command_set_1 & 0x0040)) ? "Unavailable" : // word082 
     2252       !(drive.cfs_enable_1 & 0x0040) ? "Disabled" : "Enabled"); // word085 
     2253  } 
     2254 
     2255  // Print write cache status 
     2256  if (options.get_wcache) { 
     2257    pout("Write cache is:   %s\n", 
     2258      (   (drive.command_set_2 & 0xc000) != 0x4000 // word083 
     2259       || !(drive.command_set_1 & 0x0020)) ? "Unavailable" : // word082 
     2260       !(drive.cfs_enable_1 & 0x0020) ? "Disabled" : "Enabled"); // word085 
     2261  } 
     2262 
    22492263  // Print remaining drive info 
    22502264  if (options.drive_info) { 
     
    23032317        pout("APM disabled\n"); 
    23042318    } 
     2319  } 
     2320 
     2321  // Enable/Disable read look-ahead 
     2322  if (options.set_lookahead) { 
     2323    bool enable = (options.set_lookahead > 0); 
     2324    if (!ata_set_features(device, (enable ? ATA_ENABLE_READ_LOOK_AHEAD : ATA_DISABLE_READ_LOOK_AHEAD))) { 
     2325        pout("Read look-ahead %sable failed: %s\n", (enable ? "en" : "dis"), device->get_errmsg()); 
     2326        returnval |= FAILSMART; 
     2327    } 
     2328    else 
     2329      pout("Read look-ahead %sabled\n", (enable ? "en" : "dis")); 
     2330  } 
     2331 
     2332  // Enable/Disable write cache 
     2333  if (options.set_wcache) { 
     2334    bool enable = (options.set_wcache > 0); 
     2335    if (!ata_set_features(device, (enable ? ATA_ENABLE_WRITE_CACHE : ATA_DISABLE_WRITE_CACHE))) { 
     2336        pout("Write cache %sable failed: %s\n", (enable ? "en" : "dis"), device->get_errmsg()); 
     2337        returnval |= FAILSMART; 
     2338    } 
     2339    else 
     2340      pout("Write cache %sabled\n", (enable ? "en" : "dis")); 
    23052341  } 
    23062342