return target;
}
+/* Return non-zero if FILE's filesystem supports symlinks. */
+bool
+symlinks_supported (const char *file)
+{
+ if (is_windows_9x () != TRUE
+ && get_volume_info (file, NULL)
+ && (volume_info.flags & FILE_SUPPORTS_REPARSE_POINTS) != 0)
+ return true;
+ return false;
+}
+
\f
/* Posix ACL emulation. */
extern int openat (int, const char *, int, int);
extern int fchmodat (int, char const *, mode_t, int);
extern int lchmod (char const *, mode_t);
+extern bool symlinks_supported (const char *);
+
/* Return total and free memory info. */
extern int w32_memory_info (unsigned long long *, unsigned long long *,
if (!file)
return NULL;
+ /* Do not follow symlinks, so that the caller could watch symlink
+ files. */
+ DWORD crflags = FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED;
+ if (symlinks_supported (parent_dir))
+ crflags |= FILE_FLAG_OPEN_REPARSE_POINT;
+
if (w32_unicode_filenames)
{
wchar_t dir_w[MAX_PATH], file_w[MAX_PATH];
processes from deleting files inside
parent_dir. */
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
- NULL, OPEN_EXISTING,
- FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED,
+ NULL, OPEN_EXISTING, crflags,
NULL);
}
else
hdir = CreateFileA (dir_a,
FILE_LIST_DIRECTORY,
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
- NULL, OPEN_EXISTING,
- FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED,
+ NULL, OPEN_EXISTING, crflags,
NULL);
}
if (hdir == INVALID_HANDLE_VALUE)