Diff for /embedaddon/smartmontools/dev_interface.cpp between versions 1.1.1.1 and 1.1.1.2

version 1.1.1.1, 2012/02/21 16:32:16 version 1.1.1.2, 2012/10/09 09:36:45
Line 3 Line 3
  *   *
  * Home page of code is: http://smartmontools.sourceforge.net   * Home page of code is: http://smartmontools.sourceforge.net
  *   *
 * Copyright (C) 2008-11 Christian Franke <smartmontools-support@lists.sourceforge.net> * Copyright (C) 2008-12 Christian Franke <smartmontools-support@lists.sourceforge.net>
  *   *
  * This program is free software; you can redistribute it and/or modify   * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by   * it under the terms of the GNU General Public License as published by
Line 25 Line 25
 #include <stdarg.h>  #include <stdarg.h>
 #include <stdexcept>  #include <stdexcept>
   
   #if defined(HAVE_GETTIMEOFDAY)
   #include <sys/time.h>
   #elif defined(HAVE_FTIME)
   #include <sys/timeb.h>
   #endif
   
 const char * dev_interface_cpp_cvsid = "$Id$"  const char * dev_interface_cpp_cvsid = "$Id$"
   DEV_INTERFACE_H_CVSID;    DEV_INTERFACE_H_CVSID;
   
Line 48  smart_device::~smart_device() throw() Line 54  smart_device::~smart_device() throw()
 {  {
 }  }
   
   bool smart_device::is_syscall_unsup() const
   {
     if (get_errno() == ENOSYS)
       return true;
   #ifdef ENOTSUP
     if (get_errno() == ENOTSUP)
       return true;
   #endif
     return false;
   }
   
 bool smart_device::set_err(int no, const char * msg, ...)  bool smart_device::set_err(int no, const char * msg, ...)
 {  {
   if (!msg)    if (!msg)
Line 61  bool smart_device::set_err(int no, const char * msg, . Line 78  bool smart_device::set_err(int no, const char * msg, .
   
 bool smart_device::set_err(int no)  bool smart_device::set_err(int no)
 {  {
  smi()->set_err_var(&m_err, no);  return smi()->set_err_var(&m_err, no);
  return false; 
 }  }
   
 smart_device * smart_device::autodetect_open()  smart_device * smart_device::autodetect_open()
Line 230  std::string smart_interface::get_valid_dev_types_str() Line 246  std::string smart_interface::get_valid_dev_types_str()
 {  {
   // default    // default
   std::string s =    std::string s =
    "ata, scsi, sat[,N][+TYPE], usbcypress[,X], usbjmicron[,x][,N], usbsunplus";    "ata, scsi, sat[,auto][,N][+TYPE], usbcypress[,X], usbjmicron[,x][,N], usbsunplus";
   // append custom    // append custom
   std::string s2 = get_valid_custom_dev_types_str();    std::string s2 = get_valid_custom_dev_types_str();
   if (!s2.empty()) {    if (!s2.empty()) {
Line 244  std::string smart_interface::get_app_examples(const ch Line 260  std::string smart_interface::get_app_examples(const ch
   return "";    return "";
 }  }
   
void smart_interface::set_err(int no, const char * msg, ...)int64_t smart_interface::get_timer_usec()
 {  {
  if (!msg) {#if defined(HAVE_GETTIMEOFDAY)
    set_err(no); return; #if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)
   {
     static bool have_clock_monotonic = true;
     if (have_clock_monotonic) {
       struct timespec ts;
       if (!clock_gettime(CLOCK_MONOTONIC, &ts))
         return ts.tv_sec * 1000000LL + ts.tv_nsec/1000;
       have_clock_monotonic = false;
     }
   }    }
    #endif
     {
       struct timeval tv;
       gettimeofday(&tv, 0);
       return tv.tv_sec * 1000000LL + tv.tv_usec;
     }
   #elif defined(HAVE_FTIME)
     {
       struct timeb tb;
       ftime(&tb);
       return tb.time * 1000000LL + tb.millitm * 1000;
     }
   #else
     return -1;
   #endif
   }
   
   bool smart_interface::disable_system_auto_standby(bool /*disable*/)
   {
     return set_err(ENOSYS);
   }
   
   bool smart_interface::set_err(int no, const char * msg, ...)
   {
     if (!msg)
       return set_err(no);
   m_err.no = no;    m_err.no = no;
   va_list ap; va_start(ap, msg);    va_list ap; va_start(ap, msg);
   m_err.msg = vstrprintf(msg, ap);    m_err.msg = vstrprintf(msg, ap);
   va_end(ap);    va_end(ap);
     return false;
 }  }
   
void smart_interface::set_err(int no)bool smart_interface::set_err(int no)
 {  {
  set_err_var(&m_err, no);  return set_err_var(&m_err, no);
 }  }
   
void smart_interface::set_err_var(smart_device::error_info * err, int no)bool smart_interface::set_err_var(smart_device::error_info * err, int no)
 {  {
   err->no = no;    err->no = no;
   err->msg = get_msg_for_errno(no);    err->msg = get_msg_for_errno(no);
   if (err->msg.empty() && no != 0)    if (err->msg.empty() && no != 0)
     err->msg = strprintf("Unknown error %d", no);      err->msg = strprintf("Unknown error %d", no);
     return false;
 }  }
   
 const char * smart_interface::get_msg_for_errno(int no)  const char * smart_interface::get_msg_for_errno(int no)

Removed from v.1.1.1.1  
changed lines
  Added in v.1.1.1.2


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>