]> git.proxmox.com Git - mirror_smartmontools-debian.git/blobdiff - dev_interface.h
Refreshed patches and removed patches applied upstream
[mirror_smartmontools-debian.git] / dev_interface.h
index dae7fc5551e0be966c20301ec7c03b7cf2e30868..fe3bb2a38d4f7a81208337e635cd0b5bd373c68b 100644 (file)
@@ -18,7 +18,7 @@
 #ifndef DEV_INTERFACE_H
 #define DEV_INTERFACE_H
 
-#define DEV_INTERFACE_H_CVSID "$Id: dev_interface.h 3520 2012-03-06 20:50:10Z chrfranke $\n"
+#define DEV_INTERFACE_H_CVSID "$Id: dev_interface.h 3663 2012-10-24 20:35:55Z chrfranke $\n"
 
 #include "utility.h"
 
@@ -147,6 +147,10 @@ public:
   const char * get_errmsg() const
     { return m_err.msg.c_str(); }
 
+  /// Return true if last error indicates an unsupported system call.
+  /// Default implementation returns true on ENOSYS and ENOTSUP.
+  virtual bool is_syscall_unsup() const;
+
   /// Set last error number and message.
   /// Printf()-like formatting is supported.
   /// Returns false always to allow use as a return expression.
@@ -183,7 +187,7 @@ public:
   /// Open device with autodetection support.
   /// May return another device for further access.
   /// In this case, the original pointer is no longer valid.
-  /// Default Implementation calls 'open()' and returns 'this'.
+  /// Default implementation calls 'open()' and returns 'this'.
   virtual smart_device * autodetect_open();
 
   ///////////////////////////////////////////////
@@ -502,12 +506,35 @@ public:
   virtual bool ata_identify_is_cached() const;
 
 protected:
+  /// Flags for ata_cmd_is_supported().
+  enum {
+    supports_data_out = 0x01, // PIO DATA OUT
+    supports_smart_status = 0x02, // read output registers for SMART STATUS only
+    supports_output_regs = 0x04, // read output registers for all commands
+    supports_multi_sector = 0x08, // more than one sector (1 DRQ/sector variant)
+    supports_48bit_hi_null = 0x10, // 48-bit commands with null high bytes only
+    supports_48bit = 0x20, // all 48-bit commands
+  };
+
   /// Check command input parameters.
+  /// Return false if required features are not implemented.
   /// Calls set_err(...) accordingly.
+  bool ata_cmd_is_supported(const ata_cmd_in & in, unsigned flags,
+    const char * type = 0);
+
+  /// Check command input parameters (old version).
+  // TODO: Remove if no longer used.
   bool ata_cmd_is_ok(const ata_cmd_in & in,
     bool data_out_support = false,
     bool multi_sector_support = false,
-    bool ata_48bit_support = false);
+    bool ata_48bit_support = false)
+    {
+      return ata_cmd_is_supported(in,
+        (data_out_support ? supports_data_out : 0) |
+        supports_output_regs |
+        (multi_sector_support ? supports_multi_sector : 0) |
+        (ata_48bit_support ? supports_48bit : 0));
+    }
 
   /// Hide/unhide ATA interface.
   void hide_ata(bool hide = true)
@@ -730,6 +757,12 @@ public:
   /// TODO: Remove this hack.
   virtual std::string get_app_examples(const char * appname);
 
+  /// Get microseconds since some unspecified starting point.
+  /// Used only for command duration measurements in debug outputs.
+  /// Returns -1 if unsupported.
+  /// Default implementation uses clock_gettime(), gettimeofday() or ftime().
+  virtual int64_t get_timer_usec();
+
   /// Disable/Enable system auto standby/sleep mode.
   /// Return false if unsupported or if system is running
   /// on battery.