system/helpers.cpp: change wakeup_hdd function to use hdd_get_standby/hdd_flush

Origin commit data
------------------
Branch: ni/coolstream
Commit: 10eb8869d6
Author: [CST] Focus <focus.cst@gmail.com>
Date: 2014-02-12 (Wed, 12 Feb 2014)


------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
[CST] Focus
2014-02-12 16:29:57 +04:00
parent b6ad82bf2b
commit 98748d9f51

View File

@@ -79,12 +79,24 @@ bool file_exists(const char *filename)
void wakeup_hdd(const char *hdd_dir)
{
if(!check_dir(hdd_dir)){
if(!check_dir(hdd_dir) && hdd_get_standby(hdd_dir)){
std::string wakeup_file = hdd_dir;
wakeup_file += "/.wakeup";
int fd = open(wakeup_file.c_str(), O_SYNC | O_WRONLY | O_CREAT | O_TRUNC);
if (fd >= 0) {
unsigned char buf[512];
memset(buf, 0xFF, sizeof(buf));
for (int i = 0; i < 20; i++) {
if (write(fd, buf, sizeof(buf)) < 0) {
perror("write to .wakeup");
break;
}
}
fdatasync(fd);
close(fd);
}
hdd_flush(hdd_dir);
remove(wakeup_file.c_str());
creat(wakeup_file.c_str(),S_IREAD|S_IWRITE);
sync();
}
}
//use for script with full path