From 8bc4e3ad8c3a393ce489fdeba08e811608e80a72 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Sun, 9 Mar 2003 18:15:57 +0000 Subject: Merge from trunk. * Makefile.in: Explicitly call perl to run cygwin-gperf. * path.cc: Move some device stuff. * cygwin-gperf: Define some device stuff. * devices.h: Declare some device stuff. --- winsup/cygwin/ChangeLog | 24 ++++++++++++++++++++++++ winsup/cygwin/ChangeLog.branch | 8 ++++++++ winsup/cygwin/cygwin-gperf | 2 ++ winsup/cygwin/devices.h | 3 +++ winsup/cygwin/path.cc | 14 ++------------ winsup/cygwin/rmsym | 11 +++++++++++ winsup/cygwin/syscalls.cc | 36 ++++++++++++++++++++++++------------ 7 files changed, 74 insertions(+), 24 deletions(-) create mode 100755 winsup/cygwin/rmsym diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 1d027672022..bd7e2754c75 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,27 @@ +2003-03-09 Christopher Faylor + + * syscalls.cc (unlink): Attempt to be more clever about setting + attributes of file. Only open file in query mode to avoid having to + mess with security stuff for reading. + +2003-03-09 Corinna Vinschen + + * rmsym: Fix regular expression. + +2003-03-09 Christopher Faylor + + * Makefile.in: Change from using new-* to cygwin0 for temporary + targets. + +2003-03-09 Corinna Vinschen + + * rmsym: Fix regular expression. + +2003-03-09 Christopher Faylor + + * Makefile.in: Change from using new-* to cygwin0 for temporary + targets. + 2003-03-09 Corinna Vinschen * include/cygwin/socket.h: Set SOMAXCONN to Winsock2 value. diff --git a/winsup/cygwin/ChangeLog.branch b/winsup/cygwin/ChangeLog.branch index 4b6af364af8..b2ba9c6db2c 100644 --- a/winsup/cygwin/ChangeLog.branch +++ b/winsup/cygwin/ChangeLog.branch @@ -1,3 +1,11 @@ +2003-03-09 Christopher Faylor + + * Makefile.in: Explicitly call perl to run cygwin-gperf. + + * path.cc: Move some device stuff. + * cygwin-gperf: Define some device stuff. + * devices.h: Declare some device stuff. + 2003-03-02 Christopher Faylor * Makefile.in (devicess.cc): Make generation dependent on cygwin-gperf. diff --git a/winsup/cygwin/cygwin-gperf b/winsup/cygwin/cygwin-gperf index 6b830c36bd8..a139e89262d 100755 --- a/winsup/cygwin/cygwin-gperf +++ b/winsup/cygwin/cygwin-gperf @@ -78,6 +78,8 @@ static const device piper_dev_storage = static const device pipew_dev_storage = {"", FH_PIPEW, "", 0, 0, 0, 0}; +static const device dev_fs = + {"", FH_FS, "", 0, 0, 0, 0}; EOF for my $f (sort keys %fh_declare) { $_ .= "const device *$f = $fh_declare{$f};\n"; diff --git a/winsup/cygwin/devices.h b/winsup/cygwin/devices.h index be5b99cf05d..9d743373b28 100644 --- a/winsup/cygwin/devices.h +++ b/winsup/cygwin/devices.h @@ -168,3 +168,6 @@ extern const device *icmp_dev; extern const device *unix_dev; extern const device *stream_dev; extern const device *dgram_dev; +extern const device *proc_dev; +extern const device *cygdrive_dev; +extern const device *fh_dev; diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index 18609976804..786cc7a345f 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -1139,16 +1139,6 @@ set_flags (unsigned *flags, unsigned val) } } -/* CGF FIXME device */ -static const device dev_proc = -{"/proc", FH_PROC, "/proc", 0, 0, 0, 0}; - -static const device dev_cygdrive = -{"/cygdrive", FH_CYGDRIVE, "/cygdrive", 0, 0, 0, 0}; - -static const device dev_fs = -{"", FH_FS, "", 0, 0, 0, 0}; - /* conv_to_win32_path: Ensure src_path is a pure Win32 path and store the result in win32_path. @@ -1255,7 +1245,7 @@ mount_info::conv_to_win32_path (const char *src_path, char *dst, device& dev, MALLOC_CHECK; if (isproc (pathbuf)) { - dev = dev_proc; + dev = *proc_dev; dev.devn = fhandler_proc::get_proc_fhandler (pathbuf); if (dev.devn == FH_BAD) return ENOENT; @@ -1271,7 +1261,7 @@ mount_info::conv_to_win32_path (const char *src_path, char *dst, device& dev, unit = 0; dst[0] = '\0'; if (mount_table->cygdrive_len > 1) - dev = dev_cygdrive; + dev = *cygdrive_dev; } else if (cygdrive_win32_path (pathbuf, dst, unit)) { diff --git a/winsup/cygwin/rmsym b/winsup/cygwin/rmsym new file mode 100755 index 00000000000..428aa9d5064 --- /dev/null +++ b/winsup/cygwin/rmsym @@ -0,0 +1,11 @@ +#!/bin/sh +lib=$1; shift +nm=$1; shift +ar=$1; shift +ranlib=$1; shift +grepit=`echo $* | sed 's/ /\$|__imp__/g'` +[ -n "$grepit" ] && grepit="__imp__$grepit\$" +objs=`$nm $lib | awk -F: '/^d[0-9]*.o:/ {obj=$1} '"/$grepit/"'{print obj}'` +[ -n "$objs" ] || exit 1 +$ar d $lib $objs +$ranlib $lib diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index 3ccfabcdb4c..64f56787e86 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -136,36 +136,48 @@ unlink (const char *ourname) if (!writable_directory (win32_name)) { syscall_printf ("non-writable directory"); + set_errno (EPERM); goto done; } + /* Allow us to delete even if read-only */ SetFileAttributes (win32_name, (DWORD) win32_name & ~(FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM)); /* Attempt to use "delete on close" semantics to handle removing a file which may be open. */ HANDLE h; - h = CreateFile (win32_name, GENERIC_READ, FILE_SHARE_DELETE, &sec_none_nih, + h = CreateFile (win32_name, 0, FILE_SHARE_READ, &sec_none_nih, OPEN_EXISTING, FILE_FLAG_DELETE_ON_CLOSE, 0); - - (void) SetFileAttributes (win32_name, (DWORD) win32_name); - (void) DeleteFile (win32_name); - DWORD lasterr; - lasterr = GetLastError (); if (h != INVALID_HANDLE_VALUE) - CloseHandle (h); - - if (GetFileAttributes (win32_name) == INVALID_FILE_ATTRIBUTES - || (!win32_name.isremote () && wincap.has_delete_on_close ())) { - syscall_printf ("DeleteFile succeeded"); - goto ok; + (void) SetFileAttributes (win32_name, (DWORD) win32_name); + BOOL res = CloseHandle (h); + syscall_printf ("%d = CloseHandle (%p)", res, h); + if (GetFileAttributes (win32_name) == INVALID_FILE_ATTRIBUTES + || (!win32_name.isremote () && wincap.has_delete_on_close ())) + { + syscall_printf ("CreateFile (FILE_FLAG_DELETE_ON_CLOSE) succeeded"); + goto ok; + } + else + { + syscall_printf ("CreateFile (FILE_FLAG_DELETE_ON_CLOSE) failed"); + SetFileAttributes (win32_name, (DWORD) win32_name & ~(FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM)); + } } + + /* Try a delete with attributes reset */ if (DeleteFile (win32_name)) { syscall_printf ("DeleteFile after CreateFile/ClosHandle succeeded"); goto ok; } + DWORD lasterr; + lasterr = GetLastError (); + + (void) SetFileAttributes (win32_name, (DWORD) win32_name); + /* Windows 9x seems to report ERROR_ACCESS_DENIED rather than sharing violation. So, set lasterr to ERROR_SHARING_VIOLATION in this case to simplify tests. */ -- cgit v1.2.1