Added support for MOVEFILE_WRITE_THROUGH using linux sync syscall. Tested on Arch Linux.
Signed-off-by: Oded Elisha oded123456@gmail.com --- dlls/kernel32/path.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/dlls/kernel32/path.c b/dlls/kernel32/path.c index a389743..81610a2 100644 --- a/dlls/kernel32/path.c +++ b/dlls/kernel32/path.c @@ -1268,6 +1268,9 @@ BOOL WINAPI CopyFileExA(LPCSTR sourceFilename, LPCSTR destFilename, return ret; }
+extern int CDECL wine_server_handle_to_fd( HANDLE handle, unsigned int access, int *unix_fd, + unsigned int *options ); +
/************************************************************************** * MoveFileWithProgressW (KERNEL32.@) @@ -1283,6 +1286,7 @@ BOOL WINAPI MoveFileWithProgressW( LPCWSTR source, LPCWSTR dest, NTSTATUS status; HANDLE source_handle = 0, dest_handle; ANSI_STRING source_unix, dest_unix; + BOOL should_sync = FALSE;
TRACE("(%s,%s,%p,%p,%04x)\n", debugstr_w(source), debugstr_w(dest), fnProgress, param, flag ); @@ -1293,8 +1297,9 @@ BOOL WINAPI MoveFileWithProgressW( LPCWSTR source, LPCWSTR dest, if (!dest) return DeleteFileW( source );
- if (flag & MOVEFILE_WRITE_THROUGH) - FIXME("MOVEFILE_WRITE_THROUGH unimplemented\n"); + if ((flag & MOVEFILE_WRITE_THROUGH) && !(flag & MOVEFILE_DELAY_UNTIL_REBOOT)) { + should_sync = TRUE; + }
/* check if we are allowed to rename the source */
@@ -1404,6 +1409,10 @@ BOOL WINAPI MoveFileWithProgressW( LPCWSTR source, LPCWSTR dest, } }
+ if (should_sync) { + sync(); + } + NtClose( source_handle ); RtlFreeAnsiString( &source_unix ); RtlFreeAnsiString( &dest_unix );
Signed-off-by: Oded Elisha oded123456@gmail.com --- dlls/kernel32/path.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/dlls/kernel32/path.c b/dlls/kernel32/path.c index a389743..81610a2 100644 --- a/dlls/kernel32/path.c +++ b/dlls/kernel32/path.c @@ -1268,6 +1268,9 @@ BOOL WINAPI CopyFileExA(LPCSTR sourceFilename, LPCSTR destFilename, return ret; }
+extern int CDECL wine_server_handle_to_fd( HANDLE handle, unsigned int access, int *unix_fd, + unsigned int *options ); +
/************************************************************************** * MoveFileWithProgressW (KERNEL32.@) @@ -1283,6 +1286,7 @@ BOOL WINAPI MoveFileWithProgressW( LPCWSTR source, LPCWSTR dest, NTSTATUS status; HANDLE source_handle = 0, dest_handle; ANSI_STRING source_unix, dest_unix; + BOOL should_sync = FALSE;
TRACE("(%s,%s,%p,%p,%04x)\n", debugstr_w(source), debugstr_w(dest), fnProgress, param, flag ); @@ -1293,8 +1297,9 @@ BOOL WINAPI MoveFileWithProgressW( LPCWSTR source, LPCWSTR dest, if (!dest) return DeleteFileW( source );
- if (flag & MOVEFILE_WRITE_THROUGH) - FIXME("MOVEFILE_WRITE_THROUGH unimplemented\n"); + if ((flag & MOVEFILE_WRITE_THROUGH) && !(flag & MOVEFILE_DELAY_UNTIL_REBOOT)) { + should_sync = TRUE; + }
/* check if we are allowed to rename the source */
@@ -1404,6 +1409,10 @@ BOOL WINAPI MoveFileWithProgressW( LPCWSTR source, LPCWSTR dest, } }
+ if (should_sync) { + sync(); + } + NtClose( source_handle ); RtlFreeAnsiString( &source_unix ); RtlFreeAnsiString( &dest_unix );
This reverts commit d8480efdb2be9e6d03c1efd3e4978daf35b1ee27.
Signed-off-by: Oded Elisha oded123456@gmail.com --- dlls/kernel32/path.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-)
diff --git a/dlls/kernel32/path.c b/dlls/kernel32/path.c index 81610a2..a389743 100644 --- a/dlls/kernel32/path.c +++ b/dlls/kernel32/path.c @@ -1268,9 +1268,6 @@ BOOL WINAPI CopyFileExA(LPCSTR sourceFilename, LPCSTR destFilename, return ret; }
-extern int CDECL wine_server_handle_to_fd( HANDLE handle, unsigned int access, int *unix_fd, - unsigned int *options ); -
/************************************************************************** * MoveFileWithProgressW (KERNEL32.@) @@ -1286,7 +1283,6 @@ BOOL WINAPI MoveFileWithProgressW( LPCWSTR source, LPCWSTR dest, NTSTATUS status; HANDLE source_handle = 0, dest_handle; ANSI_STRING source_unix, dest_unix; - BOOL should_sync = FALSE;
TRACE("(%s,%s,%p,%p,%04x)\n", debugstr_w(source), debugstr_w(dest), fnProgress, param, flag ); @@ -1297,9 +1293,8 @@ BOOL WINAPI MoveFileWithProgressW( LPCWSTR source, LPCWSTR dest, if (!dest) return DeleteFileW( source );
- if ((flag & MOVEFILE_WRITE_THROUGH) && !(flag & MOVEFILE_DELAY_UNTIL_REBOOT)) { - should_sync = TRUE; - } + if (flag & MOVEFILE_WRITE_THROUGH) + FIXME("MOVEFILE_WRITE_THROUGH unimplemented\n");
/* check if we are allowed to rename the source */
@@ -1409,10 +1404,6 @@ BOOL WINAPI MoveFileWithProgressW( LPCWSTR source, LPCWSTR dest, } }
- if (should_sync) { - sync(); - } - NtClose( source_handle ); RtlFreeAnsiString( &source_unix ); RtlFreeAnsiString( &dest_unix );
Signed-off-by: Oded Elisha oded123456@gmail.com --- dlls/kernel32/path.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/dlls/kernel32/path.c b/dlls/kernel32/path.c index a389743..64e34b7 100644 --- a/dlls/kernel32/path.c +++ b/dlls/kernel32/path.c @@ -1283,6 +1283,7 @@ BOOL WINAPI MoveFileWithProgressW( LPCWSTR source, LPCWSTR dest, NTSTATUS status; HANDLE source_handle = 0, dest_handle; ANSI_STRING source_unix, dest_unix; + BOOL should_sync = FALSE;
TRACE("(%s,%s,%p,%p,%04x)\n", debugstr_w(source), debugstr_w(dest), fnProgress, param, flag ); @@ -1293,8 +1294,9 @@ BOOL WINAPI MoveFileWithProgressW( LPCWSTR source, LPCWSTR dest, if (!dest) return DeleteFileW( source );
- if (flag & MOVEFILE_WRITE_THROUGH) - FIXME("MOVEFILE_WRITE_THROUGH unimplemented\n"); + if ((flag & MOVEFILE_WRITE_THROUGH) && !(flag & MOVEFILE_DELAY_UNTIL_REBOOT)) { + should_sync = TRUE; + }
/* check if we are allowed to rename the source */
@@ -1404,6 +1406,10 @@ BOOL WINAPI MoveFileWithProgressW( LPCWSTR source, LPCWSTR dest, } }
+ if (should_sync) { + sync(); + } + NtClose( source_handle ); RtlFreeAnsiString( &source_unix ); RtlFreeAnsiString( &dest_unix );
Oded Elisha oded123456@gmail.com writes:
@@ -1404,6 +1406,10 @@ BOOL WINAPI MoveFileWithProgressW( LPCWSTR source, LPCWSTR dest, } }
- if (should_sync) {
sync();
- }
That's not the right way to flush a file. You probably want something like FlushFileBuffers.
Maybe fsync()?
See: http://blog.httrack.com/blog/2013/11/15/everything-you-always-wanted-to-know...
sync() is still a couple levels up from where things REALLY get written and buffers released. According to the Internet sync() just schedules writes sometime soon.
On 02/07/2018 01:26 PM, Alexandre Julliard wrote:
Oded Elisha oded123456@gmail.com writes:
@@ -1404,6 +1406,10 @@ BOOL WINAPI MoveFileWithProgressW( LPCWSTR source, LPCWSTR dest, } }
- if (should_sync) {
sync();
- }
That's not the right way to flush a file. You probably want something like FlushFileBuffers.
2018-02-07 20:39 GMT+01:00 George Gonzalez ggonzalez@codeweavers.com:
Maybe fsync()?
The point is that you want to use a Win32 API instead of a POSIX one.
Ah, righto!
One interesting thing from that link, it discusses whether sync() actually writes anything out physically, and whether it guarantees that it's physically on the disk, physically updated in the directory, or maybe one or the other, and whether those are atomic, and is it at the drive, or actually written from the drive internal cache to the permanent parts of the drive, and how does all that relate to network files? So many possible ways to weasel out of a definite and firm sync.
On 02/07/2018 02:53 PM, Matteo Bruni wrote:
2018-02-07 20:39 GMT+01:00 George Gonzalez ggonzalez@codeweavers.com:
Maybe fsync()?
The point is that you want to use a Win32 API instead of a POSIX one.