From b7b166b75ee577764936e868eb2716bcb9781bc5 Mon Sep 17 00:00:00 2001 From: corinna Date: Tue, 14 Aug 2007 16:19:13 +0000 Subject: [PATCH] * path.cc (symlink_info::check): In case of ERROR_SHARING_VIOLATION and ERROR_ACCESS_DENIED, try to get file attributes by using directory functions. --- winsup/cygwin/ChangeLog | 6 ++++++ winsup/cygwin/path.cc | 19 ++++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 54ae41a945..51f338e215 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,11 @@ 2007-08-14 Corinna Vinschen + * path.cc (symlink_info::check): In case of ERROR_SHARING_VIOLATION and + ERROR_ACCESS_DENIED, try to get file attributes by using directory + functions. + +2007-08-14 Corinna Vinschen + * path.cc (fs_info::update): Correctly handle the volume root directory. 2007-08-14 Corinna Vinschen diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index 88747dbd9e..b616a101dc 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))) -- 2.11.0