summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/fhandler.h
Commit message (Collapse)AuthorAgeFilesLines
* TIOCPKT mode of PTY is broken if ONLCR bit is cleared.Takashi Yano2015-04-231-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * tty.h (class tty_min): Remove variable "write_error" to which any errors are not currently set at anywhere. (class tty): Add variable "column" for handling ONOCR. * tty.cc (tty::init): Add initialization code for variable "column". * fhandler.h (class fhandler_pty_master): Remove variable "need_nl" which is not necessary any more. "need_nl" was needed by OPOST process in fhandler_pty_master::process_slave_output(). (class fhandler_pty_common): Add function process_opost_output() for handling post processing for OPOST in write process. * fhandler_tty.cc (fhandler_pty_master::process_slave_output): Count TIOCPKT control byte into length to be read in TIOCPKT mode. Move post processing for OPOST to write process. Remove code related to variable "write_error". Return with EIO error if slave is already closed. (fhandler_pty_master::fhandler_pty_master): Remove initialization code for variable "need_nl". (fhandler_pty_common::process_opost_output): Add this function for handling of OPOST in write process. Add code to avoid blocking in non-blocking mode when output is suspended by ^S. (fhandler_pty_slave::write): Call fhandler_pty_common:: process_opost_output() instead of WriteFile(). Remove code related to variable "write_error". (fhandler_pty_master::doecho): Call fhandler_pty_common:: process_opost_output() instead of WriteFile(). * select.cc (peek_pipe): Remove code related to variable "need_nl". Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* * fhandler.h (fhandler_base::get_echo_handle): New virtual method.Corinna Vinschen2015-03-051-0/+3
| | | | | | | | | | | | | | | | (class fhandler_pty_master): Add echo_r and echo_w handles constituting read and write side of new echo pipe. * select.cc (peek_pipe): On pty masters, check additionally if input from the echo pipe is available. * fhandler_tty.cc (fhandler_pty_master::doecho): Drop output_mutex locking. Write output to echo pipe. (fhandler_pty_master::process_slave_output): Check if input is available in echo pipe and prefer to read from it, if so. (fhandler_pty_slave::write): Drop output_mutex locking. (fhandler_pty_master::fhandler_pty_master): Initialize echo pipe handles to NULL. (fhandler_pty_master::close): Close and NULL echo pipe handles. (fhandler_pty_master::setup): Create echo pipe, close in case of error.
* * fhandler.h (class fhandler_base): Add was_nonblocking status flag.Corinna Vinschen2015-02-241-1/+6
| | | | | | | | | * fhandler.cc (fhandler_base::set_flags): Set was_nonblocking if the O_NONBLOCK flag has been specified. (fhandler_base_overlapped::close): Check for was_nonblocking instead of for is_nonblocking. Explain why. (fhandler_base::set_nonblocking): Set was_nonblocking if noblocking mode gets enabled.
* * path.h (path_conv): Make path_flags private. Rename known_suffix toCorinna Vinschen2015-02-151-3/+3
| | | | | | | | | | | | | | suffix and make private. Rename normalized_path to posix_path and make privtae. Accommodate name changes throughout in path_conv methods. (path_conv::known_suffix): New method. Use throughout instead of accessing suffix directly. (path_conv::get_win32): Constify. (path_conv::get_posix): New method to read posix_path. Use throughout instead of accessing normalized_path directly. (path_conv::set_posix): Rename from set_normalized_path. Accommodate name change throughout. * spawn.cc (find_exec): Return POSIX path, not Win32 path.
* * fhandler.h (class fhandler_process): Add fd_type member.Corinna Vinschen2015-01-221-1/+2
| | | | | | | | | | | | | | | | | * fhandler_process.cc (process_tab): Fix indentation. (fhandler_process::exists): Rely on format_process_fd returning file type in fd_type. (struct process_fd_t): Add fd_type member. (fhandler_process::fill_filebuf): Allow format_process_fd to set this->fd_type member. (format_process_fd): Fix path evaluation to allow recognizing trailing path components. Fix check for file descriptor path component. Return virt_symlink in fd_type if no trailing path compenents exist, return virt_fsdir otherwise and copy full resulting path into destbuf. * path.cc (path_conv::check): If /proc/$PID/fd symlink has trailing path components, reparse resulting path as if it's the incoming path. Add comment to wail over the outdated and hackish check method, and to explain what we do here.
* * fhandler.h (fhandler_termios::line_edit): Add parameter to returnCorinna Vinschen2014-11-131-1/+2
| | | | | | | | | | | | | | written bytes. * fhandler_termios.cc (fhandler_termios::tcinit): Fix formatting. (fhandler_termios::line_edit): Return bytes actually written. Write in 32 byte chunks in non-canonical mode to reduce number of WriteFile calls. Don't just eat unwritten bytes in case of an error condition. Especially, don't report them back to the caller as written. * fhandler_tty.cc (fhandler_pty_slave::read): Disable code reducing the number of bytes read from the pipe to vmin. Add comment. (fhandler_pty_master::write): Convert ret to ssize_t type. Just call line_edit once, not in a loop once for each byte. Return bytes written as returned by line_edit.
* * fhandler_socket.cc (fhandler_socket::af_local_connect): DropCorinna Vinschen2014-10-261-5/+4
| | | | | | | | | setting connect_state to connect_credxchg. (fhandler_socket::af_local_accept): Ditto. (fhandler_socket::recv_internal): Drop ill-advised connect_state check. Add comment so as not to repeat the exercise. * fhandler.h (enum conn_state): Drop now unneeded connect_credxchg state.
* Add setsockopt(sd, SOL_SOCKET, SO_PEERCRED, NULL, 0) to disableCorinna Vinschen2014-10-111-1/+4
| | | | | | | | | | | | | | | initial handshake on AF_LOCAL sockets. * fhandler.h (class fhandler_socket): Add no_getpeereid status flag. (fhandler_socket::af_local_set_no_getpeereid): New prototype. * fhandler_socket.cc (fhandler_socket::af_local_connect): Skip handshake if no_getpeereid is set. Add debug output. (fhandler_socket::af_local_accept): Likewise. (fhandler_socket::af_local_set_no_getpeereid): New function. (fhandler_socket::af_local_copy): Copy no_getpeereid. (fhandler_socket::getpeereid): Fail if no_getpeereid is set. * net.cc (cygwin_setsockopt): Add SO_PEERCRED for AF_LOCAL/SOCK_STREAM sockets. Add comment to explain why we need it. * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
* * fhandler.h (fhandler_pty_slave::fch_open_handles): Add bool parameterCorinna Vinschen2014-08-271-1/+1
| | | | | | | | | | | | | | | | | | | to declaration. * fhandler_tty.cc (fhandler_pty_slave::fch_open_handles): Add bool parameter "chown". Only request WRITE_OWNER access when opening pty synchronization objects if "chown" is set. (fhandler_pty_slave::fchmod): Call fch_open_handles with new bool parameter set to false. (fhandler_pty_slave::fchown): Call fch_open_handles with new bool parameter set to true. * kernel32.cc (CreateFileMappingW): Fix default standard rights for file mappings from READ_CONTROL to STANDARD_RIGHTS_REQUIRED to allow changing the DACL (fixes "access denied" error in pinfo::set_acl). * fhandler_disk_file.cc (fhandler_base::fstat_helper): Change debug output to print mode bits in octal. * security.cc (alloc_sd): Ditto. (set_file_attribute): Ditto.
* * fhandler.h (enum conn_state): Add "connect_credxchg" state.Corinna Vinschen2014-08-191-5/+6
| | | | | | | | | | (class fhandler_socket): Grant another bit to connect_state flag. * fhandler_socket.cc (fhandler_socket::af_local_connect): Rearrange variable definition. Set connect_state to connect_credxchg. (fhandler_socket::af_local_accept): Ditto. (fhandler_socket::recv_internal): Accept connect_credxchg on connection oriented AF_LOCAL sockets as well to allow the credential exchange. Extend comment to explain.
* * fhandler.h (fhandler_serial::is_tty): Reinstantiate.Corinna Vinschen2014-08-191-0/+1
|
* * dtable.cc (dtable::init_std_file_from_handle): Mention that consoleCorinna Vinschen2014-08-181-7/+13
| | | | | | | | | | | | | | | handles are kernel objects since Windows 8. * fhandler.h (enum conn_state): Add "listener" state. (class fhandler_socket): Drop listener status flag. (fhandler_socket::lseek): Return -1 and errno ESPIPE. (fhandler_serial::lseek): Ditto. * fhandler_socket.cc (fhandler_socket::listen): Set connect_state to listener. Add comment. (fhandler_socket::accept4): Explicitely check if the socket is listening and fail with EINVAL, if not. Explain why we have to do that. (fhandler_socket::recv_internal): Explicitely check if the socket is connected if it's a stream socket. Explain why we have to do that. (fhandler_socket::getpeereid): Drop now redundant test.
* * DevNotes: Add entry cgf-000026.Christopher Faylor2014-04-261-0/+1
| | | | | | | * fhandler.h (fhandler_console::save_top): Save top of screen coordinates. * fhandler_console.cc (dev::save_restore): Record top of screen coordinates. Clear entire buffer when restoring saved buffer and try to position the cursor on the save relative place on the screen.
* * fhandler.h (fhandler_dev_dsp): Remove variable names from declarations.Christopher Faylor2014-03-191-11/+11
| | | | | | | | | (fhandler_dev_dsp::close_audio_in): Make __reg1. (fhandler_dev_dsp::close_audio_out): Make __reg2. * fhandler_dev_dsp.cc (fhandler_dev_dsp::close_audio_in): Make __reg1. (fhandler_dev_dsp::close_audio_out): Make __reg2. (fhandler_dev_dsp::close): Don't abruptly terminate sound just because we are exiting.
* * sigproc.h (no_thread_exit_protect): New class.Christopher Faylor2014-03-171-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | * sigproc.cc (thread_exit): Use no_thread_exit_protect to determine if we need to coordinate ThreadExit/ExitProcess. * fhandler_dsp.cc (fhandler_dev_dsp::Audio_out::stop): Use no_thread_exit_protect to kludge around waiting for waveOutClose as it waits for a thread that never exits. (fhandler_dev_dsp::Audio_in::stop): Ditto for waveInClose. * fhandler.h (fhandler_dev_dsp::base): New method. (fhandler_dev_dsp::_read): Ditto. (fhandler_dev_dsp::_write): Ditto. (fhandler_dev_dsp::_ioctl): Ditto. (fhandler_dev_dsp::_fixup_after_fork): Ditto. (fhandler_dev_dsp::_fixup_after_exec): Ditto. * fhandler_dsp.cc (fhandler_dev_dsp::read): Call real function via base() pointer. (fhandler_dev_dsp::write): Ditto. (fhandler_dev_dsp::ioctl): Ditto. (fhandler_dev_dsp::fixup_after_fork): Ditto. (fhandler_dev_dsp::fixup_after_exec): Ditto. (fhandler_dev_dsp::_read): Rename by adding an leading underscore. (fhandler_dev_dsp::_write): Ditto. (fhandler_dev_dsp::_ioctl): Ditto. (fhandler_dev_dsp::_fixup_after_fork): Ditto. (fhandler_dev_dsp::_fixup_after_exec): Ditto.
* * fhandler.h (dev_console::b): Redefine as CONSOLE_SCREEN_BUFFER_INFO for useChristopher Faylor2014-03-101-1/+1
| | | | | | with older OS. * fhandler_console.cc (dev_console::fillin): Ditto for GetConsoleScreenBufferInfo.
* * fhandler.h (fhandler_console::dwBufferSize): Delete.Christopher Faylor2014-03-091-11/+11
| | | | | | | | | | | | | | | | | | | | (fhandler_console::dwCursorPosition): Ditto. (fhandler_console::wAttributes): Ditto. (fhandler_console::b): New field encompassing previously disparate screen buffer info. (fhandler_console::save_bufsize): Rename from savebufsiz (fhandler_console::save_buf): Rename sfrom savebuf. (fhandler_console::save_cursor): New field. (fhandler_console::save_restore): New function. (fhandler_console::con): Rename from dev_state. (fhandler_console::focus_aware): Accommodate name change. * fhandler_console.cc: Use 'b' field of dev_console throughout instead of disparate names. Accommodate dev_state -> con rename. (dev_state:save_restore): New function. Attempt to save the entire screen buffer rather than just the visible part. Clear the buffer when saving, like Linux. (fhandler_console::char_command): Use con.save_restore() for Save/restore screen sequence.
* * fhandler.h (fhandler_console::scroll_buffer_screen): New function.Christopher Faylor2014-02-261-0/+1
| | | | | | * fhandler_console.cc (fhandler_console::scroll_buffer_screen): New function. (fhandler_console::char_command): Use scroll_buffer_screen as appropriate. (dev_console::scroll_buffer): Remove if 0'ed block.
* * fhandler.h (dev_console::is_fullscreen): Delete.Christopher Faylor2014-02-231-6/+7
| | | | | | | | | | | | | | | | | | | | | | | (dev_console::scroll_window): Return bool indicating success. (dev_console::scroll_screen): New function. (dev_console::clear_screen): New function. (fhandler_console::clear_screen): Make __reg3. (fhandler_console::cursor_set): Ditto. (fhandler_console::cursor_get): Ditto. (fhandler_console::cursor_rel): Ditto. * fhandler_console.cc (dev_console::scroll_buffer): Adapt from fhandler_console. (fhandler_console::scroll_buffer): Use dev_console function. (dev_console::is_fullscreen): Delete. (dev_console::scroll_window): Return true if we cleared the screen. Shrink/grow buffer first before scrolling to ensure that there is sufficient space after scrolling. (fhandler_console::clear_screen): Make reg3, use dev_console function. (dev_console::clear_screen): New function adapted from fhandler_console. (fhandler_console::cursor_set): Make __reg3. (fhandler_console::cursor_rel): Ditto. (fhandler_console::cursor_get): Ditto. (fhandler_console::write): Fix "reverse index".
* * DevNotes: Add entry cgf-000024.Christopher Faylor2014-02-161-16/+17
| | | | | | | | | | | | | | | | | | | | | | | | | * fhandler.h (dev_console::state): Remove trailing underscore. (dev_console::args): Ditto. (dev_console::nargs): Ditto. (dev_console::info): Eliminate subclass. (dev_console::dwEnd): New field. (dev_console::scroll_window): New function. (dev_console::is_fullscreen): Ditto. (dev_console::fillin): Rename from fillin_info. (fhandler_console::scroll_buffer): Rename from scroll_screen. * fhandler_console.cc: Throughout s/dev_state\.info/dev_state/g. Accommodate other name changes. (dev_console::fillin): Accommodate rename. Notice max x/y written to. Forgo memset if GetConsoleScreenBufferInfo fails. (fhandler_console::scroll_buffer): Accommodate rename. Don't treat y coordinate of zero as top of screen. (dev_console::is_fullscreen): New function. (dev_console::scroll_window): Ditto. (fhandler_console::clear_screen): Just scroll the screen when clearing the screen in a state where the screen buffer is bigger than the screen. (fhandler_console::char_command): Try harder to get 'S' and 'T' working in the presence of a screen buffer. Use temporary 'n' variable rather than dev_state.args[0]. Use GNU ?: shortcut method.
* * fhandler.h (cltype): Add cl_buf_beg, cl_buf_end.Christopher Faylor2014-01-311-1/+3
| | | | | | | | * fhandler_console.cc (dev_console::console_attrs::set_cl_x): Honor buffer locations. (dev_console::console_attrs::set_cl_y): Ditto. (fhandler_console::write): On reset, use absolute positioning to go to beginning of buffer. Clear entire buffer.
* * fhandler.h: Update copyright.Christopher Faylor2014-01-041-3/+12
| | | | | | | | | | | | | | | | | | | (cltype): New enum. (dev_console::console_attrs): Define struct name. (dev_console::console_attrs::set_cl_x): New function. (dev_console::console_attrs::set_cl_y): New function. (fhandler_console::clear_screen): Redefine input params. * fhandler_console.cc: Update copyright. Throughout, reflect change in arguments to fhandler_console::clear_screeen. (fhandler_console::mouse_aware): Simplify logic slightly. (fhandler_console::scroll_screen): Remove hopefully obsolete win95 code. (dev_console::console_attrs::set_cl_x): New function. (dev_console::console_attrs::set_cl_y): New function. (fhandler_console::clear_screen): Redefine input params. Calculate position based on enum value. (region_split): Change arguments. Simplify. (ReadConsoleOutputWrapper): Remove coord argument since we now always use 0, 0. Send extra arguments to region_split.
* * fhandler.h (fhandler_pty_master::~fhandler_pty_master): Delete.Christopher Faylor2013-12-171-1/+0
| | | | * fhandler_tty.cc (fhandler_pty_master::~fhandler_pty_master): Ditto.
* * fhandler.h (fhandler_dev_clipboard): Add private memberCorinna Vinschen2013-12-101-0/+3
| | | | | | | | cygnativeformat. Declare private method set_clipboard. * fhandler_clipboard.cc (cygnativeformat): Convert static variable to fhandler_dev_clipboard member. (fhandler_dev_clipboard::set_clipboard): Convert from static function to fhandler_dev_clipboard method.
* * devices.in (dev_cygdrive_storage): Revert mapping to \Device\Null.Corinna Vinschen2013-10-311-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | (dev_storage): Ditto for /dev. * devices.cc: Regenerate. * fhandler.cc (fhandler_base::open_null): New method to open a fake \Device\Null handler. (fhandler_base::open): Fix formatting. Change O_ACCMODE test to a switch statement. Simplify a test which still tested for a now unused create_disposition. * fhandler.h (fhandler_base::open_null): Declare. (fhandler_netdrive::close): Declare. * fhandler_dev.cc (fhandler_dev::open): Open fake \Device\Null handle by just calling new open_null method. * fhandler_disk_file.cc (fhandler_cygdrive::open): Ditto. * fhandler_netdrive.cc (fhandler_netdrive::open): Call open_null rather than setting nohandle. (fhandler_netdrive::close): New method. * fhandler_registry.cc (fetch_hkey): Fix token in RegOpenUserClassesRoot call. Create valid key for HKEY_CURRENT_CONFIG by mapping to real key HKEY_LOCAL_MACHINE\System\CurrentControlSet\Hardware Profiles\Current. (fhandler_registry::open): Set nohandle only when using pseudo registry handle. * fhandler_virtual.cc (fhandler_virtual::opendir): Call open rather than just setting nohandle here. * fhandler_virtual::fstatvfs): Set ST_RDONLY fs flag. * globals.cc (ro_u_null): New readonly UNICODE_STRING for \Device\Null. * path.h (path_conv::set_path): Revert previous change caring for wide_path.
* * devices.in (dev_cygdrive_storage): Map to \Device\Null.Corinna Vinschen2013-10-301-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (dev_storage): Map /dev and /dev/windows to \Device\Null. * devices.cc: Regenerate. * dir.cc (opendir): Create unique id. Explain why. * fhandler.h (fhandler_dev::get_dev): Implement inline. (fhandler_cygdrive::close): Drop declaration. (fhandler_cygdrive::get_dev): Implement inline. (fhandler_windows::get_hwnd): Ditto. (fhandler_windows::set_close_on_exec): Drop declaration. (fhandler_windows::fixup_after_fork): Ditto. * fhandler_dev.cc (fhandler_dev::open): Call fhandler_disk_file::open without O_CREAT flag. Explain why. Create \Device\Null handle if /dev/ doesn't actually exist. (fhandler_dev::close): Drop nohandle case. (fhandler_dev::fstatvfs): Drop nohandle check. Test for fs_got_fs instead. Set ST_RDONLY fs flag for simulated /dev. (fhandler_dev::opendir): If /dev doesn't exist, call open() to create fake \Device\Null handle. Don't set nohandle. Set dir_exists correctly. (fhandler_dev::rewinddir): Call fhandler_disk_file::rewinddir only if /dev is a real directory. * fhandler_disk_file.cc (fhandler_disk_file::opendir): If called for the cygdrive dir, call open() to create fake \Device\Null handle. Only attach __DIR_mounts buffer to dir if not called for cygdrive dir. Don't set nohandle. (fhandler_cygdrive::open): Create \Device\Null handle. (fhandler_cygdrive::close): Remove. (fhandler_cygdrive::fstatvfs): Set ST_RDONLY fs flag. * fhandler_windows.cc (fhandler_windows::open): Create \Device\Null handle. (fhandler_windows::read): Don't add io_handle to WFMO handle array. Change subsequent test for return value accordingly. Fix test for "message arrived". (fhandler_windows::set_close_on_exec): Remove. (fhandler_windows::fixup_after_fork): Remove. * path.h (path_conv::set_path): Make sure wide_path is NULL when setting a new path. * select.cc (peek_windows): Use correct hWnd value, not io_handle. (fhandler_windows::select_read): Don't use io_handle as wait object. (fhandler_windows::select_write): Ditto. (fhandler_windows::select_except): Ditto.
* * devices.in (dev_storage): Map /dev/clipboard to \Device\Null.Corinna Vinschen2013-10-251-1/+0
| | | | | | | | | | | * devices.cc: Regenerate. * fhandler.h (fhandler_dev_clipboard::open): Drop declaration. * fhandler_clipboard.cc (fhandler_dev_clipboard::dup): Drop call to open. Set private members to 0 and call fhandler_base::dup. (fhandler_dev_clipboard::open): Remove so that default fhandler_base::open is used to open \Device\Null. (set_clipboard): Drop gratuitios call to RegisterClipboardFormatW. (fhandler_dev_clipboard::close): Call fhandler_base::close from here.
* * devices.in (dev_storage): Map /dev/random and /dev/urandom toCorinna Vinschen2013-10-251-3/+2
| | | | | | | | | | | | | | \Device\Null. * devices.cc: Regenerate. * fhandler.h (fhandler_dev_random::open): Drop declaration. (fhandler_dev_random::close): Ditto. (fhandler_dev_random::crypt_gen_random): Convert to static method. * fhandler_random.cc (fhandler_dev_random::open): Remove so that default fhandler_base::open is used to open \Device\Null. (fhandler_dev_random::close): Ditto. * fhandler_socket.cc (entropy_source): Delete. (fhandler_socket::af_local_set_secret): Remove entropy_source code and call fhandler_dev_random::crypt_gen_random directly instead.
* * fhandler.h (fhandler_dev_zero::lseek): Convert to inline method.Corinna Vinschen2013-10-241-4/+3
| | | | | | | | | | | | | (class fhandler_dev_random): Drop dummy_offset. (fhandler_dev_random::lseek): Convert to inline method. (fhandler_dev_dsp::lseek): Ditto. * fhandler_dsp.cc (fhandler_dev_dsp::lseek): Drop here. * fhandler_random.cc (fhandler_dev_random::open): Drop setting dummy_offset. (fhandler_dev_random::lseek): Drop here. * fhandler_tape.cc (fhandler_dev_tape::lseek): Make no-op, but keep old code for reference. * fhandler_zero.cc (fhandler_dev_zero::lseek): Drop here.
* * external.cc (fillout_pinfo): If start_time is 0, wait a while beforeChristopher Faylor2013-10-241-1/+1
| | | | | | | | | | returning the pinfo structure. * fhandler.cc (fhandler_base::open_setup): Convert from inline. * fhandler.h (fhandler_base::open_setup): Declare. * fhandler_console.cc (fhandler_console::open_setup): Always call fhandler_base::open_setup. * fhandler_tty.cc (fhandler_pty_slave::open_setup): Ditto. (fhandler_pty_master::open_setup): Ditto.
* * devices.in (dev_storage): Map /dev/zero and /dev/full to \Device\Null.Corinna Vinschen2013-10-241-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * devices.cc: Regenerate. * dtable.h (struct dtable): Make fhandler_base friend, rather than fhandler_disk_file. * fhandler.cc (fhandler_base::open_with_arch): Create unique id. (fhandler_base::cleanup): Call del_my_locks. (fhandler_base::fcntl): Handle F_GETLK, F_SETLK and F_SETLKW. * fhandler.h (fhandler_base::get_dev): Return real device number. (fhandler_base::set_unique_id): New inline method. (fhandler_disk_file::lock): Drop declaration. (fhandler_disk_file::get_dev): New method, return pc.fs_serial_number. (fhandler_dev_zero::open): Drop declaration. * fhandler_disk_file.cc (fhandler_disk_file::close): Move del_my_locks call to fhandler_base::open_with_arch. (fhandler_disk_file::fcntl): Move handling of locking commands to fhandler_base::fcntl. (fhandler_base::open_fs): Drop call to NtAllocateLocallyUniqueId. * fhandler_zero.cc (fhandler_dev_zero::open): Remove so that default fhandler_base::open is used to open \Device\Null. * flock.cc (fixup_lockf_after_exec): Finding a single fhandler is enough here. (fhandler_base::lock): Replace fhandler_disk_file::lock. Refuse to lock nohandle devices. Handle read/write test using POSIX flags. Explain why. Never fail on SEEK_CUR or SEEK_END, rather assume position 0, just as Linux. * net.cc (fdsock): Create unique id.
* * fhandler.h (fhandler_base::cleanup): Mark as extern rather than inline.Christopher Faylor2013-10-221-1/+1
| | | | | | * fhandler_base.cc (fhandler_base::cleanup): Define. * fhandler_tty.cc (fhandler_pty_slave::cleanup): Call fhandler_base::cleanup. (fhandler_pty_master::cleanup): Ditto.
* * autoload.cc (CryptAcquireContextW): Remove.Corinna Vinschen2013-10-151-3/+1
| | | | | | | | | | | | | | | | | | | | (CryptGenRandom): Remove. (CryptReleaseContext): Remove. (SystemFunction036): Define. Add comment to explain that this is actually the RtlGenRandom function. * fhandler.h (class fhandler_dev_random): Drop crypt_prov member. (fhandler_dev_random::fhandler_dev_random): Define inline. (fhandler_dev_random::dup): Drop declaration. * fhandler_random.cc (fhandler_dev_random::fhandler_dev_random): Remove here. (fhandler_dev_random::crypt_gen_random): Use RtlGenRandom to drop dependency to old Crypto API. (fhandler_dev_random::read): Implement an enhanced version of reading random bytes from RtlGenRandom for the sake of a better /dev/random emulation. (fhandler_dev_random::close): Just return 0 since crypt_prov doesn't exisyt anymore. (fhandler_dev_random::dup): Drop entirely for the same reason.
* Remove /dev/mem, /dev/kmem, /dev/port support.Corinna Vinschen2013-07-151-41/+0
| | | | | | | | | | | | | | * Makefile.in (DLL_OFILES): Drop fhandler_mem.o. (fhandler_mem_CFLAGS): Remove rule. * devices.in (enum fh_devices): Remove FH_MEM, FH_KMEM and FH_PORT. * devices.cc: Regenerate. * dtable.cc (fh_alloc): Drop handling for FH_MEM, FH_KMEM and FH_PORT. * fhandler.h (class fhandler_dev_mem): Remove. * fhandler_mem.cc: Remove file. * globals.cc (ro_u_pmem): Remove. * mmap.cc (fhandler_dev_mem::mmap): Remove. (fhandler_dev_mem::munmap): Remove. (fhandler_dev_mem::fixup_mmap_after_fork): Remove.
* * fhandler.cc (fhandler_base::lock): Move to flock.cc.Corinna Vinschen2013-06-041-2/+4
| | | | | | | | | | | | | | (fhandler_base::fixup_after_exec): Reset mandatory_locking. * fhandler.h (class fhandler_base): Add mandatory_locking status flag. Add mandatory_locking accessor methods. Accommodate change throughout. (fhandler_base::mand_lock): Declare. (class fhandler_disk_file): Drop in favor of new status flag. * (fhandler_disk_file::fcntl): Call need_fork_fixup if mandatory_locking flag gets set. * flock.cc (fhandler_base::lock): Define here. (flock): Handle mandatory_locking. (lockf): Ditto. (fhandler_base::mand_lock): Define.
* * autoload.cc (CancelSynchronousIo): Define.Corinna Vinschen2013-06-021-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | * fcntl.cc (fcntl64): Drop handling of locking commands. * fhandler.h (class fhandler_disk_file): Add mandatory_locking. (fhandler_disk_file::fcntl): Declare. (fhandler_disk_file::mand_lock): Declare. * fhandler_disk_file.cc (fhandler_disk_file::fhandler_disk_file): Initialize mandatory_locking. (fhandler_disk_file::fcntl): New method. Handle F_LCK_MANDATORY and locking commands. (fhandler_disk_file::dup): Duplicate mandatory_locking. Fix a bug when duplicating prw_handle failed. (fhandler_disk_file::fixup_after_fork): Reset mandatory_locking. * flock.cc (fhandler_disk_file::lock): Add comment. (struct lock_parms): New struct to pass parameters to blocking_lock_thr thread function. (blocking_lock_thr): New thread function. (fhandler_disk_file::mand_lock): New methof implementing mandatory locking with Windows semantics. * ntdll.h (NtLockFile): Declare. (NtUnlockFile): Declare. * include/fcntl.h: Fix a comment. (F_LCK_MANDATORY): Define. Add lengthy comment to explain.
* * fhandler.h (class fhandler_dev_random): Change type of pseudo toCorinna Vinschen2013-05-211-1/+1
| | | | uint32_t to make sure it's 32 bit on all supported platforms.
* * Merge in cygwin-64bit-branch.Corinna Vinschen2013-04-231-105/+109
|
* Throughout, change __attribute__ ((regparm (N))) to just __regN. Throughout,Christopher Faylor2013-01-211-130/+129
| | | | | | | | | | | | | | | | | | | (mainly in fhandler*) start fixing gcc 4.7.2 mismatch between regparm definitions and declarations. * gendef: Define some functions to take @ declaration to accommodate _regN defines which use __stdcall. * gentls_offsets: Define __regN macros as empty. * autoload.cc (wsock_init): Remove unneeded regparm attribute. * winsup.h (__reg1): Define. (__reg2): Define. (__reg3): Define. * advapi32.cc (DuplicateTokenEx): Coerce some initializers to avoid warnings from gcc 4.7.2. * exceptions.cc (status_info): Declare struct to use NTSTATUS. (cygwin_exception::dump_exception): Coerce e->ExceptionCode to NTSTATUS. * fhandler_clipboard.cc (cygnativeformat): Redefine as UINT to avoid gcc 4.7.2 warnings. (fhandler_dev_clipboard::read): Ditto.
* * fhandler.h (class dev_console): Flag for expanded control sequence.Corinna Vinschen2013-01-111-1/+2
| | | | * fhandler_console.cc (char_command): Supporting cursor style modes.
* * fhandler.h (class fhandler_dev_raw): Add members devbufalloc andCorinna Vinschen2012-10-131-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | devbufalign. (class fhandler_dev_floppy): Remove member bytes_per_sector; * fhandler_floppy.cc (bytes_per_sector): Define as devbufalign. (fhandler_dev_floppy::open): Set devbufalign to a multiple of the sector size and handle devbuf allocation and alignment in !O_DIRECT case here. Change comment accordingly. Call FSCTL_ALLOW_EXTENDED_DASD_IO for partitions as well. (fhandler_dev_floppy::raw_write): Fix comment. Rewrite and fix writing behaviour when application uses read and lseek. (fhandler_dev_floppy::lseek): Use rounddown macro. Call SetFilePointerEx rather than the old SetFilePointer. (fhandler_dev_floppy::ioctl): Reformat switch. Call IOCTL_DISK_UPDATE_PROPERTIES rather than IOCTL_DISK_UPDATE_DRIVE_SIZE in BLKRRPART case. Support BLKIOMIN, BLKIOOPT, BLKPBSZGET and BLKALIGNOFF. * fhandler_raw.cc (fhandler_dev_raw::fhandler_dev_raw): Initialize all devbuf-related members. (fhandler_dev_raw::~fhandler_dev_raw): Delete devbufalloc rather than devbuf. (fhandler_dev_raw::open): Drop allocating devbuf. (fhandler_dev_raw::dup): Allocate devbufalloc and set devbuf to support new sector-aligned devbuf handling. (fhandler_dev_raw::fixup_after_exec): Ditto. * fhandler_tape.cc (fhandler_dev_tape::open): Ditto, set devbufalign to 1. * include/cygwin/fs.h (BLKIOMIN): Define. (BLKIOOPT): Define. (BLKALIGNOFF): Define. (BLKPBSZGET): Define.
* whitespace cleanupChristopher Faylor2012-08-161-1/+1
|
* * fhandler.h (fhandler_socket::recv_internal): Add bool parameter.Corinna Vinschen2012-08-011-1/+1
| | | | | | | | | | | | | | | | Add regparm attribute. * fhandler_socket.cc (fhandler_socket::read): Call recv_internal with second parameter set to false. (fhandler_socket::readv): Ditto. (fhandler_socket::recvfrom): Ditto. (fhandler_socket::recv_internal): Convert use_recvmsg from local variable to parameter. Use as request for using WSARecvMsg. Only fail if WSARecvMsg can't be loaded and wsamsg->Control.len > 0, otherwise use WSARecv{From}. Restrict dwFlags to MSG_PEEK when using WSARecvMsg. (fhandler_socket::recvmsg): Prefer using WSARecvMsg. Change priority of tests for not using WSARecvMsg. Call recv_internal with second parameter set accordingly.
* * fhandler.h (class fhandler_dev_clipboard): Remove member eof.Corinna Vinschen2012-07-021-1/+0
| | | | | | | | | | | * fhandler_clipboard.cc: Throughout remove handling of eof member. (fhandler_dev_clipboard::write): Handle EOF condition immediately, rather than pushing it erroneously to the next read call. Rearrange code. Fix bug in CF_UNICODETEXT case which potentially dropped single bytes at the end of the buffer. Add comment. * strfuncs.cc (sys_cp_wcstombs): Allow returning non-NUL-terminated buffer if dst != NULL and len == (size_t) -1. Extend leading comment to explain what's returned in more detail.
* * DevNotes: Add entry cgf-000011.Christopher Faylor2012-06-031-9/+2
| | | | | | | | | | | | | | | | | | | * fhandler.h (fhandler_base::refcnt): Delete. (fhandler_base::inc_refcnt): New function. (fhandler_base::dec_refcnt): New function. * cygheap.h (cygheap_fdnew::~cygheap_fdnew): Accommodate split of refcnt to inc_refcnt/dec_refcnt. (cygheap_fdget::cygheap_fdget): Ditto. (cygheap_fdget::~cygheap_fdget::cygheap_fdget): Ditto. * dtable.cc (dtable::release): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::init_std_file_from_handle): Ditto. (dtable::dup3): On success, return with fdtab locked. * dtable.h (dtable): Add dup_finish as a friend. * syscalls.cc (dup_finish): Define new function. Increment refcnt while fdtab is locked. (dup2): Use common dup_finish() to perform dup operation. (dup3): Ditto.
* * fhandler.h (refcnt): Add i interlocked. Explain why.Corinna Vinschen2012-05-231-1/+5
| | | | | * winbase.h (ilockadd): New function. (InterlockedAdd): Define as ilockadd.
* * DevNotes: Add entry cgf-000005.Christopher Faylor2012-05-121-1/+1
| | | | | | | * fhandler.h (PIPE_ADD_PID): Redefine to something we actually DON'T use. * pipe.cc (fhandler_pipe::create): Avoid clearing all open_mode bits when checking for PIPE_ADD_PID. Properly keep track of len so that passed in name is not overwritten.
* * fhandler.h (PIPE_ADD_PID): Define new flag.Christopher Faylor2012-04-301-2/+6
| | | | | | | * pipe.cc (fhandler_pipe::create): Don't indiscriminately add process id to every pipe since some pipe names (fifo, tty) don't need it. * sigproc.cc (sigproc_init): Pass PIPE_ADD_PID to fhandler_pipe::create to ensure that pid is always part of sigwait pipe name.
* * fhandler.h (class dev_console): Add member ext_mouse_mode5.Corinna Vinschen2012-04-251-0/+1
| | | | | | * fhandler_console.cc (fhandler_console::read): Implement extended mouse mode 1005 (xterm, mintty). Fix actual mouse reporting for large coordinates.
* * fhandler.h (class dev_console): Add members ext_mouse_mode6 andCorinna Vinschen2012-04-241-0/+2
| | | | | | | | | | ext_mouse_mode15. * fhandler_console.cc (fhandler_console::read): Implement extended mouse modes 1015 (urxvt, mintty, xterm) and 1006 (xterm). Recognize, but don't implement extended mouse mode 1005 (xterm, mintty). Support mouse coordinates greater than 222 (each axis). Fix formatting. (fhandler_console::char_command): Initialize enhanced mouse reporting modes.