mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-28 16:01:10 +02:00
system/helpers.cpp: change wakeup_hdd function to use hdd_get_standby/hdd_flush
Origin commit data
------------------
Commit: 10eb8869d6
Author: [CST] Focus <focus.cst@gmail.com>
Date: 2014-02-12 (Wed, 12 Feb 2014)
This commit is contained in:
@@ -79,12 +79,24 @@ bool file_exists(const char *filename)
|
|||||||
|
|
||||||
void wakeup_hdd(const char *hdd_dir)
|
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;
|
std::string wakeup_file = hdd_dir;
|
||||||
wakeup_file += "/.wakeup";
|
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());
|
remove(wakeup_file.c_str());
|
||||||
creat(wakeup_file.c_str(),S_IREAD|S_IWRITE);
|
|
||||||
sync();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//use for script with full path
|
//use for script with full path
|
||||||
|
Reference in New Issue
Block a user