smartmontools SVN Rev 3317
Utility to control and monitor storage systems with "S.M.A.R.T."
ataprint.h
Go to the documentation of this file.
00001 /*
00002  * ataprint.h
00003  *
00004  * Home page of code is: http://smartmontools.sourceforge.net
00005  *
00006  * Copyright (C) 2002-9 Bruce Allen <smartmontools-support@lists.sourceforge.net>
00007  * Copyright (C) 2008-12 Christian Franke <smartmontools-support@lists.sourceforge.net>
00008  * Copyright (C) 1999-2000 Michael Cornwell <cornwell@acm.org>
00009  *
00010  * This program is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2, or (at your option)
00013  * any later version.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * (for example COPYING); If not, see <http://www.gnu.org/licenses/>.
00017  *
00018  * This code was originally developed as a Senior Thesis by Michael Cornwell
00019  * at the Concurrent Systems Laboratory (now part of the Storage Systems
00020  * Research Center), Jack Baskin School of Engineering, University of
00021  * California, Santa Cruz. http://ssrc.soe.ucsc.edu/
00022  *
00023  */
00024 
00025 #ifndef ATAPRINT_H_
00026 #define ATAPRINT_H_
00027 
00028 #define ATAPRINT_H_CVSID "$Id: ataprint.h 3825 2013-07-06 21:38:25Z samm2 $\n"
00029 
00030 #include <vector>
00031 
00032 // Request to dump a GP or SMART log
00033 struct ata_log_request
00034 {
00035   bool gpl; // false: SMART, true: GP
00036   unsigned char logaddr; // Log address
00037   unsigned page; // First page (sector)
00038   unsigned nsectors; // # Sectors
00039 
00040   ata_log_request()
00041     : gpl(false), logaddr(0), page(0), nsectors(0)
00042     { }
00043 };
00044 
00045 // Options for ataPrintMain
00046 struct ata_print_options
00047 {
00048   bool drive_info;
00049   int identify_word_level, identify_bit_level;
00050   bool smart_check_status;
00051   bool smart_general_values;
00052   bool smart_vendor_attrib;
00053   bool smart_error_log;
00054   bool smart_selftest_log;
00055   bool smart_selective_selftest_log;
00056 
00057   bool gp_logdir, smart_logdir;
00058   unsigned smart_ext_error_log;
00059   unsigned smart_ext_selftest_log;
00060   bool retry_error_log, retry_selftest_log;
00061 
00062   std::vector<ata_log_request> log_requests;
00063 
00064   bool devstat_all_pages, devstat_ssd_page;
00065   std::vector<int> devstat_pages;
00066 
00067   bool sct_temp_sts, sct_temp_hist;
00068   bool sct_erc_get;
00069   bool sct_erc_set;
00070   unsigned sct_erc_readtime, sct_erc_writetime;
00071   bool sataphy, sataphy_reset;
00072 
00073   bool smart_disable, smart_enable;
00074   bool smart_auto_offl_disable, smart_auto_offl_enable;
00075   bool smart_auto_save_disable, smart_auto_save_enable;
00076 
00077   int smart_selftest_type; // OFFLINE_FULL_SCAN, ..., see atacmds.h. -1 for no test
00078   bool smart_selftest_force; // Ignore already running test
00079   ata_selective_selftest_args smart_selective_args; // Extra args for selective self-test
00080 
00081   unsigned sct_temp_int;
00082   bool sct_temp_int_pers;
00083 
00084   enum { FMT_BRIEF = 0x01, FMT_HEX_ID = 0x02, FMT_HEX_VAL = 0x04 };
00085   unsigned char output_format; // FMT_* flags
00086 
00087   firmwarebug_defs firmwarebugs; // -F options
00088   bool fix_swapped_id; // Fix swapped ID strings returned by some buggy drivers
00089 
00090   ata_vendor_attr_defs attribute_defs; // -v options
00091 
00092   bool ignore_presets; // Ignore presets from drive database
00093   bool show_presets; // Show presets and exit
00094   unsigned char powermode; // Skip check, if disk in idle or standby mode
00095 
00096   bool get_set_used; // true if any get/set command is used
00097   bool get_aam; // print Automatic Acoustic Management status
00098   int set_aam; // disable(-1), enable(1..255->0..254) Automatic Acoustic Management
00099   bool get_apm; // print Advanced Power Management status
00100   int set_apm; // disable(-1), enable(2..255->1..254) Advanced Power Management
00101   bool get_lookahead; // print read look-ahead status
00102   int set_lookahead; // disable(-1), enable(1) read look-ahead
00103   int set_standby; // set(1..255->0..254) standby timer
00104   bool set_standby_now; // set drive to standby
00105   bool get_security; // print ATA security status
00106   bool set_security_freeze; // Freeze ATA security
00107   bool get_wcache; // print write cache status
00108   int set_wcache; // disable(-1), enable(1) write cache
00109   bool sct_wcache_reorder_get; // print write cache reordering status
00110   int sct_wcache_reorder_set; // disable(-1), enable(1) write cache reordering
00111 
00112   ata_print_options()
00113     : drive_info(false),
00114       identify_word_level(-1), identify_bit_level(-1),
00115       smart_check_status(false),
00116       smart_general_values(false),
00117       smart_vendor_attrib(false),
00118       smart_error_log(false),
00119       smart_selftest_log(false),
00120       smart_selective_selftest_log(false),
00121       gp_logdir(false), smart_logdir(false),
00122       smart_ext_error_log(0),
00123       smart_ext_selftest_log(0),
00124       retry_error_log(false), retry_selftest_log(false),
00125       devstat_all_pages(false), devstat_ssd_page(false),
00126       sct_temp_sts(false), sct_temp_hist(false),
00127       sct_erc_get(false),
00128       sct_erc_set(false),
00129       sct_erc_readtime(0), sct_erc_writetime(0),
00130       sataphy(false), sataphy_reset(false),
00131       smart_disable(false), smart_enable(false),
00132       smart_auto_offl_disable(false), smart_auto_offl_enable(false),
00133       smart_auto_save_disable(false), smart_auto_save_enable(false),
00134       smart_selftest_type(-1), smart_selftest_force(false),
00135       sct_temp_int(0), sct_temp_int_pers(false),
00136       output_format(0),
00137       fix_swapped_id(false),
00138       ignore_presets(false),
00139       show_presets(false),
00140       powermode(0),
00141       get_set_used(false),
00142       get_aam(false), set_aam(0),
00143       get_apm(false), set_apm(0),
00144       get_lookahead(false), set_lookahead(0),
00145       set_standby(0), set_standby_now(false),
00146       get_security(false), set_security_freeze(false),
00147       get_wcache(false), set_wcache(0),
00148       sct_wcache_reorder_get(false), sct_wcache_reorder_set(0)
00149     { }
00150 };
00151 
00152 int ataPrintMain(ata_device * device, const ata_print_options & options);
00153 
00154 #endif