2011-06-22 Corinna Vinschen * fhandler_tty.cc (fhandler_pty_master::setup): Fix crash in debug output. 2011-06-18 Corinna Vinschen * path.cc (normalize_win32_path): Skip all slashes after recognizing a ".." path component. Add comment. 2011-06-17 Corinna Vinschen * fhandler.cc (fhandler_base::open): Drop local create_options variable. Use options member instead. * fhandler.h (class fhandler_base): Change type of access member to ACCESS_MASK. Change get_access and set_access methods accordingly. Add options member. Add get_options and set_options methods. (class fhandler_disk_file): Add prw_handle. (fhandler_disk_file::prw_open): Declare. (fhandler_disk_file::close): Declare. (fhandler_disk_file::dup): Declare. (fhandler_disk_file::fixup_after_fork): Declare. * fhandler_disk_file.cc (fhandler_disk_file::fhandler_disk_file): Initialize prw_handle to NULL. (fhandler_disk_file::close): Close prw_handle. (fhandler_disk_file::dup): New method. (fhandler_disk_file::fixup_after_fork): Set prw_handle to NULL since prw_handle is not inherited. (fhandler_disk_file::prw_open): New method. Add long comment to explain current behaviour. (fhandler_disk_file::pread): Revert previous change. Change to use prw_handle if possible. (fhandler_disk_file::pwrite): Change to use prw_handle if possible. 2011-06-17 Corinna Vinschen * dcrt0.cc (dll_crt0_1): Call strace.dll_info after call to pinfo_init. * strace.cc (strace::hello): Drop printing DLL information here since application info is not always available at this point. (strace::dll_info): New method to print DLL info. * include/sys/strace.h (strace::dll_info): Declare. 2011-06-17 Corinna Vinschen * dtable.cc (handle_to_fn): Accommodate name change of pty named pipes, otherwise ptys are not recognized. 2011-06-16 Christopher Faylor * fhandler_console.cc (fhandler_console::set_unit): Set pc.file_attributes() to reflect existence. * fhandler.h (fhandler_pty_common::fhandler_pty_common): Ditto. * pinfo.cc (_pinfo::set_ctty): Output device numbers in hex. 2011-06-15 Christopher Faylor * errno.cc (EIO): Lowercase "o" representative string. 2011-06-14 Christopher Faylor * cygheap.h (init_cygheap::ctty_on_hold): Remove conditionalized variable. * dcrt0.cc (do_exit): Remove code which handled CYGWIN=tty style ttys. * devices.in: Remove "/dev/ttym". * dtable.cc: Rename tty to pty where appropriate throughout. (dtable::stdio_init): Use new t->is_console rather than using now-deleted hwnd element in tty structure. (dtable::init_std_file_from_handle): Remove code which handled CYGWIN=tty style ttys. (fh_alloc): Ditto. * fhandler.h: Rename tty to pty where appropriate. (fhandler_pty_common): Delete output_done_event, ioctl_request_event, ioctl_done_event. (fhandler_pty_master::setup): Delete argument. (fhandler_tty_master): Delete. (fhandler_union): Delete __tty_master. * fhandler_console.cc (use_tty): Delete. (fhandler_console::get_tty_stuff): Set is_console to true rather than calling sethwnd. (fhandler_console::send_winch_maybe): Remove CYGWIN=tty considerations. (fhandler_console::input_tcsetattr): Ditto. * fhandler_termios.cc (fhandler_termios::tcsetpgrp): Use new t->is_console rather than using now-deleted hwnd element in tty structure. * fhandler_tty.cc: Rename tty to pty where appropriate throughout. (tty_master): Delete. (process_input): Ditto. (process_output): Ditto. (process_ioctl): Ditto. (fhandler_tty_master::*): Ditto. (fhandler_pty_master::process_slave_output): Remove CYGWIN=tty considerations. (fhandler_pty_slave::open): Ditto for *_done_event. (fhandler_pty_slave::write): Ditto. (fhandler_pty_slave::ioctl): Ditto. (fhandler_pty_slave::fch_open_handles): Ditto. (fhandler_pty_slave::fch_set_sd): Ditto. (fhandler_pty_slave::fch_close_handles): Ditto. (fhandler_pty_common::close): Ditto. (fhandler_pty_master::setup): Ditto. Remove now-unneeded ispty parameter. (fhandler_pty_master::open): Reflect argument removal for tty::allocate. * select.cc: Rename tty to pty where appropriate throughout. * sigproc.cc (proc_subproc): Remove CYGWIN=tty considerations. * tty.cc (ttyslot): Accommodate CYGWIN=tty removal. (tty_list::init_session): Ditto. (tty_list::attach): Ditto. (tty::create_master): Delete. (tty_list::terminate): Ditto. (tty_list::allocate): Delete "with_console" parameter. Remove CYGWIN=tty considerations. (tty::init): Set is_console = false. Use 'false' for was_opened since it is a boolean. * tty.h (*_{DONE,REQUEST}_EVENT): Delete. (tty_min::is_console): Declare new field which replaces hwnd. (tty_min::gethwnd): Delete. (tty_min::sethwnd): Ditto. (tty_list::allocate): Delete parameter. (tty_list::terminate): Delete declaration. * include/sys/cygwin.h (PID_USETTY): Redefine to PID_UNUSED1 and change comment to reflect its availability. 2011-06-13 Christopher Faylor * fhandler_tty_slave.cc (fhandler_tty_slave::fhandler_tty_slave): Revert previous change since unit 0 is perfectly valid. 2011-06-12 Christopher Faylor Rename FH_BAD to FH_NADA throughout. * devices.h (FH_ERROR): New value. (iscons_dev): Extend to detect all the console device types. * devices.in: Set aside storage for FH_ERROR. * dtable.cc (dtable::init_std_file_from_handle): Use iscons_dev to detect when device is a console. (fh_alloc): Pass device to console constructor. (build_fh_pc): Short circuit when we detect that the constructor saw an error. * fhandler.h (fhandler_console::fhandler_console): Accept fh_devices parameter. (get_tty_stuff): Change to void. * fhandler_console (fhandler_console::set_unit): Set device to FH_ERROR on attempt to access anything other than the current console. (fhandler_console::get_tty_stuff): Change to void return. (fhandler_console::open): Return EPERM on FH_ERROR device type. (fhandler_console::fhandler_console): Set the device type appropriately before calling get_tty_stuff and rely on that function to reset it if necessary. 2011-06-10 Christopher Faylor * environ.cc (create_upcaseenv): Delete. (ucenv): Don't honor create_upcaseenv. (environ_init): Remove early retrieval of CYGWIN environment variable. Change comment to reflect new behavior. 2011-06-09 Christopher Faylor * child_info.h (CURR_CHILD_INFO_MAGIC): Reset. (child_info::old_title): Delete. (child_info::~child_info_spawn): Remove recording of old_title. * dcrt0.cc (title_buf): Delete. (child_info_spawn::handle_spawn): Remove recording of old_title. (dll_crt0_1): Get rid of all title handling. (do_exit): Ditto. * environ.cc (known): Delete strip_title and title. * fhandler_console.cc (fhandler_console::write): Remove recording of old_title. * globals.cc (exit_states): Remove ES_TITLE. (display_title): Delete. (strip_title_path): Delete. (old_title): Delete. * spawn.cc (spawn_guts): Remove old_title accommodation. 2011-06-09 Christopher Faylor * environ.cc (envcache): Delete. (known): Remove envcache. (getwinenv): Don't honor envcache setting. 2011-06-09 Christopher Faylor * environ.c: Move code earlier to allow: (_addenv): Call parse_options() when CYGWIN environment variable is being changed. (parse_options): Change parameter to 'const'. 2011-06-08 Christopher Faylor * environ.cc (tty_is_gone): Add missing space to message. 2011-06-08 Christopher Faylor * environ.cc (settings::set_process_state): Delete. (tty_is_gone): New function. (known): Change "tty" to call tty_is_gone(). Remove unneeded '&' from beginning of function address. (parse_options): Remove set_process_state handling. * shared_info.h (CURR_USER_MAGIC): Reset. (user_info::warned_notty): New member. 2011-06-07 Christopher Faylor * fhandler_console.cc (fhandler_console::open_shared_console): Semi-revert to using fixed location for console stuff. * shared.cc (offsets): Ditto. Comment. * shared_info (shared_locations): Re-add SH_SHARED_CONSOLE. 2011-06-05 Christopher Faylor * fhandler_disk_file.cc (fhandler_disk_file::pread): Reset windows file position pointer back to previous location after successful read. 2011-06-04 Christopher Faylor * fhandler_console.cc (fhandler_console::open_shared_console): Don't zero handle to open_shared since it is supposed to be an input. (enum_windows): Set handle input to open_shared to NULL since it does not represent any previously opened shared region. * shared.cc (open_shared): Tweak debugging output. 2011-06-03 Christopher Faylor * ntdll.h (FILE_PIPE_*): Define constants. * select.cc (pipe_data_available): Detect closing state. 2011-06-03 Christopher Faylor * pinfo.cc (_pinfo::set_ctty): Don't reset myself->{pgid,sid} if terminal has no pgid or sid settings. 2011-06-03 Christopher Faylor * fhandler.cc (fhandler_base_overlapped::wait_overlapped): Only raise SIGPIPE when writing. * fhandler.h: Include "tty.h". (fhandler_termios::_tc): Rename from tc. (fhandler_termios::tc): New method. (fhandler_termios::tcinit): Remove an argument. (fhandler_termios::get_ttyp): Use method to retrieve value. (fhandler_console::console_state): Move here. (fhandler_console::dev_state): Delete. (fhandler_console::shared_console_info): Define. (fhandler_console::open_shared_console): Move this function under fhandler_console umbrella. (fhandler_console::tc): Define. Return static value. (fhandler_console::focus_aware): Accommodate deletion of dev_state. (fhandler_console): Add tty_list::get_cttyp as a friend. * fhandler_console.cc (dev_state): Redefine as a pointer within shared_console_info and change dev-> to dev. throughout. (fhandler_console::shared_console_info): Move into fhandler_console. (fhandler_console::open_shared_console): Move into fhandler_console change argument to simple bool. (enum_windows): Accommodate changes to console_state and open_shared_console. (console_unit::console_unit): Ditto. (fhandler_console::get_tty_stuff): Accommodate change to dev_state. (tty_list::get_cttyp): Accommodate change to handler_console::shared_console_info. (fhandler_console::read): Accommodate change from tc to tc (). (fhandler_console::set_input_state): Ditto. (fhandler_console::open): Accommodate tcinit argument change and change from tc to tc(). (fhandler_console::input_tcsetattr): Accomodate change from tc to tc(). (fhandler_console::input_tcsetattr): Ditto. (fhandler_console::write_normal): Ditto. (fhandler_console::init): Ditto. (fhandler_console::igncr_enabled): Ditto. * fhandler_termios.cc (fhandler_termios::tcinit): Remove first argument. Expect tc() to have been set up first. Use tc() rather than tc. (fhandler_termios::tcsetpgrp): Accomodate change from tc to tc(). (fhandler_termios::tcgetpgrp): Ditto. (fhandler_termios::bg_check): Ditto. (fhandler_termios::line_edit: Ditto. (fhandler_tty_master::set_winsize): Ditto. (fhandler_tty_slave::open): Ditto. (fhandler_tty_slave::init): Ditto. (fhandler_pty_master::write): Ditto. (fhandler_pty_master::setup): Ditto. Accommodate change in arguments to tcinit. (fhandler_tty_slave::fch_open_handles): Set _tc directly. (tty_min::is_orphaned_process_group): Don't assume that parent pid exists. * pinfo.cc (_pinfo::set_ctty): Reset myself->{pgid,sid} here if we were started by a non-Cygwin process but the tty exists. * shared_info.h (console_state): Delete from here. * tty.h: Make multiple inclusion safe. 2011-05-31 Christopher Faylor * exceptions.cc (ctrl_c_handler): Simplify test for no parent tty. * fhandler_console.cc (fhandler_console::get_tty_stuff): Return NULL if ctty is not tty/console. Improve test for slave tty/pty device. 2011-05-31 Christopher Faylor * external.cc (fillout_pinfo): Don't truncate ctty if it's < 0. * select.cc (pipe_data_available): Avoid printing debug info by default or suffer very large strace files. 2011-05-31 Christopher Faylor * select.cc (pipe_data_available): New function - uses NtQueryInformationFile to return information about pipes. (peek_pipe): Rewrite to use pipe_data_available for both read and write tests. 2011-05-30 Christopher Faylor * dtable.cc (dtable::select_write): Add missing argument to debug_printf. * fhandler.cc (fhandler_base_overlapped::setup_overlapped): Explicitly set io_pending to false. (fhandler_base_overlapped::has_ongoing_io): Call GetOverlappedResult to force completion of I/O. (fhandler_base_overlapped::wait_overlapped): Rewrite to correctly deal with nonblocking reads and to make more race proof. (fhandler_base_overlapped::raw_write): Deal with new enum values. (fhandler_base_overlapped::raw_read): Ditto. Don't deal with ongoing I/O here since it makes no sense in the read context. * fhandler.h (enum wait_return): Add overlapped_unknown, overlapped_nonblocking_no_data. * pipe.cc (pipe): Add debugging output. 2011-05-30 Christopher Faylor * dll_init.cc (dll_list::append): Eliminate increment of unused tot variable. * dll_init.h (dll_list::tot): Delete. (dll_list::populate_all_deps): Delete undefined function. * fhandler.cc (fhandler_base_overlapped::wait_overlapped): Move EPIPE handling under error condition. 2011-05-30 Ryan Johnson * dll_init.cc (reserve_upto): Remove. (release_upto): Ditto. (dll_list::reserve_space): New function to reserve space needed by DLL_LOAD dlls early in the fork process. (dll_list::load_after_fork): Rewrite to use recursion to track reservations it makes while trying to make dlls land where they belong. (dll_list::load_after_fork_impl): New function used by load_after_fork. (dll_list::alloc): Initialize image base field. * dll_init.h (dll_list::prefered_base): New field. (dll_list::reserve_space): Declare new function. (dll_list::load_after_fork): Declare new function. * fork.cc (frok::child): call dll_list::reserve_space early, so we can retry if it fails. 2011-05-30 Tor Perkins * fhandler_termios.cc (fhandler_termios::bg_check): Do not return EIO when a process group has no leader as this is allowed and does not imply an orphaned process group. Add a test for orphaned process groups. (tty_min::is_orphaned_process_group): Define new function. * tty.h (tty_min::is_orphaned_process_group): Define new function. 2011-05-30 Ryan Johnson * dll_init.cc (dll_list::find_by_modname): New function to search the dll list for a module name only (no path). (dll_list::alloc): Initialize newly-added members of struct dll. (dll_list::append): New function to factor out the append operation (used by dll_list::topsort). (dll_list::populate_deps): New function to identify dll dependencies. (dll_list::topsort): New function to sort the dll list topologically by dependencies. (dll_list::topsort_visit): New helper function for the above. * dll_init.h (dll::ndeps): New class member. (dll::deps): Ditto. (dll::modname): Ditto. (dll_list::find_by_modname): New function related to topsort. (dll_list::populate_all_deps): Ditto. (dll_list::populate_deps): Ditto. (dll_list::topsort): Ditto. (dll_list::topsort_visit): Ditto. (dll_list::append): Ditto. (pefile): New struct allowing simple introspection of dll images. * fork.cc (fork): Topologically sort the dll list before forking 2011-05-30 Christopher Faylor * child_info.h (CURR_CHILD_INFO_MAGIC): Refresh. (child_info::refresh_cygheap): New function. * spawn.cc (spawn_guts): Call refresh_cygheap before creating a new process to ensure that cygheap_max is up-to-date. * fork.cc (frok::parent): Ditto. 2011-05-30 Christopher Faylor * cygheap.cc (cygheap_dummy): Rename from cygheap_at_start. (cygheap): Accommodate name change to cygheap_dummy. (cygheap_init): Ditto. (cygheap_fixup_in_child): Simplify slightly. * fork.cc (fork): Add an advisory comment. 2011-05-29 Christopher Faylor * fhandler.cc (fhandler_overlapped::wait_overlapped): Make sure that I/O is cancelled on signal. 2011-05-28 Ryan Johnson * dll_init.cc (dll_list::alloc): Initialize dll::image_size. (reserve_at): Don't reserve space needed by the target dll if the latter overlaps the free region to be blocked. (dll_list::load_after_fork): Use new version of reserve_at. * dll_init.h (dll::image_size): New member. (pefile): New struct. 2011-05-28 Christopher Faylor Ryan Johnson * dll_init.c (dll_list::load_after_fork): Don't clear in_forkee here. * fork.cc (frok::errmsg): Rename from 'error'. (frok::error): New function. Handle conditional printing of error messages. (frok::parent): Record hchild handle for use by error function. Use throughout. Use error function rather than setting error pointer directly. (fork): Clear is_forkee here. Accommodate rename of 'error' to 'errmsg'. * sigproc.cc (child_info::proc_retry): Detect EXITCODE_FORK_FAILED. 2011-05-28 Christopher Faylor * fhandler.cc (handler_base_overlapped::wait_overlapped): Rework to attempt to properly set errno and bytes read for non-blocking case. Change to just rely on res to indicate error conditions. 2011-05-28 Christopher Faylor * fhandler.cc (fhandler_base_overlapped::wait_overlapped): Don't set io_pending unless ReadFile has returned an error. (this is a partial fix, accidentally checked in) 2011-05-28 Christopher Faylor * autoload.cc: Call _api_fatal in asm. * child_info.h: Redefine CURR_CHILD_INFO_MAGIC. (child_info_fork::abort): Rename from handle_failure. Change arguments. * cygtls.h (_local_storage::ttybuf): New field. * dcrt0.cc (vapi_fatal): Split api_fatal. Add "in forked process" to message when appropriate. (api_fatal): Use vapi_fatal. * devices.h: Make multiple inclusion safe. (fh_devices): Add FH_CONS* stuff. Reorder slightly. (device): Eliminate anonymous union. Add more ways to access minor/major. (device::setunit): Accommodate no-longer-anonymous union. (device::is_fs): Ditto. (device::is_fs_special): Ditto. (device::major): New function. (device::minor): Ditto. (device::is_device): New function. (device::not_device): Ditto. (device::operator int): New operator. (device::operator fh_devices): Ditto. (device::operator bool): Ditto. (device::operator DWORD): Ditto. (device::operator =): Ditto. (isproc_dev): New function. (isprocsys_dev): Ditto. (iscons_dev): Ditto. (istty_slave_dev): Ditto. * devices.in: Add new "/dev/cons*" strings. Accommodate no-longer-anonymous union throughout. (BRACK): Use more precise method for initialization. * devices.cc: Regenerate. * dtable.cc (dtable::stdio_init): Use get_cttyp instead of get_tty. (dtable::find_archetype): Use new DWORD operator in device to test archetypes. (dtable::init_std_file_from_handle): Use different method to initialize 'dev'. Adapt to different ctty handling and accommodate /dev/cons*. (fh_alloc): Accommodate no-longer-anonymous union. Adapt to new /dev/cons*. (build_fh_pc): Make debugging output more useful. * exceptions.cc (ctrl_c_handler): Use get_cttyp instead of get_tty. * external.cc (fillout_pinfo): Accommodate new cons* stuff. * fhandler.cc (fhandler_base::read): Eliminate is_slow() test. * fhandler.h (fhandler_base::*): Adapt to changes in device.h. (fhandler_*::is_slow): Delete. ( fhandler_proc::get_proc_fhandler): Return fh_devices type. * fhandler_console.cc (open_shared_console): New function. (console_unit): New class. (console_unit::console_unit): New constructor. (enum_windows): New function. Declare as friend to console_unit. (fhandler_console::set_unit): New function. (fhandler_console::get_tty_stuff): Call set_unit to set the unit number and determine if initialization is needed. Eliminate flags parameter. (tty_list::get_cttyp): Rename (sorta) from get_tty. Return pointer to correct tty_min. (fhandler_console::open): Adapt to elimination of argument to get_tty_stuff. (fhandler_console::output_tcsetattr): Properly detect error condition. (fhandler_console::fixup_after_fork_exec): Adapt to get_tty_stuff() setting tc automatically. * fhandler_proc.cc: Use FH_BAD rather than 0 throughout where using fh_devices enum. (fhandler_proc::get_proc_fhandler): Return fh_devices. Adapt to devices.h changes. * fhandler_process.cc: Adapt to devices.h changes. Use FH_BAD rather than 0 throughout where using fh_devices enum. * fhandler_procnet.cc: Ditto. * fhandler_procsys.cc: Ditto. * fhandler_procsysvipc.cc: Ditto. * fhandler_tape.cc (fhandler_dev_tape::fhandler_dev_tape): Ditto. * fhandler_termios.cc (handler_termios::bg_check): Use tc->ttyname() rather than assuming that we can construct a tty. * fhandler_tty.cc (fhandler_tty_master::fhandler_tty_master): Just return get_minor() of dev. (fhandler_pty_master::process_slave_output): Add slightly more debugging info. (fhandler_tty_slave::fhandler_tty_slave): Change name from ntty to unit. (fhandler_pty_master::open): Ditto. (fhandler_tty_slave::ioctl): Adapt to change which causes ctty to represent a complete device. (fhandler_tty_master::init_console): Add debugging for failure path. (fhandler_pty_master::setup): Use get_unit() to retrieve unit number rather than relying on raw ntty. (fhandler_pty_master::setup): Ditto. * fhandler_virtual.h (virt_tab_t): Redefine fhandler as fh_devices. * fork.cc: Remove obsolete vfork stuff. (frok::child): Don't assume that a ctty == 0 is valid. * mount.cc (mount_info::conv_to_win32_path): Adapt to device struct changes. (mount_info::conv_to_win32_path): Ditto. * path.cc (path_conv::check): Retrive major/minor numbers via a method rather than accessing them directly from device. Rely on dev operators to set/retrieve device information as required by device struct change. * path.h (isproc_dev): Move to devices.h. (isprocsys_dev): Ditto. (isvirtual_dev): Ditto. (path_conv:{isdevice,isfifo,isspecial,iscygdrive,issocket,get_devn,get_unitn}): Use device methods to access/manipulate devices. * pinfo.cc (pinfo::exit): Don't assume that ctty == 0 is valid. Use iscons_dev to determine if a device is a console. (_pinfo::_ctty): Use device::parse to generate tty/cons name. (_pinfo::set_ctty): Don't assume that ctty == 0 is valid. Remove redundant info from debugging. * shared.cc (offsets): Remove console offset. * shared_info.h (shared_locations): Ditto. * syscalls.cc (umask): Use device methods to manipulate device information. (ctermid): Use device::parse to generate term device name. * tlsoffsets.h: Regenerate. * tty.cc (ttyslot): Return minor number of ctty since ctty now represents a full device. (tty::create_master): Set ctty to a complete device. (tty_list::attach): Rework to detect new /dev/cons* stuff. (tty_list::terminate): Adapt to changes to ctty. (tty_list::init): Adapt to change to setntty - pass in device major number. (tty::exists): Use get_unit() to retrive tty unit number. (tty::open_mutex): Ditto. (tty::open_inuse): Ditto. (tty::create_inuse): Ditto. (tty::get_event): Ditto. (tty_min::ttyname): Define new function. * tty.h (tty_min::ntty): Redefine as fh_devices. (tty::exists): Use get_unit() to retrive tty unit number. (tty::open_mutex): Ditto. (tty::open_inuse): Ditto. (tty::create_inuse): Ditto. (tty::get_event): Ditto. (tty_min::ttyname): Declare new function. (tty::getntty): Declare as const. (tty_list::operator []): Assure that only minor part of argument is used. * dll_init.cc (dll_list::alloc): Detect mismatch of data segments early issuing an explicit error message if necessary. * heap.cc (heap_init): Adapt to changes from fork->handle_failure to fork->abort. * pinfo.h (EXITCODE_FORK_FAILED): New enum. (from Ryan Johnson) * sigproc.cc (child_info_fork::abort): Rename from handle_failure. Change arguments to allow passing in a printf-like message. * winsup.h (api_fatal): Delete macro definition. (api_fatal): Redefine from __api_fatal. (vapi_fatal): Declare new function. * include/sys/strace.h (strace_vprintf): Define new macro. * ntdll.h (_SYSTEM_INFORMATION_CLASS): Add SystemHandleInformation. 2011-05-27 Corinna Vinschen * shared.cc (offsets): Reorder so that console_state is lowest in memory. Explain why. (open_shared): Accommodate reordering of offsets array. * shared_info.h (shared_locations): Reorder SH_SHARED_CONSOLE after SH_MYSELF. 2011-05-26 Corinna Vinschen * mount.h (MAX_MOUNTS): Raise to 64. 2011-05-25 Eric Blake * cygtls.h (strerror_r_buf): New buffer. * errno.cc (strerror): Move guts... (_strerror_r): ...to new function demanded by newlib. (strerror_r): Don't clobber strerror buffer. (_user_strerror): Drop unused declaration. * tlsoffsets.h: Regenerate. 2011-05-25 Corinna Vinschen * init.cc (dll_entry): Reinstantiate wow64_test_stack_marker and previous stack tests. 2011-05-25 Corinna Vinschen * posix.sgml (std-notes): Add missing . 2011-05-24 Corinna Vinschen * mount.cc (mount_info::conv_to_win32_path): Remove unused code. * mount.h (class mount_info): Remove sys_mount_table_counter member. * shared_info.h (class shared_info): Ditto. (CURR_SHARED_MAGIC): Update. 2011-05-24 Corinna Vinschen * pinfo.h (struct _pinfo): Reduce size of progname array slightly. Explain why. 2011-05-23 Eric Blake * errno.cc (strerror): Print unknown errno as int. (__xpg_strerror_r): Likewise, and don't clobber strerror buffer. * cygtls.h (strerror_buf): Resize to allow '-'. 2011-05-23 Corinna Vinschen * fhandler_process.cc (thread_info::fill_if_match): Reformat. (format_process_maps): Ditto. Fetch pointer to procinfo structure from mapped process. Print info about global shared Cygwin regions. 2011-05-21 Corinna Vinschen * fhandler_process.cc (struct dos_drive_mappings): Use malloc/free rather than cmalloc/cfree. Check return value from malloc before using it. (struct heap_info): Ditto. (struct thread_info): Ditto. Rename from stack_info. Rename members and local variables accordingly. (thread_info::thread_info): Store stack and TEB addresses. (thread_info::fill_if_match): Print "teb" if a TEB address has been found. Special case for WOW64, explain why. (format_process_maps): Fetch PEB address. Print MEM_RESERVE regions with equal signs to distinguish them from PAGE_NOACCESS regions. Fix printing of 'p' and 's' to differ between MEM_PRIVATE and MEM_MAPPED pages, as on Linux. Print 'g' instead of 'p for PAGE_GUARD pages. Print PEB and SharedUserData area if recognized. 2011-05-20 Corinna Vinschen * miscfuncs.cc (CygwinCreateThread): Fix condition for adding the guardsize to the stacksize. Fix accompanying comment. 2011-05-20 Corinna Vinschen * miscfuncs.cc (CygwinCreateThread): Add accidentally missing comment. 2011-05-20 Corinna Vinschen * fhandler_process.cc (struct heap_info): Change type of base and end members to char *. Print "shared" rather than "share". (struct stack_info): New class to fetch process stack information. (format_process_maps): Initialize and check for stack information. 2011-05-20 Corinna Vinschen * miscfuncs.cc (thread_wrapper): Remove statements added for debugging purposes. 2011-05-20 Corinna Vinschen * child_info.h (CURR_CHILD_INFO_MAGIC): Update. (class child_info_fork): Remove stacksize, add stackaddr and guardsize members. * dcrt0.cc (child_info_fork::alloc_stack_hard_way): Partial rewrite to regenerate the stack exactly as in the parent. (child_info_fork::alloc_stack): Set stackaddr to 0, rather than stacksize. (dll_crt0_1): Check for stackaddr before changing the stack addresses in the TEB. * fork.cc (frok::child): Check for stackaddr here. (frok::parent): Set ch.stackaddr and ch.guardsize if not called from the main thread. * init.cc (dll_entry): Replace pointer to NT_TIB with pointer to TEB. Fix incorrectly changed address test before removing _my_tls. Set StackLimit to NULL on Windows 2000. Explain why. * miscfuncs.cc (struct thread_wrapper_arg): Store stackbase rather than stacksize, store commitaddr, remove guardsize. Store all pointers as char * for easier address arithmetic. (thread_wrapper): Rewrite to remove OS stack before calling thread function. Add lots of comments to explain what we do. (CygwinCreateThread): Reserve our own stack in case we got no application stack. Add comments. * ntdll.h (struct _TEB): Extend defintion up to DeallocationStack member. * thread.cc (pthread_attr::pthread_attr): Use "(size_t) -1" rather then 0xffffffff. * wincap.h (wincaps::has_stack_size_param_is_a_reservation): New element. * wincap.cc: Implement above element throughout. 2011-05-19 Yaakov Selkowitz * thread.cc: Mark psiginfo and psignal as available in list of optional cancellation points. 2011-05-19 Yaakov Selkowitz * cygwin.din (__fpurge): Export. * posix.sgml (std-solaris): Add __fpurge. * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump. 2011-05-18 Yaakov Selkowitz * posix.sgml (std-susv4): Remove chroot, futimes, hstrerror. (std-deprec): Add chroot. (std-bsd): Add futimes, hstrerror. (std-notimpl): Add clock_nanosleep, nexttoward, nexttowardf. Remove initstate, which is implemented and listed in std-susv4. 2011-05-17 Yaakov Selkowitz * cygwin.din (error): Export. (error_at_line): Export. (error_message_count): Export. (error_one_per_line): Export. (error_print_progname): Export. * errno.cc (error_message_count): Define. (error_one_per_line): Define. (error_print_progname): Define. (_verror): New static function. (error): New function. (error_at_line): New function. * posix.sgml (std-gnu): Add error, error_at_line. * include/error.h: New header. * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump. 2011-05-17 Yaakov Selkowitz * cygwin.din (clock_getcpuclockid): Export. (pthread_getcpuclockid): Export. * hires.h (PID_TO_CLOCKID): New macro. (CLOCKID_TO_PID): New macro. (CLOCKID_IS_PROCESS): New macro. (THREADID_TO_CLOCKID): New macro. (CLOCKID_TO_THREADID): New macro. (CLOCKID_IS_THREAD): New macro. * ntdll.h (enum _THREAD_INFORMATION_CLASS): Add ThreadTimes. * posix.sgml (std-notimpl): Add clock_getcpuclockid and pthread_getcpuclockid from here... (std-susv4): ... to here. (std-notes): Remove limitations of clock_getres and clock_gettime. Note limitation of timer_create to CLOCK_REALTIME. * sysconf.cc (sca): Set _SC_CPUTIME to _POSIX_CPUTIME, and _SC_THREAD_CPUTIME to _POSIX_THREAD_CPUTIME. * thread.cc (pthread_getcpuclockid): New function. * timer.cc (timer_create): Set errno to ENOTSUP for CPU-time clocks. * times.cc (clock_gettime): Handle CLOCK_PROCESS_CPUTIME_ID and CLOCK_THREAD_CPUTIME_ID. (clock_getres): Ditto. (clock_settime): Set errno to EPERM for CPU-time clocks. (clock_getcpuclockid): New function. * include/pthread.h (pthread_getcpuclockid): Declare. * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump. 2011-05-17 Corinna Vinschen * miscfuncs.cc (thread_wrapper): Remove unused _cygtls record. * mmap.cc (is_mmapped_region): Avoid crash if no mmaps exist. 2011-05-16 Corinna Vinschen * globals.cc (__getlogin_username): Remove. * uinfo.cc (getlogin_r): Fetch username from cygheap. (getlogin): Add static buffer username and fetch username from getlogin_r. 2011-05-16 Corinna Vinschen * cygtls.h (struct _local_storage): Remove unused members rarg and _localtime_buf. Remove username in favor of a global buffer. Reorder slightly to keep the net.cc stuff together. * globals.cc (__getlogin_username): New global char buffer. * tlsoffsets.h: Regenerate. * uinfo.cc (getlogin): Copy username into __getlogin_username. 2011-05-16 Corinna Vinschen * heap.cc (heap_init): Rewrite initial heap allocation to use addresses beyond 0x20000000. Explain why and how. * shared.cc (shared_info::heap_slop_size): Remove. * shared_info.h (class shared_info): Remove heap_slop_inited and heap_slop members. Remove heap_slop_size declaration. (CURR_SHARED_MAGIC): Update. * wincap.cc: Throughout, drop heapslop. * wincap.h (struct wincaps): Drop heapslop. 2011-05-16 Corinna Vinschen * dcrt0.cc (child_info_fork::alloc_stack_hard_way): Check if the requested stack is application-provided within the user heap or an mmapped region. If so, just use it. Add comment to explain why. * miscfuncs.cc (thread_wrapper): If an application-provided stack has been given, implement cygtls area at the stackbase. Fix comment. * mmap.cc (is_mmapped_region): New function. * winsup.h (is_mmapped_region): Declare. 2011-05-15 Corinna Vinschen * miscfuncs.cc (thread_wrapper): Add comments to assembler code. 2011-05-15 Corinna Vinschen * cygwin.din (pthread_attr_getguardsize): Export. (pthread_attr_setguardsize): Export. (pthread_attr_setstack): Export. (pthread_attr_setstackaddr): Export. * init.cc (dll_entry): Remove wow64_test_stack_marker. Check for unusual stack address by testing stack addresses from current TEB. Check validity of _my_tls by testing if it's within the stack as given in current TEB. * miscfuncs.cc (struct thread_wrapper_arg): New structure used to push all required information to thread_wrapper function. (thread_wrapper): Wrapper function for actual thread function. If an application stack has been given, change %ebp and %esp so that the thread function runs on that stack. If the thread has been created by CygwinCreateThread, set up the POSIX guard pages if necessary. (CygwinCreateThread): New function. * miscfuncs.h (CygwinCreateThread): Declare. * ntdll.h (struct _TEB): Define all members up to Peb. * posix.sgml (std-susv4): Move pthread_attr_getguardsize, pthread_attr_setguardsize and pthread_attr_setstack here. (std-deprec): Add pthread_attr_setstackaddr. * sysconf.cc (sca): Set _SC_THREAD_ATTR_STACKADDR to _POSIX_THREAD_ATTR_STACKADDR. * thread.cc (pthread::precreate): Copy pthread_attr stackaddr and guardsize members. (pthread::create): Call CygwinCreateThread. (pthread_attr::pthread_attr): Initialize guardsize. (pthread_attr_setstack): New function. (pthread_attr_setstackaddr): New function. (pthread_attr_setguardsize): New function. (pthread_attr_getguardsize): New function. (pthread_getattr_np): Copy attr.guardsize. * thread.h (pthread_attr): Add member guardsize. * include/pthread.h (pthread_attr_getguardsize): Declare. (pthread_attr_setguardsize): Declare. * include/cygwin/version.h: Bump API minor number. 2011-05-13 Corinna Vinschen * fhandler_process.cc (struct heap_info::heap): Convert base to uintptr_t. Add heap_id, end, flags members. (heap_info::heap_vm_chunks): Rename from heaps. (heap_info::heap_info): Rearrange using RtlQueryProcessDebugInformation to get information of heap virtual memory blocks. Store heap id and flags, as well as end address of each block. (heap_info::fill_if_match): Check incoming base address against full address range of heap chunks. Convert flag values in extra heap information. (format_process_maps): Change order so that heap check is done before MEM_MAPPED check since there are shareable heaps. * ntdll.h (PDI_HEAP_BLOCKS): Define. (HEAP_FLAG_NOSERIALIZE): Define. (HEAP_FLAG_GROWABLE): Define. (HEAP_FLAG_EXCEPTIONS): Define. (HEAP_FLAG_NONDEFAULT): Define. (HEAP_FLAG_SHAREABLE): Define. (HEAP_FLAG_EXECUTABLE): Define. (HEAP_FLAG_DEBUGGED): Define. (struct _DEBUG_HEAP_ARRAY): Define. (struct _DEBUG_HEAP_BLOCK): Define. 2011-05-12 Corinna Vinschen Based on newlib patch to strptime by Peter Rosin : * libc/time/strptime.c (is_leap_year): New static function. (first_day): Ditto. (__strptime): Fill in tm_yday when all of tm_year, tm_mon and tm_mday are updated. Fill in tm_mon, tm_mday and tm_wday when both of tm_year and tm_yday are updated. 2011-05-12 Yaakov Selkowitz * fhandler_proc.cc (format_proc_meminfo): Rewrite to use sysinfo(). Support RAM and swap space larger than 4GB. Remove output elements not found with modern Linux kernels. (format_proc_swaps): Support paging files larger than 4GB. 2011-05-11 Corinna Vinschen * autoload.cc: Remove useless comment. 2011-05-11 Corinna Vinschen * autoload.cc (EnumProcessModules): Remove. * dlfcn.cc (dlopen): Make sure errno is set if an error occurs. (dlsym): Rewrite using RtlQueryProcessDebugInformation instead of EnumProcessModules. * ntdll.h (struct _DEBUG_MODULE_ARRAY): Define. (RtlCreateQueryDebugBuffer): Declare. (RtlDestroyQueryDebugBuffer): Declare. (RtlQueryProcessDebugInformation): Declare. 2011-05-11 Corinna Vinschen * autoload.cc (GetModuleFileNameExW): Remove. * autoload.cc (GetModuleInformation): Remove. 2011-05-11 Corinna Vinschen * autoload.cc (QueryWorkingSet): Remove. 2011-05-11 Ryan Johnson * fhandler_process.cc (format_process_maps): Rework to report all mapped address space in a process (committed or reserved), identifying the nature of the mapping (mapped file/image, heap, shared memory) when possible. (dos_drive_mappings): New helper classes. (heap_info): Ditto. * ntdll.h (struct _MEMORY_SECTION_NAME): Define. 2011-05-11 Corinna Vinschen * autoload.cc (GetProcessMemoryInfo): Remove. * resource.cc (fill_rusage): Call NtQueryInformationProcess rather than GetProcessMemoryInfo to drop a psapi dependency. 2011-05-11 Corinna Vinschen * fhandler_socket.cc (get_inet_addr): Rearrange for better readability. Make waiting loop interruptible and cancelable. Check for SYSTEM DOS flag before reading the file. Change return value to return 0 on success, SOCKET_ERROR on failure. (fhandler_socket::bind): Only set R/O DOS flag on filesystems not supporting ACLs. (fhandler_socket::connect): Accommodate changed return values from get_inet_addr. Use SOCKET_ERROR instead of -1. (fhandler_socket::sendto): Accommodate changed return values from get_inet_addr. * syslog.cc (connect_syslogd): Ditto. 2011-05-10 Christian Franke * security.cc (check_registry_access): Handle missing security descriptor of HKEY_PERFORMANCE_DATA. 2011-05-10 Corinna Vinschen * lc_msg.h: Regenerate. 2011-05-10 Corinna Vinschen * fhandler_proc.cc (format_proc_uptime): Don't call GetSystemInfo. Fetch CPU count from wincap. (format_proc_stat): Ditto. * globals.cc (system_info): Move to wincap. * heap.cc (heap_init): Fetch page size from wincap. * syscalls.cc (getpagesize): Fetch allocation granularity from wincap. (getsystempagesize): Fetch page size from wincap. * wincap.cc (wincap_2003): Default is_server to false. (wincapc::init): Call GetSystemInfo here. Always set is_server value. * wincap.h (class wincapc): Add system_info as private member. (wincapc::cpu_count): New public method. (wincapc::page_size): Ditto. (wincapc::allocation_granularity): Ditto. 2011-05-10 Corinna Vinschen * environ.cc (set_chunksize): Remove. (parse_thing): Remove forkchunk entry. * fork.cc (child_copy): Drop handling external chunksize setting. * wincap.cc: Througout, drop chunksize. (wincapc::set_chunksize): Remove. * wincap.h (struct wincaps): Drop chunksize and declaration of set_chunksize. 2011-05-08 Yaakov Selkowitz * times.cc (settimeofday): Add EFAULT handler. Set errno to EINVAL if tv.tv_nsec is invalid, and to EPERM if SetSystemTime fails. Return -1 in case of failure, all for compatibility with BSD and Linux. (clock_settime): New function. * cygwin.din (clock_settime): Export. * posix.sgml (std-susv4): Add clock_settime. Move clock_setres from here... (std-deprec): ... to here. (std-notes): Correct limitation of clock_setres to only CLOCK_REALTIME. Add limitation of clock_settime to only CLOCK_REALTIME. * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump. 2011-05-07 Corinna Vinschen * registry.cc (get_registry_hive_path): Change system_printf to debug_printf. (load_registry_hive): Ditto. 2011-05-06 Christopher Faylor * fhandler.h (fhandler_base::close_with_arch): Make non-virtual. (fhandler_base::open_fs): Move closer to it's close counterpart. 2011-05-06 Christopher Faylor * fhandler.cc (fhandler_base::dup): Avoid duping a handle when an fhandler has an archetype. * fhandler_console.cc (fhandler_console::invisible_console): Move to the top. (fhandler_console::set_close_on_exec): Don't set close-on-exec on handle since it's an archetype and you don't know how many things could be using it. 2011-05-06 Christopher Faylor * fhandler.h (fhandler_dev_dsp): Cosmetic change. * fhandler_tty.cc (fhandler_pty_master::process_slave_output): Put back Sleep(10) for tty_master case. * sigproc.cc (stopped_or_terminated): Don't consider a pid which has been reaped to be terminated. 2011-05-06 Yaakov Selkowitz * sysconf.cc (sysinfo): New function. * cygwin.din (sysinfo): Export. * posix.sgml (std-gnu): Add sysinfo. * include/sys/sysinfo.h (struct sysinfo): Define. (sysinfo): Declare. * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump. 2011-05-06 Corinna Vinschen * libc/minires-os-if.c (get_dns_info): Drop printing uninitialized value of dwRetVal in debug output. 2011-05-06 Corinna Vinschen * fhandler.h (fhandler_socket::read): Declare. (fhandler_socket::write): Declare. * fhandler_procsys.cc (fhandler_procsys::read): Add FIXME comment. (fhandler_procsys::write): Ditto. * fhandler_socket.cc (fhandler_socket::read): New method. (fhandler_socket::write): New method. * syscalls.cc: Rearrange order of read/write functions. (read): Call fhandler read method directly instead of just readv. (readv): Remove EINTR loop. This is done in all affected fhandler's now. (write): Call fhandler write method directly instead of just writev. Fix debug output. 2011-05-05 Christopher Faylor * cygheap.cc (cygheap::close_ctty): Close ctty via close_with_arch(). * debug.cc (close_handle): Call debugger on failure. * devices.in (device::tty_to_real_device): Delete. * devices.h (device::tty_to_real_device): Ditto. * devices.cc: Regenerate. * dtable.cc: Delete old ifdef'ed vfork code. (dtable::release): Don't handle archetype here. (dtable::init_std_file_from_handle): Consolidate console tests. Generate major/minor for tty ASAP. Fix incorrect setting of DEV_TTYS* for serial. (fh_alloc): New function derived from build_fh_pc. Pass current tty when building tty. (build_pc_pc): Use fh_alloc to create. Set name from fh->dev if appropriate. Generate an archetype or point to one here. (dtable::dup_worker): Deal with archetypes. Rely on = operator copying whole class rather than just fhandler_base. (dtable::fixup_after_exec): Call close_with_arch to handle closing of fhandlers with archetypes. * fhandler.cc (fhandler_base::operator =): Call memcpy with fhandler's size() rather than sizeof fhandler_base. (fhandler_base::open_with_arch): New function. Handles opening of fhandler's with archetypes, dealing with usecounts, etc. (fhandler_base::close_with_arch): Ditto for close. * fhandler.h: Many changes for archetypes. (fhandler_base::set_name): Set both normalized path and regular path. (fhandler_base::open_with_arch): New function. (fhandler_base::open_setup): Ditto. (fhandler_base::use_archetype): Ditto. (fhandler_base::_archetype_usecount): Ditto. (fhandler_*::size): Ditto. (fhandler_dev_tape::open): Remove virtual decoration. (fhandler_console::use_archetype): New function. Return true. (fhandler_console::open_setup): New function. (fhandler_console::dup): Delete. (fhandler_tty_slave::fhandler_tty_slave): Redeclare to take an argument. (fhandler_tty_slave::use_archetype): New function. Return true. (fhandler_tty_slave::cleanup): New function. (fhandler_pty_master::use_archetype): New function. Return true. (fhandler_pty_master::cleanup): New function. (fhandler_pty_master::is_tty_master): New function. Return false. (fhandler_tty_master::is_tty_master): New function. Return true. (fhandler_dev_dsp::fhandler_dev_dsp): New function. Return true. (report_tty_counts): Only report on archetype's usecount if there is one. * fhandler_console.cc (fhandler_console::get_tty_stuff): Remove handling of setsid, set_ctty, set_flags, and manage_console_count. (fhandler_console::open_setup): New function. Implement functionality removed from get_tty_stuff. (fhandler_console::dup): Delete. (fhandler_console::output_tcsetattr): Set errno on error. (fhandler_console::fhandler_console): Set device early. (fhandler_console::init): Use open_with_arch to open console handles. (fhandler_console::fixup_after_fork_exec): Nuke most of the stuff for dealing with console handles. * fhandler_dsp.cc (fhandler_dev_dsp::open): Remove archetype handling. (fhandler_dev_dsp::write): Ditto. (fhandler_dev_dsp::read): Ditto. (fhandler_dev_dsp::close): Ditto. (fhandler_dev_dsp::dup): Ditto. (fhandler_dev_dsp::ioctl): Ditto. (fhandler_dev_dsp::fixup_after_fork): Ditto. (fhandler_dev_dsp::fixup_after_exec): Ditto. * fhandler_tty.cc (fhandler_tty_common::__acquire_output_mutex): Add a little more debugging. (fhandler_tty_common::__release_output_mutex): Ditto. (fhandler_pty_master::process_slave_output): Ditto. Don't do signal handling or pthread_cancel handling in the tty master thread. (process_output): Minor reorg. (fhandler_tty_slave::fhandler_tty_slave): Set device based on new ntty argument. (fhandler_tty_slave::open): Remove archetype handling. Move some processing into open_setup(). (fhandler_tty_slave::open_setup): New function. (fhandler_tty_slave::cleanup): New function. (fhandler_tty_slave::close): Remove archetype handling. Move some processing into cleanup(). (fhandler_tty_slave::init): Rename argument from f to h. Open device using open_with_arch(). Remove archetype handling. (fhandler_pty_master::dup): Ditto. (fhandler_pty_master::open): Ditto. (fhandler_pty_master::close): Ditto. Move some handling to cleanup(). (fhandler_pty_master::cleanup): New function. (fhandler_tty_master::init_console): Give unique name to captive console fhandler. * pinfo.cc (_pinfo::set_ctty): Rename argument from arch to fh. Eliminate archetype assumption. * syscalls.cc (close_all_files): Use close_with_arch for closing. (open): Use open_with_arch() rather than open(). (close): Use close_with_arch() rather than close(). 2011-05-05 Corinna Vinschen * pinfo.h (class push_process_state): New class to push a process state flag temporarily into myself->process_state. * fhandler_console.cc (fhandler_console::read): Add push_process_state handler. (fhandler_console::write): Call bg_check from here. Add push_process_state handler. * fhandler_tty.cc (fhandler_tty_slave::write): Ditto. (fhandler_tty_slave::read): Ditto. (fhandler_pty_master::write): Ditto. (fhandler_pty_master::read): Ditto. * syscalls.cc (readv): Remove bg_check call and setting process state. (writev): Ditto. 2011-05-05 Corinna Vinschen * syscalls.cc (readv): Add myfault handler. Don't check repeatedly open state of file handler. Streamline loop. (writev): Add myfault handler. 2011-05-05 Christopher Faylor * fhandler.cc (fhandler_base_overlapped::raw_read): Rename from read_overlapped. (fhandler_base_overlapped::raw_e): Rename from write_overlapped. * fhandler.h (fhandler_*::raw_read): Add reparm decoration. (fhandler_*::raw_write): Ditto. (fhandler_base_overlapped::raw_read): Rename from read_overlapped. (fhandler_base_overlapped::raw_write): Rename from write_overlapped. (fhandler_pipe::raw_read): Delete. (fhandler_pipe::raw_write): Ditto. (fhandler_mailslot::raw_read): Ditto. * fhandler_fifo.cc (fhandler_fifo::raw_read): Reflect read_overlapped -> raw_read rename. (fhandler_fifo::raw_write): Ditto. * fhandler_mailslot.cc (fhandler_mailslot::raw_read): Delete. (fhandler_mailslot::raw_write): Reflect read_overlapped -> raw_read rename. * pipe.cc (fhandler_pipe::raw_read): Delete. (fhandler_pipe::raw_write): Ditto. 2011-05-05 Christopher Faylor * fork.cc (fork): Clear PID_REAPED. * pinfo.cc (pinfo_init): Ditto. (pinfo::init): Check for PID_REAPED. * sigproc.cc (stopped_or_terminated): Ditto. 2011-05-05 Christopher Faylor * pinfo.cc (_pinfo::exists): Check for PID_REAPED. 2011-05-05 Corinna Vinschen * fhandler_disk_file.cc (fhandler_disk_file::pread): Correctly return with errno set to EBADF if file open mode is incorrect. (fhandler_disk_file::pwrite): Ditto. 2011-05-05 Corinna Vinschen * fhandler.cc (is_at_eof): Drop static storage class. Drop err parameter since we don't change the Win32 error here anymore. (fhandler_base::raw_read): Accommodate change to is_at_eof. * fhandler_disk_file.cc (fhandler_disk_file::pread): In binary mode use direct call to NtReadFile, rather than lseek/read. (fhandler_disk_file::pwrite): In binary mode use direct call to NtWriteFile, rather than lseek/write. 2011-05-05 Corinna Vinschen * dcrt0.cc (dll_crt0_1): Reset locale to "C" even when dynamically loaded. 2011-05-05 Yaakov Selkowitz * posix.sgml (std-notimpl): Remove bsd_signal, setcontext, and swapcontext, marked obsolete in SUSv3 and not present in SUSv4. 2011-05-05 Christian Franke * fhandler_registry.cc (fhandler_registry::exists): Fix regression in EACCES handling. (fhandler_registry::open): Fix "%val" case. 2011-05-04 Christopher Faylor * signal.cc (_pinfo::kill): Return success on kill(0) only if pid exists or is in PID_EXITED state. Report pid 0 when pid does not exist rather than pid -1. Make debug output reflect actual function call. * sigproc.cc (stopped_or_terminated): Set process state to reaped when we've finished waiting for it. * include/sys/cygwin.h (PID_REAPED): New enum. 2011-05-04 Yaakov Selkowitz * cygwin.din (psiginfo): Export. (psignal): Export. (sys_siglist): Export. * posix.sgml (std-notimpl): Move psiginfo and psignal from here... (std-susv4): ... to here. (std-deprec): Add sys_siglist. * strsig.cc (sys_siglist): New array. (psiginfo): New function. * include/cygwin/signal.h (sys_siglist): Declare. (psiginfo): Declare. * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump. 2011-05-04 Christopher Faylor * dll_list::detach (dll_list::detach): Avoid doing anything with detach during a failing fork. 2011-05-04 Christopher Faylor * dll_init.cc (dll_global_dtors): Avoid calling destructors during failing fork(). 2011-05-04 Corinna Vinschen * fhandler.h (class fhandler_base): Remove uninterruptible_io status flag. (fhandler_base::ready_for_read): Remove declaration. (fhandler_socket::ready_for_read): Ditto. (fhandler_pipe::ready_for_read): Ditto. (fhandler_tty_master::is_slow): Remove. * fhandler_console.cc (fhandler_console::open): Drop setting uninterruptible_io. * fhandler_serial.cc (fhandler_serial::open): Ditto. * fhandler_tty.cc (fhandler_tty_slave::fhandler_tty_slave): Ditto. (fhandler_tty_master::init_console): Ditto. * pipe.cc (fhandler_pipe::fhandler_pipe): Ditto. (fhandler_pipe::open): Ditto. (_pipe): Ditto. * select.cc (fhandler_pipe::ready_for_read): Remove. (fhandler_base::ready_for_read): Remove. * syscalls.cc (readv): Drop unneeded wait variable. Remove entire test which might lead to calling ready_for_read. Remove now unused label out. 2011-05-04 Corinna Vinschen * fhandler.h (class fhandler_mailslot): Move down in file and change parent class to fhandler_base_overlapped. Remove declaration of method write. Add declaraiotns for raw_read and raw_write. * fhandler_mailslot.cc (fhandler_mailslot::fhandler_mailslot): Call fhandler_base_overlapped constructor. (fhandler_mailslot::fstat): Call fhandler_base_overlapped::fstat. (fhandler_mailslot::open): Drop FILE_SYNCHRONOUS_IO_NONALERT flag from call to NtOpenFile. (fhandler_mailslot::raw_read): New method. (fhandler_mailslot::raw_write): Ditto. Take over length algorithm from former write method. (fhandler_mailslot::write): Remove. (fhandler_mailslot::ioctl): Call fhandler_base_overlapped::ioctl. 2011-05-04 Corinna Vinschen * fhandler.h (fhandler_dev_tape::_lock): Add bool parameter. * fhandler_tape.cc (lock): Call _lock with false argument. (_lock): Take bool cancelable parameter. Handle O_NONBLOCK. Make cancelable if cancelabe parameter is true. (fhandler_dev_tape::raw_read): Call _lock with true argument. (fhandler_dev_tape::raw_write): Ditto. 2011-05-04 Corinna Vinschen * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add fh member. (fhandler_dev_dsp::Audio_out::Audio_out): Take pointer to encapsulating fhandler_dev_dsp as parameter. (fhandler_dev_dsp::Audio_in::Audio_in): Ditto. (fhandler_dev_dsp::Audio::Audio): Take pointer to encapsulating fhandler_dev_dsp as parameter and store in fh. (fhandler_dev_dsp::Audio_out::write): Change return type to int and return number of bytes written. Return -1 if waitforspace returns false and no bytes have been written so far. (fhandler_dev_dsp::Audio_out::waitforspace): Change return type to bool. Handle O_NONBLOCK. Make waiting loop interruptible and cancelable. Return false in any of these cases, otherwise true. (fhandler_dev_dsp::Audio_in::read): Set returned nBytes to -1 if waitfordata returns false and nothing has been read so far. (fhandler_dev_dsp::Audio_in::waitfordata): Change return type to bool. Handle O_NONBLOCK. Make waiting loop interruptible and cancelable. Return false in any of these cases, otherwise true. (fhandler_dev_dsp::write): Call Audio_out constructor with this as parameter. (fhandler_dev_dsp::read): Call Audio_in constructor with this as parameter. 2011-05-04 Christopher Faylor * thread.h (pthread::static_cancel_self): Mark as noreturn. (pthread::cancel_self): Ditto. * thread.cc (pthread::cancel_self): Explicitly use pthread::exit to avoid a "function returns" error. 2011-05-04 Christopher Faylor * pinfo.h (pinfo::pinfo): Set procinfo to NULL to avoid potential cleanup of uninitialized garbage. (Suggested by Ryan Johnson) 2011-05-03 Corinna Vinschen * select.cc (cygwin_select): Make degenerate case cancelable. (select_stuff::destroy): New inline method to delete memory taken by select_stuff. (select_stuff::~select_stuff): Call destroy. (select_stuff::wait): Add case to allow canceling select. * select.h (select_stuff::destroy): Declare. * thread.cc: Mark poll, pselect and poll as cancelable. 2011-05-03 Corinna Vinschen * fhandler.cc (fhandler_base_overlapped::wait_overlapped): Make cancelable. Remove test for main thread, always add signal_arrived to waited objects. 2011-05-03 Corinna Vinschen * fhandler_tty.cc (fhandler_tty_slave::read): Set WFMO timeout to 0 for nonblocking case. Drop useless waiter variable. Rewrite wait for input_available_event to use a switch statement. Handle timeout and failure more gracefully. Make restartable and cancelable. Rewrite wait for input_mutex to use WFMO and a switch statement. Handle timeout and failure more gracefully. Make restartable and cancelable. 2011-05-02 Christopher Faylor * signal.cc (_pinfo::kill): Avoid referencing 'pid' after ESRCH. 2011-05-02 Yaakov Selkowitz * cygwin.din (pthread_attr_getstack): Export. (pthread_attr_getstackaddr): Export. (pthread_getattr_np): Export. * ntdll.h (enum _THREAD_INFORMATION_CLASS): Add ThreadBasicInformation. (struct _THREAD_BASIC_INFORMATION): Define. (NtQueryInformationThread): Declare. * posix.sgml (std-susv4): Add pthread_attr_getstack. (std-gnu): Add pthread_getattr_np. (std-deprec): Add pthread_attr_getstackaddr. (std-notimpl): Remove pthread_attr_[gs]etstackaddr, as they were removed from SUSv4. * thread.cc (pthread_attr::pthread_attr): Initialize stackaddr. (pthread_attr_getstack): New function. (pthread_attr_getstackaddr): New function. (pthread_attr_setstacksize): Return EINVAL if passed size less than PTHREAD_STACK_MIN, as required by POSIX. (pthread_getattr_np): New function. * thread.h (class pthread_attr): Add stackaddr member. * include/pthread.h (pthread_attr_getstack): Declare. (pthread_attr_getstackaddr): Declare unconditionally. (pthread_attr_setstack): Declare inside false conditional for reference. (pthread_getattr_np): Declare. * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump. 2011-05-02 Christopher Faylor * Makefile.in: Allow CFLAGS to be overridden from the environment. 2011-05-02 Corinna Vinschen * thread.cc (cancelable_wait): Remove test for main thread. * fhandler_fifo.cc (fhandler_fifo::open_nonserver): Ditto. 2011-05-02 Corinna Vinschen * fhandler_tty.cc (andler_pty_master::process_slave_output): Make interruptible and cancelable. Fix nonblocking case. 2011-05-02 Corinna Vinschen * fhandler_console.cc (fhandler_console::read): Make restartable and cancelable. 2011-05-02 Christopher Faylor * strace.cc (strace::vprntf): Avoid closing unopened handle. 2011-05-02 Yaakov Selkowitz * sysconf.cc (sca): Set _SC_SPIN_LOCKS to _POSIX_SPIN_LOCKS. 2011-05-02 Christopher Faylor * dll_init.cc (dll_list::alloc): Reset 'p' in forked process. * select.cc (select_stuff::wait): Move cleanup() closer to WFMO to minimize unavoidable (?) race. 2011-05-02 Corinna Vinschen * fhandler_serial.cc (fhandler_serial::raw_read): Add restartability after a signal. Add cancelability. (fhandler_serial::raw_write): Wait for write to succeed if O_NONBLOCK is not set. Add signal handling and cancelability. 2011-05-01 Corinna Vinschen * fhandler_windows.cc (fhandler_windows::read): Use pthread::get_cancel_event to fetch thread's cancel event. * flock.cc (lf_setlock): Ditto. * posix_ipc.cc (ipc_cond_timedwait): Ditto. * thread.cc (pthread::get_cancel_event): New static method. * thread.h (pthread::get_cancel_event): Declare. 2011-05-01 Corinna Vinschen * libc/minires-os-if.c (get_dns_info): Remove unnecessary test for existence of DnsQuery_A. 2011-05-01 Corinna Vinschen Throughout, use user32 UNICODE functions rather than ANSI functions. * autoload.cc: Convert all definitions for ANSI user32 functions to definitions for the corresponding UNICODE function. (SendMessageA): Remove. (SendNotifyMessageW): Define. * fhandler.h (fhandler_windows::is_slow): Remove. * fhandler_windows.cc (fhandler_windows::write): Use SendNotifyMessageW call rather than SendMessage to make function always return immediately. (fhandler_windows::read): Make function interruptible and a cancellation point. Handle O_NONBLOCK. * select.cc (peek_serial): Don't wait for signal_arrived here. * window.cc (wininfo::winthread): Call CreateWindowExW directly rather than CreateWindow wrapper. 2011-05-01 Corinna Vinschen * net.cc (fdsock): Drop setting uninterruptible_io to true. 2011-05-01 Corinna Vinschen * fhandler.h (fhandler_socket::is_slow): Remove. 2011-04-30 Corinna Vinschen * fcntl.cc (fcntl64): Call pthread_testcancel. * fhandler_socket.cc (fhandler_socket::connect): Ditto. (fhandler_socket::accept4): Ditto. (fhandler_socket::recvfrom): Ditto. (fhandler_socket::recvmsg): Ditto. (fhandler_socket::sendto): Ditto. (fhandler_socket::sendmsg): Ditto. * flock.cc (lf_setlock): Allow to cancel thread running blocking file lock. Try to make code more readable. (lockf): Call pthread_testcancel. * mmap.cc (msync): Ditto. * posix_ipc.cc (ipc_cond_timedwait): Call pthread::static_cancel_self rather than pthread_testcancel. * select.cc (cygwin_select): Call pthread_testcancel. * syscalls.cc (pread): Ditto. (pwrite): Ditto. (readv): Ditto. (writev): Ditto. (open): Ditto. (close): Ditto. (fsync): Ditto. * termios.cc (tcdrain): Ditto. * thread.cc: Align list of cancellation points with above changes. Mark not-implemented functions, too. (cancelable_wait): Don't set unused object indices to WAIT_FAILED since that could result in wrong behaviour. Set them to the invalid value WAIT_TIMEOUT + 1 instead. 2011-04-30 Corinna Vinschen * thread.h (class pthread): Add bool member canceled. * thread.cc (pthread::pthread): Initialize canceled to false. (pthread::cancel): Set canceled before setting cancel_event. (pthread::testcancel): Check for canceled. Only wait for cancel_event if canceled is true. Explain why. (pthread::_fixup_after_fork): Set canceled to false. 2011-04-29 Corinna Vinschen * errno.cc (errmap): Sort. Map ERROR_EXE_MACHINE_TYPE_MISMATCH to ENOEXEC. 2011-04-29 Corinna Vinschen * thread.cc: Update comment listing cancellation points per POSIX. 2011-04-29 Corinna Vinschen * advapi32.cc: Add comment. (EqualSid): Remove. (CopySid): Remove. (AddAccessAllowedAce): Remove. (AddAccessDeniedAce): Remove. (MakeSelfRelativeSD): Remove. * flock.cc: Replace above functions throughout with their ntdll.dll equivalent. * sec_acl.cc: Ditto. * sec_auth.cc: Ditto. * sec_helper.cc: Ditto. * security.cc: Ditto. * security.h: Ditto. (RtlEqualSid): Declare. Explain why. (RtlCopySid): Ditto. 2011-04-29 Corinna Vinschen * advapi32.cc (AccessCheck): Remove. (PrivilegeCheck): Remove. (OpenThreadToken): Remove. * fhandler_tty.cc: Replace above functions throughout with their ntdll.dll equivalent. * security.cc: Ditto. 2011-04-29 Corinna Vinschen * ntdll.h (IsEventSignalled): New inline function. * cygthread.cc (cygthread::terminate_thread): Use IsEventSignalled in place of WaitForSingleObject on event with 0 timeout. * fhandler.cc (fhandler_base_overlapped::has_ongoing_io): Ditto. * fhandler_fifo.cc (fhandler_fifo::open_nonserver): Ditto. (fhandler_fifo::wait): Ditto. * fhandler_termios.cc (fhandler_termios::bg_check): Ditto. * select.cc (verify_tty_slave): Ditto. * thread.cc (pthread::testcancel): Ditto. 2011-04-29 Corinna Vinschen * advapi32.cc (GetTokenInformation): Remove. (SetTokenInformation): Remove. * grp.cc: Replace above functions throughout with their ntdll.dll equivalent. * sec_auth.cc: Ditto. * syscalls.cc: Ditto. * uinfo.cc: Ditto. 2011-04-29 Corinna Vinschen * posix_ipc.cc (ipc_cond_timedwait): Only wait for pthread's cancel_event if thread's cancelability isn't disabled. 2011-04-28 Corinna Vinschen * advapi32.cc (SetSecurityDescriptorDacl): Remove. (SetSecurityDescriptorGroup): Remove. (SetSecurityDescriptorOwner): Remove. * pinfo.cc: Replace above functions throughout with their ntdll.dll equivalent. * sec_acl.cc: Ditto. * sec_helper.cc: Ditto. * security.cc: Ditto. * sec_helper.cc (__sec_user): Remove old comment. 2011-04-28 Corinna Vinschen * posix_ipc.cc (ipc_cond_timedwait): Also wait for pthread's cancel_event, if any. Call pthread_testcancel if cancel_event has been signalled. 2011-04-28 Corinna Vinschen * posix_ipc.cc (ipc_cond_timedwait): Remove pthread_testcancel calls. (_mq_send): Add pthread_testcancel call at start of function. (_mq_receive): Ditto. 2011-04-28 Corinna Vinschen * cygerrno.h (geterrno_from_nt_status): Declare. * errno.cc (geterrno_from_nt_status): Define. * flock.cc: Fix copyright dates. * ntdll.h (enum _TIMER_TYPE): Define. (PTIMER_APC_ROUTINE): Define. (NtCancelTimer): Declare. (NtCreateTimer): Declare. (NtSetTimer): Declare. * posix_ipc.cc (ipc_cond_timedwait): Rewrite to make interruptible and restartable. Call pthread_testcancel in case of timeout to enable pthread_cancel on waiting thread. Replace WFMO timeout with waiting for a waitable timer. Explain why. Replace single call to WFMO with two calls, one for the event, one for the mutex. Don't lock mutex in case of error. (ipc_cond_signal): Make void function. (ipc_cond_close): Ditto. (_mq_send): Immediately return -1 in case of error from ipc_cond_timedwait. (_mq_receive): Ditto. 2011-04-28 Corinna Vinschen * advapi32.cc (GetSecurityDescriptorDacl): Remove. (GetSecurityDescriptorGroup): Remove. (GetSecurityDescriptorOwner): Remove. * sec_acl.cc: Replace above functions throughout with their ntdll.dll equivalent. Remove redundant debug output. * sec_auth.cc: Ditto. * security.cc: Ditto. * uinfo.cc: Ditto. 2011-04-28 Corinna Vinschen * advapi32.cc (InitializeAcl): Remove. (AddAce): Remove. (FindFirstFreeAce): Remove. (GetAce): Remove. (InitializeSecurityDescriptor): Remove. (OpenProcessToken): Remove. * dcrt0.cc: Replace above functions throughout with their ntdll.dll equivalent. * fhandler_tty.cc: Ditto. * flock.cc: Ditto. * pinfo.cc: Ditto. Drop unnecessary error handling. * sec_acl.cc: Ditto. * sec_auth.cc: Ditto. * sec_helper.cc: Ditto. * security.cc: Ditto. 2011-04-28 Corinna Vinschen * advapi32.cc (InitializeSid): Remove. (EqualPrefixSid): Remove. (GetLengthSid): Remove. (GetSidSubAuthority): Remove. (GetSidSubAuthorityCount): Remove. (GetSidIdentifierAuthority): Remove. * fhandler_disk_file.cc: Replace above functions throughout with their ntdll.dll equivalent. * sec_auth.cc: Ditto. * sec_helper.cc: Ditto. * security.cc: Ditto. 2011-04-28 Corinna Vinschen * advapi32.cc (AllocateLocallyUniqueId): Remove. * fhandler_disk_file.cc (fhandler_base::open_fs): Replace call to AllocateLocallyUniqueId with call to NtAllocateLocallyUniqueId; * posix_ipc.cc (mq_open): Ditto. Drop error handling for that call. (sem_open): Ditto. 2011-04-28 Corinna Vinschen * autoload.cc (GetSecurityInfo): Remove. * ntdll.h (RtlConvertToAutoInheritSecurityObject): Declare. (RtlDeleteSecurityObject): Declare. (RtlGetControlSecurityDescriptor): Declare. (RtlLengthSecurityDescriptor): Declare. * security.cc (file_mapping): New global variable. (get_file_sd): Rewrite. Clean up code. Get rid of GetSecurityInfo call. (alloc_sd): Call RtlSetControlSecurityDescriptor to set SE_DACL_PROTECTED flag. (check_file_access): Remove mapping. Use file_mapping instead. (check_registry_access): Rename mapping to reg_mapping. * wincap.cc: Througout, drop use_get_sec_info_on_dirs, * wincap.h (struct wincaps): Drop use_get_sec_info_on_dirs. 2011-04-24 Corinna Vinschen * include/fenv.h: Add missing _FENV_H_ define. 2011-04-23 Corinna Vinschen * registry.cc (reg_key::get_dword): Rename from get_int, use DWORD rather than int type. Avoid compiler warning. (reg_key::set_dword): Rename from set_int, use DWORD rather than int type. Change return type to NTSTATUS. (reg_key::get_string): Change return type to NTSTATUS. (reg_key::set_string): Ditto. * registry.h: Accommodate above changes. * environ.cc (regopt): Test return value of reg_key::get_string as NTSTATUS. * sched.cc (sched_rr_get_interval): Change local int vars to DWORD. Call reg_key::get_dword instead of reg_key::get_int. * shared.cc (init_installation_root): Test return value of reg_key::get_string as NTSTATUS. (shared_info::heap_slop_size): Call reg_key::get_dword rather than reg_key::get_int. (shared_info::heap_chunk_size): Ditto. * shared_info.h (CURR_SHARED_MAGIC): Update. (class shared_info): Change heap_chunk and heap_slop to DWORD values. 2011-04-21 Corinna Vinschen * cygtls.cc (_cygtls::init_thread): Drop setting locals.process_logmask. * cygtls.cc (_cygtls::remove): Always free mallocated TLS storage on thread exit. Drop freeing locals.process_ident. * cygtls.h (struct _local_storage): Remove syslog-related members. * syslog.cc (syslog_globals): New static storage for global syslog settings. Use throughout instead of _my_tls.locals. (openlog): Set new syslog_globals.process_ident value more carefully. * tlsoffsets.h: Regenerate. 2011-04-21 Thomas Stalder * include/sys/poll.h: Include signal.h to get definition of sigset_t. 2011-04-20 Christopher Faylor * cygheap.cc (init_cygheap::close_ctty): Avoid closing console-cttys since they don't use archetypes and this will just result in double frees. * dll_init.cc (dll_list::protect): Define. (dll_list::alloc): Guard list access. (dll_list::detach): Ditto. * dll_init.h (dll_list::protect): Declare new muto. (dll_list::guard): Define/declare function to guard list access. * fhandler_termios.cc (fhandler_termios::sigflush): Avoid SEGV in pathological condition of get_ttyp() == NULL. 2011-04-20 Christopher Faylor * select.cc (serial_cleanup): Make sure that device_specific_pipe is always deleted regardless of whether it has a unique thread associated with it (socket_cleanup): Ditto. (mailslot_cleanup): Ditto. 2011-04-20 Corinna Vinschen * devices.h: Renumber internal devices so that FH_PROCESS is part of the /proc family of virtual devices. (FH_PROC_MAX_MINOR): Define. * path.h (isproc_dev): Use FH_PROC_MAX_MINOR rather than FH_PROC. 2011-04-19 Peter Rosin * select.cc (pipe_cleanup): Make sure that device_specific_pipe is always deleted regardless of whether it has a unique thread associated with it. 2011-04-19 Jon TURNEY * thread.cc (semaphore::init): We cannot reliably infer anything from the existing contents of sem, so merely warn rather than return EBUSY if it looks like we are reinitialising a semaphore. 2011-04-19 Corinna Vinschen * autoload.cc (GetConsoleWindow): Drop. (GetSystemWindowsDirectoryW): Drop. * fhandler_console.cc (beep): Call GetSystemWindowsDirectoryW instead of GetWindowsDirectoryW. * uinfo.cc (cygheap_user::env_systemroot): Call GetSystemWindowsDirectoryW and convert to multibyte on the fly. * winlean.h (GetWindowsDirectoryW): Redefine to something invalid. Explain why. 2011-04-19 Corinna Vinschen * Makefile.in (DLL_IMPORTS): Drop advapi32.dll. * autoload.cc: Enable autoloading advapi32 functions. * environ.cc (regopt): Use wide char arguments in reg_key functions. * fhandler_console.cc (beep): Ditto. Use WCHAR throughout. * registry.cc (reg_key): Rewrite reg_key class to use native NT registry functions. Use WCHAR string parameters throughout. Use PCWSTR rather than const WCHAR. Drop multibyte char functionality. Drop unused methods. (get_registry_hive_path): Use RtlQueryRegistryValues to fetch path from registry. (load_registry_hive): Drop useless check for user hive being available. Load hive using NtLoadKey. * registry.h: Accommodate above changes. * sched.cc (sched_rr_get_interval): Use wide char arguments in reg_key functions. * shared.cc (init_installation_root): Ditto. (shared_info::init_obcaseinsensitive): Use RtlQueryRegistryValues to fetch obcaseinsensitive value. (shared_info::heap_slop_size): Use wide char arguments in reg_key functions. (shared_info::heap_chunk_size): Ditto. * syscalls.cc (gethostid): Ditto. * winsup.h (__WIDE): Define. (_WIDE): Define. * libc/minires-os-if.c (get_registry_dns_items): Don't fetch values from registry. Just extract them from given UNICODE_STRING parameter. (get_registry_dns): Fetch all registry values at once using RtlQueryRegistryValues. 2011-04-19 Corinna Vinschen * net.cc (get_ipv4fromreg_ipcnt): Rearrange to fetch all registry values at once using RtlQueryRegistryValues. (get_ipv4fromreg): Ditto. 2011-04-19 Corinna Vinschen * fhandler_registry.cc (fhandler_registry::fstat): Use RegQueryInfoKeyW. 2011-04-19 Corinna Vinschen * fhandler_proc.cc (read_value): Remove definition. (print): Simplify. (format_proc_cpuinfo): Drop useless call to GetSystemInfo. Rearrange to use Rtl registry functions. Rename dwOldThreadAffinityMask to orig_affinity_mask. 2011-04-18 Corinna Vinschen * localtime.cc (tzload): Don't change global timezone information when called from gmtime or gmtime_r. (tzparse): Ditto. 2011-04-18 Corinna Vinschen * cygtls.cc (_cygtls::remove): Always close sockevt handle. 2011-04-18 Corinna Vinschen * cygwin.din (ppoll): Export. * poll.cc (ppoll): Implement. * posix.sgml (std-gnu): Add ppoll. * include/cygwin/version.h: Bump API minor number. * include/sys/poll.h (ppoll): Declare. 2011-04-18 Corinna Vinschen * fhandler_socket.cc (fhandler_socket::evaluate_events): Handle the FD_CLOSE event specially when called from accept. Explain why. (fhandler_socket::shutdown): Fake success on not-connected socket and trigger socket event if the read side of a socket is affected. Explain why. * poll.cc (poll): Check for saw_shutdown_read on sockets to generate POLLHUP as well. 2011-04-18 Corinna Vinschen * Fix various copyrights. 2011-04-17 Christopher Faylor * signal.cc (_pinfo::kill): Set this_process_state when process exists. 2011-04-17 Christopher Faylor * signal.cc (_pinfo::kill): Return 0 when attempting to test for existence of an existed process which has not yet been reaped. 2011-04-17 Christopher Faylor * cygheap.h (init_cygheap::ctty): Use base class so that console can join in the fun. * dtable.cc (dtable::stdio_init): Remove special-case call to set_console_ctty (). * exceptions.cc (sigpacket::process): Conditionally flush terminal input on certain signals. * fhandler.h (fhandler_console::get_tty_stuff): Make non-static. (fhandler_termios::get_ttyp): Move here. (fhandler_termios::sigflush): Declare. (fhandler_tty_common::get_ttyp): Delete. * fhandler_console.cc (fhandler_console::get_tty_stuff): Pass this as "arch" argument. (set_console_ctty): Delete. (tty_list::get_tty): Just return pointer to shared console region, delaying get_tty_stuff until open(). (fhandler_console::init): Treat NULL handle as signifying that console should be opened with O_NOCTTY flag. Rename handle argument to the more common 'h'. * fhandler_termios.cc (fhandler_termios::sigflush): Define. * fhandler_tty.cc (handler_tty_master::init_console): Pass NULL as first argument to fhandler_console::init. * pinfo.cc (_pinfo::set_ctty): Change third parameter to fhandler_termios *. Add extra debugging. * pinfo.h (_pinfo::set_ctty): Change third parameter to fhandler_termios *. * sigproc.cc (handle_sigsuspend): Don't special-case non-main threads. 2011-04-15 Yaakov Selkowitz * thread.cc (pthread_setschedprio): New function. * include/pthread.h (pthread_setschedprio): Declare. * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump. * cygwin.din (pthread_setschedprio): Export. * posix.sgml (std-notimpl) Move pthread_setschedprio from here... (std-susv4) ...to here. 2011-04-10 Yaakov Selkowitz * fhandler_proc.cc (proc_tab): Add /proc/swaps virtual file. (format_proc_swaps): New function. 2011-04-06 Yaakov Selkowitz * Makefile.in: Move srcdir definition before others which uses it. 2011-04-06 Jon TURNEY * dll_init.cc (reserve_at, release_at): New functions. (load_after_fork): If the DLL was loaded higher than the required address, assume that it loaded at it's base address and also reserve memory there to force it to be relocated. 2011-04-04 Yaakov Selkowitz * include/cygwin/types.h: Move #include to end of header so that it gets the dev_t typedef. * include/sys/sysmacros.h (gnu_dev_major, gnu_dev_minor, gnu_dev_makedev): Prototype and define as inline functions. (major, minor, makedev): Redefine in terms of gnu_dev_*. 2011-04-04 Yaakov Selkowitz * include/cygwin/types.h: Move multiple inclusion guards to beginning and end of header. 2011-04-04 Christopher Faylor * Makefile.in: Move Makefile.common include earlier to fix problems with relative ${srcdir} path which confuses make. 2011-04-04 Corinna Vinschen Drop NT4 support. * autoload.cc (DnsQuery_A): Fatal if not available. (DnsRecordListFree): Ditto. (DsGetDcNameW): Ditto. (NetGetAnyDCName): Remove. (NetGetDCName): Remove. (EnumProcessModules): Fatal if not available. (GetModuleFileNameExW): Ditto. (GetModuleInformation): Ditto. (GetProcessMemoryInfo): Ditto. (QueryWorkingSet): Ditto. (LsaRegisterLogonProcess): Ditto. * fenv.cc (_feinitialise): Drop supports_sse condition. * fhandler_disk_file.cc (path_conv::isgood_inode): Fix comment. (fhandler_base::fstat_by_name): Drop has_fileid_dirinfo condition. (fhandler_disk_file::opendir): Ditto. * fhandler_netdrive.cc (fhandler_netdrive::readdir): Fix comment. * fhandler_proc.cc (format_proc_partitions): Drop NT4-only code. * fhandler_process.cc (get_process_state): Ditto. * kernel32.cc (GetWindowsDirectoryW): Remove. (GetWindowsDirectoryA): Remove. * miscfuncs.cc (nice_to_winprio): Drop NT4-only code. * mount.cc (fs_info::update): Fix comments. * net.cc (get_2k_ifs): Drop NT4-only code. * sec_auth.cc (get_logon_server): Ditto. (lsaauth): Drop NT4-specific error handling. * security.cc (alloc_sd): Set SE_DACL_PROTECTED unconditionally. * select.cc (select_stuff::wait): Always use MWMO_INPUTAVAILABLE. (peek_windows): Drop NT4-only condition in call to PeekMessage. * syscalls.cc (gethostid): Remove NT4-only workaround. * wincap.cc: Througout, drop has_dacl_protect, has_broken_if_oper_status, has_process_io_counters, has_terminal_services, has_extended_priority_class, has_guid_volumes, has_fileid_dirinfo, has_mwmo_inputavailable and supports_sse from wincaps. (wincap_nt4sp4): Remove. (wincap_minimal): Set to wincap_2000. (wincapc::init): Rely on availability of OSVERSIONINFOEX structure. Treat error from GetVersionEx as fatal. Treat NT4 as fatal. * wincap.h (struct wincaps): Drop has_dacl_protect, has_broken_if_oper_status, has_process_io_counters, has_terminal_services, has_extended_priority_class, has_guid_volumes, has_fileid_dirinfo, has_mwmo_inputavailable and supports_sse flags and methods. * winlean.h (GetWindowsDirectoryW) Define as GetSystemWindowsDirectoryW. (GetWindowsDirectoryA): Define as GetSystemWindowsDirectoryA. 2011-04-04 Corinna Vinschen * dtable.cc (dtable::init_std_file_from_handle): Fix a comment to reflect the current state. 2011-04-04 Yaakov Selkowitz * Makefile.in (fhandler_proc_CFLAGS): Define USERNAME, HOSTNAME, and GCC_VERSION. * fhandler_proc.cc (format_proc_version): Add build machine and GCC version information as on Linux. 2011-04-04 Yaakov Selkowitz Corinna Vinschen * devices.h (fh_devices): Define FH_PROC_MIN_MINOR. Reorder major-0 devices so that all /proc directories fall between FH_PROC and FH_PROC_MIN_MINOR. * path.h (isproc_dev): Redefine accordingly. 2011-04-04 Corinna Vinschen * cygserver_setpwd.h (setlsapwd): Add username parameter to declaration. * external.cc (cygwin_internal): In the CW_SET_PRIV_KEY case, fetch additional username parameter. * setlsapwd.cc (setlsapwd): Add username parameter. Allow admin to set the hidden password for other users. 2011-04-04 Corinna Vinschen * sec_auth.cc (get_user_groups): Mark well-known groups as well-known. (get_user_local_groups): Ditto. (verify_token): Drop useless label. * sec_helper.cc (cygsid::get_sid): Check for well-known SID if well_known isn't set. * security.h (well_known_sid_type): New inline function. 2011-04-02 Corinna Vinschen * autoload.cc (FindFirstVolumeA): Remove. (FindNextVolumeA): Remove. (FindVolumeClose): Remove. (GetVolumeNameForVolumeMountPointA): Remove. * ntdll.h (NtFlushBuffersFile): Declare. * syscalls.cc (sync_worker): Rewrite using native NT functions. (sync): Ditto. 2011-04-02 Corinna Vinschen * fhandler_proc.cc (format_proc_partitions): Express length in WCHAR size. 2011-04-02 Corinna Vinschen * autoload.cc (GetExtendedTcpTable): Remove. (GetTcpTable): Remove. (CharNextExA): Remove. (FindWindowA): Remove. (ShowWindowAsync): Remove. * dcrt0.cc (disable_dep): Remove unused function. (dll_crt0_0): Drop comment babbling about TS & DEP. * fhandler_socket.cc (address_in_use): Remove unused function. * wincap.cc: Throughout, drop ts_has_dep_problem from wincaps. (wincapc::init): Drop code setting ts_has_dep_problem flag. * wincap.h (struct wincaps): Drop ts_has_dep_problem flags and method. 2011-04-01 Yaakov Selkowitz Implement /proc/sysvipc/* * devices.in (dev_procsysvipc_storage): Add. * devices.cc: Regenerate. * devices.h (fh_devices): Add FH_PROCSYSVIPC. * dtable.cc (build_fh_pc): Add case FH_PROCSYSVIPC. * fhandler.h (class fhandler_procsysvipc): Declare. (fhandler_union): Add __procsysvipc. * fhandler_proc.cc (proc_tab): Add sysvipc virt_directory. * fhandler_procsysvipc.cc: New file. * Makefile.in (DLL_OFILES): Add fhandler_procsysvipc.o. * path.h (isproc_dev): Add FH_PROCSYSVIPC to conditional. 2011-04-01 Corinna Vinschen * Makefile.in (DLL_OFILES): Add avapi32.o. * advapi32.cc: New file. * autoload.cc: Add block of remaining advapi32 functions used by Cygwin. Keep commented out. Explain why. 2011-04-01 Yaakov Selkowitz * fhandler_proc.cc (format_proc_loadavg): Add running/total processes as fourth component of output. * fhandler_process.cc (get_process_state): Make non-static. Add FIXME about generating an 'O' flag. 2011-04-01 Corinna Vinschen * fhandler_random.cc (fhandler_dev_random::crypt_gen_random): Use CryptAcquireContextW. * ntdll.h (STATUS_PROCEDURE_NOT_FOUND): Define. * sec_auth.cc (open_local_policy): Rename NTSTATUS variable ret to status. Drop usage of LsaNtStatusToWinError. (verify_token): Call NtQuerySecurityObject instead of GetKernelObjectSecurity. (create_token): Rename NTSTATUS variable ret to status. Rename ret2 to sub_status. Drop usage of LsaNtStatusToWinError. In case LsaLogonUser fails, report the sub_status as well. 2011-04-01 Corinna Vinschen * libc/strptime.c: Remove misleading comment. 2011-03-31 Corinna Vinschen * ntdll.h: Allow usage from plain C code. (FSCTL_PIPE_IMPERSONATE): Define. (enum _THREAD_INFORMATION_CLASS): Define. (RTL_QUERY_REGISTRY_xxx): Define. (RTL_REGISTRY_xxx): Define. (PRTL_QUERY_REGISTRY_ROUTINE): Define. (struct _RTL_QUERY_REGISTRY_TABLE): Define. (enum _KEY_VALUE_INFORMATION_CLASS): Define. (struct _KEY_VALUE_PARTIAL_INFORMATION): Define. (NtAccessCheck): Declare. (NtAllocateLocallyUniqueId): Declare. (NtCreateKey): Declare. (NtDuplicateToken): Declare. (NtLoadKey): Declare. (NtOpenKey): Declare. (NtOpenProcessToken): Declare. (NtOpenThreadToken): Declare. (NtPrivilegeCheck): Declare. (NtQueryInformationToken): Declare. (NtQueryValueKey): Declare. (NtSetInformationThread): Declare. (NtSetInformationToken): Declare. (NtSetValueKey): Declare. (RtlAbsoluteToSelfRelativeSD): Declare. (RtlAddAccessAllowedAce): Declare. (RtlAddAccessDeniedAce): Declare. (RtlAddAce): Declare. (RtlCheckRegistryKey): Declare. (RtlCopySid): Declare. (RtlCreateAcl): Declare. (RtlCreateRegistryKey): Declare. (RtlCreateSecurityDescriptor): Declare. (RtlEqualPrefixSid): Declare. (RtlEqualSid): Declare. (RtlFirstFreeAce): Declare. (RtlGetAce): Declare. (RtlGetDaclSecurityDescriptor): Declare. (RtlGetGroupSecurityDescriptor): Declare. (RtlGetOwnerSecurityDescriptor): Declare. (RtlIdentifierAuthoritySid): Declare. (RtlInitializeSid): Declare. (RtlLengthSid): Declare. (RtlQueryRegistryValues): Declare. (RtlSetControlSecurityDescriptor): Declare. (RtlSetDaclSecurityDescriptor): Declare. (RtlSetGroupSecurityDescriptor): Declare. (RtlSetOwnerSecurityDescriptor): Declare. (RtlSubAuthorityCountSid): Declare. (RtlSubAuthoritySid): Declare. (RtlWriteRegistryValue): Declare. 2011-03-31 Corinna Vinschen * uinfo.cc (cygheap_user::init): Don't call GetUserName. Fetch username from Windows environment instead. Explain why. (cygheap_user::env_domain): Use MAX_DOMAIN_NAME_LEN rather than DNLEN to specify the size of the domain name buffer. 2011-03-30 Corinna Vinschen * hires.h: Fix copyright. * times.cc: Ditto. (FACTOR): Add comment. (NSPERSEC): Ditto. (JITTER): New definition. Comment. (systime_ns): Avoid gratuitous copying of the value returned by GetSystemTimeAsFileTime. (corelocaltime, localtime, gmtime): Remove very old, unused code block. (cygwin_tzset): Remove. (hires_ms::timeGetTime_ns): Add missing semicolon in comment. (hires_ms::nsecs): Redefine check for difference between internal timer value and system time. 2011-03-30 Corinna Vinschen * times.cc (hires_ms::resolution): Make sure resolution is never 0. (clock_setres): Ditto. 2011-03-29 Corinna Vinschen * cygtls.h (struct _local_storage): Redefine process_ident as wchar_t pointer. * syslog.cc (CYGWIN_LOG_NAME): Convert to wide char constant. (openlog): Convert incoming ident string to wide char. Fix formatting. (vsyslog): Print ident string as wide char string. Convert message string to wide char and call UNICODE Win32 Event functions to make sure to use correct codeset. * tlsoffset.h: Regenerate. 2011-03-29 Corinna Vinschen * fhandler_socket.cc (get_inet_addr): Make externally available. * autoload.cc (GetUdpTable): Define. * syslog.cc (connect_syslogd): Use get_inet_addr rather than _stat64 to check for local socket file. Create socket with type returned by get_inet_addr. If connect on UDP socket works, test if there's really a listening peer, otherwise fall back to Windows event log. (try_connect_syslogd): Use syslogd_inited flag to check if syslogd is available. 2011-03-29 Corinna Vinschen * uinfo.cc (cygheap_user::env_domain): Use LookupAccountSidW and convert user and domain to multibyte strings to make sure to use correct codeset. 2011-03-29 Corinna Vinschen * autoload.cc (UuidCreate): Remove. (UuidCreateSequential): Remove. * passwd.cc (internal_getpwsid): Avoid a strict-aliasing compiler error with gcc 4.5.1. * fhandler_floppy.cc (fhandler_dev_floppy::get_drive_info): Ditto. * ntdll.h (NtAllocateUuids): Declare. * syscalls.cc (gethostid): Use NtAllocateUuids function rather than UuidCreateSequential/UuidCreate to get rid of rpcrt4 dependency. 2011-03-29 Corinna Vinschen * cygwin.din (pthread_spin_destroy): Export. (pthread_spin_init): Export. (pthread_spin_lock): Export. (pthread_spin_trylock): Export. (pthread_spin_unlock): Export. * posix.sgml (std-susv4): Add pthread_spin_destroy, pthread_spin_init, pthread_spin_lock, pthread_spin_trylock, pthread_spin_unlock. (std-notimpl): Remove pthread_spin_[...]. * pthread.cc (pthread_spin_init): New function. * thread.cc (pthread_spinlock::is_good_object): New function. (pthread_mutex::pthread_mutex): Rearrange initializers to accommodate protected data in pthread_mutex. (pthread_spinlock::pthread_spinlock): New constructor. (pthread_spinlock::lock): New method. (pthread_spinlock::unlock): New method. (pthread_spinlock::init): New method. (pthread_spin_lock): New function. (pthread_spin_trylock): New function. (pthread_spin_unlock): New function. (pthread_spin_destroy): New function. * thread.h (PTHREAD_SPINLOCK_MAGIC): Define. (class pthread_mutex): Change access level of members shared with derived classes to protected. (pthread_mutex::set_shared): New protected method. (class pthread_spinlock): New class, derived class of pthread_mutex. * include/pthread.h (pthread_spin_destroy): Declare. (pthread_spin_init): Declare. (pthread_spin_lock): Declare. (pthread_spin_trylock): Declare. (pthread_spin_unlock): Declare. * include/cygwin/types.h (pthread_spinlock_t): New typedef. * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump. 2011-03-29 Corinna Vinschen * net.cc (SIO_BASE_HANDLE): Define. (fdsock): If we got an LSP handle, try to create a copy of the base handle instead. Change comment to explain. 2011-03-29 Corinna Vinschen * include/cygwin/version.h: Bump CYGWIN_VERSION_DLL_MINOR to 10. 2011-03-29 Corinna Vinschen * autoload.cc (winmm): Remove time functions. Don't treat unloadable wave functions as fatal. * hires.h (hires_ms::timeGetTime_ns): New private method. (hires_ms::dmsecs): Call timeGetTime_ns here. * ntdll.h (struct _KSYSTEM_TIME): Define. (KUSER_SHARED_DATA): Redefine to allow access to InterruptTime. (SharedUserData): Define here. (NtQueryTimerResolution): Declare. (NtSetTimerResolution): Declare. * path.cc (SharedUserData): Move to ntdll.h. * times.cc (hires_ms::timeGetTime_ns): New private method. Use throughout instead of timeGetTime. Document entire functionality of timeGetTime in case we need it. (hires_ms::resolution): Try a call to NtQueryTimerResolution to fetch current period. Fall back to heuristic if that fails. Cast to DWORD in assignments to minperiod. (clock_setres): Align period to possible values per a call to NtQueryTimerResolution. Explain why. Replace calls to timeBeginPeriod and timeEndPeriod with underlying call to NtSetTimerResolution. Use status code from NtSetTimerResolution to compute errno. Convert period to ULONGLONG and store 100ns value to simplify code. 2011-03-29 Yaakov Selkowitz Corinna Vinschen * include/sys/xattr.h: New file. 2011-03-28 Jon TURNEY * thread.cc (semaphore::init, destroy, close): Standards conformance fix. On a failure, return -1 and set errno. * thread.h (semaphore::terminate): Save errno since semaphore::close() may now modify it. 2011-03-27 Yaakov Selkowitz * cygwin.din (strchrnul): Export. * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump. * posix.sgml (std-gnu): Add strchrnul. 2011-03-27 Christopher Faylor * dll_init.cc (dll::init): Accommodate ill-behaved dlls who don't fill out p.envptr. 2011-03-25 Corinna Vinschen * mmap.cc (mmap64): Add a cheat to let a certain autoconf test succeed on 64 bit systems. Explain why. 2011-03-23 Christopher Faylor * wincap.cc (wincap_2003): Set use_dont_resolve_hack to true. 2011-03-23 Christopher Faylor * autoload.cc (dll_load): Change error message to make it clear if a newer DLL is being run. 2011-03-20 Corinna Vinschen * fenv.cc (_feinitialise): Don't use SSE instructions on systems not supporting them. * wincap.h (wincaps::supports_sse): New element. * wincap.cc: Implement above element throughout. 2011-03-18 Corinna Vinschen * cygwin.sc: Raise default cygheap size to 2 Megs. 2011-03-18 Christopher Faylor * fhandler.h (DEFAULT_PIPEBUFSIZE): Reset to 64K. 2011-03-18 Corinna Vinschen * mmap.cc (mmap_record::alloc_fh): Initialize name strings in fdev to empty strings or suffer a SEGV. Drop second parameter in call to build_fh_dev. 2011-03-18 Corinna Vinschen * mmap.cc (class mmap_record): Pack 4 byte-aligned. Convert member dev to plain int. (mmap_record::alloc_fh): Create temporary device from dev and use in call to build_fh_dev. 2011-03-18 Corinna Vinschen * mmap.cc (mmap_record::page_map): Define as variable array rather than as pointer. (mmap_record::alloc_page_map): Remove. (mmap_record::free_page_map): Remove. (mmap_record::init_page_map): New method. (mmap_record::add_record): Take mmap_record parameter by reference rather than by value. (mmap_record::map_pages): Fix comment. (mmap_list::add_record): Allocate space for mmap_record including the page_map in a single ccalloc call. Call init_page_map afterwards. (mmap_list::del_record): Remove call to mmap_record::free_page_map. 2011-03-16 Corinna Vinschen * crt0.c (mainCRTStartup): Move call to _feinitialise from here... * dcrt0.cc (_dll_crt0): ...to here. 2011-03-16 Corinna Vinschen * winver.rc: Fix copyright dates. 2011-03-14 Corinna Vinschen * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Only use file id as inode number if it masters the isgood_inode check. 2011-03-13 Christopher Faylor * fhandler.cc (fhandler_base_overlapped::wait_overlapped): Remove special treatment for ERROR_NO_SYSTEM_RESOURCES. Cancel I/O and reset the overlapped handle on error. (fhandler_base_overlapped::write_overlapped): Limit writes to max_atomic_write bytes in blocking case. Incorporate code from now-defunct write_overlapped_fallback. Fix serious oversight where ptr was not advanced as buffer was written. (fhandler_base_overlapped::write_overlapped_fallback): Eliminate. * fhandler.h (fhandler_base_overlapped::write_overlapped_fallback): Ditto for declaration. (DEFAULT_PIPEBUFSIZE): Lower size to slightly less than documented worst-case atomic write size. (fhandler_overlapped::wait_return): Remove unused element. 2011-03-09 Christopher Faylor * fhandler.cc (fhandler_base_overlapped::wait_overlapped): Handle overlapped_fallback error condition like other error conditions. Set res carefully and specifically for each condition rather than resorting to a default. (fhandler_base_overlapped::write_overlapped): Preserve errno in overlapped_fallback condition. Correct write_overlapped_fallback to avoid inappropriate looping. (fhandler_base_overlapped::write_overlapped_fallback): Add some more comments. 2011-03-09 Christopher Faylor * fhandler.cc (fhandler_base_overlapped::write_overlapp): Oops! Accommodate change in arguments to wait_overlapped. 2011-03-09 Christopher Faylor * errno.cc (errmap): Change mapping of NO_SYSTEM_RESOURCES to EFBIG. * fhandler.cc (MAX_OVERLAPPED_WRITE_LEN): New constant. (MIN_OVERLAPPED_WRITE_LEN): Ditto. (fhandler_base_overlapped::close): Accommodate change in arguments to wait_overlapped. (fhandler_base_overlapped::setup_overlapped): Add __stdcall and regparm modifiers. (fhandler_base_overlapped::destroy_overlapped): Ditto. (fhandler_base_overlapped::has_ongoing_io): Ditto. (fhandler_base_overlapped::wait_overlapped): Modify to return an enum returning various states. Accept nonblocking parameter. (fhandler_base_overlapped::read_overlapped): Add __stdcall and regparm modifiers. Rework to attempt to be smarter about reacting to states returned by wait_overlapped. (fhandler_base_overlapped::write_overlapped): Ditto. Add fallback option for when wait_overlapped detects that smaller chunks must be written. (fhandler_base_overlapped::write_overlapped_fallback): Ditto. * fhandler.h (DEFAULT_PIPEBUFSIZE): Move definition here from pipe.cc. (fhandler_base::has_ongoing_io): Define with __stdcall and regparm modifiers. (fhandler_base_overlapped::wait_return): New enum. (fhandler_base_overlapped::max_atomic_write): New variable. (fhandler_base_overlapped:: wait_overlapped): Accommodate changes mentioned above to arguments and modifiers. (fhandler_base_overlapped::setup_overlapped): Ditto for modifiers. (fhandler_base_overlapped::read_overlapped): Ditto. (fhandler_base_overlapped::write_overlapped): Ditto. (fhandler_base_overlapped::destroy_overlapped): Ditto. (fhandler_base_overlapped::has_ongoing_io): Ditto. (fhandler_base_overlapped::fhandler_base_overlapped): Zero max_atomic_write. * fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Set max_atomic_write to the size of the DEFAULT_PIPEBUFSIZE. (fhandler_fifo::wait): Accommodate change in arguments to wait_overlapped. * pipe.cc (fhandler_pipe::fhandler_pipe): Set max_atomic_write to the size of the DEFAULT_PIPEBUFSIZE. (fhandler_pipe::create_selectable): Allow minimum size of DEFAULT_PIPEBUFSIZE. (DEFAULT_PIPEBUFSIZE): Delete here, move to fhandler.h. 2011-03-08 Corinna Vinschen * security.cc: Fix copyright dates. 2011-03-08 Corinna Vinschen * fhandler.cc (fhandler_base::open): When creating a file on a filesystem supporting ACLs, create the file with WRITE_DAC access. Explain why. * fhandler_disk_file.cc (fhandler_disk_file::mkdir): Ditto for directories. * fhandler_socket.cc (fhandler_socket::bind): Ditto for sockets. * path.cc (symlink_worker): Ditto for symlinks. * security.cc (get_file_sd): Always call GetSecurityInfo for directories on XP and Server 2003. Improve comment to explain why. (set_file_attribute): Explicitely cast mode_t value to bool in call to get_file_sd. * wincap.h (wincaps::use_get_sec_info_on_dirs): New element. * wincap.cc: Implement above element throughout. 2011-03-04 Corinna Vinschen * fhandler_procsys.cc (fhandler_procsys::exists): Rewrite. (fhandler_procsys::fill_filebuf): Fill buffer with valid string even if reading the symlink fails. 2011-03-03 Corinna Vinschen * posix_ipc.cc (ipc_cond_timedwait): If ipc_mutex_unlock fails, return actual error number. (_mq_send): Break loop if ipc_cond_timedwait returns with error. (_mq_receive): Ditto. 2011-03-03 Corinna Vinschen * errno.cc (__xpg_strerror_r): Add accidentally missing condition. 2011-03-02 Corinna Vinschen * fhandler_procsys.cc (fhandler_procsys::open): Call worker exists method, rather than wrapper. 2011-03-01 Christopher Faylor * autoload.cc (dll_load): Avoid in_forkee test since this apparently fails even when not forked. 2011-03-01 Christopher Faylor * include/cygwin/version.h: Bump CYGWIN_VERSION_DLL_MINOR to 9. 2011-02-28 Christopher Faylor * autoload.cc (dll_load): Only perform DONT_RESOLVE_DLL_REFERENCES hack on systems which need it. * wincap.cc (use_dont_resolve_hack): Set as appropriate. * wincap.h (use_dont_resolve_hack): Define. 2011-02-28 Christopher Faylor * autoload.cc (dll_load): Make inline. Clarify logic. 2011-02-27 Corinna Vinschen * autoload.cc (dll_load): Only call LoadLibraryExW with DONT_RESOLVE_DLL_REFERENCES if a normal LoadLibrary call failed with ERROR_INVALID_ADDRESS. (LsaRegisterLogonProcess): Align comment to previous change. 2011-02-26 Christopher Faylor * autoload.cc: Use LoadDLLfuncEx3 for all winmm functions. Accommodate changes to LoadDLLprime. (LoadDLLprime): Take an extra argument indicating whether this dll needs special handling on fork. Place this information in the "handle" location. (LoadDLLfuncEx3): Eliminate "func" handling. Pass new no_resolve_on_fork argument to LoadDLLprime. (dll_load): New function. (std_dll_init): Accommodate changes to dll_info::handle. Use dll_load to load DLL in both cases where it is used. 2011-02-26 Corinna Vinschen * autoload.cc: Make autoloaded ntdll function non-optional. Ditto for secur32 functions, except for LsaRegisterLogonProcess. Change return value to ERROR_PROC_NOT_FOUND. Explain why. * sec_auth.cc (lsaauth): Handle ERROR_PROC_NOT_FOUND from call to LsaRegisterLogonProcess when generating the errno value. 2011-02-22 Corinna Vinschen * dcrt0.cc: Fix copyright dates. * winsup.h: Ditto. * syscalls.cc (_read): Move EXPORT_ALIAS to its rightful place. 2011-02-21 Christopher Faylor * cygwin.din: Mark __assert* and _abort as NOSIGFE. 2011-02-21 Corinna Vinschen * fhandler_socket (fhandler_socket::readv): Call recv_internal directly, rather than recvmsg. (fhandler_socket::writev): Call send_internal directly, rather than sendmsg. * net.cc (cygwin_recv): Call fhandler_socket::recvfrom directly, rather than cygwin_recvfrom. (cygwin_send): Call fhandler_socket::sendto directly, rather than cygwin_sendto. 2011-02-20 Christopher Faylor * fhandler.cc (fhandler_base_overlapped::close): Finish any pending I/O before closing. (fhandler_base_overlapped::wait_overlapped): Defensively zero bytes read. Add more info to debugging output. 2011-02-18 Christopher Faylor * dcrt0.cc (dll_crt0_1): Add a CYGHEAP_DEBUG conditional for debugging which allocates a lot of space at startup. 2011-02-18 Corinna Vinschen * cygwin.sc: Set alignment of .cygheap section to 64K. 2011-02-15 Corinna Vinschen * spawn.cc (spawn_guts): Only set PID_NOTCYGWIN in _P_OVERLAY mode. Drop flag if creating new process failed. 2011-02-15 Corinna Vinschen * Throughout fix copyright dates. 2011-02-15 Corinna Vinschen * devices.in: Throughout use slashes instead of backslashes in the native path of devices not backed by native NT devices. * devices.cc: Regenerate. * globals.cc (ro_u_pmem): Use correct case. (ro_u_globalroot): New R/O unicode string. * path.cc (path_conv::check): Fix incorrect handling of /proc/sys block devices if they are just visited due to a component check. (symlink_info::posixify): Fix typo in comment. (cygwin_conv_path): Use ro_u_globalroot instead of string constant. (fast_cwd_version): New shared variable to store FAST_CWD version used on the system. (find_fast_cwd_pointer): Rename from find_fast_cwd_pointers. Don't set global fast_cwd_ptr pointer here. Return pointer value instead. (find_fast_cwd): New function to set fast_cwd_ptr and fast_cwd_version. (cwdstuff::override_win32_cwd): Call find_fast_cwd from here. Check for fast_cwd_version to differ between old and new FAST_CWD structure. Check old_cwd for NULL to avoid SEGV. Don't set CWD if we have neitehr a valid fast_cwd_ptr, nor a valid CWD handle in the process parameter block. (cwdstuff::set): Create Win32 path taking /proc/sys paths into account. * spawn.cc (spawn_guts): Recode creating runpath. Also take /proc/sys paths into account. Drop special CWD handling when starting non-Cygwin processes. 2011-02-15 Corinna Vinschen * fhandler_procsys.cc (fhandler_procsys::opendir): Avoid SEGV if opening object directory fails. * fhandler_virtual.cc (fhandler_virtual::opendir): Don't leak memory. 2011-02-15 Corinna Vinschen * fhandler_disk_file.cc (fhandler_disk_file::readdir_helper): Don't append slash if there is one already. 2011-02-15 Corinna Vinschen Revert change from 2010-08-31: * path.cc (normalize_posix_path): Drop support for //./ and //?/ prefixes. (path_conv::check): Ditto. 2011-02-15 Corinna Vinschen * fhandler_disk_file.cc (fhandler_disk_file::readdir_helper): Use POSIX path to check for symlink. 2011-02-14 Corinna Vinschen * config/i386/profile.h: Sync with Mingw. 2011-02-13 Corinna Vinschen * path.cc (struct _FAST_CWD): Redefine to new layout used since patch for KB 2393802. Adjust comments throughout. (struct _FAST_CWD_OLD): Rename former definition. (cwdstuff::override_win32_cwd): Check if the OS is using the old or the new FAST_CWD structure layout and handle accordingly. 2011-02-11 Christopher Faylor * mkstatic: Make sure that we are not cd'ed to temporary directory on exit to avoid bogus warnings on directory cleanup. * speclib: Ditto. * mkimport: Ditto. 2011-02-11 Christopher Faylor * cygwin.sc: Eliminate __cygheap_mid. * cygheap.cc: Ditto. 2011-02-11 Christopher Faylor * cygheap.cc (_cygheap_mid): Drop unneeded section attribute. (cygheap_init): Just zero cygheap structure. * cygwin.sc: Keep 16 byte alignment but drop all other alignments related to cygheap. Eliminate unused __cygheap_end1. 2011-02-11 Corinna Vinschen * cygwin.sc: Raise default cygheap size to 1 Meg. Set alignment to standard 64K. 2011-02-11 Corinna Vinschen * include/endian.h: Move definitions of __BIG_ENDIAN, __LITTLE_ENDIAN, and __BYTE_ORDER into ... * include/bits/endian.h: New file. * include/arpa/nameser_compat.h: Include endian.h rather than defining BYTE_ORDER here. * include/asm/byteorder.h: Include bits/endian.h. Drop definition of __LITTLE_ENDIAN. * include/netinet/ip.h: Include bits/endian.h. Drop definitions of BIG_ENDIAN, LITTLE_ENDIAN, and BYTE_ORDER. Use underscored variants of aforementioned constants. * include/netinet/tcp.h: Ditto. * include/sys/param.h: Drop disabled definitions of BIG_ENDIAN, LITTLE_ENDIAN, and BYTE_ORDER. * include/netinet/ip.h: Reformat. Define setsockopt IP_TOS options matching recent RFCs. Tweak comments. 2011-02-10 Eric Blake * errno.cc (includes): Avoid compilation failure if settles on wrong strerror_r signature. * errno.cc (__xpg_strerror_r): New function. (strerror_r): Update to copy newlib's fixes. (strerror): Set errno on failure. (_sys_errlist): Cause EINVAL failure for reserved values. * cygwin.din: Export new function. * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Combine this into minor 236. 2011-02-09 Yaakov Selkowitz * cygwin.din (pthread_yield): Export as alias to sched_yield. * include/pthread.h (pthread_yield): Declare. * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump. * posix.sgml (std-deprec): Add pthread_yield. 2011-02-09 Christopher Faylor * cygheap.cc: Add some __stdcall decoration where appropriate. * lib/cygwin_crt0.c: __attribute -> __attribute__. 2011-02-09 Christopher Faylor * hookapi.cc (hook_or_detect_cygwin): Prevent i from being considered uninitialized by gcc. 2011-02-09 Christopher Faylor * exception.h: Remove DEBUG_EXCEPTION left over debugging ifdef. 2011-02-08 Christopher Faylor * dll_init.cc: Fix typo in comment. 2011-02-07 Corinna Vinschen * configure.in: Remove AC_ALLOCA test and test for __builtin_memset. * configure: Regenerate. 2011-02-07 Corinna Vinschen * fhandler_console.cc (fhandler_console::write_normal): Remove erroneous premature return after collecting truncated multibyte sequence in trunc_buf. Rather fall through to printing routine. Fix return value to take trunc_buf content into account. Improve comments. 2011-02-05 Christopher Faylor * autoload.cc (wsock_init): Properly define WSAStartup function pointer to avoid stack damage. 2011-02-02 Corinna Vinschen * libc/bsdlib.cc: Include err.h. 2011-02-02 Eric Blake * include/err.h: Fix loss of semicolons in previous patch. 2011-02-02 Corinna Vinschen * include/err.h (err): Add noreturn attribute. (errx): Ditto. (verr): Ditto. (verrx): Ditto. 2011-02-02 Corinna Vinschen * path.cc (conv_path_list): Remove enclosing quotes and trailing backslashes from Win32 environment path lists. 2011-02-01 Christian Franke * fhandler.cc (fhandler_base::fsync): Ignore ERROR_INVALID_FUNCTION error from FlushFileBuffers(). 2011-01-31 Corinna Vinschen * syscalls.cc (utmp_data): Fix potential buffer overflow. 2011-01-31 Corinna Vinschen * fhandler_socket.cc (address_in_use): Improve comment readability. 2011-01-30 Corinna Vinschen * fhandler_socket.cc (address_in_use): Disable. Add comment. (fhandler_socket::bind): Change comment to explain setting the SO_EXCLUSIVEADDRUSE socket option. Remove code which checks for address in use. * net.cc (cygwin_setsockopt): Never set SO_REUSEADDR option. Improve comment to compensate for the deleted comment in fhandler_socket::bind. * wincap.cc: Throughout, drop has_enhanced_socket_security from wincaps. * wincap.h (struct wincaps): Drop has_enhanced_socket_security flags and method. 2011-01-28 Peter Foley * configure.in: Define LIBSERVER regardless of cross_host. * configure: Regenerate. 2011-01-28 Corinna Vinschen * fhandler_socket.cc (fhandler_socket::wait_for_events): Call pthread_testcancel in case of timeout to enable pthread_cancel on waiting thread. 2011-01-27 Corinna Vinschen * include/features.h (__STDC_ISO_10646__): Move to newlib's sys/features.h. 2011-01-26 Corinna Vinschen * fhandler_disk_file.cc (fhandler_base::fstat_by_nfs_ea): Fix computation of st_blocks. (fhandler_base::fstat_helper): Fix formatting. 2011-01-24 Corinna Vinschen * include/features.h (__STDC_ISO_10646__): Define. Add comment. 2011-01-21 Corinna Vinschen * syscalls.cc (rename): Fix permission problem with symlinks on NFS. Rework how NtOpenFile gets called to make it more readable. Change comment. 2011-01-20 Corinna Vinschen * exec.cc: Include pinfo.h. * winf.h: Move definitions of _P_PATH_TYPE_EXEC and _P_MODE from here... * pinfo.h: ...to here. (_P_PATH_TYPE_EXEC): Redefine to be bigger than _P_SYSTEM. (_P_MODE): Redefine so as not to mask out _P_SYSTEM. * spawn.cc (spawnlp): Add _P_PATH_TYPE_EXEC flag in call to spawnve. (spawnlpe): Ditto. (spawnvp): Ditto. 2011-01-19 Corinna Vinschen * spawn.cc (av::fixup): Reenable #! handling for all exec functions. Return ENOEXEC in !p_type_exec case only for unrecognized files. Fix comment formatting. 2011-01-19 Corinna Vinschen * exec.cc (execlp): Add missing _P_PATH_TYPE_EXEC flag in call to spawnve. 2011-01-19 Corinna Vinschen * exec.cc: Rearrange functions in alphabetical order. (_execve): Drop temporary define and drop export alias. (execl): Call spawnve. (execle): New function. (execlp): New function. (execv): Call spawnve. (execve): Drop converting NULL envp to emtpy envp. (execvp): Call spawnve. (execvpe): Drop converting NULL envp to emtpy envp. Call spawnve. (fexecve): Call spawnve. * spawn.cc (spawnve): Convert NULL envp to emtpy envp. Remove outdated comment. (spawnlp): Call spawnve. (spawnlpe): Ditto. (spawnvp): Ditto. (spawnvpe): Fix formatting. 2011-01-19 Corinna Vinschen * exec.cc (strccpy): Move function from here... * strfuncs.cc (strccpy): ...to here. * string.h (strccpy): Declare. * winsup.h (strccpy): Drop declaration. 2011-01-19 Corinna Vinschen * errno.cc (errmap): Add error codes for invalid binaries. * exec.cc (execvp): Call spawnve with _P_PATH_TYPE_EXEC flag from here. (execvpe): Ditto. * spawn.cc (spawn_guts): Filter _P_PATH_TYPE_EXEC from mode and store in p_type_exec. Call av::fixup with addtional p_type_exec argument. (spawnve): Check for filtered mode. (spawnvpe): Add _P_PATH_TYPE_EXEC flag when calling spawnve. (av::fixup): Accept additional bool parameter p_type_exec. Only check for script if p_type_exec is true. * winf.h (_P_PATH_TYPE_EXEC): Define. (_P_MODE): Define. (av::fixup): Declare with additional bool parameter. 2011-01-17 Corinna Vinschen * fhandler_proc.cc (format_proc_partitions): Fix compiler warning. 2011-01-17 Corinna Vinschen * path.cc (path_conv::check): Don't follow reparse point symlinks if PC_SYM_NOFOLLOW_REP flag is set. (cygwin_conv_path): Set PC_SYM_NOFOLLOW_REP flag when converting from POSIX to Win32. * path.h (enum pathconv_arg): Define PC_SYM_NOFOLLOW_REP flag. 2011-01-17 Corinna Vinschen * fhandler_proc.cc (proc_tab_cmp): Fix typo in comment. (fhandler_proc::fill_filebuf): Handle return value of 0 from format function as error. (format_proc_stat): Set errno when returning 0 size. (format_proc_partitions): Rewrite method to fetch partition info. 2011-01-13 Corinna Vinschen * fhandler_disk_file.cc (fhandler_base::fstat_helper): Always set st_size of directories to 0. Explain why. 2011-01-12 Corinna Vinschen * posix.sgml: Add madvise to BSD list. 2011-01-12 Corinna Vinschen * cygwin.din (madvise): Export posix_madvise as madvise. * include/cygwin/version.h: Bump CYGWIN_VERSION_API_MINOR. * include/sys/mman.h: Define madvise constants, keep Linux-specific constants undefined. (madvise): Declare. 2011-01-12 Corinna Vinschen * fhandler.h (struct part_t): New type. (class fhandler_dev_floppy): Convert partitions to part_t pointer. Add lock_partition method. * fhandler_floppy.cc (fhandler_dev_floppy::lock_partition): New method to implement ondemand partition locking. (fhandler_dev_floppy::write_file): Call lock_partition from here if writing failed due to a potential write restriction on a disk partition. (fhandler_dev_floppy::open): Don't lock partitions here. (fhandler_dev_floppy::close): Keep track of partition handle reference count. Close handles and remove partitions pointer ony if count is 0. (fhandler_dev_floppy::dup): Just copy partitions pointer and increment reference count. 2011-01-11 Corinna Vinschen * fhandler.h (MAX_PARTITIONS): New definition. (class fhandler_dev_floppy): Add partitions array member. Add close method. * fhandler_floppy.cc (fhandler_dev_floppy::fhandler_dev_floppy): Zero out partitions array. (fhandler_dev_floppy::open): Fix "entire disk" condition for call to DeviceIoControl (FSCTL_ALLOW_EXTENDED_DASD_IO). When opening disks for writing, call DeviceIoControl (FSCTL_LOCK_VOLUME) on all affected disk partitions starting with Vista. (fhandler_dev_floppy::close): New method. (fhandler_dev_floppy::dup): Duplicate handles in partitions, if any. * wincap.h (wincaps::has_restricted_raw_disk_access): New element. * wincap.cc: Implement above element throughout. 2011-01-11 Yaakov Selkowitz * termios.cc (cfgetospeed, cfgetispeed): Constify argument per POSIX. * include/sys/termios.h (cfgetospeed, cfgetispeed): Declare functions. Move macros after declarations and make conditional on !__cplusplus. 2011-01-11 Corinna Vinschen * cygtls.cc (_cygtls::init_thread): Call _REENT_INIT_PTR. Drop setting current locale and calling srand48. 2011-01-02 Christopher Faylor * ChangeLog-2010: Create from ChangeLog. * ChangeLog: Start fresh.