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


Origin commit data
------------------
Commit: 874b74e8d6
Author: Stefan Seyfried <seife@tuxbox-git.slipkontur.de>
Date: 2010-11-06 (Sat, 06 Nov 2010)
This commit is contained in:
Stefan Seyfried
2010-11-06 22:15:24 +00:00
parent 8828b0362d
commit f20a032e6c

View File

@@ -180,21 +180,21 @@ int CHDDMenuHandler::doMenu ()
int CHDDDestExec::exec(CMenuTarget* /*parent*/, const std::string&) int CHDDDestExec::exec(CMenuTarget* /*parent*/, const std::string&)
{ {
char cmd[100]; 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); if (n < 0)
//FIXME: atm we can have 2 hdd, sata and usb return 0;
snprintf(cmd, sizeof(cmd), "hdparm -S%d /dev/sda >/dev/null 2>/dev/null", g_settings.hdd_sleep);
system(cmd); for (int i = 0; i < n; i++) {
snprintf(cmd, sizeof(cmd), "hdparm -M%d /dev/sda >/dev/null 2>/dev/null", g_settings.hdd_noise); printf("CHDDDestExec: noise %d sleep %d /dev/%s\n",
system(cmd); g_settings.hdd_noise, g_settings.hdd_sleep, namelist[i]->d_name);
snprintf(cmd, sizeof(cmd), "hdparm -S%d /dev/sdb >/dev/null 2>/dev/null", g_settings.hdd_sleep); snprintf(cmd, sizeof(cmd), "hdparm -M%d -S%d /dev/%s >/dev/null 2>/dev/null",
system(cmd); g_settings.hdd_noise, g_settings.hdd_sleep, namelist[i]->d_name);
snprintf(cmd, sizeof(cmd), "hdparm -M%d /dev/sdb >/dev/null 2>/dev/null", g_settings.hdd_noise); system(cmd);
system(cmd); free(namelist[i]);
snprintf(cmd, sizeof(cmd), "hdparm -K /dev/sda >/dev/null 2>/dev/null"); }
system(cmd); free(namelist);
snprintf(cmd, sizeof(cmd), "hdparm -K /dev/sdb >/dev/null 2>/dev/null");
system(cmd);
return 1; return 1;
} }