diff --git a/HISTORY b/HISTORY
index 131f0e26..7e22ce1f 100644
--- a/HISTORY
+++ b/HISTORY
@@ -1,7 +1,7 @@
SnapRAID HISTORY
================
-1.10 2012/4
+1.10 2012/6
===========
* If a file is excluded, it prints explicitely which attribute caused the
exclusion.
@@ -9,6 +9,7 @@ SnapRAID HISTORY
to remove the 260 chars limitation.
* Automatically excludes also the temporary copy of content file,
the one with the ".tmp" extension.
+ * Avoid the Windows system to go in automatic sleep mode when running.
1.9 2012/3
==========
diff --git a/Makefile.am b/Makefile.am
index 3a8c868d..26b494cc 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -18,7 +18,8 @@ snapraid_SOURCES = \
raid.c \
selftest.c \
speed.c \
- mingw.c
+ mingw.c \
+ os.c
noinst_HEADERS = \
portable.h \
@@ -45,7 +46,8 @@ noinst_HEADERS = \
cpu.h \
raid.h \
tables.h \
- mingw.h
+ mingw.h \
+ os.h
mktest_SOURCES = \
mktest.c \
diff --git a/TODO b/TODO
index 2f3aaf4f..880cdf29 100644
--- a/TODO
+++ b/TODO
@@ -5,6 +5,20 @@ This is the list of TODO items for SnapRAID.
- v1.10
+* In the repair() function the euristic to detect if we recovered after the sync, can be extended
+to all the subsequent blocks, because we always proceeed in block order during a sync.
+So, if for a block we can detect that we recovered after a sync, also for all the subsequent blocks
+this is true.
+
+* To list all the hardlink in Windows Vista it's possible to use FindFirstFileNameW/FindNextFileNameW
+See: http://blogs.msdn.com/b/oldnewthing/archive/2011/07/20/10188033.aspx
+
+* Support Symlinks also in Windows.
+See: http://www.codeproject.com/Articles/21202/Reparse-Points-in-Vista
+
+* In Windows to use FILE_FLAG_BACKUP_SEMANTICS we should also get privileges.
+See http://www.codeproject.com/Articles/21202/Reparse-Points-in-Vista.
+
* In Autosave, do not save if we are near the termination.
* Allow to filter the files to check/fix based on the drive where they reside.
@@ -59,11 +73,11 @@ http://thread.gmane.org/gmane.linux.raid/34195/focus=34236
* In the content file, for each block store the last time the hash was checked
with both "check" and also "sync".
-It will allow to define a new "check" command checking only aged blocks
+It will allow to define a new "check" command, checking only aged blocks
and skipping recently checked ones.
-This could be problematic for the increased memory occupation, and the need
-to update the content file also in check.
-Maybe a new check command ? Use "refresh" ?
+A good name could be "scrub".
+This could be problematic for the increased memory occupation.
+The check command could be maintaned independent, and not saving the content file.
* Save the content file in compressed .gz format to save space.
diff --git a/os.c b/os.c
new file mode 100644
index 00000000..6a042943
--- /dev/null
+++ b/os.c
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2011 Andrea Mazzoleni
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#include "portable.h"
+
+#include "os.h"
+
+/****************************************************************************/
+/* os */
+
+#ifdef __MINGW32__
+#define WIN32_ES_SYSTEM_REQUIRED 0x00000001L
+#define WIN32_ES_DISPLAY_REQUIRED 0x00000002L
+#define WIN32_ES_USER_PRESENT 0x00000004L
+#define WIN32_ES_AWAYMODE_REQUIRED 0x00000040L
+#define WIN32_ES_CONTINUOUS 0x80000000L
+#endif
+
+void os_init(void)
+{
+#ifdef __MINGW32__
+ HMODULE kernel32 = GetModuleHandle("KERNEL32.DLL");
+ WORD (WINAPI* WIN32_SetThreadExecutionState)(DWORD);
+
+ if (kernel32) {
+ WIN32_SetThreadExecutionState = (void*)GetProcAddress(kernel32, "SetThreadExecutionState");
+ if (WIN32_SetThreadExecutionState) {
+ /* set the thread execution level to avoid sleep */
+ if (WIN32_SetThreadExecutionState(WIN32_ES_CONTINUOUS | WIN32_ES_SYSTEM_REQUIRED | WIN32_ES_AWAYMODE_REQUIRED) == 0) {
+ /* retry with the XP variant */
+ WIN32_SetThreadExecutionState(WIN32_ES_CONTINUOUS | WIN32_ES_SYSTEM_REQUIRED);
+ }
+ }
+ }
+#endif
+}
+
+void os_done(void)
+{
+#ifdef __MINGW32__
+ HMODULE kernel32 = GetModuleHandle("KERNEL32.DLL");
+ WORD (WINAPI* WIN32_SetThreadExecutionState)(DWORD);
+
+ if (kernel32) {
+ WIN32_SetThreadExecutionState = (void*)GetProcAddress(kernel32, "SetThreadExecutionState");
+ if (WIN32_SetThreadExecutionState) {
+ /* restore the normal execution level */
+ WIN32_SetThreadExecutionState(WIN32_ES_CONTINUOUS);
+ }
+ }
+#endif
+}
+
diff --git a/os.h b/os.h
new file mode 100644
index 00000000..87bd730f
--- /dev/null
+++ b/os.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2011 Andrea Mazzoleni
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#ifndef __OS_H
+#define __OS_H
+
+/****************************************************************************/
+/* os */
+
+void os_init(void);
+void os_done(void);
+
+#endif
+
diff --git a/snapraid.c b/snapraid.c
index a793a8e6..6e0f6bb8 100644
--- a/snapraid.c
+++ b/snapraid.c
@@ -22,6 +22,7 @@
#include "elem.h"
#include "state.h"
#include "raid.h"
+#include "os.h"
/****************************************************************************/
/* main */
@@ -140,6 +141,8 @@ int main(int argc, char* argv[])
tommy_list filterlist;
char* e;
+ os_init();
+
/* defaults */
conf = CONF;
verbose = 0;
@@ -342,6 +345,8 @@ int main(int argc, char* argv[])
state_done(&state);
tommy_list_foreach(&filterlist, (tommy_foreach_func*)filter_free);
+ os_done();
+
return EXIT_SUCCESS;
}