From 1495fd232eabb1f394f583694f44fdee0a43fd02 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Apr 22 2009 23:37:01 +0000 Subject: Properly handle some ST and FUJITSU drive attributes. (rhbz 496087, 497107) --- diff --git a/0001-Seagate-s-ST9160821AS-drive-encodes-something-strang.patch b/0001-Seagate-s-ST9160821AS-drive-encodes-something-strang.patch new file mode 100644 index 0000000..6c64396 --- /dev/null +++ b/0001-Seagate-s-ST9160821AS-drive-encodes-something-strang.patch @@ -0,0 +1,60 @@ +From d274be25f7cd7ac60f5c10dcf569b57019e803b2 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Thu, 23 Apr 2009 00:30:19 +0200 +Subject: [PATCH] Seagate's ST9160821AS drive encodes something strange in attribute 9 + +Attribute 9 of ST9160821AS apparently is not the power on time in hours. +Since we have no idea what it is and how it is encoded this adds a quirk +to mark the attribute as 'unknown' for this drive. + +See rhbz #497107. +--- + atasmart.c | 11 ++++++++++- + 1 files changed, 10 insertions(+), 1 deletions(-) + +diff --git a/atasmart.c b/atasmart.c +index 8b44aa4..5cf6c30 100644 +--- a/atasmart.c ++++ b/atasmart.c +@@ -1205,6 +1205,7 @@ typedef enum SkSmartQuirk { + SK_SMART_QUIRK_194_UNKNOWN = 64, + SK_SMART_QUIRK_200_WRITEERRORCOUNT = 128, + SK_SMART_QUIRK_201_DETECTEDTACOUNT = 256, ++ SK_SMART_QUIRK_9_UNKNOWN = 512 + } SkSmartQuirk; + + /* %STRINGPOOLSTART% */ +@@ -1218,6 +1219,7 @@ static const char *quirk_name[] = { + "194_UNKNOWN", + "200_WRITEERRORCOUNT", + "201_DETECTEDTACOUNT", ++ "9_UNKNOWN", + NULL + }; + /* %STRINGPOOLSTOP% */ +@@ -1230,6 +1232,12 @@ typedef struct SkSmartQuirkDatabase { + + static const SkSmartQuirkDatabase quirk_database[] = { { + ++ /*** Seagate */ ++ "^ST9160821AS$", ++ NULL, ++ SK_SMART_QUIRK_9_UNKNOWN ++ }, { ++ + /*** Fujitsu */ + "^FUJITSU MHR2040AT$", + NULL, +@@ -1451,7 +1459,8 @@ static const SkSmartAttributeInfo *lookup_attribute(SkDisk *d, uint8_t id) { + "power-on-half-minutes", SK_SMART_ATTRIBUTE_UNIT_MSECONDS + }; + return &a; +- } ++ } else if (quirk & SK_SMART_QUIRK_9_UNKNOWN) ++ return NULL; + /* %STRINGPOOLSTOP% */ + + break; +-- +1.6.2.2 + diff --git a/0001-don-t-claim-we-would-know-what-reallocated-event-cou.patch b/0001-don-t-claim-we-would-know-what-reallocated-event-cou.patch new file mode 100644 index 0000000..12100ce --- /dev/null +++ b/0001-don-t-claim-we-would-know-what-reallocated-event-cou.patch @@ -0,0 +1,46 @@ +From 1d770b0d655cb20dfd093f012eaef72b2efe07fa Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Thu, 23 Apr 2009 00:28:54 +0200 +Subject: [PATCH] don't claim we would know what reallocated-event-count actually is + +We don't reliably know what this actually is on many drives and since it +is redundant to reallocated-sectors-count it's no loss to admit that we +have no clue. + +See rhbz #497107. +--- + atasmart.c | 5 ++--- + 1 files changed, 2 insertions(+), 3 deletions(-) + +diff --git a/atasmart.c b/atasmart.c +index 053cb88..8b44aa4 100644 +--- a/atasmart.c ++++ b/atasmart.c +@@ -1165,14 +1165,14 @@ static const SkSmartAttributeInfo const attribute_info[256] = { + [193] = { "load-cycle-count", SK_SMART_ATTRIBUTE_UNIT_NONE }, + [194] = { "temperature-celsius-2", SK_SMART_ATTRIBUTE_UNIT_MKELVIN }, + [195] = { "hardware-ecc-recovered", SK_SMART_ATTRIBUTE_UNIT_NONE }, +- [196] = { "reallocated-event-count", SK_SMART_ATTRIBUTE_UNIT_SECTORS }, ++ [196] = { "reallocated-event-count", SK_SMART_ATTRIBUTE_UNIT_NONE }, + [197] = { "current-pending-sector", SK_SMART_ATTRIBUTE_UNIT_SECTORS }, + [198] = { "offline-uncorrectable", SK_SMART_ATTRIBUTE_UNIT_SECTORS }, + [199] = { "udma-crc-error-count", SK_SMART_ATTRIBUTE_UNIT_NONE }, + [200] = { "multi-zone-error-rate", SK_SMART_ATTRIBUTE_UNIT_NONE }, + [201] = { "soft-read-error-rate", SK_SMART_ATTRIBUTE_UNIT_NONE }, + [202] = { "ta-increase-count", SK_SMART_ATTRIBUTE_UNIT_NONE }, +- [203] = { "run-out-cancel", SK_SMART_ATTRIBUTE_UNIT_NONE }, ++ [203] = { "run-out-cancel", SK_SMART_ATTRIBUTE_UNIT_UNKNOWN }, + [204] = { "shock-count-write-open", SK_SMART_ATTRIBUTE_UNIT_NONE }, + [205] = { "shock-rate-write-open", SK_SMART_ATTRIBUTE_UNIT_NONE }, + [206] = { "flying-height", SK_SMART_ATTRIBUTE_UNIT_UNKNOWN }, +@@ -1665,7 +1665,6 @@ int sk_disk_smart_parse_attributes(SkDisk *d, SkSmartAttributeParseCallback cb, + + /* Handle a few fields specially */ + if ((!strcmp(a.name, "reallocated-sector-count") || +- !strcmp(a.name, "reallocated-event-count") || + !strcmp(a.name, "current-pending-sector")) && + a.pretty_unit == SK_SMART_ATTRIBUTE_UNIT_SECTORS && + a.pretty_value > 0) { +-- +1.6.2.2 + diff --git a/0001-use-only-uppermost-32-bits-for-reallocated-sectors-c.patch b/0001-use-only-uppermost-32-bits-for-reallocated-sectors-c.patch new file mode 100644 index 0000000..102693f --- /dev/null +++ b/0001-use-only-uppermost-32-bits-for-reallocated-sectors-c.patch @@ -0,0 +1,31 @@ +From aa1f82fd2ba0cd0345cb5a36a66de64a0b70d321 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Thu, 23 Apr 2009 00:25:39 +0200 +Subject: [PATCH] use only uppermost 32 bits for reallocated-sectors-count attribute pretty value + +This seems to fix the attribute for Fujitsu drives. And those 32 bit +should be enough to still encode bad sectors up to 2TB which should be +more than enough. Hence it is probably safe to ignore the remaing 16 bit +even on non-Fujitsu drives. + +See rhbz #496087. +--- + atasmart.c | 2 ++ + 1 files changed, 2 insertions(+), 0 deletions(-) + +diff --git a/atasmart.c b/atasmart.c +index 20c3931..053cb88 100644 +--- a/atasmart.c ++++ b/atasmart.c +@@ -1129,6 +1129,8 @@ static void make_pretty(SkSmartAttributeParsedData *a) { + !strcmp(a->name, "loaded-hours") || + !strcmp(a->name, "head-flying-hours")) + a->pretty_value = fourtyeight * 60 * 60 * 1000; ++ else if (!strcmp(a->name, "reallocated-sector-count")) ++ a->pretty_value = fourtyeight & 0xFFFFFFFFU; + else + a->pretty_value = fourtyeight; + } +-- +1.6.2.2 + diff --git a/libatasmart.spec b/libatasmart.spec index 1121276..9f1a444 100644 --- a/libatasmart.spec +++ b/libatasmart.spec @@ -1,6 +1,6 @@ Name: libatasmart Version: 0.12 -Release: 1%{?dist} +Release: 2%{?dist} Summary: ATA S.M.A.R.T. Disk Health Monitoring Library Group: System Environment/Libraries Source0: http://0pointer.de/public/libatasmart-%{version}.tar.gz @@ -8,6 +8,9 @@ License: LGPLv2+ Url: http://git.0pointer.de/?p=libatasmart.git;a=summary BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: libudev-devel +Patch1: 0001-don-t-claim-we-would-know-what-reallocated-event-cou.patch +Patch2: 0001-Seagate-s-ST9160821AS-drive-encodes-something-strang.patch +Patch3: 0001-use-only-uppermost-32-bits-for-reallocated-sectors-c.patch %description A small and lightweight parser library for ATA S.M.A.R.T. hard disk @@ -27,6 +30,9 @@ Development Files for libatasmart Client Development %prep %setup -q +%patch1 -p1 +%patch2 -p1 +%patch3 -p1 %build %configure --disable-static @@ -55,6 +61,9 @@ rm -rf $RPM_BUILD_ROOT %doc blob-examples/SAMSUNG* blob-examples/ST* blob-examples/Maxtor* blob-examples/WDC* %changelog +* Wed Apr 22 2009 Lennart Poettering 0.12-2 +- Properly handle some ST and FUJITSU drive attributes. (rhbz 496087, 497107) + * Wed Apr 15 2009 Lennart Poettering 0.12-1 - New upstream release