]> git.proxmox.com Git - mirror_smartmontools-debian.git/commitdiff
Imported Upstream version 6.2+svn3841
authorGiuseppe Iuculano <iuculano@debian.org>
Thu, 5 Sep 2013 11:31:29 +0000 (13:31 +0200)
committerGiuseppe Iuculano <iuculano@debian.org>
Thu, 5 Sep 2013 11:31:29 +0000 (13:31 +0200)
25 files changed:
ChangeLog
INSTALL
NEWS
README
WARNINGS
atacmds.cpp
atacmds.h
ataprint.cpp
ataprint.h
autogen.sh
configure.ac
dev_areca.cpp
drivedb.h
os_freebsd.cpp
os_linux.cpp
os_win32.cpp
os_win32/daemon_win32.cpp
os_win32/smartd_warning.cmd
os_win32/update-smart-drivedb.nsi
scsicmds.cpp
smartctl.8.in
smartctl.cpp
smartd.conf.5.in
update-smart-drivedb.in
utility.cpp

index 40fd918717ccb83048a2365b3cb15e2f726ab6ad..9e8131f8f0cd7fb1a4924da2dafa3f5873ac739c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,123 @@
-$Id: ChangeLog 3812 2013-04-20 18:59:19Z chrfranke $
+$Id: ChangeLog 3841 2013-07-26 17:38:57Z chrfranke $
+
+2013-07-26  Christian Franke  <franke@computer.org>
+
+       smartmontools 6.2
+
+2013-07-25  Christian Franke  <franke@computer.org>
+
+       drivedb.h:
+       - SandForce Driven SSDs: ADATA SP900
+       - Transcend CompactFlash Cards: *GCF150
+       - Hitachi/HGST Travelstar 5K750: Apple OEM
+       - Hitachi/HGST Travelstar Z7K500
+       - Hitachi/HGST Travelstar 7K750
+       - Hitachi Deskstar 5K3000: *BLE630 OEM
+       - Seagate Constellation ES.3
+       - Western Digital Caviar Blue (SATA): Rename, add WD1602ABKS
+       - Western Digital Caviar Blue (SATA 6Gb/s): Rename, add WD10EZEX
+       - USB: Toshiba Canvio 3.0 Portable Hard Drive (0x0480:0xa007)
+       - USB: Toshiba Canvio Desktop (0x0480:0xd010)
+       - USB: Seagate FreeAgent Desk (0x0bc2:0x3008)
+       - USB: Sharkoon 2-Bay RAID Box (0x6795:0x2756)
+
+2013-07-21  Christian Franke  <franke@computer.org>
+
+       utility.cpp: Add check for empty subexpressions in regular expressions.
+
+2013-07-21  Christian Franke  <franke@computer.org>
+
+       drivedb.h:
+       - Crucial/Micron RealSSD C300/M500: Rename, add M500
+       - SandForce Driven SSDs: Kingston KC300, MS200
+       - Intel 320 Series SSDs: *A variant
+       - Intel 330/335 Series SSDs: Rename, add 335 Series
+       - Toshiba 2.5" HDD MK..46GSX
+       - Toshiba 2.5" HDD MK..61GSY[N]: Rename, add *GSY variant
+       - Toshiba 2.5" HDD MK..65GSX: *GSXF variant
+       - Toshiba 3.5" HDD DT01ACA...
+       - Seagate Laptop SSHD
+       - Seagate Constellation ES.2: 2GB
+       - USB: Seagate Expansion External (0x0bc2:0x3320)
+       - USB: Seagate Backup Plus Desktop USB 3.0 (0x0bc2:0xa0a1)
+       - USB: WD Elements (0x1058:0x10a2)
+
+2013-07-20  Christian Franke  <franke@computer.org>
+
+       dev_areca.cpp: Fix possible segfault on empty port.
+
+2013-07-20  Christian Franke  <franke@computer.org>
+
+       os_win32/daemon_win32.cpp: Do not install the service as interactive.
+       This is no longer supported since Vista and produces misleading error
+       messages in event log.
+
+2013-07-20  Christian Franke  <franke@computer.org>
+
+       ataprint.cpp: Do not print 'SCT Commands not supported' if SCT is
+       not used (regression from r3825 r3826).
+       smartctl.8.in: Mark '-g/-s wcreorder' as EXPERIMENTAL.
+
+2013-07-18  Christian Franke  <franke@computer.org>
+
+       os_win32.cpp: Add Win-8.1 and 2012r2 to get_os_version_str(),
+       remove 9x/ME and NT4.
+
+2013-07-08  Alex Samorukov  <samm@os2.kiev.ua>
+
+       Add Automake 1.12.2 to the list of supported versions
+
+2013-07-07  Christian Franke  <franke@computer.org>
+
+       configure.ac: Support SVN 1.8 working copy format.
+
+2013-07-06  Alex Samorukov <samm@os2.kiev.ua>
+
+       smartctl: Added ATA Write Cache Reordering control using "-g wcreorder"
+       and "-s wcreorder[,on|off]" options (bug #221)
+       smartctl: minor formatting fixes
+
+2013-07-05  Alex Samorukov <samm@os2.kiev.ua>
+
+       HPT RAID support: maximum disk number now is 128 (#281)
+
+2013-06-28  Alex Samorukov <samm@os2.kiev.ua>
+
+       drivedb.h:
+       - Apacer SDM4 2Gb SSD
+
+2013-06-17  Alex Samorukov <samm@os2.kiev.ua>
+
+       scsicmds.cpp: fix build on RedHat 9
+       os_freebsd.cpp: skip port multipliers on FreeBSD
+       drivedb.h:
+        - OWC Mercury EXTREME Pro 6G SSD (from #277)
+        - USB: Fujitsu  SATA-to-USB3.0 bridge chip (#280)
+
+2013-06-12  Alex Samorukov <samm@os2.kiev.ua>
+
+       drivedb.h:
+       - JMicron SSD: P400e/P400m series
+
+2013-06-09  Christian Franke  <franke@computer.org>
+
+       INSTALL, NEWS, README, WARNINGS: Update SVN repository URLs.
+
+2013-06-09  Christian Franke  <franke@computer.org>
+
+       os_win32/smartd_warning.cmd: Using %DATE% in temp file names
+       breaks the script if localized date contains '/'
+       (This fix is already included in smartmontools-6.1-2.win32-setup.exe).
+
+2013-06-06  Christian Franke  <franke@computer.org>
+
+       os_win32/update-smart-drivedb.nsi: Use new SVN repository for
+       download.
+
+2013-06-04  Christian Franke  <franke@computer.org>
+
+       update-smart-drivedb.in: Use new sourceforge code browser for
+       download.
 
 2013-04-20  Christian Franke  <franke@computer.org>
 
diff --git a/INSTALL b/INSTALL
index f63b04a32c14aa42376f6594152e2753d80c9bc6..64d68addd965d734fcae7f55803bcff1ee2c5246 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -1,7 +1,7 @@
 Smartmontools installation instructions
 =======================================
 
-$Id: INSTALL 3713 2012-11-23 21:26:17Z chrfranke $
+$Id: INSTALL 3817 2013-06-09 16:59:50Z chrfranke $
 
 Please also see the smartmontools home page:
 http://smartmontools.sourceforge.net/
@@ -185,7 +185,7 @@ Table of contents:
 =======================
 
     Get the sources from the SVN repository:
-    svn co https://smartmontools.svn.sourceforge.net/svnroot/smartmontools/trunk/smartmontools smartmontools
+    svn co http://svn.code.sf.net/p/smartmontools/code/trunk/smartmontools smartmontools
 
     Then type:
     ./autogen.sh
diff --git a/NEWS b/NEWS
index 1b7edfe83de040c7118e4745704f3d0d8654e73f..7a550c88eb7e60de771765371093eea609938855 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,14 +1,25 @@
 smartmontools NEWS
 ------------------
-$Id: NEWS 3808 2013-04-18 17:30:12Z chrfranke $
+$Id: NEWS 3841 2013-07-26 17:38:57Z chrfranke $
 
 The most up-to-date version of this file is:
-http://smartmontools.svn.sourceforge.net/viewvc/smartmontools/trunk/smartmontools/NEWS?view=markup
+http://sourceforge.net/p/smartmontools/code/HEAD/tree/trunk/smartmontools/NEWS
 
-Date <Not released yet, please try current SVN>
+Date 2013-07-26
 Summary: smartmontools release 6.2
 -----------------------------------------------------------
+- smartctl: Added ATA write cache reordering control using
+  '-g wcreorder' and '-s wcreorder,[on|off]' options.
+- update-smart-drivedb: Updated for new SVN repository.
+- HDD, SSD and USB additions to drive database.
+- Areca RAID support: Fixed possible segfault on empty port.
+- HPT RAID support: Maximum disk number increased to 128.
+- Linux: RHEL 9 compile fixes.
+- FreeBSD: Device scanning now skips port multipliers.
 - Cygwin: 64-bit compile fixes.
+- Windows: Fixed bogus temp file name in smartd_warning.cmd
+  (already included in smartmontools-6.1-2.win32-setup.exe).
+- Windows: smartd service is no longer installed as interactive.
 
 Date 2013-03-16
 Summary: smartmontools release 6.1
diff --git a/README b/README
index 5a6d12e75466f3990726261389cf6023f9bff44b..4a52100549fb49e7149597a522211d97df02de64 100644 (file)
--- a/README
+++ b/README
@@ -3,7 +3,7 @@ smartmontools - S.M.A.R.T. utility toolset for Darwin/Mac
 OSX, FreeBSD, Linux, NetBSD, OpenBSD, Solaris, and Windows.
 ==========================================================
 
-$Id: README 3727 2012-12-13 17:23:06Z samm2 $
+$Id: README 3817 2013-06-09 16:59:50Z chrfranke $
 
 == HOME ==
 The home for smartmontools is located at:
@@ -69,21 +69,21 @@ smartd   is a daemon that periodically monitors S.M.A.R.T. status and
 Source tarballs
 ---------------
 
-http://sourceforge.net/project/showfiles.php?group_id=64297
+http://sourceforge.net/projects/smartmontools/files/
 
 SVN
 ---
 
-svn co https://smartmontools.svn.sourceforge.net/svnroot/smartmontools/trunk/smartmontools smartmontools
+svn co http://svn.code.sf.net/p/smartmontools/code/trunk/smartmontools smartmontools
 
 This will create a subdirectory called smartmontools containing the code.
 
 To instead get the 5.38 release:
 
-svn co https://smartmontools.svn.sourceforge.net/svnroot/smartmontools/tags/RELEASE_5_38/sm5 smartmontools
+svn co http://svn.code.sf.net/p/smartmontools/code/tags/RELEASE_5_38/sm5 smartmontools
 
 You can see what the different tags are by looking at
-http://smartmontools.svn.sourceforge.net/viewvc/smartmontools/tags/
+http://sourceforge.net/p/smartmontools/code/HEAD/tree/tags/
 
 == BUILDING/INSTALLING SMARTMONTOOLS ==
 
index 658af7e04bf16495f539c0d88b98335cc3e6404c..a96499405ba5ada9785e3f966628ecdf96120b7f 100644 (file)
--- a/WARNINGS
+++ b/WARNINGS
@@ -1,7 +1,7 @@
-$Id: WARNINGS 2844 2009-07-18 12:59:21Z chrfranke $
+$Id: WARNINGS 3817 2013-06-09 16:59:50Z chrfranke $
 
 The most recent version of this file can be found here:
-http://smartmontools.svn.sourceforge.net/viewvc/smartmontools/trunk/smartmontools/WARNINGS?view=markup
+http://sourceforge.net/p/smartmontools/code/HEAD/tree/trunk/smartmontools/WARNINGS
 
 The following are reports of serious problems (eg system lockup) which
 were due to smartmontools.  There are DARWIN, LINUX, FREEBSD, SOLARIS
index d84d1f033fc2752e2e44f48c5db93cc7e7058003..629ff2e314b70a23f9e392764a0164c8e6900be5 100644 (file)
@@ -35,7 +35,7 @@
 #include "utility.h"
 #include "dev_ata_cmd_set.h" // for parsed_ata_device
 
-const char * atacmds_cpp_cvsid = "$Id: atacmds.cpp 3777 2013-02-19 18:32:15Z samm2 $"
+const char * atacmds_cpp_cvsid = "$Id: atacmds.cpp 3825 2013-07-06 21:38:25Z samm2 $"
                                  ATACMDS_H_CVSID;
 
 // Print ATA debug messages?
@@ -2443,6 +2443,73 @@ int ataReadSCTTempHist(ata_device * device, ata_sct_temperature_history_table *
   return 0;
 }
 
+// Get/Set Write Cache Reordering
+int ataGetSetSCTWriteCacheReordering(ata_device * device, bool enable, bool persistent, bool set)
+{
+  // Check initial status
+  ata_sct_status_response sts;
+  if (ataReadSCTStatus(device, &sts))
+    return -1;
+
+  // Do nothing if other SCT command is executing
+  if (sts.ext_status_code == 0xffff) {
+    pout("Another SCT command is executing, abort Feature Control\n"
+         "(SCT ext_status_code 0x%04x, action_code=%u, function_code=%u)\n",
+      sts.ext_status_code, sts.action_code, sts.function_code);
+    return -1;
+  }
+
+  ata_sct_feature_control_command cmd; memset(&cmd, 0, sizeof(cmd));
+  // CAUTION: DO NOT CHANGE THIS VALUE (SOME ACTION CODES MAY ERASE DISK)
+  cmd.action_code   = 4; // Feature Control command
+  cmd.function_code  = (set ? 1 : 2); // 1=Set, 2=Get
+  cmd.feature_code  = 2; //  Enable/Disable Write Cache Reordering 
+  cmd.state         = (enable ? 1 : 2); // 1 enable, 2 disable
+  cmd.option_flags  = (persistent ? 0x01 : 0x00);
+
+  // swap endian order if needed
+  if (isbigendian()) {
+    swapx(&cmd.action_code);
+    swapx(&cmd.function_code);
+    swapx(&cmd.feature_code);
+    swapx(&cmd.state);
+    swapx(&cmd.option_flags);
+  }
+
+  // write command via SMART log page 0xe0
+  // TODO: Debug output
+  ata_cmd_in in;
+  in.in_regs.command = ATA_SMART_CMD;
+  in.in_regs.lba_high = SMART_CYL_HI; in.in_regs.lba_mid = SMART_CYL_LOW;
+  in.in_regs.features = ATA_SMART_WRITE_LOG_SECTOR;
+  in.in_regs.lba_low = 0xe0;
+  in.set_data_out(&cmd, 1);
+
+  if (!set)
+    // Time limit returned in ATA registers
+    in.out_needed.sector_count = in.out_needed.lba_low = true;
+
+  ata_cmd_out out;
+  if (!device->ata_pass_through(in, out)) {
+    pout("Write SCT (%cet) XXX Error Recovery Control Command failed: %s\n",
+      (!set ? 'G' : 'S'), device->get_errmsg());
+    return -1;
+  }
+  int state = out.out_regs.sector_count | (out.out_regs.lba_low << 8);
+
+  // re-read and check SCT status
+  if (ataReadSCTStatus(device, &sts))
+    return -1;
+
+  if (!(sts.ext_status_code == 0 && sts.action_code == 4 && sts.function_code == (set ? 1 : 2))) {
+    pout("Unexpected SCT status 0x%04x (action_code=%u, function_code=%u)\n",
+      sts.ext_status_code, sts.action_code, sts.function_code);
+    return -1;
+  }
+  return state;
+}
+
+
 // Set SCT Temperature Logging Interval
 int ataSetSCTTempInterval(ata_device * device, unsigned interval, bool persistent)
 {
index a0d965dee40ee9d91ed9fc46c5c9b054dfbe8d12..21d809584a9522f788a21fc786157066b9939a3f 100644 (file)
--- a/atacmds.h
+++ b/atacmds.h
@@ -25,7 +25,7 @@
 #ifndef ATACMDS_H_
 #define ATACMDS_H_
 
-#define ATACMDS_H_CVSID "$Id: atacmds.h 3632 2012-10-09 10:10:53Z chrfranke $"
+#define ATACMDS_H_CVSID "$Id: atacmds.h 3825 2013-07-06 21:38:25Z samm2 $"
 
 #include "dev_interface.h" // ata_device
 
@@ -835,6 +835,12 @@ int ataDoesSmartWork(ata_device * device);
 // returns 1 if SMART supported, 0 if not supported or can't tell
 int ataSmartSupport(const ata_identify_device * drive);
 
+// Return values:
+//  1: Write Cache Reordering enabled
+//  2: Write Cache Reordering disabled
+// -1: error
+int ataGetSetSCTWriteCacheReordering(ata_device * device, bool enable, bool persistent, bool set);
+
 // Return values:
 //  1: SMART enabled
 //  0: SMART disabled
index 51fe7d49c77ae99adb9e691cc29b97f84bd329cf..9239dcaf36ce8e016f2016a62063fd57269167a2 100644 (file)
@@ -40,7 +40,7 @@
 #include "utility.h"
 #include "knowndrives.h"
 
-const char * ataprint_cpp_cvsid = "$Id: ataprint.cpp 3786 2013-03-07 22:09:17Z chrfranke $"
+const char * ataprint_cpp_cvsid = "$Id: ataprint.cpp 3831 2013-07-20 14:25:56Z chrfranke $"
                                   ATAPRINT_H_CVSID;
 
 
@@ -2457,6 +2457,8 @@ int ataPrintMain (ata_device * device, const ata_print_options & options)
        || options.sct_temp_int
        || options.sct_erc_get
        || options.sct_erc_set
+       || options.sct_wcache_reorder_get
+       || options.sct_wcache_reorder_set
   );
 
   // Exit if no further options specified
@@ -2616,6 +2618,37 @@ int ataPrintMain (ata_device * device, const ata_print_options & options)
   if (options.get_security)
     print_ata_security_status("ATA Security is:  ", drive.words088_255[128-88]);
 
+  // Check if SCT commands available
+  bool sct_ok = false;
+  if (need_sct_support) {
+    if (!isSCTCapable(&drive)) {
+      failuretest(OPTIONAL_CMD, returnval|=FAILSMART);
+    }
+    else
+      sct_ok = true;
+  }
+
+  // Print write cache reordering status
+  if (sct_ok && options.sct_wcache_reorder_get) {
+    int wcache_reorder=ataGetSetSCTWriteCacheReordering(device,
+      false /* enable */, false /* persistent */, false /*set*/);
+      pout("Wt Cache Reorder: ");
+      switch(wcache_reorder) {
+        case 0: /* not defined in standard but returned on some drives if not set */
+        pout("Unknown"); break;
+        case 1:
+        pout("Enabled"); break;
+        case 2:
+        pout("Disabled"); break;
+        default: /* error? */
+        pout("N/A"); break;
+      }
+      pout("\n");
+  }
+  if (!sct_ok && options.sct_wcache_reorder_get) {
+    pout("Wt Cache Reorder: Unavailable\n");
+  }
+
   // Print remaining drive info
   if (options.drive_info) {
     // Print the (now possibly changed) power mode if available
@@ -2631,7 +2664,10 @@ int ataPrintMain (ata_device * device, const ata_print_options & options)
   // START OF THE ENABLE/DISABLE SECTION OF THE CODE
   if (   options.smart_disable           || options.smart_enable
       || options.smart_auto_save_disable || options.smart_auto_save_enable
-      || options.smart_auto_offl_disable || options.smart_auto_offl_enable)
+      || options.smart_auto_offl_disable || options.smart_auto_offl_enable
+      || options.set_aam || options.set_apm || options.set_lookahead
+      || options.set_wcache || options.set_security_freeze || options.set_standby
+      || options.sct_wcache_reorder_set)
     pout("=== START OF ENABLE/DISABLE COMMANDS SECTION ===\n");
   
   // Enable/Disable AAM
@@ -2696,6 +2732,21 @@ int ataPrintMain (ata_device * device, const ata_print_options & options)
       pout("Write cache %sabled\n", (enable ? "en" : "dis"));
   }
 
+  // Enable/Disable write cache reordering
+  if (sct_ok && options.sct_wcache_reorder_set) {
+    bool enable = (options.sct_wcache_reorder_set > 0);
+
+    int wcache_reorder=ataGetSetSCTWriteCacheReordering(device,
+      enable, false /* persistent */, true /*set*/);
+
+    if (wcache_reorder < 0) {
+        pout("Write cache reordering %sable failed: %s\n", (enable ? "en" : "dis"), device->get_errmsg());
+        returnval |= FAILSMART;
+    }
+    else
+      pout("Write cache reordering %sabled\n", (enable ? "en" : "dis"));
+  }
+
   // Freeze ATA security
   if (options.set_security_freeze) {
     if (!ata_nodata_command(device, ATA_SECURITY_FREEZE_LOCK)) {
@@ -2826,7 +2877,10 @@ int ataPrintMain (ata_device * device, const ata_print_options & options)
   // all this for a newline!
   if (   options.smart_disable           || options.smart_enable
       || options.smart_auto_save_disable || options.smart_auto_save_enable
-      || options.smart_auto_offl_disable || options.smart_auto_offl_enable)
+      || options.smart_auto_offl_disable || options.smart_auto_offl_enable
+      || options.set_aam || options.set_apm || options.set_lookahead
+      || options.set_wcache || options.set_security_freeze || options.set_standby
+      || options.sct_wcache_reorder_set)
     pout("\n");
 
   // START OF READ-ONLY OPTIONS APART FROM -V and -i
@@ -3163,16 +3217,9 @@ int ataPrintMain (ata_device * device, const ata_print_options & options)
     }
   }
 
-  // SCT commands
-  bool sct_ok = false;
-  if (need_sct_support) {
-    if (!isSCTCapable(&drive)) {
-      pout("SCT Commands not supported\n\n");
-      failuretest(OPTIONAL_CMD, returnval|=FAILSMART);
-    }
-    else
-      sct_ok = true;
-  }
+  if(!sct_ok && (options.sct_temp_sts || options.sct_temp_hist || options.sct_temp_int
+                 || options.sct_erc_get || options.sct_erc_set                        ))
+    pout("SCT Commands not supported\n\n");
 
   // Print SCT status and temperature history table
   if (sct_ok && (options.sct_temp_sts || options.sct_temp_hist || options.sct_temp_int)) {
index d8ca067581a17782527f89119cf71cbe1d58aa1a..e83020fa4ea6398c803b745908bb4fbdae6b5992 100644 (file)
@@ -25,7 +25,7 @@
 #ifndef ATAPRINT_H_
 #define ATAPRINT_H_
 
-#define ATAPRINT_H_CVSID "$Id: ataprint.h 3609 2012-09-20 21:24:43Z chrfranke $\n"
+#define ATAPRINT_H_CVSID "$Id: ataprint.h 3825 2013-07-06 21:38:25Z samm2 $\n"
 
 #include <vector>
 
@@ -106,6 +106,8 @@ struct ata_print_options
   bool set_security_freeze; // Freeze ATA security
   bool get_wcache; // print write cache status
   int set_wcache; // disable(-1), enable(1) write cache
+  bool sct_wcache_reorder_get; // print write cache reordering status
+  int sct_wcache_reorder_set; // disable(-1), enable(1) write cache reordering
 
   ata_print_options()
     : drive_info(false),
@@ -142,7 +144,8 @@ struct ata_print_options
       get_lookahead(false), set_lookahead(0),
       set_standby(0), set_standby_now(false),
       get_security(false), set_security_freeze(false),
-      get_wcache(false), set_wcache(0)
+      get_wcache(false), set_wcache(0),
+      sct_wcache_reorder_get(false), sct_wcache_reorder_set(0)
     { }
 };
 
index 90d1e9561565cb1f845fa9e9fe1de5efdb501a8c..0a472d2c10f5c0d2e0bb748545b1e9ff3c411149 100755 (executable)
@@ -1,5 +1,5 @@
 #!/bin/sh
-# $Id: autogen.sh 3748 2013-01-18 20:12:44Z chrfranke $
+# $Id: autogen.sh 3829 2013-07-08 15:13:16Z samm2 $
 #
 # Generate ./configure from config.in and Makefile.in from Makefile.am.
 # This also adds files like missing,depcomp,install-sh to the source
@@ -84,7 +84,7 @@ case "$ver" in
     rm -f casetest.tmp
     ;;
 
-  1.9.[1-6]|1.10|1.10.[12]|1.11|1.11.[1-6]|1.12.[3-5])
+  1.9.[1-6]|1.10|1.10.[12]|1.11|1.11.[1-6]|1.12.[2-5])
     # OK
     ;;
 
index 912c0d2c93b08239a2cf4614fa71aa582821dbf7..26472eba0560ccac8fca42422782c23d7012e1a9 100644 (file)
@@ -1,5 +1,5 @@
 #
-# $Id: configure.ac 3811 2013-04-20 17:10:41Z chrfranke $
+# $Id: configure.ac 3841 2013-07-26 17:38:57Z chrfranke $
 #
 dnl Process this file with autoconf to produce a configure script.
 AC_PREREQ(2.50)
@@ -7,9 +7,9 @@ AC_INIT(smartmontools, 6.2, smartmontools-support@lists.sourceforge.net)
 AC_CONFIG_SRCDIR(smartctl.cpp)
 
 smartmontools_configure_date=`date -u +'%Y-%m-%d %T %Z'`
-smartmontools_cvs_tag=`echo '$Id: configure.ac 3811 2013-04-20 17:10:41Z chrfranke $'`
-smartmontools_release_date=2013-03-16
-smartmontools_release_time="14:35:27 UTC"
+smartmontools_cvs_tag=`echo '$Id: configure.ac 3841 2013-07-26 17:38:57Z chrfranke $'`
+smartmontools_release_date=2013-07-26
+smartmontools_release_time="17:38:20 UTC"
 
 AC_DEFINE_UNQUOTED(SMARTMONTOOLS_CONFIGURE_ARGS, "$ac_configure_args",            [smartmontools Configure Arguments])
 AC_DEFINE_UNQUOTED(SMARTMONTOOLS_CONFIGURE_DATE, "$smartmontools_configure_date", [smartmontools Configure Date])
@@ -67,13 +67,17 @@ esac
 AC_MSG_CHECKING([whether this is a build from SVN])
 is_svn_build=no
 svn_deps=
-if test -f "$srcdir/.svn/entries"; then
+if test -f "$srcdir/.svn/wc.db"; then
+  # SVN 1.7, 1.8 working copy
+  svn_deps='${srcdir}/.svn/wc.db'
+elif test -f "${srcdir}/.svn/entries"; then
+  # SVN <= 1.6 working copy (SVN 1.7 has empty entries file)
+  svn_deps='${srcdir}/.svn/entries'
+fi
+if test -n "$svn_deps"; then
   is_svn_build=unknown
   if (cd "$srcdir" && svn --version && svnversion && svn info) >/dev/null 2>&1; then
     is_svn_build=yes
-    svn_deps='${srcdir}/.svn/entries'
-    # SVN 1.7 working copy?
-    test -f "$srcdir/.svn/wc.db" && svn_deps='${srcdir}/.svn/wc.db'
   fi
 fi
 AC_SUBST([svn_deps])
index 9ee8be7b8a54bc0ef61eb484350b0899bfa58351..ec4afee4dae6f04bc3a8041357896c912629529b 100644 (file)
@@ -21,7 +21,7 @@
 #include "dev_interface.h"
 #include "dev_areca.h"
 
-const char * dev_areca_cpp_cvsid = "$Id: dev_areca.cpp 3803 2013-03-24 18:52:54Z chrfranke $"
+const char * dev_areca_cpp_cvsid = "$Id: dev_areca.cpp 3835 2013-07-20 18:37:19Z chrfranke $"
   DEV_ARECA_H_CVSID;
 
 #include "atacmds.h"
@@ -613,10 +613,11 @@ bool generic_areca_device::arcmsr_scsi_pass_through(struct scsi_cmnd_io * iop)
 
   // ----- BEGIN TO SEND TO ARECA DRIVER ------
   expected = arcmsr_ui_handler(areca_packet, areca_packet_len, return_buff);
-  if ( expected < 0 )
-  {
-    return set_err(EIO);
-  }
+
+  if (expected < 0)
+    return set_err(EIO, "arcmsr_scsi_pass_through: I/O error");
+  if (expected < 15) // 7 bytes if port is empty
+    return set_err(EIO, "arcmsr_scsi_pass_through: missing data (%d bytes, expected %d)", expected, 15);
 
   int scsi_status = return_buff[5];
   int in_data_len = return_buff[11] | return_buff[12] << 8 | return_buff[13] << 16 | return_buff[14] << 24;
index 5d60396c27b04a91dd243d1b0da858d8a2d5a8ec..1be81d13c1d93adc677e6293fec08e2656cadc14 100644 (file)
--- a/drivedb.h
+++ b/drivedb.h
@@ -75,7 +75,7 @@
 /*
 const drive_settings builtin_knowndrives[] = {
  */
-  { "$Id: drivedb.h 3812 2013-04-20 18:59:19Z chrfranke $",
+  { "$Id: drivedb.h 3840 2013-07-25 21:29:08Z chrfranke $",
     "-", "-",
     "This is a dummy entry to hold the SVN-Id of drivedb.h",
     ""
@@ -157,13 +157,24 @@ const drive_settings builtin_knowndrives[] = {
     "APPLE SSD SM128",
     "", "", ""
   },
+  { "Apacer SDM4",
+    "2GB SATA Flash Drive", // tested with APSDM002G15AN-CT/SFI2101D
+    "SFI2101D", "",
+    "-v 160,raw48,Initial_Bad_Block_Count "
+    "-v 161,raw48,Bad_Block_Count "
+    "-v 162,raw48,Spare_Block_Count "
+    "-v 163,raw48,Max_Erase_Count "
+    "-v 164,raw48,Min_Erase_Count " // could be wrong
+    "-v 165,raw48,Average_Erase_Count " // could be wrong
+  },
   { "Asus-Phison SSD",
     "ASUS-PHISON SSD",
     "", "", ""
   },
-  { "Crucial/Micron RealSSD C300", // Marvell 88SS9174 BJP2
-    "C300-CTFDDA[AC](064|128|256)MAG", // tested with C300-CTFDDAC128MAG/0002,
+  { "Crucial/Micron RealSSD C300/M500", // Marvell 88SS91xx
+    "C300-CTFDDA[AC](064|128|256)MAG|" // Marvell 88SS9174 BJP2, tested with C300-CTFDDAC128MAG/0002,
       // C300-CTFDDAC064MAG/0006
+    "Crucial_CT(120|240|480)M500SSD3", // Marvell 88SS9187 BLD2, tested with Crucial_CT120M500SSD3/MU02
     "", "",
   //"-v 1,raw48,Raw_Read_Error_Rate "
   //"-v 5,raw16(raw16),Reallocated_Sector_Ct "
@@ -189,9 +200,11 @@ const drive_settings builtin_knowndrives[] = {
     "-v 202,raw48,Perc_Rated_Life_Used "
     "-v 206,raw48,Write_Error_Rate"
   },
-  { "Crucial/Micron RealSSD m4/C400", // Marvell 9176, fixed firmware
+  { "Crucial/Micron RealSSD m4/C400/P400", // Marvell 9176, fixed firmware
     "C400-MTFDDA[ACK](064|128|256|512)MAM|"
-    "M4-CT(064|128|256|512)M4SSD[23]", // tested with M4-CT512M4SSD2/0309
+    "M4-CT(064|128|256|512)M4SSD[23]|" // tested with M4-CT512M4SSD2/0309
+    "MTFDDAK(064|128|256|512|050|100|200|400)MA[RN]-1[JKS]1AA.*", // tested with
+                                             // MTFDDAK256MAR-1K1AA/MA52
     "030[9-Z]|03[1-Z].|0[4-Z]..|[1-Z]....*", // >= "0309"
     "",
   //"-v 1,raw48,Raw_Read_Error_Rate "
@@ -243,6 +256,7 @@ const drive_settings builtin_knowndrives[] = {
     "SandForce 1st Ed\\.|" // Demo Drive, tested with firmware 320A13F0
     "ADATA SSD S(396|510|599) .?..GB|" // tested with ADATA SSD S510 60GB/320ABBF0,
       // ADATA SSD S599 256GB/3.1.0, 64GB/3.4.6
+    "ADATA SP900|" // Premier Pro, SF-2281, tested with ADATA SP900/5.0.6
     "Corsair CSSD-F(40|60|80|115|120|160|240)GBP?2.*|" // Corsair Force, tested with
       // Corsair CSSD-F40GB2/1.1, Corsair CSSD-F115GB2-A/2.1a
     "Corsair Force (3 SSD|GS|GT)|" // SF-2281, tested with
@@ -253,8 +267,10 @@ const drive_settings builtin_knowndrives[] = {
       // FTM24CT25H/STTMP2P1
     "KINGSTON SH10[03]S3(90|120|240|480)G|" // HyperX (3K), SF-2281, tested with
       // SH100S3240G/320ABBF0, SH103S3120G/505ABBF0
+    "KINGSTON SKC300S37A(60|120|240|480)G|" // SF-2281, tested with SKC300S37A120G/KC4ABBF0
     "KINGSTON SVP200S3(7A)?(60|90|120|240|480)G|" // V+ 200, SF-2281, tested with
       // SVP200S37A480G/502ABBF0, SVP200S390G/332ABBF0
+    "KINGSTON SMS200S3(30|60|120)G|" // mSATA, SF-2241, tested with SMS200S3120G/KC3ABBF0
     "KINGSTON SMS450S3(32|64|128)G|" // mSATA, SF-2281, tested with SMS450S3128G/503ABBF0
     "KINGSTON (SV300|SKC100|SE100)S3.*G|" // other SF-2281
     "MKNSSDCR(45|60|90|120|180|240|480)GB(-DX)?|" // Mushkin Chronos (deluxe), SF-2281,
@@ -282,6 +298,8 @@ const drive_settings builtin_knowndrives[] = {
       // OWC Mercury Electra 6G SSD/502ABBF0
     "OWC Mercury Extreme Pro (RE )?SSD|" // tested with
       // OWC Mercury Extreme Pro SSD/360A13F0
+    "OWC Mercury EXTREME Pro 6G SSD|" // tested with
+      // OWC Mercury EXTREME Pro 6G SSD/507ABBF0
     "Patriot Pyro|" // tested with Patriot Pyro/332ABBF0
     "SanDisk SDSSDX(60|120|240|480)GG25|" // SanDisk Extreme, SF-2281, tested with
       // SDSSDX240GG25/R201
@@ -510,8 +528,8 @@ const drive_settings builtin_knowndrives[] = {
     "-v 242,raw48,Host_Reads_32MiB"
   },
   { "Intel 320 Series SSDs", // tested with INTEL SSDSA2CT040G3/4PC10362,
-      // INTEL SSDSA2CW160G3/4PC10362, INTEL SSDSA2BT040G3/4PC10362
-    "INTEL SSDSA[12][BC][WT](040|080|120|160|300|600)G3",
+      // INTEL SSDSA2CW160G3/4PC10362, INTEL SSDSA2BT040G3/4PC10362, INTEL SSDSA2BW120G3A/4PC10362
+    "INTEL SSDSA[12][BC][WT](040|080|120|160|300|600)G3A?",
     "", "",
     "-F nologdir "
   //"-v 3,raw16(avg16),Spin_Up_Time "
@@ -597,8 +615,9 @@ const drive_settings builtin_knowndrives[] = {
     "-v 242,raw48,Host_Reads_32MiB "
     "-v 249,raw48,NAND_Writes_1GiB"
   },
-  { "Intel 330 Series SSDs", // tested with INTEL SSDSC2CT180A3/300i, SSDSC2CT240A3/300i
-    "INTEL SSDSC2CT(060|120|180|240)A3",
+  { "Intel 330/335 Series SSDs", // tested with INTEL SSDSC2CT180A3/300i, SSDSC2CT240A3/300i,
+      // INTEL SSDSC2CT240A4/335t
+    "INTEL SSDSC2CT(060|120|180|240)A[34]", // A4 = 335 Series
     "", "",
   //"-v 5,raw16(raw16),Reallocated_Sector_Ct "
     "-v 9,msec24hour32,Power_On_Hours_and_Msec "
@@ -840,8 +859,8 @@ const drive_settings builtin_knowndrives[] = {
     "-v 212,raw48,Unknown_Attribute"  // ] from September 2012
   },
   { "Transcend CompactFlash Cards", // tested with TRANSCEND/20080820,
-      // TS4GCF133/20100709, TS16GCF133/20100709
-    "TRANSCEND|TS(4|8|16)GCF133",
+      // TS4GCF133/20100709, TS16GCF133/20100709, TS16GCF150/20110407
+    "TRANSCEND|TS(4|8|16)GCF(133|150)",
     "", "",
     "-v 7,raw48,Unknown_Attribute "
     "-v 8,raw48,Unknown_Attribute"
@@ -1650,8 +1669,9 @@ const drive_settings builtin_knowndrives[] = {
     "HGST HT[ES]5450(25|32|50)A7E38[01]",
     "", "", ""
   },
-  { "Hitachi/HGST Travelstar 5K750", // tested with Hitachi HTS547575A9E384/JE4OA60A
-    "Hitachi HT[ES]5475(50|64|75)A9E38[14]",
+  { "Hitachi/HGST Travelstar 5K750", // tested with Hitachi HTS547575A9E384/JE4OA60A,
+       // APPLE HDD HTS547550A9E384/JE3AD70F
+    "(Hitachi|APPLE HDD) HT[ES]5475(50|64|75)A9E38[14]",
     "", "", ""
   },
   { "Hitachi Travelstar 7K60",
@@ -1687,6 +1707,16 @@ const drive_settings builtin_knowndrives[] = {
     "(Hitachi )?HT[ES]7250(12|16|25|32|50)A9A36[2-5]",
     "", "", ""
   },
+  { "Hitachi/HGST Travelstar Z7K500", // tested with HITACHI HTS725050A7E630/GH2ZB390,
+      // HGST HTS725050A7E630/GH2OA420
+    "(HITACHI|HGST) HT[ES]7250(25|32|50)A7E63[015]",
+    "", "", ""
+  },
+  { "Hitachi/HGST Travelstar 7K750", // tested with Hitachi HTS727550A9E364/JF3OA0E0,
+      // Hitachi HTS727575A9E364/JF4OA0D0
+    "(Hitachi|HGST) HT[ES]7275(50|64|75)A9E36[14]",
+    "", "", ""
+  },
   { "HGST Travelstar 7K1000", // tested with HGST HTS721010A9E630/JB0OA3B0
     "HGST HTS721010A9E630",
     "", "", ""
@@ -1711,8 +1741,9 @@ const drive_settings builtin_knowndrives[] = {
     "(IBM-)?IC35L(030|060|090|120|180)AVV207-[01]",
     "", "", ""
   },
-  { "Hitachi Deskstar 5K3000", // tested with HDS5C3030ALA630/MEAOA5C0
-    "(Hitachi )?HDS5C30(15|20|30)ALA63[02].*",
+  { "Hitachi Deskstar 5K3000", // tested with HDS5C3030ALA630/MEAOA5C0,
+       // Hitachi HDS5C3020BLE630/MZ4OAAB0 (OEM, Toshiba Canvio Desktop)
+    "(Hitachi )?HDS5C30(15|20|30)(ALA|BLE)63[02].*",
     "", "", ""
   },
   { "Hitachi Deskstar 5K4000", // tested with HDS5C4040ALE630/MPAOA250
@@ -1821,6 +1852,10 @@ const drive_settings builtin_knowndrives[] = {
     "TOSHIBA MK(12|16)37GSX",
     "", "", ""
   },
+  { "Toshiba 2.5\" HDD MK..46GSX", // tested with TOSHIBA MK1246GSX/LB213M
+    "TOSHIBA MK(80|12|16|25)46GSX",
+    "", "", ""
+  },
   { "Toshiba 2.5\" HDD MK..50GACY", // tested with TOSHIBA MK8050GACY/TF105A
     "TOSHIBA MK8050GACY",
     "", "", ""
@@ -1847,12 +1882,13 @@ const drive_settings builtin_knowndrives[] = {
     "TOSHIBA MK(75|10)59GSM",
     "", "", ""
   },
-  { "Toshiba 2.5\" HDD MK..61GSYN", // tested with TOSHIBA MK5061GSYN/MH000A
-    "TOSHIBA MK(16|25|32|50|64)61GSYN",
+  { "Toshiba 2.5\" HDD MK..61GSY[N]", // tested with TOSHIBA MK5061GSY/MC102E, MK5061GSYN/MH000A
+    "TOSHIBA MK(16|25|32|50|64)61GSYN?",
     "", "", ""
   },
-  { "Toshiba 2.5\" HDD MK..65GSX", // tested with TOSHIBA MK5065GSX/GJ003A, MK3265GSXN/GH012H
-    "TOSHIBA MK(16|25|32|50|64)65GSXN?",
+  { "Toshiba 2.5\" HDD MK..65GSX", // tested with TOSHIBA MK5065GSX/GJ003A, MK3265GSXN/GH012H,
+      // MK5065GSXF/GP006B
+    "TOSHIBA MK(16|25|32|50|64)65GSX[FN]?",
     "", "", ""
   },
   { "Toshiba 2.5\" HDD MK..76GSX", // tested with TOSHIBA MK3276GSX/GS002D
@@ -1869,6 +1905,11 @@ const drive_settings builtin_knowndrives[] = {
     "TOSHIBA MK(10|20)02TSKB",
     "", "", ""
   },
+  { "Toshiba 3.5\" HDD DT01ACA...", // tested with TOSHIBA DT01ACA100/MS2OA750,
+      // TOSHIBA DT01ACA200/MX4OABB0, TOSHIBA DT01ACA300/MX6OABB0
+    "TOSHIBA DT01ACA(025|032|050|075|100|150|200|300)",
+    "", "", ""
+  },
   { "Toshiba 1.8\" HDD",
     "TOSHIBA MK[23468]00[4-9]GA[HL]",
     "", "", ""
@@ -1996,6 +2037,10 @@ const drive_settings builtin_knowndrives[] = {
     "ST(160|250|320)LT0(07|09|11|14)-.*",
     "", "", ""
   },
+  { "Seagate Laptop SSHD", // tested with ST500LM000-1EJ162/SM11
+    "ST(500|1000)LM0(00|14)-.*",
+    "", "", ""
+  },
   { "Seagate Medalist 1010, 1720, 1721, 2120, 3230 and 4340",  // ATA2, with -t permissive
     "ST3(1010|1720|1721|2120|3230|4340)A",
     "", "", ""
@@ -2242,8 +2287,12 @@ const drive_settings builtin_knowndrives[] = {
     "ST(5|10|20)00NM0011",
     "", "", ""
   },
-  { "Seagate Constellation ES.2 (SATA 6Gb/s)", // tested with ST33000650NS
-    "ST3300065[012]NS",
+  { "Seagate Constellation ES.2 (SATA 6Gb/s)", // tested with ST32000645NS/0004, ST33000650NS
+    "ST3(2000645|300065[012])NS",
+    "", "", ""
+  },
+  { "Seagate Constellation ES.3", // tested with ST1000NM0033-9ZM173/0001, ST4000NM0033-9ZM170/SN03
+    "ST[1234]000NM00[35]3-.*",
     "", "", ""
   },
   { "Seagate Pipeline HD 5900.1",
@@ -2391,12 +2440,13 @@ const drive_settings builtin_knowndrives[] = {
     "WDC WD((8|12|16|25|32)00AABS|(8|12|16|25|32|40|50)00AAJS)-.*",
     "", "", ""
   },
-  { "Western Digital Caviar Blue Serial ATA",  // WD Caviar SE16 Serial ATA
-    "WDC WD((16|20|25|32|40|50|64|75)00AAKS|10EALS)-.*",
+  { "Western Digital Caviar Blue (SATA)",  // WD Caviar SE16 Serial ATA
+      // tested with WD1602ABKS-18N8A0/DELL/02.03B04
+    "WDC WD((16|20|25|32|40|50|64|75)00AAKS|1602ABKS|10EALS)-.*",
     "", "", ""
   },
-  { "Western Digital Caviar Blue Serial ATA",  // SATA 3.0 variants
-    "WDC WD((25|32|50)00AAKX|7500AALX|10EALX)-.*",
+  { "Western Digital Caviar Blue (SATA 6Gb/s)", // tested with WDC WD10EZEX-00RKKA0/80.00A80
+    "WDC WD((25|32|50)00AAKX|7500AALX|10EALX|10EZEX)-.*",
     "", "", ""
   },
   { "Western Digital RE Serial ATA",
@@ -2649,6 +2699,18 @@ const drive_settings builtin_knowndrives[] = {
     "",
     "-d sat"
   },
+  { "USB: Toshiba Canvio 3.0 Portable Hard Drive; ", // 1TB
+    "0x0480:0xa007",
+    "", // 0x0001
+    "",
+    "-d sat"
+  },
+  { "USB: Toshiba Canvio Desktop; ", // 2TB
+    "0x0480:0xd010",
+    "",
+    "",
+    "-d sat"
+  },
   // Cypress
   { "USB: ; Cypress CY7C68300A (AT2)",
     "0x04b4:0x6830",
@@ -2669,6 +2731,13 @@ const drive_settings builtin_knowndrives[] = {
     "",
     "-d sat"
   },
+  // Fujitsu chip on DeLock 42475 
+  { "USB: Fujitsu  SATA-to-USB3.0 bridge chip", // USB 3.0
+    "0x04c5:0x201d",
+    "", // 0x0001
+    "",
+    "-d sat"
+  },
   // Myson Century
   { "USB: ; Myson Century CS8818",
     "0x04cf:0x8818",
@@ -3014,8 +3083,14 @@ const drive_settings builtin_knowndrives[] = {
     "",
     "-d sat"
   },
-  { "USB: Seagate Expansion External; ", // 2TB
-    "0x0bc2:0x33(00|32)",
+  { "USB: Seagate FreeAgent Desk; ", // 1TB
+    "0x0bc2:0x3008",
+    "",
+    "",
+    "-d sat,12"
+  },
+  { "USB: Seagate Expansion External; ", // 2TB, 3TB
+    "0x0bc2:0x33(00|20|32)",
     "",
     "",
     "-d sat"
@@ -3062,8 +3137,8 @@ const drive_settings builtin_knowndrives[] = {
     "",
     "-d sat"
   },
-  { "USB: Seagate Backup Plus Desktop USB 3.0; ", // 3TB, 8 LBA/1 PBA offset
-    "0x0bc2:0xa0a4",
+  { "USB: Seagate Backup Plus Desktop USB 3.0; ", // 4TB, 3TB (8 LBA/1 PBA offset)
+    "0x0bc2:0xa0a[14]",
     "",
     "",
     "-d sat"
@@ -3219,7 +3294,7 @@ const drive_settings builtin_knowndrives[] = {
     "-d sat"
   },
   { "USB: WD Elements; ",
-    "0x1058:0x1010",
+    "0x1058:0x10(10|a2)",
     "", // 0x0105
     "",
     "-d sat"
@@ -3534,6 +3609,13 @@ const drive_settings builtin_knowndrives[] = {
     "",
     "" // unsupported
   },
+  // 0x6795 (?)
+  { "USB: Sharkoon 2-Bay RAID Box; ", // USB 3.0
+    "0x6795:0x2756",
+    "", // 0x0100
+    "",
+    "-d sat"
+  },
 /*
 }; // builtin_knowndrives[]
  */
index 4f00cddcaa5cc06c31dc7574df74b306a94ce667..502d228f09297487a58cb98e3e6a12b73e9139d4 100644 (file)
@@ -75,7 +75,7 @@
 #define PATHINQ_SETTINGS_SIZE   128
 #endif
 
-const char *os_XXXX_c_cvsid="$Id: os_freebsd.cpp 3771 2013-02-10 15:36:55Z samm2 $" \
+const char *os_XXXX_c_cvsid="$Id: os_freebsd.cpp 3824 2013-07-05 10:40:38Z samm2 $" \
 ATACMDS_H_CVSID CCISS_H_CVSID CONFIG_H_CVSID INT64_H_CVSID OS_FREEBSD_H_CVSID SCSICMDS_H_CVSID UTILITY_H_CVSID;
 
 #define NO_RETURN 0
@@ -1827,6 +1827,11 @@ smart_device * freebsd_smart_interface::autodetect_smart_device(const char * nam
     for (i = 0; i < (int)scsinames.size(); i++) {
       if(strcmp(scsinames[i].c_str(), test_name)==0)
       { // our disk device is CAM
+        if(strncmp(scsinames[i].c_str(), "/dev/pmp", strlen("/dev/pmp")) == 0) {
+          pout("Skipping port multiplier [%s]\n", scsinames[i].c_str());
+          set_err(EINVAL);
+          return 0;
+        }
         if ((cam_dev = cam_open_device(test_name, O_RDWR)) == NULL) {
           // open failure
           set_err(errno);
@@ -1923,7 +1928,7 @@ smart_device * freebsd_smart_interface::get_custom_smart_device(const char * nam
       set_err(EINVAL, "Option '-d hpt,L/M/N' invalid controller id L supplied");
       return 0;
     }
-    if (!(1 <= channel && channel <= 16)) {
+    if (!(1 <= channel && channel <= 128)) {
       set_err(EINVAL, "Option '-d hpt,L/M/N' invalid channel number M supplied");
       return 0;
     }
index 164e8f794efdf98532cacaf6018c11b891b94cea..dbdab1f4be3e3ee9ffdc214198680dec4e8ea3e4 100644 (file)
@@ -91,7 +91,7 @@
 
 #define ARGUSED(x) ((void)(x))
 
-const char * os_linux_cpp_cvsid = "$Id: os_linux.cpp 3738 2012-12-17 12:01:35Z samm2 $"
+const char * os_linux_cpp_cvsid = "$Id: os_linux.cpp 3824 2013-07-05 10:40:38Z samm2 $"
   OS_LINUX_H_CVSID;
 extern unsigned char failuretest_permissive;
 
@@ -2908,7 +2908,7 @@ smart_device * linux_smart_interface::get_custom_smart_device(const char * name,
       set_err(EINVAL, "Option '-d hpt,L/M/N' invalid controller id L supplied");
       return 0;
     }
-    if (!(1 <= channel && channel <= 16)) {
+    if (!(1 <= channel && channel <= 128)) {
       set_err(EINVAL, "Option '-d hpt,L/M/N' invalid channel number M supplied");
       return 0;
     }
index 6c5fc5178d795eb36b9d62b43db198f7898ca3b6..8e4abfb2479afe5f0549ffb08634a97dd6336ee2 100644 (file)
@@ -95,7 +95,7 @@
 #define SELECT_WIN_32_64(x32, x64) (x64)
 #endif
 
-const char * os_win32_cpp_cvsid = "$Id: os_win32.cpp 3804 2013-03-27 20:39:41Z chrfranke $";
+const char * os_win32_cpp_cvsid = "$Id: os_win32.cpp 3830 2013-07-18 20:59:53Z chrfranke $";
 
 /////////////////////////////////////////////////////////////////////////////
 // Windows I/O-controls, some declarations are missing in the include files
@@ -604,36 +604,51 @@ std::string win_smart_interface::get_os_version_str()
       return vstr;
   }
 
-  if (vi.dwPlatformId > 0xff || vi.dwMajorVersion > 0xff || vi.dwMinorVersion > 0xff)
-    return vstr;
-
-  const char * w;
-  switch (vi.dwPlatformId << 16 | vi.dwMajorVersion << 8 | vi.dwMinorVersion) {
-    case VER_PLATFORM_WIN32_WINDOWS<<16|0x0400| 0:
-      w = (vi.szCSDVersion[1] == 'B' ||
-           vi.szCSDVersion[1] == 'C'     ? "95-osr2" : "95");    break;
-    case VER_PLATFORM_WIN32_WINDOWS<<16|0x0400|10:
-      w = (vi.szCSDVersion[1] == 'A'     ? "98se"    : "98");    break;
-    case VER_PLATFORM_WIN32_WINDOWS<<16|0x0400|90: w = "me";     break;
-  //case VER_PLATFORM_WIN32_NT     <<16|0x0300|51: w = "nt3.51"; break;
-    case VER_PLATFORM_WIN32_NT     <<16|0x0400| 0: w = "nt4";    break;
-    case VER_PLATFORM_WIN32_NT     <<16|0x0500| 0: w = "2000";   break;
-    case VER_PLATFORM_WIN32_NT     <<16|0x0500| 1:
-      w = (!GetSystemMetrics(87/*SM_MEDIACENTER*/) ?   "xp"
-                                                   :   "xp-mc"); break;
-    case VER_PLATFORM_WIN32_NT     <<16|0x0500| 2:
-      w = (!GetSystemMetrics(89/*SM_SERVERR2*/)    ?   "2003"
-                                                   :   "2003r2"); break;
-    case VER_PLATFORM_WIN32_NT     <<16|0x0600| 0:
-      w = (vi.wProductType == VER_NT_WORKSTATION   ?   "vista"
-                                                   :   "2008" );  break;
-    case VER_PLATFORM_WIN32_NT     <<16|0x0600| 1:
-      w = (vi.wProductType == VER_NT_WORKSTATION   ?   "win7"
-                                                   :   "2008r2"); break;
-    case VER_PLATFORM_WIN32_NT     <<16|0x0600| 2:
-      w = (vi.wProductType == VER_NT_WORKSTATION   ?   "win8"
-                                                   :   "2012"); break;
-    default: w = 0; break;
+  const char * w = 0;
+  if (vi.dwPlatformId == VER_PLATFORM_WIN32_NT) {
+
+    if (vi.dwMajorVersion > 6 || (vi.dwMajorVersion == 6 && vi.dwMinorVersion >= 2)) {
+      // Starting with Windows 8.1 Preview, GetVersionEx() does no longer report the
+      // actual OS version, see:
+      // http://msdn.microsoft.com/en-us/library/windows/desktop/dn302074.aspx
+
+      ULONGLONG major_equal = VerSetConditionMask(0, VER_MAJORVERSION, VER_EQUAL);
+      for (unsigned major = vi.dwMajorVersion; major <= 9; major++) {
+        OSVERSIONINFOEXA vi2; memset(&vi2, 0, sizeof(vi2));
+        vi2.dwOSVersionInfoSize = sizeof(vi2); vi2.dwMajorVersion = major;
+        if (!VerifyVersionInfo(&vi2, VER_MAJORVERSION, major_equal))
+          continue;
+        if (vi.dwMajorVersion < major) {
+          vi.dwMajorVersion = major; vi.dwMinorVersion = 0;
+        }
+
+        ULONGLONG minor_equal = VerSetConditionMask(0, VER_MINORVERSION, VER_EQUAL);
+        for (unsigned minor = vi.dwMinorVersion; minor <= 9; minor++) {
+          memset(&vi2, 0, sizeof(vi2)); vi2.dwOSVersionInfoSize = sizeof(vi2);
+          vi2.dwMinorVersion = minor;
+          if (!VerifyVersionInfo(&vi2, VER_MINORVERSION, minor_equal))
+            continue;
+          vi.dwMinorVersion = minor;
+          break;
+        }
+
+        break;
+      }
+    }
+
+    if (vi.dwMajorVersion <= 0xf && vi.dwMinorVersion <= 0xf) {
+      bool ws = (vi.wProductType <= VER_NT_WORKSTATION);
+      switch (vi.dwMajorVersion << 4 | vi.dwMinorVersion) {
+        case 0x50: w =       "2000";              break;
+        case 0x51: w =       "xp";                break;
+        case 0x52: w = (!GetSystemMetrics(89/*SM_SERVERR2*/)
+                           ? "2003"  : "2003r2"); break;
+        case 0x60: w = (ws ? "vista" : "2008"  ); break;
+        case 0x61: w = (ws ? "win7"  : "2008r2"); break;
+        case 0x62: w = (ws ? "win8"  : "2012"  ); break;
+        case 0x63: w = (ws ? "win8.1": "2012r2"); break;
+      }
+    }
   }
 
   const char * w64 = "";
@@ -644,7 +659,7 @@ std::string win_smart_interface::get_os_version_str()
 
   if (!w)
     snprintf(vptr, vlen, "-%s%u.%u%s",
-      (vi.dwPlatformId==VER_PLATFORM_WIN32_NT ? "nt" : "9x"),
+      (vi.dwPlatformId==VER_PLATFORM_WIN32_NT ? "nt" : "??"),
       (unsigned)vi.dwMajorVersion, (unsigned)vi.dwMinorVersion, w64);
   else if (vi.wServicePackMinor)
     snprintf(vptr, vlen, "-%s%s-sp%u.%u", w, w64, vi.wServicePackMajor, vi.wServicePackMinor);
index ae3dc29173697a84f4c779df12f1a1d338279283..9404efd0c486ee957a9d7519f6e505260d3d803f 100644 (file)
@@ -20,7 +20,7 @@
 
 #include "daemon_win32.h"
 
-const char * daemon_win32_cpp_cvsid = "$Id: daemon_win32.cpp 3760 2013-01-30 18:43:39Z chrfranke $"
+const char * daemon_win32_cpp_cvsid = "$Id: daemon_win32.cpp 3834 2013-07-20 16:17:13Z chrfranke $"
   DAEMON_WIN32_H_CVSID;
 
 #include <stdio.h>
@@ -987,7 +987,7 @@ static int svcadm_main(const char * ident, const daemon_winsvc_options * svc_opt
     if (!(hs = CreateService(hm,
       svc_opts->svcname, svc_opts->dispname,
       SERVICE_ALL_ACCESS,
-      SERVICE_WIN32_OWN_PROCESS|SERVICE_INTERACTIVE_PROCESS,
+      SERVICE_WIN32_OWN_PROCESS,
       SERVICE_AUTO_START, SERVICE_ERROR_NORMAL, path,
       NULL/*no load ordering*/, NULL/*no tag id*/,
       ""/*no depedencies*/, NULL/*local system account*/, NULL/*no pw*/))) {
index a0eaa84fcc40386ae85f6b1d648965bde8cee574..3a7b0997066b54dae587cdadf9c4abfc6df42473 100644 (file)
@@ -12,7 +12,7 @@
 :: You should have received a copy of the GNU General Public License
 :: (for example COPYING); If not, see <http://www.gnu.org/licenses/>.
 ::
-:: $Id: smartd_warning.cmd 3810 2013-04-18 20:08:39Z chrfranke $
+:: $Id: smartd_warning.cmd 3816 2013-06-09 16:16:11Z chrfranke $
 ::
 
 set err=
@@ -59,8 +59,8 @@ if "%USERDNSDOMAIN%" == "" (
 set SMARTD_SUBJECT=SMART error (%SMARTD_FAILTYPE%) detected on host: %COMPUTERNAME%
 
 :: Temp file for message
-if not "%TMP%" == "" set SMARTD_FULLMSGFILE=%TMP%\smartd_warning-%DATE%-%RANDOM%.txt
-if     "%TMP%" == "" set SMARTD_FULLMSGFILE=smartd_warning-%DATE%-%RANDOM%.txt
+if not "%TMP%" == "" set SMARTD_FULLMSGFILE=%TMP%\smartd_warning-%RANDOM%.txt
+if     "%TMP%" == "" set SMARTD_FULLMSGFILE=smartd_warning-%RANDOM%.txt
 
 :: Format message
 (
index f0e681c659ad77c135649815c7d5af0e74e49844..aa2d525e5d1daf2200f092eaf6b2f6ea387203fa 100644 (file)
@@ -3,7 +3,7 @@
 ;
 ; Home page of code is: http://smartmontools.sourceforge.net
 ;
-; Copyright (C) 2011 Christian Franke <smartmontools-support@lists.sourceforge.net>
+; Copyright (C) 2011-13 Christian Franke <smartmontools-support@lists.sourceforge.net>
 ;
 ; 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
@@ -13,7 +13,7 @@
 ; You should have received a copy of the GNU General Public License
 ; (for example COPYING); If not, see <http://www.gnu.org/licenses/>.
 ;
-; $Id: update-smart-drivedb.nsi 3392 2011-06-29 19:13:22Z chrfranke $
+; $Id: update-smart-drivedb.nsi 3815 2013-06-06 17:31:59Z chrfranke $
 ;
 
 
@@ -95,10 +95,10 @@ Function Download
   Pop $R0
   DetailPrint "Download from $R0"
 
-  ; Trac repository browser (does not return HTTP 404 errors)
-  StrCpy $R1 "http://sourceforge.net/apps/trac/smartmontools/export/HEAD/$R0/smartmontools/drivedb.h"
-  ; ViewVC repository browser (does not return ContentLength required for NSISdl::download)
-  ;StrCpy $R1 "http://smartmontools.svn.sourceforge.net/viewvc/smartmontools/$R0/smartmontools/drivedb.h?revision=HEAD"
+  ; SVN repository read-only URL
+  ; (SF code browser does not return ContentLength required for NSISdl::download)
+  StrCpy $R1 "http://svn.code.sf.net/p/smartmontools/code/$R0/smartmontools/drivedb.h"
+
   DetailPrint "($R1)"
 
   NSISdl::download $R1 "drivedb.h.new"
index 3adc913f1f543e4999b24dc7a7c9fc7fd8b5d308..623be8d65aee1fc83da60685749ae6b18aae19fc 100644 (file)
@@ -40,6 +40,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <errno.h>
+#include <ctype.h>
 
 #include "config.h"
 #include "int64.h"
@@ -48,7 +49,7 @@
 #include "dev_interface.h"
 #include "utility.h"
 
-const char *scsicmds_c_cvsid="$Id: scsicmds.cpp 3807 2013-04-18 17:11:12Z chrfranke $"
+const char *scsicmds_c_cvsid="$Id: scsicmds.cpp 3820 2013-06-17 08:45:10Z samm2 $"
   SCSICMDS_H_CVSID;
 
 // Print SCSI debug messages?
index c30e03e570627831a49489ad420a5dcc8174eafd..e7a2dcea1e49331fde9551e23310518c5e85ebbc 100644 (file)
@@ -2,7 +2,7 @@
 Copyright (C) 2002-10 Bruce Allen <smartmontools-support@lists.sourceforge.net>
 Copyright (C) 2004-13 Christian Franke <smartmontools-support@lists.sourceforge.net>
 
-$Id: smartctl.8.in 3799 2013-03-15 17:47:25Z chrfranke $
+$Id: smartctl.8.in 3832 2013-07-20 14:49:31Z chrfranke $
 
 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
@@ -553,7 +553,7 @@ such as:
 connected to a HighPoint RocketRAID controller.  The integer L is the
 controller id, the integer M is the channel number, and the integer N
 is the PMPort number if it is available.  The allowed values of L are
-from 1 to 4 inclusive, M are from 1 to 16 inclusive and N from 1 to 4
+from 1 to 4 inclusive, M are from 1 to 128 inclusive and N from 1 to 4
 if PMPort available.  And also these values are limited by the model
 of the HighPoint RocketRAID controller.
 Use syntax such as:
@@ -884,6 +884,17 @@ The write cache is usually enabled by default.
 Gets/sets the \'Write Cache Enable\' (WCE) bit (if supported).
 The write cache is usually enabled by default.
 
+.I wcreorder[,on|off]
+\- [ATA only] [NEW EXPERIMENTAL SMARTCTL FEATURE]
+Gets/sets Write Cache Reordering.
+If it is disabled (off), disk write scheduling is executed on a 
+first-in-first-out (FIFO) basis. If Write Cache Reordering is enabled (on),
+then disk write scheduling may be reordered by the drive. If write cache is
+disabled, the current Write Cache Reordering state is remembered but has
+no effect on non-cached writes, which are always written in the order received.
+The state of Write Cache Reordering has no effect on either NCQ or LCQ queued
+commands.
+
 .I rcache[,on|off]
 \- [SCSI only] [NEW EXPERIMENTAL SMARTCTL FEATURE]
 Gets/sets the \'Read Cache Disable\' (RCE) bit. \'Off\' value disables read cache
@@ -2256,4 +2267,4 @@ Links to these and other documents may be found on the Links page of the
 
 .SH
 SVN ID OF THIS PAGE:
-$Id: smartctl.8.in 3799 2013-03-15 17:47:25Z chrfranke $
+$Id: smartctl.8.in 3832 2013-07-20 14:49:31Z chrfranke $
index 190f9f3af6ded2e07b89ab0066e8b5746cd4404e..61c7c93e30c0be72a36ef543fc1aff81c71b5480 100644 (file)
@@ -50,7 +50,7 @@
 #include "smartctl.h"
 #include "utility.h"
 
-const char * smartctl_cpp_cvsid = "$Id: smartctl.cpp 3726 2012-12-12 20:02:48Z chrfranke $"
+const char * smartctl_cpp_cvsid = "$Id: smartctl.cpp 3826 2013-07-06 21:57:29Z samm2 $"
   CONFIG_H_CVSID SMARTCTL_H_CVSID;
 
 // Globals to control printing
@@ -85,7 +85,7 @@ static void Usage()
 "  --identify[=[w][nvb]]\n"
 "         Show words and bits from IDENTIFY DEVICE data                (ATA)\n\n"
 "  -g NAME, --get=NAME\n"
-"        Get device setting: all, aam, apm, lookahead, security, wcache, rcache\n\n"
+"        Get device setting: all, aam, apm, lookahead, security, wcache, rcache, wcreorder\n\n"
 "  -a, --all\n"
 "         Show all SMART information for device\n\n"
 "  -x, --xall\n"
@@ -121,7 +121,7 @@ static void Usage()
 "  -s NAME[,VALUE], --set=NAME[,VALUE]\n"
 "        Enable/disable/change device setting: aam,[N|off], apm,[N|off],\n"
 "        lookahead,[on|off], security-freeze, standby,[N|off|now],\n"
-"        wcache,[on|off], rcache,[on|off]\n\n"
+"        wcache,[on|off], rcache,[on|off], wcreorder,[on|off]\n\n"
   );
   printf(
 "======================================= READ AND DISPLAY DATA OPTIONS =====\n\n"
@@ -218,10 +218,10 @@ static std::string getvalidarglist(int opt)
   case 'f':
     return "old, brief, hex[,id|val]";
   case 'g':
-    return "aam, apm, lookahead, security, wcache, rcache";
+    return "aam, apm, lookahead, security, wcache, rcache, wcreorder";
   case opt_set:
     return "aam,[N|off], apm,[N|off], lookahead,[on|off], security-freeze, "
-           "standby,[N|off|now], wcache,[on|off], rcache,[on|off]";
+           "standby,[N|off|now], wcache,[on|off], rcache,[on|off], wcreorder,[on|off]";
   case 's':
     return getvalidarglist(opt_smart)+", "+getvalidarglist(opt_set);
   case opt_identify:
@@ -626,6 +626,7 @@ static const char * parse_options(int argc, char** argv,
       ataopts.smart_logdir = ataopts.gp_logdir = true;
       ataopts.sct_temp_sts = ataopts.sct_temp_hist = true;
       ataopts.sct_erc_get = true;
+      ataopts.sct_wcache_reorder_get = true;
       ataopts.devstat_all_pages = true;
       ataopts.sataphy = true;
       ataopts.get_set_used = true;
@@ -867,6 +868,17 @@ static const char * parse_options(int argc, char** argv,
             else
               badarg = true;
           }
+          else if (!strcmp(name, "wcreorder")) {
+            if (get) {
+              ataopts.sct_wcache_reorder_get = true;
+            }
+            else if (off)
+              ataopts.sct_wcache_reorder_set = -1;
+            else if (on)
+              ataopts.sct_wcache_reorder_set = 1;
+            else
+              badarg = true;
+          }
           else if (!strcmp(name, "rcache")) {
             if (get)
               scsiopts.get_rcd = true;
index a4b093c05dfc2e8fd09e4119f334e2e34ae36ee9..f3722624c9be49dbc37f6b829d874d5d37b2485e 100644 (file)
@@ -2,7 +2,7 @@
 Copyright (C) 2002-10 Bruce Allen <smartmontools-support@lists.sourceforge.net>
 Copyright (C) 2004-13 Christian Franke <smartmontools-support@lists.sourceforge.net>
 
-$Id: smartd.conf.5.in 3741 2013-01-02 17:06:54Z chrfranke $
+$Id: smartd.conf.5.in 3833 2013-07-20 15:00:04Z chrfranke $
 
 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
@@ -460,7 +460,7 @@ Please see the \fBsmartctl\fP(8) man page for further details.
 connected to a HighPoint RocketRAID controller.  The integer L is the
 controller id, the integer M is the channel number, and the integer N
 is the PMPort number if it is available.  The allowed values of L are
-from 1 to 4 inclusive, M are from 1 to 16 inclusive and N from 1 to 4
+from 1 to 4 inclusive, M are from 1 to 128 inclusive and N from 1 to 4
 if PMPort available.  And also these values are limited by the model
 of the HighPoint RocketRAID controller.
 In log files and email messages this disk will be identified as
@@ -1656,4 +1656,4 @@ SEE ALSO:
 
 .SH
 SVN ID OF THIS PAGE:
-$Id: smartd.conf.5.in 3741 2013-01-02 17:06:54Z chrfranke $
+$Id: smartd.conf.5.in 3833 2013-07-20 15:00:04Z chrfranke $
index ca728e170820abe70e27f4ec56fab2d8c02c38cf..1bd6395b67b7c4c700cf43e09fff897e94760197 100644 (file)
@@ -2,7 +2,7 @@
 #
 # smartmontools drive database update script
 #
-# Copyright (C) 2010-11 Christian Franke <smartmontools-support@lists.sourceforge.net>
+# Copyright (C) 2010-13 Christian Franke <smartmontools-support@lists.sourceforge.net>
 #
 # 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
@@ -12,7 +12,7 @@
 # You should have received a copy of the GNU General Public License
 # (for example COPYING); If not, see <http://www.gnu.org/licenses/>.
 #
-# $Id: update-smart-drivedb.in 3294 2011-03-16 21:36:58Z chrfranke $
+# $Id: update-smart-drivedb.in 3814 2013-06-04 19:38:25Z chrfranke $
 #
 
 set -e
@@ -39,12 +39,8 @@ DEST="$drivedbdir/drivedb.h"
 # Smartctl used for syntax check
 SMARTCTL="$sbindir/smartctl"
 
-# Trac repository browser (does not return HTTP 404 errors)
-#SRCEXPR='http://sourceforge.net/apps/trac/smartmontools/export/HEAD/$location/smartmontools/drivedb.h'
-
-# ViewVC repository browser
-SRCEXPR='http://smartmontools.svn.sourceforge.net/viewvc/smartmontools/$location/smartmontools/drivedb.h?revision=HEAD'
-
+# Download URL for sourceforge code browser
+SRCEXPR='http://sourceforge.net/p/smartmontools/code/HEAD/tree/$location/smartmontools/drivedb.h?format=raw'
 
 # Parse options
 q="-q "
@@ -106,8 +102,8 @@ for location in "branches/$BRANCH" "trunk"; do
     errmsg="download from $location failed (HTTP error)"
     continue
   fi
-  if grep -i 'ViewVC Exception' "$DEST.new" >/dev/null; then
-    errmsg="download from $location failed (ViewVC error)"
+  if grep -i '<title>.*Error has Occurred' "$DEST.new" >/dev/null; then
+    errmsg="download from $location failed (SF code browser error)"
     continue
   fi
 
@@ -132,10 +128,10 @@ if $SMARTCTL -B "$DEST.new" -P showall >/dev/null; then :; else
   exit 1
 fi
 
-# Keep old file if identical, ignore differences in Id string
+# Keep old file if identical
 rm -f "$DEST.lastcheck"
 if [ -f "$DEST" ]; then
-  if cat "$DEST" | sed 's|\$''Id''[^$]*\$|$''Id''$|' | cmp - "$DEST.new" >/dev/null; then
+  if cmp "$DEST" "$DEST.new" >/dev/null 2>/dev/null; then
     rm -f "$DEST.new"
     touch "$DEST.lastcheck"
     echo "$DEST is already up to date"
index e1454cc2f45cce057130169d0ca8f25af85d17c9..7cd81ca14aa4e6117bf00c114e67c919a21b6842 100644 (file)
@@ -52,7 +52,7 @@
 #include "atacmds.h"
 #include "dev_interface.h"
 
-const char * utility_cpp_cvsid = "$Id: utility.cpp 3739 2013-01-01 16:32:48Z chrfranke $"
+const char * utility_cpp_cvsid = "$Id: utility.cpp 3838 2013-07-21 16:32:27Z chrfranke $"
                                  UTILITY_H_CVSID INT64_H_CVSID;
 
 const char * packet_types[] = {
@@ -364,27 +364,62 @@ void syserror(const char *message){
   return;
 }
 
+// Check regular expression for non-portable features.
+//
 // POSIX extended regular expressions interpret unmatched ')' ordinary:
 // "The close-parenthesis shall be considered special in this context
 //  only if matched with a preceding open-parenthesis."
 //
-// Actual '(...)' nesting errors remain undetected on strict POSIX
-// implementations (glibc) but an error is reported on others (Cygwin).
-// 
-// The check below is rather incomplete because it does not handle
-// e.g. '\)' '[)]'.
-// But it should work for the regex subset used in drive database
-// and smartd '-s' directives.
-static int check_regex_nesting(const char * pattern)
+// GNU libc and BSD libc support unmatched ')', Cygwin reports an error.
+//
+// POSIX extended regular expressions do not define empty subexpressions:
+// "A vertical-line appearing first or last in an ERE, or immediately following
+//  a vertical-line or a left-parenthesis, or immediately preceding a
+//  right-parenthesis, produces undefined results."
+//
+// GNU libc and Cygwin support empty subexpressions, BSD libc reports an error.
+//
+static const char * check_regex(const char * pattern)
 {
-  int level = 0, i;
-  for (i = 0; pattern[i] && level >= 0; i++) {
-    switch (pattern[i]) {
-      case '(': level++; break;
-      case ')': level--; break;
+  int level = 0;
+  char c;
+
+  for (int i = 0; (c = pattern[i]); i++) {
+    // Skip "\x"
+    if (c == '\\') {
+      if (!pattern[++i])
+        break;
+      continue;
     }
+
+    // Skip "[...]"
+    if (c == '[') {
+      if (pattern[++i] == '^')
+        i++;
+      if (!pattern[i++])
+        break;
+      while ((c = pattern[i]) && c != ']')
+        i++;
+      if (!c)
+        break;
+      continue;
+    }
+
+    // Check "(...)" nesting
+    if (c == '(')
+      level++;
+    else if (c == ')' && --level < 0)
+      return "Unmatched ')'";
+
+    // Check for leading/trailing '|' or "||", "|)", "|$", "(|", "^|"
+    char c1;
+    if (   (c == '|' && (   i == 0 || !(c1 = pattern[i+1])
+                          || c1 == '|' || c1 == ')' || c1 == '$'))
+        || ((c == '(' || c == '^') && pattern[i+1] == '|')       )
+      return "Empty '|' subexpression";
   }
-  return level;
+
+  return (const char *)0;
 }
 
 // Wrapper class for regex(3)
@@ -465,8 +500,9 @@ bool regular_expression::compile()
     return false;
   }
 
-  if (check_regex_nesting(m_pattern.c_str()) < 0) {
-    m_errmsg = "Unmatched ')'";
+  const char * errmsg = check_regex(m_pattern.c_str());
+  if (errmsg) {
+    m_errmsg = errmsg;
     free_buf();
     return false;
   }