* configure.in: Use -gstabs+ as compile debug option. This seems to promote

better handling of symbols.
* configure: Regenerate.
* delqueue.cc (delqueue_list::process_queue): Allow ERROR_ACCESS_DENIED to
indicate that a file is being shared under Windows 95.
* syscalls.cc (_unlink): Use full path name.  Take special action for Windows
95.  Assume that an ERROR_ACCESS_DENIED indicates a sharing violation unless
it's on a remote drive.  Punt if there is an ERROR_ACCESS_DENIED on a remote
drive.
This commit is contained in:
Christopher Faylor 2000-05-04 19:46:32 +00:00
parent cf3eb87bef
commit 8e9b0aee25
4 changed files with 42 additions and 25 deletions

View File

@ -1,3 +1,15 @@
Wed May 3 21:54:11 2000 Christopher Faylor <cgf@cygnus.com>
* configure.in: Use -gstabs+ as compile debug option. This seems to
promote better handling of symbols.
* configure: Regenerate.
* delqueue.cc (delqueue_list::process_queue): Allow ERROR_ACCESS_DENIED
to indicate that a file is being shared under Windows 95.
* syscalls.cc (_unlink): Use full path name. Take special action for
Windows 95. Assume that an ERROR_ACCESS_DENIED indicates a sharing
violation unless it's on a remote drive. Punt if there is an
ERROR_ACCESS_DENIED on a remote drive.
Wed May 3 18:07:00 2000 Corinna Vinschen <corinna@vinschen.de> Wed May 3 18:07:00 2000 Corinna Vinschen <corinna@vinschen.de>
* errno.cc (errmap): Map ERROR_BAD_NETPATH to new errno ENOSHARE. * errno.cc (errmap): Map ERROR_BAD_NETPATH to new errno ENOSHARE.

View File

@ -85,7 +85,8 @@ delqueue_list::process_queue ()
{ {
int res = GetLastError (); int res = GetLastError ();
empty = 0; empty = 0;
if (res == ERROR_SHARING_VIOLATION) if (res == ERROR_SHARING_VIOLATION ||
(os_being_run != winNT && res == ERROR_ACCESS_DENIED))
{ {
/* File still inuse, that's ok */ /* File still inuse, that's ok */
syscall_printf ("Still using %s", name[i]); syscall_printf ("Still using %s", name[i]);

View File

@ -45,12 +45,6 @@ details. */
paths. Win32 paths in mount table entries may be UNC paths or paths. Win32 paths in mount table entries may be UNC paths or
standard Win32 paths starting with <drive-letter>: standard Win32 paths starting with <drive-letter>:
In converting from a Win32 to a POSIX pathname, if there is no
mount point that will allow the conversion to take place, a user
mount point will be automatically created under
cygdrive/<drive> and the translation will be redone, this
time successfully.
Text vs Binary issues are not considered here in path style Text vs Binary issues are not considered here in path style
decisions. decisions.

View File

@ -47,7 +47,7 @@ _unlink (const char *ourname)
{ {
int res = -1; int res = -1;
path_conv win32_name (ourname, SYMLINK_NOFOLLOW); path_conv win32_name (ourname, SYMLINK_NOFOLLOW, 1);
if (win32_name.error) if (win32_name.error)
{ {
@ -82,6 +82,9 @@ _unlink (const char *ourname)
break; break;
} }
DWORD lasterr;
lasterr = GetLastError ();
/* FIXME: There's a race here. */ /* FIXME: There's a race here. */
HANDLE h = CreateFile (win32_name, GENERIC_READ, HANDLE h = CreateFile (win32_name, GENERIC_READ,
FILE_SHARE_READ, FILE_SHARE_READ,
@ -91,7 +94,7 @@ _unlink (const char *ourname)
{ {
CloseHandle (h); CloseHandle (h);
syscall_printf ("CreateFile/CloseHandle succeeded"); syscall_printf ("CreateFile/CloseHandle succeeded");
if (i > 0 || GetFileAttributes (win32_name) == (DWORD) -1) if (os_being_run == winNT || GetFileAttributes (win32_name) == (DWORD) -1)
{ {
res = 0; res = 0;
break; break;
@ -99,33 +102,40 @@ _unlink (const char *ourname)
} }
if (i > 0) if (i > 0)
goto err;
res = GetLastError ();
syscall_printf ("couldn't delete file, %E");
/* if access denied, chmod to be writable in case it is not
and try again */
/* FIXME!!! Should check whether ourname is directory or file
and only try again if permissions are not sufficient */
if (res == ERROR_ACCESS_DENIED)
{ {
/* chmod file to be writable here */ DWORD dtype;
if (chmod (win32_name, 0777) == 0) if (os_being_run == winNT || lasterr != ERROR_ACCESS_DENIED)
continue;
else
goto err; goto err;
char root[MAX_PATH];
strcpy (root, win32_name);
dtype = GetDriveType (rootdir (root));
if (dtype & DRIVE_REMOTE)
{
syscall_printf ("access denied on remote drive");
goto err; /* Can't detect this, unfortunately */
} }
lasterr = ERROR_SHARING_VIOLATION;
}
syscall_printf ("i %d, couldn't delete file, %E", i);
/* If we get ERROR_SHARING_VIOLATION, the file may still be open - /* If we get ERROR_SHARING_VIOLATION, the file may still be open -
Windows NT doesn't support deleting a file while it's open. */ Windows NT doesn't support deleting a file while it's open. */
if (res == ERROR_SHARING_VIOLATION) if (lasterr == ERROR_SHARING_VIOLATION)
{ {
cygwin_shared->delqueue.queue_file (win32_name); cygwin_shared->delqueue.queue_file (win32_name);
res = 0; res = 0;
break; break;
} }
/* if access denied, chmod to be writable in case it is not
and try again */
/* FIXME: Should check whether ourname is directory or file
and only try again if permissions are not sufficient */
if (lasterr == ERROR_ACCESS_DENIED && chmod (win32_name, 0777) == 0)
continue;
err: err:
__seterrno (); __seterrno ();
res = -1; res = -1;