summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <cgf@redhat.com>2003-03-09 18:15:57 +0000
committerChristopher Faylor <cgf@redhat.com>2003-03-09 18:15:57 +0000
commit8bc4e3ad8c3a393ce489fdeba08e811608e80a72 (patch)
treea956969f25f325fcdc29a37bbac3ada0c065b3b9
parent9fa5c93e0ee003c3210bf399426141bfc1310dd5 (diff)
downloadgdb-8bc4e3ad8c3a393ce489fdeba08e811608e80a72.tar.gz
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.
-rw-r--r--winsup/cygwin/ChangeLog24
-rw-r--r--winsup/cygwin/ChangeLog.branch8
-rwxr-xr-xwinsup/cygwin/cygwin-gperf2
-rw-r--r--winsup/cygwin/devices.h3
-rw-r--r--winsup/cygwin/path.cc14
-rwxr-xr-xwinsup/cygwin/rmsym11
-rw-r--r--winsup/cygwin/syscalls.cc36
7 files changed, 74 insertions, 24 deletions
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 <cgf@redhat.com>
+
+ * 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 <corinna@vinschen.de>
+
+ * rmsym: Fix regular expression.
+
+2003-03-09 Christopher Faylor <cgf@redhat.com>
+
+ * Makefile.in: Change from using new-* to cygwin0 for temporary
+ targets.
+
+2003-03-09 Corinna Vinschen <corinna@vinschen.de>
+
+ * rmsym: Fix regular expression.
+
+2003-03-09 Christopher Faylor <cgf@redhat.com>
+
+ * Makefile.in: Change from using new-* to cygwin0 for temporary
+ targets.
+
2003-03-09 Corinna Vinschen <corinna@vinschen.de>
* 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 <cgf@redhat.com>
+
+ * 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 <cgf@redhat.com>
* 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. */