smart.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #ifndef _SYMON_LIB_SMART_H
  2. #define _SYMON_LIB_SMART_H
  3. #define MAX_SMART_ATTRIBUTES 30
  4. /* The structures below are what the disks send back verbatim. Byte-alignment
  5. * is mandatory here.
  6. */
  7. #pragma pack(1)
  8. struct smart_attribute {
  9. u_int8_t id;
  10. u_int16_t flags;
  11. u_int8_t current;
  12. u_int8_t worst;
  13. u_int8_t raw[6];
  14. u_int8_t res;
  15. };
  16. /* smart_values structure should be 512 = one disk block exactly */
  17. struct smart_values {
  18. u_int16_t rev;
  19. struct smart_attribute attributes[MAX_SMART_ATTRIBUTES];
  20. u_int8_t offline_status;
  21. u_int8_t test_status;
  22. u_int16_t offline_time;
  23. u_int8_t vendor1;
  24. u_int8_t offline_cap;
  25. u_int16_t smart_cap;
  26. u_int8_t errlog_capl;
  27. u_int8_t vendor2;
  28. u_int8_t stest_ctime;
  29. u_int8_t etest_ctime;
  30. u_int8_t ctest_ctime;
  31. u_int8_t res[11];
  32. u_int8_t vendor3[125];
  33. u_int8_t sum;
  34. };
  35. #pragma pack()
  36. #ifndef DISK_BLOCK_LEN
  37. #define DISK_BLOCK_LEN 512
  38. #endif
  39. #define SMART_CYLINDER 0xc24f
  40. #define SMART_TIMEOUT 1000
  41. #define ATA_SMART_READ_VALUES 0xd0
  42. #define ATA_ATTRIBUTE_END 0x00
  43. #define ATA_ATTRIBUTE_READ_ERROR_RATE 0x01
  44. #define ATA_ATTRIBUTE_REALLOCATED_SECTOR_COUNT 0x05
  45. #define ATA_ATTRIBUTE_SPIN_RETRY_COUNT 0x0a
  46. #define ATA_ATTRIBUTE_AIR_FLOW_TEMPERATURE 0xbe
  47. #define ATA_ATTRIBUTE_TEMPERATURE 0xc2
  48. #define ATA_ATTRIBUTE_REALLOCATION_EVENT_COUNT 0xc4
  49. #define ATA_ATTRIBUTE_CURRENT_PENDING_SECTOR_COUNT 0xc5
  50. #define ATA_ATTRIBUTE_UNCORRECTABLE_SECTOR_COUNT 0xc6
  51. #define ATA_ATTRIBUTE_SOFT_READ_ERROR_RATE 0xc9
  52. #define ATA_ATTRIBUTE_G_SENSE_ERROR_RATE 0xdd
  53. #define ATA_ATTRIBUTE_TEMPERATURE2 0xe7
  54. #define ATA_ATTRIBUTE_FREE_FALL_PROTECTION 0xfe
  55. struct smart_report {
  56. int read_error_rate;
  57. int reallocated_sectors;
  58. int spin_retries;
  59. int air_flow_temp;
  60. int temperature;
  61. int reallocations;
  62. int current_pending;
  63. int uncorrectables;
  64. int soft_read_error_rate;
  65. int g_sense_error_rate;
  66. int temperature2;
  67. int free_fall_protection;
  68. };
  69. extern void smart_parse(struct smart_values *ds, struct smart_report *sr);
  70. extern int smart_status(unsigned char low, unsigned char high);
  71. #endif /* _SYMON_LIB_SMART_H */