From e634dacce7ee3bcb4d8aba9e6ad125b6b875c179 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Mon, 31 Aug 2015 17:57:08 +0300 Subject: [PATCH] Fix directory accessibility tests for w32 network volumes * src/w32.c (faccessat): Don't fail with network volumes without a share. (w32_accessible_directory_p): Handle network volumes without a share. --- src/w32.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/w32.c b/src/w32.c index dea8431ed7a..cc55507919c 100644 --- a/src/w32.c +++ b/src/w32.c @@ -3826,7 +3826,7 @@ faccessat (int dirfd, const char * path, int mode, int flags) errno = EACCES; return -1; } - break; + goto check_attrs; } /* FALLTHROUGH */ case ERROR_FILE_NOT_FOUND: @@ -3839,6 +3839,8 @@ faccessat (int dirfd, const char * path, int mode, int flags) } return -1; } + + check_attrs: if ((mode & X_OK) != 0 && !(is_exec (path) || (attributes & FILE_ATTRIBUTE_DIRECTORY) != 0)) { @@ -3871,6 +3873,23 @@ w32_accessible_directory_p (const char *dirname, ptrdiff_t dirlen) bool last_slash = dirlen > 0 && IS_DIRECTORY_SEP (dirname[dirlen - 1]); HANDLE dh; + /* Network volumes need a different reading method. */ + if (is_unc_volume (dirname)) + { + void *read_result = NULL; + wchar_t fnw[MAX_PATH]; + char fna[MAX_PATH]; + + dh = open_unc_volume (dirname); + if (dh != INVALID_HANDLE_VALUE) + { + read_result = read_unc_volume (dh, fnw, fna, MAX_PATH); + close_unc_volume (dh); + } + /* Treat empty volumes as accessible. */ + return read_result != NULL || GetLastError () == ERROR_NO_MORE_ITEMS; + } + /* Note: map_w32_filename makes sure DIRNAME is not longer than MAX_UTF8_PATH. */ strcpy (pattern, map_w32_filename (dirname, NULL)); -- 2.11.4.GIT