From 33bbb9d009cd0a17c57516b6681f74a4efbdaf32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Pierre=20Andr=C3=A9?= Date: Tue, 6 Aug 2013 11:44:40 +0200 Subject: [PATCH] Fixed creating a new image file on Windows Creating a new image file (clone or metadata) by ntfsclone failed on Windows, because the file was not opened with the needed flags. --- libntfs-3g/win32_io.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libntfs-3g/win32_io.c b/libntfs-3g/win32_io.c index b7e1cc92..437a3fc7 100644 --- a/libntfs-3g/win32_io.c +++ b/libntfs-3g/win32_io.c @@ -482,7 +482,8 @@ static int ntfs_device_win32_simple_open_file(const char *filename, *handle = CreateFile(filename, ntfs_device_unix_status_flags_to_win32(flags), locking ? 0 : (FILE_SHARE_WRITE | FILE_SHARE_READ), - NULL, OPEN_EXISTING, 0, NULL); + NULL, (flags & O_CREAT ? OPEN_ALWAYS : OPEN_EXISTING), + 0, NULL); if (*handle == INVALID_HANDLE_VALUE) { errno = ntfs_w32error_to_errno(GetLastError()); ntfs_log_trace("CreateFile(%s) failed.\n", filename);