Commit Graph

5169 Commits

Author SHA1 Message Date
Corinna Vinschen 0191627a26 * include/sys/cygwin.h: Add new cygwin_getinfo_type
CW_SET_EXTERNAL_TOKEN.
	Add new enum CW_TOKEN_IMPERSONATION, CW_TOKEN_RESTRICTED.
	* cygheap.h (cyguser): New flags ext_token_is_restricted,
	curr_token_is_restricted and setuid_to_restricted.
	* external.cc (cygwin_internal): Add CW_SET_EXTERNAL_TOKEN.
	* sec_auth.cc (set_imp_token): New function.
	(cygwin_set_impersonation_token): Call set_imp_token ().
	* security.h (set_imp_token): New prototype.
	* spawn.cc (spawn_guts): Use CreateProcessAsUserW if restricted token
	was enabled by setuid().  Do not create new window station in this case.
	* syscalls.cc (seteuid32): Add handling of restricted external tokens.
	Set HANDLE_FLAG_INHERIT for primary token.
	(setuid32): Set setuid_to_restricted flag.
	* uinfo.cc (uinfo_init): Do not reimpersonate if restricted token was
	enabled by setuid ().  Initialize user.*_restricted flags.
2009-10-13 10:23:31 +00:00
Eric Blake b8a35083c6 Improve clock_gettime and utimensat resolution.
* hires.h (hires_ms): Change initime_us to initime_ns, with 10x
more resolution.
(hires_ms::nsecs): New prototype.
(hires_ms::usecs, hires_ms::msecs, hires_ms::uptime): Adjust.
* times.cc (systime_ns): New helper function.
(hires_ms::prime): Use it for more resolution.
(hires_ms::usecs): Change to...
(hires_ms::nsecs): ...with more resolution.
(clock_gettime): Use more resolution.
(systime): Rewrite in terms of systime_ns.
(timespec_to_filetime): Rewrite math to reflect true operation.
* fhandler_disk_file.cc (utimens_fs): Use higher resolution.
2009-10-13 02:26:33 +00:00
Corinna Vinschen 2fc007681e * external.cc (cygwin_internal): Return 0 in CW_SET_DOS_FILE_WARNING
and CW_SETERRNO cases.
2009-10-12 19:26:08 +00:00
Corinna Vinschen d358c9e9b0 * fhandler_disk_file.cc (fhandler_disk_file::link): Only append .lnk
if the original device had one, too.  Add comment.

	* fhandler_socket.cc (fhandler_socket::fstat): Always return a size of
	0 on sockets.
2009-10-12 11:57:29 +00:00
Corinna Vinschen 9fa1c6420b * path.cc (tfx_chars): Convert all ASCII control characters except
ASCII NUL as well.  Change layout to make the conversions more clear.
	Add comment.
2009-10-09 11:17:17 +00:00
Corinna Vinschen 1441f6a3d1 * include/cygwin/config.h (DEFAULT_LOCALE): Define as "C.UTF-8". 2009-10-09 08:36:21 +00:00
Christopher Faylor 5391a40c89 * exceptions.cc (_cygtls::signal_exit): There's no need to set signal_arrived
if we're exiting.
2009-10-08 15:56:14 +00:00
Eric Blake 80636211bc * fhandler_disk_file.cc (utimens_fs): Plug fd leak on EINVAL. 2009-10-08 11:13:45 +00:00
Charles Wilson dc4e4aabba Support pseudo-reloc version 2 2009-10-07 15:47:38 +00:00
Corinna Vinschen dfbf36f8db * syscalls.cc (seteuid32): Call set_cygwin_privileges on primary token
as well.
2009-10-07 08:20:49 +00:00
Corinna Vinschen b4311a9067 * fhandler.h (fhandler_pty_master::tcgetpgrp): Declare.
* fhandler_termios.cc (fhandler_termios::tcgetpgrp): Only return
	valid pgid if tty is controlling tty.  Set errno to ENOTTY and
	return -1 otherwise.
	(fhandler_pty_master::tcgetpgrp): New function.  Return 0 for
	master side of pty if it's not the controlling tty of the process.
2009-10-07 07:52:30 +00:00
Charles Wilson c8ee587a8e Add cygwin wrapper for ExitProcess and TerminateProcess. 2009-10-06 21:51:17 +00:00
Christopher Faylor a12518a37c * exceptions.cc: Move global variable sigExeced...
* globals.cc: here.
* pinfo.cc (pinfo::maybe_set_exit_code_from_windows): Remove now unneeded
declaration.
2009-10-06 03:39:38 +00:00
Dave Korn 3772467948 * Makefile.in (CFLAGS): Add -mno-use-libstdc-wrappers. 2009-10-04 17:48:05 +00:00
Corinna Vinschen 960624f47e * syscalls.cc (internal_setlocale): Add comment. 2009-10-04 11:32:07 +00:00
Corinna Vinschen 0ca6c6b802 * dcrt0.cc (dll_crt0_1): Drop calls to setlocale/_setlocale_r. Just
call initial_setlocale from here.
	* syscalls.cc (initial_setlocale): Set internal charset and revert
	application locale to "C".
	(setlocale): Don't set Cygwin's internal charset here.
2009-10-02 14:58:10 +00:00
Christopher Faylor 284c5ea0a5 * dcrt0.cc (dll_crt0_1): Move cxx_malloc reset kluge from here.
(check_sanity_and_sync): to here.
* path.cc (has_dot_last_component): Rewrite to detect some corner cases that
were previously uncaught.
2009-10-02 06:04:57 +00:00
Corinna Vinschen 4180b64df4 * fhandler_console.cc (beep): Move up to avoid forward declaration.
(fhandler_console::read): Just beep on characters invalid in current
	charset.  Add comment.
2009-09-30 09:23:45 +00:00
Eric Blake 1c0909882c * syscalls.cc (rename): Fix regression in rename("dir","d/"). 2009-09-30 02:11:05 +00:00
Corinna Vinschen 4abcdf2717 * fhandler_socket.cc (fhandler_socket::recv_internal): Always call
WSARecv on SOCK_STREAM sockets.
2009-09-29 08:46:29 +00:00
Corinna Vinschen 587b75f7bd * fhandler.h (class dev_console): Constify charset parameter of
str_to_con.
	* fhandler_console.cc (dev_console::con_to_str): Simplify.  Always
	default to the current internal locale.
	(dev_console::get_console_cp): Always use codepage 437 for alternate
	charset.
	(dev_console::str_to_con): Constify charset parameter.
	(fhandler_console::write_normal): Always use codepage 437 for alternate
	charset.  Otherwise always default to the current internal locale.
	Replace ASCII SO with ASCII CAN.
	* strfuncs.cc: Tweka comments according to below changes.
	(sys_cp_wcstombs): Constify charset parameter.  Convert all wchar_t
	values in the Unicode private use area U+F0xx to the singlebyte
	counterpart.  Drop special handling creating ASCII SO sequence from
	U+DCxx value.  Rearrange for performance.  Replace ASCII SO with
	ASCII CAN.
	(sys_cp_mbstowcs): Constify charset parameter.  Replace ASCII SO with
	ASCII CAN.  Drop special case for U+DCxx ASCII SO sequences.  Always
	create a replacement from the Unicode private use area U+F0xx for
	invalid byte values in a multibyte sequence.  Do the same for wchar_t
	values from the U+F0xx range to make them roundtrip safe.
	* wchar.h (sys_cp_wcstombs): Constify charset parameter.
	(sys_cp_mbstowcs): Ditto.
2009-09-28 12:10:32 +00:00
Corinna Vinschen d856640e1c * cygheap.cc (cygheap_init): Default locale.charset to "UTF-8".
* dcrt0.cc (dll_crt0_1): Call setlocale (LC_CTYPE, "") here, just
	before resetting application locale to "C".
	* environ.cc (environ_init): Drop code setting locale here.
	* syscalls.cc (check_codepage): Break out check for required codepage
	from internal_setlocale.
	(internal_setlocale): Just convert CWD and $PATH from old charset to
	new charset and set internal charset.
	(setlocale): Change accordingly.  Don't require LC_ALL or LC_CTYPE to
	store old locale value.  Always call internal_setlocale if charset
	changed due to locale environment changes.
2009-09-28 10:43:49 +00:00
Eric Blake 15e9ecd14a Add fexecve, execvpe.
* exec.cc (fexecve): New function.
* cygwin.din (execvpe, fexecve): Export new fexecve and existing
execvpe.
* include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
* posix.sgml: Mention them.
2009-09-26 21:01:10 +00:00
Eric Blake 52dba6a5c4 Fix some POSIX-compliance bugs in link, rename, mkdir.
* syscalls.cc (link): Delete obsolete comment.  Reject directories
and missing source up front.
(rename): Use correct errno for trailing '.'.  Detect empty
strings.  Allow trailing slash to newpath iff oldpath is
directory.
* dir.cc (mkdir): Reject dangling symlink with trailing slash.
* fhandler_disk_file.cc (fhandler_disk_file::link): Reject
trailing slash.
* fhandler.cc (fhandler_base::link): Match Linux errno.
2009-09-26 15:51:53 +00:00
Eric Blake 2bf78f0928 Provide euidaccess, canonicalize_file_name; fix fchmodat.
* syscalls.cc (fchmodat): lchmod is not yet implemented.
(euidaccess): New function.
* path.cc (realpath): Update comment.
(canonicalize_file_name): New function.
* include/cygwin/stdlib.h (canonicalize_file_name): Declare it.
* include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
* cygwin.din: Export canonicalize_file_name, eaccess, euidaccess.
* posix.sgml: Mention them.
2009-09-25 23:55:00 +00:00
Eric Blake 3dbe243afa Fix faccessat(,0) and access() semantics.
* fhandler.h (fhandler_base::fhaccess): Add parameter.
* security.h (check_file_access, check_registry_access): Likewise.
* security.cc (check_file_access, check_registry_access)
(check_access): Implement new parameter.
* fhandler.cc (fhandler_base::fhaccess): Likewise.
(device_access_denied): Update caller.
* syscalls.cc (access, faccessat): Update callers.
* spawn.cc (find_exec, fixup): Likewise.
2009-09-25 13:44:45 +00:00
Corinna Vinschen 599d462dfa * posix_ipc.cc (mq_open): Avoid closing the same descriptor twice in
case of errors.
	(sem_open): Ditto.
2009-09-24 09:25:35 +00:00
Corinna Vinschen 1c23aff7a3 * kernel32.cc (CreateMutexW): Use correct access mask.
(CreateSemaphoreW): Ditto.
2009-09-24 09:09:45 +00:00
Corinna Vinschen 8e3607fcee * strfuncs.cc (__set_charset_from_codepage): Fetch current ANSI
codepage if cp is 0.
2009-09-23 17:13:55 +00:00
Corinna Vinschen 565d6ede3f Fix typo. 2009-09-23 12:01:42 +00:00
Corinna Vinschen e664429d77 * strfuncs.cc (sys_cp_wcstombs): Convert lone surrogate pair
second halves to unambiguous ASCII SO sequence.  When converting
	chars invalid in current codepage to ASCII SO sequence, make
	sure to check for surrogate pair second half only if ct least
	one wide characters is left.  Decrement nwc if valid second half has
	been converted.
	(sys_cp_mbstowcs): Improve ASCII SO handling.  Never break from loop
	if invalid character has been found.  Recognize ASCII SO sequence
	representing originally invalid mulitbyte char converted into a
	lone surrogate pair second half.  Convert accordingly.
2009-09-23 11:31:00 +00:00
Corinna Vinschen 5e8d7527af * autoload.cc (WSARecv): Define.
* fhandler_socket.cc (fhandler_socket::recv_internal): Call WSARecv
	instead of WSARecvFrom if no name parameter is given.  Explain why.
2009-09-22 14:27:57 +00:00
Eric Blake 74a67d01a5 Make *at functions more like Linux.
* syscalls.cc (faccessat): Fix typo, reject bad flags.
(fchmodat, fchownat, fstatat, utimensat, linkat, unlinkat): Reject
bad flags.
2009-09-22 12:13:53 +00:00
Corinna Vinschen abe6b5a3e2 * strfuncs.cc (sys_cp_mbstowcs): Reset shift state after handling
invalid multibyte sequence.
2009-09-22 09:44:32 +00:00
Corinna Vinschen 4401b147bb * path.cc (symlink_worker): Rework error handling to generate Linux
compatible errno in case of trailing slash in newpath.
2009-09-22 09:24:30 +00:00
Eric Blake 29bca9bb0c Match dup2 and fcntl error values to POSIX.
* dtable.h (OPEN_MAX_MAX): New macro.
* resource.cc (getrlimit) [RLIMIT_NOFILE]: Use it.
* dtable.cc (dtable::extend): Likewise.
* fcntl.cc (fcntl64): Obey POSIX rule with too-large F_DUPFD.
* syscalls.cc (dup2): Likewise.
2009-09-22 04:09:03 +00:00
Eric Blake a7b24e14d7 * ChangeLog-2002: Fix typo.
* ChangeLog-2008: Likewise.
2009-09-22 02:49:15 +00:00
Corinna Vinschen ee42ccd3a2 * cygheap.h (cwdstuff::get_posix): Convert to const inline method just
returning pointer to posix path.
	(cwdstuff::reset_posix): Convert to non-inline method taking a wchar_t
	pointer.
	* path.cc (cwdstuff::set): Revert change from 2009-05-13.  Set posix
	to valid incoming path again.
	(cwdstuff::reset_posix): New implementation setting posix path from
	incoming wchar_t path.  Explain usage.
	(cwdstuff::get_posix): Drop implementation.
	(cwdstuff::get): Drop special case to handle empty posix path.
	* syscalls.cc (internal_setlocale): Store old posix cwd as wide char
	path.  Restore posix cwd using new charset.  Explain why.
2009-09-21 19:29:16 +00:00
Corinna Vinschen 6cabe044dd * fhandler_disk_file.cc (fhandler_disk_file::link): Drop faking hardlink
creation on filesystems not supporting hardlinks.
2009-09-21 10:56:50 +00:00
Christopher Faylor 92c4330f5b * dcrt0.cc (dll_crt0_1): Add another hack to REALLY make sure that cxx_malloc
is always set to the cygwin version.
2009-09-21 02:32:06 +00:00
Christopher Faylor adfbdcdb07 * external.cc (cygwin_internal): Add hack to always reset cxx_malloc to proper
value.
* lib/_cygwin_crt0_common.cc (_cygwin_crt0_common): Relocate wayward comment.
2009-09-21 02:19:31 +00:00
Christopher Faylor 50a8741474 * exceptions.cc (sigpacket::process): Explicitly set thread-specific handler
function to zero to avoid transferring to incorrect location.
(_cygtls::call_signal_handler): Don't transfer to handler if there is no
handler to transfer to.
2009-09-19 15:34:19 +00:00
Christopher Faylor 7b9f3ce02c * exceptions.cc (sigpacket::process): Give sigwait() processing precedence even
when a handler is present.
* syscalls.cc (getpagesize): Change return to 'int'.
2009-09-18 21:27:02 +00:00
Christopher Faylor a7f0112577 * ntea.c (write_ea): Don't abort if not-samba. 2009-09-16 16:23:51 +00:00
Christopher Faylor d984eb88db * select.cc (peek_console): Always check window size when there is ANY keyboard
activity.
2009-09-01 14:25:10 +00:00
Corinna Vinschen 2671595b4a * path.h (INTERIX_SYMLINK_COOKIE): Define.
* path.cc (symlink_info::check_sysfile): Read Interix symlinks as well.
2009-08-26 20:32:35 +00:00
Corinna Vinschen 50bd7b0bb6 * fhandler.cc (fhandler_base::open): Only set R/O attribute if ACLs
are not used.
2009-08-26 19:37:34 +00:00
Corinna Vinschen c177980e75 * mount.cc (fs_info::update): Add comment.
* path.cc (symlink_info::check_reparse_point): Return -1 for volume
	mount points.  Explain why.
	(symlink_info::check): Call fs.update again for volume mount points.
	Explain why.
2009-08-25 11:27:03 +00:00
Corinna Vinschen 11788f8ce0 * globals.cc (ro_u_volume): New R/O unicode string.
* path.cc (symlink_info::check_reparse_point): Fix check for volume
	mount points to work on Vista and later as well.
2009-08-24 11:14:30 +00:00
Christopher Faylor f3b6fef631 * cygwin/strfuncs.cc (__set_charset_from_codepage): Add codepages 20866
(KOI8-R) and 21866 (KOI8-U).

* doc/setup2.sgml (setup-locale-charsetlist): Add KOI8-R and KOI8-U to list of
supported charsets.
2009-08-22 15:01:03 +00:00
Christopher Faylor 6282fe16dd * dll_init.h (has_dtors): New flag.
(run_dtors): New wrapper function which avoids calling dtors more than once.
* dll_init.cc (dll_global_dtors): Use dll.run_dtors wrapper.
(dll_list::detach): Ditto.
(dll_list::alloc): Set has_dtors flag.
2009-08-21 21:32:06 +00:00
Christopher Faylor e41f43a1a6 * fcntl.cc (fcntl64): Detect negative fd as error. 2009-08-21 21:19:45 +00:00
Corinna Vinschen a2c5f4b4e4 * mmap.cc (mmap64): Allocate fh_disk_file on cygheap. Delete
explicitely before returning.
2009-08-21 08:47:59 +00:00
Corinna Vinschen 1c1b04b84c * dtable.cc (build_fh_dev): Take additional bool parameter indicating
whether set_name should be called or not.
	(dtable::dup_worker): Call build_fh_pc with new second parameter set
	to false.  Explain why.  If fhandler's dup failed, delete rather than
	cfree newfh and set newfh to NULL to indicate failure correctly.
	* dtable.h (build_fh_pc): Change declaration according to above change.
	Default set_name parameter to true.
	* mmap.cc (mmap_record::free_fh): Delete rather than cfree fh.
2009-08-20 08:34:21 +00:00
Christopher Faylor 421ba492fa * dtable.cc (dtable::fixup_after_exec): Close any popen'ed file handles here.
* fhandler.h (fhandler_*::ispipe): New function.
(fhandler_base::get_popen_pid): Define virtual function.
(fhandler_*::isdevice): Make const.
(fhandler_*::isfifo): Ditto.
2009-08-18 15:21:47 +00:00
Christopher Faylor 4315703af7 * syscalls.cc (popen): Reorganize slightly for clarity. Fix a comment. 2009-08-18 01:51:35 +00:00
Christopher Faylor d5c44ae231 * syscalls.cc (popen): Rewrite to accommodate situations where stdin, stdout,
or stderr are closed.
2009-08-18 01:40:46 +00:00
Christopher Faylor 28c054b720 * pipe.cc (fhandler_pipe::create_selectable): Add -pipe to default pipe names.
* lib/_cygwin_crt0_common.cc (_cygwin_crt0_common): Use bool/true/false for
what is actually a boolean variable.
2009-08-17 12:45:51 +00:00
Corinna Vinschen 719ffe8792 * fhandler_disk_file.cc (fhandler_disk_file::readdir): Fix length
check for ".." dir.
2009-08-14 18:27:18 +00:00
Corinna Vinschen e684ace44e * fhandler_disk_file.cc (fhandler_disk_file::readdir): Change comment
to be fair.
2009-08-14 14:10:31 +00:00
Corinna Vinschen e575678945 * fhandler_disk_file.cc (fhandler_disk_file::readdir_helper): Remove
ill-advised attempt to optimize "." and ".." handling by checking for
	specific position in directory listing.  Explain why.
	(fhandler_disk_file.cc (fhandler_disk_file::readdir): Ditto.
	Special-case opening file on NFS to fetch inode number and add longish
	comment to explain why.
2009-08-14 13:39:07 +00:00
Corinna Vinschen c1999c4b0c * (fhandler_socket::getsockname): Fix length returned for unbound
AF_LOCAL sockets.
	(fhandler_socket::getpeername): Ditto.
	* net.cc (socketpair): Don't set sun_path and peer_sun_path to
	make sure getsockname and getpeername return the correct values
	for AF_LOCAL sockets.
2009-08-14 06:58:44 +00:00
Corinna Vinschen 95a1cc7024 * fhandler_socket.cc (fhandler_socket::accept): Use sizeof rather
then constant size.  Truncate returned data, but return full address
	length as per POSIX.
	(fhandler_socket::getsockname): Truncate returned data, but return full
	address length as per POSIX.
	(fhandler_socket::getpeername): Ditto.
2009-08-13 15:44:29 +00:00
Corinna Vinschen d3d4aa96aa * fhandler.h (class fhandler_socket): Add peer_sun_path member.
(fhandler_socket::set_peer_sun_path): New method.
	(fhandler_socket::get_peer_sun_path): New method.
	* fhandler_socket.cc (fhandler_socket::fhandler_socket): Initialize
	peer_sun_path to NULL.
	(fhandler_socket::~fhandler_socket): Free peer_sun_path if necessary.
	(fhandler_socket::dup): Duplicate peer_sun_path.
	(fhandler_socket::accept): Ditto.  Return fake unbound peer content
	and len in case of AF_LOCAL sockets.
	(fhandler_socket::getsockname): Always use local sockaddr_storage to
	store socket address and copy over to incoming address.  Handle every
	namelen correctly per POSIX.
	(fhandler_socket::getpeername): Ditto.  Add code path to return
	correct value for AF_LOCAL sockets.
	(fhandler_socket::set_peer_sun_path): New method.
	* net.cc (socketpair): Set peer_sun_path to empty string, just like
	sun_path.
2009-08-13 10:26:42 +00:00
Corinna Vinschen ce5eb135a2 * cxx.cc (default_cygwin_cxx_malloc): Enhance commenting.
* dll_init.cc (dll_dllcrt0_1): Likewise.
	* dlfcn.cc (dlopen): Prevent dlopen()'d DLL from installing any
	cxx malloc overrides.
	* include/cygwin/cygwin_dll.h (__dynamically_loaded): New variable.
	* lib/_cygwin_crt0_common.cc (_cygwin_crt0_common): Check it and only
	install cxx malloc overrides when statically loaded.  Extend comments.
2009-08-13 07:35:50 +00:00
Corinna Vinschen a73a3f438b * fhandler_socket.cc (fhandler_socket::accept): Always use local
sockaddr_storage to store peer address and copy over to incoming
	peer address if available.  Truncate data as necessary according
	to POSIX.
2009-08-12 14:48:16 +00:00
Corinna Vinschen b1ce1770ea * include/limits.h (NGROUPS_MAX): Set to a more sane value.
* include/sys/param.h (NGROUPS): Ditto.
2009-08-11 07:28:22 +00:00
Corinna Vinschen 9043b49e63 * spawn.cc (av::fixup): Check shell scripts for executability only on
filesystems/mounts supporting real permissions.
2009-08-10 18:36:28 +00:00
Corinna Vinschen 019fc8d880 * dtable.cc (DEV_SOCKET): New static WCHAR string. Name of
the native NT socket device.
	(dtable::init_std_file_from_handle): Remove unused tmp_pathbuf
	variable.  Move check for sockets into FILE_TYPE_PIPE clause.
	Rely on handle_to_fn having recognized socket, or check if
	getsockopt works to accommodate NT4 shortcoming.
	(handle_to_fn): Use tmp_pathbuf for OBJECT_NAME_INFORMATION
	buffer and simplify code due to that.  Check name returned by
	NtQueryObject for socket device.
2009-08-10 15:38:37 +00:00
Christopher Faylor 78d959ce6f * fhandler_console.cc (create_invisible_console_workaround): Fix size of cmd in
the way originally intended.
2009-08-10 15:25:58 +00:00
Corinna Vinschen 264ae244af * fhandler_console.cc (create_invisible_console_workaround): Fix
size of cmd to take spaces into account.
2009-08-10 08:54:51 +00:00
Corinna Vinschen 7be107ce24 * dtable.cc (dtable::init_std_file_from_handle): Fix comment to
document change in the Windows 7 workaround.
	* wincap.cc (wincapc::init): Don't set has_console_handle_problem
	to false on 32 bit systems.
2009-08-08 20:24:54 +00:00
Corinna Vinschen 19753e1dbf * net.cc (cygwin_getnameinfo): Force setting NI_NUMERICSERV only
on Windows 2003 and earlier, only if the port number doesn't
	resolve to a well-known service.  Change comment accordingly.
2009-08-06 14:55:49 +00:00
Christopher Faylor a99345591f * cygheap.h (cygheap_debug::endh): Delete.
* debug.cc (lock_debug::acquired): Delete.
(lock_debug::lock_debug): Simplify.
(lock_debug::unlock): Ditto.
(find_handle): Don't set endh here.
(add_handle): Add new handle to beginning of the list rather than trying to
maintain an end list pointer.
(delete_handle): Minor optimization.
(mark_closed): Make logic clearer.
(verify_handle): Lock handle list before scanning.
(setclexec): Ditto.
(modify_handle): Ditto.
(newh): Don't lock handle list here.  Assume caller did this.
(mark_closed): Ditto.
(close_handle): Remove unneeded #if.
* dtable.cc (dtable::dup2): Tweak debug output.
2009-08-05 04:44:27 +00:00
Christopher Faylor 7f01964f06 * path.cc (patch_conv::check): Zero path before setting it. 2009-08-05 03:18:48 +00:00
Christopher Faylor 631681619e * fhandler_socket.cc (fhandler_socket::send_internal): Just use wmem size if
the length exceeds it.
* net.cc (fdsock): Use 65535 as window size, just like the comment says or we
run into problems with DuplicateHandle.
* path.cc (patch_conv::check): Use set_path to set invalid filename.
* path.h (path_conv::path_conv): Ditto.
2009-08-04 22:35:35 +00:00
Christopher Faylor 3b689b97bd * fhandler.h (pdrive_buf): Defensively allocate one extra byte. 2009-08-04 04:31:08 +00:00
Christopher Faylor 824d851859 * fhandler.h (fhandler_cygdrive:DRVSZ): New enum.
(pdrive_buf): New place to hold information about cygdrive.
* fhandler_disk_file.cc (fhandler_cygdrive::set_drives): Store drive info in
pdrive_buf since get_win32_name() could now be too small to hold everything.
(fhandler_cygdrive::rewinddir): Reset pdrive to pdrive_buf.
(fhandler_cygdrive::closedir): Ditto.
* pipe.cc (fhandler_pipe::init): Be more defensive when referencing
get_win32_name().  Rework logic which made a copy of the POSIX path and then
never used it.
2009-08-04 04:20:36 +00:00
Christopher Faylor ff7b364c12 * sigproc.cc (stopped_or_terminated): Don't return a match when stopsig ==
SIGCONT and not WCONTINUED.
* termios.cc (tcsetpgrp): Improve debugging output.
2009-08-02 21:38:40 +00:00
Christopher Faylor fafbf75509 * cygheap_malloc.h: New file.
* cygheap.h: Remove stuff now included in cygheap_malloc.h and include that
file.  Make cygheap_init a standard c++ function.  Remove unneeded child_info
declaration.
* path.h: Include cygheap_malloc.h.  Remove extra cstrdup declaration.
(path_conv): Reorganize to group variables together.
(path_conv::path): Make const char *.
(path_conv::known_suffix): Ditto.
(path_conv::normalized_path): Ditto.
(path_conv::path_conv): Reorganize initializers to reflect new element
ordering.
(path_conv::get_win32): Change return value to const char *.
(path_conv::set_path): Move back here from spawn.cc.
(parh_conv::modifiable_path): New function.
* path.cc (path_conv::add_ext_from_sym): Accommodate const'ness of
known_suffixes.
(path_conv::set_normalized_path): Ditto for normalized_path.
(path_conv::check): Use modifiable_path whereever we need to modify the path
element.  Use set_path to set the path.
(path_conv::~path_conv): Accommodate new const'ness.
* spawn.cc (perhaps_suffix): Declare ext as const since that's what is being
returned.
(path_conv::set_path): Move back to path.h.
* winf.f (linebuf): Perform minor cleanup.
(linebuf::fromargv): Change second parameter to const.
* winf.cc (linebuf::fromargv): Ditto.
2009-08-01 19:52:46 +00:00
Christopher Faylor 8cc84a8ce3 * path.h (path_conv::set_path): Change return value.
* spawn.cc (path_conv::set_path): Return newly set value.
(find_exec): Set retval to newly set value when calling set_path.
2009-08-01 17:55:58 +00:00
Christopher Faylor a3a060b596 * spawn.cc (find_exec): Fix one more path where retval was not set. 2009-08-01 03:36:44 +00:00
Christopher Faylor 5f297dc330 * spawn.cc (find_exec): Stop relying on the ability to set retval to a fixed
path_conv buffer and set it on the fly instead.
2009-08-01 03:27:51 +00:00
Corinna Vinschen eeb6806f87 * path.h (cstrdup): Fix declaration. 2009-07-30 20:19:54 +00:00
Corinna Vinschen 900f20710f * globals.cc (enum exit_states::ES_GLOBAL_DTORS): Delete.
* dcrt0.cc (__main): Schedule dll_global_dtors to run
	atexit before global dtors.
	(do_exit): Delete test for ES_GLOBAL_DTORS and call to
	dll_global_dtors.
2009-07-30 15:48:51 +00:00
Corinna Vinschen 0986989f6a * path.h (class path_conv): Convert path from char array to char *.
Initialize to NULL in constructors.  Drop normalized_path_size member.
	(path_conv::size): Remove.
	(path_conv::operator =): Always copy with sizeof path_conv.  Always
	duplicate path on cygheap.
	(path_conv::set_path): Move implementation to spawn.cc.
	* path.cc (path_conv::set_normalized_path): Always allocate
	normalized_path on cygheap.
	(path_conv::check): Don't work on path, rather allocate THIS_path in
	TLS and use it throughout.  When finished, allocate path on cygheap
	and copy over.  Defer tacking on extension after having copied path.
	* spawn.cc (path_conv::set_path): Implement here.
2009-07-30 08:56:57 +00:00
Corinna Vinschen 8d641a5b46 * mount.h (enum fs_info_type): New type.
(IMPLEMENT_FS_FLAG): New define.
	(class fs_info): Convert filesystem type status flags into an enum
	fs_info_type.  Add cifs FS.  Revert change to has_buggy_open and
	has_buggy_fileid_dirinfo.  Make them normal; status flags again.
	Implement is_FS functions using IMPLEMENT_FS_FLAG.
	* mount.cc (fs_info::update): Define MINIMAL_WIN_NTFS_FLAGS and
	FS_IS_WINDOWS_NTFS.  Add comment.  Only test remote filesystems
	for "NTFS" once.  Add is_cifs check using FS_IS_WINDOWS_NTFS.
	Set has_buggy_open flag for SUNWNFS.  Set has_buggy_fileid_dirinfo
	flag for UNIXFS and all cifs type filesystems.  Only check for
	caseinsensitivity once.
	(fillout_mntent): Create locale fs_names array.  Use for setting
	_my_tls.locals.mnt_type.
2009-07-28 10:39:55 +00:00
Corinna Vinschen 8171ddb73f * posix.sgml (std-notes): Remove obsolete reference to CYGWIN=server. 2009-07-27 08:05:47 +00:00
Corinna Vinschen 4d670aabf6 * posix.sgml (std-notes): Add flock restriction. 2009-07-26 09:34:35 +00:00
Corinna Vinschen 6359951b47 * fhandler_console.cc (set_console_title): Set buffer size to
TITLESIZE + 1.  Call sys_mbstowcs with correct destination length.
2009-07-25 08:27:10 +00:00
Christopher Faylor 43c23d4b82 * sigproc.h (wait_for_sigthread): Eliminate parameter.
* sigproc.cc (wait_for_sigthread): Ditto.  Don't synchronize with wait_sig
after receiving an event that it is ready to go.
(init_sig_pipe): New function.
(wait_sig): Call init_sig_pipe to create pipes for communicating signals to
this process.  Don't send sigCONT signal when initializing.
* fork.cc (frok::child): Accommodate wait_for_sigpipe parameter change.
* fhandler.h (fhandler_*::write): Make ssize_t/__stdcall.
(fhandler_*::write_overlapped): Ditto.
(fhandler_*::raw_write): Ditto.
(fhandler_*::readv): Ditto.
(fhandler_*::writev): Ditto.
(fhandler_*::raw_read): Make __stdcall.
* fhandler: Accommodate changes to read/write functions throughout.
* fhandler_clipboard.cc: Ditto.
* fhandler_console.cc: Ditto.
* fhandler_dsp.cc: Ditto.
* fhandler_fifo.cc: Ditto.
* fhandler_mailslot.cc: Ditto.
* fhandler_mem.cc: Ditto.
* fhandler_mem.cc: Ditto.
* fhandler_random.cc: Ditto.
* fhandler_tape.cc: Ditto.
* fhandler_tty.cc: Ditto.
* fhandler_virtual.cc: Ditto.
* fhandler_windows.cc: Ditto.
* fhandler_zero.cc: Ditto.
* syscalls.cc (readv): Use ssize_t as temp variable.
* fhandler.cc (fhandler_base::read): Coerce returned len to signed or it will
never be treated as < 0.
(fhandler_base::wait_overlapped): Minimize calls to GetLastError.  Remove
duplicate debugging test.  Fix error return.
* fhandler.h (fhandler_fifo::fifo_name): Declare new function.
(fhandler_fifo::close): Ditto.
(fhandler_fifo::dup): Ditto.
(fhandler_fifo::close_on_exec): Ditto.
* fhandler.cc (fhandler_fifo::fifo_name): Define new function.
(FIFO_BUF_SIZE): New define.
(cnp): Ditto.
(fhandler_fifo::open): Rework.  Use cnp to open named pipe.  Always open write
side as a client.  Open dummy client when writing and can't connect.
(wait): Rework.  Implement fifo_wait_for_next_client.  Handle signals during
connect better.  Add new fifo_wait_for_server code which polls
(sigh) waiting for server.
(fhandler_fifo::raw_read): Handle transition states when one client closes and
another is available.
(fhandler_fifo::close): Define.
(fhandler_fifo::dup): Ditto.
(fhandler_fifo::close_on_exec): Ditto.
2009-07-24 20:54:33 +00:00
Corinna Vinschen f8cb4b4916 * syscalls.cc (internal_setlocale): Fix typo in GBK codepage. 2009-07-24 18:24:57 +00:00
Corinna Vinschen 92d816d492 * syscalls.cc (unlink_nt): Ignore sharing violation on NFS. Align
comments.
2009-07-24 14:13:44 +00:00
Corinna Vinschen a6131454a5 * mount.h (fs_info::fsn): New member.
(fs_info::clear): Clear fsn.
	(fs_info::fsname): New read accessor for fsn.
	* mount.cc (fs_info::update): Fill in fsn member with lowercased
	filesystem name if filesystem is not well-known.  Fall back to
	"unknown" if filesystem name is missing.
	(fillout_mntent): Print filesystem name retrieved in fs_info::update
	rather than static string "unknown".
2009-07-23 11:46:06 +00:00
Corinna Vinschen 4a77fa092c * mount.cc (fs_info::update): Revert to open filesystem with access set
to READ_CONTROL.  If that fails, try additionally with FILE_READ_DATA.
2009-07-23 07:51:55 +00:00
Eric Blake 3f6f9155c9 * exceptions.cc (handle_exceptions): Set si_addr according to
POSIX for SIGSEGV.
2009-07-23 02:47:17 +00:00
Corinna Vinschen d974d420d4 * mount.cc (fs_info::update): Open filesystem with access set to 0.
Explain why.
2009-07-22 18:49:48 +00:00
Corinna Vinschen c9b8019225 * mount.cc: Revert accidental checkin. 2009-07-22 18:27:47 +00:00
Corinna Vinschen c45871c9c5 * path.cc (symlink_info::check): Handle STATUS_NOT_SUPPORTED from
NtCreateFile just like STATUS_EAS_NOT_SUPPORTED.
2009-07-22 18:21:09 +00:00
Corinna Vinschen 6c188691db * mount.cc (fillout_mntent): Fix typo (noexec -> notexec). 2009-07-22 16:21:33 +00:00
Corinna Vinschen ffea27fc8d * path.cc (symlink_info::check): Fix typo in comment. 2009-07-22 15:55:47 +00:00
Corinna Vinschen 4a77aea071 * fhandler.h (enum del_lock_called_from): New enumeration.
(fhandler_base::del_my_locks): Declare taking a del_lock_called_from
	as argument.
	* fhandler.cc (fhandler_base::close): Call del_my_locks with "on_close".
	(fhandler_base::fixup_after_fork): Call del_my_locks with "after_fork".
	(fhandler_base::fixup_after_exec): Call del_my_locks with "after_exec".
	* flock.cc (fhandler_base::del_my_locks): Take del_lock_called_from
	as argument.  Call node->del_my_locks with NULL handle in after_exec
	case.  Explain why.
2009-07-22 15:46:36 +00:00
Corinna Vinschen a7b11fec84 * dtable.cc (dup2): Correct return value for no-op. 2009-07-21 13:29:00 +00:00
Corinna Vinschen b48215aae0 * fhandler_disk_file.cc (fhandler_disk_file::fchmod): Add special case
for MVFS.  Explain why.
	(fhandler_disk_file::utimens): Drop local variables lastaccess and
	lastwrite.  Copy timestamps right into FILE_BASIC_INFORMATION structure
	to avoid copying them twice.
2009-07-21 08:10:36 +00:00
Corinna Vinschen 20fc2f4936 * wincap.h (wincaps::has_always_all_codepages): New element.
* wincap.cc: Implement above element throughout.
	* wchar.h (__sjis_mbtowc): Declare.
	(__eucjp_mbtowc): Ditto.
	(__gbk_mbtowc): Ditto.
	(__kr_mbtowc): Ditto.
	(__big5_mbtowc): Ditto.
	* syscalls.cc (internal_setlocale): Convert to char * function.
	Return parameter by default.  Return NULL if request to use a
	charset can't be satisfied due to missing codepage support in the
	underlying OS.  Fix comment.
	(setlocale): Store original locale.  Restore to original locale if
	internal_setlocale returns NULL.
2009-07-20 15:44:55 +00:00
Corinna Vinschen 637a1aec8f * fork.cc (fork): Create local tmp_pathbuf. Explain why. 2009-07-20 14:16:06 +00:00
Christopher Faylor acced2cea2 * exceptions.cc (sig_handle_tty_stop): Set stopsig to SIGCONT when continuing.
(stopped_or_terminated): Honor WCONTINUED.
* wait.cc (wait4): Ditto.
* include/cygwin/wait.h (WCONTINUED): Define.
(__W_CONTINUED): Ditto.
(WIFCONTINUED): Ditto.
2009-07-18 20:25:07 +00:00
Dave Korn c627d4ddd0 * libstdcxx_wrapper.cc (operator delete): Remove stray space in
asm name.
2009-07-17 23:37:05 +00:00
Christopher Faylor 5e78ead367 revert erroneous checkin 2009-07-17 22:51:28 +00:00
Christopher Faylor 486a2c9610 * cygtls.cc (_cygtls::init_exception_handler): Test for e, not e->prev or we
could still end up adding our handler twice.  Add comment explaining what we're
doing.
* dll_init.cc (dll_dllcrt0_1): Clarify comment.
2009-07-17 18:17:11 +00:00
Christopher Faylor d2445fa2cc * cygtls.cc (_cygtls::init_exception_handler): Avoid adding our exception
handler twice.
2009-07-17 16:54:21 +00:00
Corinna Vinschen 8319377680 * syscalls.cc (unlink_nt): Just return when a sharing violation
occurs on remote filesystems.
2009-07-17 16:45:22 +00:00
Corinna Vinschen 0fb0fb8391 * globals.cc: Improve comment on R/O UNICODE_STRINGs.
* mount.h (class fs_info): Add is_mvfs bit.
	* mount.cc (fs_info::update): Recognize MVFS remote filesystem.
	(fillout_mntent): Reorder filesystem checks for speed.  Add
	mvfs, unixfs, and sunwnfs filesystem types.
	* path.h (class path_conv): Add fs_is_mvfs method.
	* path.cc (symlink_worker): On MVFS, always create symlinks as
	Windows shortcuts.  Explain why.
2009-07-17 09:00:19 +00:00
Corinna Vinschen d6f45fb002 * syscalls.cc (unlink_nt): First remove the R/O DOS attribute with
FILE_WRITE_ATTRIBUTES access only, then re-open the file for DELETE.
	Explain why.
2009-07-16 16:55:25 +00:00
Corinna Vinschen 76cf56714e * fhandler_disk_file.cc (fhandler_disk_file::fchmod): Remove file
attribute check already done in NtSetAttributesFile.
2009-07-16 15:28:57 +00:00
Corinna Vinschen fc261e53f0 * globals.cc: Reorder constant UNICODE_STRINGs for clarity.
* mount.h (fs_info::sttaus): Move filesystem type flags into
	substructure.  Add union to allow simple test for having set any
	one filesystem type flag.  Replace has_buggy_open flag with is_sunwnfs
	flag.  Replace has_buggy_fileid_dirinfo with is_unixfs flag.
	(fs_info::got_fs): New private method.
	(fs_info::has_buggy_open): New explicit implementation.
	(fs_info::has_buggy_fileid_dirinfo): Ditto.
	* mount.cc (fs_info::update): Optimize filesystem checks for speed.
	* winsup.h (IMPLEMENT_STATUS_FLAG): Change write accessor to return
	value just set.
2009-07-16 09:56:25 +00:00
Corinna Vinschen 5e5a843711 * fhandler_netdrive.cc (GET_RESOURCE_INFO): Remove.
(thread_netdrive): Drop GET_RESOURCE_INFO case.
	(fhandler_netdrive::exists): Use GET_RESOURCE_OPENENUM info class
	to check for existance.
2009-07-15 18:18:03 +00:00
Corinna Vinschen f84aaff222 * fhandler_netdrive.cc (fhandler_netdrive::readdir): Remove useless
alloca.
2009-07-15 14:31:51 +00:00
Corinna Vinschen b31ca33dcc * path.cc (cwdstuff::set): Only fix up UNC path in win32 so as not
to overwrite incoming path.
2009-07-15 13:27:34 +00:00
Corinna Vinschen 8deb411836 Throughout avoid having to initialize constant UNICODE_STRINGs.
* globals.cc: Define constant UNICODE_STRINGs and store in .rdata
	section.
	* fhandler_disk_file.cc: Throughout, use readonly UNICODE_STRINGs
	rather then initializing local UNICODE_STRING variable where
	applicable.
	* fhandler_mem.cc (fhandler_dev_mem::open): Ditto.
	* flock.cc (inode_t::inode_t): Ditto.
	* mmap.cc: Ditto.
	* syscalls.cc: Ditto.
	* mount.cc (fs_info::update): Ditto.
	* path.cc: Ditto.

	* ntdll.h (RtlEqualUnicodePathPrefix): Redefine to take prefix as
	UNICODE_STRING.
	(RtlEqualUnicodePathSuffix): Redefine to take suffix as UNICODE_STRING.
	* fhandler_disk_file.cc: Accommodate throughout.
	* mount.cc (fs_info::update): Ditto.
	* path.cc (cwdstuff::set): Ditto.
	* syscalls.cc: Ditto.
2009-07-14 17:37:42 +00:00
Corinna Vinschen 472345a06c * globals.cc (active_codepage): Remove. 2009-07-14 16:24:33 +00:00
Christopher Faylor 62fb43a722 * how-spawn-works.txt: Add "out of date" note.
* how-vfork-works.txt: Ditto.
2009-07-12 21:26:40 +00:00
Christopher Faylor 4a42a25876 * Makefile.in: Don't do anything special with any RCS directories.
* ntdll.h (PROCESSINFOCLASS): Remove unneeded trailing comma.
* pinfo.cc (_pinfo::dup_proc_pipe): Remove unneeded assignment.
* sigproc.cc (sig_send): Don't send signal to myself if this is an exec stub.
2009-07-12 21:15:47 +00:00
Corinna Vinschen 77dcafa5ad * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Don't use
FileAllInformation info class since it needs a big buffer.  Add a
	comment.
2009-07-12 13:00:36 +00:00
Dave Korn 97bef5b7fd * winbase.h (ilockexch): Avoid making 'ret' volatile.
(ilockcmpexch): Likewise.
2009-07-07 21:41:43 +00:00
Dave Korn cd6c79f4fe * ChangeLog: Assorted minor whitespace fixes in old entries. 2009-07-07 20:25:34 +00:00
Dave Korn b602bb90e2 winsup/ChangeLog:
* Makefile.common (COMPILE_CXX): Add support for per-file overrides
	to exclude $(nostdinc) and $(nostdincxx) from compiler flags.
	(COMPILE_CC): Likewise for $(nostdinc).

winsup/cygwin/ChangeLog:

	* Makefile.in (DLL_OFILES): Add libstdcxx_wrapper.o
	(libstdcxx_wrapper_CFLAGS): Add flags for new module.
	(_cygwin_crt0_common_STDINCFLAGS): Define per-file override.
	(libstdcxx_wrapper_STDINCFLAGS, cxx_STDINCFLAGS): Likewise.
	* cxx.cc: Include "cygwin-cxx.h".
	(operator new): Tweak prototype for full standards compliance.
	(operator new[]): Likewise.
	(operator new (nothrow)): New fallback function.
	(operator new[] (nothrow), operator delete (nothrow),
	operator delete[] (nothrow)): Likewise.
	(default_cygwin_cxx_malloc): New struct of pointers to the above,
	for final last-resort fallback default.
	* cygwin-cxx.h: New file.
	(struct per_process_cxx_malloc): Define.
	(default_cygwin_cxx_malloc): Declare extern.
	* cygwin.din (__wrap__ZdaPv): Export new wrapper.
	(__wrap__ZdaPvRKSt9nothrow_t, __wrap__ZdlPv,
	__wrap__ZdlPvRKSt9nothrow_t, __wrap__Znaj,
	__wrap__ZnajRKSt9nothrow_t, __wrap__Znwj,
	__wrap__ZnwjRKSt9nothrow_t): Likewise.
	* globals.cc (__cygwin_user_data): Init newly-repurposed 'forkee'
	field (now 'cxx_malloc') to point to default_cygwin_cxx_malloc.
	* libstdcxx_wrapper.cc: New file.
	(__wrap__ZdaPv, __wrap__ZdaPvRKSt9nothrow_t, __wrap__ZdlPv,
	__wrap__ZdlPvRKSt9nothrow_t, __wrap__Znaj,
	__wrap__ZnajRKSt9nothrow_t, __wrap__Znwj,
	__wrap__ZnwjRKSt9nothrow_t): Define wrapper functions for libstdc++
	malloc operators and their overrides.
	* winsup.h (default_cygwin_cxx_malloc): Declare extern.
	* include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
	* include/sys/cygwin.h (struct per_process_cxx_malloc): Forward
	declare here.
	(struct per_process::forkee): Rename and repurpose from this ...
	(struct per_process::cxx_malloc): ... to this.
	* lib/_cygwin_crt0_common.cc: Include cygwin-cxx.h.
	(WEAK): Define shorthand helper macro.
	(__cygwin_cxx_malloc): Define and populate with weak references
	to whatever libstdc++ malloc operators will be visible at final
	link time for Cygwin apps and dlls.
	(_cygwin_crt0_common): Always look up cygwin DLL's internal
	per_process data, and don't test for (impossible) failure.  Inherit
	any members of __cygwin_cxx_malloc that we don't have overrides
	for from the DLL's default and store the resulting overall set of
	overrides back into the DLL's global per_process data.
2009-07-07 20:12:44 +00:00
Corinna Vinschen 6499c6e07b * cygtls.cc (_cygtls::remove): Fix typo. 2009-07-07 08:07:38 +00:00
Christopher Faylor 37b9360dc6 * Makefile.in (clean): Clean generated files in srcdir.
* tlsoffsets.h: Regenerate.
2009-07-06 23:19:08 +00:00
Christopher Faylor 421dde25fa * cygtls.cc (_cygtls::remove): Avoid closing a NULL handle. 2009-07-06 23:05:10 +00:00
Corinna Vinschen 58fc288ada * fhandler_socket.cc (fhandler_socket::recv_internal): Convert wsabuf
and wsacnt to references.  Fix handling of WSAEMSGSIZE.
2009-07-06 20:30:34 +00:00
Corinna Vinschen 023c25829c * cygtls.h (struct _local_storage): Add thread storage pointers for
memory used by socket select functions.  Combine them into a single
	struct select.
	* cygtls.cc: Accommodate above change throughout.
	(_cygtls::init_thread): Drop initalizing of sockevt to
	INVALID_HANDLE_VALUE.
	(_cygtls::fixup_after_fork): Reset sockevt to NULL.
	(_cygtls::remove): Don't use sockevt value to bail out prematurely.
	Set sockevt to NULL.  Free malloced select members.
	* select.h (struct select_socket_info): Drop max_w4 member.
	* select.cc (thread_socket): Use INFINITE timeout value if number of
	objects to wait for is <= MAXIMUM_WAIT_OBJECTS.  Use num_w4 member
	of select_socket_info struct rather than dropped max_w4.
	(init_tls_select_info): New inline function to initialize TLS select
	members.
	(start_thread_socket): Just call init_tls_select_info to initialize TLS
	select members and use them later on.
	(socket_cleanup): Don't free select_socket_info pointer members since
	they are thread local now.
2009-07-06 15:42:01 +00:00
Christopher Faylor 1183d7fb13 * dtable.cc (handle_to_fn): Detect failing NtQueryObject. 2009-07-06 15:11:30 +00:00
Corinna Vinschen e4001d4ccd * autoload.cc: Delete stray CR. 2009-07-06 10:44:14 +00:00
Christopher Faylor 5ea3e685eb * fhandler_console.cc: Change workstation -> windows station throughout. 2009-07-05 16:49:56 +00:00
Christopher Faylor 01d8a2dfd6 * autoload.cc (SetParent): Add new import.
* fhandler.h (fhandler_console::create_invisible_console): Declare new
function.
(create_invisible_console_workaround): Ditto.
* fhandler_console.cc (fhandler_console::create_invisible_console): Define new
function.
(create_invisible_console_workaround): Ditto.  Add too much code to deal with
broken Windows 7.  Use a helper app to start an invisible console window.
(fhandler_console::need_invisible): Reorganize to use helper functions to
create invisible console.
* spawn.cc (spawn_guts): Avoid zeroing already zeroed fields in si.
2009-07-04 23:51:10 +00:00
Dave Korn 38a58dd13c * autoload.cc (AttachConsole): Correct size of args. 2009-07-04 14:51:09 +00:00
Christopher Faylor 3c4f2024a1 * dcrt0.cc (jit_debug): New global.
(initial_env): Set jit_debug when we are automatically starting a gdb process.
* dtable.cc (dtable::get_debugger_info): Don't tty tricks when we are being
debugged by our own captive gdb, as determined by jit_debug == true.
(dtable::init_std_file_from_handle): Detect errors when initializing a tty
early rather than at random points later.
* fhandler.h (fhandler_*::init): Return int to indicate success/failure.
* fhandler.cc (fhandler_base::init): Reflect change in return value.
* pipe.cc (fhandler_pipe::init): Ditto.
(fhandler_pipe::create_selectable): Don't say we're retrying when we aren't.
* fhandler_console.cc (fhandler_console::init): Ditto.  Return success/failure.
* fhandler_serial.cc (fhandler_serial::init): Ditto.
* fhandler_tty.cc (fhandler_tty_slave::init): Ditto.
(fhandler_tty_slave::open): Make debugging output more detailed.
* tty.cc (tty_list::terminate): Don't close I/O handles before all slaves have
checked in.
(tty::slave_alive): Make a non-inlined function.  Check if tty pipe handles can
be created as an additional exists check.
* tty.h (tty::slave_alive): Just define here.
2009-07-03 18:05:51 +00:00
Corinna Vinschen 8d7471ab44 * posix.sgml: Add fpurge and mkstemps to BSD list. 2009-07-03 13:04:01 +00:00
Corinna Vinschen e5f37aa148 * cygwin.din (fpurge, mkstemps): New exports.
* include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
	* mktemp.cc (_gettemp): Add parameter.
	(mkstemps): New function.
	(mkstemp, mkdtemp, mktemp): Adjust clients.
2009-07-03 13:01:17 +00:00
Corinna Vinschen a4175657bf * autoload.cc: Fix typo in comment.
(ShowWindowAsync): Define.
	(AttachConsole): Define.
	* fhandler_console.cc (fhandler_console::need_invisible): Add band-aid
	for Windows 7 AllocConsole bug.
2009-07-03 10:50:51 +00:00
Corinna Vinschen d3920e10ad * net.cc (get_xp_ifs): Fix typo in comment. 2009-07-01 15:45:23 +00:00
Corinna Vinschen 975a630109 * fhandler.h (class fhandler_socket): Add class members and methods
to store and retrieve the SO_RCVBUF and SO_SNDBUF sizes.
	* fhandler_socket.cc (fhandler_socket::dup): Duplicate new members.
	(fhandler_socket::send_internal): Check for SO_SNDBUF size and
	restrict send to 1 byte less per KB 823764.  Leave loop immediately
	if WSASendMsg has been used.
	* net.cc (fdsock): Change comment again.  Set buffer sizes to 65536.
	Store values in fhandler_socket.
	(cygwin_setsockopt): Store SO_RCVBUF and SO_SNDBUF sizes in
	fhandler_socket.
	(cygwin_sendto): Drop call to sig_dispatch_pending.
	(cygwin_recvfrom): Ditto.
	(cygwin_recvmsg): Ditto.
	(cygwin_sendmsg): Ditto.
2009-07-01 09:16:17 +00:00
Christopher Faylor b4fa816474 * select.h: New file split from fhandler.h.
(select_record::select_record): Define do-nothing constructor for "new" to
avoid gratuitous zeroing.
(select_info): New base class.
(select_pipe_info): New class with methods for dealing with pipes.
(select_socket_info): New class with methods for dealing with sockets.
(select_serial_info): Dummy class for serial.
(select_mailslot_info): Dummy class for mailslots.
(select_stuff): Define device_specific_* as actual classes rather than void *.
* dtable.h (dtable::select_read): Accommodate return value change to 'bool' and
argument change to "select_stuff".
(dtable::select_write): Ditto.
(dtable::select_except): Ditto.
* dtable.cc (dtable::select_read): Accommodate return value change to 'bool'
and argument change to "select_stuff".
(dtable::select_write): Ditto.
(dtable::select_except): Ditto.
* fhandler.h: Excise select-related classes.
(fhandler_*::select_read): Change argument to select_stuff.
(fhandler_*::select_write): Ditto.
(fhandler_*::select_except): Ditto.
* select.cc (UNIX_FD_ZERO): Use memset rather than bzero.
(select_stuff::test_and_set): Change return type to bool.  Allocate
select_record on entry and let fhandler_*::select_* operate on the start.next
field of select_stuff.
(pipeinf): Delete.
(select_pipe_info::select_pipe_info): New constructor.  Allocates event for
controlling pipe waits.
(select_pipe_info::~select_pipe_info): New destructor.  Destroy event.  Stop
thread.
(select_pipe_info::add_watch_handle): New function.
(thread_pipe): Wait for the hEvent part of any overlapped pipes before peeking.
(start_thread_pipe): Don't allocate device_specific_pipe stuff here.  Assume
that it has been allocated earlier.
(pipe_cleanup): Rely on select_pipe_info destructor to clean up pipe
paraphenalia.
(fhandler_*::select_*): Derive select_record from new select_stuff argument.
(fhandler_pipe::select_*): Ditto.  Allocate pipe-specific field if not already
allocated.
(serialinf): Delete.
(thread_serial): serialinf -> select_serial_info.
(fhandler_base::ready_for_read): Rewrite to accommodate change in argument to
fhandler_*::select_*.
(socketinf): Delete.
(thread_socket): socketinf -> select_socket_info.
(mailslotinf): Delete.
(thread_mailslot): mailslotinf -> select_mailslot_info.
2009-06-30 21:18:44 +00:00
Christopher Faylor 840bb39798 * fhandler.cc (fhandler_base::has_ongoing_io): Accept an argument indicating
whether the overlapped event should be tested.
(fhandler_base::read_overlapped): Pass is_overlapped state to has_ongoing_io.
(fhandler_base::write_overlapped): Ditto.
* fhandler.h (fhandler_base::has_ongoing_io): Accommodate argument change.
* select.cc (peek_pipe): Ditto.
2009-06-30 14:36:11 +00:00
Corinna Vinschen 4a83803381 * net.cc (fdsock): Set default socket buffer sizes to 65520. Change
comment accordingly.
	* fhandler_socket.cc (fhandler_socket::send_internal): Set maximum
	send size to 65520 as well.
2009-06-30 10:36:40 +00:00
Christopher Faylor 9adef9ffef * select.cc (peek_pipe): Turn on (temporarily?) the experimental code which
tries to determine when a pipe is writable.
2009-06-29 14:32:58 +00:00
Christopher Faylor 7fc7ee1726 * select.cc (peek_pipe): Use has_ongoing_io() to determine if the pipe is ready
for writing rather than performing brute-force checks.
2009-06-28 19:27:15 +00:00
Christopher Faylor c81ceaefec * fhandler.h (fhandler_base::has_ongoing_io): Declare new function.
* fhandler.cc (fhandler_base::has_ongoing_io): Define new function.
(fhandler_base::read_overlapped): Use has_ongoing_io to avoid writing when
handle has not completed last I/O.
(fhandler_base::write_overlapped): Ditto.
* select.cc (peek_pipe): Be more careful about accessing hEvent field from
get_overlapped().
2009-06-28 19:23:13 +00:00
Christopher Faylor 91000b5d66 * gendef (cleanup): Rename from 'nocr'. Remove comments and trailing spaces.
* cygwin.din: Add long-needed comment describing what dll_crt0__FP11per_process
demangles to.
2009-06-28 18:23:35 +00:00
Corinna Vinschen 8d1d548fd8 * wincap.h (wincaps::has_broken_alloc_console): New element.
* wincap.cc: Implement above element throughout.
2009-06-26 15:12:06 +00:00
Corinna Vinschen 21a49eaeeb * sec_auth.cc (lsaauth): Close unused handle.
(lsaprivkeyauth): Ditto.
2009-06-25 08:22:09 +00:00
Corinna Vinschen bc4020d725 * sec_auth.cc (get_server_groups): Ignore errors from
get_user_local_groups.
2009-06-23 10:23:16 +00:00
Corinna Vinschen d6bb3f330d * spawn.cc (spawn_guts): Don't run additional check for Win32
incompatible CWD if newargv.fixup bailed out already.
	(av::fixup): Check shell scripts for executability.
2009-06-22 15:40:59 +00:00
Corinna Vinschen 1279c76b6a * path.cc (chdir): Check error conditions first. 2009-06-18 09:47:13 +00:00
Corinna Vinschen 3477392bd7 * fhandler_socket.cc (fhandler_socket::recv_internal): Mark WSARecvMsg
as NO_COPY.
2009-06-17 08:23:17 +00:00
Christopher Faylor 6a451dce26 * fhandler.cc (fhandler_base::read_overlapped): Use a better variable name. 2009-06-16 20:33:45 +00:00
Christopher Faylor 4844eaa5f8 * fhandler.cc (fhandler_base::read_overlapped): Preserve len when looping due
to received signal.
2009-06-16 19:05:43 +00:00
Corinna Vinschen ea3923078a * net.cc (get_flags): New static function to generate interface flags
value.
	(get_ipv4fromreg_ipcnt): New static function to fetch number of
	configured IPv4 addresses for a given NIC from registry.
	(get_ipv4fromreg): New static function to fetch configured IPv4
	addresses for a given NIC from registry.
	(get_friendlyname): New static function to generate friendly name.
	(get_hwaddr): New static function to copy hardware address.
	(get_xp_ifs): Restructure slightly.  Add code to generate IPv4 entries
	entries for interfaces which are disconnected.
2009-06-15 20:04:15 +00:00
Christopher Faylor fee56469d4 * errno.cc (errmap): Add mapping for ERROR_IO_INCOMPLETE.
* fhandler.cc (fhandler_base::fcntl): Fix comment.
(fhandler_base::wait_overlapped): Accept an optional len parameter.  Use the
len parameter when WriteFile fails with ERROR_IO_PENDING.  Make debug output
less alarming.
(fhandler_base::write_overlapped): Pass len to wait_overlapped.
* fhandler.h (fhandler_base::wait_overlapped): Add an optional argument
denoting the number of characters intended to be written.
* fhandler_tty.cc (fhandler_pty_master::close): Don't close archetype handles
when cygwin is still initializing since the handles aren't actually opened at
that point.
2009-06-14 23:42:09 +00:00
Corinna Vinschen 313c719cb8 * localtime.cc (time2): Take another stab at fixing a compiler warning. 2009-06-14 09:35:35 +00:00
Christopher Faylor b5b99c0486 * localtime.cc (time2): Take a stab at fixing a compiler warning. 2009-06-14 05:49:01 +00:00
Christopher Faylor 6a712635dd * fhandler.cc (fhandler_base::wait_overlapped): Honor nonblocking flag for
writes.  Don't reset event handle when we see a ERROR_IO_PENDING.
* sigproc.cc (stopped_or_terminated): Use bool constants for consistency.
* wait.cc (wait4): Remove nonsensical comment.
2009-06-14 05:38:55 +00:00
Corinna Vinschen 792c564b27 * fhandler_socket.cc (fhandler_socket::recv_internal): Set namelen
pointer to NULL if name pointer is NULL.  Explain why.
2009-06-13 16:13:01 +00:00
Corinna Vinschen c3d7820d5b * localtime.cc (time2): Change "spring gap" to "spring forward gap"
in comment.
2009-06-12 15:08:43 +00:00
Corinna Vinschen 7ce08eab6c * localtime.cc (time2): Add workaround for spring gap problem. Add
explaining comment.
2009-06-12 15:06:26 +00:00
Corinna Vinschen 06391373b0 * Makefile.in (SUBLIBS): Add librt.a.
(librt.a): New rule to build librt.a.
2009-06-12 10:19:36 +00:00
Corinna Vinschen bf79ee9167 Improve ChangeLog entry. Fix posix_ipc.cc copyright 2009-06-12 09:52:06 +00:00
Corinna Vinschen b32c31d117 * posix_ipc.cc (check_path): Fix typo in comment. Align naming
convention rules to Linux.  Add comment.
2009-06-12 09:50:05 +00:00
Corinna Vinschen 962082b91a * autoload.cc (GetSystemTimes): Remove.
* fhandler_proc.cc (format_proc_uptime): Use global system_info rather
	than retrieving a local copy of the SYSTEM_INFO.  Drop call to
	GetSystemTimes and retrieve SystemPerformanceInformation on all systems
	again with buffer size big enough for 64 bit systems.
	(format_proc_stat): Use global system_info rather than retrieving a
	local copy of the SYSTEM_INFO.  Retrieve SystemPerformanceInformation
	with buffer size big enough for 64 bit systems.
2009-06-09 09:45:29 +00:00
Corinna Vinschen e83d7b1835 Fix ChangeLog entry 2009-06-08 20:06:55 +00:00
Corinna Vinschen d8e551a1a7 * autoload.cc (GetSystemTimes): Define.
* fhandler_proc.cc (format_proc_uptime): Use GetSystemInfo to retrieve
	processor count.  Use GetSystemTimes when available to retrieve system
	idle time.  Improve debug output.
	(format_proc_stat): Use GetSystemInfo to retrieve processor
	count.  Improve debug output.  Ignore if SystemPerformanceInformation
	returns error.  Explain why.
2009-06-08 20:04:37 +00:00
Corinna Vinschen 3b80aa0156 * fork.cc (frok::parent): Remove ancient code erroneously flushing
stdout descriptor.
2009-06-08 19:45:39 +00:00
Corinna Vinschen c84bbb2d8f * cygerrno.h (save_errno::~save_errno): Set errno directly to avoid
flooding debug output.
2009-06-08 19:44:33 +00:00
Corinna Vinschen 590f450aa9 * path.cc (symlink_info::check): Return with error set to ENOENT if
STATUS_NO_MEDIA_IN_DEVICE is returned.
2009-06-08 15:22:52 +00:00
Christopher Faylor 71f53a2f62 * cygheap.h (mini_cygheap): New struct.
(init_cygheap): Inherit locale field via mini_cygheap.
* cygheap.cc (cygheap_at_start): Define new variable.
(cygheap): Initialize as cygheap_at_start so that locale information is always
available.
(cygheap_init): Initialize cygheap iff it is set to cygheap_at_start.
* shared_info.h (memory_init): Accommodate argument change.
* memory.cc (memory_init): Accept an argument indicating whether cygheap should
be initialized or not.
* dcrt0.cc (child_info_fork::handle_fork): Pass false to memory_init().
(child_info_spawn::handle_spawn): Ditto.
(dll_crt0_0): Pass true to memory_init when not forking or execing.
* cygheap.h (cygheap_types::HEAP_2_DLL): New enum.
* dll_init.h (dll): Remove unused namelen field.
(dll_list::load_after_fork): Accommodate change in arguments.
* dll_init.cc (dll_list::alloc): Allocate dll information in the cygwin heap.
(dll_list::detach): Free dll information from the cygwin heap.
(dll_list::load_after_fork): Use dll information in the cygwin heap directly
rather than querying parent.
* fork.cc (frok::first_dll): Delete.
(frok::child): Don't report on first_dll.  Don't pass it to load_on_fork.
(frok::parent): Don't set first_dll.
(fork): Ditto.
2009-06-08 03:53:40 +00:00
Corinna Vinschen cf2e7e9cbc * dll_init.cc (dll_list::alloc): Allocate memory using a section
object.  Explain why.  Drop call to GetSystemInfo, rather call
	getpagesize to get allocation granularity.  Only align to allocation
	granularity under WOW64.  Use roundup2 to align.
	(dll_list::detach): Call NtUnmapViewOfSection instead of VirtualFree.
2009-06-07 07:26:07 +00:00
Corinna Vinschen f985cc1c53 * mmap.cc: Use NtUnmapViewOfSection instead of UnmapViewOfFile
throughout for symmetry.
	(fhandler_dev_mem::munmap): Use correct process handle in call to
	NtUnmapViewOfSection.
2009-06-06 19:56:41 +00:00
Corinna Vinschen 1d95e198c1 * dll_init.h (struct dll): Set size of name element to ANYSIZE_ARRAY.
* dll_init.cc: Fix formatting.
	(dll_list::alloc): Only allocate as much memory for struct dll as
	necessary for given DLL name.
	(dll_list::load_after_fork): Only read a single page of parent memory.
	Only read more if namelen indicates that it's necessary.
2009-06-06 11:47:29 +00:00
Dave Korn 611fe46079 * winbase.h (ilockexch): Fix asm constraints.
(ilockcmpexch):  Likewise.
2009-06-05 13:53:01 +00:00
Corinna Vinschen a341aab5a5 * heap.cc (heap_init): Fix typo in comment. 2009-06-05 11:15:28 +00:00
Corinna Vinschen fbe1e28194 * fhandler_clipboard.cc: Avoid calling system_printf.
(set_clipboard): Add basic error checking.  Set errno here.  Per MSDN,
	don't call GlobalFree on data block transferred to clipboard.
	(fhandler_dev_clipboard::write): Drop setting errno after call to
	set_clipboard.
	(fhandler_dev_clipboard::read): Add basic error checking. Simplify code.
2009-06-04 17:14:53 +00:00
Corinna Vinschen 7774a4b029 * fhandler_console.cc (set_console_title): Convert title string to
wchar_t and call SetConsoleTitleW.
2009-06-04 14:59:47 +00:00
Corinna Vinschen f17f20c139 * fhandler_console.cc (fhandler_console::read): Allow Ctrl-Space to
emit a NUL byte.
2009-06-04 09:57:34 +00:00
Dave Korn b650c255ab * thread.cc (__cygwin_lock_lock): Delete racy optimisation.
(__cygwin_lock_unlock):  Likewise.
2009-06-04 01:45:05 +00:00
Corinna Vinschen b8c9d44669 * strfuncs.cc (sys_cp_mbstowcs): Fix condition. 2009-06-03 19:04:07 +00:00
Corinna Vinschen 397775c6f6 * strfuncs.cc (sys_cp_wcstombs): Implement reverse functionality
of the change to sys_cp_mbstowcs from 2009-05-30.
	(sys_cp_mbstowcs): Slightly reformat.  Fix comment to accommodate
	change to sys_cp_wcstombs.  Don't write to *ptr if dst is NULL.
2009-06-03 17:23:39 +00:00
Corinna Vinschen c48a1e46bf * fhandler_console.cc (fhandler_console::read): Convert Alt-Backspace
to \033\177 or to \377 dependent on the setting of dev_state->metabit.
2009-06-03 11:07:38 +00:00
Corinna Vinschen fa986bf9cd * path.cc (path_conv::check): Don't call set_exec for files on "noacl"
mount points.
2009-06-02 13:29:30 +00:00
Christopher Faylor e44b9069cd * strfuncs.cc (sys_cp_mbstowcs): Treat src as unsigned char *. Convert failure
of f_mbtowc into a single malformed utf-16 value.
2009-05-31 03:59:38 +00:00
Christopher Faylor 025e4859af * cygwin/include/sys/termios.h: Make default erase character "^?". 2009-05-30 17:21:22 +00:00
Christopher Faylor bfa7707bce * fhandler_console.cc (fhandler_console::read): Convert backspace key to DEL. 2009-05-30 05:51:41 +00:00
Christopher Faylor 992ddba949 * path.cc (cwdstuff::set): Rewrite previous change to properly test the end of
the buffer.
2009-05-29 20:18:50 +00:00
Christopher Faylor 9971adf5aa * path.cc (cwdstuff::set): Avoid removing a nonexistent trailing slash. 2009-05-28 05:10:03 +00:00
Christopher Faylor 0a20e5a02b * net.cc (gethostby_helper): Use correct signedness. 2009-05-20 14:56:46 +00:00
Christopher Faylor 6b4d6adebd * mount.cc (mount_info::add_item): Avoid using any-old '/' as indicating root. 2009-05-19 00:42:35 +00:00
Christopher Faylor 3fdcac0b1c * mount.cc (mount_info::got_usr_bin): Mark as NO_COPY.
(mount_info::got_usr_lib): Ditto.
(mount_info::root_idx): Ditto.
2009-05-18 04:58:21 +00:00
Corinna Vinschen a972ea99d5 * wchar.h (sys_mbstowcs): Add missing __stdcall attribute. 2009-05-15 11:27:41 +00:00
Corinna Vinschen 6f401eccfb * cygheap.cc (cygheap_init): Set Cygwin default locale values.
* cygheap.h (struct cygheap_locale): New structure.
	(struct user_heap_info): Add cygheap_locale member locale.
	* dcrt0.cc (dll_crt0_1): Revert to calling _setlocale_r so that only
	the applications locale is reverted to "C".
	* environ.cc (environ_init): Remove unused got_lc variable.
	* fhandler.h (class dev_console): Remove now unsed locale variables.
	* fhandler_console.cc (fhandler_console::get_tty_stuff): Remove
	setting dev_console's locale members.
	(dev_console::con_to_str): Use internal locale settings.  Default to
	__ascii_wctomb if charset is "ASCII".
	(fhandler_console::write_normal): Ditto.
	* strfuncs.cc (__ascii_wctomb): Drop declaration.
	(__db_wctomb): Use fixed value 2 instead of not
	necessarily matching MB_CUR_MAX.
	(__eucjp_wctomb): Use 3 instead of MB_CUR_MAX.
	(sys_cp_wcstombs): Remove special case for "C" locale.
	(sys_wcstombs): Implement here.  Use internal locale data stored on
	cygheap.
	(sys_cp_mbstowcs): Remove special case for "C" locale.
	(sys_mbstowcs): Implement here.  Use internal locale data stored on
	cygheap.
	* syscalls.cc (internal_setlocale): New function to set cygheap locale
	data and to reset CWD posix path.
	(setlocale): Just call internal_setlocale from here if necessary.
	* wchar.h (__ascii_wctomb): Declare.
	(sys_wcstombs): Don't define inline, just declare.
	(sys_mbstowcs): Ditto.
2009-05-14 19:49:37 +00:00
Christopher Faylor ef5da523a9 * mount.cc (mount_info::init): Remove MOUNT_CYGWIN_EXEC setting when
auto-mounting /usr/bin.
2009-05-14 14:44:31 +00:00