From 874b74e8d6bd08adbc032c6b7c315d787b3bc9d1 Mon Sep 17 00:00:00 2001 From: seife Date: Sat, 6 Nov 2010 22:15:24 +0000 Subject: [PATCH] hdd_menu: apply hdparm on all drives git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@885 e54a6e83-5905-42d5-8d5c-058d10e6a962 --- src/gui/hdd_menu.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/gui/hdd_menu.cpp b/src/gui/hdd_menu.cpp index 12dee8718..ada9d8626 100644 --- a/src/gui/hdd_menu.cpp +++ b/src/gui/hdd_menu.cpp @@ -180,21 +180,21 @@ int CHDDMenuHandler::doMenu () int CHDDDestExec::exec(CMenuTarget* /*parent*/, const std::string&) { char cmd[100]; + struct dirent **namelist; + int n = scandir("/sys/block", &namelist, my_filter, alphasort); - printf("CHDDDestExec: noise %d sleep %d\n", g_settings.hdd_noise, g_settings.hdd_sleep); - //FIXME: atm we can have 2 hdd, sata and usb - snprintf(cmd, sizeof(cmd), "hdparm -S%d /dev/sda >/dev/null 2>/dev/null", g_settings.hdd_sleep); - system(cmd); - snprintf(cmd, sizeof(cmd), "hdparm -M%d /dev/sda >/dev/null 2>/dev/null", g_settings.hdd_noise); - system(cmd); - snprintf(cmd, sizeof(cmd), "hdparm -S%d /dev/sdb >/dev/null 2>/dev/null", g_settings.hdd_sleep); - system(cmd); - snprintf(cmd, sizeof(cmd), "hdparm -M%d /dev/sdb >/dev/null 2>/dev/null", g_settings.hdd_noise); - system(cmd); - snprintf(cmd, sizeof(cmd), "hdparm -K /dev/sda >/dev/null 2>/dev/null"); - system(cmd); - snprintf(cmd, sizeof(cmd), "hdparm -K /dev/sdb >/dev/null 2>/dev/null"); - system(cmd); + if (n < 0) + return 0; + + for (int i = 0; i < n; i++) { + printf("CHDDDestExec: noise %d sleep %d /dev/%s\n", + g_settings.hdd_noise, g_settings.hdd_sleep, namelist[i]->d_name); + snprintf(cmd, sizeof(cmd), "hdparm -M%d -S%d /dev/%s >/dev/null 2>/dev/null", + g_settings.hdd_noise, g_settings.hdd_sleep, namelist[i]->d_name); + system(cmd); + free(namelist[i]); + } + free(namelist); return 1; }