summaryrefslogtreecommitdiff
path: root/apps/debug_menu.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/debug_menu.c')
-rw-r--r--apps/debug_menu.c51
1 files changed, 35 insertions, 16 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index 6676a84d4b..694252a897 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -1510,7 +1510,7 @@ static int disk_callback(int btn, struct gui_synclist *lists)
1510} 1510}
1511 1511
1512#ifdef HAVE_ATA_SMART 1512#ifdef HAVE_ATA_SMART
1513static struct ata_smart_values *smart_data = NULL; 1513static struct ata_smart_values smart_data STORAGE_ALIGN_ATTR;
1514 1514
1515static const char * ata_smart_get_attr_name(unsigned char id) 1515static const char * ata_smart_get_attr_name(unsigned char id)
1516{ 1516{
@@ -1526,20 +1526,24 @@ static const char * ata_smart_get_attr_name(unsigned char id)
1526 case 9: return "Power-On Hours Count"; 1526 case 9: return "Power-On Hours Count";
1527 case 10: return "Spin-Up Retry Count"; 1527 case 10: return "Spin-Up Retry Count";
1528 case 12: return "Power Cycle Count"; 1528 case 12: return "Power Cycle Count";
1529 case 191: return "G-Sense Error Rate";
1529 case 192: return "Power-Off Retract Count"; 1530 case 192: return "Power-Off Retract Count";
1530 case 193: return "Load/Unload Cycle Count"; 1531 case 193: return "Load/Unload Cycle Count";
1531 case 194: return "HDA Temperature"; 1532 case 194: return "HDA Temperature";
1533 case 195: return "Hardware ECC Recovered";
1532 case 196: return "Reallocated Event Count"; 1534 case 196: return "Reallocated Event Count";
1533 case 197: return "Current Pending Sector Count"; 1535 case 197: return "Current Pending Sector Count";
1534 case 198: return "Uncorrectable Sector Count"; 1536 case 198: return "Uncorrectable Sector Count";
1535 case 199: return "UltraDMA CRC Error Count"; 1537 case 199: return "UDMA CRC Error Count";
1538 case 200: return "Write Error Rate";
1539 case 201: return "TA Counter Detected";
1536 case 220: return "Disk Shift"; 1540 case 220: return "Disk Shift";
1537 case 222: return "Loaded Hours"; 1541 case 222: return "Loaded Hours";
1538 case 223: return "Load/Unload Retry Count"; 1542 case 223: return "Load/Unload Retry Count";
1539 case 224: return "Load Friction"; 1543 case 224: return "Load Friction";
1544 case 225: return "Load Cycle Count";
1540 case 226: return "Load-In Time"; 1545 case 226: return "Load-In Time";
1541 case 240: return "Transfer Error Rate"; /* Fujitsu */ 1546 case 240: return "Transfer Error Rate"; /* Fujitsu */
1542 /*case 240: return "Head Flying Hours";*/
1543 default: return "Unknown Attribute"; 1547 default: return "Unknown Attribute";
1544 } 1548 }
1545}; 1549};
@@ -1639,7 +1643,7 @@ static bool ata_smart_dump(void)
1639 fd = creat("/smart_data.bin", 0666); 1643 fd = creat("/smart_data.bin", 0666);
1640 if(fd >= 0) 1644 if(fd >= 0)
1641 { 1645 {
1642 write(fd, smart_data, sizeof(struct ata_smart_values)); 1646 write(fd, &smart_data, sizeof(struct ata_smart_values));
1643 close(fd); 1647 close(fd);
1644 } 1648 }
1645 1649
@@ -1651,7 +1655,7 @@ static bool ata_smart_dump(void)
1651 for (i = 0; i < NUMBER_ATA_SMART_ATTRIBUTES; i++) 1655 for (i = 0; i < NUMBER_ATA_SMART_ATTRIBUTES; i++)
1652 { 1656 {
1653 if (ata_smart_attr_to_string( 1657 if (ata_smart_attr_to_string(
1654 &smart_data->vendor_attributes[i], buf, sizeof(buf))) 1658 &smart_data.vendor_attributes[i], buf, sizeof(buf)))
1655 { 1659 {
1656 write(fd, buf, strlen(buf)); 1660 write(fd, buf, strlen(buf));
1657 write(fd, "\n", 1); 1661 write(fd, "\n", 1);
@@ -1666,32 +1670,47 @@ static bool ata_smart_dump(void)
1666static int ata_smart_callback(int btn, struct gui_synclist *lists) 1670static int ata_smart_callback(int btn, struct gui_synclist *lists)
1667{ 1671{
1668 (void)lists; 1672 (void)lists;
1673 static bool read_done = false;
1669 1674
1670 if (btn == ACTION_STD_CANCEL) 1675 if (btn == ACTION_STD_CANCEL)
1671 { 1676 {
1672 smart_data = NULL; 1677 read_done = false;
1673 return btn; 1678 return btn;
1674 } 1679 }
1675 1680
1676 /* read S.M.A.R.T. data only on first redraw */ 1681 /* read S.M.A.R.T. data only on first redraw */
1677 if (!smart_data) 1682 if (!read_done)
1678 { 1683 {
1679 int i; 1684 int rc;
1680 char buf[SIMPLELIST_MAX_LINELENGTH]; 1685 memset(&smart_data, 0, sizeof(struct ata_smart_values));
1681 smart_data = ata_read_smart(); 1686 rc = ata_read_smart(&smart_data);
1682 simplelist_set_line_count(0); 1687 simplelist_set_line_count(0);
1683 simplelist_addline("Id Name: Current,Worst Raw"); 1688 if (rc == 0)
1684 for (i = 0; i < NUMBER_ATA_SMART_ATTRIBUTES; i++) { 1689 {
1685 if (ata_smart_attr_to_string( 1690 int i;
1686 &smart_data->vendor_attributes[i], buf, sizeof(buf))) 1691 char buf[SIMPLELIST_MAX_LINELENGTH];
1687 simplelist_addline(buf); 1692 simplelist_addline("Id Name: Current,Worst Raw");
1693 for (i = 0; i < NUMBER_ATA_SMART_ATTRIBUTES; i++)
1694 {
1695 if (ata_smart_attr_to_string(
1696 &smart_data.vendor_attributes[i], buf, sizeof(buf)))
1697 {
1698 simplelist_addline(buf);
1699 }
1700 }
1701 }
1702 else
1703 {
1704 simplelist_addline("ATA SMART error: 0x%x", rc);
1688 } 1705 }
1706 read_done = true;
1689 } 1707 }
1690 1708
1691 if (btn == ACTION_STD_CONTEXT) 1709 if (btn == ACTION_STD_CONTEXT)
1692 { 1710 {
1711 splash(0, "Dumping data...");
1693 ata_smart_dump(); 1712 ata_smart_dump();
1694 splashf(HZ, "S.M.A.R.T. data dumped"); 1713 splash(HZ, "SMART data dumped");
1695 } 1714 }
1696 1715
1697 return btn; 1716 return btn;