Package: smartmontools Version: 5.41+svn3365-1 Severity: normal Tags: patch
Dear Maintainer, smartctl -a will still happily exit with success if there are failing attributes detected but the disk reports its overall health status as PASS. However, disks are rather liberal at declaring themselves PASS and automatically detecting whether a disk is showing signs of failing is rather convoluted in the absence of proper exit code. The attached patch attempts to remedy the situation. -- Package-specific info: Output of /usr/share/bug/smartmontools: # CONFIG_IDE_TASK_IOCTL is not set -- System Information: Debian Release: wheezy/sid APT prefers testing APT policy: (990, 'testing'), (500, 'unstable'), (1, 'experimental') Architecture: amd64 (x86_64) Kernel: Linux 3.2.0-1-amd64 (SMP w/2 CPU cores) Locale: LANG=en_US.UTF-8, LC_CTYPE=cs_CZ.utf8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Versions of packages smartmontools depends on: ii debianutils 4.2.1 ii libc6 2.13-27 ii libcap-ng0 0.6.6-1 ii libgcc1 1:4.6.3-1 ii libselinux1 2.1.9-2 ii libstdc++6 4.6.3-1 ii lsb-base 3.2-28.1 Versions of packages smartmontools recommends: ii bsd-mailx [mailx] 8.1.2-0.20111106cvs-1 Versions of packages smartmontools suggests: pn gsmartcontrol <none> pn smart-notifier <none> -- no debconf information
--- debian/changelog.orig 2010-12-26 12:26:38.000000000 +0100 +++ debian/changelog 2011-06-22 19:55:21.000000000 +0200 @@ -1,1 +1,7 @@ +smartmontools (...) unstable; urgency=low + + * Fix return value for global PASSED status but some attributes + still reporting FAILING_NOW + + -- Petr Baudis <[email protected]> Fri, 16 Mar 2012 04:16:32 +0100 + --- ataprint.cpp.orig 2011-06-14 21:27:12.000000000 +0200 +++ ataprint.cpp 2011-06-22 19:54:04.000000000 +0200 @@ -804,12 +804,13 @@ // onlyfailed=0 : print all attribute values // onlyfailed=1: just ones that are currently failed and have prefailure bit set // onlyfailed=2: ones that are failed, or have failed with or without prefailure bit set -static void PrintSmartAttribWithThres(const ata_smart_values * data, - const ata_smart_thresholds_pvt * thresholds, - const ata_vendor_attr_defs & defs, - int onlyfailed, unsigned char format) +static int PrintSmartAttribWithThres(const ata_smart_values * data, + const ata_smart_thresholds_pvt * thresholds, + const ata_vendor_attr_defs & defs, + int onlyfailed, unsigned char format) { bool needheader = true; + int ret = 0; // step through all vendor attributes for (int i = 0; i < NUMBER_ATA_SMART_ATTRIBUTES; i++) { @@ -828,4 +829,9 @@ } + if (state == ATTRSTATE_FAILED_NOW) + ret |= FAILATTR; + else if (state == ATTRSTATE_FAILED_PAST) + ret |= FAILAGE; + if (!needheader) { if (!onlyfailed && format == 1) @@ -880,4 +880,5 @@ pout("\n"); } + return ret; } @@ -2036,7 +2042,7 @@ else { print_on(); pout("Please note the following marginal Attributes:\n"); - PrintSmartAttribWithThres(&smartval, &smartthres, attribute_defs, 2, options.output_format); + returnval |= PrintSmartAttribWithThres(&smartval, &smartthres, attribute_defs, 2, options.output_format); } returnval|=FAILAGE; } @@ -2057,7 +2063,7 @@ else { print_on(); pout("Failed Attributes:\n"); - PrintSmartAttribWithThres(&smartval, &smartthres, attribute_defs, 1, options.output_format); + returnval |= PrintSmartAttribWithThres(&smartval, &smartthres, attribute_defs, 1, options.output_format); } } else @@ -2090,7 +2096,7 @@ else { print_on(); pout("Failed Attributes:\n"); - PrintSmartAttribWithThres(&smartval, &smartthres, attribute_defs, 1, options.output_format); + returnval |= PrintSmartAttribWithThres(&smartval, &smartthres, attribute_defs, 1, options.output_format); } } else { @@ -2102,7 +2108,7 @@ else { print_on(); pout("Please note the following marginal Attributes:\n"); - PrintSmartAttribWithThres(&smartval, &smartthres, attribute_defs, 2, options.output_format); + returnval |= PrintSmartAttribWithThres(&smartval, &smartthres, attribute_defs, 2, options.output_format); } returnval|=FAILAGE; } @@ -2123,8 +2129,8 @@ // Print vendor-specific attributes if (smart_val_ok && options.smart_vendor_attrib) { print_on(); - PrintSmartAttribWithThres(&smartval, &smartthres, attribute_defs, - (printing_is_switchable ? 2 : 0), options.output_format); + returnval |= PrintSmartAttribWithThres(&smartval, &smartthres, attribute_defs, + (printing_is_switchable ? 2 : 0), options.output_format); print_off(); }

