aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2015-08-31 17:57:08 +0300
committerEli Zaretskii2015-08-31 17:57:08 +0300
commite634dacce7ee3bcb4d8aba9e6ad125b6b875c179 (patch)
treeec36eeae10d003747996a40c9b433e831a75a663 /src
parent5ee3ef8e1867d284be0ff9f654f8bde46e751978 (diff)
downloademacs-e634dacce7ee3bcb4d8aba9e6ad125b6b875c179.tar.gz
emacs-e634dacce7ee3bcb4d8aba9e6ad125b6b875c179.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/w32.c21
1 files changed, 20 insertions, 1 deletions
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)
3826 errno = EACCES; 3826 errno = EACCES;
3827 return -1; 3827 return -1;
3828 } 3828 }
3829 break; 3829 goto check_attrs;
3830 } 3830 }
3831 /* FALLTHROUGH */ 3831 /* FALLTHROUGH */
3832 case ERROR_FILE_NOT_FOUND: 3832 case ERROR_FILE_NOT_FOUND:
@@ -3839,6 +3839,8 @@ faccessat (int dirfd, const char * path, int mode, int flags)
3839 } 3839 }
3840 return -1; 3840 return -1;
3841 } 3841 }
3842
3843 check_attrs:
3842 if ((mode & X_OK) != 0 3844 if ((mode & X_OK) != 0
3843 && !(is_exec (path) || (attributes & FILE_ATTRIBUTE_DIRECTORY) != 0)) 3845 && !(is_exec (path) || (attributes & FILE_ATTRIBUTE_DIRECTORY) != 0))
3844 { 3846 {
@@ -3871,6 +3873,23 @@ w32_accessible_directory_p (const char *dirname, ptrdiff_t dirlen)
3871 bool last_slash = dirlen > 0 && IS_DIRECTORY_SEP (dirname[dirlen - 1]); 3873 bool last_slash = dirlen > 0 && IS_DIRECTORY_SEP (dirname[dirlen - 1]);
3872 HANDLE dh; 3874 HANDLE dh;
3873 3875
3876 /* Network volumes need a different reading method. */
3877 if (is_unc_volume (dirname))
3878 {
3879 void *read_result = NULL;
3880 wchar_t fnw[MAX_PATH];
3881 char fna[MAX_PATH];
3882
3883 dh = open_unc_volume (dirname);
3884 if (dh != INVALID_HANDLE_VALUE)
3885 {
3886 read_result = read_unc_volume (dh, fnw, fna, MAX_PATH);
3887 close_unc_volume (dh);
3888 }
3889 /* Treat empty volumes as accessible. */
3890 return read_result != NULL || GetLastError () == ERROR_NO_MORE_ITEMS;
3891 }
3892
3874 /* Note: map_w32_filename makes sure DIRNAME is not longer than 3893 /* Note: map_w32_filename makes sure DIRNAME is not longer than
3875 MAX_UTF8_PATH. */ 3894 MAX_UTF8_PATH. */
3876 strcpy (pattern, map_w32_filename (dirname, NULL)); 3895 strcpy (pattern, map_w32_filename (dirname, NULL));