Codebase list libatasmart / 66480f7
Merge commit 'upstream/0.17' Michael Biebl 14 years ago
12 changed file(s) with 172 addition(s) and 74 deletion(s). Raw diff Collapse all Expand all
2525 blob-examples/README \
2626 blob-examples/FUJITSU_MHY2120BH--0084000D \
2727 blob-examples/FUJITSU_MHY2120BH--0085000B \
28 blob-examples/FUJITSU_MHY2120BH--0085000B \
28 blob-examples/FUJITSU_MHY2250BH--0085000B \
2929 blob-examples/FUJITSU_MHZ2160BH_G1--0084000A \
3030 blob-examples/INTEL_SSDSA2MH080G1GC--045C8820 \
3131 blob-examples/Maxtor_96147H8--BAC51KJ0 \
3232 blob-examples/Maxtor_96147H8--BAC51KJ0--2 \
33 blob-examples/MCCOE64GEMPP--2.9.09 \
3334 blob-examples/SAMSUNG_HD501LJ--CR100-12 \
35 blob-examples/SAMSUNG_MMCQE28G8MUP--0VA_VAM08L1Q \
36 blob-examples/SAMSUNG_MP0804H--UE100-14 \
3437 blob-examples/ST320410A--3.39 \
3538 blob-examples/ST9160821AS--3.CLH \
39 blob-examples/ST9100821AS--3.CME \
3640 blob-examples/TOSHIBA_MK1651GSY--38IGT0G5T \
3741 blob-examples/WDC_WD2500JB--00REA0-20.00K20 \
3842 blob-examples/WDC_WD2500JS-75NCB3--10.02E04 \
331331 blob-examples/README \
332332 blob-examples/FUJITSU_MHY2120BH--0084000D \
333333 blob-examples/FUJITSU_MHY2120BH--0085000B \
334 blob-examples/FUJITSU_MHY2120BH--0085000B \
334 blob-examples/FUJITSU_MHY2250BH--0085000B \
335335 blob-examples/FUJITSU_MHZ2160BH_G1--0084000A \
336336 blob-examples/INTEL_SSDSA2MH080G1GC--045C8820 \
337337 blob-examples/Maxtor_96147H8--BAC51KJ0 \
338338 blob-examples/Maxtor_96147H8--BAC51KJ0--2 \
339 blob-examples/MCCOE64GEMPP--2.9.09 \
339340 blob-examples/SAMSUNG_HD501LJ--CR100-12 \
341 blob-examples/SAMSUNG_MMCQE28G8MUP--0VA_VAM08L1Q \
342 blob-examples/SAMSUNG_MP0804H--UE100-14 \
340343 blob-examples/ST320410A--3.39 \
341344 blob-examples/ST9160821AS--3.CLH \
345 blob-examples/ST9100821AS--3.CME \
342346 blob-examples/TOSHIBA_MK1651GSY--38IGT0G5T \
343347 blob-examples/WDC_WD2500JB--00REA0-20.00K20 \
344348 blob-examples/WDC_WD2500JS-75NCB3--10.02E04 \
4848
4949 REQUIREMENTS:
5050 None (except Linux with a GLibc)
51
52 BUGS:
53 http://bugs.freedesktop.org/buglist.cgi?bug_status=__open__&product=libatasmart
107107 uint8_t smart_data[512];
108108 uint8_t smart_thresholds[512];
109109
110 SkBool smart_initialized:1;
111
110112 SkBool identify_valid:1;
111113 SkBool smart_data_valid:1;
112114 SkBool smart_thresholds_valid:1;
147149 #define SK_MSECOND_VALID_MIN 1ULL
148150 #define SK_MSECOND_VALID_SHORT_MAX (60ULL * 60ULL * 1000ULL)
149151 #define SK_MSECOND_VALID_LONG_MAX (30ULL * 365ULL * 24ULL * 60ULL * 60ULL * 1000ULL)
152
153 int init_smart(SkDisk *d);
150154
151155 static const char *disk_type_to_human_string(SkDiskType type) {
152156
817821 int ret;
818822 size_t len = 512;
819823
824 if (init_smart(d) < 0)
825 return -1;
826
820827 if (!disk_smart_is_available(d)) {
821828 errno = ENOTSUP;
822829 return -1;
873880 int sk_disk_smart_status(SkDisk *d, SkBool *good) {
874881 uint16_t cmd[6];
875882 int ret;
883
884 if (init_smart(d) < 0)
885 return -1;
876886
877887 if (!disk_smart_is_available(d)) {
878888 errno = ENOTSUP;
919929 int sk_disk_smart_self_test(SkDisk *d, SkSmartSelfTest test) {
920930 uint16_t cmd[6];
921931 int ret;
932
933 if (init_smart(d) < 0)
934 return -1;
922935
923936 if (!disk_smart_is_available(d)) {
924937 errno = ENOTSUP;
13351348 SK_SMART_QUIRK_9_UNKNOWN = 0x0400,
13361349 SK_SMART_QUIRK_197_UNKNOWN = 0x0800,
13371350 SK_SMART_QUIRK_198_UNKNOWN = 0x1000,
1351 SK_SMART_QUIRK_190_UNKNOWN = 0x2000
13381352 } SkSmartQuirk;
13391353
13401354 /* %STRINGPOOLSTART% */
13521366 "9_UNKNOWN",
13531367 "197_UNKNOWN",
13541368 "198_UNKNOWN",
1369 "190_UNKNOWN",
13551370 NULL
13561371 };
13571372 /* %STRINGPOOLSTOP% */
14961511 "^MBZOC60P$",
14971512 SK_SMART_QUIRK_5_UNKNOWN
14981513 }, {
1514
1515 /*** Apple SSD (?) http://bugs.freedesktop.org/show_bug.cgi?id=24700 */
1516 "^MCCOE64GEMPP$",
1517 "^2.9.09$",
1518 SK_SMART_QUIRK_5_UNKNOWN|
1519 SK_SMART_QUIRK_190_UNKNOWN
1520 }, {
14991521 NULL,
15001522 NULL,
15011523 0
16061628 } else if (quirk & SK_SMART_QUIRK_9_UNKNOWN)
16071629 return NULL;
16081630 /* %STRINGPOOLSTOP% */
1631
1632 break;
1633
1634 case 190:
1635 if (quirk & SK_SMART_QUIRK_190_UNKNOWN)
1636 return NULL;
16091637
16101638 break;
16111639
25192547 return r;
25202548 }
25212549
2550 int init_smart(SkDisk *d) {
2551 /* We don't do the SMART initialization right-away, since some
2552 * drivers spin up when we do that */
2553
2554 int ret;
2555
2556 if (d->smart_initialized)
2557 return 0;
2558
2559 d->smart_initialized = TRUE;
2560
2561 /* Check if driver can do SMART, and enable if necessary */
2562 if (!disk_smart_is_available(d))
2563 return 0;
2564
2565 if (!disk_smart_is_enabled(d)) {
2566 if ((ret = disk_smart_enable(d, TRUE)) < 0)
2567 goto fail;
2568
2569 if ((ret = disk_identify_device(d)) < 0)
2570 goto fail;
2571
2572 if (!disk_smart_is_enabled(d)) {
2573 errno = EIO;
2574 ret = -1;
2575 goto fail;
2576 }
2577 }
2578
2579 disk_smart_read_thresholds(d);
2580
2581 fail:
2582 return ret;
2583 }
2584
25222585 int sk_disk_open(const char *name, SkDisk **_d) {
25232586 SkDisk *d;
25242587 int ret = -1;
25932656 d->type = SK_DISK_TYPE_NONE;
25942657 } else
25952658 disk_identify_device(d);
2596
2597 /* Check if driver can do SMART, and enable if necessary */
2598 if (disk_smart_is_available(d)) {
2599
2600 if (!disk_smart_is_enabled(d)) {
2601 if ((ret = disk_smart_enable(d, TRUE)) < 0)
2602 goto fail;
2603
2604 if ((ret = disk_identify_device(d)) < 0)
2605 goto fail;
2606
2607 if (!disk_smart_is_enabled(d)) {
2608 errno = EIO;
2609 ret = -1;
2610 goto fail;
2611 }
2612 }
2613
2614 disk_smart_read_thresholds(d);
2615 }
26162659 }
26172660
26182661 *_d = d;
26502693 size =
26512694 (d->identify_valid ? 8 + sizeof(d->identify) : 0) +
26522695 (d->smart_data_valid ? 8 + sizeof(d->smart_data) : 0) +
2653 (d->smart_thresholds ? 8 + sizeof(d->smart_thresholds) : 0);
2696 (d->smart_thresholds_valid ? 8 + sizeof(d->smart_thresholds) : 0);
26542697
26552698 if (sk_disk_smart_status(d, &good) >= 0) {
26562699 size += 12;
0 /* Saved 113 relocations, saved 2 strings (19 b) due to suffix compression. */
0 /* Saved 114 relocations, saved 2 strings (19 b) due to suffix compression. */
11 static const char _strpool_[] =
22 "16 Byte SCSI ATA SAT Passthru\0"
33 "12 Byte SCSI ATA SAT Passthru\0"
9797 "9_UNKNOWN\0"
9898 "197_UNKNOWN\0"
9999 "198_UNKNOWN\0"
100 "190_UNKNOWN\0"
100101 "power-on-minutes\0"
101102 "power-on-seconds\0"
102103 "power-on-half-minutes\0"
233234 uint8_t smart_data[512];
234235 uint8_t smart_thresholds[512];
235236
237 SkBool smart_initialized:1;
238
236239 SkBool identify_valid:1;
237240 SkBool smart_data_valid:1;
238241 SkBool smart_thresholds_valid:1;
273276 #define SK_MSECOND_VALID_MIN 1ULL
274277 #define SK_MSECOND_VALID_SHORT_MAX (60ULL * 60ULL * 1000ULL)
275278 #define SK_MSECOND_VALID_LONG_MAX (30ULL * 365ULL * 24ULL * 60ULL * 60ULL * 1000ULL)
279
280 int init_smart(SkDisk *d);
276281
277282 static const char *disk_type_to_human_string(SkDiskType type) {
278283
943948 int ret;
944949 size_t len = 512;
945950
951 if (init_smart(d) < 0)
952 return -1;
953
946954 if (!disk_smart_is_available(d)) {
947955 errno = ENOTSUP;
948956 return -1;
9991007 int sk_disk_smart_status(SkDisk *d, SkBool *good) {
10001008 uint16_t cmd[6];
10011009 int ret;
1010
1011 if (init_smart(d) < 0)
1012 return -1;
10021013
10031014 if (!disk_smart_is_available(d)) {
10041015 errno = ENOTSUP;
10451056 int sk_disk_smart_self_test(SkDisk *d, SkSmartSelfTest test) {
10461057 uint16_t cmd[6];
10471058 int ret;
1059
1060 if (init_smart(d) < 0)
1061 return -1;
10481062
10491063 if (!disk_smart_is_available(d)) {
10501064 errno = ENOTSUP;
14611475 SK_SMART_QUIRK_9_UNKNOWN = 0x0400,
14621476 SK_SMART_QUIRK_197_UNKNOWN = 0x0800,
14631477 SK_SMART_QUIRK_198_UNKNOWN = 0x1000,
1478 SK_SMART_QUIRK_190_UNKNOWN = 0x2000
14641479 } SkSmartQuirk;
14651480
14661481 /* %STRINGPOOLSTART% */
14781493 ((const char*) 2656),
14791494 ((const char*) 2666),
14801495 ((const char*) 2678),
1496 ((const char*) 2690),
14811497 NULL
14821498 };
14831499 /* %STRINGPOOLSTOP% */
16221638 "^MBZOC60P$",
16231639 SK_SMART_QUIRK_5_UNKNOWN
16241640 }, {
1641
1642 /*** Apple SSD (?) http://bugs.freedesktop.org/show_bug.cgi?id=24700 */
1643 "^MCCOE64GEMPP$",
1644 "^2.9.09$",
1645 SK_SMART_QUIRK_5_UNKNOWN|
1646 SK_SMART_QUIRK_190_UNKNOWN
1647 }, {
16251648 NULL,
16261649 NULL,
16271650 0
17141737 /* %STRINGPOOLSTART% */
17151738 if (quirk & SK_SMART_QUIRK_9_POWERONMINUTES) {
17161739 static const SkSmartAttributeInfo a = {
1717 ((const char*) 2690), SK_SMART_ATTRIBUTE_UNIT_MSECONDS, verify_long_time
1740 ((const char*) 2702), SK_SMART_ATTRIBUTE_UNIT_MSECONDS, verify_long_time
17181741 };
17191742 return &a;
17201743
17211744 } else if (quirk & SK_SMART_QUIRK_9_POWERONSECONDS) {
17221745 static const SkSmartAttributeInfo a = {
1723 ((const char*) 2707), SK_SMART_ATTRIBUTE_UNIT_MSECONDS, verify_long_time
1746 ((const char*) 2719), SK_SMART_ATTRIBUTE_UNIT_MSECONDS, verify_long_time
17241747 };
17251748 return &a;
17261749
17271750 } else if (quirk & SK_SMART_QUIRK_9_POWERONHALFMINUTES) {
17281751 static const SkSmartAttributeInfo a = {
1729 ((const char*) 2724), SK_SMART_ATTRIBUTE_UNIT_MSECONDS, verify_long_time
1752 ((const char*) 2736), SK_SMART_ATTRIBUTE_UNIT_MSECONDS, verify_long_time
17301753 };
17311754 return &a;
17321755 } else if (quirk & SK_SMART_QUIRK_9_UNKNOWN)
17351758
17361759 break;
17371760
1761 case 190:
1762 if (quirk & SK_SMART_QUIRK_190_UNKNOWN)
1763 return NULL;
1764
1765 break;
1766
17381767 case 192:
17391768 /* %STRINGPOOLSTART% */
17401769 if (quirk & SK_SMART_QUIRK_192_EMERGENCYRETRACTCYCLECT) {
17411770 static const SkSmartAttributeInfo a = {
1742 ((const char*) 2746), SK_SMART_ATTRIBUTE_UNIT_NONE, NULL
1771 ((const char*) 2758), SK_SMART_ATTRIBUTE_UNIT_NONE, NULL
17431772 };
17441773 return &a;
17451774 }
17511780 /* %STRINGPOOLSTART% */
17521781 if (quirk & SK_SMART_QUIRK_194_10XCELSIUS) {
17531782 static const SkSmartAttributeInfo a = {
1754 ((const char*) 2776), SK_SMART_ATTRIBUTE_UNIT_MKELVIN, verify_temperature
1783 ((const char*) 2788), SK_SMART_ATTRIBUTE_UNIT_MKELVIN, verify_temperature
17551784 };
17561785 return &a;
17571786 } else if (quirk & SK_SMART_QUIRK_194_UNKNOWN)
17761805 /* %STRINGPOOLSTART% */
17771806 if (quirk & SK_SMART_QUIRK_200_WRITEERRORCOUNT) {
17781807 static const SkSmartAttributeInfo a = {
1779 ((const char*) 2802), SK_SMART_ATTRIBUTE_UNIT_NONE, NULL
1808 ((const char*) 2814), SK_SMART_ATTRIBUTE_UNIT_NONE, NULL
17801809 };
17811810 return &a;
17821811 }
17881817 /* %STRINGPOOLSTART% */
17891818 if (quirk & SK_SMART_QUIRK_201_DETECTEDTACOUNT) {
17901819 static const SkSmartAttributeInfo a = {
1791 ((const char*) 2820), SK_SMART_ATTRIBUTE_UNIT_NONE, NULL
1820 ((const char*) 2832), SK_SMART_ATTRIBUTE_UNIT_NONE, NULL
17921821 };
17931822 return &a;
17941823 }
19832012 const char * const map[] = {
19842013 [SK_SMART_ATTRIBUTE_UNIT_UNKNOWN] = NULL,
19852014 [SK_SMART_ATTRIBUTE_UNIT_NONE] = ((const char*) 30),
1986 [SK_SMART_ATTRIBUTE_UNIT_MSECONDS] = ((const char*) 2838),
1987 [SK_SMART_ATTRIBUTE_UNIT_SECTORS] = ((const char*) 2841),
1988 [SK_SMART_ATTRIBUTE_UNIT_MKELVIN] = ((const char*) 2849)
2015 [SK_SMART_ATTRIBUTE_UNIT_MSECONDS] = ((const char*) 2850),
2016 [SK_SMART_ATTRIBUTE_UNIT_SECTORS] = ((const char*) 2853),
2017 [SK_SMART_ATTRIBUTE_UNIT_MKELVIN] = ((const char*) 2861)
19892018 };
19902019 /* %STRINGPOOLSTOP% */
19912020
21752204
21762205 /* %STRINGPOOLSTART% */
21772206 const char * const map[] = {
2178 [SK_SMART_OVERALL_GOOD] = ((const char*) 2852),
2179 [SK_SMART_OVERALL_BAD_ATTRIBUTE_IN_THE_PAST] = ((const char*) 2857),
2180 [SK_SMART_OVERALL_BAD_SECTOR] = ((const char*) 2883),
2181 [SK_SMART_OVERALL_BAD_ATTRIBUTE_NOW] = ((const char*) 2894),
2182 [SK_SMART_OVERALL_BAD_SECTOR_MANY] = ((const char*) 2912),
2183 [SK_SMART_OVERALL_BAD_STATUS] = ((const char*) 2928),
2207 [SK_SMART_OVERALL_GOOD] = ((const char*) 2864),
2208 [SK_SMART_OVERALL_BAD_ATTRIBUTE_IN_THE_PAST] = ((const char*) 2869),
2209 [SK_SMART_OVERALL_BAD_SECTOR] = ((const char*) 2895),
2210 [SK_SMART_OVERALL_BAD_ATTRIBUTE_NOW] = ((const char*) 2906),
2211 [SK_SMART_OVERALL_BAD_SECTOR_MANY] = ((const char*) 2924),
2212 [SK_SMART_OVERALL_BAD_STATUS] = ((const char*) 2940),
21842213 };
21852214 /* %STRINGPOOLSTOP% */
21862215
26452674 return r;
26462675 }
26472676
2677 int init_smart(SkDisk *d) {
2678 /* We don't do the SMART initialization right-away, since some
2679 * drivers spin up when we do that */
2680
2681 int ret;
2682
2683 if (d->smart_initialized)
2684 return 0;
2685
2686 d->smart_initialized = TRUE;
2687
2688 /* Check if driver can do SMART, and enable if necessary */
2689 if (!disk_smart_is_available(d))
2690 return 0;
2691
2692 if (!disk_smart_is_enabled(d)) {
2693 if ((ret = disk_smart_enable(d, TRUE)) < 0)
2694 goto fail;
2695
2696 if ((ret = disk_identify_device(d)) < 0)
2697 goto fail;
2698
2699 if (!disk_smart_is_enabled(d)) {
2700 errno = EIO;
2701 ret = -1;
2702 goto fail;
2703 }
2704 }
2705
2706 disk_smart_read_thresholds(d);
2707
2708 fail:
2709 return ret;
2710 }
2711
26482712 int sk_disk_open(const char *name, SkDisk **_d) {
26492713 SkDisk *d;
26502714 int ret = -1;
27192783 d->type = SK_DISK_TYPE_NONE;
27202784 } else
27212785 disk_identify_device(d);
2722
2723 /* Check if driver can do SMART, and enable if necessary */
2724 if (disk_smart_is_available(d)) {
2725
2726 if (!disk_smart_is_enabled(d)) {
2727 if ((ret = disk_smart_enable(d, TRUE)) < 0)
2728 goto fail;
2729
2730 if ((ret = disk_identify_device(d)) < 0)
2731 goto fail;
2732
2733 if (!disk_smart_is_enabled(d)) {
2734 errno = EIO;
2735 ret = -1;
2736 goto fail;
2737 }
2738 }
2739
2740 disk_smart_read_thresholds(d);
2741 }
27422786 }
27432787
27442788 *_d = d;
27762820 size =
27772821 (d->identify_valid ? 8 + sizeof(d->identify) : 0) +
27782822 (d->smart_data_valid ? 8 + sizeof(d->smart_data) : 0) +
2779 (d->smart_thresholds ? 8 + sizeof(d->smart_thresholds) : 0);
2823 (d->smart_thresholds_valid ? 8 + sizeof(d->smart_thresholds) : 0);
27802824
27812825 if (sk_disk_smart_status(d, &good) >= 0) {
27822826 size += 12;
00 #! /bin/sh
11 # Guess values for system-dependent variables and create Makefiles.
2 # Generated by GNU Autoconf 2.63 for libatasmart 0.16.
2 # Generated by GNU Autoconf 2.63 for libatasmart 0.17.
33 #
44 # Report bugs to <mzyvongnfzneg (at) 0pointer (dot) net>.
55 #
744744 # Identity of this package.
745745 PACKAGE_NAME='libatasmart'
746746 PACKAGE_TARNAME='libatasmart'
747 PACKAGE_VERSION='0.16'
748 PACKAGE_STRING='libatasmart 0.16'
747 PACKAGE_VERSION='0.17'
748 PACKAGE_STRING='libatasmart 0.17'
749749 PACKAGE_BUGREPORT='mzyvongnfzneg (at) 0pointer (dot) net'
750750
751751 ac_unique_file="atasmart.c"
14881488 # Omit some internal or obsolete options to make the list less imposing.
14891489 # This message is too long to be a string in the A/UX 3.1 sh.
14901490 cat <<_ACEOF
1491 \`configure' configures libatasmart 0.16 to adapt to many kinds of systems.
1491 \`configure' configures libatasmart 0.17 to adapt to many kinds of systems.
14921492
14931493 Usage: $0 [OPTION]... [VAR=VALUE]...
14941494
15581558
15591559 if test -n "$ac_init_help"; then
15601560 case $ac_init_help in
1561 short | recursive ) echo "Configuration of libatasmart 0.16:";;
1561 short | recursive ) echo "Configuration of libatasmart 0.17:";;
15621562 esac
15631563 cat <<\_ACEOF
15641564
16681668 test -n "$ac_init_help" && exit $ac_status
16691669 if $ac_init_version; then
16701670 cat <<\_ACEOF
1671 libatasmart configure 0.16
1671 libatasmart configure 0.17
16721672 generated by GNU Autoconf 2.63
16731673
16741674 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
16821682 This file contains any messages produced by compilers while
16831683 running configure, to aid debugging if configure makes a mistake.
16841684
1685 It was created by libatasmart $as_me 0.16, which was
1685 It was created by libatasmart $as_me 0.17, which was
16861686 generated by GNU Autoconf 2.63. Invocation command line was
16871687
16881688 $ $0 $@
25482548
25492549 # Define the identity of the package.
25502550 PACKAGE='libatasmart'
2551 VERSION='0.16'
2551 VERSION='0.17'
25522552
25532553
25542554 cat >>confdefs.h <<_ACEOF
26732673 PACKAGE_URL=http://git.0pointer.de/?p=libatasmart.git
26742674
26752675
2676 LIBATASMART_VERSION_INFO=4:2:0
2676 LIBATASMART_VERSION_INFO=4:3:0
26772677
26782678
26792679 # Make sure we can run config.sub.
1856218562 # report actual input values of CONFIG_FILES etc. instead of their
1856318563 # values after options handling.
1856418564 ac_log="
18565 This file was extended by libatasmart $as_me 0.16, which was
18565 This file was extended by libatasmart $as_me 0.17, which was
1856618566 generated by GNU Autoconf 2.63. Invocation command line was
1856718567
1856818568 CONFIG_FILES = $CONFIG_FILES
1862518625 _ACEOF
1862618626 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
1862718627 ac_cs_version="\\
18628 libatasmart config.status 0.16
18628 libatasmart config.status 0.17
1862918629 configured by $0, generated by GNU Autoconf 2.63,
1863018630 with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
1863118631
2020
2121 AC_PREREQ(2.63)
2222
23 AC_INIT([libatasmart], 0.16, [mzyvongnfzneg (at) 0pointer (dot) net])
23 AC_INIT([libatasmart], 0.17, [mzyvongnfzneg (at) 0pointer (dot) net])
2424 AC_CONFIG_SRCDIR([atasmart.c])
2525 AC_CONFIG_HEADERS([config.h])
2626 AC_CONFIG_MACRO_DIR(m4)
2929
3030 AC_SUBST(PACKAGE_URL, [http://git.0pointer.de/?p=libatasmart.git])
3131
32 AC_SUBST(LIBATASMART_VERSION_INFO, [4:2:0])
32 AC_SUBST(LIBATASMART_VERSION_INFO, [4:3:0])
3333
3434 AC_CANONICAL_HOST
3535