diff options
author | Christopher Faylor <cgf@redhat.com> | 2003-09-14 01:35:37 +0000 |
---|---|---|
committer | Christopher Faylor <cgf@redhat.com> | 2003-09-14 01:35:37 +0000 |
commit | 5fde1453082cc2c308748a08cc531f8e9b7a10e1 (patch) | |
tree | 961bffc8ffb47e8741cbf43750d5fd53bbd26303 | |
parent | e110d2668a3cb21ede13338d5e87364685a74ab4 (diff) | |
download | gdb-5fde1453082cc2c308748a08cc531f8e9b7a10e1.tar.gz |
merge from trunk
-rw-r--r-- | winsup/cygwin/ChangeLog | 73 | ||||
-rw-r--r-- | winsup/cygwin/ChangeLog.branch | 4 | ||||
-rw-r--r-- | winsup/cygwin/dcrt0.cc | 3 | ||||
-rw-r--r-- | winsup/cygwin/dir.cc | 9 | ||||
-rw-r--r-- | winsup/cygwin/exceptions.cc | 15 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_disk_file.cc | 81 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_socket.cc | 1 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_tty.cc | 10 | ||||
-rw-r--r-- | winsup/cygwin/include/cygwin/version.h | 2 | ||||
-rw-r--r-- | winsup/cygwin/include/sys/cygwin.h | 2 | ||||
-rw-r--r-- | winsup/cygwin/net.cc | 2 | ||||
-rw-r--r-- | winsup/cygwin/path.cc | 11 | ||||
-rw-r--r-- | winsup/cygwin/path.h | 1 | ||||
-rw-r--r-- | winsup/cygwin/pinfo.cc | 9 | ||||
-rw-r--r-- | winsup/cygwin/shared.cc | 2 | ||||
-rw-r--r-- | winsup/cygwin/signal.cc | 2 | ||||
-rw-r--r-- | winsup/cygwin/syscalls.cc | 4 | ||||
-rw-r--r-- | winsup/cygwin/thread.cc | 4 | ||||
-rw-r--r-- | winsup/cygwin/winsup.h | 3 |
19 files changed, 175 insertions, 63 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 6522e5124a7..7a10e0792a5 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,76 @@ +2003-09-13 Christopher Faylor <cgf@redhat.com> + + * fhandler_disk_file.cc (path_conv::ndisk_links): Fix potential + off-by-one problem when first file in a directory is a directory. + +2003-09-13 Pierre Humblet <pierre.humblet@ieee.org> + + * include/sys/cygwin.h: Rename PID_UNUSED to PID_MAP_RW. + * pinfo.cc (pinfo_init): Initialize myself->gid. + (pinfo::init): Create the "access" variable, set it appropriately and + use it to specify the requested access. + * exceptions.cc (sig_handle_tty_stop): Add PID_MAP_RW in pinfo parent. + * signal.cc (kill_worker): Ditto for pinfo dest. + * syscalls.cc (setpgid): Ditto for pinfo p. + +2003-09-13 Christopher Faylor <cgf@redhat.com> + + * include/cygwin/version.h: Bump DLL minor number to 5. + +2003-09-12 Christopher Faylor <cgf@redhat.com> + + * thread.cc (MTinterface::fixup_after_fork): Remove code which + potentially overwrote _impure pointer with contents of thread which + invoked fork since this eliminates important information like the + pointer to the atexit queue. + +2003-09-12 Christopher Faylor <cgf@redhat.com> + + * fhandler_disk_file.cc (path_conv::ndisk_links): Fix problem where + search characters overwrote the path instead of being tacked on the + end. + +2003-09-12 Christopher Faylor <cgf@redhat.com> + + * dcrt0.cc (_dll_crt0): Accommodate breaking apart of early_stuff_init. + * exceptions.cc (early_stuff_init): Delete. + (init_console_handler): New function - top half of early_stuff_init. + (init_global_security): New function - bottom half of early_stuff_init. + (sig_handle): Avoid special hExeced test for SIGINT. Just terminate + the captive process. + (signal_exit): Add debugging output. + * fhandler_tty.cc (fhandler_tty_slave::open): Don't allocate a console + if one already seems to exist. Properly initialize ctrl-c handling if + we do allocate a console. + * winsup.h (early_stuff_init): Delete declaration. + (init_console_handler): New declaration. + (init_global_security): New declaration. + +2003-09-11 Christopher Faylor <cgf@redhat.com> + + * fhandler_disk_file.cc (path_conv::ndisk_links): Rename from + num_entries. Accept an argument and calculate any extra links needed + based on missing . and .. entries. + (fhandler_disk_file::fstat_helper): Always call pc->ndisks_links() to + calculate the number of links. + * path.h (path_conv::ndisk_links): Declare. + +2003-09-11 Christopher Faylor <cgf@redhat.com> + + * path.cc (normalize_posix_path): Put check for '//' prefix back to + denote a UNC path. + (slash_unc_prefix_p): Remove vestige of old //c method for accessing + drives. + +2003-09-11 Christopher Faylor <cgf@redhat.com> + + * dir.cc (rmdir): Add more samba workarounds. + +2003-09-11 Corinna Vinschen <corinna@vinschen.de> + + * shared.cc (user_shared_initialize): Revert length attribute for name + variable to be just UNLEN + 1. + 2003-09-10 Pierre Humblet <pierre.humblet@ieee.org> * shared_info.h (shared_info::initialize): Remove argument. diff --git a/winsup/cygwin/ChangeLog.branch b/winsup/cygwin/ChangeLog.branch index 398fbf692af..742c004035f 100644 --- a/winsup/cygwin/ChangeLog.branch +++ b/winsup/cygwin/ChangeLog.branch @@ -1,3 +1,7 @@ +2003-09-13 Christopher Faylor <cgf@redhat.com> + + * fhandler_socket.cc (fhandler_socket::accept): Add debugging output. + 2003-09-09 Christopher Faylor <cgf@redhat.com> * exceptions.cc (set_process_mask): Remove pending_signals setting. diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index 20b2460bb38..16c0c42e063 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -858,7 +858,8 @@ _dll_crt0 () main_environ = user_data->envptr; *main_environ = NULL; - early_stuff_init (); + init_console_handler (); + init_global_security (); if (!DuplicateHandle (GetCurrentProcess (), GetCurrentProcess (), GetCurrentProcess (), &hMainProc, 0, FALSE, DUPLICATE_SAME_ACCESS)) diff --git a/winsup/cygwin/dir.cc b/winsup/cygwin/dir.cc index 36cabbd72dd..247216d3ac6 100644 --- a/winsup/cygwin/dir.cc +++ b/winsup/cygwin/dir.cc @@ -325,12 +325,17 @@ rmdir (const char *dir) SetFileAttributes (real_dir, (DWORD) real_dir & ~FILE_ATTRIBUTE_READONLY); - if (RemoveDirectory (real_dir)) + int rc = RemoveDirectory (real_dir); + DWORD att = GetFileAttributes (real_dir); + + /* Sometimes smb indicates failure when it really succeeds, so check for + this case specifically. */ + if (rc || att == INVALID_FILE_ATTRIBUTES) { /* RemoveDirectory on a samba drive doesn't return an error if the directory can't be removed because it's not empty. Checking for existence afterwards keeps us informed about success. */ - if (GetFileAttributes (real_dir) != INVALID_FILE_ATTRIBUTES) + if (att != INVALID_FILE_ATTRIBUTES) set_errno (ENOTEMPTY); else res = 0; diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index 48699b14d54..88972131647 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -117,12 +117,16 @@ init_exception_handler (exception_list *el) #endif void -early_stuff_init () +init_console_handler () { (void) SetConsoleCtrlHandler (ctrl_c_handler, FALSE); if (!SetConsoleCtrlHandler (ctrl_c_handler, TRUE)) system_printf ("SetConsoleCtrlHandler failed, %E"); +} +void +init_global_security () +{ /* Initialize global security attribute stuff */ sec_none.nLength = sec_none_nih.nLength = @@ -612,7 +616,7 @@ sig_handle_tty_stop (int sig) its list of subprocesses. */ if (my_parent_is_alive ()) { - pinfo parent (myself->ppid); + pinfo parent (myself->ppid, PID_MAP_RW); if (NOTSTATE (parent, PID_NOCLDSTOP)) sig_send (parent, SIGCHLD); } @@ -1024,7 +1028,7 @@ sig_handle (int sig, sigset_t mask) if (handler == (void *) SIG_DFL) { if (sig == SIGCHLD || sig == SIGIO || sig == SIGCONT || sig == SIGWINCH - || sig == SIGURG || (hExeced && sig == SIGINT)) + || sig == SIGURG) { sigproc_printf ("default signal %d ignored", sig); goto done; @@ -1107,7 +1111,10 @@ signal_exit (int rc) user_data->resourcelocks->Init (); if (hExeced) - TerminateProcess (hExeced, rc); + { + sigproc_printf ("terminating captive process"); + TerminateProcess (hExeced, rc); + } sigproc_printf ("about to call do_exit (%x)", rc); (void) SetEvent (signal_arrived); diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc index 93b06061558..3400b9c8fad 100644 --- a/winsup/cygwin/fhandler_disk_file.cc +++ b/winsup/cygwin/fhandler_disk_file.cc @@ -29,41 +29,65 @@ details. */ #define _COMPILING_NEWLIB #include <dirent.h> -/* The fhandler_base stat calls and helpers are actually only - applicable to files on disk. However, they are part of the - base class so that on-disk device files can also access them - as appropriate. */ - -static int __stdcall -num_entries (const char *win32_name) +unsigned __stdcall +path_conv::ndisk_links (DWORD nNumberOfLinks) { - WIN32_FIND_DATA buf; - HANDLE handle; - char buf1[MAX_PATH]; - int count = 0; + if (!isdir () || isremote ()) + return nNumberOfLinks; + + int len = strlen (*this); + char fn[len + 3]; + strcpy (fn, *this); - strcpy (buf1, win32_name); - int len = strlen (buf1); - if (len == 0 || isdirsep (buf1[len - 1])) - strcat (buf1, "*"); + const char *s; + unsigned count; + if (nNumberOfLinks <= 1) + { + s = "/*"; + count = 0; + } else - strcat (buf1, "/*"); /* */ + { + s = "/.."; + count = nNumberOfLinks; + } - handle = FindFirstFileA (buf1, &buf); + if (len == 0 || isdirsep (fn[len - 1])) + strcpy (fn + len, s + 1); + else + strcpy (fn + len, s); + + WIN32_FIND_DATA buf; + HANDLE h = FindFirstFile (fn, &buf); - if (handle == INVALID_HANDLE_VALUE) - return 2; /* 2 is the minimum number of links to a dir, so... */ int saw_dot = 2; - while (FindNextFileA (handle, &buf)) + if (h != INVALID_HANDLE_VALUE) { - if (buf.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) - count++; - if (buf.cFileName[0] == '.' - && (buf.cFileName[1] == '\0' - || (buf.cFileName[1] == '.' && buf.cFileName[2] == '\0'))) + if (nNumberOfLinks > 1) saw_dot--; + else + do + { + if (buf.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) + count++; + if (buf.cFileName[0] == '.' + && (buf.cFileName[1] == '\0' + || (buf.cFileName[1] == '.' && buf.cFileName[2] == '\0'))) + saw_dot--; + } + while (FindNextFileA (h, &buf)); + FindClose (h); + } + + if (nNumberOfLinks > 1) + { + fn[len + 2] = '\0'; + h = FindFirstFile (fn, &buf); + if (h) + saw_dot--; + FindClose (h); } - FindClose (handle); + return count + saw_dot; } @@ -218,10 +242,7 @@ fhandler_base::fstat_helper (struct __stat64 *buf, This is too slow on remote drives, so we do without it. Setting the count to 2 confuses `find (1)' command. So let's try it with `1' as link count. */ - if (pc.isdir () && !pc.isremote () && nNumberOfLinks == 1) - buf->st_nlink = num_entries (pc.get_win32 ()); - else - buf->st_nlink = nNumberOfLinks; + buf->st_nlink = pc.ndisk_links (nNumberOfLinks); /* Assume that if a drive has ACL support it MAY have valid "inodes". It definitely does not have valid inodes if it does not have ACL diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc index 338ce278233..fe2f0564f82 100644 --- a/winsup/cygwin/fhandler_socket.cc +++ b/winsup/cygwin/fhandler_socket.cc @@ -646,6 +646,7 @@ fhandler_socket::accept (struct sockaddr *peer, int *len) } } + debug_printf ("res %d", res); return res; } diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc index 602c6348970..248b3c646fa 100644 --- a/winsup/cygwin/fhandler_tty.cc +++ b/winsup/cygwin/fhandler_tty.cc @@ -555,8 +555,8 @@ fhandler_tty_slave::open (int flags, mode_t) set_output_handle (to_master_local); set_open_status (); - if (fhandler_console::open_fhs++ == 0 && !output_done_event - && wincap.pty_needs_alloc_console ()) + if (fhandler_console::open_fhs++ == 0 && !GetConsoleCP () + && !output_done_event && wincap.pty_needs_alloc_console ()) { BOOL b; HWINSTA h = CreateWindowStation (NULL, 0, GENERIC_READ | GENERIC_WRITE, &sec_none_nih); @@ -567,8 +567,10 @@ fhandler_tty_slave::open (int flags, mode_t) termios_printf ("SetProcessWindowStation %d, %E", b); } b = AllocConsole (); // will cause flashing if workstation - // stuff fails - termios_printf ("%d = AllocConsole ()", b); + // stuff fails + termios_printf ("%d = AllocConsole (), %E", b); + if (b) + init_console_handler (); } termios_printf ("incremented open_fhs %d", fhandler_console::open_fhs); termios_printf ("tty%d opened", get_unit ()); diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h index 1c92343d910..c793983fb4b 100644 --- a/winsup/cygwin/include/cygwin/version.h +++ b/winsup/cygwin/include/cygwin/version.h @@ -42,7 +42,7 @@ details. */ changes to the DLL and is mainly informative in nature. */ #define CYGWIN_VERSION_DLL_MAJOR 1005 -#define CYGWIN_VERSION_DLL_MINOR 4 +#define CYGWIN_VERSION_DLL_MINOR 5 /* Major numbers before CYGWIN_VERSION_DLL_EPOCH are incompatible. */ diff --git a/winsup/cygwin/include/sys/cygwin.h b/winsup/cygwin/include/sys/cygwin.h index 9dd46db16ab..36c3f53b1d6 100644 --- a/winsup/cygwin/include/sys/cygwin.h +++ b/winsup/cygwin/include/sys/cygwin.h @@ -89,7 +89,7 @@ enum PID_ORPHANED = 0x0020, /* Member of an orphaned process group. */ PID_ACTIVE = 0x0040, /* Pid accepts signals. */ PID_CYGPARENT = 0x0080, /* Set if parent was a cygwin app. */ - PID_UNUSED = 0x0100, /* ... */ + PID_MAP_RW = 0x0100, /* Flag to open map rw. */ PID_MYSELF = 0x0200, /* Flag that pid is me. */ PID_NOCLDSTOP = 0x0400, /* Set if no SIGCHLD signal on stop. */ PID_INITIALIZING = 0x0800, /* Set until ready to receive signals. */ diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc index 9d7cc00fdb2..7b09751f6dc 100644 --- a/winsup/cygwin/net.cc +++ b/winsup/cygwin/net.cc @@ -638,7 +638,7 @@ fdsock (cygheap_fdmanip& fd, const device *dev, SOCKET soc) fd->set_io_handle ((HANDLE) soc); fd->set_flags (O_RDWR | O_BINARY); fd->set_r_no_interrupt (winsock2_active); - // CORINNA - needed? // cygheap->fdtab.inc_need_fixup_before (); + cygheap->fdtab.inc_need_fixup_before (); debug_printf ("fd %d, name '%s', soc %p", (int) fd, dev->name, soc); return true; } diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index 79b521bc1f1..d1e31ad9c84 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -207,10 +207,10 @@ normalize_posix_path (const char *src, char *dst) syscall_printf ("src %s", src); - if (isdrive (src)) + if (isdrive (src) || slash_unc_prefix_p (src)) { int err = normalize_win32_path (src, dst); - if (!err && isdrive (dst)) + if (!err) for (char *p = dst; (p = strchr (p, '\\')); p++) *p = '/'; return err; @@ -1082,9 +1082,7 @@ slash_unc_prefix_p (const char *path) char *p = NULL; int ret = (isdirsep (path[0]) && isdirsep (path[1]) - && isalpha (path[2]) - && path[3] != 0 - && !isdirsep (path[3]) + && isalnum (path[2]) && ((p = strpbrk (path + 3, "\\/")) != NULL)); if (!ret || p == NULL) return ret; @@ -3487,7 +3485,8 @@ conv_path_list_buf_size (const char *path_list, bool to_posix) + (nrel * strlen (to_posix ? pc.normalized_path : pc.get_win32 ())) + 100; - cfree (pc.normalized_path); // FIXME - probably should be in a destructor but + if (!pc.normalized_path_size && pc.normalized_path) + cfree (pc.normalized_path); // FIXME - probably should be in a destructor but // it's hard to justify a destructor for the few // places where this is needed return size; diff --git a/winsup/cygwin/path.h b/winsup/cygwin/path.h index 3f4fe34a949..b6ab6cf9f03 100644 --- a/winsup/cygwin/path.h +++ b/winsup/cygwin/path.h @@ -194,6 +194,7 @@ class path_conv return (sizeof (*this) - sizeof (path)) + strlen (path) + 1 + normalized_path_size; } + unsigned __stdcall ndisk_links (DWORD); char *normalized_path; size_t normalized_path_size; void set_normalized_path (const char *) __attribute__ ((regparm (2))); diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc index 61ed29d1588..5409bb21e6b 100644 --- a/winsup/cygwin/pinfo.cc +++ b/winsup/cygwin/pinfo.cc @@ -92,7 +92,7 @@ pinfo_init (char **envp, int envc) myself->pgid = myself->sid = myself->pid; myself->ctty = -1; myself->uid = ILLEGAL_UID; - + myself->gid = UNKNOWN_GID; environ_init (NULL, 0); /* call after myself has been set up */ } @@ -141,6 +141,8 @@ pinfo::init (pid_t n, DWORD flag, HANDLE in_h) } int createit = flag & (PID_IN_USE | PID_EXECED); + DWORD access = FILE_MAP_READ + | (flag & (PID_IN_USE | PID_EXECED | PID_MAP_RW) ? FILE_MAP_WRITE : 0); for (int i = 0; i < 10; i++) { int created; @@ -160,7 +162,7 @@ pinfo::init (pid_t n, DWORD flag, HANDLE in_h) } else if (!createit) { - h = OpenFileMappingA (FILE_MAP_READ | FILE_MAP_WRITE, FALSE, mapname); + h = OpenFileMappingA (access, FALSE, mapname); created = 0; } else @@ -178,8 +180,7 @@ pinfo::init (pid_t n, DWORD flag, HANDLE in_h) return; } - procinfo = (_pinfo *) MapViewOfFileEx (h, FILE_MAP_READ | FILE_MAP_WRITE, - 0, 0, 0, mapaddr); + procinfo = (_pinfo *) MapViewOfFileEx (h, access, 0, 0, 0, mapaddr); ProtectHandle1 (h, pinfo_shared_handle); if ((procinfo->process_state & PID_INITIALIZING) && (flag & PID_NOREDIR) diff --git a/winsup/cygwin/shared.cc b/winsup/cygwin/shared.cc index 0862ef71ae9..eab99904009 100644 --- a/winsup/cygwin/shared.cc +++ b/winsup/cygwin/shared.cc @@ -148,7 +148,7 @@ open_shared (const char *name, int n, HANDLE &shared_h, DWORD size, void user_shared_initialize () { - char name[UNLEN > 127 ? UNLEN + 1 : 128] = ""; + char name[UNLEN + 1] = ""; if (wincap.has_security ()) { diff --git a/winsup/cygwin/signal.cc b/winsup/cygwin/signal.cc index a85e151d988..4e62ed70ab7 100644 --- a/winsup/cygwin/signal.cc +++ b/winsup/cygwin/signal.cc @@ -173,7 +173,7 @@ kill_worker (pid_t pid, int sig) sig_dispatch_pending (); int res = 0; - pinfo dest (pid); + pinfo dest (pid, PID_MAP_RW); BOOL sendSIGCONT; if (!dest) diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index 54116caf7c3..915ce4b67ab 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -1982,7 +1982,7 @@ setpgid (pid_t pid, pid_t pgid) } else { - pinfo p (pid); + pinfo p (pid, PID_MAP_RW); if (!p) { set_errno (ESRCH); @@ -2438,7 +2438,7 @@ chroot (const char *newroot) syscall_printf ("%d = chroot (%s)", ret ? get_errno () : 0, newroot ? newroot : "NULL"); - if (path.normalized_path) + if (!path.normalized_path_size && path.normalized_path) cfree (path.normalized_path); return ret; } diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc index 937406a8a48..a8d59591b57 100644 --- a/winsup/cygwin/thread.cc +++ b/winsup/cygwin/thread.cc @@ -224,10 +224,6 @@ MTinterface::fixup_after_fork (void) /* As long as the signal handling not multithreaded switch reents storage back to _impure_ptr for the mainthread to support fork from threads other than the mainthread */ - struct _reent *reent_old = __getreent (); - - if (reent_old && _impure_ptr != reent_old) - *_impure_ptr = *reent_old; reents._clib = _impure_ptr; reents._winsup = &winsup_reent; winsup_reent._process_logmask = LOG_UPTO (LOG_DEBUG); diff --git a/winsup/cygwin/winsup.h b/winsup/cygwin/winsup.h index 677d498f8c8..7cbc56bf287 100644 --- a/winsup/cygwin/winsup.h +++ b/winsup/cygwin/winsup.h @@ -223,7 +223,8 @@ void __stdcall to_timestruc_t (FILETIME * ptr, timestruc_t * out); void __stdcall time_as_timestruc_t (timestruc_t * out); void __stdcall set_console_title (char *); -void early_stuff_init (); +void init_console_handler (); +void init_global_security (); int __stdcall check_null_str (const char *name) __attribute__ ((regparm(1))); int __stdcall check_null_empty_str (const char *name) __attribute__ ((regparm(1))); |