diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2007-08-14 16:19:13 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2007-08-14 16:19:13 +0000 |
commit | 3b98bacfd6eca3f7bbd4fe2f9d012e9baea1ceea (patch) | |
tree | 02f8c43c1c97abf5e5cbca6264c6ed0f824e1050 /winsup/cygwin/path.cc | |
parent | cb8e4b58f566cbef94e61c1776a14f025c064220 (diff) | |
download | cygnal-3b98bacfd6eca3f7bbd4fe2f9d012e9baea1ceea.tar.gz cygnal-3b98bacfd6eca3f7bbd4fe2f9d012e9baea1ceea.tar.bz2 cygnal-3b98bacfd6eca3f7bbd4fe2f9d012e9baea1ceea.zip |
* path.cc (symlink_info::check): In case of ERROR_SHARING_VIOLATION and
ERROR_ACCESS_DENIED, try to get file attributes by using directory
functions.
Diffstat (limited to 'winsup/cygwin/path.cc')
-rw-r--r-- | winsup/cygwin/path.cc | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index 88747dbd9..b616a101d 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -3518,16 +3518,29 @@ symlink_info::check (char *path, const suffix_info *suffixes, unsigned opt) GetFileAttributes for a non-existant file an a Win9x share, GetLastError returns ERROR_INVALID_FUNCTION. Go figure! Also, GetFileAttributes fails with ERROR_SHARING_VIOLATION - if the file is locked exclusively by another process. + if the file is locked exclusively by another process, or with + ERROR_ACCESS_DENIED if the file exists but the user has no right + to open the file with FILE_READ_ATTRIBUTES. If we don't special handle this here, the file is accidentally treated as non-existant. */ DWORD win_error = GetLastError (); if (win_error == ERROR_INVALID_FUNCTION) win_error = ERROR_FILE_NOT_FOUND; - else if (win_error == ERROR_SHARING_VIOLATION) + else if (win_error == ERROR_SHARING_VIOLATION + || win_error == ERROR_ACCESS_DENIED) { + /* This is easily converted to NT functions at one point, + see fhandler_base::fstat_by_name. */ + WIN32_FIND_DATA data; + HANDLE f = FindFirstFile (suffix.path, &data); + if (f != INVALID_HANDLE_VALUE) + { + FindClose (f); + fileattr = data.dwFileAttributes; + } + else + fileattr = 0; ext_tacked_on = !!*ext_here; - fileattr = 0; goto file_not_symlink; } if (set_error (geterrno_from_win_error (win_error, EACCES))) |