summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/fhandler.h
Commit message (Collapse)AuthorAgeFilesLines
* * 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.
* * fhandler.h (fhandler_base::nohandle): Revert to standard implementation.Christopher Faylor2012-04-181-8/+1
| | | | | | | | | | * dtable.cc (dtable::fixup_after_exec): Specifically reject releasing nohandle() type fhandlers rather than relying on contents of io_handle. (dtable::fixup_after_fork): Ditto. * fhandler_termios.cc: Add includes necessary for definitions of have_execed and have_execed_cygwin. (fhandler_termios::sigflush): Don't flush console input when we've started a non-Cygwin process.
* wincap.h: Rename assitant to assistant throughout. wincap.cc: Ditto.Christopher Faylor2012-04-151-0/+1
| | | | | | | | | | | | | * devices.in (exists_console): Use fhandler_console::exists () rather than raw test. * devices.cc: Regenerate. * fhandler.h (fhandler_console::exists): Define new function. * fhandler_console.cc (fhandler_console::need_invisible): Use fhandler_console::exists () rather than raw test. * spawn.cc: Rename assitant to assistant throughout. (child_info_spawn::worker): Simplify test for when to start a non-Cygwin process in its own process group. Just do it whenever we start a non-Cygwin process.
* * fhandler.h (fhandler_base::nohandle): Implement "by hand" rather than throughChristopher Faylor2012-04-061-1/+8
| | | | macro. Set io_handle to INVALID_HANDLE_VALUE when setting flag to true.
* * fhandler.h (fhandler_pty_common::bytes_available): Declare new function.Christopher Faylor2012-04-051-0/+2
| | | | | | | | | | | | | | | (fhandler_pty_master::flush_to_slave): Ditto. * fhandler_tty.cc (bytes_available): Define new function. (fhandler_pty_common::bytes_available): Ditto. (handler_pty_master::flush_to_slave): Ditto. (fhandler_pty_master::process_slave_output): Call flush_to_slave () here. Use bytes_available () rather than PeekNamedPipe. Cleanup sloppy logic. (fhandler_pty_slave::read): Use bytes_available () rather than PeekNamedPipe. (fhandler_pty_slave::ioctl): Ditto. (fhandler_pty_master::ioctl): Ditto. (fhandler_pty_master::cleanup): Remove ancient #if 0. * select.cc (peek_pipe): Call flush_to_slave whenever we're checking for a pty master.
* * fhandler.h (fhandler_base::stat_fixup): Rename fromCorinna Vinschen2012-04-021-1/+1
| | | | | | fhandler_base::set_ino_and_dev. * syscalls.cc (fhandler_base::stat_fixup): Ditto. Accommodate name change throughout. Fixup link count of console devices.
* * fhandler.h (fhandler_base::set_ino_and_dev): Declare.Corinna Vinschen2012-04-021-0/+1
| | | | | | | | * syscalls.cc (fhandler_base::set_ino_and_dev): New method to set st_ino, st_dev, and st_rdev for devices in a single spot. (fstat64): Call fhandler_base::set_ino_and_dev instead of setting st_ino, st_dev, and st_rdev here. (stat_worker): Ditto.
* * fhandler.h (fhandler_dev::open): Declare.Corinna Vinschen2012-04-021-0/+5
| | | | | | | | | | | | | | | | (fhandler_dev::close): Declare. (fhandler_dev::fstat): Declare. (fhandler_dev::fstatvfs): Declare. (fhandler_cygdrive::fstatvfs): Declare. * fhandler_dev.cc (fhandler_dev::open): New method. (fhandler_dev::close): Ditto. (fhandler_dev::fstat): Ditto. (fhandler_dev::fstatvfs): Ditto. * fhandler_disk_file.cc (fhandler_base::fstat_helper): Don't fill st_rdev. (fhandler_cygdrive::fstatvfs): New method. * path.h (path_conv::fs_got_fs): New method. * mount.h (fs_info::got_fs): Change type to bool, make public.
* (Interim checkin while we work on this)Christopher Faylor2012-03-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * devices.cc: Regenerate. * devices.h (device::noexpose): New field. (device::dev_on_fs): Make a bit field. (get_major): Use proper type for declaration. (expose): New field. (ext_dev_storage): Delete declaration. (dev_storage_size): Ditto. (dev_storage): New declaration. (dev_storage_end): Ditto. * devices.in: Mark /dev/ptym*, /dev/com*, /dev/pipe, /dev/fifo, and "/dev" as "no expose". * fhandler.h (fhandler_dev::lastrealpos): Delete declaration. (fhandler_dev::devidx): Declare new field. * fhandler_disk_file.cc: Move fhandler_dev functions into fhandler_dev.cc. * fhandler_dev.cc: Add includes needed for functions moved from fhandler_disk_file.cc. (dev_storage_scan_start): Define place to start listing devices. (dev_storage_size): Define size of array to scan. (fhandler_dev::fhandler_dev): Move here from fhandler_disk_file.cc. (fhandler_dev::opendir): Ditto. (fhandler_dev::readdir): Just check devidx for non-NULL to determine when to go to disk for /dev content. Use dev_storage rather than ext_dev_storage. Iterate over dev_storage using devidx pointer. Use accessor functions rather than raw references to the device struct. Only increment dir->__d_position when we are actually going to be returning something. Add debug_printf for exit. (fhandler_dev::rewinddir): Set devidx as appropriate depending on whether there's a /dev on disk or not. * gendevices: Don't mark dev_storage static but do put it in the _RDATA section. * path.cc (path_conv::check): Use new "device::expose()" function to decide to forbid programs from referencing internal device types.
* * Makefile.in (DLL_OFILES): Add fhandler_dev.o.Corinna Vinschen2012-03-291-0/+29
| | | | | | | | | | | | | | | | | | | | | | | * devices.h (DEV_DEV_MAJOR): Define. (FH_DEV): Redefine in terms of DEV_DEV_MAJOR. (ext_dev_storage): Declare. (dev_storage_size): Declare. (dev_dev_storage): Declare. (dev_dev): Define. (isdev_dev): Define. * devices.in (dev_dev_storage): Activate. (ext_dev_storage): Define as externally available pointer to dev_storage. (dev_storage_size): Define to contain number of dev_storage elements. * dir.cc (rmdir): Handle /dev as always not empty. * dtable.cc (fh_alloc): Handle DEV_DEV_MAJOR. * fhandler.h (fhandler_dev): New class, derived from fhandler_disk_file. (fhandler_union): Add fhandler_dev member. * fhandler_disk_file.cc (class __DIR_mounts): Handle /dev directory to make sure it always exists. * fhandler_dev.cc: New file implementing /dev. * globals.cc (ro_u_dev): New R/O unicode string. * path.cc (path_conv::check): Handle FH_DEV device.
* * fhandler.h (class fhandler_dev_clipboard): Add fstat method.Corinna Vinschen2012-03-261-0/+1
| | | | | | | | | * fhandler_clipboard.cc (cygcb_t): New type for Cygwin-specific clipboard format. (set_clipboard): Use new clipboard format to allow setting a timestamp. (fhandler_dev_clipboard::fstat): New method. Read modification and access timestamp as well as length from clipboard data. (fhandler_dev_clipboard::read): Use new clipboard format.
* Christopher Faylor <me.cygwin2012@cgf.cx>Christopher Faylor2012-03-121-0/+1
| | | | | | | | | | | * fhandler.h (wait_return): Add overlapped_nullread. * fhandler.cc (fhandler_base_overlapped::wait_overlapped): Detect zero-byte read as a special case. (fhandler_base_overlapped::raw_read): Keep looping when zero-byte read detected without EOF. (fhandler_base_overlapped::raw_write): Quiet gcc warning by adding overlapped_nullread to switch statement even though it will never actually be hit.
* tcgetsid: fix return typeEric Blake2012-02-281-2/+2
| | | | | | | | * include/sys/termios.h (tcgetsid): Fix return type. * termios.cc (tcgetsid): Likewise. * fhandler_termios.cc (fhandler_termios::tcgetsid): Likewise. * fhandler.h (fhandler_base): Likewise. * fhandler.cc (fhandler_base::tcgetsid): Likewise.