From 6e091490bba302f0de73c6e3546f77f78acf6178 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Sun, 28 Apr 2013 22:25:32 +0200 Subject: [PATCH] Adds comment about FILE_FLAG_BACKUP_SEMANTICS use. --- TODO | 11 ----------- mingw.c | 6 +++--- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/TODO b/TODO index 5a1e74bd..8db8c445 100644 --- a/TODO +++ b/TODO @@ -46,17 +46,6 @@ on the error message. See: https://sourceforge.net/projects/snapraid/forums/foru * Support interrupted operations with EINTR. For remote filesystems it could be relevant. -* In Windows to use FILE_FLAG_BACKUP_SEMANTICS we should also get privileges. -See http://www.codeproject.com/Articles/21202/Reparse-Points-in-Vista. -Altought it doesn't seem necessary when used in CreateFile to just open directory. -Anyway, see this snipset found with google: -DWORD access = 0; -DWORD share = FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE; -CreateFile(path1,access,share,NULL,OPEN_EXISTING, - (GetFileAttributes(path1)&FILE_ATTRIBUTE_DIRECTORY)?FILE_FLAG_BACKUP_SEMANTICS:0,NULL); -It seems to use it *exclusively* for directory. -Is it possible that the need of lstat_ex depends on that ? - * In Windows we must be case insensitive, at least for ASCII<128 comparison. For other UTF-8 chars is too complex. diff --git a/mingw.c b/mingw.c index b80bcf64..2609a835 100644 --- a/mingw.c +++ b/mingw.c @@ -648,7 +648,7 @@ int lstat_ex(const char* file, struct windows_stat* st) /* * Open the handle of the file. * - * Use FILE_FLAG_BACKUP_SEMANTICS to open directories and to override the file security checks. + * Use FILE_FLAG_BACKUP_SEMANTICS to open directories (it's just ignored for files). * Use FILE_FLAG_OPEN_REPARSE_POINT to open symbolic links and not the their target. */ h = CreateFileW(convert(file), 0, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT, 0); @@ -690,7 +690,7 @@ int windows_stat(const char* file, struct windows_stat* st) /* * Open the handle of the file. * - * Use FILE_FLAG_BACKUP_SEMANTICS to open directories and to override the file security checks. + * Use FILE_FLAG_BACKUP_SEMANTICS to open directories (it's just ignored for files). */ h = CreateFileW(convert(file), 0, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0); if (h == INVALID_HANDLE_VALUE) { @@ -1015,7 +1015,7 @@ int windows_readlink(const char* file, char* buffer, size_t size) /* * Open the handle of the file. * - * Use FILE_FLAG_BACKUP_SEMANTICS to open directories and to override the file security checks. + * Use FILE_FLAG_BACKUP_SEMANTICS to open directories (it's just ignored for files). * Use FILE_FLAG_OPEN_REPARSE_POINT to open symbolic links and not the their target. */ h = CreateFileW(convert(file), 0, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT, 0);