libc/winsup/cygwin/fhandler.h

2168 lines
65 KiB
C
Raw Normal View History

2000-02-17 20:38:33 +01:00
/* fhandler.h
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Red Hat, Inc.
2000-02-17 20:38:33 +01:00
This file is part of Cygwin.
This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
#pragma once
#include "pinfo.h"
2000-02-17 20:38:33 +01:00
* 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-06-04 02:12:29 +02:00
#include "tty.h"
/* fcntl flags used only internaly. */
#define O_NOSYMLINK 0x080000
#define O_DIROPEN 0x100000
/* newlib used to define O_NDELAY differently from O_NONBLOCK. Now it
properly defines both to be the same. Unfortunately, we have to
2001-10-29 00:05:49 +01:00
behave properly the old version, too, to accommodate older executables. */
#define OLD_O_NDELAY (CYGWIN_VERSION_CHECK_FOR_OLD_O_NONBLOCK ? 4 : 0)
/* Care for the old O_NDELAY flag. If one of the flags is set,
both flags are set. */
#define O_NONBLOCK_MASK (O_NONBLOCK | OLD_O_NDELAY)
/* It appears that 64K is the block size used for buffered I/O on NT.
Using this blocksize in read/write calls in the application results
in a much better performance than using smaller values. */
#define PREFERRED_IO_BLKSIZE ((blksize_t) 65536)
/* It also appears that this may be the only acceptable block size for
atomic writes to a pipe. It is a shame that we have to make this
so small. http://cygwin.com/ml/cygwin/2011-03/msg00541.html */
#define DEFAULT_PIPEBUFSIZE PREFERRED_IO_BLKSIZE
/* Used for fhandler_pipe::create. Use an available flag which will
never be used in Cygwin for this function. */
#define PIPE_ADD_PID FILE_FLAG_FIRST_PIPE_INSTANCE
2000-02-17 20:38:33 +01:00
extern const char *windows_device_names[];
extern struct __cygwin_perfile *perfile_table;
2000-02-17 20:38:33 +01:00
#define __fmode (*(user_data->fmode_ptr))
* path.h (pathconv_arg): Add PC_POSIX. (path_conv): Add normalized_path field. * path.cc (path_conv::~path_conv): New destructor. (path_conv::check): Set normalized_path, where appropriate. * dtable.cc (build_fhandler_from_name): Use normalized path from path_conv. * syscalls.cc (chroot): Ditto. * cygheap.h: Remove path_prefix_p declaration. Christopher Faylor <cgf@redhat.com> (minor fixups) * Makefile.in: Add fhandler_proc.o, fhandler_registry.o, fhandler_process.o and fhandler_virtual.o. * dtable.cc (dtable::build_fhandler): Add entries for FH_PROC, FH_REGISTRY and FH_PROCESS. Set unix_name to the normalized posix path. * fhandler.h: Add constants for FH_PROC, FH_REGISTRY and FH_PROCESS. Add class declarations for fhandler_virtual, fhandler_proc, fhandler_registry and fhandler_virtual. Update fhandler_union accordingly. * fhandler_proc.cc: New file. Add implementation for fhandler_proc. * fhandler_virtual.cc: New file. Add implementation for fhandler_virtual. * fhandler_process.cc: New file. Add implementation for fhandler_process. * fhandler_registry.cc: New file. Add implementation for fhandler_registry. * path.cc: Add isproc and isvirtual_dev macros. * path.cc (path_conv::check): Add check for virtual devices. * path.cc (mount_info::conv_to_win32_path): Convert paths in /proc to empty Win32 paths. * path.cc (chdir): Replace check for FH_CYGDRIVE with more generic isvirtual_dev macro. Force setting of posix path for virtual fhandlers. * path.h: Add externally visible path_prefix_p and normalized_posix_path prototypes.
2002-05-02 06:13:48 +02:00
extern const char proc[];
* Makefile.in (DLL_OFILES): Add fhandler_procsys.o. * devices.h (enum fh_devices): Add FH_PROCSYS. * devices.in (dev_procsys_storage): New device. * devices.cc: Regenerate. * dtable.cc (build_fh_pc): Add code to allocate fhandler_procsys. * fhandler.h (proc_len): Convert to size_t. (procsys): Declare. (procsys_len): Declare. (enum virtual_ftype_t): Move here from fhandler_virtual.h. Add members supported by fhandler_procsys. (fhandler_virtual::exists): Return virtual_ftype_t. Change in all derived classes. (class fhandler_procsys): New class. (fhandler_union): Add fhandler_procnet and fhandler_procsys members. * fhandler_disk_file.cc (__DIR_mounts::check_missing_mount): Use ro_u_proc. (fhandler_base::fstat_by_handle): Don't copy attributes if file is an NT device. (fhandler_base::fstat_by_name): Ditto. * fhandler_netdrive.cc (fhandler_netdrive::exists): Return virtual_ftype_t. * fhandler_proc.cc (proc_tab): Sort alphabetically. Use _VN macro to store length. (proc_len): Change to size_t. (proc_tab_cmp): New static function. (virt_tab_search): New function to search entry in virt_tab_t arrays. Use throughout in /proc and sibling classes instead of loop. (fhandler_proc::exists): Return virtual_ftype_t. * fhandler_process.cc (process_tab): Sort alphabetically. Use _VN macro to store length. (fhandler_process::exists): Return virtual_ftype_t. (fhandler_process::open): Simplify code. * fhandler_procnet.cc (procnet_tab): Sort alphabetically. Use _VN macro to store length. (fhandler_procnet::exists): Return virtual_ftype_t. (fhandler_procnet::open): Simplify. * fhandler_procsys.cc: New file. * fhandler_registry.cc (fhandler_registry::exists): Return virtual_ftype_t. * fhandler_virtual.cc (fhandler_virtual::exists): Ditto. * fhandler_virtual.h (enum virtual_ftype_t): Move to fhandler.h. (virt_tab_t): Add name_len member. (_VN): New macro. (virt_tab_search): Declare. * mount.cc (mount_info::conv_to_win32_path): Fix comment. Backslashify isprocsys_dev paths. * ntdll.h (STATUS_OBJECT_TYPE_MISMATCH): Define (STATUS_INSTANCE_NOT_AVAILABLE): Define. (STATUS_PIPE_NOT_AVAILABLE): Define. (STATUS_INVALID_PIPE_STATE): Define. (STATUS_PIPE_BUSY): Define. (SYMBOLIC_LINK_QUERY): Define. (NtOpenSymbolicLinkObject): Declare. (NtQuerySymbolicLinkObject): Declare. * path.cc (path_conv::check): Accommodate fact that exists method returns virtual_ftype_t now. Add cases for new virtual_ftype_t types. (cygwin_conv_path): Add GLOBALROOT prefix to native device paths. Make sure to strip \\?\ prefix only for actual filesystem-based paths, not for all paths. * path.h (isproc_dev): Add FH_PROCSYS. (isprocsys_dev): Define.
2010-09-06 11:47:01 +02:00
extern const size_t proc_len;
extern const char procsys[];
extern const size_t procsys_len;
2000-02-17 20:38:33 +01:00
class select_record;
* select.h: New file split from fhandler.h. (select_record::select_record): Define do-nothing constructor for "new" to avoid gratuitous zeroing. (select_info): New base class. (select_pipe_info): New class with methods for dealing with pipes. (select_socket_info): New class with methods for dealing with sockets. (select_serial_info): Dummy class for serial. (select_mailslot_info): Dummy class for mailslots. (select_stuff): Define device_specific_* as actual classes rather than void *. * dtable.h (dtable::select_read): Accommodate return value change to 'bool' and argument change to "select_stuff". (dtable::select_write): Ditto. (dtable::select_except): Ditto. * dtable.cc (dtable::select_read): Accommodate return value change to 'bool' and argument change to "select_stuff". (dtable::select_write): Ditto. (dtable::select_except): Ditto. * fhandler.h: Excise select-related classes. (fhandler_*::select_read): Change argument to select_stuff. (fhandler_*::select_write): Ditto. (fhandler_*::select_except): Ditto. * select.cc (UNIX_FD_ZERO): Use memset rather than bzero. (select_stuff::test_and_set): Change return type to bool. Allocate select_record on entry and let fhandler_*::select_* operate on the start.next field of select_stuff. (pipeinf): Delete. (select_pipe_info::select_pipe_info): New constructor. Allocates event for controlling pipe waits. (select_pipe_info::~select_pipe_info): New destructor. Destroy event. Stop thread. (select_pipe_info::add_watch_handle): New function. (thread_pipe): Wait for the hEvent part of any overlapped pipes before peeking. (start_thread_pipe): Don't allocate device_specific_pipe stuff here. Assume that it has been allocated earlier. (pipe_cleanup): Rely on select_pipe_info destructor to clean up pipe paraphenalia. (fhandler_*::select_*): Derive select_record from new select_stuff argument. (fhandler_pipe::select_*): Ditto. Allocate pipe-specific field if not already allocated. (serialinf): Delete. (thread_serial): serialinf -> select_serial_info. (fhandler_base::ready_for_read): Rewrite to accommodate change in argument to fhandler_*::select_*. (socketinf): Delete. (thread_socket): socketinf -> select_socket_info. (mailslotinf): Delete. (thread_mailslot): mailslotinf -> select_mailslot_info.
2009-06-30 23:18:44 +02:00
class select_stuff;
2000-02-17 20:38:33 +01:00
class fhandler_disk_file;
class inode_t;
typedef struct __DIR DIR;
struct dirent;
struct iovec;
struct __acl32;
2000-02-17 20:38:33 +01:00
enum dirent_states
{
dirent_ok = 0x0000,
dirent_saw_dot = 0x0001,
dirent_saw_dot_dot = 0x0002,
dirent_saw_eof = 0x0004,
dirent_isroot = 0x0008,
dirent_set_d_ino = 0x0010,
dirent_get_d_ino = 0x0020,
dirent_nfs_d_ino = 0x0040,
/* Global flags which must not be deleted on rewinddir or seekdir. */
dirent_info_mask = 0x0078
};
* Use new unified status_flag accessor methods from classes fhandler_*, tty_min, mtinfo and fs_info thoroughout. * fhandler.h: Redefine all set_close_on_exec methods to take a bool argument. (enum conn_state): Rename from connect_state. (class fhandler_base): Rename some status flags to align with accessor method names. Drop encoded flag entirely. Unify status accessor methods. Const'ify all read accessor methods. (class fhandler_socket): Ditto. (class fhandler_dev_raw): Ditto. * fhandler_disk_file.cc (fhandler_base::fstat_fs): Use fs.fs_is_fat() instead of evaluating FATness of file system here. (fhandler_disk_file::opendir): Drop call to set_encoded(). (fhandler_disk_file::readdir): Use pc.isencoded() directly. * mtinfo.h (class mtinfo_drive): Const'ify all read accessor methods. * path.cc (fsinfo_cnt): Add. (fs_info::update): Accomodate class changes. Evaluate file system name specific flags right here. Add thread safety for reading and writing global fsinfo array. * path.h (enum path_types): Drop values for flags kept in fs already. (struct fs_info): Move status informatin into private struct type status_flags. Add accessor methods. Remove path and file system name string arrays in favor of status bits. (class path_conv): Use new fs_info status information where appropriate. (path_conf::fs_has_ea): Rename from fs_fast_ea. (path_conf::fs_has_acls): New method. (path_conf::root_dir): Remove. (path_conf::volname): Remove. * syscalls (statfs): Evaluate root dir locally. * tty.h (class tty_min): Unify status accessor methods. Const'ify all read accessor methods.
2004-04-10 15:45:10 +02:00
enum conn_state
{
unconnected = 0,
connect_pending = 1,
connected = 2,
connect_failed = 3
};
enum line_edit_status
{
line_edit_ok = 0,
line_edit_input_done = 1,
line_edit_signalled = 2,
line_edit_error = 3,
line_edit_pipe_full = 4
};
enum bg_check_types
{
bg_error = -1,
bg_eof = 0,
bg_ok = 1,
bg_signalled = 2
};
enum query_state {
no_query = 0,
* autoload.cc (NtCreateFile): Add. * dir.cc (mkdir): Change set_file_attribute call to indicate that NT security isn't used. * fhandler.cc (fhandler_base::open_9x): New method, created from fhandler_base::open. (fhandler_base::open): Rearrange to use NtCreateFile instead of CreateFile. * fhandler.h (enum query_state): Redefine query_null_access to query_stat_control. query_null_access isn't allowed in NtCreateFile. (fhandler_base::open_9x): Declare. * fhandler_disk_file.cc (fhandler_base::fstat_fs): Use query_stat_control first, query_read_control if that fails. (fhandler_disk_file::fchmod): Call enable_restore_privilege before trying to open for query_write_control. Don't fall back to opening for query_read_control. (fhandler_disk_file::fchown): Ditto. (fhandler_disk_file::facl): Only request restore privilege and query access necessary for given cmd. * fhandler_raw.cc (fhandler_dev_raw::open): Call fhandler_base::open instead of opening device here. * ntdll.h (NtCreateFile): Declare. * path.cc (symlink_worker): Change set_file_attribute call to indicate that NT security isn't used. * sec_acl.cc (getacl): Fix bracketing. * sec_helper.cc (enable_restore_privilege): New function. * security.cc (str2buf2uni_cat): New function. (write_sd): Don't request restore permission here. * security.h (set_process_privileges): Drop stale declaration. (str2buf2uni): Declare. (str2buf2uni_cat): Declare. (enable_restore_privilege): Declare. * syscalls.cc (fchown32): Return immediate success on 9x.
2004-04-16 23:22:13 +02:00
query_read_control = 1,
query_read_attributes = 2,
query_write_control = 3,
query_write_dac = 4,
query_write_attributes = 5
};
enum del_lock_called_from {
on_close,
after_fork,
after_exec
};
* Makefile.in (DLL_OFILES): Add fhandler_procsys.o. * devices.h (enum fh_devices): Add FH_PROCSYS. * devices.in (dev_procsys_storage): New device. * devices.cc: Regenerate. * dtable.cc (build_fh_pc): Add code to allocate fhandler_procsys. * fhandler.h (proc_len): Convert to size_t. (procsys): Declare. (procsys_len): Declare. (enum virtual_ftype_t): Move here from fhandler_virtual.h. Add members supported by fhandler_procsys. (fhandler_virtual::exists): Return virtual_ftype_t. Change in all derived classes. (class fhandler_procsys): New class. (fhandler_union): Add fhandler_procnet and fhandler_procsys members. * fhandler_disk_file.cc (__DIR_mounts::check_missing_mount): Use ro_u_proc. (fhandler_base::fstat_by_handle): Don't copy attributes if file is an NT device. (fhandler_base::fstat_by_name): Ditto. * fhandler_netdrive.cc (fhandler_netdrive::exists): Return virtual_ftype_t. * fhandler_proc.cc (proc_tab): Sort alphabetically. Use _VN macro to store length. (proc_len): Change to size_t. (proc_tab_cmp): New static function. (virt_tab_search): New function to search entry in virt_tab_t arrays. Use throughout in /proc and sibling classes instead of loop. (fhandler_proc::exists): Return virtual_ftype_t. * fhandler_process.cc (process_tab): Sort alphabetically. Use _VN macro to store length. (fhandler_process::exists): Return virtual_ftype_t. (fhandler_process::open): Simplify code. * fhandler_procnet.cc (procnet_tab): Sort alphabetically. Use _VN macro to store length. (fhandler_procnet::exists): Return virtual_ftype_t. (fhandler_procnet::open): Simplify. * fhandler_procsys.cc: New file. * fhandler_registry.cc (fhandler_registry::exists): Return virtual_ftype_t. * fhandler_virtual.cc (fhandler_virtual::exists): Ditto. * fhandler_virtual.h (enum virtual_ftype_t): Move to fhandler.h. (virt_tab_t): Add name_len member. (_VN): New macro. (virt_tab_search): Declare. * mount.cc (mount_info::conv_to_win32_path): Fix comment. Backslashify isprocsys_dev paths. * ntdll.h (STATUS_OBJECT_TYPE_MISMATCH): Define (STATUS_INSTANCE_NOT_AVAILABLE): Define. (STATUS_PIPE_NOT_AVAILABLE): Define. (STATUS_INVALID_PIPE_STATE): Define. (STATUS_PIPE_BUSY): Define. (SYMBOLIC_LINK_QUERY): Define. (NtOpenSymbolicLinkObject): Declare. (NtQuerySymbolicLinkObject): Declare. * path.cc (path_conv::check): Accommodate fact that exists method returns virtual_ftype_t now. Add cases for new virtual_ftype_t types. (cygwin_conv_path): Add GLOBALROOT prefix to native device paths. Make sure to strip \\?\ prefix only for actual filesystem-based paths, not for all paths. * path.h (isproc_dev): Add FH_PROCSYS. (isprocsys_dev): Define.
2010-09-06 11:47:01 +02:00
enum virtual_ftype_t {
virt_blk = -7, /* Block special */
virt_chr = -6, /* Character special */
virt_fsfile = -5, /* FS-based file via /proc/sys */
virt_socket = -4, /* Socket */
virt_pipe = -3, /* Pipe */
virt_symlink = -2, /* Symlink */
virt_file = -1, /* Regular file */
virt_none = 0, /* Invalid, Error */
virt_directory = 1, /* Directory */
virt_rootdir = 2, /* Root directory of virtual FS */
virt_fsdir = 3, /* FS-based directory via /proc/sys */
};
2000-02-17 20:38:33 +01:00
class fhandler_base
{
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
friend class dtable;
friend void close_all_files (bool);
struct status_flags
{
* fhandler.h (fhandler_pipe::create_selectable): Remove optional argument, take an options argument for CreateNamedPipe/CreateFile. Change handle arguments to expect pointers. (fhandler_fifo::fifo_state): Delete. (fhandler_fifo::dummy_client): Ditto. (fhandler_fifo::open_nonserver): Ditto. (fhandler_fifo::wait_state): Ditto. (fhandler_fifo::raw_write): Ditto. (fhandler_fifo::read_ready): New field. (fhandler_fifo::write_ready): Ditto. (fhandler_fifo::wait): Modify argument. (fhandler_fifo::fifo_name): Add a new argument. (fhandler_fifo::fixup_after_fork): New function. * fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Remove initialization of expunged elements. Initialize new handles to NULL. (fhandler_fifo::open_nonserver): Delete. (fnevent): New macro for creating a named event. (fnpipe): New macro for creating a unique named pipe name. (create_pipe): New macro for simplification of named pipe creation. (fhandler_fifo::fifo_name): Use new argument when creating a shared name. (fhandler_fifo::open): Rewrite. Use events to synchronize. (pure_debug_printf): New macro, active only when DEBUGGING. (fhandler_fifo::wait): Rewrite to wait for new fifo events which are supplied as a parameter. (fhandler_fifo::raw_read): Rewrite to use handle mechanism to detect client-side disconnect. (fhandler_fifo::raw_write): Delete. (fhandler_fifo::close): Remove accommodations for expunged fields. Close event handles. (fhandler_fifo::dup): Remove accommodations for expunged fields. Duplicate event handles. (fhandler_fifo::fixup_after_fork): New function. Perform fixups on event handles. (fhandler_fifo::set_close_on_exec): Remove accommodations for expunged fields. Set inheritance for new handle fields. * miscfuncs.cc (CreatePipeOverlapped): Accommodate changes in fhandler_pipe::create_selectable. * tty.cc (tty::not_allocated): Ditto. * pipe.cc (fhandler_pipe::create): Ditto. (fhandler_pipe::create_selectable): Accept an extra open_mode argument. Pass arguments by reference and allow opening one end of the pipe at a time. * sys/strace.h (debug_only_printf): Define new macro which calls debug_printf only when DEBUGGING is defined.
2011-10-30 05:50:36 +01:00
unsigned rbinary : 1; /* binary read mode */
unsigned rbinset : 1; /* binary read mode explicitly set */
unsigned wbinary : 1; /* binary write mode */
unsigned wbinset : 1; /* binary write mode explicitly set */
unsigned nohandle : 1; /* No handle associated with fhandler. */
unsigned did_lseek : 1; /* set when lseek is called as a flag that
_write should check if we've moved
beyond EOF, zero filling or making
file sparse if so. */
* fhandler.h (fhandler_pipe::create_selectable): Remove optional argument, take an options argument for CreateNamedPipe/CreateFile. Change handle arguments to expect pointers. (fhandler_fifo::fifo_state): Delete. (fhandler_fifo::dummy_client): Ditto. (fhandler_fifo::open_nonserver): Ditto. (fhandler_fifo::wait_state): Ditto. (fhandler_fifo::raw_write): Ditto. (fhandler_fifo::read_ready): New field. (fhandler_fifo::write_ready): Ditto. (fhandler_fifo::wait): Modify argument. (fhandler_fifo::fifo_name): Add a new argument. (fhandler_fifo::fixup_after_fork): New function. * fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Remove initialization of expunged elements. Initialize new handles to NULL. (fhandler_fifo::open_nonserver): Delete. (fnevent): New macro for creating a named event. (fnpipe): New macro for creating a unique named pipe name. (create_pipe): New macro for simplification of named pipe creation. (fhandler_fifo::fifo_name): Use new argument when creating a shared name. (fhandler_fifo::open): Rewrite. Use events to synchronize. (pure_debug_printf): New macro, active only when DEBUGGING. (fhandler_fifo::wait): Rewrite to wait for new fifo events which are supplied as a parameter. (fhandler_fifo::raw_read): Rewrite to use handle mechanism to detect client-side disconnect. (fhandler_fifo::raw_write): Delete. (fhandler_fifo::close): Remove accommodations for expunged fields. Close event handles. (fhandler_fifo::dup): Remove accommodations for expunged fields. Duplicate event handles. (fhandler_fifo::fixup_after_fork): New function. Perform fixups on event handles. (fhandler_fifo::set_close_on_exec): Remove accommodations for expunged fields. Set inheritance for new handle fields. * miscfuncs.cc (CreatePipeOverlapped): Accommodate changes in fhandler_pipe::create_selectable. * tty.cc (tty::not_allocated): Ditto. * pipe.cc (fhandler_pipe::create): Ditto. (fhandler_pipe::create_selectable): Accept an extra open_mode argument. Pass arguments by reference and allow opening one end of the pipe at a time. * sys/strace.h (debug_only_printf): Define new macro which calls debug_printf only when DEBUGGING is defined.
2011-10-30 05:50:36 +01:00
unsigned query_open : 3; /* open file without requesting either
2005-02-13 19:17:29 +01:00
read or write access */
unsigned close_on_exec : 1; /* close-on-exec */
unsigned need_fork_fixup : 1; /* Set if need to fixup after fork. */
Implement fhandler reference counting. * cygheap.h (cygheap_fdmanip::release): Make virtual. (cygheap_fdnew::~cygheap_fdnew): New destructor increments reference count when fd has been allocated. (cygheap_fdget::fh): New (old?) field. (cygheap_fdget::cygheap_fdget): Increment reference count when we've found an active fd. Set fh appropriately. (cygheap_fdget::~cygheap_fdget): Decrement reference count when appropriate. Delete fh if reference count goes to zero. (cygheap_fdget::release): New function. Do more bookkeping on release. * dtable.cc (dtable::release): Change from void to boolean return. Only delete the fhandler when its reference count is <= 0 (this should be a fairly unusual case). Return true if fhandler has been deleted. (cygwin_attach_handle_to_fd): Increment reference count when fh is assigned. (dtable::init_std_file_from_handle): Ditto. * dtable.h (dtable::release): Change return to boolean. * fhandler.cc (fhandler_base::fhandler_base): Set new isclosed flag to false. Set _refcnt to zero. (fhandler_base::close): Simplify paranoid debugging output. Set new isclosed() flag. (fhandler_base_overlapped::wait_overlapped): Use isclosed() flag to avoid querying the exception handle. * fhandler.h (fhandler_base::_refcnt): New field. (fhandler_base::refcnt): New function. (fhandler_base::isclosed): Implement. (fhandler_base::fhandler_base): Set isclosed to false. * syscalls.cc: Remove space after function before parentheses for several strace printfs. (dup): Add standard strace "leaver" code. (dup2): Ditto. (dup3): Ditto. (remove): Ditto. (getpid): Ditto. (getppid): Ditto. (lseek64): Fix strace debugging to correctly use %R. * fhandler_termios.cc (fhandler_termios::tcsetpgrp): Avoid sending signals to other processes if we're debugging since it can cause a deadlock with the calling debugger. * exceptions.cc (_cygtls::call_signal_handler): Add debugging-only strace output.
2011-12-17 01:03:31 +01:00
unsigned isclosed : 1; /* Set when fhandler is closed. */
public:
status_flags () :
* Use new unified status_flag accessor methods from classes fhandler_*, tty_min, mtinfo and fs_info thoroughout. * fhandler.h: Redefine all set_close_on_exec methods to take a bool argument. (enum conn_state): Rename from connect_state. (class fhandler_base): Rename some status flags to align with accessor method names. Drop encoded flag entirely. Unify status accessor methods. Const'ify all read accessor methods. (class fhandler_socket): Ditto. (class fhandler_dev_raw): Ditto. * fhandler_disk_file.cc (fhandler_base::fstat_fs): Use fs.fs_is_fat() instead of evaluating FATness of file system here. (fhandler_disk_file::opendir): Drop call to set_encoded(). (fhandler_disk_file::readdir): Use pc.isencoded() directly. * mtinfo.h (class mtinfo_drive): Const'ify all read accessor methods. * path.cc (fsinfo_cnt): Add. (fs_info::update): Accomodate class changes. Evaluate file system name specific flags right here. Add thread safety for reading and writing global fsinfo array. * path.h (enum path_types): Drop values for flags kept in fs already. (struct fs_info): Move status informatin into private struct type status_flags. Add accessor methods. Remove path and file system name string arrays in favor of status bits. (class path_conv): Use new fs_info status information where appropriate. (path_conf::fs_has_ea): Rename from fs_fast_ea. (path_conf::fs_has_acls): New method. (path_conf::root_dir): Remove. (path_conf::volname): Remove. * syscalls (statfs): Evaluate root dir locally. * tty.h (class tty_min): Unify status accessor methods. Const'ify all read accessor methods.
2004-04-10 15:45:10 +02:00
rbinary (0), rbinset (0), wbinary (0), wbinset (0), nohandle (0),
did_lseek (0), query_open (no_query), close_on_exec (0),
Implement fhandler reference counting. * cygheap.h (cygheap_fdmanip::release): Make virtual. (cygheap_fdnew::~cygheap_fdnew): New destructor increments reference count when fd has been allocated. (cygheap_fdget::fh): New (old?) field. (cygheap_fdget::cygheap_fdget): Increment reference count when we've found an active fd. Set fh appropriately. (cygheap_fdget::~cygheap_fdget): Decrement reference count when appropriate. Delete fh if reference count goes to zero. (cygheap_fdget::release): New function. Do more bookkeping on release. * dtable.cc (dtable::release): Change from void to boolean return. Only delete the fhandler when its reference count is <= 0 (this should be a fairly unusual case). Return true if fhandler has been deleted. (cygwin_attach_handle_to_fd): Increment reference count when fh is assigned. (dtable::init_std_file_from_handle): Ditto. * dtable.h (dtable::release): Change return to boolean. * fhandler.cc (fhandler_base::fhandler_base): Set new isclosed flag to false. Set _refcnt to zero. (fhandler_base::close): Simplify paranoid debugging output. Set new isclosed() flag. (fhandler_base_overlapped::wait_overlapped): Use isclosed() flag to avoid querying the exception handle. * fhandler.h (fhandler_base::_refcnt): New field. (fhandler_base::refcnt): New function. (fhandler_base::isclosed): Implement. (fhandler_base::fhandler_base): Set isclosed to false. * syscalls.cc: Remove space after function before parentheses for several strace printfs. (dup): Add standard strace "leaver" code. (dup2): Ditto. (dup3): Ditto. (remove): Ditto. (getpid): Ditto. (getppid): Ditto. (lseek64): Fix strace debugging to correctly use %R. * fhandler_termios.cc (fhandler_termios::tcsetpgrp): Avoid sending signals to other processes if we're debugging since it can cause a deadlock with the calling debugger. * exceptions.cc (_cygtls::call_signal_handler): Add debugging-only strace output.
2011-12-17 01:03:31 +01:00
need_fork_fixup (0), isclosed (0)
{}
} status, open_status;
* dtable.cc (dtable::build_fhandler): Issue internal error on unknown device. * fhandler.cc (fhandler_base::close): Show both name and handle in debugging output. * fhandler.h (fhandler_base::get_guard): New virtual method. (fhandler_pipe::get_guard): New method. (fhandler_socket::ready_for_read): Delete declaration. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (struct select_record::peek): Declare new method. * select.cc (MAKEready): Delete. (peek_pipe): Use get_guard method to retrieve potential guard mutex handle. (fhandler_base::ready_for_read): Rewrite as generic ready-for-read handler. Should only be called for "slow" devices. (fhandler_socket::ready_for_read): Delete definition. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (fhandler_pipe::select_read): Fill in new peek record in select_record structure. (fhandler_console::select_read): Ditto. (fhandler_tty_common::select_read): Ditto. (fhandler_serial::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_tty_slave::ready_for_read): Check for tty not open. Set errnos appropriately. * syscalls.cc (_read): Allow ready_for_read to set errno. * pinfo.cc (pinfo::init): Return spawn/NO_WAIT process as valid if it is initializing. * sigproc.cc (getsem): Adjust wait for process to initialize downward to avoid huge waits.
2001-11-01 22:15:53 +01:00
private:
ACCESS_MASK access;
ULONG options;
2000-02-17 20:38:33 +01:00
HANDLE io_handle;
* smallprint.cc (__small_vswprintf): Fix uninitialized usage of `w'. Revamp advisory file locking to avoid cross reference pointers as well as to allow BSD flock semantics. More agressively delete unused nodes and sync objects. * fhandler.h (fhandler_base::ino): Rename from namehash. Fix comment. (fhandler_base::node): Remove. (fhandler_base::unique_id): Add. (fhandler_base::del_my_locks): New method. (get_ino): Rename from get_namehash. Change usage throughout Cygwin. (get_unique_id): New method. * fhandler.cc (fhandler_base::close): Call own del_my_locks method. Fix comment. (fhandler_base::fhandler_base): Accommodate new and changed members. (fhandler_base::fixup_after_fork): Call del_my_locks. (fhandler_base::fixup_after_exec): Ditto for files with close-on-exec flag set. * fhandler_disk_file.cc (get_ino_by_handle): Rename from readdir_get_ino_by_handle. Accommodate throughout. (fhandler_base::open_fs): Fill ino with inode number if FS has good inodes. Allocate a LUID and store in unique_id to recognize file descriptors referencing the same file object. * flock.cc: Drop flock TODO comments. Use explicit types __dev32_t and __ino64_t instead of dev_t and ino_t. (LOCK_OBJ_NAME_LEN): Change to reflect longer lf_id length. (get_obj_handle_count): New method. (lockf_t::lf_id): Change type to long long. (inode_t::get_lock_obj_handle_count): Drop in favor of static function get_obj_handle_count. (inode_t::del_locks): Remove. (inode_t::get): Add create_if_missing flag argument. (inode_t::del_my_locks): Reimplement to handle POSIX and BSD flock locks. Return if node can be deleted or not. (inode_t::~inode_t): Ditto. Close handles to i_dir and i_mtx. (fixup_lockf_after_fork): Remove. (fhandler_base::del_my_locks): New method. (fixup_lockf_after_exec): Check if node can be deleted. (inode_t::get): Only create node if create_if_missing is set. Lock the returned node here before unlocking the node list. (inode_t::get_all_locks_list): Accommodate new lf_id length. (inode_t::create_lock_obj): Ditto. (lockf_t::open_lock_obj): Ditto. Change return type to bool. De-const. Set lf_obj instead of returning a handle. (lockf_t::del_lock_obj): Call SetEvent only if new incoming parameters allow it. Explain how it's supposed to work. (fhandler_disk_file::lock): Only fetch file length in SEEK_END case. Use NtQueryInformationFile(FileStandardInformation) instead of calling fstat_by_handle. Always unlock node before returning. Use fhandler's unique id to create lf_id for BSD flock locks. Rely on node lock from inode_t::get. Call del_lock_obj on removed locks here to allow explicit unlocking. Delete node if no lock exists on the file anymore. (lf_setlock): Get file handle as additional parameter. Handle the fact that lf_getblock now always opens the attached event object. Reactivate erroneously applied patch which deactivates setting thread priority. Additionally handle blocking on BSD flock locks. (lf_clearlock): Get file handle as additional parameter. (lf_getlock): Close event handle opened by lf_getblock. (lf_getblock): Open potentially blocking event object here and check its signal state if it's a BSD flock lock. (lf_wakelock): Get file handle as additional parameter. * fork.cc (frok::child): Drop call to fixup_lockf_after_fork. * ntdll.h (struct _EVENT_BASIC_INFORMATION): Define. (enum _EVENT_INFORMATION_CLASS): Define. (NtQueryEvent): Declare. * fhandler.h (fhandler_base::fs_flags): Remove. (fhandler_base::set_fs_flags): Remove. (fhandler_base::get_fs_flags): Remove. * fhandler.cc (fhandler_base::write): Check for sparse file using pc.fs_flags(). * fhandler_disk_file.cc (fhandler_disk_file::ftruncate): Ditto. The return of the volume serial number in fs_info. * fhandler.h (get_dev): New method. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Drop call to NtQueryVolumeInformationFile(FileFsVolumeInformation). Just use get_dev() method. * fhandler_fifo.cc (fhandler_fifo::open) Use device ID and inode number to generate fifo name. * path.h (fs_info::sernum): New member. (fs_info::serial_number): New method. (path_conv::fs_serial_number): New method. * path.cc (fs_info::update): Fetch volume serial number and store in sernum.
2008-03-31 20:03:25 +02:00
__ino64_t ino; /* file ID or hashed filename, depends on FS. */
Implement fhandler reference counting. * cygheap.h (cygheap_fdmanip::release): Make virtual. (cygheap_fdnew::~cygheap_fdnew): New destructor increments reference count when fd has been allocated. (cygheap_fdget::fh): New (old?) field. (cygheap_fdget::cygheap_fdget): Increment reference count when we've found an active fd. Set fh appropriately. (cygheap_fdget::~cygheap_fdget): Decrement reference count when appropriate. Delete fh if reference count goes to zero. (cygheap_fdget::release): New function. Do more bookkeping on release. * dtable.cc (dtable::release): Change from void to boolean return. Only delete the fhandler when its reference count is <= 0 (this should be a fairly unusual case). Return true if fhandler has been deleted. (cygwin_attach_handle_to_fd): Increment reference count when fh is assigned. (dtable::init_std_file_from_handle): Ditto. * dtable.h (dtable::release): Change return to boolean. * fhandler.cc (fhandler_base::fhandler_base): Set new isclosed flag to false. Set _refcnt to zero. (fhandler_base::close): Simplify paranoid debugging output. Set new isclosed() flag. (fhandler_base_overlapped::wait_overlapped): Use isclosed() flag to avoid querying the exception handle. * fhandler.h (fhandler_base::_refcnt): New field. (fhandler_base::refcnt): New function. (fhandler_base::isclosed): Implement. (fhandler_base::fhandler_base): Set isclosed to false. * syscalls.cc: Remove space after function before parentheses for several strace printfs. (dup): Add standard strace "leaver" code. (dup2): Ditto. (dup3): Ditto. (remove): Ditto. (getpid): Ditto. (getppid): Ditto. (lseek64): Fix strace debugging to correctly use %R. * fhandler_termios.cc (fhandler_termios::tcsetpgrp): Avoid sending signals to other processes if we're debugging since it can cause a deadlock with the calling debugger. * exceptions.cc (_cygtls::call_signal_handler): Add debugging-only strace output.
2011-12-17 01:03:31 +01:00
long _refcnt;
2000-02-17 20:38:33 +01:00
* dtable.cc (dtable::build_fhandler): Issue internal error on unknown device. * fhandler.cc (fhandler_base::close): Show both name and handle in debugging output. * fhandler.h (fhandler_base::get_guard): New virtual method. (fhandler_pipe::get_guard): New method. (fhandler_socket::ready_for_read): Delete declaration. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (struct select_record::peek): Declare new method. * select.cc (MAKEready): Delete. (peek_pipe): Use get_guard method to retrieve potential guard mutex handle. (fhandler_base::ready_for_read): Rewrite as generic ready-for-read handler. Should only be called for "slow" devices. (fhandler_socket::ready_for_read): Delete definition. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (fhandler_pipe::select_read): Fill in new peek record in select_record structure. (fhandler_console::select_read): Ditto. (fhandler_tty_common::select_read): Ditto. (fhandler_serial::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_tty_slave::ready_for_read): Check for tty not open. Set errnos appropriately. * syscalls.cc (_read): Allow ready_for_read to set errno. * pinfo.cc (pinfo::init): Return spawn/NO_WAIT process as valid if it is initializing. * sigproc.cc (getsem): Adjust wait for process to initialize downward to avoid huge waits.
2001-11-01 22:15:53 +01:00
protected:
2000-02-17 20:38:33 +01:00
/* File open flags from open () and fcntl () calls */
int openflags;
2000-02-17 20:38:33 +01:00
char *rabuf; /* used for crlf conversion in text files */
size_t ralen;
size_t raixget;
size_t raixput;
size_t rabuflen;
* smallprint.cc (__small_vswprintf): Fix uninitialized usage of `w'. Revamp advisory file locking to avoid cross reference pointers as well as to allow BSD flock semantics. More agressively delete unused nodes and sync objects. * fhandler.h (fhandler_base::ino): Rename from namehash. Fix comment. (fhandler_base::node): Remove. (fhandler_base::unique_id): Add. (fhandler_base::del_my_locks): New method. (get_ino): Rename from get_namehash. Change usage throughout Cygwin. (get_unique_id): New method. * fhandler.cc (fhandler_base::close): Call own del_my_locks method. Fix comment. (fhandler_base::fhandler_base): Accommodate new and changed members. (fhandler_base::fixup_after_fork): Call del_my_locks. (fhandler_base::fixup_after_exec): Ditto for files with close-on-exec flag set. * fhandler_disk_file.cc (get_ino_by_handle): Rename from readdir_get_ino_by_handle. Accommodate throughout. (fhandler_base::open_fs): Fill ino with inode number if FS has good inodes. Allocate a LUID and store in unique_id to recognize file descriptors referencing the same file object. * flock.cc: Drop flock TODO comments. Use explicit types __dev32_t and __ino64_t instead of dev_t and ino_t. (LOCK_OBJ_NAME_LEN): Change to reflect longer lf_id length. (get_obj_handle_count): New method. (lockf_t::lf_id): Change type to long long. (inode_t::get_lock_obj_handle_count): Drop in favor of static function get_obj_handle_count. (inode_t::del_locks): Remove. (inode_t::get): Add create_if_missing flag argument. (inode_t::del_my_locks): Reimplement to handle POSIX and BSD flock locks. Return if node can be deleted or not. (inode_t::~inode_t): Ditto. Close handles to i_dir and i_mtx. (fixup_lockf_after_fork): Remove. (fhandler_base::del_my_locks): New method. (fixup_lockf_after_exec): Check if node can be deleted. (inode_t::get): Only create node if create_if_missing is set. Lock the returned node here before unlocking the node list. (inode_t::get_all_locks_list): Accommodate new lf_id length. (inode_t::create_lock_obj): Ditto. (lockf_t::open_lock_obj): Ditto. Change return type to bool. De-const. Set lf_obj instead of returning a handle. (lockf_t::del_lock_obj): Call SetEvent only if new incoming parameters allow it. Explain how it's supposed to work. (fhandler_disk_file::lock): Only fetch file length in SEEK_END case. Use NtQueryInformationFile(FileStandardInformation) instead of calling fstat_by_handle. Always unlock node before returning. Use fhandler's unique id to create lf_id for BSD flock locks. Rely on node lock from inode_t::get. Call del_lock_obj on removed locks here to allow explicit unlocking. Delete node if no lock exists on the file anymore. (lf_setlock): Get file handle as additional parameter. Handle the fact that lf_getblock now always opens the attached event object. Reactivate erroneously applied patch which deactivates setting thread priority. Additionally handle blocking on BSD flock locks. (lf_clearlock): Get file handle as additional parameter. (lf_getlock): Close event handle opened by lf_getblock. (lf_getblock): Open potentially blocking event object here and check its signal state if it's a BSD flock lock. (lf_wakelock): Get file handle as additional parameter. * fork.cc (frok::child): Drop call to fixup_lockf_after_fork. * ntdll.h (struct _EVENT_BASIC_INFORMATION): Define. (enum _EVENT_INFORMATION_CLASS): Define. (NtQueryEvent): Declare. * fhandler.h (fhandler_base::fs_flags): Remove. (fhandler_base::set_fs_flags): Remove. (fhandler_base::get_fs_flags): Remove. * fhandler.cc (fhandler_base::write): Check for sparse file using pc.fs_flags(). * fhandler_disk_file.cc (fhandler_disk_file::ftruncate): Ditto. The return of the volume serial number in fs_info. * fhandler.h (get_dev): New method. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Drop call to NtQueryVolumeInformationFile(FileFsVolumeInformation). Just use get_dev() method. * fhandler_fifo.cc (fhandler_fifo::open) Use device ID and inode number to generate fifo name. * path.h (fs_info::sernum): New member. (fs_info::serial_number): New method. (path_conv::fs_serial_number): New method. * path.cc (fs_info::update): Fetch volume serial number and store in sernum.
2008-03-31 20:03:25 +02:00
/* Used for advisory file locking. See flock.cc. */
long long unique_id;
void del_my_locks (del_lock_called_from);
HANDLE read_state;
2000-02-17 20:38:33 +01:00
* dtable.cc (dtable::build_fhandler): Issue internal error on unknown device. * fhandler.cc (fhandler_base::close): Show both name and handle in debugging output. * fhandler.h (fhandler_base::get_guard): New virtual method. (fhandler_pipe::get_guard): New method. (fhandler_socket::ready_for_read): Delete declaration. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (struct select_record::peek): Declare new method. * select.cc (MAKEready): Delete. (peek_pipe): Use get_guard method to retrieve potential guard mutex handle. (fhandler_base::ready_for_read): Rewrite as generic ready-for-read handler. Should only be called for "slow" devices. (fhandler_socket::ready_for_read): Delete definition. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (fhandler_pipe::select_read): Fill in new peek record in select_record structure. (fhandler_console::select_read): Ditto. (fhandler_tty_common::select_read): Ditto. (fhandler_serial::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_tty_slave::ready_for_read): Check for tty not open. Set errnos appropriately. * syscalls.cc (_read): Allow ready_for_read to set errno. * pinfo.cc (pinfo::init): Return spawn/NO_WAIT process as valid if it is initializing. * sigproc.cc (getsem): Adjust wait for process to initialize downward to avoid huge waits.
2001-11-01 22:15:53 +01:00
public:
long inc_refcnt () {return InterlockedIncrement (&_refcnt);}
2012-08-17 01:34:45 +02:00
long dec_refcnt () {return InterlockedDecrement (&_refcnt);}
class fhandler_base *archetype;
* cygheap.h (cygheap_types): Add HEAP_ARCHETYPES. (init_cheap::ctty): Change to pointer. * dtable.h (dtable::find_archetype): Declare new function. (dtable::add_archetype): Declare new function. (dtable::delete_archetype): Declare new function. (dtable::narchetypes): Declare. (dtable::farchetypes): Declare. (dtable::initial_archetype_size): Declare. (dtable::dtable): Initialize new fields. (dtable::initial_archetype_size): Declare. * dtable.cc (dtable::find_archetype): Define new function. (dtable::add_archetype): Define new function. (dtable::delete_archetype): Define new function. (dtable::initial_archetype_size): Define. * fhandler.h (fhandler_base::archetype): Declare. (fhandler_base::usecount): Declare. * fhandler.cc (fhandler_base::fhandler_base): Initialize new fields. * fhandler_console.cc (fhandler_console::get_tty_stuff): Pass NULL to third argument of set_ctty. * fhandler_tty.cc (fhandler_tty_slave::open): Accommodate new archetype method to create only one instance of a tty. (fhandler_tty_slave::close): Don't close handles unless archetype usecount is zero. When that happens, close archetype too. (fhandler_tty_slave::dup): Just copy archetype. Set use count appropriately. Set ctty, if appropriate. (fhandler_tty_common::dup): Remove slave considerations. (fhandler_tty_common::set_close_on_exec): Remove cygheap->ctty considerations. * pinfo.cc (_pinfo::set_ctty): Accommodate new archetype methods. * pinfo.h (_pinfo::set_ctty): Make third argument explicit. * syscalls.cc (close_all_files): Decrement controlling tty use count before closing all handles to allow controlling tty to be closed. Remove previous controlling tty considerations.
2003-12-11 07:12:41 +01:00
int usecount;
path_conv pc;
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
void reset (const fhandler_base *);
* 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-06 00:30:53 +02:00
virtual bool use_archetype () const {return false;}
virtual void set_name (path_conv &pc);
* 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-06 00:30:53 +02:00
virtual void set_name (const char *s)
{
pc.set_normalized_path (s);
pc.set_path (s);
}
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
int error () const {return pc.error;}
void set_error (int error) {pc.error = error;}
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
bool exists () const {return pc.exists ();}
int pc_binmode () const {return pc.binmode ();}
device& dev () {return pc.dev;}
operator DWORD& () {return (DWORD&) pc;}
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
fhandler_base ();
2000-02-17 20:38:33 +01:00
virtual ~fhandler_base ();
/* Non-virtual simple accessor functions. */
void set_io_handle (HANDLE x) { io_handle = x; }
2000-02-17 20:38:33 +01:00
* 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-28 20:17:09 +02:00
DWORD& get_device () { return dev (); }
DWORD get_major () { return dev ().get_major (); }
DWORD get_minor () { return dev ().get_minor (); }
virtual int get_unit () { return dev ().get_minor (); }
2000-02-17 20:38:33 +01:00
ACCESS_MASK get_access () const { return access; }
void set_access (ACCESS_MASK x) { access = x; }
ULONG get_options () const { return options; }
void set_options (ULONG x) { options = x; }
2000-02-17 20:38:33 +01:00
int get_flags () { return openflags; }
Remove fcntl.h includes throughout. * fhandler.h: Move fcntl.h include here. (fhandler_base::set_flags): Accept supplied_bin argument. Make non-inlined. * dtable.cc (dtable::init_std_file_from_handle): Just use binmode from pc. (reset_to_open_binmode): Use set_flags. * cygwin.din (open): Avoid newlib wrapper. (read): Ditto. (unlink): Ditto. (write): Ditto. * fhandler.cc (fhandler_base::set_flags): Accept supplied_bin argument. Make binmode decisions here. (fhandler_base::open): Avoid using pc if it is NULL. Eliminate binmode logic. Just call set_flags with binmode argument. (fhandler_base::init): Call set_flags with binmode argument. * fhandler_clipboard.cc (fhandler_dev_clipboard::open): Ditto. * fhandler_console.cc (fhandler_console::open): Ditto. (fhandler_console::init): Force binary on open. * fhandler_disk_file.cc (fhandler_disk_file::open): Don't set binmode here. Let it happen in base class. * fhandler_dsp.cc (fhandler_dev_dsp::open): Force binmode open. Set return value appropriately if unable to open. * fhandler_proc.cc (fhandler_proc::open): Make sure flags are set before open_status. * fhandler_process.cc (fhandler_process::open): Ditto. * fhandler_registry.cc (fhandler_registry::open): Ditto. * fhandler_random.cc (fhandler_dev_random::fhandler_dev_random): Ditto. * fhandler_raw.cc (fhandler_dev_raw::open): Force O_BINARY by default. * fhandler_serial.cc (fhandler_serial::init): Ditto. * fhandler_tty.cc (fhandler_tty_slave::open): Ditto. (fhandler_pty_master::open): Ditto. * fhandler_virtual.cc (fhandler_virtual::open): Ditto. * fhandler_windows.cc (fhandler_windows::open): Ditto. * fhandler_zero.cc (fhandler_dev_zero::open): Ditto. * net.cc (fdsock): Ditto. * path.cc (path_conv::check): Avoid checking for extension when error or directory. (set_flags): Set PATH_TEXT explicitly, when appropriate. (mount_info::conv_to_win32_path): Use set_flags() to set path flags. * path.h (PATH_TEXT): New enum. (path_conv::binmode): Return appropriate constant based on binmode. * pipe.cc (make_pipe): Set binmode to O_TEXT xor O_BINARY. * syscalls.cc (setmode_helper): Make debugging message a little clearer. (setmode): Set binmode via set_flags.
2002-06-05 03:42:28 +02:00
void set_flags (int x, int supplied_bin = 0);
2000-02-17 20:38:33 +01:00
bool is_nonblocking ();
* child_info.h (child_info_spawn::__stdin): New element. (child_info_spawn::__stdin): Ditto. (CURR_CHILD_INFO_MAGIC): Regenerate. * dcrt0.cc (check_sanity_and_sync): Minor cleanup. (child_info_spawn::handle_spawn): Handle new __std* elements by calling move_fd. * dtable.cc (dtable::move_fd): Define new function. * dtable.h (dtable::move_fd): Declare new function. * fhandler.h (fhandler_pipe::popen_pid): Declare new element. * fhandler.h (fhandler_pipe::get_popen_pid): Define new function. * fhandler.h (fhandler_pipe::set_popen_pid): Ditto. * pipe.cc (fhandler_pipe::fhandler_pipe): Zero popen_pid. (fhandler_pipe::dup): Ditto. * spawn.cc (handle): Change second argument to bool. (spawn_guts): Accept __stdin/__stdout arguments and set them appropriately in child_info structure and in STARTUPINFO structure. * syscalls.cc (popen): New cygwin-specific implementation using spawn. (pclose): Ditto. * winsup.h (spawn_guts): Accommodate new arguments for spawn_guts. * fhandler.cc (fhandler_base::set_no_inheritance): Make second arg a bool. * fhandler.h (fhandler_base::set_no_inheritance): Ditto for declaration. * child_info.h (child_info::msv_count): Rename from the now-inappropriate "zero". (child_info_spawn::filler): Add filler to work around Vista bug. (child_info_fork::filler): Ditto. * dcrt0.cc (get_cygwin_startup_info): Remove "zero" check since it is now always filled out. * fork.cc (frok::parent): Move ch.zero manipulation to constructor. * spawn.cc (spawn_guts): Ditto. Remove _ch wrapper. * sigproc.cc (child_info::child_info): Initialize starter[]. * shared.cc (shared_info::heap_slop_size): Remove noisy system_printfs. * shared_info.h (CURR_SHARED_MAGIC): Regenerate.
2006-12-11 19:55:29 +01:00
void set_nonblocking (int);
* Use new unified status_flag accessor methods from classes fhandler_*, tty_min, mtinfo and fs_info thoroughout. * fhandler.h: Redefine all set_close_on_exec methods to take a bool argument. (enum conn_state): Rename from connect_state. (class fhandler_base): Rename some status flags to align with accessor method names. Drop encoded flag entirely. Unify status accessor methods. Const'ify all read accessor methods. (class fhandler_socket): Ditto. (class fhandler_dev_raw): Ditto. * fhandler_disk_file.cc (fhandler_base::fstat_fs): Use fs.fs_is_fat() instead of evaluating FATness of file system here. (fhandler_disk_file::opendir): Drop call to set_encoded(). (fhandler_disk_file::readdir): Use pc.isencoded() directly. * mtinfo.h (class mtinfo_drive): Const'ify all read accessor methods. * path.cc (fsinfo_cnt): Add. (fs_info::update): Accomodate class changes. Evaluate file system name specific flags right here. Add thread safety for reading and writing global fsinfo array. * path.h (enum path_types): Drop values for flags kept in fs already. (struct fs_info): Move status informatin into private struct type status_flags. Add accessor methods. Remove path and file system name string arrays in favor of status bits. (class path_conv): Use new fs_info status information where appropriate. (path_conf::fs_has_ea): Rename from fs_fast_ea. (path_conf::fs_has_acls): New method. (path_conf::root_dir): Remove. (path_conf::volname): Remove. * syscalls (statfs): Evaluate root dir locally. * tty.h (class tty_min): Unify status accessor methods. Const'ify all read accessor methods.
2004-04-10 15:45:10 +02:00
bool wbinary () const { return status.wbinset ? status.wbinary : 1; }
bool rbinary () const { return status.rbinset ? status.rbinary : 1; }
2000-02-17 20:38:33 +01:00
* Use new unified status_flag accessor methods from classes fhandler_*, tty_min, mtinfo and fs_info thoroughout. * fhandler.h: Redefine all set_close_on_exec methods to take a bool argument. (enum conn_state): Rename from connect_state. (class fhandler_base): Rename some status flags to align with accessor method names. Drop encoded flag entirely. Unify status accessor methods. Const'ify all read accessor methods. (class fhandler_socket): Ditto. (class fhandler_dev_raw): Ditto. * fhandler_disk_file.cc (fhandler_base::fstat_fs): Use fs.fs_is_fat() instead of evaluating FATness of file system here. (fhandler_disk_file::opendir): Drop call to set_encoded(). (fhandler_disk_file::readdir): Use pc.isencoded() directly. * mtinfo.h (class mtinfo_drive): Const'ify all read accessor methods. * path.cc (fsinfo_cnt): Add. (fs_info::update): Accomodate class changes. Evaluate file system name specific flags right here. Add thread safety for reading and writing global fsinfo array. * path.h (enum path_types): Drop values for flags kept in fs already. (struct fs_info): Move status informatin into private struct type status_flags. Add accessor methods. Remove path and file system name string arrays in favor of status bits. (class path_conv): Use new fs_info status information where appropriate. (path_conf::fs_has_ea): Rename from fs_fast_ea. (path_conf::fs_has_acls): New method. (path_conf::root_dir): Remove. (path_conf::volname): Remove. * syscalls (statfs): Evaluate root dir locally. * tty.h (class tty_min): Unify status accessor methods. Const'ify all read accessor methods.
2004-04-10 15:45:10 +02:00
void wbinary (bool b) {status.wbinary = b; status.wbinset = 1;}
void rbinary (bool b) {status.rbinary = b; status.rbinset = 1;}
void set_open_status () {open_status = status;}
void reset_to_open_binmode ()
{
Remove fcntl.h includes throughout. * fhandler.h: Move fcntl.h include here. (fhandler_base::set_flags): Accept supplied_bin argument. Make non-inlined. * dtable.cc (dtable::init_std_file_from_handle): Just use binmode from pc. (reset_to_open_binmode): Use set_flags. * cygwin.din (open): Avoid newlib wrapper. (read): Ditto. (unlink): Ditto. (write): Ditto. * fhandler.cc (fhandler_base::set_flags): Accept supplied_bin argument. Make binmode decisions here. (fhandler_base::open): Avoid using pc if it is NULL. Eliminate binmode logic. Just call set_flags with binmode argument. (fhandler_base::init): Call set_flags with binmode argument. * fhandler_clipboard.cc (fhandler_dev_clipboard::open): Ditto. * fhandler_console.cc (fhandler_console::open): Ditto. (fhandler_console::init): Force binary on open. * fhandler_disk_file.cc (fhandler_disk_file::open): Don't set binmode here. Let it happen in base class. * fhandler_dsp.cc (fhandler_dev_dsp::open): Force binmode open. Set return value appropriately if unable to open. * fhandler_proc.cc (fhandler_proc::open): Make sure flags are set before open_status. * fhandler_process.cc (fhandler_process::open): Ditto. * fhandler_registry.cc (fhandler_registry::open): Ditto. * fhandler_random.cc (fhandler_dev_random::fhandler_dev_random): Ditto. * fhandler_raw.cc (fhandler_dev_raw::open): Force O_BINARY by default. * fhandler_serial.cc (fhandler_serial::init): Ditto. * fhandler_tty.cc (fhandler_tty_slave::open): Ditto. (fhandler_pty_master::open): Ditto. * fhandler_virtual.cc (fhandler_virtual::open): Ditto. * fhandler_windows.cc (fhandler_windows::open): Ditto. * fhandler_zero.cc (fhandler_dev_zero::open): Ditto. * net.cc (fdsock): Ditto. * path.cc (path_conv::check): Avoid checking for extension when error or directory. (set_flags): Set PATH_TEXT explicitly, when appropriate. (mount_info::conv_to_win32_path): Use set_flags() to set path flags. * path.h (PATH_TEXT): New enum. (path_conv::binmode): Return appropriate constant based on binmode. * pipe.cc (make_pipe): Set binmode to O_TEXT xor O_BINARY. * syscalls.cc (setmode_helper): Make debugging message a little clearer. (setmode): Set binmode via set_flags.
2002-06-05 03:42:28 +02:00
set_flags ((get_flags () & ~(O_TEXT | O_BINARY))
| ((open_status.wbinary || open_status.rbinary)
? O_BINARY : O_TEXT));
}
2000-02-17 20:38:33 +01:00
IMPLEMENT_STATUS_FLAG (bool, wbinset)
IMPLEMENT_STATUS_FLAG (bool, rbinset)
IMPLEMENT_STATUS_FLAG (bool, nohandle)
IMPLEMENT_STATUS_FLAG (bool, did_lseek)
IMPLEMENT_STATUS_FLAG (query_state, query_open)
IMPLEMENT_STATUS_FLAG (bool, close_on_exec)
IMPLEMENT_STATUS_FLAG (bool, need_fork_fixup)
Implement fhandler reference counting. * cygheap.h (cygheap_fdmanip::release): Make virtual. (cygheap_fdnew::~cygheap_fdnew): New destructor increments reference count when fd has been allocated. (cygheap_fdget::fh): New (old?) field. (cygheap_fdget::cygheap_fdget): Increment reference count when we've found an active fd. Set fh appropriately. (cygheap_fdget::~cygheap_fdget): Decrement reference count when appropriate. Delete fh if reference count goes to zero. (cygheap_fdget::release): New function. Do more bookkeping on release. * dtable.cc (dtable::release): Change from void to boolean return. Only delete the fhandler when its reference count is <= 0 (this should be a fairly unusual case). Return true if fhandler has been deleted. (cygwin_attach_handle_to_fd): Increment reference count when fh is assigned. (dtable::init_std_file_from_handle): Ditto. * dtable.h (dtable::release): Change return to boolean. * fhandler.cc (fhandler_base::fhandler_base): Set new isclosed flag to false. Set _refcnt to zero. (fhandler_base::close): Simplify paranoid debugging output. Set new isclosed() flag. (fhandler_base_overlapped::wait_overlapped): Use isclosed() flag to avoid querying the exception handle. * fhandler.h (fhandler_base::_refcnt): New field. (fhandler_base::refcnt): New function. (fhandler_base::isclosed): Implement. (fhandler_base::fhandler_base): Set isclosed to false. * syscalls.cc: Remove space after function before parentheses for several strace printfs. (dup): Add standard strace "leaver" code. (dup2): Ditto. (dup3): Ditto. (remove): Ditto. (getpid): Ditto. (getppid): Ditto. (lseek64): Fix strace debugging to correctly use %R. * fhandler_termios.cc (fhandler_termios::tcsetpgrp): Avoid sending signals to other processes if we're debugging since it can cause a deadlock with the calling debugger. * exceptions.cc (_cygtls::call_signal_handler): Add debugging-only strace output.
2011-12-17 01:03:31 +01:00
IMPLEMENT_STATUS_FLAG (bool, isclosed)
* Use new unified status_flag accessor methods from classes fhandler_*, tty_min, mtinfo and fs_info thoroughout. * fhandler.h: Redefine all set_close_on_exec methods to take a bool argument. (enum conn_state): Rename from connect_state. (class fhandler_base): Rename some status flags to align with accessor method names. Drop encoded flag entirely. Unify status accessor methods. Const'ify all read accessor methods. (class fhandler_socket): Ditto. (class fhandler_dev_raw): Ditto. * fhandler_disk_file.cc (fhandler_base::fstat_fs): Use fs.fs_is_fat() instead of evaluating FATness of file system here. (fhandler_disk_file::opendir): Drop call to set_encoded(). (fhandler_disk_file::readdir): Use pc.isencoded() directly. * mtinfo.h (class mtinfo_drive): Const'ify all read accessor methods. * path.cc (fsinfo_cnt): Add. (fs_info::update): Accomodate class changes. Evaluate file system name specific flags right here. Add thread safety for reading and writing global fsinfo array. * path.h (enum path_types): Drop values for flags kept in fs already. (struct fs_info): Move status informatin into private struct type status_flags. Add accessor methods. Remove path and file system name string arrays in favor of status bits. (class path_conv): Use new fs_info status information where appropriate. (path_conf::fs_has_ea): Rename from fs_fast_ea. (path_conf::fs_has_acls): New method. (path_conf::root_dir): Remove. (path_conf::volname): Remove. * syscalls (statfs): Evaluate root dir locally. * tty.h (class tty_min): Unify status accessor methods. Const'ify all read accessor methods.
2004-04-10 15:45:10 +02:00
int get_default_fmode (int flags);
2000-02-17 20:38:33 +01:00
* Use new unified status_flag accessor methods from classes fhandler_*, tty_min, mtinfo and fs_info thoroughout. * fhandler.h: Redefine all set_close_on_exec methods to take a bool argument. (enum conn_state): Rename from connect_state. (class fhandler_base): Rename some status flags to align with accessor method names. Drop encoded flag entirely. Unify status accessor methods. Const'ify all read accessor methods. (class fhandler_socket): Ditto. (class fhandler_dev_raw): Ditto. * fhandler_disk_file.cc (fhandler_base::fstat_fs): Use fs.fs_is_fat() instead of evaluating FATness of file system here. (fhandler_disk_file::opendir): Drop call to set_encoded(). (fhandler_disk_file::readdir): Use pc.isencoded() directly. * mtinfo.h (class mtinfo_drive): Const'ify all read accessor methods. * path.cc (fsinfo_cnt): Add. (fs_info::update): Accomodate class changes. Evaluate file system name specific flags right here. Add thread safety for reading and writing global fsinfo array. * path.h (enum path_types): Drop values for flags kept in fs already. (struct fs_info): Move status informatin into private struct type status_flags. Add accessor methods. Remove path and file system name string arrays in favor of status bits. (class path_conv): Use new fs_info status information where appropriate. (path_conf::fs_has_ea): Rename from fs_fast_ea. (path_conf::fs_has_acls): New method. (path_conf::root_dir): Remove. (path_conf::volname): Remove. * syscalls (statfs): Evaluate root dir locally. * tty.h (class tty_min): Unify status accessor methods. Const'ify all read accessor methods.
2004-04-10 15:45:10 +02:00
virtual void set_close_on_exec (bool val);
2000-02-17 20:38:33 +01:00
LPSECURITY_ATTRIBUTES get_inheritance (bool all = 0)
{
if (all)
* Use new unified status_flag accessor methods from classes fhandler_*, tty_min, mtinfo and fs_info thoroughout. * fhandler.h: Redefine all set_close_on_exec methods to take a bool argument. (enum conn_state): Rename from connect_state. (class fhandler_base): Rename some status flags to align with accessor method names. Drop encoded flag entirely. Unify status accessor methods. Const'ify all read accessor methods. (class fhandler_socket): Ditto. (class fhandler_dev_raw): Ditto. * fhandler_disk_file.cc (fhandler_base::fstat_fs): Use fs.fs_is_fat() instead of evaluating FATness of file system here. (fhandler_disk_file::opendir): Drop call to set_encoded(). (fhandler_disk_file::readdir): Use pc.isencoded() directly. * mtinfo.h (class mtinfo_drive): Const'ify all read accessor methods. * path.cc (fsinfo_cnt): Add. (fs_info::update): Accomodate class changes. Evaluate file system name specific flags right here. Add thread safety for reading and writing global fsinfo array. * path.h (enum path_types): Drop values for flags kept in fs already. (struct fs_info): Move status informatin into private struct type status_flags. Add accessor methods. Remove path and file system name string arrays in favor of status bits. (class path_conv): Use new fs_info status information where appropriate. (path_conf::fs_has_ea): Rename from fs_fast_ea. (path_conf::fs_has_acls): New method. (path_conf::root_dir): Remove. (path_conf::volname): Remove. * syscalls (statfs): Evaluate root dir locally. * tty.h (class tty_min): Unify status accessor methods. Const'ify all read accessor methods.
2004-04-10 15:45:10 +02:00
return close_on_exec () ? &sec_all_nih : &sec_all;
else
* Use new unified status_flag accessor methods from classes fhandler_*, tty_min, mtinfo and fs_info thoroughout. * fhandler.h: Redefine all set_close_on_exec methods to take a bool argument. (enum conn_state): Rename from connect_state. (class fhandler_base): Rename some status flags to align with accessor method names. Drop encoded flag entirely. Unify status accessor methods. Const'ify all read accessor methods. (class fhandler_socket): Ditto. (class fhandler_dev_raw): Ditto. * fhandler_disk_file.cc (fhandler_base::fstat_fs): Use fs.fs_is_fat() instead of evaluating FATness of file system here. (fhandler_disk_file::opendir): Drop call to set_encoded(). (fhandler_disk_file::readdir): Use pc.isencoded() directly. * mtinfo.h (class mtinfo_drive): Const'ify all read accessor methods. * path.cc (fsinfo_cnt): Add. (fs_info::update): Accomodate class changes. Evaluate file system name specific flags right here. Add thread safety for reading and writing global fsinfo array. * path.h (enum path_types): Drop values for flags kept in fs already. (struct fs_info): Move status informatin into private struct type status_flags. Add accessor methods. Remove path and file system name string arrays in favor of status bits. (class path_conv): Use new fs_info status information where appropriate. (path_conf::fs_has_ea): Rename from fs_fast_ea. (path_conf::fs_has_acls): New method. (path_conf::root_dir): Remove. (path_conf::volname): Remove. * syscalls (statfs): Evaluate root dir locally. * tty.h (class tty_min): Unify status accessor methods. Const'ify all read accessor methods.
2004-04-10 15:45:10 +02:00
return close_on_exec () ? &sec_none_nih : &sec_none;
}
Reintegrate socket duplication via WSADuplicateSocket/WSASocket. * autoload.cc (WSADuplicateSocketW): Define. (WSASocketW): Define. * dtable.cc (dtable::release): Call dec_need_fixup_before if necessary. (dtable::fixup_before_fork): New function. (dtable::fixup_before_exec): New function. * dtable.h (class dtable): Add member cnt_need_fixup_before. Add declarations for above new functions. (dtable::dec_need_fixup_before): New inline method. (dtable::inc_need_fixup_before): New inline method. (dtable::need_fixup_before): New inline method. * fhandler.h (fhandler_base::fixup_before_fork_exec): New virtual method. (fhandler_base::need_fixup_before): New virtual method. (class fhandler_socket): Add member prot_info_ptr. (fhandler_socket::init_fixup_before): Declare. (fhandler_socket::need_fixup_before): New inline method. (fhandler_socket::fixup_before_fork_exec): Declare. (fhandler_socket::fixup_after_exec): Declare. * fhandler_socket.cc (fhandler_socket::fhandler_socket): Initialize prot_info_ptr to NULL. (fhandler_socket::~fhandler_socket): Free prot_info_ptr conditionally. (fhandler_socket::init_fixup_before): New method. (fhandler_socket::fixup_before_fork_exec): Ditto. (fhandler_socket::fixup_after_fork): Use WSASocketW to duplicate socket if necessary. (fhandler_socket::fixup_after_exec): New method. (fhandler_socket::dup): Use fixup_before_fork_exec/fixup_after_fork to duplicate socket if necessary. * fork.cc (frok::parent): Start child suspended if some fhandler needs fixup before fork. If so, call dtable::fixup_before_fork after CreateProcess and resume child. * net.cc (fdsock): Try to find out if socket needs fixup before and initialize socket accordingly. Add HUGE comment to explain what happens and why. * spawn.cc (spawn_guts): Start child suspended if some fhandler needs fixup before exec. If so, call dtable::fixup_before_exec after CreateProcess.
2009-11-17 11:43:01 +01:00
virtual int fixup_before_fork_exec (DWORD) { return 0; }
* dtable.cc (dtable::release): Check for socket. Change cnt_need_fixup_before accordingly. (dtable::dup2): Ditto. (dtable::fixup_before_fork): New method. (dtable::fixup_before_exec): Ditto. * dtable.h (class dtable): Add member `cnt_need_fixup_before'. Add definition for methods `dec_need_fixup_before', `inc_need_fixup_before', `need_fixup_before', `fixup_before_exec' and `fixup_before_fork'. * fhandler.h (class fhandler_base): Slight rearrangements. Add definitions for methods `fixup_before_fork_exec'. (class fhandler_socket): Eliminate superfluous constructor. Add member `prot_info_ptr'. Add destructor. Add definitions for methods `dup', `fixup_before_fork_exec', `fixup_after_fork' and `fixup_after_exec'. * fork.cc (fork_parent): Care for file types which need a fixup before fork. Start child in suspended state then. * net.cc: New global variable `ws2_32_handle' and `wsadata'. (fdsock): Check for Winsock version. Call `set_socket_inheritance' only if Winsock version < 2.0. Care for `need_fixup' count in fdtab. (cygwin_socket): Eliminate call to `set_socket_inheritance'. (cygwin_accept): Ditto. (cygwin_rcmd): Ditto. (cygwin_rresvport): Ditto. (cygwin_rexec): Ditto. (socketpair): Ditto. (fhandler_socket::fhandler_socket): Set `need_fork_fixup'. Allocate space for the WSAPROTOCOL_INFOA struct used in fixup. (fhandler_socket::~fhandler_socket): New destructor. (fhandler_socket::fixup_before_fork_exec): New method. (fhandler_socket::fixup_after_fork): Ditto. (fhandler_socket::dup): Ditto. (wsock_init): New static function. (LoadDLLinitfunc (wsock32)): Rearranged. (LoadDLLinitfunc (ws2_32)): New function. (dummy_autoload): Add autoload statemants for `WSADuplicateSocketA' and `WSASocketA'. * spawn.cc (spawn_guts): Care for file types which need a fixup before exec. Start child in suspended state then.
2000-10-26 12:13:41 +02:00
virtual void fixup_after_fork (HANDLE);
* fhandler.cc (fhandler_base::fixup_after_exec): Declare here. * fhandler.h (fhandler_base::fixup_after_exec): Make non-inline. (fhandler_termios::fixup_after_fork): Delete declaration. (fhandler_termios::fixup_after_exec): Ditto. (fhandler_tty_common::inuse): Remove. (fhandler_tty_common::dup): Delete declaration. (fhandler_tty_common::fixup_after_fork): Ditto. (fhandler_tty_slave::fixup_after_exec): Declare new function. (fhandler_pty_master::dwProcessId): New variable. (fhandler_pty_master::from_master): Ditto. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::setup): New function. (fhandler_pty_master::fixup_after_fork): Ditto. (fhandler_pty_master::fixup_after_exec): Ditto. * fhandler_termios.cc (fhandler_termios::fixup_after_exec): Delete definition. (fhandler_termios::fixup_after_fork): Ditto. * fhandler_tty.cc (fhandler_tty_master::init): Use fhandler_pty_master setup function rather than obsolete tty::common_init. Delete obsolete inuse setting. (fhandler_tty_slave::fhandler_tty_slave): Set inuse to NULL here. (fhandler_tty_slave::open): Change debugging output for clarity. Check for different things when doing a sanity check on the tty. Reflect the fact that master_pid now is the cygwin pid rather than the windows pid. Use "arch" rather than "archetype" for consistency. (fhandler_tty_slave::close): Close inuse here. (fhandler_tty_slave::dup): Remove old if 0'ed code. (fhandler_pty_master::dup): New function. Handles pty master archetype. (fhandler_pty_master::fhandler_pty_master): Zero pty_master specific fields. (fhandler_pty_master::open): Implement using archetypes, similar to slave. Use fhandler_pty_master setup function rather than obsolete tty::common_init. Don't set inuse. (fhandler_tty_common::close): Don't deal with inuse. Delete old if 0'ed code. (fhandler_pty_master::close): Implement using archetypes. Close from_master and to_master. (fhandler_tty_common::set_close_on_exec): Just set close_on_exec flag here since everything uses archetypes now. (fhandler_tty_common::fixup_after_fork): Delete definition. (fhandler_tty_slave::fixup_after_exec): Define new function. (fhandler_pty_master::setup): New function, derived from tty::common_init. (fhandler_pty_master::fixup_after_fork): New function. (shared_info.h): Reset SHARED_INFO_CB to reflect new tty size. * tty.cc (tty_list::terminate): Close individual handles from tty_master. (tty::master_alive): Delete. (tty::make_pipes): Ditto. (tty::common_init): Ditto. * tty.h (tty::from_slave): Delete. (tty::to_slave): Ditto. (tty::common_init): Delete declaration. (tty::make_pipes): Ditto. (tty::master_pid): Define as pid_t since it is now a cygwin pid.
2006-06-02 17:41:34 +02:00
virtual void fixup_after_exec ();
void create_read_state (LONG n)
{
read_state = CreateSemaphore (&sec_none_nih, 0, n, NULL);
ProtectHandle (read_state);
}
void signal_read_state (LONG n)
{
ReleaseSemaphore (read_state, n, NULL);
}
2000-02-17 20:38:33 +01:00
bool get_readahead_valid () { return raixget < ralen; }
2000-02-17 20:38:33 +01:00
int puts_readahead (const char *s, size_t len = (size_t) -1);
int put_readahead (char value);
int get_readahead ();
int peek_readahead (int queryput = 0);
int eat_readahead (int n);
void set_readahead_valid (int val, int ch = -1);
int get_readahead_into_buffer (char *buf, size_t buflen);
bool has_acls () const { return pc.has_acls (); }
2000-02-17 20:38:33 +01:00
bool isremote () { return pc.isremote (); }
bool has_attribute (DWORD x) const {return pc.has_attribute (x);}
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
const char *get_name () const { return pc.normalized_path; }
const char *get_win32_name () { return pc.get_win32 (); }
* smallprint.cc (__small_vswprintf): Fix uninitialized usage of `w'. Revamp advisory file locking to avoid cross reference pointers as well as to allow BSD flock semantics. More agressively delete unused nodes and sync objects. * fhandler.h (fhandler_base::ino): Rename from namehash. Fix comment. (fhandler_base::node): Remove. (fhandler_base::unique_id): Add. (fhandler_base::del_my_locks): New method. (get_ino): Rename from get_namehash. Change usage throughout Cygwin. (get_unique_id): New method. * fhandler.cc (fhandler_base::close): Call own del_my_locks method. Fix comment. (fhandler_base::fhandler_base): Accommodate new and changed members. (fhandler_base::fixup_after_fork): Call del_my_locks. (fhandler_base::fixup_after_exec): Ditto for files with close-on-exec flag set. * fhandler_disk_file.cc (get_ino_by_handle): Rename from readdir_get_ino_by_handle. Accommodate throughout. (fhandler_base::open_fs): Fill ino with inode number if FS has good inodes. Allocate a LUID and store in unique_id to recognize file descriptors referencing the same file object. * flock.cc: Drop flock TODO comments. Use explicit types __dev32_t and __ino64_t instead of dev_t and ino_t. (LOCK_OBJ_NAME_LEN): Change to reflect longer lf_id length. (get_obj_handle_count): New method. (lockf_t::lf_id): Change type to long long. (inode_t::get_lock_obj_handle_count): Drop in favor of static function get_obj_handle_count. (inode_t::del_locks): Remove. (inode_t::get): Add create_if_missing flag argument. (inode_t::del_my_locks): Reimplement to handle POSIX and BSD flock locks. Return if node can be deleted or not. (inode_t::~inode_t): Ditto. Close handles to i_dir and i_mtx. (fixup_lockf_after_fork): Remove. (fhandler_base::del_my_locks): New method. (fixup_lockf_after_exec): Check if node can be deleted. (inode_t::get): Only create node if create_if_missing is set. Lock the returned node here before unlocking the node list. (inode_t::get_all_locks_list): Accommodate new lf_id length. (inode_t::create_lock_obj): Ditto. (lockf_t::open_lock_obj): Ditto. Change return type to bool. De-const. Set lf_obj instead of returning a handle. (lockf_t::del_lock_obj): Call SetEvent only if new incoming parameters allow it. Explain how it's supposed to work. (fhandler_disk_file::lock): Only fetch file length in SEEK_END case. Use NtQueryInformationFile(FileStandardInformation) instead of calling fstat_by_handle. Always unlock node before returning. Use fhandler's unique id to create lf_id for BSD flock locks. Rely on node lock from inode_t::get. Call del_lock_obj on removed locks here to allow explicit unlocking. Delete node if no lock exists on the file anymore. (lf_setlock): Get file handle as additional parameter. Handle the fact that lf_getblock now always opens the attached event object. Reactivate erroneously applied patch which deactivates setting thread priority. Additionally handle blocking on BSD flock locks. (lf_clearlock): Get file handle as additional parameter. (lf_getlock): Close event handle opened by lf_getblock. (lf_getblock): Open potentially blocking event object here and check its signal state if it's a BSD flock lock. (lf_wakelock): Get file handle as additional parameter. * fork.cc (frok::child): Drop call to fixup_lockf_after_fork. * ntdll.h (struct _EVENT_BASIC_INFORMATION): Define. (enum _EVENT_INFORMATION_CLASS): Define. (NtQueryEvent): Declare. * fhandler.h (fhandler_base::fs_flags): Remove. (fhandler_base::set_fs_flags): Remove. (fhandler_base::get_fs_flags): Remove. * fhandler.cc (fhandler_base::write): Check for sparse file using pc.fs_flags(). * fhandler_disk_file.cc (fhandler_disk_file::ftruncate): Ditto. The return of the volume serial number in fs_info. * fhandler.h (get_dev): New method. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Drop call to NtQueryVolumeInformationFile(FileFsVolumeInformation). Just use get_dev() method. * fhandler_fifo.cc (fhandler_fifo::open) Use device ID and inode number to generate fifo name. * path.h (fs_info::sernum): New member. (fs_info::serial_number): New method. (path_conv::fs_serial_number): New method. * path.cc (fs_info::update): Fetch volume serial number and store in sernum.
2008-03-31 20:03:25 +02:00
__dev32_t get_dev () { return pc.fs_serial_number (); }
__ino64_t get_ino () { return ino ?: ino = hash_path_name (0, pc.get_nt_native_path ()); }
long long get_unique_id () const { return unique_id; }
* cygheap.h (class cygheap_fdenum): New class to enumerate used fhandlers. * dtable.h (class dtable): Add cygheap_fdenum as friend class. * fhandler.h (fhandler_base::get_proc_fd_name): New virtual method to return a name for /proc/<pid>/fd. (fhandler_socket::get_proc_fd_name): Ditto. (fhandler_pipe::get_proc_fd_name): Ditto. (fhandler_virtual::opendir): Make virtual method. (fhandler_process::opendir): New method. * fhandler.cc (fhandler_base::get_proc_fd_name): New method. * fhandler_process.cc: Include ctype.h. (PROCESS_FD): Define. (process_listing): Add "fd". (fhandler_process::exists): Fix comment. Return 1 in case of "fd" directory. Handle files below "fd". (fhandler_process::fstat): Drop "self" handling. Set correct link count for directories. (fhandler_process::opendir): New method to handle "fd" directory. (fhandler_process::readdir): Add "fd" handling. (fhandler_process::open): Drop "self" handling. (fhandler_process::fill_filebuf): Ditto. Add "fd" handling. Fix "maps" output string. * fhandler_registry.cc (fhandler_registry::fstat): Set correct link count for directories. * fhandler_socket.cc (fhandler_socket::get_proc_fd_name): New method. * path.cc (symlink_info::set): Fix thinko. * pinfo.cc (_pinfo::commune_recv): Rename pathbuf to path throughout. Drop local path variable in PICOM_FIFO case. Fix debug output. Close handles as early as possible. Add PICOM_FDS and PICOM_FD handling. (_pinfo::commune_send): Add PICOM_FDS and PICOM_FD handling. (_pinfo::fd): New method. (_pinfo::fds): New method. * pinfo.h (enum picom): Add PICOM_FDS and PICOM_FD. (_pinfo::fd): Declare. (_pinfo::fds): Declare. * pipe.cc (fhandler_pipe::get_proc_fd_name): New method.
2005-01-31 11:28:55 +01:00
/* Returns name used for /proc/<pid>/fd in buf. */
virtual char *get_proc_fd_name (char *buf);
2000-02-17 20:38:33 +01:00
virtual void hclose (HANDLE h) {CloseHandle (h);}
* child_info.h (child_info_spawn::__stdin): New element. (child_info_spawn::__stdin): Ditto. (CURR_CHILD_INFO_MAGIC): Regenerate. * dcrt0.cc (check_sanity_and_sync): Minor cleanup. (child_info_spawn::handle_spawn): Handle new __std* elements by calling move_fd. * dtable.cc (dtable::move_fd): Define new function. * dtable.h (dtable::move_fd): Declare new function. * fhandler.h (fhandler_pipe::popen_pid): Declare new element. * fhandler.h (fhandler_pipe::get_popen_pid): Define new function. * fhandler.h (fhandler_pipe::set_popen_pid): Ditto. * pipe.cc (fhandler_pipe::fhandler_pipe): Zero popen_pid. (fhandler_pipe::dup): Ditto. * spawn.cc (handle): Change second argument to bool. (spawn_guts): Accept __stdin/__stdout arguments and set them appropriately in child_info structure and in STARTUPINFO structure. * syscalls.cc (popen): New cygwin-specific implementation using spawn. (pclose): Ditto. * winsup.h (spawn_guts): Accommodate new arguments for spawn_guts. * fhandler.cc (fhandler_base::set_no_inheritance): Make second arg a bool. * fhandler.h (fhandler_base::set_no_inheritance): Ditto for declaration. * child_info.h (child_info::msv_count): Rename from the now-inappropriate "zero". (child_info_spawn::filler): Add filler to work around Vista bug. (child_info_fork::filler): Ditto. * dcrt0.cc (get_cygwin_startup_info): Remove "zero" check since it is now always filled out. * fork.cc (frok::parent): Move ch.zero manipulation to constructor. * spawn.cc (spawn_guts): Ditto. Remove _ch wrapper. * sigproc.cc (child_info::child_info): Initialize starter[]. * shared.cc (shared_info::heap_slop_size): Remove noisy system_printfs. * shared_info.h (CURR_SHARED_MAGIC): Regenerate.
2006-12-11 19:55:29 +01:00
virtual void set_no_inheritance (HANDLE &, bool);
2000-02-17 20:38:33 +01:00
/* fixup fd possibly non-inherited handles after fork */
* child_info.h (child_info_spawn::__stdin): New element. (child_info_spawn::__stdin): Ditto. (CURR_CHILD_INFO_MAGIC): Regenerate. * dcrt0.cc (check_sanity_and_sync): Minor cleanup. (child_info_spawn::handle_spawn): Handle new __std* elements by calling move_fd. * dtable.cc (dtable::move_fd): Define new function. * dtable.h (dtable::move_fd): Declare new function. * fhandler.h (fhandler_pipe::popen_pid): Declare new element. * fhandler.h (fhandler_pipe::get_popen_pid): Define new function. * fhandler.h (fhandler_pipe::set_popen_pid): Ditto. * pipe.cc (fhandler_pipe::fhandler_pipe): Zero popen_pid. (fhandler_pipe::dup): Ditto. * spawn.cc (handle): Change second argument to bool. (spawn_guts): Accept __stdin/__stdout arguments and set them appropriately in child_info structure and in STARTUPINFO structure. * syscalls.cc (popen): New cygwin-specific implementation using spawn. (pclose): Ditto. * winsup.h (spawn_guts): Accommodate new arguments for spawn_guts. * fhandler.cc (fhandler_base::set_no_inheritance): Make second arg a bool. * fhandler.h (fhandler_base::set_no_inheritance): Ditto for declaration. * child_info.h (child_info::msv_count): Rename from the now-inappropriate "zero". (child_info_spawn::filler): Add filler to work around Vista bug. (child_info_fork::filler): Ditto. * dcrt0.cc (get_cygwin_startup_info): Remove "zero" check since it is now always filled out. * fork.cc (frok::parent): Move ch.zero manipulation to constructor. * spawn.cc (spawn_guts): Ditto. Remove _ch wrapper. * sigproc.cc (child_info::child_info): Initialize starter[]. * shared.cc (shared_info::heap_slop_size): Remove noisy system_printfs. * shared_info.h (CURR_SHARED_MAGIC): Regenerate.
2006-12-11 19:55:29 +01:00
bool fork_fixup (HANDLE, HANDLE &, const char *);
Reintegrate socket duplication via WSADuplicateSocket/WSASocket. * autoload.cc (WSADuplicateSocketW): Define. (WSASocketW): Define. * dtable.cc (dtable::release): Call dec_need_fixup_before if necessary. (dtable::fixup_before_fork): New function. (dtable::fixup_before_exec): New function. * dtable.h (class dtable): Add member cnt_need_fixup_before. Add declarations for above new functions. (dtable::dec_need_fixup_before): New inline method. (dtable::inc_need_fixup_before): New inline method. (dtable::need_fixup_before): New inline method. * fhandler.h (fhandler_base::fixup_before_fork_exec): New virtual method. (fhandler_base::need_fixup_before): New virtual method. (class fhandler_socket): Add member prot_info_ptr. (fhandler_socket::init_fixup_before): Declare. (fhandler_socket::need_fixup_before): New inline method. (fhandler_socket::fixup_before_fork_exec): Declare. (fhandler_socket::fixup_after_exec): Declare. * fhandler_socket.cc (fhandler_socket::fhandler_socket): Initialize prot_info_ptr to NULL. (fhandler_socket::~fhandler_socket): Free prot_info_ptr conditionally. (fhandler_socket::init_fixup_before): New method. (fhandler_socket::fixup_before_fork_exec): Ditto. (fhandler_socket::fixup_after_fork): Use WSASocketW to duplicate socket if necessary. (fhandler_socket::fixup_after_exec): New method. (fhandler_socket::dup): Use fixup_before_fork_exec/fixup_after_fork to duplicate socket if necessary. * fork.cc (frok::parent): Start child suspended if some fhandler needs fixup before fork. If so, call dtable::fixup_before_fork after CreateProcess and resume child. * net.cc (fdsock): Try to find out if socket needs fixup before and initialize socket accordingly. Add HUGE comment to explain what happens and why. * spawn.cc (spawn_guts): Start child suspended if some fhandler needs fixup before exec. If so, call dtable::fixup_before_exec after CreateProcess.
2009-11-17 11:43:01 +01:00
virtual bool need_fixup_before () const {return false;}
2000-02-17 20:38:33 +01:00
* 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-06 00:30:53 +02:00
int open_with_arch (int, mode_t = 0);
virtual int open (int, mode_t);
virtual void open_setup (int flags) { return; }
int close_with_arch ();
2000-02-17 20:38:33 +01:00
virtual int close ();
* 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-06 00:30:53 +02:00
virtual void cleanup () { return; }
int _archetype_usecount (const char *fn, int ln, int n)
{
if (!archetype)
return 0;
archetype->usecount += n;
if (strace.active ())
strace.prntf (_STRACE_ALL, fn, "line %d: %s<%p> usecount + %d = %d", ln, get_name (), archetype, n, archetype->usecount);
return archetype->usecount;
}
int open_fs (int, mode_t = 0);
* 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-06 00:30:53 +02:00
# define archetype_usecount(n) _archetype_usecount (__PRETTY_FUNCTION__, __LINE__, (n))
int close_fs () { return fhandler_base::close (); }
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
virtual int __stdcall fstat (struct __stat64 *buf) __attribute__ ((regparm (2)));
void stat_fixup (struct __stat64 *buf) __attribute__ ((regparm (2)));
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
int __stdcall fstat_fs (struct __stat64 *buf) __attribute__ ((regparm (2)));
* fhandler.h (class fhandler_base): Change inheritance of fstat_helper and fstat_by_... methods to private. (fhandler_base::fstat_helper): Drop all redundant arguments. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Drop call to fstat_by_nfs_ea here. Drop fetching basic file information. Drop setting file attributes. Accommodate change in fstat_helper call. (fhandler_base::fstat_by_name): Simplify. Only fetch directory information to get the inode number. Drop setting file attributes. Accommodate change in fstat_helper call. (fhandler_base::fstat_fs): Call fstat_by_nfs_ea if on NFS. (fhandler_base::fstat_helper): Drop all redundant arguments. Use information already collected in the fhandler. Move heading comment into code and drop dwFileAttributes comment. * mmap.cc (mmap64): Call fstat_fs rather than fstat_by_handle. * mount.cc (fs_info::update): Note that has_buggy_basic_info is unused. * path.cc (symlink_info::check_reparse_point): Add comment. (symlink_info::check): Fetch FileNetworkOpenInformation rather than FileBasicInformation throughout, except on NFS. Explain why. Store FILE_NETWORK_OPEN_INFORMATION in conv_hdl. Remove FILE_ATTRIBUTE_DIRECTORY attribute in conv_hdl for reparse point symlinks. * path.h (class path_conv_handle): Add FILE_NETWORK_OPEN_INFORMATION member _fnoi. (path_conv_handle::fnoi): New accessor method for _fnoi. (path_conv::fnoi): New accessor method for cubv_hdl._fnoi. * fhandler_tty.cc (fhandler_tty_slave::init): Use tty::setpgid method.
2010-09-13 13:17:36 +02:00
private:
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
int __stdcall fstat_helper (struct __stat64 *buf,
* fhandler.h (class fhandler_base): Change inheritance of fstat_helper and fstat_by_... methods to private. (fhandler_base::fstat_helper): Drop all redundant arguments. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Drop call to fstat_by_nfs_ea here. Drop fetching basic file information. Drop setting file attributes. Accommodate change in fstat_helper call. (fhandler_base::fstat_by_name): Simplify. Only fetch directory information to get the inode number. Drop setting file attributes. Accommodate change in fstat_helper call. (fhandler_base::fstat_fs): Call fstat_by_nfs_ea if on NFS. (fhandler_base::fstat_helper): Drop all redundant arguments. Use information already collected in the fhandler. Move heading comment into code and drop dwFileAttributes comment. * mmap.cc (mmap64): Call fstat_fs rather than fstat_by_handle. * mount.cc (fs_info::update): Note that has_buggy_basic_info is unused. * path.cc (symlink_info::check_reparse_point): Add comment. (symlink_info::check): Fetch FileNetworkOpenInformation rather than FileBasicInformation throughout, except on NFS. Explain why. Store FILE_NETWORK_OPEN_INFORMATION in conv_hdl. Remove FILE_ATTRIBUTE_DIRECTORY attribute in conv_hdl for reparse point symlinks. * path.h (class path_conv_handle): Add FILE_NETWORK_OPEN_INFORMATION member _fnoi. (path_conv_handle::fnoi): New accessor method for _fnoi. (path_conv::fnoi): New accessor method for cubv_hdl._fnoi. * fhandler_tty.cc (fhandler_tty_slave::init): Use tty::setpgid method.
2010-09-13 13:17:36 +02:00
DWORD nNumberOfLinks)
__attribute__ ((regparm (3)));
* Makefile.in (DLL_OFILES): Add nfs.o. * fhandler.cc (fhandler_base::open): Open files on NFS shares with correct access flags and EAs. * fhandler.h (fhandler_base::fstat_by_nfs_ea): Declare. * fhandler_disk_file.cc (fhandler_base::fstat_by_nfs_ea): New method. (fhandler_base::fstat_by_handle): Call fstat_by_nfs_ea for files on NFS shares. (fhandler_disk_file::fchmod): Use NFS specific method to set mode for files on NFS shares. Don't overrule errno from call to set_file_attribute with errno from NtSetInformationFile call. (fhandler_disk_file::fchown): Add comment. * mount.cc (fillout_mntent): Accommodate change in second parameter to fs_info::update. * nfs.cc: New file. * nfs.h: New file. * path.cc (fs_info::update): Take handle instead of bool as second parameter. Use that handle if it's not NULL. Only close handle if it has been opened here. Use static defined buffers instead of alloca'd buffers. (path_conv::check): Call symlink_info::check with reference to fs. Don't call fs.update here if file exists. (conv_path_list): Prefer tmp_pathbuf buffer over using alloca. (symlink_worker): Use NFS specific method to create symlinks on NFS shares. Prefer tmp_pathbuf buffer over using alloca. (symlink_info::check_shortcut): Reopen file from incoming handle with necessary FILE_GENERIC_READ flag. Prefer tmp_pathbuf buffer over using alloca. (symlink_info::check_sysfile): Ditto. (symlink_info::check_reparse_point): Use tmp_pathbuf buffer to allocate REPARSE_DATA_BUFFER. (symlink_info::check_nfs_symlink): New method. (enum symlink_t): Remove. (symlink_info::check): Don't use NtQueryAttributesFile. Rather, open file with necessary access flags and call NtQueryInformationFile. Fix error handling in case file can't be opened. For existing files, call fs_info::update here. Restructure symlink checking to accommodate the fact that the file is already open. Add case for NFS symlinks. * path.h (fs_info::update): Take handle instead of bool as second parameter.
2008-05-20 17:11:23 +02:00
int __stdcall fstat_by_nfs_ea (struct __stat64 *buf) __attribute__ ((regparm (2)));
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
int __stdcall fstat_by_handle (struct __stat64 *buf) __attribute__ ((regparm (2)));
int __stdcall fstat_by_name (struct __stat64 *buf) __attribute__ ((regparm (2)));
* fhandler.h (class fhandler_base): Change inheritance of fstat_helper and fstat_by_... methods to private. (fhandler_base::fstat_helper): Drop all redundant arguments. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Drop call to fstat_by_nfs_ea here. Drop fetching basic file information. Drop setting file attributes. Accommodate change in fstat_helper call. (fhandler_base::fstat_by_name): Simplify. Only fetch directory information to get the inode number. Drop setting file attributes. Accommodate change in fstat_helper call. (fhandler_base::fstat_fs): Call fstat_by_nfs_ea if on NFS. (fhandler_base::fstat_helper): Drop all redundant arguments. Use information already collected in the fhandler. Move heading comment into code and drop dwFileAttributes comment. * mmap.cc (mmap64): Call fstat_fs rather than fstat_by_handle. * mount.cc (fs_info::update): Note that has_buggy_basic_info is unused. * path.cc (symlink_info::check_reparse_point): Add comment. (symlink_info::check): Fetch FileNetworkOpenInformation rather than FileBasicInformation throughout, except on NFS. Explain why. Store FILE_NETWORK_OPEN_INFORMATION in conv_hdl. Remove FILE_ATTRIBUTE_DIRECTORY attribute in conv_hdl for reparse point symlinks. * path.h (class path_conv_handle): Add FILE_NETWORK_OPEN_INFORMATION member _fnoi. (path_conv_handle::fnoi): New accessor method for _fnoi. (path_conv::fnoi): New accessor method for cubv_hdl._fnoi. * fhandler_tty.cc (fhandler_tty_slave::init): Use tty::setpgid method.
2010-09-13 13:17:36 +02:00
public:
virtual int __stdcall fstatvfs (struct statvfs *buf) __attribute__ ((regparm (2)));
int utimens_fs (const struct timespec *) __attribute__ ((regparm (2)));
virtual int __stdcall fchmod (mode_t mode) __attribute__ ((regparm (1)));
virtual int __stdcall fchown (__uid32_t uid, __gid32_t gid) __attribute__ ((regparm (2)));
virtual int __stdcall facl (int, int, __acl32 *) __attribute__ ((regparm (3)));
* Makefile.in (DLL_OFILES): Add ntea.o. * cygwin.din (getxattr, listxattr, removexattr, setxattr, lgetxattr, llistxattr, lremovexattr, lsetxattr, fgetxattr, flistxattr, fremovexattr, fsetxattr): Export Linux extended attribute functions. Sort. * errno.cc (errmap): Add mappings for ERROR_EAS_DIDNT_FIT, ERROR_EAS_NOT_SUPPORTED, ERROR_EA_LIST_INCONSISTENT, ERROR_EA_TABLE_FULL, ERROR_FILE_CORRUPT, ERROR_INVALID_EA_NAME. * fhandler.h (class fhandler_base): Declare new fgetxattr and fsetxattr methods. (class fhandler_disk_file): Ditto. * fhandler.cc (fhandler_base::fgetxattr): New method. (fhandler_base::fsetxattr): New method. * fhandler_disk_file.cc (fhandler_disk_file::fgetxattr): New method. (fhandler_disk_file::fsetxattr): New method. * ntdll.h (STATUS_EA_TOO_LARGE): Define. (STATUS_NONEXISTENT_EA_ENTRY): Define. (STATUS_NO_EAS_ON_FILE): Define. * ntea.cc (read_ea): Rewrite for long pathnames and for using with Linux extended attribute functions. (write_ea): Ditto. (getxattr_worker): New static function. (getxattr): New function. (lgetxattr): New function. (fgetxattr): New function. (listxattr): New function. (llistxattr): New function. (flistxattr): New function. (setxattr_worker): New static function. (setxattr): New function. (lsetxattr): New function. (fsetxattr): New function. (removexattr): New function. (lsetxattr): New function. (fsetxattr): New function. * security.h (read_ea): Change declaration according to above changes. (write_ea): Ditto. * include/cygwin/version.h: Bump API minor version.
2008-02-10 16:43:04 +01:00
virtual ssize_t __stdcall fgetxattr (const char *, void *, size_t) __attribute__ ((regparm (3)));
virtual int __stdcall fsetxattr (const char *, const void *, size_t, int) __attribute__ ((regparm (3)));
virtual int __stdcall fadvise (_off64_t, _off64_t, int) __attribute__ ((regparm (3)));
virtual int __stdcall ftruncate (_off64_t, bool) __attribute__ ((regparm (3)));
virtual int __stdcall link (const char *) __attribute__ ((regparm (2)));
virtual int __stdcall utimens (const struct timespec *) __attribute__ ((regparm (2)));
virtual int __stdcall fsync () __attribute__ ((regparm (1)));
2000-02-17 20:38:33 +01:00
virtual int ioctl (unsigned int cmd, void *);
virtual int fcntl (int cmd, void *);
virtual char const *ttyname () { return get_name (); }
virtual void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3)));
* sigproc.h (wait_for_sigthread): Eliminate parameter. * sigproc.cc (wait_for_sigthread): Ditto. Don't synchronize with wait_sig after receiving an event that it is ready to go. (init_sig_pipe): New function. (wait_sig): Call init_sig_pipe to create pipes for communicating signals to this process. Don't send sigCONT signal when initializing. * fork.cc (frok::child): Accommodate wait_for_sigpipe parameter change. * fhandler.h (fhandler_*::write): Make ssize_t/__stdcall. (fhandler_*::write_overlapped): Ditto. (fhandler_*::raw_write): Ditto. (fhandler_*::readv): Ditto. (fhandler_*::writev): Ditto. (fhandler_*::raw_read): Make __stdcall. * fhandler: Accommodate changes to read/write functions throughout. * fhandler_clipboard.cc: Ditto. * fhandler_console.cc: Ditto. * fhandler_dsp.cc: Ditto. * fhandler_fifo.cc: Ditto. * fhandler_mailslot.cc: Ditto. * fhandler_mem.cc: Ditto. * fhandler_mem.cc: Ditto. * fhandler_random.cc: Ditto. * fhandler_tape.cc: Ditto. * fhandler_tty.cc: Ditto. * fhandler_virtual.cc: Ditto. * fhandler_windows.cc: Ditto. * fhandler_zero.cc: Ditto. * syscalls.cc (readv): Use ssize_t as temp variable. * fhandler.cc (fhandler_base::read): Coerce returned len to signed or it will never be treated as < 0. (fhandler_base::wait_overlapped): Minimize calls to GetLastError. Remove duplicate debugging test. Fix error return. * fhandler.h (fhandler_fifo::fifo_name): Declare new function. (fhandler_fifo::close): Ditto. (fhandler_fifo::dup): Ditto. (fhandler_fifo::close_on_exec): Ditto. * fhandler.cc (fhandler_fifo::fifo_name): Define new function. (FIFO_BUF_SIZE): New define. (cnp): Ditto. (fhandler_fifo::open): Rework. Use cnp to open named pipe. Always open write side as a client. Open dummy client when writing and can't connect. (wait): Rework. Implement fifo_wait_for_next_client. Handle signals during connect better. Add new fifo_wait_for_server code which polls (sigh) waiting for server. (fhandler_fifo::raw_read): Handle transition states when one client closes and another is available. (fhandler_fifo::close): Define. (fhandler_fifo::dup): Ditto. (fhandler_fifo::close_on_exec): Ditto.
2009-07-24 22:54:33 +02:00
virtual ssize_t __stdcall write (const void *ptr, size_t len);
virtual ssize_t __stdcall readv (const struct iovec *, int iovcnt, ssize_t tot = -1);
virtual ssize_t __stdcall writev (const struct iovec *, int iovcnt, ssize_t tot = -1);
virtual ssize_t __stdcall pread (void *, size_t, _off64_t) __attribute__ ((regparm (3)));
virtual ssize_t __stdcall pwrite (void *, size_t, _off64_t) __attribute__ ((regparm (3)));
virtual _off64_t lseek (_off64_t offset, int whence);
virtual int lock (int, struct __flock64 *);
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
virtual int dup (fhandler_base *child, int flags);
virtual int fpathconf (int);
2000-02-17 20:38:33 +01:00
* autoload.cc (NtCreateSection): Define. * cygheap.cc (_csbrk): Call getpagesize instead of getshmlba. * dcrt0.cc (dll_crt0_0): Call mmap_init. * external.cc (cygwin_internal): Call getpagesize instead of getshmlba. * fhandler.h (fhandler_base::mmap): Change access to prot parameter. (fhandler_base::fixup_mmap_after_fork): Ditto. (fhandler_disk_file::mmap): Ditto. (fhandler_disk_file::fixup_mmap_after_fork): Ditto. (fhandler_dev_mem::mmap): Ditto. (fhandler_dev_mem::fixup_mmap_after_fork): Ditto. * fhandler_mem.cc (fhandler_dev_mem::write): Call getsystempagesize instead of getpagesize. (fhandler_dev_mem::read): Ditto. (fhandler_dev_mem::fstat): Ditto. (fhandler_dev_mem::mmap): Move to mmap.cc. (fhandler_dev_mem::munmap): Ditto. (fhandler_dev_mem::msync): Ditto. (fhandler_dev_mem::fixup_mmap_after_fork): Ditto. * fhandler_proc.cc (format_proc_meminfo): Call getsystempagesize instead of getpagesize. * fhandler_process.cc (format_process_stat): Ditto. (format_process_status): Ditto. (get_mem_values): Ditto. * mmap.cc: Fix formatting. Try to make more readable and modular. Take advantage of pagesize==granularity. (gen_protect): New static function to evaluate Windows protection bits from POSIX protection and flags. (gen_access): Ditto for Windows access mode. (VirtualProt9x): Wrapper function to call VirtualProtect on 9x. (VirtualProtNT): Ditto for NT. (VirtualProtEx9x): Ditto for VirtualProtectEx on 9x. (VirtualProtExNT): Ditto for NT. (CreateMapping9x): Wrapper function for creating a mapping handle on 9x. (CreateMappingNT): Ditto for NT. (MapView9x): Wrapper function to map a view on 9x. (MapViewNT): Ditto for NT. (mmap_funcs_9x): Structure containing function pointers to wrapper functions for 9x. (mmap_funcs_nt): Ditto for NT. (mmap_func): Pointer to wrapper functions used in subsequent code. (mmap_init): Initialize mmap_func depending on OS. (class mmap_record): Use sensible member names. Add POSIX protection member. Drop Windows access flags member. Constify more methods. Use accessors instead of direct member access inside of own methods. (mmap_record::gen_protect): Class wrapper to evaluate matching Windows protection bits. (mmap_record::gen_access): Ditto for Windows access flags. (mmap_record::compatible_flags): New function to check if flags are compatible with flags of existing map. (list::add_record): Drop offset and length arguments. (class map): Change counters to unsigned. Match usage throughout. (mmapped_areas): Convert from pointer to global struct. (mmap_record::alloc_page_map): Simplify. (mmap_record::map_pages): Ditto. (mmap_record::fixup_page_map): Delete. (mmap64): Simplify. Add workaround for Windows 98 bug. Fix bug on NT that existing anonymous mappings weren't searched for a match. (munmap): Add workaround for Windows 98 bug. (msync): Simplify. (mprotect): Handle existing maps correctly. (mlock): Add local pagesize variable and enlightening comment. (fhandler_disk_file::mmap): Main functionality now in CreateMapping/ MapView wrapper functions. (fhandler_disk_file::fixup_mmap_after_fork): Call MapView wrapper. (fhandler_dev_mem::mmap): Moved from fhandler_mem.cc. Simplify by calling MapViewNT. (fhandler_dev_mem::munmap): Moved from fhandler_mem.cc. (fhandler_dev_mem::msync): Ditto. (fhandler_dev_mem::fixup_mmap_after_fork): Ditto. Call MapViewNT. (fixup_mmaps_after_fork): Restructure and hopefully speed up loop for setting protection and memory content on MAP_PRIVATE maps. * ntdll.h (AT_ROUND_TO_PAGE): Remove define. (AT_EXTENDABLE_FILE): Add define. (NtCreateSection): Add prototype. * syscalls.cc (getpagesize): Return granularity as pagesize now. (getsystempagesize): New function to retrieve "real" pagesize. (getshmlba): Delete since it's replaced by getpagesize now. * wincap.h (wincaps::has_mmap_alignment_bug): New element. * wincap.cc: Implement above element throughout. * winsup.h (getshmlba): Drop prototype. (getsystempagesize): Add prototype. (mmap_init): Ditto. * include/sys/mman.h: (Not yet) define MAP_NORESERVE.
2005-11-28 23:32:29 +01:00
virtual HANDLE mmap (caddr_t *addr, size_t len, int prot,
int flags, _off64_t off);
virtual int munmap (HANDLE h, caddr_t addr, size_t len);
virtual int msync (HANDLE h, caddr_t addr, size_t len, int flags);
* autoload.cc (NtCreateSection): Define. * cygheap.cc (_csbrk): Call getpagesize instead of getshmlba. * dcrt0.cc (dll_crt0_0): Call mmap_init. * external.cc (cygwin_internal): Call getpagesize instead of getshmlba. * fhandler.h (fhandler_base::mmap): Change access to prot parameter. (fhandler_base::fixup_mmap_after_fork): Ditto. (fhandler_disk_file::mmap): Ditto. (fhandler_disk_file::fixup_mmap_after_fork): Ditto. (fhandler_dev_mem::mmap): Ditto. (fhandler_dev_mem::fixup_mmap_after_fork): Ditto. * fhandler_mem.cc (fhandler_dev_mem::write): Call getsystempagesize instead of getpagesize. (fhandler_dev_mem::read): Ditto. (fhandler_dev_mem::fstat): Ditto. (fhandler_dev_mem::mmap): Move to mmap.cc. (fhandler_dev_mem::munmap): Ditto. (fhandler_dev_mem::msync): Ditto. (fhandler_dev_mem::fixup_mmap_after_fork): Ditto. * fhandler_proc.cc (format_proc_meminfo): Call getsystempagesize instead of getpagesize. * fhandler_process.cc (format_process_stat): Ditto. (format_process_status): Ditto. (get_mem_values): Ditto. * mmap.cc: Fix formatting. Try to make more readable and modular. Take advantage of pagesize==granularity. (gen_protect): New static function to evaluate Windows protection bits from POSIX protection and flags. (gen_access): Ditto for Windows access mode. (VirtualProt9x): Wrapper function to call VirtualProtect on 9x. (VirtualProtNT): Ditto for NT. (VirtualProtEx9x): Ditto for VirtualProtectEx on 9x. (VirtualProtExNT): Ditto for NT. (CreateMapping9x): Wrapper function for creating a mapping handle on 9x. (CreateMappingNT): Ditto for NT. (MapView9x): Wrapper function to map a view on 9x. (MapViewNT): Ditto for NT. (mmap_funcs_9x): Structure containing function pointers to wrapper functions for 9x. (mmap_funcs_nt): Ditto for NT. (mmap_func): Pointer to wrapper functions used in subsequent code. (mmap_init): Initialize mmap_func depending on OS. (class mmap_record): Use sensible member names. Add POSIX protection member. Drop Windows access flags member. Constify more methods. Use accessors instead of direct member access inside of own methods. (mmap_record::gen_protect): Class wrapper to evaluate matching Windows protection bits. (mmap_record::gen_access): Ditto for Windows access flags. (mmap_record::compatible_flags): New function to check if flags are compatible with flags of existing map. (list::add_record): Drop offset and length arguments. (class map): Change counters to unsigned. Match usage throughout. (mmapped_areas): Convert from pointer to global struct. (mmap_record::alloc_page_map): Simplify. (mmap_record::map_pages): Ditto. (mmap_record::fixup_page_map): Delete. (mmap64): Simplify. Add workaround for Windows 98 bug. Fix bug on NT that existing anonymous mappings weren't searched for a match. (munmap): Add workaround for Windows 98 bug. (msync): Simplify. (mprotect): Handle existing maps correctly. (mlock): Add local pagesize variable and enlightening comment. (fhandler_disk_file::mmap): Main functionality now in CreateMapping/ MapView wrapper functions. (fhandler_disk_file::fixup_mmap_after_fork): Call MapView wrapper. (fhandler_dev_mem::mmap): Moved from fhandler_mem.cc. Simplify by calling MapViewNT. (fhandler_dev_mem::munmap): Moved from fhandler_mem.cc. (fhandler_dev_mem::msync): Ditto. (fhandler_dev_mem::fixup_mmap_after_fork): Ditto. Call MapViewNT. (fixup_mmaps_after_fork): Restructure and hopefully speed up loop for setting protection and memory content on MAP_PRIVATE maps. * ntdll.h (AT_ROUND_TO_PAGE): Remove define. (AT_EXTENDABLE_FILE): Add define. (NtCreateSection): Add prototype. * syscalls.cc (getpagesize): Return granularity as pagesize now. (getsystempagesize): New function to retrieve "real" pagesize. (getshmlba): Delete since it's replaced by getpagesize now. * wincap.h (wincaps::has_mmap_alignment_bug): New element. * wincap.cc: Implement above element throughout. * winsup.h (getshmlba): Drop prototype. (getsystempagesize): Add prototype. (mmap_init): Ditto. * include/sys/mman.h: (Not yet) define MAP_NORESERVE.
2005-11-28 23:32:29 +01:00
virtual bool fixup_mmap_after_fork (HANDLE h, int prot, int flags,
_off64_t offset, DWORD size,
void *address);
void *operator new (size_t, void *p) __attribute__ ((nothrow)) {return p;}
2000-02-17 20:38:33 +01:00
virtual int init (HANDLE, DWORD, mode_t);
2000-02-17 20:38:33 +01:00
virtual int tcflush (int);
virtual int tcsendbreak (int);
virtual int tcdrain ();
virtual int tcflow (int);
virtual int tcsetattr (int a, const struct termios *t);
virtual int tcgetattr (struct termios *t);
virtual int tcsetpgrp (const pid_t pid);
virtual int tcgetpgrp ();
virtual pid_t tcgetsid ();
virtual bool is_tty () const { return false; }
virtual bool ispipe () const { return false; }
virtual pid_t get_popen_pid () const {return 0;}
virtual bool isdevice () const { return true; }
virtual bool isfifo () const { return false; }
virtual int ptsname_r (char *, size_t);
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
virtual class fhandler_socket *is_socket () { return NULL; }
2000-02-17 20:38:33 +01:00
virtual class fhandler_console *is_console () { return 0; }
virtual int is_windows () {return 0; }
virtual void __stdcall raw_read (void *ptr, size_t& ulen) __attribute__ ((regparm (3)));
virtual ssize_t __stdcall raw_write (const void *ptr, size_t ulen) __attribute__ ((regparm (3)));
2000-02-17 20:38:33 +01:00
/* Virtual accessor functions to hide the fact
that some fd's have two handles. */
virtual HANDLE& get_handle () { return io_handle; }
virtual HANDLE& get_io_handle () { return io_handle; }
virtual HANDLE& get_output_handle () { return io_handle; }
* dtable.cc (dtable::dup_worker): Reset path_conv handle in duplicated fhandler. * fhandler.cc (fhandler_base::fstatvfs): Keep handle in created path_conv. * fhandler.h (fhandler_base::get_stat_access): New method. (fhandler_base::get_stat_handle): New method. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Use handle returned by get_stat_handle. Only request inode from system if it isn't already set in the fhandler, and only for filesystems supporting them. (fhandler_base::fstat_fs): Use handle returned by get_stat_handle. Change the way open_fs is called. Explain why. (fhandler_base::fstat_helper): Use handle returned by get_stat_handle. Never use 0 inode number. Simplify executable recognition by re-using get_stat_handle if file could be opened with sufficient rights. (fhandler_disk_file::fstatvfs): Use handle returned by get_stat_handle. (fhandler_disk_file::facl): Use handle returned by get_stat_handle in GETACL and GETACLCNT cases. (fhandler_disk_file::link): Use handle returned by get_stat_handle instead of opening file here again. Add comment. (readdir_get_ino): Keep handle in created path_conv and drop opening file. * ntdll.h (wait_pending): New helper function. * path.cc (symlink_info::check): Drop unused 'opt' parameter from declaration. Add path_conv_handle argument. (path_conv::check): Make sure conv_handle is closed. Keep PC_KEEP_HANDLE flag in pflags_or. Accommodate call to sym.check to new args. (path_conv::~path_conv): Close conv_handle. (symlink_info::check_shortcut): Don't re-open file here, just use incoming handle. Drop goto's and label out. (symlink_info::check_sysfile): Don't re-open file here, just use incoming handle. Keep track of file position to accommodate the fact that file has been opened asynchronously in calling function. (symlink_info::check_nfs_symlink): Don't re-open file here, just use incoming handle. (symlink_info::check): Drop unused 'opt' parameter. Add path_conv_handle argument. Always try to open file with GENERIC_READ rights first to allow reading file content w/o having to re-open the file. Drop back to READ_CONTROL | FILE_READ_ATTRIBUTES otherwise. Call symlink test functions (except for check_reparse_point) only if file could be opened with GENERIC_READ. Keep file handle open if PC_KEEP_HANDLE is set in pflags. * path.h (enum pathconv_arg): Add PC_KEEP_HANDLE flag. (class path_conv_handle): New class. (class path_conv): Add conv_handle member. (path_conv::operator =): Duplicate conv_handle. (path_conv::handle): New method. (path_conv::access): New method. (path_conv::reset_conv_handle): New method. (path_conv::close_conv_handle): New method.
2010-06-15 14:05:15 +02:00
virtual HANDLE get_stat_handle () { return pc.handle () ?: io_handle; }
virtual bool hit_eof () {return false;}
* select.h: New file split from fhandler.h. (select_record::select_record): Define do-nothing constructor for "new" to avoid gratuitous zeroing. (select_info): New base class. (select_pipe_info): New class with methods for dealing with pipes. (select_socket_info): New class with methods for dealing with sockets. (select_serial_info): Dummy class for serial. (select_mailslot_info): Dummy class for mailslots. (select_stuff): Define device_specific_* as actual classes rather than void *. * dtable.h (dtable::select_read): Accommodate return value change to 'bool' and argument change to "select_stuff". (dtable::select_write): Ditto. (dtable::select_except): Ditto. * dtable.cc (dtable::select_read): Accommodate return value change to 'bool' and argument change to "select_stuff". (dtable::select_write): Ditto. (dtable::select_except): Ditto. * fhandler.h: Excise select-related classes. (fhandler_*::select_read): Change argument to select_stuff. (fhandler_*::select_write): Ditto. (fhandler_*::select_except): Ditto. * select.cc (UNIX_FD_ZERO): Use memset rather than bzero. (select_stuff::test_and_set): Change return type to bool. Allocate select_record on entry and let fhandler_*::select_* operate on the start.next field of select_stuff. (pipeinf): Delete. (select_pipe_info::select_pipe_info): New constructor. Allocates event for controlling pipe waits. (select_pipe_info::~select_pipe_info): New destructor. Destroy event. Stop thread. (select_pipe_info::add_watch_handle): New function. (thread_pipe): Wait for the hEvent part of any overlapped pipes before peeking. (start_thread_pipe): Don't allocate device_specific_pipe stuff here. Assume that it has been allocated earlier. (pipe_cleanup): Rely on select_pipe_info destructor to clean up pipe paraphenalia. (fhandler_*::select_*): Derive select_record from new select_stuff argument. (fhandler_pipe::select_*): Ditto. Allocate pipe-specific field if not already allocated. (serialinf): Delete. (thread_serial): serialinf -> select_serial_info. (fhandler_base::ready_for_read): Rewrite to accommodate change in argument to fhandler_*::select_*. (socketinf): Delete. (thread_socket): socketinf -> select_socket_info. (mailslotinf): Delete. (thread_mailslot): mailslotinf -> select_mailslot_info.
2009-06-30 23:18:44 +02:00
virtual select_record *select_read (select_stuff *);
virtual select_record *select_write (select_stuff *);
virtual select_record *select_except (select_stuff *);
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
virtual const char *get_native_name ()
2000-02-17 20:38:33 +01:00
{
return dev ().native;
2000-02-17 20:38:33 +01:00
}
virtual bg_check_types bg_check (int) {return bg_ok;}
* Makefile.in: Add cygheap.o. * child_info.h: Add specific exec class. * cygheap.h: New file. Contains declarations for cygwin heap. * cygheap.cc: New file. Implements cygwin heap functions. * dcrt0.cc (quoted): Simplify due to new method for passing arguments between cygwin programs. (alloc_stack_hard_way): Attempt to handle overlapped stack. (dll_crt0_1): Move child_info processing here. Accomodate new method for passing arguments between cygwin programs. Initialize cygwin heap. Establish __argc and __argv variables. (_dll_crt0): Move most of child_info processing to dll_crt0_1. (cygwin_dll_init): Remove duplication. * dtable.cc (dtable::extend): Allocate dtable using cygwin heap. (dtable::build_fhandler): Ditto for fhandler type being constructed. (dtable::dup_worker): Free new fhandler from cygwin heap on error. (dtable::select_*): Don't assume that this == fdtab. (dtable::linearize_fd_array): Delete. (dtable::delinearize_fd_array): Delete. (dtable::fixup_after_exec): New file. (dtable::vfork_child_dup): Use cygwin heap. (dtable::vfork_parent_restore): Ditto. * dtable.h: Remove obsolete methods. Add new method. * environ.cc (posify): Eliminate already_posix parameter and logic. (envsize): New function. (_addenv): Use envsize. (environ_init): Accept an argument pointing to an existing environment list. If supplied, allocate space for this in the the program's heap. * fhandler.cc (fhandler_base::operator =): Move here from fhandler.h. Use cygwin heap to allocate filenames. (fhandler_base::set_name): Allocate/free names from cygwin heap. (fhandler_base::linearize): Delete. (fhandler_base::de_linearize): Delete. (fhandler_base::operator delete): Free from cygwin heap. (fhandler_base::~fhandler_base): Ditto. * fhandler.h: Accomodate elimination of *linearize and other changes above. * fhandler_console.cc (fhandler_console::fixup_after_exec): Rename from de_linearize. * heap.h: New file. * fhandler_tty.cc (fhandler_tty_slave::fhandler_tty_slave): Use cygwin heap for name. fhandler_tty::fixup_after_exec): Rename from de_linearize. * fork.cc (fork): Call cygheap_fixup_in_child. * heap.cc: Use declarations in heap.h. * malloc.cc: Sprinkle assertions throughout to catch attempts to free/realloc something from the cygwin heap. * path.cc: Throughout, eliminate use of per-thread cache for cwd. Use cwd_* functions rather than cwd_* variables to access cwd_win32 and cwd_posix. (cwd_win32): New function. (cwd_posix): New function. (cwd_hash): New function. (cwd_fixup_after_exec): New function. * path.h: Accomodate path.cc changes. * pinfo.cc (pinfo_init): Accept a pointer to an environment table. Pass this to environ_init. Eliminate old 'title' tests. * pinfo.h: Accomodate above change in argument. * spawn.cc (struct av): New method for building argv list. (av::unshift): New method. (spawn_guts): Allocate everything that the child process needs in the cygwin heap and pass a pointer to this to the child. Build argv list using new method. Eliminate delinearize stuff. * thread.h: Eliminate _cwd_win32 and _cwd_posix buffers. * winsup.h: Eliminate obsolete functions. Add envsize() declaration.
2000-09-03 06:16:35 +02:00
void clear_readahead ()
{
raixput = raixget = ralen = rabuflen = 0;
rabuf = NULL;
}
void operator delete (void *p) {cfree (p);}
virtual void set_eof () {}
virtual int mkdir (mode_t mode);
virtual int rmdir ();
virtual DIR *opendir (int fd) __attribute__ ((regparm (2)));
virtual int readdir (DIR *, dirent *) __attribute__ ((regparm (3)));
virtual long telldir (DIR *);
virtual void seekdir (DIR *, long);
virtual void rewinddir (DIR *);
virtual int closedir (DIR *);
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
bool is_auto_device () {return isdevice () && !dev ().isfs ();}
bool is_fs_special () {return pc.is_fs_special ();}
bool issymlink () {return pc.issymlink ();}
bool device_access_denied (int) __attribute__ ((regparm (2)));
int fhaccess (int flags, bool) __attribute__ ((regparm (3)));
* 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-09 17:47:44 +01:00
virtual bool __stdcall has_ongoing_io () __attribute__ ((regparm (1))) {return false;}
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
fhandler_base (void *) {}
virtual void copyto (fhandler_base *x)
{
x->pc.free_strings ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
*reinterpret_cast<fhandler_base *> (x) = *this;
x->reset (this);
}
virtual fhandler_base *clone (cygheap_types malloc_type = HEAP_FHANDLER)
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
{
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_base));
* fhandler.h (fhandler_pipe::create_selectable): Remove optional argument, take an options argument for CreateNamedPipe/CreateFile. Change handle arguments to expect pointers. (fhandler_fifo::fifo_state): Delete. (fhandler_fifo::dummy_client): Ditto. (fhandler_fifo::open_nonserver): Ditto. (fhandler_fifo::wait_state): Ditto. (fhandler_fifo::raw_write): Ditto. (fhandler_fifo::read_ready): New field. (fhandler_fifo::write_ready): Ditto. (fhandler_fifo::wait): Modify argument. (fhandler_fifo::fifo_name): Add a new argument. (fhandler_fifo::fixup_after_fork): New function. * fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Remove initialization of expunged elements. Initialize new handles to NULL. (fhandler_fifo::open_nonserver): Delete. (fnevent): New macro for creating a named event. (fnpipe): New macro for creating a unique named pipe name. (create_pipe): New macro for simplification of named pipe creation. (fhandler_fifo::fifo_name): Use new argument when creating a shared name. (fhandler_fifo::open): Rewrite. Use events to synchronize. (pure_debug_printf): New macro, active only when DEBUGGING. (fhandler_fifo::wait): Rewrite to wait for new fifo events which are supplied as a parameter. (fhandler_fifo::raw_read): Rewrite to use handle mechanism to detect client-side disconnect. (fhandler_fifo::raw_write): Delete. (fhandler_fifo::close): Remove accommodations for expunged fields. Close event handles. (fhandler_fifo::dup): Remove accommodations for expunged fields. Duplicate event handles. (fhandler_fifo::fixup_after_fork): New function. Perform fixups on event handles. (fhandler_fifo::set_close_on_exec): Remove accommodations for expunged fields. Set inheritance for new handle fields. * miscfuncs.cc (CreatePipeOverlapped): Accommodate changes in fhandler_pipe::create_selectable. * tty.cc (tty::not_allocated): Ditto. * pipe.cc (fhandler_pipe::create): Ditto. (fhandler_pipe::create_selectable): Accept an extra open_mode argument. Pass arguments by reference and allow opening one end of the pipe at a time. * sys/strace.h (debug_only_printf): Define new macro which calls debug_printf only when DEBUGGING is defined.
2011-10-30 05:50:36 +01:00
fhandler_base *fh = new (ptr) fhandler_base (ptr);
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
copyto (fh);
return fh;
}
2000-02-17 20:38:33 +01:00
};
struct wsa_event
{
LONG serial_number;
long events;
int connect_errorcode;
pid_t owner;
};
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * include/cygwin/version.h: Bump DLL version to 1.7.0. 2006-07-25 Corinna Vinschen <corinna@vinschen.de> * select.h: Remove. * fhandler_socket.cc: Don't include select.h. * select.cc: Ditto. 2006-07-25 Corinna Vinschen <corinna@vinschen.de> * cygtls.h: Drop socket related includes. (struct _local_storage): Remove exitsock and exitsock_sin. Add select_sockevt. * cygtls.cc: Accomodate above change throughout. * fhandler.h (class fhandler_socket): Make wsock_evt public. * fhandler_socket.cc (fhandler_socket::fhandler_socket): Accomodate reordering members. (fhandler_socket::evaluate_events): Drop FD_CONNECT event as soon as it gets read once. Never remove FD_WRITE event here. (fhandler_socket::wait_for_events): Wait 50 ms instead of INFINITE for socket events. (fhandler_socket::accept): Fix conditional. Set wsock_events members of accepted socket to useful start values. (fhandler_socket::recv_internal): Always drop FD_READ/FD_OOB events from wsock_events after the call to WSARecvFrom. (fhandler_socket::send_internal): Drop FD_WRITE event from wsock_events if the call to WSASendTo fails with WSAEWOULDBLOCK. Fix return value condition. * select.cc (struct socketinf): Change to accomodate using socket event handling. (peek_socket): Use event handling for peeking socket. (thread_socket): Ditto. (start_thread_socket): Ditto. (socket_cleanup): Same here. * tlsoffsets.h: Regenerate. 2006-07-20 Corinna Vinschen <corinna@vinschen.de> * fhandler.h (class fhandler_socket): Rearrange slightly to keep event handling methods and members together. Drop owner status flag. Split wait method. Rename event handling methods for readability. * fhandler_socket.cc (struct wsa_event): Add owner field. (LOCK_EVENTS): New macro. (UNLOCK_EVENTS): Ditto. (fhandler_socket::init_events): rename from prepare. (fhandler_socket::evaluate_events): First half of former wait method. Do everything but wait. Allow specifiying whether or not events from event_mask should be erased from wsock_events->events. Simplify OOB handling. Allow sending SIGURG to any process (group). (fhandler_socket::wait_for_events): Second half of former wait method. Call evaluate_events and wait in a loop if socket is blocking. (fhandler_socket::release_events): Rename from release. (fhandler_socket::connect): Accomodate above name changes. (fhandler_socket::accept): Ditto. (fhandler_socket::recv_internal): Ditto. (fhandler_socket::send_internal): Ditto. (fhandler_socket::close): Ditto. (fhandler_socket::fcntl): Always set owner to given input value on F_SETOWN. Handle F_GETOWN. * net.cc (fdsock): Accomodate above name changes. 2006-07-20 Corinna Vinschen <corinna@vinschen.de> * fhandler_socket.cc (fhandler_socket::wait): Set Winsock errno to WSAEWOULDBLOCK instead of WSAEINPROGRESS. 2006-07-18 Brian Ford <Brian.Ford@FlightSafety.com> Corinna Vinschen <corinna@vinschen.de> * winsup.h (mmap_region_status): New enum. (mmap_is_attached_or_noreserve_page): Adjust prototype and rename as below. * mmap.cc (mmap_is_attached_or_noreserve_page): Rename mmap_is_attached_or_noreserve. Add region length parameter. Return enum above. * exceptions.cc (_cygtls::handle_exceptions): Accomodate above. * fhandler.cc (fhandler_base::raw_read): Call above for NOACCESS errors and retry on success to allow reads into untouched MAP_NORESERVE buffers. 2006-07-18 Corinna Vinschen <corinna@vinschen.de> * cygwin.din (posix_openpt): Export. * tty.cc (posix_openpt): New function. * include/cygwin/stdlib.h (posix_openpt): Declare. * include/cygwin/version.h: Bump API minor number. 2006-07-14 Corinna Vinschen <corinna@vinschen.de> * security.cc (get_token_group_sidlist): Always add the interactive group to the token. Add comment. Create logon_id group SID by copying it from incoming group list. (create_token): Add subauth_token parameter. Use information in subauth_token if present. Tweak SourceIdentifier if subauth_token is present for debugging purposes. * security.h (create_token): Add subauth_token parameter in declaration. * syscalls.cc (seteuid32): Call subauth first. Call create_token regardless. Use subauth token in call to create_token if subauth succeeded. 2006-07-13 Corinna Vinschen <corinna@vinschen.de> * include/netinet/in.h: Update copyright. 2006-07-13 Corinna Vinschen <corinna@vinschen.de> * fhandler_socket.cc (fhandler_socket::wait): Rework function so that WaitForMultipleObjects is really only called when necessary. 2006-07-12 Corinna Vinschen <corinna@vinschen.de> * include/netdb.h: Declare rcmd, rcmd_af, rexec, rresvport, rresvport_af, iruserok, iruserok_sa, ruserok. 2006-07-12 Corinna Vinschen <corinna@vinschen.de> * Makefile.in (DLL_OFILES): Drop iruserok.o. Add rcmd.o. * autoload.cc (rcmd): Drop definition. * cygwin.din: Export bindresvport, bindresvport_sa, iruserok_sa, rcmd_af, rresvport_af. * net.cc (cygwin_rcmd): Remove. (last_used_bindresvport): Rename from last_used_rrecvport. (cygwin_bindresvport_sa): New function implementing bindresvport_sa. (cygwin_bindresvport): New function implementing bindresvport. (cygwin_rresvport): Remove. * include/cygwin/version.h: Bump API minor number. * include/netinet/in.h: Declare bindresvport and bindresvport_sa. * libc/iruserok.c: Remove file. * libc/rcmd.cc: New file implementing rcmd, rcmd_af, rresvport, rresvport_af, iruserok_sa, iruserok and ruserok. 2006-07-12 Corinna Vinschen <corinna@vinschen.de> * fhandler_socket.cc (fhandler_socket::getsockname): Return valid result for unbound sockets. 2006-07-11 Corinna Vinschen <corinna@vinschen.de> * fhandler_socket.cc (fhandler_socket::fixup_after_fork): Handle wsock_mtx and wsock_evt on fork, thus handling close_on_exec correctly. (fhandler_socket::fixup_after_exec): Drop misguided attempt to handle close_on_exec here. (fhandler_socket::dup): Call fixup_after_fork with NULL parent. Add comment. (fhandler_socket::set_close_on_exec): Handle wsock_mtx and wsock_evt. 2006-07-10 Corinna Vinschen <corinna@vinschen.de> * fhandler.h (class fhandler_socket): Add wsock_mtx, wsock_evt and wsock_events members. Remove closed status flag, add listener status flag. Accomodate new implementation of socket event handling methods. Declare recv* and send* functions ssize_t as the POSIX equivalents. (fhandler_socket::recv_internal): Declare. (fhandler_socket::send_internal): Ditto. * fhandler_socket.cc (EVENT_MASK): Define mask of selected events. (fhandler_socket::fhandler_socket): Initialize new members. (fhandler_socket::af_local_setblocking): Don't actually set the socket to blocking mode. Keep sane event selection. (fhandler_socket::af_local_unsetblocking): Don't actually set the socket to previous blocking setting, just remember it. (struct wsa_event): New structure to keep event data per shared socket. (NUM_SOCKS): Define number of shared sockets concurrently handled by all active Cygwin processes. (wsa_events): New shared datastructure keeping all wsa_event records. (socket_serial_number): New shared variable to identify shared sockets. (wsa_slot_mtx): Global mutex to serialize wsa_events access. (search_wsa_event_slot): New static function to select a new wsa_event slot for a new socket. (fhandler_socket::prepare): Rewrite. Prepare event selection per new socket. (fhandler_socket::wait): Rewrite. Wait for socket events in thread safe and multiple process safe. (fhandler_socket::release): Rewrite. Close per-socket descriptor mutex handle and event handle. (fhandler_socket::dup): Duplicate wsock_mtx and wsock_evt. Fix copy-paste error in debug output. (fhandler_socket::connect): Accomodate new event handling. (fhandler_socket::listen): Set listener flag on successful listen. (fhandler_socket::accept): Accomodate new event handling. (fhandler_socket::recv_internal): New inline method centralizing common recv code. (fhandler_socket::recvfrom): Call recv_internal now. (fhandler_socket::recvmsg): Ditto. Streamline copying from iovec to WSABUF. (fhandler_socket::send_internal): New inline method centralizing common send code. (fhandler_socket::sendto): Call send_internal now. (fhandler_socket::sendmsg): Ditto. Streamline copying from iovec to WSABUF. (fhandler_socket::close): Call release now. (fhandler_socket::ioctl): Never actually switch to blocking mode. Just keep track of the setting. * net.cc (fdsock): Call prepare now. (cygwin_connect): Revert again to event driven technique. (cygwin_accept): Ditto. * poll.cc (poll): Don't call recvfrom on a listening socket. Remove special case for failing recvfrom. * include/sys/socket.h: Declare recv* and send* functions ssize_t as requested by POSIX. 2006-07-07 Corinna Vinschen <corinna@vinschen.de> * net.cc (cygwin_inet_ntop): Fix data type of forth parameter. 2006-07-06 Corinna Vinschen <corinna@vinschen.de> * include/cygwin/in6.h (struct in6_addr): Fix typo. 2006-07-06 Corinna Vinschen <corinna@vinschen.de> * cygwin.din: Export in6addr_any, in6addr_loopback, freeaddrinfo, gai_strerror, getaddrinfo, getnameinfo. * fhandler_socket.cc: Include cygwin/in6.h. (get_inet_addr): Accomodate AF_INET6 usage. (fhandler_socket::connect): Ditto. (fhandler_socket::listen): Ditto. (fhandler_socket::sendto): Ditto. * net.cc: Include cygwin/in6.h. (in6addr_any): Define. (in6addr_loopback): Define. (cygwin_socket): Accomodate AF_INET6 usage. (socketpair): Bind socketpairs only to loopback for security. (inet_pton4): New static function. (inet_pton6): Ditto. (cygwin_inet_pton): New AF_INET6 aware inet_pton implementation. (inet_ntop4): New static function. (inet_ntop6): Ditto. (cygwin_inet_ntop): New AF_INET6 aware inet_ntop implementation. (ga_aistruct): New static function. (ga_clone): Ditto. (ga_echeck): Ditto. (ga_nsearch): Ditto. (ga_port): Ditto. (ga_serv): Ditto. (ga_unix): Ditto. (gn_ipv46): Ditto. (ipv4_freeaddrinfo): Ditto. (ipv4_getaddrinfo): Ditto. (ipv4_getnameinfo): Ditto. (gai_errmap_t): New structure holding error code - error string mapping. (cygwin_gai_strerror): New function implementing gai_strerror. (w32_to_gai_err): New static function. (get_ipv6_funcs): Ditto. (load_ipv6_funcs): Ditto. (cygwin_freeaddrinfo): New function implementing freeaddrinfo. (cygwin_getaddrinfo): New function implementing getaddrinfo. (cygwin_getnameinfo): New function implementing getnameinfo. * include/netdb.h: Include stdint.h and cygwin/socket.h. Define data types and macros used by getaddrinfo and friends. Declare freeaddrinfo, gai_strerror, getaddrinfo and getnameinfo. * include/cygwin/in.h: Add IPv6 related IPPROTOs. Remove definition of struct sockaddr_in6. Include cygwin/in6.h instead. * include/cygwin/in6.h: New header file defining IPv6 releated data types and macros. * include/cygwin/socket.h: Enable AF_INET6 and PF_INET6. Add IPv6 related socket options. * include/cygwin/version.h: Bump API minor number. 2006-07-06 Corinna Vinschen <corinna@vinschen.de> * autoload.cc (DsGetDcNameA): Define. (NetGetAnyDCName): Define. * security.cc: Include dsgetdc.h. (DsGetDcNameA): Declare. (DS_FORCE_REDISCOVERY): Define. (get_logon_server): Add bool parameter to control rediscovery of DC. Use DsGetDcNameA function if supported, NetGetDCName/NetGetAnyDCName otherwise. (get_server_groups): Rediscover DC if get_user_groups fails and try again. (get_reg_security): Use correct error code macro when testing RegGetKeySecurity return value. * security.h (get_logon_server): Remove default vaue from wserver parameter. Add rediscovery parameter. * uinfo.cc (cygheap_user::env_logsrv): Accomodate rediscovery parameter in call to get_logon_server.
2006-07-25 21:23:23 +02:00
2000-02-17 20:38:33 +01:00
class fhandler_socket: public fhandler_base
{
* dtable.cc (dtable::build_fhandler): Issue internal error on unknown device. * fhandler.cc (fhandler_base::close): Show both name and handle in debugging output. * fhandler.h (fhandler_base::get_guard): New virtual method. (fhandler_pipe::get_guard): New method. (fhandler_socket::ready_for_read): Delete declaration. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (struct select_record::peek): Declare new method. * select.cc (MAKEready): Delete. (peek_pipe): Use get_guard method to retrieve potential guard mutex handle. (fhandler_base::ready_for_read): Rewrite as generic ready-for-read handler. Should only be called for "slow" devices. (fhandler_socket::ready_for_read): Delete definition. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (fhandler_pipe::select_read): Fill in new peek record in select_record structure. (fhandler_console::select_read): Ditto. (fhandler_tty_common::select_read): Ditto. (fhandler_serial::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_tty_slave::ready_for_read): Check for tty not open. Set errnos appropriately. * syscalls.cc (_read): Allow ready_for_read to set errno. * pinfo.cc (pinfo::init): Return spawn/NO_WAIT process as valid if it is initializing. * sigproc.cc (getsem): Adjust wait for process to initialize downward to avoid huge waits.
2001-11-01 22:15:53 +01:00
private:
2000-02-17 20:38:33 +01:00
int addr_family;
int type;
* fhandler.h (fhandler_socket::secret_event): Remove. (fhandler_socket::af_local_set_secret): New function combining former set_connect_secret and get_connect_secret into one function. (fhandler_socket::af_local_setblocking): Rename from eid_setblocking. (fhandler_socket::af_local_unsetblocking): Rename from eid_unsetblocking. (fhandler_socket::af_local_set_cred): New method. (fhandler_socket::af_local_copy): New method. (fhandler_socket::af_local_recv_secret): New method. (fhandler_socket::af_local_send_secret): New method. (fhandler_socket::af_local_recv_cred): Rename from eid_recv. (fhandler_socket::af_local_send_cred): Rename from eid_send. (fhandler_socket::af_local_accept): New method. (fhandler_socket::af_local_set_sockpair_cred): Rename from set_socketpair_eids. (fhandler_socket::eid_accept): Remove. (fhandler_socket::eid_connect): Remove. (fhandler_socket::set_connect_secret): Remove. (fhandler_socket::get_connect_secret): Remove. (fhandler_socket::create_secret_event): Remove. (fhandler_socket::check_peer_secret_event): Remove. (fhandler_socket::signal_secret_event): Remove. (fhandler_socket::close_secret_event): Remove. (fhandler_socket::sec_event_accept): Remove. (fhandler_socket::sec_event_connect): Remove. * fhandler_socket.cc (secret_event_name): Remove. (fhandler_socket::af_local_set_sockpair_cred): Rename from set_socketpair_eids. (fhandler_socket::af_local_setblocking): Rename from eid_setblocking. (fhandler_socket::af_local_unsetblocking): Rename from eid_unsetblocking. (fhandler_socket::af_local_recv_secret): New function to receive AF_LOCAL connect secret over socket itself. (fhandler_socket::af_local_send_secret): New function to send AF_LOCAL connect secret over socket itself. (fhandler_socket::af_local_recv_cred): Rename from eid_recv. (fhandler_socket::af_local_send_cred): Rename from eid_send. (fhandler_socket::eid_connect): Remove. (fhandler_socket::af_local_connect): Take over connect side handling of AF_LOCAL secret and credential handshake. (fhandler_socket::eid_accept): Remove. (fhandler_socket::af_local_accept): New method, take over accept side handling of AF_LOCAL secret and credential handshake. (fhandler_socket::af_local_set_cred): New method, set eid credentials to start values. (fhandler_socket::af_local_copy): New method, copy secret and credentials to another socket. (fhandler_socket::af_local_set_secret): New function combining former set_connect_secret and get_connect_secret into one function. (fhandler_socket::create_secret_event): Remove. (fhandler_socket::signal_secret_event): Remove. (fhandler_socket::close_secret_event): Remove. (fhandler_socket::check_peer_secret_event): Remove. (fhandler_socket::sec_event_connect): Remove. (fhandler_socket::sec_event_accept): Remove. (fhandler_socket::fixup_after_fork): Drop secret_event handling. (fhandler_socket::bind): Call af_local_set_secret. (fhandler_socket::connect): Call af_local_set_cred and af_local_connect. (fhandler_socket::listen): Call af_local_set_cred. (fhandler_socket::accept): Call af_local_copy and af_local_accept on accepted socket. (fhandler_socket::close): Don't call close_secret_event. (fhandler_socket::set_close_on_exec): Don't set secret_event inheritance. * net.cc (cygwin_getsockopt): Add debug output. (socketpair): Call af_local_set_sockpair_cred instead of set_socketpair_eids. * select.cc (set_bits): Drop AF_LOCAL special handling in case of except bit set.
2005-03-24 15:04:06 +01:00
int connect_secret[4];
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * include/cygwin/version.h: Bump DLL version to 1.7.0. 2006-07-25 Corinna Vinschen <corinna@vinschen.de> * select.h: Remove. * fhandler_socket.cc: Don't include select.h. * select.cc: Ditto. 2006-07-25 Corinna Vinschen <corinna@vinschen.de> * cygtls.h: Drop socket related includes. (struct _local_storage): Remove exitsock and exitsock_sin. Add select_sockevt. * cygtls.cc: Accomodate above change throughout. * fhandler.h (class fhandler_socket): Make wsock_evt public. * fhandler_socket.cc (fhandler_socket::fhandler_socket): Accomodate reordering members. (fhandler_socket::evaluate_events): Drop FD_CONNECT event as soon as it gets read once. Never remove FD_WRITE event here. (fhandler_socket::wait_for_events): Wait 50 ms instead of INFINITE for socket events. (fhandler_socket::accept): Fix conditional. Set wsock_events members of accepted socket to useful start values. (fhandler_socket::recv_internal): Always drop FD_READ/FD_OOB events from wsock_events after the call to WSARecvFrom. (fhandler_socket::send_internal): Drop FD_WRITE event from wsock_events if the call to WSASendTo fails with WSAEWOULDBLOCK. Fix return value condition. * select.cc (struct socketinf): Change to accomodate using socket event handling. (peek_socket): Use event handling for peeking socket. (thread_socket): Ditto. (start_thread_socket): Ditto. (socket_cleanup): Same here. * tlsoffsets.h: Regenerate. 2006-07-20 Corinna Vinschen <corinna@vinschen.de> * fhandler.h (class fhandler_socket): Rearrange slightly to keep event handling methods and members together. Drop owner status flag. Split wait method. Rename event handling methods for readability. * fhandler_socket.cc (struct wsa_event): Add owner field. (LOCK_EVENTS): New macro. (UNLOCK_EVENTS): Ditto. (fhandler_socket::init_events): rename from prepare. (fhandler_socket::evaluate_events): First half of former wait method. Do everything but wait. Allow specifiying whether or not events from event_mask should be erased from wsock_events->events. Simplify OOB handling. Allow sending SIGURG to any process (group). (fhandler_socket::wait_for_events): Second half of former wait method. Call evaluate_events and wait in a loop if socket is blocking. (fhandler_socket::release_events): Rename from release. (fhandler_socket::connect): Accomodate above name changes. (fhandler_socket::accept): Ditto. (fhandler_socket::recv_internal): Ditto. (fhandler_socket::send_internal): Ditto. (fhandler_socket::close): Ditto. (fhandler_socket::fcntl): Always set owner to given input value on F_SETOWN. Handle F_GETOWN. * net.cc (fdsock): Accomodate above name changes. 2006-07-20 Corinna Vinschen <corinna@vinschen.de> * fhandler_socket.cc (fhandler_socket::wait): Set Winsock errno to WSAEWOULDBLOCK instead of WSAEINPROGRESS. 2006-07-18 Brian Ford <Brian.Ford@FlightSafety.com> Corinna Vinschen <corinna@vinschen.de> * winsup.h (mmap_region_status): New enum. (mmap_is_attached_or_noreserve_page): Adjust prototype and rename as below. * mmap.cc (mmap_is_attached_or_noreserve_page): Rename mmap_is_attached_or_noreserve. Add region length parameter. Return enum above. * exceptions.cc (_cygtls::handle_exceptions): Accomodate above. * fhandler.cc (fhandler_base::raw_read): Call above for NOACCESS errors and retry on success to allow reads into untouched MAP_NORESERVE buffers. 2006-07-18 Corinna Vinschen <corinna@vinschen.de> * cygwin.din (posix_openpt): Export. * tty.cc (posix_openpt): New function. * include/cygwin/stdlib.h (posix_openpt): Declare. * include/cygwin/version.h: Bump API minor number. 2006-07-14 Corinna Vinschen <corinna@vinschen.de> * security.cc (get_token_group_sidlist): Always add the interactive group to the token. Add comment. Create logon_id group SID by copying it from incoming group list. (create_token): Add subauth_token parameter. Use information in subauth_token if present. Tweak SourceIdentifier if subauth_token is present for debugging purposes. * security.h (create_token): Add subauth_token parameter in declaration. * syscalls.cc (seteuid32): Call subauth first. Call create_token regardless. Use subauth token in call to create_token if subauth succeeded. 2006-07-13 Corinna Vinschen <corinna@vinschen.de> * include/netinet/in.h: Update copyright. 2006-07-13 Corinna Vinschen <corinna@vinschen.de> * fhandler_socket.cc (fhandler_socket::wait): Rework function so that WaitForMultipleObjects is really only called when necessary. 2006-07-12 Corinna Vinschen <corinna@vinschen.de> * include/netdb.h: Declare rcmd, rcmd_af, rexec, rresvport, rresvport_af, iruserok, iruserok_sa, ruserok. 2006-07-12 Corinna Vinschen <corinna@vinschen.de> * Makefile.in (DLL_OFILES): Drop iruserok.o. Add rcmd.o. * autoload.cc (rcmd): Drop definition. * cygwin.din: Export bindresvport, bindresvport_sa, iruserok_sa, rcmd_af, rresvport_af. * net.cc (cygwin_rcmd): Remove. (last_used_bindresvport): Rename from last_used_rrecvport. (cygwin_bindresvport_sa): New function implementing bindresvport_sa. (cygwin_bindresvport): New function implementing bindresvport. (cygwin_rresvport): Remove. * include/cygwin/version.h: Bump API minor number. * include/netinet/in.h: Declare bindresvport and bindresvport_sa. * libc/iruserok.c: Remove file. * libc/rcmd.cc: New file implementing rcmd, rcmd_af, rresvport, rresvport_af, iruserok_sa, iruserok and ruserok. 2006-07-12 Corinna Vinschen <corinna@vinschen.de> * fhandler_socket.cc (fhandler_socket::getsockname): Return valid result for unbound sockets. 2006-07-11 Corinna Vinschen <corinna@vinschen.de> * fhandler_socket.cc (fhandler_socket::fixup_after_fork): Handle wsock_mtx and wsock_evt on fork, thus handling close_on_exec correctly. (fhandler_socket::fixup_after_exec): Drop misguided attempt to handle close_on_exec here. (fhandler_socket::dup): Call fixup_after_fork with NULL parent. Add comment. (fhandler_socket::set_close_on_exec): Handle wsock_mtx and wsock_evt. 2006-07-10 Corinna Vinschen <corinna@vinschen.de> * fhandler.h (class fhandler_socket): Add wsock_mtx, wsock_evt and wsock_events members. Remove closed status flag, add listener status flag. Accomodate new implementation of socket event handling methods. Declare recv* and send* functions ssize_t as the POSIX equivalents. (fhandler_socket::recv_internal): Declare. (fhandler_socket::send_internal): Ditto. * fhandler_socket.cc (EVENT_MASK): Define mask of selected events. (fhandler_socket::fhandler_socket): Initialize new members. (fhandler_socket::af_local_setblocking): Don't actually set the socket to blocking mode. Keep sane event selection. (fhandler_socket::af_local_unsetblocking): Don't actually set the socket to previous blocking setting, just remember it. (struct wsa_event): New structure to keep event data per shared socket. (NUM_SOCKS): Define number of shared sockets concurrently handled by all active Cygwin processes. (wsa_events): New shared datastructure keeping all wsa_event records. (socket_serial_number): New shared variable to identify shared sockets. (wsa_slot_mtx): Global mutex to serialize wsa_events access. (search_wsa_event_slot): New static function to select a new wsa_event slot for a new socket. (fhandler_socket::prepare): Rewrite. Prepare event selection per new socket. (fhandler_socket::wait): Rewrite. Wait for socket events in thread safe and multiple process safe. (fhandler_socket::release): Rewrite. Close per-socket descriptor mutex handle and event handle. (fhandler_socket::dup): Duplicate wsock_mtx and wsock_evt. Fix copy-paste error in debug output. (fhandler_socket::connect): Accomodate new event handling. (fhandler_socket::listen): Set listener flag on successful listen. (fhandler_socket::accept): Accomodate new event handling. (fhandler_socket::recv_internal): New inline method centralizing common recv code. (fhandler_socket::recvfrom): Call recv_internal now. (fhandler_socket::recvmsg): Ditto. Streamline copying from iovec to WSABUF. (fhandler_socket::send_internal): New inline method centralizing common send code. (fhandler_socket::sendto): Call send_internal now. (fhandler_socket::sendmsg): Ditto. Streamline copying from iovec to WSABUF. (fhandler_socket::close): Call release now. (fhandler_socket::ioctl): Never actually switch to blocking mode. Just keep track of the setting. * net.cc (fdsock): Call prepare now. (cygwin_connect): Revert again to event driven technique. (cygwin_accept): Ditto. * poll.cc (poll): Don't call recvfrom on a listening socket. Remove special case for failing recvfrom. * include/sys/socket.h: Declare recv* and send* functions ssize_t as requested by POSIX. 2006-07-07 Corinna Vinschen <corinna@vinschen.de> * net.cc (cygwin_inet_ntop): Fix data type of forth parameter. 2006-07-06 Corinna Vinschen <corinna@vinschen.de> * include/cygwin/in6.h (struct in6_addr): Fix typo. 2006-07-06 Corinna Vinschen <corinna@vinschen.de> * cygwin.din: Export in6addr_any, in6addr_loopback, freeaddrinfo, gai_strerror, getaddrinfo, getnameinfo. * fhandler_socket.cc: Include cygwin/in6.h. (get_inet_addr): Accomodate AF_INET6 usage. (fhandler_socket::connect): Ditto. (fhandler_socket::listen): Ditto. (fhandler_socket::sendto): Ditto. * net.cc: Include cygwin/in6.h. (in6addr_any): Define. (in6addr_loopback): Define. (cygwin_socket): Accomodate AF_INET6 usage. (socketpair): Bind socketpairs only to loopback for security. (inet_pton4): New static function. (inet_pton6): Ditto. (cygwin_inet_pton): New AF_INET6 aware inet_pton implementation. (inet_ntop4): New static function. (inet_ntop6): Ditto. (cygwin_inet_ntop): New AF_INET6 aware inet_ntop implementation. (ga_aistruct): New static function. (ga_clone): Ditto. (ga_echeck): Ditto. (ga_nsearch): Ditto. (ga_port): Ditto. (ga_serv): Ditto. (ga_unix): Ditto. (gn_ipv46): Ditto. (ipv4_freeaddrinfo): Ditto. (ipv4_getaddrinfo): Ditto. (ipv4_getnameinfo): Ditto. (gai_errmap_t): New structure holding error code - error string mapping. (cygwin_gai_strerror): New function implementing gai_strerror. (w32_to_gai_err): New static function. (get_ipv6_funcs): Ditto. (load_ipv6_funcs): Ditto. (cygwin_freeaddrinfo): New function implementing freeaddrinfo. (cygwin_getaddrinfo): New function implementing getaddrinfo. (cygwin_getnameinfo): New function implementing getnameinfo. * include/netdb.h: Include stdint.h and cygwin/socket.h. Define data types and macros used by getaddrinfo and friends. Declare freeaddrinfo, gai_strerror, getaddrinfo and getnameinfo. * include/cygwin/in.h: Add IPv6 related IPPROTOs. Remove definition of struct sockaddr_in6. Include cygwin/in6.h instead. * include/cygwin/in6.h: New header file defining IPv6 releated data types and macros. * include/cygwin/socket.h: Enable AF_INET6 and PF_INET6. Add IPv6 related socket options. * include/cygwin/version.h: Bump API minor number. 2006-07-06 Corinna Vinschen <corinna@vinschen.de> * autoload.cc (DsGetDcNameA): Define. (NetGetAnyDCName): Define. * security.cc: Include dsgetdc.h. (DsGetDcNameA): Declare. (DS_FORCE_REDISCOVERY): Define. (get_logon_server): Add bool parameter to control rediscovery of DC. Use DsGetDcNameA function if supported, NetGetDCName/NetGetAnyDCName otherwise. (get_server_groups): Rediscover DC if get_user_groups fails and try again. (get_reg_security): Use correct error code macro when testing RegGetKeySecurity return value. * security.h (get_logon_server): Remove default vaue from wserver parameter. Add rediscovery parameter. * uinfo.cc (cygheap_user::env_logsrv): Accomodate rediscovery parameter in call to get_logon_server.
2006-07-25 21:23:23 +02:00
wsa_event *wsock_events;
HANDLE wsock_mtx;
HANDLE wsock_evt;
public:
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * include/cygwin/version.h: Bump DLL version to 1.7.0. 2006-07-25 Corinna Vinschen <corinna@vinschen.de> * select.h: Remove. * fhandler_socket.cc: Don't include select.h. * select.cc: Ditto. 2006-07-25 Corinna Vinschen <corinna@vinschen.de> * cygtls.h: Drop socket related includes. (struct _local_storage): Remove exitsock and exitsock_sin. Add select_sockevt. * cygtls.cc: Accomodate above change throughout. * fhandler.h (class fhandler_socket): Make wsock_evt public. * fhandler_socket.cc (fhandler_socket::fhandler_socket): Accomodate reordering members. (fhandler_socket::evaluate_events): Drop FD_CONNECT event as soon as it gets read once. Never remove FD_WRITE event here. (fhandler_socket::wait_for_events): Wait 50 ms instead of INFINITE for socket events. (fhandler_socket::accept): Fix conditional. Set wsock_events members of accepted socket to useful start values. (fhandler_socket::recv_internal): Always drop FD_READ/FD_OOB events from wsock_events after the call to WSARecvFrom. (fhandler_socket::send_internal): Drop FD_WRITE event from wsock_events if the call to WSASendTo fails with WSAEWOULDBLOCK. Fix return value condition. * select.cc (struct socketinf): Change to accomodate using socket event handling. (peek_socket): Use event handling for peeking socket. (thread_socket): Ditto. (start_thread_socket): Ditto. (socket_cleanup): Same here. * tlsoffsets.h: Regenerate. 2006-07-20 Corinna Vinschen <corinna@vinschen.de> * fhandler.h (class fhandler_socket): Rearrange slightly to keep event handling methods and members together. Drop owner status flag. Split wait method. Rename event handling methods for readability. * fhandler_socket.cc (struct wsa_event): Add owner field. (LOCK_EVENTS): New macro. (UNLOCK_EVENTS): Ditto. (fhandler_socket::init_events): rename from prepare. (fhandler_socket::evaluate_events): First half of former wait method. Do everything but wait. Allow specifiying whether or not events from event_mask should be erased from wsock_events->events. Simplify OOB handling. Allow sending SIGURG to any process (group). (fhandler_socket::wait_for_events): Second half of former wait method. Call evaluate_events and wait in a loop if socket is blocking. (fhandler_socket::release_events): Rename from release. (fhandler_socket::connect): Accomodate above name changes. (fhandler_socket::accept): Ditto. (fhandler_socket::recv_internal): Ditto. (fhandler_socket::send_internal): Ditto. (fhandler_socket::close): Ditto. (fhandler_socket::fcntl): Always set owner to given input value on F_SETOWN. Handle F_GETOWN. * net.cc (fdsock): Accomodate above name changes. 2006-07-20 Corinna Vinschen <corinna@vinschen.de> * fhandler_socket.cc (fhandler_socket::wait): Set Winsock errno to WSAEWOULDBLOCK instead of WSAEINPROGRESS. 2006-07-18 Brian Ford <Brian.Ford@FlightSafety.com> Corinna Vinschen <corinna@vinschen.de> * winsup.h (mmap_region_status): New enum. (mmap_is_attached_or_noreserve_page): Adjust prototype and rename as below. * mmap.cc (mmap_is_attached_or_noreserve_page): Rename mmap_is_attached_or_noreserve. Add region length parameter. Return enum above. * exceptions.cc (_cygtls::handle_exceptions): Accomodate above. * fhandler.cc (fhandler_base::raw_read): Call above for NOACCESS errors and retry on success to allow reads into untouched MAP_NORESERVE buffers. 2006-07-18 Corinna Vinschen <corinna@vinschen.de> * cygwin.din (posix_openpt): Export. * tty.cc (posix_openpt): New function. * include/cygwin/stdlib.h (posix_openpt): Declare. * include/cygwin/version.h: Bump API minor number. 2006-07-14 Corinna Vinschen <corinna@vinschen.de> * security.cc (get_token_group_sidlist): Always add the interactive group to the token. Add comment. Create logon_id group SID by copying it from incoming group list. (create_token): Add subauth_token parameter. Use information in subauth_token if present. Tweak SourceIdentifier if subauth_token is present for debugging purposes. * security.h (create_token): Add subauth_token parameter in declaration. * syscalls.cc (seteuid32): Call subauth first. Call create_token regardless. Use subauth token in call to create_token if subauth succeeded. 2006-07-13 Corinna Vinschen <corinna@vinschen.de> * include/netinet/in.h: Update copyright. 2006-07-13 Corinna Vinschen <corinna@vinschen.de> * fhandler_socket.cc (fhandler_socket::wait): Rework function so that WaitForMultipleObjects is really only called when necessary. 2006-07-12 Corinna Vinschen <corinna@vinschen.de> * include/netdb.h: Declare rcmd, rcmd_af, rexec, rresvport, rresvport_af, iruserok, iruserok_sa, ruserok. 2006-07-12 Corinna Vinschen <corinna@vinschen.de> * Makefile.in (DLL_OFILES): Drop iruserok.o. Add rcmd.o. * autoload.cc (rcmd): Drop definition. * cygwin.din: Export bindresvport, bindresvport_sa, iruserok_sa, rcmd_af, rresvport_af. * net.cc (cygwin_rcmd): Remove. (last_used_bindresvport): Rename from last_used_rrecvport. (cygwin_bindresvport_sa): New function implementing bindresvport_sa. (cygwin_bindresvport): New function implementing bindresvport. (cygwin_rresvport): Remove. * include/cygwin/version.h: Bump API minor number. * include/netinet/in.h: Declare bindresvport and bindresvport_sa. * libc/iruserok.c: Remove file. * libc/rcmd.cc: New file implementing rcmd, rcmd_af, rresvport, rresvport_af, iruserok_sa, iruserok and ruserok. 2006-07-12 Corinna Vinschen <corinna@vinschen.de> * fhandler_socket.cc (fhandler_socket::getsockname): Return valid result for unbound sockets. 2006-07-11 Corinna Vinschen <corinna@vinschen.de> * fhandler_socket.cc (fhandler_socket::fixup_after_fork): Handle wsock_mtx and wsock_evt on fork, thus handling close_on_exec correctly. (fhandler_socket::fixup_after_exec): Drop misguided attempt to handle close_on_exec here. (fhandler_socket::dup): Call fixup_after_fork with NULL parent. Add comment. (fhandler_socket::set_close_on_exec): Handle wsock_mtx and wsock_evt. 2006-07-10 Corinna Vinschen <corinna@vinschen.de> * fhandler.h (class fhandler_socket): Add wsock_mtx, wsock_evt and wsock_events members. Remove closed status flag, add listener status flag. Accomodate new implementation of socket event handling methods. Declare recv* and send* functions ssize_t as the POSIX equivalents. (fhandler_socket::recv_internal): Declare. (fhandler_socket::send_internal): Ditto. * fhandler_socket.cc (EVENT_MASK): Define mask of selected events. (fhandler_socket::fhandler_socket): Initialize new members. (fhandler_socket::af_local_setblocking): Don't actually set the socket to blocking mode. Keep sane event selection. (fhandler_socket::af_local_unsetblocking): Don't actually set the socket to previous blocking setting, just remember it. (struct wsa_event): New structure to keep event data per shared socket. (NUM_SOCKS): Define number of shared sockets concurrently handled by all active Cygwin processes. (wsa_events): New shared datastructure keeping all wsa_event records. (socket_serial_number): New shared variable to identify shared sockets. (wsa_slot_mtx): Global mutex to serialize wsa_events access. (search_wsa_event_slot): New static function to select a new wsa_event slot for a new socket. (fhandler_socket::prepare): Rewrite. Prepare event selection per new socket. (fhandler_socket::wait): Rewrite. Wait for socket events in thread safe and multiple process safe. (fhandler_socket::release): Rewrite. Close per-socket descriptor mutex handle and event handle. (fhandler_socket::dup): Duplicate wsock_mtx and wsock_evt. Fix copy-paste error in debug output. (fhandler_socket::connect): Accomodate new event handling. (fhandler_socket::listen): Set listener flag on successful listen. (fhandler_socket::accept): Accomodate new event handling. (fhandler_socket::recv_internal): New inline method centralizing common recv code. (fhandler_socket::recvfrom): Call recv_internal now. (fhandler_socket::recvmsg): Ditto. Streamline copying from iovec to WSABUF. (fhandler_socket::send_internal): New inline method centralizing common send code. (fhandler_socket::sendto): Call send_internal now. (fhandler_socket::sendmsg): Ditto. Streamline copying from iovec to WSABUF. (fhandler_socket::close): Call release now. (fhandler_socket::ioctl): Never actually switch to blocking mode. Just keep track of the setting. * net.cc (fdsock): Call prepare now. (cygwin_connect): Revert again to event driven technique. (cygwin_accept): Ditto. * poll.cc (poll): Don't call recvfrom on a listening socket. Remove special case for failing recvfrom. * include/sys/socket.h: Declare recv* and send* functions ssize_t as requested by POSIX. 2006-07-07 Corinna Vinschen <corinna@vinschen.de> * net.cc (cygwin_inet_ntop): Fix data type of forth parameter. 2006-07-06 Corinna Vinschen <corinna@vinschen.de> * include/cygwin/in6.h (struct in6_addr): Fix typo. 2006-07-06 Corinna Vinschen <corinna@vinschen.de> * cygwin.din: Export in6addr_any, in6addr_loopback, freeaddrinfo, gai_strerror, getaddrinfo, getnameinfo. * fhandler_socket.cc: Include cygwin/in6.h. (get_inet_addr): Accomodate AF_INET6 usage. (fhandler_socket::connect): Ditto. (fhandler_socket::listen): Ditto. (fhandler_socket::sendto): Ditto. * net.cc: Include cygwin/in6.h. (in6addr_any): Define. (in6addr_loopback): Define. (cygwin_socket): Accomodate AF_INET6 usage. (socketpair): Bind socketpairs only to loopback for security. (inet_pton4): New static function. (inet_pton6): Ditto. (cygwin_inet_pton): New AF_INET6 aware inet_pton implementation. (inet_ntop4): New static function. (inet_ntop6): Ditto. (cygwin_inet_ntop): New AF_INET6 aware inet_ntop implementation. (ga_aistruct): New static function. (ga_clone): Ditto. (ga_echeck): Ditto. (ga_nsearch): Ditto. (ga_port): Ditto. (ga_serv): Ditto. (ga_unix): Ditto. (gn_ipv46): Ditto. (ipv4_freeaddrinfo): Ditto. (ipv4_getaddrinfo): Ditto. (ipv4_getnameinfo): Ditto. (gai_errmap_t): New structure holding error code - error string mapping. (cygwin_gai_strerror): New function implementing gai_strerror. (w32_to_gai_err): New static function. (get_ipv6_funcs): Ditto. (load_ipv6_funcs): Ditto. (cygwin_freeaddrinfo): New function implementing freeaddrinfo. (cygwin_getaddrinfo): New function implementing getaddrinfo. (cygwin_getnameinfo): New function implementing getnameinfo. * include/netdb.h: Include stdint.h and cygwin/socket.h. Define data types and macros used by getaddrinfo and friends. Declare freeaddrinfo, gai_strerror, getaddrinfo and getnameinfo. * include/cygwin/in.h: Add IPv6 related IPPROTOs. Remove definition of struct sockaddr_in6. Include cygwin/in6.h instead. * include/cygwin/in6.h: New header file defining IPv6 releated data types and macros. * include/cygwin/socket.h: Enable AF_INET6 and PF_INET6. Add IPv6 related socket options. * include/cygwin/version.h: Bump API minor number. 2006-07-06 Corinna Vinschen <corinna@vinschen.de> * autoload.cc (DsGetDcNameA): Define. (NetGetAnyDCName): Define. * security.cc: Include dsgetdc.h. (DsGetDcNameA): Declare. (DS_FORCE_REDISCOVERY): Define. (get_logon_server): Add bool parameter to control rediscovery of DC. Use DsGetDcNameA function if supported, NetGetDCName/NetGetAnyDCName otherwise. (get_server_groups): Rediscover DC if get_user_groups fails and try again. (get_reg_security): Use correct error code macro when testing RegGetKeySecurity return value. * security.h (get_logon_server): Remove default vaue from wserver parameter. Add rediscovery parameter. * uinfo.cc (cygheap_user::env_logsrv): Accomodate rediscovery parameter in call to get_logon_server.
2006-07-25 21:23:23 +02:00
bool init_events ();
int evaluate_events (const long event_mask, long &events, const bool erase);
const HANDLE wsock_event () const { return wsock_evt; }
const LONG serial_number () const { return wsock_events->serial_number; }
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * include/cygwin/version.h: Bump DLL version to 1.7.0. 2006-07-25 Corinna Vinschen <corinna@vinschen.de> * select.h: Remove. * fhandler_socket.cc: Don't include select.h. * select.cc: Ditto. 2006-07-25 Corinna Vinschen <corinna@vinschen.de> * cygtls.h: Drop socket related includes. (struct _local_storage): Remove exitsock and exitsock_sin. Add select_sockevt. * cygtls.cc: Accomodate above change throughout. * fhandler.h (class fhandler_socket): Make wsock_evt public. * fhandler_socket.cc (fhandler_socket::fhandler_socket): Accomodate reordering members. (fhandler_socket::evaluate_events): Drop FD_CONNECT event as soon as it gets read once. Never remove FD_WRITE event here. (fhandler_socket::wait_for_events): Wait 50 ms instead of INFINITE for socket events. (fhandler_socket::accept): Fix conditional. Set wsock_events members of accepted socket to useful start values. (fhandler_socket::recv_internal): Always drop FD_READ/FD_OOB events from wsock_events after the call to WSARecvFrom. (fhandler_socket::send_internal): Drop FD_WRITE event from wsock_events if the call to WSASendTo fails with WSAEWOULDBLOCK. Fix return value condition. * select.cc (struct socketinf): Change to accomodate using socket event handling. (peek_socket): Use event handling for peeking socket. (thread_socket): Ditto. (start_thread_socket): Ditto. (socket_cleanup): Same here. * tlsoffsets.h: Regenerate. 2006-07-20 Corinna Vinschen <corinna@vinschen.de> * fhandler.h (class fhandler_socket): Rearrange slightly to keep event handling methods and members together. Drop owner status flag. Split wait method. Rename event handling methods for readability. * fhandler_socket.cc (struct wsa_event): Add owner field. (LOCK_EVENTS): New macro. (UNLOCK_EVENTS): Ditto. (fhandler_socket::init_events): rename from prepare. (fhandler_socket::evaluate_events): First half of former wait method. Do everything but wait. Allow specifiying whether or not events from event_mask should be erased from wsock_events->events. Simplify OOB handling. Allow sending SIGURG to any process (group). (fhandler_socket::wait_for_events): Second half of former wait method. Call evaluate_events and wait in a loop if socket is blocking. (fhandler_socket::release_events): Rename from release. (fhandler_socket::connect): Accomodate above name changes. (fhandler_socket::accept): Ditto. (fhandler_socket::recv_internal): Ditto. (fhandler_socket::send_internal): Ditto. (fhandler_socket::close): Ditto. (fhandler_socket::fcntl): Always set owner to given input value on F_SETOWN. Handle F_GETOWN. * net.cc (fdsock): Accomodate above name changes. 2006-07-20 Corinna Vinschen <corinna@vinschen.de> * fhandler_socket.cc (fhandler_socket::wait): Set Winsock errno to WSAEWOULDBLOCK instead of WSAEINPROGRESS. 2006-07-18 Brian Ford <Brian.Ford@FlightSafety.com> Corinna Vinschen <corinna@vinschen.de> * winsup.h (mmap_region_status): New enum. (mmap_is_attached_or_noreserve_page): Adjust prototype and rename as below. * mmap.cc (mmap_is_attached_or_noreserve_page): Rename mmap_is_attached_or_noreserve. Add region length parameter. Return enum above. * exceptions.cc (_cygtls::handle_exceptions): Accomodate above. * fhandler.cc (fhandler_base::raw_read): Call above for NOACCESS errors and retry on success to allow reads into untouched MAP_NORESERVE buffers. 2006-07-18 Corinna Vinschen <corinna@vinschen.de> * cygwin.din (posix_openpt): Export. * tty.cc (posix_openpt): New function. * include/cygwin/stdlib.h (posix_openpt): Declare. * include/cygwin/version.h: Bump API minor number. 2006-07-14 Corinna Vinschen <corinna@vinschen.de> * security.cc (get_token_group_sidlist): Always add the interactive group to the token. Add comment. Create logon_id group SID by copying it from incoming group list. (create_token): Add subauth_token parameter. Use information in subauth_token if present. Tweak SourceIdentifier if subauth_token is present for debugging purposes. * security.h (create_token): Add subauth_token parameter in declaration. * syscalls.cc (seteuid32): Call subauth first. Call create_token regardless. Use subauth token in call to create_token if subauth succeeded. 2006-07-13 Corinna Vinschen <corinna@vinschen.de> * include/netinet/in.h: Update copyright. 2006-07-13 Corinna Vinschen <corinna@vinschen.de> * fhandler_socket.cc (fhandler_socket::wait): Rework function so that WaitForMultipleObjects is really only called when necessary. 2006-07-12 Corinna Vinschen <corinna@vinschen.de> * include/netdb.h: Declare rcmd, rcmd_af, rexec, rresvport, rresvport_af, iruserok, iruserok_sa, ruserok. 2006-07-12 Corinna Vinschen <corinna@vinschen.de> * Makefile.in (DLL_OFILES): Drop iruserok.o. Add rcmd.o. * autoload.cc (rcmd): Drop definition. * cygwin.din: Export bindresvport, bindresvport_sa, iruserok_sa, rcmd_af, rresvport_af. * net.cc (cygwin_rcmd): Remove. (last_used_bindresvport): Rename from last_used_rrecvport. (cygwin_bindresvport_sa): New function implementing bindresvport_sa. (cygwin_bindresvport): New function implementing bindresvport. (cygwin_rresvport): Remove. * include/cygwin/version.h: Bump API minor number. * include/netinet/in.h: Declare bindresvport and bindresvport_sa. * libc/iruserok.c: Remove file. * libc/rcmd.cc: New file implementing rcmd, rcmd_af, rresvport, rresvport_af, iruserok_sa, iruserok and ruserok. 2006-07-12 Corinna Vinschen <corinna@vinschen.de> * fhandler_socket.cc (fhandler_socket::getsockname): Return valid result for unbound sockets. 2006-07-11 Corinna Vinschen <corinna@vinschen.de> * fhandler_socket.cc (fhandler_socket::fixup_after_fork): Handle wsock_mtx and wsock_evt on fork, thus handling close_on_exec correctly. (fhandler_socket::fixup_after_exec): Drop misguided attempt to handle close_on_exec here. (fhandler_socket::dup): Call fixup_after_fork with NULL parent. Add comment. (fhandler_socket::set_close_on_exec): Handle wsock_mtx and wsock_evt. 2006-07-10 Corinna Vinschen <corinna@vinschen.de> * fhandler.h (class fhandler_socket): Add wsock_mtx, wsock_evt and wsock_events members. Remove closed status flag, add listener status flag. Accomodate new implementation of socket event handling methods. Declare recv* and send* functions ssize_t as the POSIX equivalents. (fhandler_socket::recv_internal): Declare. (fhandler_socket::send_internal): Ditto. * fhandler_socket.cc (EVENT_MASK): Define mask of selected events. (fhandler_socket::fhandler_socket): Initialize new members. (fhandler_socket::af_local_setblocking): Don't actually set the socket to blocking mode. Keep sane event selection. (fhandler_socket::af_local_unsetblocking): Don't actually set the socket to previous blocking setting, just remember it. (struct wsa_event): New structure to keep event data per shared socket. (NUM_SOCKS): Define number of shared sockets concurrently handled by all active Cygwin processes. (wsa_events): New shared datastructure keeping all wsa_event records. (socket_serial_number): New shared variable to identify shared sockets. (wsa_slot_mtx): Global mutex to serialize wsa_events access. (search_wsa_event_slot): New static function to select a new wsa_event slot for a new socket. (fhandler_socket::prepare): Rewrite. Prepare event selection per new socket. (fhandler_socket::wait): Rewrite. Wait for socket events in thread safe and multiple process safe. (fhandler_socket::release): Rewrite. Close per-socket descriptor mutex handle and event handle. (fhandler_socket::dup): Duplicate wsock_mtx and wsock_evt. Fix copy-paste error in debug output. (fhandler_socket::connect): Accomodate new event handling. (fhandler_socket::listen): Set listener flag on successful listen. (fhandler_socket::accept): Accomodate new event handling. (fhandler_socket::recv_internal): New inline method centralizing common recv code. (fhandler_socket::recvfrom): Call recv_internal now. (fhandler_socket::recvmsg): Ditto. Streamline copying from iovec to WSABUF. (fhandler_socket::send_internal): New inline method centralizing common send code. (fhandler_socket::sendto): Call send_internal now. (fhandler_socket::sendmsg): Ditto. Streamline copying from iovec to WSABUF. (fhandler_socket::close): Call release now. (fhandler_socket::ioctl): Never actually switch to blocking mode. Just keep track of the setting. * net.cc (fdsock): Call prepare now. (cygwin_connect): Revert again to event driven technique. (cygwin_accept): Ditto. * poll.cc (poll): Don't call recvfrom on a listening socket. Remove special case for failing recvfrom. * include/sys/socket.h: Declare recv* and send* functions ssize_t as requested by POSIX. 2006-07-07 Corinna Vinschen <corinna@vinschen.de> * net.cc (cygwin_inet_ntop): Fix data type of forth parameter. 2006-07-06 Corinna Vinschen <corinna@vinschen.de> * include/cygwin/in6.h (struct in6_addr): Fix typo. 2006-07-06 Corinna Vinschen <corinna@vinschen.de> * cygwin.din: Export in6addr_any, in6addr_loopback, freeaddrinfo, gai_strerror, getaddrinfo, getnameinfo. * fhandler_socket.cc: Include cygwin/in6.h. (get_inet_addr): Accomodate AF_INET6 usage. (fhandler_socket::connect): Ditto. (fhandler_socket::listen): Ditto. (fhandler_socket::sendto): Ditto. * net.cc: Include cygwin/in6.h. (in6addr_any): Define. (in6addr_loopback): Define. (cygwin_socket): Accomodate AF_INET6 usage. (socketpair): Bind socketpairs only to loopback for security. (inet_pton4): New static function. (inet_pton6): Ditto. (cygwin_inet_pton): New AF_INET6 aware inet_pton implementation. (inet_ntop4): New static function. (inet_ntop6): Ditto. (cygwin_inet_ntop): New AF_INET6 aware inet_ntop implementation. (ga_aistruct): New static function. (ga_clone): Ditto. (ga_echeck): Ditto. (ga_nsearch): Ditto. (ga_port): Ditto. (ga_serv): Ditto. (ga_unix): Ditto. (gn_ipv46): Ditto. (ipv4_freeaddrinfo): Ditto. (ipv4_getaddrinfo): Ditto. (ipv4_getnameinfo): Ditto. (gai_errmap_t): New structure holding error code - error string mapping. (cygwin_gai_strerror): New function implementing gai_strerror. (w32_to_gai_err): New static function. (get_ipv6_funcs): Ditto. (load_ipv6_funcs): Ditto. (cygwin_freeaddrinfo): New function implementing freeaddrinfo. (cygwin_getaddrinfo): New function implementing getaddrinfo. (cygwin_getnameinfo): New function implementing getnameinfo. * include/netdb.h: Include stdint.h and cygwin/socket.h. Define data types and macros used by getaddrinfo and friends. Declare freeaddrinfo, gai_strerror, getaddrinfo and getnameinfo. * include/cygwin/in.h: Add IPv6 related IPPROTOs. Remove definition of struct sockaddr_in6. Include cygwin/in6.h instead. * include/cygwin/in6.h: New header file defining IPv6 releated data types and macros. * include/cygwin/socket.h: Enable AF_INET6 and PF_INET6. Add IPv6 related socket options. * include/cygwin/version.h: Bump API minor number. 2006-07-06 Corinna Vinschen <corinna@vinschen.de> * autoload.cc (DsGetDcNameA): Define. (NetGetAnyDCName): Define. * security.cc: Include dsgetdc.h. (DsGetDcNameA): Declare. (DS_FORCE_REDISCOVERY): Define. (get_logon_server): Add bool parameter to control rediscovery of DC. Use DsGetDcNameA function if supported, NetGetDCName/NetGetAnyDCName otherwise. (get_server_groups): Rediscover DC if get_user_groups fails and try again. (get_reg_security): Use correct error code macro when testing RegGetKeySecurity return value. * security.h (get_logon_server): Remove default vaue from wserver parameter. Add rediscovery parameter. * uinfo.cc (cygheap_user::env_logsrv): Accomodate rediscovery parameter in call to get_logon_server.
2006-07-25 21:23:23 +02:00
private:
int wait_for_events (const long event_mask, const DWORD flags);
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * include/cygwin/version.h: Bump DLL version to 1.7.0. 2006-07-25 Corinna Vinschen <corinna@vinschen.de> * select.h: Remove. * fhandler_socket.cc: Don't include select.h. * select.cc: Ditto. 2006-07-25 Corinna Vinschen <corinna@vinschen.de> * cygtls.h: Drop socket related includes. (struct _local_storage): Remove exitsock and exitsock_sin. Add select_sockevt. * cygtls.cc: Accomodate above change throughout. * fhandler.h (class fhandler_socket): Make wsock_evt public. * fhandler_socket.cc (fhandler_socket::fhandler_socket): Accomodate reordering members. (fhandler_socket::evaluate_events): Drop FD_CONNECT event as soon as it gets read once. Never remove FD_WRITE event here. (fhandler_socket::wait_for_events): Wait 50 ms instead of INFINITE for socket events. (fhandler_socket::accept): Fix conditional. Set wsock_events members of accepted socket to useful start values. (fhandler_socket::recv_internal): Always drop FD_READ/FD_OOB events from wsock_events after the call to WSARecvFrom. (fhandler_socket::send_internal): Drop FD_WRITE event from wsock_events if the call to WSASendTo fails with WSAEWOULDBLOCK. Fix return value condition. * select.cc (struct socketinf): Change to accomodate using socket event handling. (peek_socket): Use event handling for peeking socket. (thread_socket): Ditto. (start_thread_socket): Ditto. (socket_cleanup): Same here. * tlsoffsets.h: Regenerate. 2006-07-20 Corinna Vinschen <corinna@vinschen.de> * fhandler.h (class fhandler_socket): Rearrange slightly to keep event handling methods and members together. Drop owner status flag. Split wait method. Rename event handling methods for readability. * fhandler_socket.cc (struct wsa_event): Add owner field. (LOCK_EVENTS): New macro. (UNLOCK_EVENTS): Ditto. (fhandler_socket::init_events): rename from prepare. (fhandler_socket::evaluate_events): First half of former wait method. Do everything but wait. Allow specifiying whether or not events from event_mask should be erased from wsock_events->events. Simplify OOB handling. Allow sending SIGURG to any process (group). (fhandler_socket::wait_for_events): Second half of former wait method. Call evaluate_events and wait in a loop if socket is blocking. (fhandler_socket::release_events): Rename from release. (fhandler_socket::connect): Accomodate above name changes. (fhandler_socket::accept): Ditto. (fhandler_socket::recv_internal): Ditto. (fhandler_socket::send_internal): Ditto. (fhandler_socket::close): Ditto. (fhandler_socket::fcntl): Always set owner to given input value on F_SETOWN. Handle F_GETOWN. * net.cc (fdsock): Accomodate above name changes. 2006-07-20 Corinna Vinschen <corinna@vinschen.de> * fhandler_socket.cc (fhandler_socket::wait): Set Winsock errno to WSAEWOULDBLOCK instead of WSAEINPROGRESS. 2006-07-18 Brian Ford <Brian.Ford@FlightSafety.com> Corinna Vinschen <corinna@vinschen.de> * winsup.h (mmap_region_status): New enum. (mmap_is_attached_or_noreserve_page): Adjust prototype and rename as below. * mmap.cc (mmap_is_attached_or_noreserve_page): Rename mmap_is_attached_or_noreserve. Add region length parameter. Return enum above. * exceptions.cc (_cygtls::handle_exceptions): Accomodate above. * fhandler.cc (fhandler_base::raw_read): Call above for NOACCESS errors and retry on success to allow reads into untouched MAP_NORESERVE buffers. 2006-07-18 Corinna Vinschen <corinna@vinschen.de> * cygwin.din (posix_openpt): Export. * tty.cc (posix_openpt): New function. * include/cygwin/stdlib.h (posix_openpt): Declare. * include/cygwin/version.h: Bump API minor number. 2006-07-14 Corinna Vinschen <corinna@vinschen.de> * security.cc (get_token_group_sidlist): Always add the interactive group to the token. Add comment. Create logon_id group SID by copying it from incoming group list. (create_token): Add subauth_token parameter. Use information in subauth_token if present. Tweak SourceIdentifier if subauth_token is present for debugging purposes. * security.h (create_token): Add subauth_token parameter in declaration. * syscalls.cc (seteuid32): Call subauth first. Call create_token regardless. Use subauth token in call to create_token if subauth succeeded. 2006-07-13 Corinna Vinschen <corinna@vinschen.de> * include/netinet/in.h: Update copyright. 2006-07-13 Corinna Vinschen <corinna@vinschen.de> * fhandler_socket.cc (fhandler_socket::wait): Rework function so that WaitForMultipleObjects is really only called when necessary. 2006-07-12 Corinna Vinschen <corinna@vinschen.de> * include/netdb.h: Declare rcmd, rcmd_af, rexec, rresvport, rresvport_af, iruserok, iruserok_sa, ruserok. 2006-07-12 Corinna Vinschen <corinna@vinschen.de> * Makefile.in (DLL_OFILES): Drop iruserok.o. Add rcmd.o. * autoload.cc (rcmd): Drop definition. * cygwin.din: Export bindresvport, bindresvport_sa, iruserok_sa, rcmd_af, rresvport_af. * net.cc (cygwin_rcmd): Remove. (last_used_bindresvport): Rename from last_used_rrecvport. (cygwin_bindresvport_sa): New function implementing bindresvport_sa. (cygwin_bindresvport): New function implementing bindresvport. (cygwin_rresvport): Remove. * include/cygwin/version.h: Bump API minor number. * include/netinet/in.h: Declare bindresvport and bindresvport_sa. * libc/iruserok.c: Remove file. * libc/rcmd.cc: New file implementing rcmd, rcmd_af, rresvport, rresvport_af, iruserok_sa, iruserok and ruserok. 2006-07-12 Corinna Vinschen <corinna@vinschen.de> * fhandler_socket.cc (fhandler_socket::getsockname): Return valid result for unbound sockets. 2006-07-11 Corinna Vinschen <corinna@vinschen.de> * fhandler_socket.cc (fhandler_socket::fixup_after_fork): Handle wsock_mtx and wsock_evt on fork, thus handling close_on_exec correctly. (fhandler_socket::fixup_after_exec): Drop misguided attempt to handle close_on_exec here. (fhandler_socket::dup): Call fixup_after_fork with NULL parent. Add comment. (fhandler_socket::set_close_on_exec): Handle wsock_mtx and wsock_evt. 2006-07-10 Corinna Vinschen <corinna@vinschen.de> * fhandler.h (class fhandler_socket): Add wsock_mtx, wsock_evt and wsock_events members. Remove closed status flag, add listener status flag. Accomodate new implementation of socket event handling methods. Declare recv* and send* functions ssize_t as the POSIX equivalents. (fhandler_socket::recv_internal): Declare. (fhandler_socket::send_internal): Ditto. * fhandler_socket.cc (EVENT_MASK): Define mask of selected events. (fhandler_socket::fhandler_socket): Initialize new members. (fhandler_socket::af_local_setblocking): Don't actually set the socket to blocking mode. Keep sane event selection. (fhandler_socket::af_local_unsetblocking): Don't actually set the socket to previous blocking setting, just remember it. (struct wsa_event): New structure to keep event data per shared socket. (NUM_SOCKS): Define number of shared sockets concurrently handled by all active Cygwin processes. (wsa_events): New shared datastructure keeping all wsa_event records. (socket_serial_number): New shared variable to identify shared sockets. (wsa_slot_mtx): Global mutex to serialize wsa_events access. (search_wsa_event_slot): New static function to select a new wsa_event slot for a new socket. (fhandler_socket::prepare): Rewrite. Prepare event selection per new socket. (fhandler_socket::wait): Rewrite. Wait for socket events in thread safe and multiple process safe. (fhandler_socket::release): Rewrite. Close per-socket descriptor mutex handle and event handle. (fhandler_socket::dup): Duplicate wsock_mtx and wsock_evt. Fix copy-paste error in debug output. (fhandler_socket::connect): Accomodate new event handling. (fhandler_socket::listen): Set listener flag on successful listen. (fhandler_socket::accept): Accomodate new event handling. (fhandler_socket::recv_internal): New inline method centralizing common recv code. (fhandler_socket::recvfrom): Call recv_internal now. (fhandler_socket::recvmsg): Ditto. Streamline copying from iovec to WSABUF. (fhandler_socket::send_internal): New inline method centralizing common send code. (fhandler_socket::sendto): Call send_internal now. (fhandler_socket::sendmsg): Ditto. Streamline copying from iovec to WSABUF. (fhandler_socket::close): Call release now. (fhandler_socket::ioctl): Never actually switch to blocking mode. Just keep track of the setting. * net.cc (fdsock): Call prepare now. (cygwin_connect): Revert again to event driven technique. (cygwin_accept): Ditto. * poll.cc (poll): Don't call recvfrom on a listening socket. Remove special case for failing recvfrom. * include/sys/socket.h: Declare recv* and send* functions ssize_t as requested by POSIX. 2006-07-07 Corinna Vinschen <corinna@vinschen.de> * net.cc (cygwin_inet_ntop): Fix data type of forth parameter. 2006-07-06 Corinna Vinschen <corinna@vinschen.de> * include/cygwin/in6.h (struct in6_addr): Fix typo. 2006-07-06 Corinna Vinschen <corinna@vinschen.de> * cygwin.din: Export in6addr_any, in6addr_loopback, freeaddrinfo, gai_strerror, getaddrinfo, getnameinfo. * fhandler_socket.cc: Include cygwin/in6.h. (get_inet_addr): Accomodate AF_INET6 usage. (fhandler_socket::connect): Ditto. (fhandler_socket::listen): Ditto. (fhandler_socket::sendto): Ditto. * net.cc: Include cygwin/in6.h. (in6addr_any): Define. (in6addr_loopback): Define. (cygwin_socket): Accomodate AF_INET6 usage. (socketpair): Bind socketpairs only to loopback for security. (inet_pton4): New static function. (inet_pton6): Ditto. (cygwin_inet_pton): New AF_INET6 aware inet_pton implementation. (inet_ntop4): New static function. (inet_ntop6): Ditto. (cygwin_inet_ntop): New AF_INET6 aware inet_ntop implementation. (ga_aistruct): New static function. (ga_clone): Ditto. (ga_echeck): Ditto. (ga_nsearch): Ditto. (ga_port): Ditto. (ga_serv): Ditto. (ga_unix): Ditto. (gn_ipv46): Ditto. (ipv4_freeaddrinfo): Ditto. (ipv4_getaddrinfo): Ditto. (ipv4_getnameinfo): Ditto. (gai_errmap_t): New structure holding error code - error string mapping. (cygwin_gai_strerror): New function implementing gai_strerror. (w32_to_gai_err): New static function. (get_ipv6_funcs): Ditto. (load_ipv6_funcs): Ditto. (cygwin_freeaddrinfo): New function implementing freeaddrinfo. (cygwin_getaddrinfo): New function implementing getaddrinfo. (cygwin_getnameinfo): New function implementing getnameinfo. * include/netdb.h: Include stdint.h and cygwin/socket.h. Define data types and macros used by getaddrinfo and friends. Declare freeaddrinfo, gai_strerror, getaddrinfo and getnameinfo. * include/cygwin/in.h: Add IPv6 related IPPROTOs. Remove definition of struct sockaddr_in6. Include cygwin/in6.h instead. * include/cygwin/in6.h: New header file defining IPv6 releated data types and macros. * include/cygwin/socket.h: Enable AF_INET6 and PF_INET6. Add IPv6 related socket options. * include/cygwin/version.h: Bump API minor number. 2006-07-06 Corinna Vinschen <corinna@vinschen.de> * autoload.cc (DsGetDcNameA): Define. (NetGetAnyDCName): Define. * security.cc: Include dsgetdc.h. (DsGetDcNameA): Declare. (DS_FORCE_REDISCOVERY): Define. (get_logon_server): Add bool parameter to control rediscovery of DC. Use DsGetDcNameA function if supported, NetGetDCName/NetGetAnyDCName otherwise. (get_server_groups): Rediscover DC if get_user_groups fails and try again. (get_reg_security): Use correct error code macro when testing RegGetKeySecurity return value. * security.h (get_logon_server): Remove default vaue from wserver parameter. Add rediscovery parameter. * uinfo.cc (cygheap_user::env_logsrv): Accomodate rediscovery parameter in call to get_logon_server.
2006-07-25 21:23:23 +02:00
void release_events ();
pid_t sec_pid;
__uid32_t sec_uid;
__gid32_t sec_gid;
pid_t sec_peer_pid;
__uid32_t sec_peer_uid;
__gid32_t sec_peer_gid;
* fhandler.h (fhandler_socket::secret_event): Remove. (fhandler_socket::af_local_set_secret): New function combining former set_connect_secret and get_connect_secret into one function. (fhandler_socket::af_local_setblocking): Rename from eid_setblocking. (fhandler_socket::af_local_unsetblocking): Rename from eid_unsetblocking. (fhandler_socket::af_local_set_cred): New method. (fhandler_socket::af_local_copy): New method. (fhandler_socket::af_local_recv_secret): New method. (fhandler_socket::af_local_send_secret): New method. (fhandler_socket::af_local_recv_cred): Rename from eid_recv. (fhandler_socket::af_local_send_cred): Rename from eid_send. (fhandler_socket::af_local_accept): New method. (fhandler_socket::af_local_set_sockpair_cred): Rename from set_socketpair_eids. (fhandler_socket::eid_accept): Remove. (fhandler_socket::eid_connect): Remove. (fhandler_socket::set_connect_secret): Remove. (fhandler_socket::get_connect_secret): Remove. (fhandler_socket::create_secret_event): Remove. (fhandler_socket::check_peer_secret_event): Remove. (fhandler_socket::signal_secret_event): Remove. (fhandler_socket::close_secret_event): Remove. (fhandler_socket::sec_event_accept): Remove. (fhandler_socket::sec_event_connect): Remove. * fhandler_socket.cc (secret_event_name): Remove. (fhandler_socket::af_local_set_sockpair_cred): Rename from set_socketpair_eids. (fhandler_socket::af_local_setblocking): Rename from eid_setblocking. (fhandler_socket::af_local_unsetblocking): Rename from eid_unsetblocking. (fhandler_socket::af_local_recv_secret): New function to receive AF_LOCAL connect secret over socket itself. (fhandler_socket::af_local_send_secret): New function to send AF_LOCAL connect secret over socket itself. (fhandler_socket::af_local_recv_cred): Rename from eid_recv. (fhandler_socket::af_local_send_cred): Rename from eid_send. (fhandler_socket::eid_connect): Remove. (fhandler_socket::af_local_connect): Take over connect side handling of AF_LOCAL secret and credential handshake. (fhandler_socket::eid_accept): Remove. (fhandler_socket::af_local_accept): New method, take over accept side handling of AF_LOCAL secret and credential handshake. (fhandler_socket::af_local_set_cred): New method, set eid credentials to start values. (fhandler_socket::af_local_copy): New method, copy secret and credentials to another socket. (fhandler_socket::af_local_set_secret): New function combining former set_connect_secret and get_connect_secret into one function. (fhandler_socket::create_secret_event): Remove. (fhandler_socket::signal_secret_event): Remove. (fhandler_socket::close_secret_event): Remove. (fhandler_socket::check_peer_secret_event): Remove. (fhandler_socket::sec_event_connect): Remove. (fhandler_socket::sec_event_accept): Remove. (fhandler_socket::fixup_after_fork): Drop secret_event handling. (fhandler_socket::bind): Call af_local_set_secret. (fhandler_socket::connect): Call af_local_set_cred and af_local_connect. (fhandler_socket::listen): Call af_local_set_cred. (fhandler_socket::accept): Call af_local_copy and af_local_accept on accepted socket. (fhandler_socket::close): Don't call close_secret_event. (fhandler_socket::set_close_on_exec): Don't set secret_event inheritance. * net.cc (cygwin_getsockopt): Add debug output. (socketpair): Call af_local_set_sockpair_cred instead of set_socketpair_eids. * select.cc (set_bits): Drop AF_LOCAL special handling in case of except bit set.
2005-03-24 15:04:06 +01:00
void af_local_set_secret (char *);
void af_local_setblocking (bool &, bool &);
void af_local_unsetblocking (bool, bool);
void af_local_set_cred ();
* fhandler.h (fhandler_socket::secret_event): Remove. (fhandler_socket::af_local_set_secret): New function combining former set_connect_secret and get_connect_secret into one function. (fhandler_socket::af_local_setblocking): Rename from eid_setblocking. (fhandler_socket::af_local_unsetblocking): Rename from eid_unsetblocking. (fhandler_socket::af_local_set_cred): New method. (fhandler_socket::af_local_copy): New method. (fhandler_socket::af_local_recv_secret): New method. (fhandler_socket::af_local_send_secret): New method. (fhandler_socket::af_local_recv_cred): Rename from eid_recv. (fhandler_socket::af_local_send_cred): Rename from eid_send. (fhandler_socket::af_local_accept): New method. (fhandler_socket::af_local_set_sockpair_cred): Rename from set_socketpair_eids. (fhandler_socket::eid_accept): Remove. (fhandler_socket::eid_connect): Remove. (fhandler_socket::set_connect_secret): Remove. (fhandler_socket::get_connect_secret): Remove. (fhandler_socket::create_secret_event): Remove. (fhandler_socket::check_peer_secret_event): Remove. (fhandler_socket::signal_secret_event): Remove. (fhandler_socket::close_secret_event): Remove. (fhandler_socket::sec_event_accept): Remove. (fhandler_socket::sec_event_connect): Remove. * fhandler_socket.cc (secret_event_name): Remove. (fhandler_socket::af_local_set_sockpair_cred): Rename from set_socketpair_eids. (fhandler_socket::af_local_setblocking): Rename from eid_setblocking. (fhandler_socket::af_local_unsetblocking): Rename from eid_unsetblocking. (fhandler_socket::af_local_recv_secret): New function to receive AF_LOCAL connect secret over socket itself. (fhandler_socket::af_local_send_secret): New function to send AF_LOCAL connect secret over socket itself. (fhandler_socket::af_local_recv_cred): Rename from eid_recv. (fhandler_socket::af_local_send_cred): Rename from eid_send. (fhandler_socket::eid_connect): Remove. (fhandler_socket::af_local_connect): Take over connect side handling of AF_LOCAL secret and credential handshake. (fhandler_socket::eid_accept): Remove. (fhandler_socket::af_local_accept): New method, take over accept side handling of AF_LOCAL secret and credential handshake. (fhandler_socket::af_local_set_cred): New method, set eid credentials to start values. (fhandler_socket::af_local_copy): New method, copy secret and credentials to another socket. (fhandler_socket::af_local_set_secret): New function combining former set_connect_secret and get_connect_secret into one function. (fhandler_socket::create_secret_event): Remove. (fhandler_socket::signal_secret_event): Remove. (fhandler_socket::close_secret_event): Remove. (fhandler_socket::check_peer_secret_event): Remove. (fhandler_socket::sec_event_connect): Remove. (fhandler_socket::sec_event_accept): Remove. (fhandler_socket::fixup_after_fork): Drop secret_event handling. (fhandler_socket::bind): Call af_local_set_secret. (fhandler_socket::connect): Call af_local_set_cred and af_local_connect. (fhandler_socket::listen): Call af_local_set_cred. (fhandler_socket::accept): Call af_local_copy and af_local_accept on accepted socket. (fhandler_socket::close): Don't call close_secret_event. (fhandler_socket::set_close_on_exec): Don't set secret_event inheritance. * net.cc (cygwin_getsockopt): Add debug output. (socketpair): Call af_local_set_sockpair_cred instead of set_socketpair_eids. * select.cc (set_bits): Drop AF_LOCAL special handling in case of except bit set.
2005-03-24 15:04:06 +01:00
void af_local_copy (fhandler_socket *);
bool af_local_recv_secret ();
bool af_local_send_secret ();
bool af_local_recv_cred ();
bool af_local_send_cred ();
int af_local_accept ();
* fhandler.h (fhandler_socket::eid_connect): Make private. (fhandler_socket::set_connect_secret): Ditto. (fhandler_socket::get_connect_secret): Ditto. (fhandler_socket::create_secret_event): Ditto. Remove secret argument. (fhandler_socket::check_peer_secret_event): Ditto. (fhandler_socket::signal_secret_event): Make private. (fhandler_socket::close_secret_event): Ditto. (fhandler_socket::sec_event_accept): New private method. (fhandler_socket::sec_event_connect): Ditto. (fhandler_socket::af_local_connect): New public method. * fhandler_socket.cc: Use 'struct sockaddr' and 'struct sockaddr_in' rather than just 'sockaddr' and 'sockaddr_in' throughout. (fhandler_socket::eid_connect): Drop AF_LOCAL/SOCK_STREAM test. (fhandler_socket::create_secret_event): Remove secret argument. Always use connect_secret instead. (fhandler_socket::check_peer_secret_event): Ditto. (fhandler_socket::sec_event_connect): New method, combining entire secret event handshake on connect side. (fhandler_socket::af_local_connect): New method, combining secret event handshake and eid credential transaction on connect side, to be called from select. (fhandler_socket::sec_event_accept): New method, combining entire secret event handshake on accept side. (fhandler_socket::connect): Drop secret, use connect_secret instead. Move entire secret event handshake to sec_event_connect. (fhandler_socket::accept): Move entire secret event handshake to sec_event_accept. * select.cc (set_bits): Just call af_local_connect here.
2005-03-23 18:27:18 +01:00
public:
int af_local_connect ();
void af_local_set_sockpair_cred ();
private:
int _rmem;
int _wmem;
public:
int &rmem () { return _rmem; }
int &wmem () { return _wmem; }
void rmem (int nrmem) { _rmem = nrmem; }
void wmem (int nwmem) { _wmem = nwmem; }
Reintegrate socket duplication via WSADuplicateSocket/WSASocket. * autoload.cc (WSADuplicateSocketW): Define. (WSASocketW): Define. * dtable.cc (dtable::release): Call dec_need_fixup_before if necessary. (dtable::fixup_before_fork): New function. (dtable::fixup_before_exec): New function. * dtable.h (class dtable): Add member cnt_need_fixup_before. Add declarations for above new functions. (dtable::dec_need_fixup_before): New inline method. (dtable::inc_need_fixup_before): New inline method. (dtable::need_fixup_before): New inline method. * fhandler.h (fhandler_base::fixup_before_fork_exec): New virtual method. (fhandler_base::need_fixup_before): New virtual method. (class fhandler_socket): Add member prot_info_ptr. (fhandler_socket::init_fixup_before): Declare. (fhandler_socket::need_fixup_before): New inline method. (fhandler_socket::fixup_before_fork_exec): Declare. (fhandler_socket::fixup_after_exec): Declare. * fhandler_socket.cc (fhandler_socket::fhandler_socket): Initialize prot_info_ptr to NULL. (fhandler_socket::~fhandler_socket): Free prot_info_ptr conditionally. (fhandler_socket::init_fixup_before): New method. (fhandler_socket::fixup_before_fork_exec): Ditto. (fhandler_socket::fixup_after_fork): Use WSASocketW to duplicate socket if necessary. (fhandler_socket::fixup_after_exec): New method. (fhandler_socket::dup): Use fixup_before_fork_exec/fixup_after_fork to duplicate socket if necessary. * fork.cc (frok::parent): Start child suspended if some fhandler needs fixup before fork. If so, call dtable::fixup_before_fork after CreateProcess and resume child. * net.cc (fdsock): Try to find out if socket needs fixup before and initialize socket accordingly. Add HUGE comment to explain what happens and why. * spawn.cc (spawn_guts): Start child suspended if some fhandler needs fixup before exec. If so, call dtable::fixup_before_exec after CreateProcess.
2009-11-17 11:43:01 +01:00
private:
struct _WSAPROTOCOL_INFOW *prot_info_ptr;
public:
void init_fixup_before ();
bool need_fixup_before () const {return prot_info_ptr != NULL;}
private:
char *sun_path;
char *peer_sun_path;
struct status_flags
{
* fhandler.h (fhandler_pipe::create_selectable): Remove optional argument, take an options argument for CreateNamedPipe/CreateFile. Change handle arguments to expect pointers. (fhandler_fifo::fifo_state): Delete. (fhandler_fifo::dummy_client): Ditto. (fhandler_fifo::open_nonserver): Ditto. (fhandler_fifo::wait_state): Ditto. (fhandler_fifo::raw_write): Ditto. (fhandler_fifo::read_ready): New field. (fhandler_fifo::write_ready): Ditto. (fhandler_fifo::wait): Modify argument. (fhandler_fifo::fifo_name): Add a new argument. (fhandler_fifo::fixup_after_fork): New function. * fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Remove initialization of expunged elements. Initialize new handles to NULL. (fhandler_fifo::open_nonserver): Delete. (fnevent): New macro for creating a named event. (fnpipe): New macro for creating a unique named pipe name. (create_pipe): New macro for simplification of named pipe creation. (fhandler_fifo::fifo_name): Use new argument when creating a shared name. (fhandler_fifo::open): Rewrite. Use events to synchronize. (pure_debug_printf): New macro, active only when DEBUGGING. (fhandler_fifo::wait): Rewrite to wait for new fifo events which are supplied as a parameter. (fhandler_fifo::raw_read): Rewrite to use handle mechanism to detect client-side disconnect. (fhandler_fifo::raw_write): Delete. (fhandler_fifo::close): Remove accommodations for expunged fields. Close event handles. (fhandler_fifo::dup): Remove accommodations for expunged fields. Duplicate event handles. (fhandler_fifo::fixup_after_fork): New function. Perform fixups on event handles. (fhandler_fifo::set_close_on_exec): Remove accommodations for expunged fields. Set inheritance for new handle fields. * miscfuncs.cc (CreatePipeOverlapped): Accommodate changes in fhandler_pipe::create_selectable. * tty.cc (tty::not_allocated): Ditto. * pipe.cc (fhandler_pipe::create): Ditto. (fhandler_pipe::create_selectable): Accept an extra open_mode argument. Pass arguments by reference and allow opening one end of the pipe at a time. * sys/strace.h (debug_only_printf): Define new macro which calls debug_printf only when DEBUGGING is defined.
2011-10-30 05:50:36 +01:00
unsigned async_io : 1; /* async I/O */
* Use new unified status_flag accessor methods from classes fhandler_*, tty_min, mtinfo and fs_info thoroughout. * fhandler.h: Redefine all set_close_on_exec methods to take a bool argument. (enum conn_state): Rename from connect_state. (class fhandler_base): Rename some status flags to align with accessor method names. Drop encoded flag entirely. Unify status accessor methods. Const'ify all read accessor methods. (class fhandler_socket): Ditto. (class fhandler_dev_raw): Ditto. * fhandler_disk_file.cc (fhandler_base::fstat_fs): Use fs.fs_is_fat() instead of evaluating FATness of file system here. (fhandler_disk_file::opendir): Drop call to set_encoded(). (fhandler_disk_file::readdir): Use pc.isencoded() directly. * mtinfo.h (class mtinfo_drive): Const'ify all read accessor methods. * path.cc (fsinfo_cnt): Add. (fs_info::update): Accomodate class changes. Evaluate file system name specific flags right here. Add thread safety for reading and writing global fsinfo array. * path.h (enum path_types): Drop values for flags kept in fs already. (struct fs_info): Move status informatin into private struct type status_flags. Add accessor methods. Remove path and file system name string arrays in favor of status bits. (class path_conv): Use new fs_info status information where appropriate. (path_conf::fs_has_ea): Rename from fs_fast_ea. (path_conf::fs_has_acls): New method. (path_conf::root_dir): Remove. (path_conf::volname): Remove. * syscalls (statfs): Evaluate root dir locally. * tty.h (class tty_min): Unify status accessor methods. Const'ify all read accessor methods.
2004-04-10 15:45:10 +02:00
unsigned saw_shutdown_read : 1; /* Socket saw a SHUT_RD */
unsigned saw_shutdown_write : 1; /* Socket saw a SHUT_WR */
* fhandler.h (fhandler_pipe::create_selectable): Remove optional argument, take an options argument for CreateNamedPipe/CreateFile. Change handle arguments to expect pointers. (fhandler_fifo::fifo_state): Delete. (fhandler_fifo::dummy_client): Ditto. (fhandler_fifo::open_nonserver): Ditto. (fhandler_fifo::wait_state): Ditto. (fhandler_fifo::raw_write): Ditto. (fhandler_fifo::read_ready): New field. (fhandler_fifo::write_ready): Ditto. (fhandler_fifo::wait): Modify argument. (fhandler_fifo::fifo_name): Add a new argument. (fhandler_fifo::fixup_after_fork): New function. * fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Remove initialization of expunged elements. Initialize new handles to NULL. (fhandler_fifo::open_nonserver): Delete. (fnevent): New macro for creating a named event. (fnpipe): New macro for creating a unique named pipe name. (create_pipe): New macro for simplification of named pipe creation. (fhandler_fifo::fifo_name): Use new argument when creating a shared name. (fhandler_fifo::open): Rewrite. Use events to synchronize. (pure_debug_printf): New macro, active only when DEBUGGING. (fhandler_fifo::wait): Rewrite to wait for new fifo events which are supplied as a parameter. (fhandler_fifo::raw_read): Rewrite to use handle mechanism to detect client-side disconnect. (fhandler_fifo::raw_write): Delete. (fhandler_fifo::close): Remove accommodations for expunged fields. Close event handles. (fhandler_fifo::dup): Remove accommodations for expunged fields. Duplicate event handles. (fhandler_fifo::fixup_after_fork): New function. Perform fixups on event handles. (fhandler_fifo::set_close_on_exec): Remove accommodations for expunged fields. Set inheritance for new handle fields. * miscfuncs.cc (CreatePipeOverlapped): Accommodate changes in fhandler_pipe::create_selectable. * tty.cc (tty::not_allocated): Ditto. * pipe.cc (fhandler_pipe::create): Ditto. (fhandler_pipe::create_selectable): Accept an extra open_mode argument. Pass arguments by reference and allow opening one end of the pipe at a time. * sys/strace.h (debug_only_printf): Define new macro which calls debug_printf only when DEBUGGING is defined.
2011-10-30 05:50:36 +01:00
unsigned saw_reuseaddr : 1; /* Socket saw SO_REUSEADDR call */
unsigned listener : 1; /* listen called */
unsigned connect_state : 2;
public:
status_flags () :
* Use new unified status_flag accessor methods from classes fhandler_*, tty_min, mtinfo and fs_info thoroughout. * fhandler.h: Redefine all set_close_on_exec methods to take a bool argument. (enum conn_state): Rename from connect_state. (class fhandler_base): Rename some status flags to align with accessor method names. Drop encoded flag entirely. Unify status accessor methods. Const'ify all read accessor methods. (class fhandler_socket): Ditto. (class fhandler_dev_raw): Ditto. * fhandler_disk_file.cc (fhandler_base::fstat_fs): Use fs.fs_is_fat() instead of evaluating FATness of file system here. (fhandler_disk_file::opendir): Drop call to set_encoded(). (fhandler_disk_file::readdir): Use pc.isencoded() directly. * mtinfo.h (class mtinfo_drive): Const'ify all read accessor methods. * path.cc (fsinfo_cnt): Add. (fs_info::update): Accomodate class changes. Evaluate file system name specific flags right here. Add thread safety for reading and writing global fsinfo array. * path.h (enum path_types): Drop values for flags kept in fs already. (struct fs_info): Move status informatin into private struct type status_flags. Add accessor methods. Remove path and file system name string arrays in favor of status bits. (class path_conv): Use new fs_info status information where appropriate. (path_conf::fs_has_ea): Rename from fs_fast_ea. (path_conf::fs_has_acls): New method. (path_conf::root_dir): Remove. (path_conf::volname): Remove. * syscalls (statfs): Evaluate root dir locally. * tty.h (class tty_min): Unify status accessor methods. Const'ify all read accessor methods.
2004-04-10 15:45:10 +02:00
async_io (0), saw_shutdown_read (0), saw_shutdown_write (0),
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * include/cygwin/version.h: Bump DLL version to 1.7.0. 2006-07-25 Corinna Vinschen <corinna@vinschen.de> * select.h: Remove. * fhandler_socket.cc: Don't include select.h. * select.cc: Ditto. 2006-07-25 Corinna Vinschen <corinna@vinschen.de> * cygtls.h: Drop socket related includes. (struct _local_storage): Remove exitsock and exitsock_sin. Add select_sockevt. * cygtls.cc: Accomodate above change throughout. * fhandler.h (class fhandler_socket): Make wsock_evt public. * fhandler_socket.cc (fhandler_socket::fhandler_socket): Accomodate reordering members. (fhandler_socket::evaluate_events): Drop FD_CONNECT event as soon as it gets read once. Never remove FD_WRITE event here. (fhandler_socket::wait_for_events): Wait 50 ms instead of INFINITE for socket events. (fhandler_socket::accept): Fix conditional. Set wsock_events members of accepted socket to useful start values. (fhandler_socket::recv_internal): Always drop FD_READ/FD_OOB events from wsock_events after the call to WSARecvFrom. (fhandler_socket::send_internal): Drop FD_WRITE event from wsock_events if the call to WSASendTo fails with WSAEWOULDBLOCK. Fix return value condition. * select.cc (struct socketinf): Change to accomodate using socket event handling. (peek_socket): Use event handling for peeking socket. (thread_socket): Ditto. (start_thread_socket): Ditto. (socket_cleanup): Same here. * tlsoffsets.h: Regenerate. 2006-07-20 Corinna Vinschen <corinna@vinschen.de> * fhandler.h (class fhandler_socket): Rearrange slightly to keep event handling methods and members together. Drop owner status flag. Split wait method. Rename event handling methods for readability. * fhandler_socket.cc (struct wsa_event): Add owner field. (LOCK_EVENTS): New macro. (UNLOCK_EVENTS): Ditto. (fhandler_socket::init_events): rename from prepare. (fhandler_socket::evaluate_events): First half of former wait method. Do everything but wait. Allow specifiying whether or not events from event_mask should be erased from wsock_events->events. Simplify OOB handling. Allow sending SIGURG to any process (group). (fhandler_socket::wait_for_events): Second half of former wait method. Call evaluate_events and wait in a loop if socket is blocking. (fhandler_socket::release_events): Rename from release. (fhandler_socket::connect): Accomodate above name changes. (fhandler_socket::accept): Ditto. (fhandler_socket::recv_internal): Ditto. (fhandler_socket::send_internal): Ditto. (fhandler_socket::close): Ditto. (fhandler_socket::fcntl): Always set owner to given input value on F_SETOWN. Handle F_GETOWN. * net.cc (fdsock): Accomodate above name changes. 2006-07-20 Corinna Vinschen <corinna@vinschen.de> * fhandler_socket.cc (fhandler_socket::wait): Set Winsock errno to WSAEWOULDBLOCK instead of WSAEINPROGRESS. 2006-07-18 Brian Ford <Brian.Ford@FlightSafety.com> Corinna Vinschen <corinna@vinschen.de> * winsup.h (mmap_region_status): New enum. (mmap_is_attached_or_noreserve_page): Adjust prototype and rename as below. * mmap.cc (mmap_is_attached_or_noreserve_page): Rename mmap_is_attached_or_noreserve. Add region length parameter. Return enum above. * exceptions.cc (_cygtls::handle_exceptions): Accomodate above. * fhandler.cc (fhandler_base::raw_read): Call above for NOACCESS errors and retry on success to allow reads into untouched MAP_NORESERVE buffers. 2006-07-18 Corinna Vinschen <corinna@vinschen.de> * cygwin.din (posix_openpt): Export. * tty.cc (posix_openpt): New function. * include/cygwin/stdlib.h (posix_openpt): Declare. * include/cygwin/version.h: Bump API minor number. 2006-07-14 Corinna Vinschen <corinna@vinschen.de> * security.cc (get_token_group_sidlist): Always add the interactive group to the token. Add comment. Create logon_id group SID by copying it from incoming group list. (create_token): Add subauth_token parameter. Use information in subauth_token if present. Tweak SourceIdentifier if subauth_token is present for debugging purposes. * security.h (create_token): Add subauth_token parameter in declaration. * syscalls.cc (seteuid32): Call subauth first. Call create_token regardless. Use subauth token in call to create_token if subauth succeeded. 2006-07-13 Corinna Vinschen <corinna@vinschen.de> * include/netinet/in.h: Update copyright. 2006-07-13 Corinna Vinschen <corinna@vinschen.de> * fhandler_socket.cc (fhandler_socket::wait): Rework function so that WaitForMultipleObjects is really only called when necessary. 2006-07-12 Corinna Vinschen <corinna@vinschen.de> * include/netdb.h: Declare rcmd, rcmd_af, rexec, rresvport, rresvport_af, iruserok, iruserok_sa, ruserok. 2006-07-12 Corinna Vinschen <corinna@vinschen.de> * Makefile.in (DLL_OFILES): Drop iruserok.o. Add rcmd.o. * autoload.cc (rcmd): Drop definition. * cygwin.din: Export bindresvport, bindresvport_sa, iruserok_sa, rcmd_af, rresvport_af. * net.cc (cygwin_rcmd): Remove. (last_used_bindresvport): Rename from last_used_rrecvport. (cygwin_bindresvport_sa): New function implementing bindresvport_sa. (cygwin_bindresvport): New function implementing bindresvport. (cygwin_rresvport): Remove. * include/cygwin/version.h: Bump API minor number. * include/netinet/in.h: Declare bindresvport and bindresvport_sa. * libc/iruserok.c: Remove file. * libc/rcmd.cc: New file implementing rcmd, rcmd_af, rresvport, rresvport_af, iruserok_sa, iruserok and ruserok. 2006-07-12 Corinna Vinschen <corinna@vinschen.de> * fhandler_socket.cc (fhandler_socket::getsockname): Return valid result for unbound sockets. 2006-07-11 Corinna Vinschen <corinna@vinschen.de> * fhandler_socket.cc (fhandler_socket::fixup_after_fork): Handle wsock_mtx and wsock_evt on fork, thus handling close_on_exec correctly. (fhandler_socket::fixup_after_exec): Drop misguided attempt to handle close_on_exec here. (fhandler_socket::dup): Call fixup_after_fork with NULL parent. Add comment. (fhandler_socket::set_close_on_exec): Handle wsock_mtx and wsock_evt. 2006-07-10 Corinna Vinschen <corinna@vinschen.de> * fhandler.h (class fhandler_socket): Add wsock_mtx, wsock_evt and wsock_events members. Remove closed status flag, add listener status flag. Accomodate new implementation of socket event handling methods. Declare recv* and send* functions ssize_t as the POSIX equivalents. (fhandler_socket::recv_internal): Declare. (fhandler_socket::send_internal): Ditto. * fhandler_socket.cc (EVENT_MASK): Define mask of selected events. (fhandler_socket::fhandler_socket): Initialize new members. (fhandler_socket::af_local_setblocking): Don't actually set the socket to blocking mode. Keep sane event selection. (fhandler_socket::af_local_unsetblocking): Don't actually set the socket to previous blocking setting, just remember it. (struct wsa_event): New structure to keep event data per shared socket. (NUM_SOCKS): Define number of shared sockets concurrently handled by all active Cygwin processes. (wsa_events): New shared datastructure keeping all wsa_event records. (socket_serial_number): New shared variable to identify shared sockets. (wsa_slot_mtx): Global mutex to serialize wsa_events access. (search_wsa_event_slot): New static function to select a new wsa_event slot for a new socket. (fhandler_socket::prepare): Rewrite. Prepare event selection per new socket. (fhandler_socket::wait): Rewrite. Wait for socket events in thread safe and multiple process safe. (fhandler_socket::release): Rewrite. Close per-socket descriptor mutex handle and event handle. (fhandler_socket::dup): Duplicate wsock_mtx and wsock_evt. Fix copy-paste error in debug output. (fhandler_socket::connect): Accomodate new event handling. (fhandler_socket::listen): Set listener flag on successful listen. (fhandler_socket::accept): Accomodate new event handling. (fhandler_socket::recv_internal): New inline method centralizing common recv code. (fhandler_socket::recvfrom): Call recv_internal now. (fhandler_socket::recvmsg): Ditto. Streamline copying from iovec to WSABUF. (fhandler_socket::send_internal): New inline method centralizing common send code. (fhandler_socket::sendto): Call send_internal now. (fhandler_socket::sendmsg): Ditto. Streamline copying from iovec to WSABUF. (fhandler_socket::close): Call release now. (fhandler_socket::ioctl): Never actually switch to blocking mode. Just keep track of the setting. * net.cc (fdsock): Call prepare now. (cygwin_connect): Revert again to event driven technique. (cygwin_accept): Ditto. * poll.cc (poll): Don't call recvfrom on a listening socket. Remove special case for failing recvfrom. * include/sys/socket.h: Declare recv* and send* functions ssize_t as requested by POSIX. 2006-07-07 Corinna Vinschen <corinna@vinschen.de> * net.cc (cygwin_inet_ntop): Fix data type of forth parameter. 2006-07-06 Corinna Vinschen <corinna@vinschen.de> * include/cygwin/in6.h (struct in6_addr): Fix typo. 2006-07-06 Corinna Vinschen <corinna@vinschen.de> * cygwin.din: Export in6addr_any, in6addr_loopback, freeaddrinfo, gai_strerror, getaddrinfo, getnameinfo. * fhandler_socket.cc: Include cygwin/in6.h. (get_inet_addr): Accomodate AF_INET6 usage. (fhandler_socket::connect): Ditto. (fhandler_socket::listen): Ditto. (fhandler_socket::sendto): Ditto. * net.cc: Include cygwin/in6.h. (in6addr_any): Define. (in6addr_loopback): Define. (cygwin_socket): Accomodate AF_INET6 usage. (socketpair): Bind socketpairs only to loopback for security. (inet_pton4): New static function. (inet_pton6): Ditto. (cygwin_inet_pton): New AF_INET6 aware inet_pton implementation. (inet_ntop4): New static function. (inet_ntop6): Ditto. (cygwin_inet_ntop): New AF_INET6 aware inet_ntop implementation. (ga_aistruct): New static function. (ga_clone): Ditto. (ga_echeck): Ditto. (ga_nsearch): Ditto. (ga_port): Ditto. (ga_serv): Ditto. (ga_unix): Ditto. (gn_ipv46): Ditto. (ipv4_freeaddrinfo): Ditto. (ipv4_getaddrinfo): Ditto. (ipv4_getnameinfo): Ditto. (gai_errmap_t): New structure holding error code - error string mapping. (cygwin_gai_strerror): New function implementing gai_strerror. (w32_to_gai_err): New static function. (get_ipv6_funcs): Ditto. (load_ipv6_funcs): Ditto. (cygwin_freeaddrinfo): New function implementing freeaddrinfo. (cygwin_getaddrinfo): New function implementing getaddrinfo. (cygwin_getnameinfo): New function implementing getnameinfo. * include/netdb.h: Include stdint.h and cygwin/socket.h. Define data types and macros used by getaddrinfo and friends. Declare freeaddrinfo, gai_strerror, getaddrinfo and getnameinfo. * include/cygwin/in.h: Add IPv6 related IPPROTOs. Remove definition of struct sockaddr_in6. Include cygwin/in6.h instead. * include/cygwin/in6.h: New header file defining IPv6 releated data types and macros. * include/cygwin/socket.h: Enable AF_INET6 and PF_INET6. Add IPv6 related socket options. * include/cygwin/version.h: Bump API minor number. 2006-07-06 Corinna Vinschen <corinna@vinschen.de> * autoload.cc (DsGetDcNameA): Define. (NetGetAnyDCName): Define. * security.cc: Include dsgetdc.h. (DsGetDcNameA): Declare. (DS_FORCE_REDISCOVERY): Define. (get_logon_server): Add bool parameter to control rediscovery of DC. Use DsGetDcNameA function if supported, NetGetDCName/NetGetAnyDCName otherwise. (get_server_groups): Rediscover DC if get_user_groups fails and try again. (get_reg_security): Use correct error code macro when testing RegGetKeySecurity return value. * security.h (get_logon_server): Remove default vaue from wserver parameter. Add rediscovery parameter. * uinfo.cc (cygheap_user::env_logsrv): Accomodate rediscovery parameter in call to get_logon_server.
2006-07-25 21:23:23 +02:00
listener (0), connect_state (unconnected)
{}
} status;
* dtable.cc (dtable::release): Check for socket. Change cnt_need_fixup_before accordingly. (dtable::dup2): Ditto. (dtable::fixup_before_fork): New method. (dtable::fixup_before_exec): Ditto. * dtable.h (class dtable): Add member `cnt_need_fixup_before'. Add definition for methods `dec_need_fixup_before', `inc_need_fixup_before', `need_fixup_before', `fixup_before_exec' and `fixup_before_fork'. * fhandler.h (class fhandler_base): Slight rearrangements. Add definitions for methods `fixup_before_fork_exec'. (class fhandler_socket): Eliminate superfluous constructor. Add member `prot_info_ptr'. Add destructor. Add definitions for methods `dup', `fixup_before_fork_exec', `fixup_after_fork' and `fixup_after_exec'. * fork.cc (fork_parent): Care for file types which need a fixup before fork. Start child in suspended state then. * net.cc: New global variable `ws2_32_handle' and `wsadata'. (fdsock): Check for Winsock version. Call `set_socket_inheritance' only if Winsock version < 2.0. Care for `need_fixup' count in fdtab. (cygwin_socket): Eliminate call to `set_socket_inheritance'. (cygwin_accept): Ditto. (cygwin_rcmd): Ditto. (cygwin_rresvport): Ditto. (cygwin_rexec): Ditto. (socketpair): Ditto. (fhandler_socket::fhandler_socket): Set `need_fork_fixup'. Allocate space for the WSAPROTOCOL_INFOA struct used in fixup. (fhandler_socket::~fhandler_socket): New destructor. (fhandler_socket::fixup_before_fork_exec): New method. (fhandler_socket::fixup_after_fork): Ditto. (fhandler_socket::dup): Ditto. (wsock_init): New static function. (LoadDLLinitfunc (wsock32)): Rearranged. (LoadDLLinitfunc (ws2_32)): New function. (dummy_autoload): Add autoload statemants for `WSADuplicateSocketA' and `WSASocketA'. * spawn.cc (spawn_guts): Care for file types which need a fixup before exec. Start child in suspended state then.
2000-10-26 12:13:41 +02:00
* dtable.cc (dtable::build_fhandler): Issue internal error on unknown device. * fhandler.cc (fhandler_base::close): Show both name and handle in debugging output. * fhandler.h (fhandler_base::get_guard): New virtual method. (fhandler_pipe::get_guard): New method. (fhandler_socket::ready_for_read): Delete declaration. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (struct select_record::peek): Declare new method. * select.cc (MAKEready): Delete. (peek_pipe): Use get_guard method to retrieve potential guard mutex handle. (fhandler_base::ready_for_read): Rewrite as generic ready-for-read handler. Should only be called for "slow" devices. (fhandler_socket::ready_for_read): Delete definition. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (fhandler_pipe::select_read): Fill in new peek record in select_record structure. (fhandler_console::select_read): Ditto. (fhandler_tty_common::select_read): Ditto. (fhandler_serial::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_tty_slave::ready_for_read): Check for tty not open. Set errnos appropriately. * syscalls.cc (_read): Allow ready_for_read to set errno. * pinfo.cc (pinfo::init): Return spawn/NO_WAIT process as valid if it is initializing. * sigproc.cc (getsem): Adjust wait for process to initialize downward to avoid huge waits.
2001-11-01 22:15:53 +01:00
public:
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
fhandler_socket ();
* dtable.cc (dtable::release): Check for socket. Change cnt_need_fixup_before accordingly. (dtable::dup2): Ditto. (dtable::fixup_before_fork): New method. (dtable::fixup_before_exec): Ditto. * dtable.h (class dtable): Add member `cnt_need_fixup_before'. Add definition for methods `dec_need_fixup_before', `inc_need_fixup_before', `need_fixup_before', `fixup_before_exec' and `fixup_before_fork'. * fhandler.h (class fhandler_base): Slight rearrangements. Add definitions for methods `fixup_before_fork_exec'. (class fhandler_socket): Eliminate superfluous constructor. Add member `prot_info_ptr'. Add destructor. Add definitions for methods `dup', `fixup_before_fork_exec', `fixup_after_fork' and `fixup_after_exec'. * fork.cc (fork_parent): Care for file types which need a fixup before fork. Start child in suspended state then. * net.cc: New global variable `ws2_32_handle' and `wsadata'. (fdsock): Check for Winsock version. Call `set_socket_inheritance' only if Winsock version < 2.0. Care for `need_fixup' count in fdtab. (cygwin_socket): Eliminate call to `set_socket_inheritance'. (cygwin_accept): Ditto. (cygwin_rcmd): Ditto. (cygwin_rresvport): Ditto. (cygwin_rexec): Ditto. (socketpair): Ditto. (fhandler_socket::fhandler_socket): Set `need_fork_fixup'. Allocate space for the WSAPROTOCOL_INFOA struct used in fixup. (fhandler_socket::~fhandler_socket): New destructor. (fhandler_socket::fixup_before_fork_exec): New method. (fhandler_socket::fixup_after_fork): Ditto. (fhandler_socket::dup): Ditto. (wsock_init): New static function. (LoadDLLinitfunc (wsock32)): Rearranged. (LoadDLLinitfunc (ws2_32)): New function. (dummy_autoload): Add autoload statemants for `WSADuplicateSocketA' and `WSASocketA'. * spawn.cc (spawn_guts): Care for file types which need a fixup before exec. Start child in suspended state then.
2000-10-26 12:13:41 +02:00
~fhandler_socket ();
int get_socket () { return (int) get_handle(); }
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
fhandler_socket *is_socket () { return this; }
IMPLEMENT_STATUS_FLAG (bool, async_io)
IMPLEMENT_STATUS_FLAG (bool, saw_shutdown_read)
IMPLEMENT_STATUS_FLAG (bool, saw_shutdown_write)
IMPLEMENT_STATUS_FLAG (bool, saw_reuseaddr)
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * include/cygwin/version.h: Bump DLL version to 1.7.0. 2006-07-25 Corinna Vinschen <corinna@vinschen.de> * select.h: Remove. * fhandler_socket.cc: Don't include select.h. * select.cc: Ditto. 2006-07-25 Corinna Vinschen <corinna@vinschen.de> * cygtls.h: Drop socket related includes. (struct _local_storage): Remove exitsock and exitsock_sin. Add select_sockevt. * cygtls.cc: Accomodate above change throughout. * fhandler.h (class fhandler_socket): Make wsock_evt public. * fhandler_socket.cc (fhandler_socket::fhandler_socket): Accomodate reordering members. (fhandler_socket::evaluate_events): Drop FD_CONNECT event as soon as it gets read once. Never remove FD_WRITE event here. (fhandler_socket::wait_for_events): Wait 50 ms instead of INFINITE for socket events. (fhandler_socket::accept): Fix conditional. Set wsock_events members of accepted socket to useful start values. (fhandler_socket::recv_internal): Always drop FD_READ/FD_OOB events from wsock_events after the call to WSARecvFrom. (fhandler_socket::send_internal): Drop FD_WRITE event from wsock_events if the call to WSASendTo fails with WSAEWOULDBLOCK. Fix return value condition. * select.cc (struct socketinf): Change to accomodate using socket event handling. (peek_socket): Use event handling for peeking socket. (thread_socket): Ditto. (start_thread_socket): Ditto. (socket_cleanup): Same here. * tlsoffsets.h: Regenerate. 2006-07-20 Corinna Vinschen <corinna@vinschen.de> * fhandler.h (class fhandler_socket): Rearrange slightly to keep event handling methods and members together. Drop owner status flag. Split wait method. Rename event handling methods for readability. * fhandler_socket.cc (struct wsa_event): Add owner field. (LOCK_EVENTS): New macro. (UNLOCK_EVENTS): Ditto. (fhandler_socket::init_events): rename from prepare. (fhandler_socket::evaluate_events): First half of former wait method. Do everything but wait. Allow specifiying whether or not events from event_mask should be erased from wsock_events->events. Simplify OOB handling. Allow sending SIGURG to any process (group). (fhandler_socket::wait_for_events): Second half of former wait method. Call evaluate_events and wait in a loop if socket is blocking. (fhandler_socket::release_events): Rename from release. (fhandler_socket::connect): Accomodate above name changes. (fhandler_socket::accept): Ditto. (fhandler_socket::recv_internal): Ditto. (fhandler_socket::send_internal): Ditto. (fhandler_socket::close): Ditto. (fhandler_socket::fcntl): Always set owner to given input value on F_SETOWN. Handle F_GETOWN. * net.cc (fdsock): Accomodate above name changes. 2006-07-20 Corinna Vinschen <corinna@vinschen.de> * fhandler_socket.cc (fhandler_socket::wait): Set Winsock errno to WSAEWOULDBLOCK instead of WSAEINPROGRESS. 2006-07-18 Brian Ford <Brian.Ford@FlightSafety.com> Corinna Vinschen <corinna@vinschen.de> * winsup.h (mmap_region_status): New enum. (mmap_is_attached_or_noreserve_page): Adjust prototype and rename as below. * mmap.cc (mmap_is_attached_or_noreserve_page): Rename mmap_is_attached_or_noreserve. Add region length parameter. Return enum above. * exceptions.cc (_cygtls::handle_exceptions): Accomodate above. * fhandler.cc (fhandler_base::raw_read): Call above for NOACCESS errors and retry on success to allow reads into untouched MAP_NORESERVE buffers. 2006-07-18 Corinna Vinschen <corinna@vinschen.de> * cygwin.din (posix_openpt): Export. * tty.cc (posix_openpt): New function. * include/cygwin/stdlib.h (posix_openpt): Declare. * include/cygwin/version.h: Bump API minor number. 2006-07-14 Corinna Vinschen <corinna@vinschen.de> * security.cc (get_token_group_sidlist): Always add the interactive group to the token. Add comment. Create logon_id group SID by copying it from incoming group list. (create_token): Add subauth_token parameter. Use information in subauth_token if present. Tweak SourceIdentifier if subauth_token is present for debugging purposes. * security.h (create_token): Add subauth_token parameter in declaration. * syscalls.cc (seteuid32): Call subauth first. Call create_token regardless. Use subauth token in call to create_token if subauth succeeded. 2006-07-13 Corinna Vinschen <corinna@vinschen.de> * include/netinet/in.h: Update copyright. 2006-07-13 Corinna Vinschen <corinna@vinschen.de> * fhandler_socket.cc (fhandler_socket::wait): Rework function so that WaitForMultipleObjects is really only called when necessary. 2006-07-12 Corinna Vinschen <corinna@vinschen.de> * include/netdb.h: Declare rcmd, rcmd_af, rexec, rresvport, rresvport_af, iruserok, iruserok_sa, ruserok. 2006-07-12 Corinna Vinschen <corinna@vinschen.de> * Makefile.in (DLL_OFILES): Drop iruserok.o. Add rcmd.o. * autoload.cc (rcmd): Drop definition. * cygwin.din: Export bindresvport, bindresvport_sa, iruserok_sa, rcmd_af, rresvport_af. * net.cc (cygwin_rcmd): Remove. (last_used_bindresvport): Rename from last_used_rrecvport. (cygwin_bindresvport_sa): New function implementing bindresvport_sa. (cygwin_bindresvport): New function implementing bindresvport. (cygwin_rresvport): Remove. * include/cygwin/version.h: Bump API minor number. * include/netinet/in.h: Declare bindresvport and bindresvport_sa. * libc/iruserok.c: Remove file. * libc/rcmd.cc: New file implementing rcmd, rcmd_af, rresvport, rresvport_af, iruserok_sa, iruserok and ruserok. 2006-07-12 Corinna Vinschen <corinna@vinschen.de> * fhandler_socket.cc (fhandler_socket::getsockname): Return valid result for unbound sockets. 2006-07-11 Corinna Vinschen <corinna@vinschen.de> * fhandler_socket.cc (fhandler_socket::fixup_after_fork): Handle wsock_mtx and wsock_evt on fork, thus handling close_on_exec correctly. (fhandler_socket::fixup_after_exec): Drop misguided attempt to handle close_on_exec here. (fhandler_socket::dup): Call fixup_after_fork with NULL parent. Add comment. (fhandler_socket::set_close_on_exec): Handle wsock_mtx and wsock_evt. 2006-07-10 Corinna Vinschen <corinna@vinschen.de> * fhandler.h (class fhandler_socket): Add wsock_mtx, wsock_evt and wsock_events members. Remove closed status flag, add listener status flag. Accomodate new implementation of socket event handling methods. Declare recv* and send* functions ssize_t as the POSIX equivalents. (fhandler_socket::recv_internal): Declare. (fhandler_socket::send_internal): Ditto. * fhandler_socket.cc (EVENT_MASK): Define mask of selected events. (fhandler_socket::fhandler_socket): Initialize new members. (fhandler_socket::af_local_setblocking): Don't actually set the socket to blocking mode. Keep sane event selection. (fhandler_socket::af_local_unsetblocking): Don't actually set the socket to previous blocking setting, just remember it. (struct wsa_event): New structure to keep event data per shared socket. (NUM_SOCKS): Define number of shared sockets concurrently handled by all active Cygwin processes. (wsa_events): New shared datastructure keeping all wsa_event records. (socket_serial_number): New shared variable to identify shared sockets. (wsa_slot_mtx): Global mutex to serialize wsa_events access. (search_wsa_event_slot): New static function to select a new wsa_event slot for a new socket. (fhandler_socket::prepare): Rewrite. Prepare event selection per new socket. (fhandler_socket::wait): Rewrite. Wait for socket events in thread safe and multiple process safe. (fhandler_socket::release): Rewrite. Close per-socket descriptor mutex handle and event handle. (fhandler_socket::dup): Duplicate wsock_mtx and wsock_evt. Fix copy-paste error in debug output. (fhandler_socket::connect): Accomodate new event handling. (fhandler_socket::listen): Set listener flag on successful listen. (fhandler_socket::accept): Accomodate new event handling. (fhandler_socket::recv_internal): New inline method centralizing common recv code. (fhandler_socket::recvfrom): Call recv_internal now. (fhandler_socket::recvmsg): Ditto. Streamline copying from iovec to WSABUF. (fhandler_socket::send_internal): New inline method centralizing common send code. (fhandler_socket::sendto): Call send_internal now. (fhandler_socket::sendmsg): Ditto. Streamline copying from iovec to WSABUF. (fhandler_socket::close): Call release now. (fhandler_socket::ioctl): Never actually switch to blocking mode. Just keep track of the setting. * net.cc (fdsock): Call prepare now. (cygwin_connect): Revert again to event driven technique. (cygwin_accept): Ditto. * poll.cc (poll): Don't call recvfrom on a listening socket. Remove special case for failing recvfrom. * include/sys/socket.h: Declare recv* and send* functions ssize_t as requested by POSIX. 2006-07-07 Corinna Vinschen <corinna@vinschen.de> * net.cc (cygwin_inet_ntop): Fix data type of forth parameter. 2006-07-06 Corinna Vinschen <corinna@vinschen.de> * include/cygwin/in6.h (struct in6_addr): Fix typo. 2006-07-06 Corinna Vinschen <corinna@vinschen.de> * cygwin.din: Export in6addr_any, in6addr_loopback, freeaddrinfo, gai_strerror, getaddrinfo, getnameinfo. * fhandler_socket.cc: Include cygwin/in6.h. (get_inet_addr): Accomodate AF_INET6 usage. (fhandler_socket::connect): Ditto. (fhandler_socket::listen): Ditto. (fhandler_socket::sendto): Ditto. * net.cc: Include cygwin/in6.h. (in6addr_any): Define. (in6addr_loopback): Define. (cygwin_socket): Accomodate AF_INET6 usage. (socketpair): Bind socketpairs only to loopback for security. (inet_pton4): New static function. (inet_pton6): Ditto. (cygwin_inet_pton): New AF_INET6 aware inet_pton implementation. (inet_ntop4): New static function. (inet_ntop6): Ditto. (cygwin_inet_ntop): New AF_INET6 aware inet_ntop implementation. (ga_aistruct): New static function. (ga_clone): Ditto. (ga_echeck): Ditto. (ga_nsearch): Ditto. (ga_port): Ditto. (ga_serv): Ditto. (ga_unix): Ditto. (gn_ipv46): Ditto. (ipv4_freeaddrinfo): Ditto. (ipv4_getaddrinfo): Ditto. (ipv4_getnameinfo): Ditto. (gai_errmap_t): New structure holding error code - error string mapping. (cygwin_gai_strerror): New function implementing gai_strerror. (w32_to_gai_err): New static function. (get_ipv6_funcs): Ditto. (load_ipv6_funcs): Ditto. (cygwin_freeaddrinfo): New function implementing freeaddrinfo. (cygwin_getaddrinfo): New function implementing getaddrinfo. (cygwin_getnameinfo): New function implementing getnameinfo. * include/netdb.h: Include stdint.h and cygwin/socket.h. Define data types and macros used by getaddrinfo and friends. Declare freeaddrinfo, gai_strerror, getaddrinfo and getnameinfo. * include/cygwin/in.h: Add IPv6 related IPPROTOs. Remove definition of struct sockaddr_in6. Include cygwin/in6.h instead. * include/cygwin/in6.h: New header file defining IPv6 releated data types and macros. * include/cygwin/socket.h: Enable AF_INET6 and PF_INET6. Add IPv6 related socket options. * include/cygwin/version.h: Bump API minor number. 2006-07-06 Corinna Vinschen <corinna@vinschen.de> * autoload.cc (DsGetDcNameA): Define. (NetGetAnyDCName): Define. * security.cc: Include dsgetdc.h. (DsGetDcNameA): Declare. (DS_FORCE_REDISCOVERY): Define. (get_logon_server): Add bool parameter to control rediscovery of DC. Use DsGetDcNameA function if supported, NetGetDCName/NetGetAnyDCName otherwise. (get_server_groups): Rediscover DC if get_user_groups fails and try again. (get_reg_security): Use correct error code macro when testing RegGetKeySecurity return value. * security.h (get_logon_server): Remove default vaue from wserver parameter. Add rediscovery parameter. * uinfo.cc (cygheap_user::env_logsrv): Accomodate rediscovery parameter in call to get_logon_server.
2006-07-25 21:23:23 +02:00
IMPLEMENT_STATUS_FLAG (bool, listener)
IMPLEMENT_STATUS_FLAG (conn_state, connect_state)
int bind (const struct sockaddr *name, int namelen);
int connect (const struct sockaddr *name, int namelen);
int listen (int backlog);
int accept4 (struct sockaddr *peer, int *len, int flags);
int getsockname (struct sockaddr *name, int *namelen);
int getpeername (struct sockaddr *name, int *namelen);
int getpeereid (pid_t *pid, __uid32_t *euid, __gid32_t *egid);
int open (int flags, mode_t mode = 0);
void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3)));
* sigproc.h (wait_for_sigthread): Eliminate parameter. * sigproc.cc (wait_for_sigthread): Ditto. Don't synchronize with wait_sig after receiving an event that it is ready to go. (init_sig_pipe): New function. (wait_sig): Call init_sig_pipe to create pipes for communicating signals to this process. Don't send sigCONT signal when initializing. * fork.cc (frok::child): Accommodate wait_for_sigpipe parameter change. * fhandler.h (fhandler_*::write): Make ssize_t/__stdcall. (fhandler_*::write_overlapped): Ditto. (fhandler_*::raw_write): Ditto. (fhandler_*::readv): Ditto. (fhandler_*::writev): Ditto. (fhandler_*::raw_read): Make __stdcall. * fhandler: Accommodate changes to read/write functions throughout. * fhandler_clipboard.cc: Ditto. * fhandler_console.cc: Ditto. * fhandler_dsp.cc: Ditto. * fhandler_fifo.cc: Ditto. * fhandler_mailslot.cc: Ditto. * fhandler_mem.cc: Ditto. * fhandler_mem.cc: Ditto. * fhandler_random.cc: Ditto. * fhandler_tape.cc: Ditto. * fhandler_tty.cc: Ditto. * fhandler_virtual.cc: Ditto. * fhandler_windows.cc: Ditto. * fhandler_zero.cc: Ditto. * syscalls.cc (readv): Use ssize_t as temp variable. * fhandler.cc (fhandler_base::read): Coerce returned len to signed or it will never be treated as < 0. (fhandler_base::wait_overlapped): Minimize calls to GetLastError. Remove duplicate debugging test. Fix error return. * fhandler.h (fhandler_fifo::fifo_name): Declare new function. (fhandler_fifo::close): Ditto. (fhandler_fifo::dup): Ditto. (fhandler_fifo::close_on_exec): Ditto. * fhandler.cc (fhandler_fifo::fifo_name): Define new function. (FIFO_BUF_SIZE): New define. (cnp): Ditto. (fhandler_fifo::open): Rework. Use cnp to open named pipe. Always open write side as a client. Open dummy client when writing and can't connect. (wait): Rework. Implement fifo_wait_for_next_client. Handle signals during connect better. Add new fifo_wait_for_server code which polls (sigh) waiting for server. (fhandler_fifo::raw_read): Handle transition states when one client closes and another is available. (fhandler_fifo::close): Define. (fhandler_fifo::dup): Ditto. (fhandler_fifo::close_on_exec): Ditto.
2009-07-24 22:54:33 +02:00
ssize_t __stdcall readv (const struct iovec *, int iovcnt, ssize_t tot = -1);
inline ssize_t recv_internal (struct _WSAMSG *wsamsg, bool use_recvmsg) __attribute__ ((regparm (3)));
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * include/cygwin/version.h: Bump DLL version to 1.7.0. 2006-07-25 Corinna Vinschen <corinna@vinschen.de> * select.h: Remove. * fhandler_socket.cc: Don't include select.h. * select.cc: Ditto. 2006-07-25 Corinna Vinschen <corinna@vinschen.de> * cygtls.h: Drop socket related includes. (struct _local_storage): Remove exitsock and exitsock_sin. Add select_sockevt. * cygtls.cc: Accomodate above change throughout. * fhandler.h (class fhandler_socket): Make wsock_evt public. * fhandler_socket.cc (fhandler_socket::fhandler_socket): Accomodate reordering members. (fhandler_socket::evaluate_events): Drop FD_CONNECT event as soon as it gets read once. Never remove FD_WRITE event here. (fhandler_socket::wait_for_events): Wait 50 ms instead of INFINITE for socket events. (fhandler_socket::accept): Fix conditional. Set wsock_events members of accepted socket to useful start values. (fhandler_socket::recv_internal): Always drop FD_READ/FD_OOB events from wsock_events after the call to WSARecvFrom. (fhandler_socket::send_internal): Drop FD_WRITE event from wsock_events if the call to WSASendTo fails with WSAEWOULDBLOCK. Fix return value condition. * select.cc (struct socketinf): Change to accomodate using socket event handling. (peek_socket): Use event handling for peeking socket. (thread_socket): Ditto. (start_thread_socket): Ditto. (socket_cleanup): Same here. * tlsoffsets.h: Regenerate. 2006-07-20 Corinna Vinschen <corinna@vinschen.de> * fhandler.h (class fhandler_socket): Rearrange slightly to keep event handling methods and members together. Drop owner status flag. Split wait method. Rename event handling methods for readability. * fhandler_socket.cc (struct wsa_event): Add owner field. (LOCK_EVENTS): New macro. (UNLOCK_EVENTS): Ditto. (fhandler_socket::init_events): rename from prepare. (fhandler_socket::evaluate_events): First half of former wait method. Do everything but wait. Allow specifiying whether or not events from event_mask should be erased from wsock_events->events. Simplify OOB handling. Allow sending SIGURG to any process (group). (fhandler_socket::wait_for_events): Second half of former wait method. Call evaluate_events and wait in a loop if socket is blocking. (fhandler_socket::release_events): Rename from release. (fhandler_socket::connect): Accomodate above name changes. (fhandler_socket::accept): Ditto. (fhandler_socket::recv_internal): Ditto. (fhandler_socket::send_internal): Ditto. (fhandler_socket::close): Ditto. (fhandler_socket::fcntl): Always set owner to given input value on F_SETOWN. Handle F_GETOWN. * net.cc (fdsock): Accomodate above name changes. 2006-07-20 Corinna Vinschen <corinna@vinschen.de> * fhandler_socket.cc (fhandler_socket::wait): Set Winsock errno to WSAEWOULDBLOCK instead of WSAEINPROGRESS. 2006-07-18 Brian Ford <Brian.Ford@FlightSafety.com> Corinna Vinschen <corinna@vinschen.de> * winsup.h (mmap_region_status): New enum. (mmap_is_attached_or_noreserve_page): Adjust prototype and rename as below. * mmap.cc (mmap_is_attached_or_noreserve_page): Rename mmap_is_attached_or_noreserve. Add region length parameter. Return enum above. * exceptions.cc (_cygtls::handle_exceptions): Accomodate above. * fhandler.cc (fhandler_base::raw_read): Call above for NOACCESS errors and retry on success to allow reads into untouched MAP_NORESERVE buffers. 2006-07-18 Corinna Vinschen <corinna@vinschen.de> * cygwin.din (posix_openpt): Export. * tty.cc (posix_openpt): New function. * include/cygwin/stdlib.h (posix_openpt): Declare. * include/cygwin/version.h: Bump API minor number. 2006-07-14 Corinna Vinschen <corinna@vinschen.de> * security.cc (get_token_group_sidlist): Always add the interactive group to the token. Add comment. Create logon_id group SID by copying it from incoming group list. (create_token): Add subauth_token parameter. Use information in subauth_token if present. Tweak SourceIdentifier if subauth_token is present for debugging purposes. * security.h (create_token): Add subauth_token parameter in declaration. * syscalls.cc (seteuid32): Call subauth first. Call create_token regardless. Use subauth token in call to create_token if subauth succeeded. 2006-07-13 Corinna Vinschen <corinna@vinschen.de> * include/netinet/in.h: Update copyright. 2006-07-13 Corinna Vinschen <corinna@vinschen.de> * fhandler_socket.cc (fhandler_socket::wait): Rework function so that WaitForMultipleObjects is really only called when necessary. 2006-07-12 Corinna Vinschen <corinna@vinschen.de> * include/netdb.h: Declare rcmd, rcmd_af, rexec, rresvport, rresvport_af, iruserok, iruserok_sa, ruserok. 2006-07-12 Corinna Vinschen <corinna@vinschen.de> * Makefile.in (DLL_OFILES): Drop iruserok.o. Add rcmd.o. * autoload.cc (rcmd): Drop definition. * cygwin.din: Export bindresvport, bindresvport_sa, iruserok_sa, rcmd_af, rresvport_af. * net.cc (cygwin_rcmd): Remove. (last_used_bindresvport): Rename from last_used_rrecvport. (cygwin_bindresvport_sa): New function implementing bindresvport_sa. (cygwin_bindresvport): New function implementing bindresvport. (cygwin_rresvport): Remove. * include/cygwin/version.h: Bump API minor number. * include/netinet/in.h: Declare bindresvport and bindresvport_sa. * libc/iruserok.c: Remove file. * libc/rcmd.cc: New file implementing rcmd, rcmd_af, rresvport, rresvport_af, iruserok_sa, iruserok and ruserok. 2006-07-12 Corinna Vinschen <corinna@vinschen.de> * fhandler_socket.cc (fhandler_socket::getsockname): Return valid result for unbound sockets. 2006-07-11 Corinna Vinschen <corinna@vinschen.de> * fhandler_socket.cc (fhandler_socket::fixup_after_fork): Handle wsock_mtx and wsock_evt on fork, thus handling close_on_exec correctly. (fhandler_socket::fixup_after_exec): Drop misguided attempt to handle close_on_exec here. (fhandler_socket::dup): Call fixup_after_fork with NULL parent. Add comment. (fhandler_socket::set_close_on_exec): Handle wsock_mtx and wsock_evt. 2006-07-10 Corinna Vinschen <corinna@vinschen.de> * fhandler.h (class fhandler_socket): Add wsock_mtx, wsock_evt and wsock_events members. Remove closed status flag, add listener status flag. Accomodate new implementation of socket event handling methods. Declare recv* and send* functions ssize_t as the POSIX equivalents. (fhandler_socket::recv_internal): Declare. (fhandler_socket::send_internal): Ditto. * fhandler_socket.cc (EVENT_MASK): Define mask of selected events. (fhandler_socket::fhandler_socket): Initialize new members. (fhandler_socket::af_local_setblocking): Don't actually set the socket to blocking mode. Keep sane event selection. (fhandler_socket::af_local_unsetblocking): Don't actually set the socket to previous blocking setting, just remember it. (struct wsa_event): New structure to keep event data per shared socket. (NUM_SOCKS): Define number of shared sockets concurrently handled by all active Cygwin processes. (wsa_events): New shared datastructure keeping all wsa_event records. (socket_serial_number): New shared variable to identify shared sockets. (wsa_slot_mtx): Global mutex to serialize wsa_events access. (search_wsa_event_slot): New static function to select a new wsa_event slot for a new socket. (fhandler_socket::prepare): Rewrite. Prepare event selection per new socket. (fhandler_socket::wait): Rewrite. Wait for socket events in thread safe and multiple process safe. (fhandler_socket::release): Rewrite. Close per-socket descriptor mutex handle and event handle. (fhandler_socket::dup): Duplicate wsock_mtx and wsock_evt. Fix copy-paste error in debug output. (fhandler_socket::connect): Accomodate new event handling. (fhandler_socket::listen): Set listener flag on successful listen. (fhandler_socket::accept): Accomodate new event handling. (fhandler_socket::recv_internal): New inline method centralizing common recv code. (fhandler_socket::recvfrom): Call recv_internal now. (fhandler_socket::recvmsg): Ditto. Streamline copying from iovec to WSABUF. (fhandler_socket::send_internal): New inline method centralizing common send code. (fhandler_socket::sendto): Call send_internal now. (fhandler_socket::sendmsg): Ditto. Streamline copying from iovec to WSABUF. (fhandler_socket::close): Call release now. (fhandler_socket::ioctl): Never actually switch to blocking mode. Just keep track of the setting. * net.cc (fdsock): Call prepare now. (cygwin_connect): Revert again to event driven technique. (cygwin_accept): Ditto. * poll.cc (poll): Don't call recvfrom on a listening socket. Remove special case for failing recvfrom. * include/sys/socket.h: Declare recv* and send* functions ssize_t as requested by POSIX. 2006-07-07 Corinna Vinschen <corinna@vinschen.de> * net.cc (cygwin_inet_ntop): Fix data type of forth parameter. 2006-07-06 Corinna Vinschen <corinna@vinschen.de> * include/cygwin/in6.h (struct in6_addr): Fix typo. 2006-07-06 Corinna Vinschen <corinna@vinschen.de> * cygwin.din: Export in6addr_any, in6addr_loopback, freeaddrinfo, gai_strerror, getaddrinfo, getnameinfo. * fhandler_socket.cc: Include cygwin/in6.h. (get_inet_addr): Accomodate AF_INET6 usage. (fhandler_socket::connect): Ditto. (fhandler_socket::listen): Ditto. (fhandler_socket::sendto): Ditto. * net.cc: Include cygwin/in6.h. (in6addr_any): Define. (in6addr_loopback): Define. (cygwin_socket): Accomodate AF_INET6 usage. (socketpair): Bind socketpairs only to loopback for security. (inet_pton4): New static function. (inet_pton6): Ditto. (cygwin_inet_pton): New AF_INET6 aware inet_pton implementation. (inet_ntop4): New static function. (inet_ntop6): Ditto. (cygwin_inet_ntop): New AF_INET6 aware inet_ntop implementation. (ga_aistruct): New static function. (ga_clone): Ditto. (ga_echeck): Ditto. (ga_nsearch): Ditto. (ga_port): Ditto. (ga_serv): Ditto. (ga_unix): Ditto. (gn_ipv46): Ditto. (ipv4_freeaddrinfo): Ditto. (ipv4_getaddrinfo): Ditto. (ipv4_getnameinfo): Ditto. (gai_errmap_t): New structure holding error code - error string mapping. (cygwin_gai_strerror): New function implementing gai_strerror. (w32_to_gai_err): New static function. (get_ipv6_funcs): Ditto. (load_ipv6_funcs): Ditto. (cygwin_freeaddrinfo): New function implementing freeaddrinfo. (cygwin_getaddrinfo): New function implementing getaddrinfo. (cygwin_getnameinfo): New function implementing getnameinfo. * include/netdb.h: Include stdint.h and cygwin/socket.h. Define data types and macros used by getaddrinfo and friends. Declare freeaddrinfo, gai_strerror, getaddrinfo and getnameinfo. * include/cygwin/in.h: Add IPv6 related IPPROTOs. Remove definition of struct sockaddr_in6. Include cygwin/in6.h instead. * include/cygwin/in6.h: New header file defining IPv6 releated data types and macros. * include/cygwin/socket.h: Enable AF_INET6 and PF_INET6. Add IPv6 related socket options. * include/cygwin/version.h: Bump API minor number. 2006-07-06 Corinna Vinschen <corinna@vinschen.de> * autoload.cc (DsGetDcNameA): Define. (NetGetAnyDCName): Define. * security.cc: Include dsgetdc.h. (DsGetDcNameA): Declare. (DS_FORCE_REDISCOVERY): Define. (get_logon_server): Add bool parameter to control rediscovery of DC. Use DsGetDcNameA function if supported, NetGetDCName/NetGetAnyDCName otherwise. (get_server_groups): Rediscover DC if get_user_groups fails and try again. (get_reg_security): Use correct error code macro when testing RegGetKeySecurity return value. * security.h (get_logon_server): Remove default vaue from wserver parameter. Add rediscovery parameter. * uinfo.cc (cygheap_user::env_logsrv): Accomodate rediscovery parameter in call to get_logon_server.
2006-07-25 21:23:23 +02:00
ssize_t recvfrom (void *ptr, size_t len, int flags,
struct sockaddr *from, int *fromlen);
ssize_t recvmsg (struct msghdr *msg, int flags);
ssize_t __stdcall write (const void *ptr, size_t len);
* sigproc.h (wait_for_sigthread): Eliminate parameter. * sigproc.cc (wait_for_sigthread): Ditto. Don't synchronize with wait_sig after receiving an event that it is ready to go. (init_sig_pipe): New function. (wait_sig): Call init_sig_pipe to create pipes for communicating signals to this process. Don't send sigCONT signal when initializing. * fork.cc (frok::child): Accommodate wait_for_sigpipe parameter change. * fhandler.h (fhandler_*::write): Make ssize_t/__stdcall. (fhandler_*::write_overlapped): Ditto. (fhandler_*::raw_write): Ditto. (fhandler_*::readv): Ditto. (fhandler_*::writev): Ditto. (fhandler_*::raw_read): Make __stdcall. * fhandler: Accommodate changes to read/write functions throughout. * fhandler_clipboard.cc: Ditto. * fhandler_console.cc: Ditto. * fhandler_dsp.cc: Ditto. * fhandler_fifo.cc: Ditto. * fhandler_mailslot.cc: Ditto. * fhandler_mem.cc: Ditto. * fhandler_mem.cc: Ditto. * fhandler_random.cc: Ditto. * fhandler_tape.cc: Ditto. * fhandler_tty.cc: Ditto. * fhandler_virtual.cc: Ditto. * fhandler_windows.cc: Ditto. * fhandler_zero.cc: Ditto. * syscalls.cc (readv): Use ssize_t as temp variable. * fhandler.cc (fhandler_base::read): Coerce returned len to signed or it will never be treated as < 0. (fhandler_base::wait_overlapped): Minimize calls to GetLastError. Remove duplicate debugging test. Fix error return. * fhandler.h (fhandler_fifo::fifo_name): Declare new function. (fhandler_fifo::close): Ditto. (fhandler_fifo::dup): Ditto. (fhandler_fifo::close_on_exec): Ditto. * fhandler.cc (fhandler_fifo::fifo_name): Define new function. (FIFO_BUF_SIZE): New define. (cnp): Ditto. (fhandler_fifo::open): Rework. Use cnp to open named pipe. Always open write side as a client. Open dummy client when writing and can't connect. (wait): Rework. Implement fifo_wait_for_next_client. Handle signals during connect better. Add new fifo_wait_for_server code which polls (sigh) waiting for server. (fhandler_fifo::raw_read): Handle transition states when one client closes and another is available. (fhandler_fifo::close): Define. (fhandler_fifo::dup): Ditto. (fhandler_fifo::close_on_exec): Ditto.
2009-07-24 22:54:33 +02:00
ssize_t __stdcall writev (const struct iovec *, int iovcnt, ssize_t tot = -1);
inline ssize_t send_internal (struct _WSAMSG *wsamsg, int flags);
2006-07-25 Corinna Vinschen <corinna@vinschen.de> * include/cygwin/version.h: Bump DLL version to 1.7.0. 2006-07-25 Corinna Vinschen <corinna@vinschen.de> * select.h: Remove. * fhandler_socket.cc: Don't include select.h. * select.cc: Ditto. 2006-07-25 Corinna Vinschen <corinna@vinschen.de> * cygtls.h: Drop socket related includes. (struct _local_storage): Remove exitsock and exitsock_sin. Add select_sockevt. * cygtls.cc: Accomodate above change throughout. * fhandler.h (class fhandler_socket): Make wsock_evt public. * fhandler_socket.cc (fhandler_socket::fhandler_socket): Accomodate reordering members. (fhandler_socket::evaluate_events): Drop FD_CONNECT event as soon as it gets read once. Never remove FD_WRITE event here. (fhandler_socket::wait_for_events): Wait 50 ms instead of INFINITE for socket events. (fhandler_socket::accept): Fix conditional. Set wsock_events members of accepted socket to useful start values. (fhandler_socket::recv_internal): Always drop FD_READ/FD_OOB events from wsock_events after the call to WSARecvFrom. (fhandler_socket::send_internal): Drop FD_WRITE event from wsock_events if the call to WSASendTo fails with WSAEWOULDBLOCK. Fix return value condition. * select.cc (struct socketinf): Change to accomodate using socket event handling. (peek_socket): Use event handling for peeking socket. (thread_socket): Ditto. (start_thread_socket): Ditto. (socket_cleanup): Same here. * tlsoffsets.h: Regenerate. 2006-07-20 Corinna Vinschen <corinna@vinschen.de> * fhandler.h (class fhandler_socket): Rearrange slightly to keep event handling methods and members together. Drop owner status flag. Split wait method. Rename event handling methods for readability. * fhandler_socket.cc (struct wsa_event): Add owner field. (LOCK_EVENTS): New macro. (UNLOCK_EVENTS): Ditto. (fhandler_socket::init_events): rename from prepare. (fhandler_socket::evaluate_events): First half of former wait method. Do everything but wait. Allow specifiying whether or not events from event_mask should be erased from wsock_events->events. Simplify OOB handling. Allow sending SIGURG to any process (group). (fhandler_socket::wait_for_events): Second half of former wait method. Call evaluate_events and wait in a loop if socket is blocking. (fhandler_socket::release_events): Rename from release. (fhandler_socket::connect): Accomodate above name changes. (fhandler_socket::accept): Ditto. (fhandler_socket::recv_internal): Ditto. (fhandler_socket::send_internal): Ditto. (fhandler_socket::close): Ditto. (fhandler_socket::fcntl): Always set owner to given input value on F_SETOWN. Handle F_GETOWN. * net.cc (fdsock): Accomodate above name changes. 2006-07-20 Corinna Vinschen <corinna@vinschen.de> * fhandler_socket.cc (fhandler_socket::wait): Set Winsock errno to WSAEWOULDBLOCK instead of WSAEINPROGRESS. 2006-07-18 Brian Ford <Brian.Ford@FlightSafety.com> Corinna Vinschen <corinna@vinschen.de> * winsup.h (mmap_region_status): New enum. (mmap_is_attached_or_noreserve_page): Adjust prototype and rename as below. * mmap.cc (mmap_is_attached_or_noreserve_page): Rename mmap_is_attached_or_noreserve. Add region length parameter. Return enum above. * exceptions.cc (_cygtls::handle_exceptions): Accomodate above. * fhandler.cc (fhandler_base::raw_read): Call above for NOACCESS errors and retry on success to allow reads into untouched MAP_NORESERVE buffers. 2006-07-18 Corinna Vinschen <corinna@vinschen.de> * cygwin.din (posix_openpt): Export. * tty.cc (posix_openpt): New function. * include/cygwin/stdlib.h (posix_openpt): Declare. * include/cygwin/version.h: Bump API minor number. 2006-07-14 Corinna Vinschen <corinna@vinschen.de> * security.cc (get_token_group_sidlist): Always add the interactive group to the token. Add comment. Create logon_id group SID by copying it from incoming group list. (create_token): Add subauth_token parameter. Use information in subauth_token if present. Tweak SourceIdentifier if subauth_token is present for debugging purposes. * security.h (create_token): Add subauth_token parameter in declaration. * syscalls.cc (seteuid32): Call subauth first. Call create_token regardless. Use subauth token in call to create_token if subauth succeeded. 2006-07-13 Corinna Vinschen <corinna@vinschen.de> * include/netinet/in.h: Update copyright. 2006-07-13 Corinna Vinschen <corinna@vinschen.de> * fhandler_socket.cc (fhandler_socket::wait): Rework function so that WaitForMultipleObjects is really only called when necessary. 2006-07-12 Corinna Vinschen <corinna@vinschen.de> * include/netdb.h: Declare rcmd, rcmd_af, rexec, rresvport, rresvport_af, iruserok, iruserok_sa, ruserok. 2006-07-12 Corinna Vinschen <corinna@vinschen.de> * Makefile.in (DLL_OFILES): Drop iruserok.o. Add rcmd.o. * autoload.cc (rcmd): Drop definition. * cygwin.din: Export bindresvport, bindresvport_sa, iruserok_sa, rcmd_af, rresvport_af. * net.cc (cygwin_rcmd): Remove. (last_used_bindresvport): Rename from last_used_rrecvport. (cygwin_bindresvport_sa): New function implementing bindresvport_sa. (cygwin_bindresvport): New function implementing bindresvport. (cygwin_rresvport): Remove. * include/cygwin/version.h: Bump API minor number. * include/netinet/in.h: Declare bindresvport and bindresvport_sa. * libc/iruserok.c: Remove file. * libc/rcmd.cc: New file implementing rcmd, rcmd_af, rresvport, rresvport_af, iruserok_sa, iruserok and ruserok. 2006-07-12 Corinna Vinschen <corinna@vinschen.de> * fhandler_socket.cc (fhandler_socket::getsockname): Return valid result for unbound sockets. 2006-07-11 Corinna Vinschen <corinna@vinschen.de> * fhandler_socket.cc (fhandler_socket::fixup_after_fork): Handle wsock_mtx and wsock_evt on fork, thus handling close_on_exec correctly. (fhandler_socket::fixup_after_exec): Drop misguided attempt to handle close_on_exec here. (fhandler_socket::dup): Call fixup_after_fork with NULL parent. Add comment. (fhandler_socket::set_close_on_exec): Handle wsock_mtx and wsock_evt. 2006-07-10 Corinna Vinschen <corinna@vinschen.de> * fhandler.h (class fhandler_socket): Add wsock_mtx, wsock_evt and wsock_events members. Remove closed status flag, add listener status flag. Accomodate new implementation of socket event handling methods. Declare recv* and send* functions ssize_t as the POSIX equivalents. (fhandler_socket::recv_internal): Declare. (fhandler_socket::send_internal): Ditto. * fhandler_socket.cc (EVENT_MASK): Define mask of selected events. (fhandler_socket::fhandler_socket): Initialize new members. (fhandler_socket::af_local_setblocking): Don't actually set the socket to blocking mode. Keep sane event selection. (fhandler_socket::af_local_unsetblocking): Don't actually set the socket to previous blocking setting, just remember it. (struct wsa_event): New structure to keep event data per shared socket. (NUM_SOCKS): Define number of shared sockets concurrently handled by all active Cygwin processes. (wsa_events): New shared datastructure keeping all wsa_event records. (socket_serial_number): New shared variable to identify shared sockets. (wsa_slot_mtx): Global mutex to serialize wsa_events access. (search_wsa_event_slot): New static function to select a new wsa_event slot for a new socket. (fhandler_socket::prepare): Rewrite. Prepare event selection per new socket. (fhandler_socket::wait): Rewrite. Wait for socket events in thread safe and multiple process safe. (fhandler_socket::release): Rewrite. Close per-socket descriptor mutex handle and event handle. (fhandler_socket::dup): Duplicate wsock_mtx and wsock_evt. Fix copy-paste error in debug output. (fhandler_socket::connect): Accomodate new event handling. (fhandler_socket::listen): Set listener flag on successful listen. (fhandler_socket::accept): Accomodate new event handling. (fhandler_socket::recv_internal): New inline method centralizing common recv code. (fhandler_socket::recvfrom): Call recv_internal now. (fhandler_socket::recvmsg): Ditto. Streamline copying from iovec to WSABUF. (fhandler_socket::send_internal): New inline method centralizing common send code. (fhandler_socket::sendto): Call send_internal now. (fhandler_socket::sendmsg): Ditto. Streamline copying from iovec to WSABUF. (fhandler_socket::close): Call release now. (fhandler_socket::ioctl): Never actually switch to blocking mode. Just keep track of the setting. * net.cc (fdsock): Call prepare now. (cygwin_connect): Revert again to event driven technique. (cygwin_accept): Ditto. * poll.cc (poll): Don't call recvfrom on a listening socket. Remove special case for failing recvfrom. * include/sys/socket.h: Declare recv* and send* functions ssize_t as requested by POSIX. 2006-07-07 Corinna Vinschen <corinna@vinschen.de> * net.cc (cygwin_inet_ntop): Fix data type of forth parameter. 2006-07-06 Corinna Vinschen <corinna@vinschen.de> * include/cygwin/in6.h (struct in6_addr): Fix typo. 2006-07-06 Corinna Vinschen <corinna@vinschen.de> * cygwin.din: Export in6addr_any, in6addr_loopback, freeaddrinfo, gai_strerror, getaddrinfo, getnameinfo. * fhandler_socket.cc: Include cygwin/in6.h. (get_inet_addr): Accomodate AF_INET6 usage. (fhandler_socket::connect): Ditto. (fhandler_socket::listen): Ditto. (fhandler_socket::sendto): Ditto. * net.cc: Include cygwin/in6.h. (in6addr_any): Define. (in6addr_loopback): Define. (cygwin_socket): Accomodate AF_INET6 usage. (socketpair): Bind socketpairs only to loopback for security. (inet_pton4): New static function. (inet_pton6): Ditto. (cygwin_inet_pton): New AF_INET6 aware inet_pton implementation. (inet_ntop4): New static function. (inet_ntop6): Ditto. (cygwin_inet_ntop): New AF_INET6 aware inet_ntop implementation. (ga_aistruct): New static function. (ga_clone): Ditto. (ga_echeck): Ditto. (ga_nsearch): Ditto. (ga_port): Ditto. (ga_serv): Ditto. (ga_unix): Ditto. (gn_ipv46): Ditto. (ipv4_freeaddrinfo): Ditto. (ipv4_getaddrinfo): Ditto. (ipv4_getnameinfo): Ditto. (gai_errmap_t): New structure holding error code - error string mapping. (cygwin_gai_strerror): New function implementing gai_strerror. (w32_to_gai_err): New static function. (get_ipv6_funcs): Ditto. (load_ipv6_funcs): Ditto. (cygwin_freeaddrinfo): New function implementing freeaddrinfo. (cygwin_getaddrinfo): New function implementing getaddrinfo. (cygwin_getnameinfo): New function implementing getnameinfo. * include/netdb.h: Include stdint.h and cygwin/socket.h. Define data types and macros used by getaddrinfo and friends. Declare freeaddrinfo, gai_strerror, getaddrinfo and getnameinfo. * include/cygwin/in.h: Add IPv6 related IPPROTOs. Remove definition of struct sockaddr_in6. Include cygwin/in6.h instead. * include/cygwin/in6.h: New header file defining IPv6 releated data types and macros. * include/cygwin/socket.h: Enable AF_INET6 and PF_INET6. Add IPv6 related socket options. * include/cygwin/version.h: Bump API minor number. 2006-07-06 Corinna Vinschen <corinna@vinschen.de> * autoload.cc (DsGetDcNameA): Define. (NetGetAnyDCName): Define. * security.cc: Include dsgetdc.h. (DsGetDcNameA): Declare. (DS_FORCE_REDISCOVERY): Define. (get_logon_server): Add bool parameter to control rediscovery of DC. Use DsGetDcNameA function if supported, NetGetDCName/NetGetAnyDCName otherwise. (get_server_groups): Rediscover DC if get_user_groups fails and try again. (get_reg_security): Use correct error code macro when testing RegGetKeySecurity return value. * security.h (get_logon_server): Remove default vaue from wserver parameter. Add rediscovery parameter. * uinfo.cc (cygheap_user::env_logsrv): Accomodate rediscovery parameter in call to get_logon_server.
2006-07-25 21:23:23 +02:00
ssize_t sendto (const void *ptr, size_t len, int flags,
const struct sockaddr *to, int tolen);
ssize_t sendmsg (const struct msghdr *msg, int flags);
2000-02-17 20:38:33 +01:00
int ioctl (unsigned int cmd, void *);
int fcntl (int cmd, void *);
_off64_t lseek (_off64_t, int) { return 0; }
int shutdown (int how);
2000-02-17 20:38:33 +01:00
int close ();
void hclose (HANDLE) {close ();}
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
int dup (fhandler_base *child, int);
* dtable.cc (dtable::release): Check for socket. Change cnt_need_fixup_before accordingly. (dtable::dup2): Ditto. (dtable::fixup_before_fork): New method. (dtable::fixup_before_exec): Ditto. * dtable.h (class dtable): Add member `cnt_need_fixup_before'. Add definition for methods `dec_need_fixup_before', `inc_need_fixup_before', `need_fixup_before', `fixup_before_exec' and `fixup_before_fork'. * fhandler.h (class fhandler_base): Slight rearrangements. Add definitions for methods `fixup_before_fork_exec'. (class fhandler_socket): Eliminate superfluous constructor. Add member `prot_info_ptr'. Add destructor. Add definitions for methods `dup', `fixup_before_fork_exec', `fixup_after_fork' and `fixup_after_exec'. * fork.cc (fork_parent): Care for file types which need a fixup before fork. Start child in suspended state then. * net.cc: New global variable `ws2_32_handle' and `wsadata'. (fdsock): Check for Winsock version. Call `set_socket_inheritance' only if Winsock version < 2.0. Care for `need_fixup' count in fdtab. (cygwin_socket): Eliminate call to `set_socket_inheritance'. (cygwin_accept): Ditto. (cygwin_rcmd): Ditto. (cygwin_rresvport): Ditto. (cygwin_rexec): Ditto. (socketpair): Ditto. (fhandler_socket::fhandler_socket): Set `need_fork_fixup'. Allocate space for the WSAPROTOCOL_INFOA struct used in fixup. (fhandler_socket::~fhandler_socket): New destructor. (fhandler_socket::fixup_before_fork_exec): New method. (fhandler_socket::fixup_after_fork): Ditto. (fhandler_socket::dup): Ditto. (wsock_init): New static function. (LoadDLLinitfunc (wsock32)): Rearranged. (LoadDLLinitfunc (ws2_32)): New function. (dummy_autoload): Add autoload statemants for `WSADuplicateSocketA' and `WSASocketA'. * spawn.cc (spawn_guts): Care for file types which need a fixup before exec. Start child in suspended state then.
2000-10-26 12:13:41 +02:00
* Use new unified status_flag accessor methods from classes fhandler_*, tty_min, mtinfo and fs_info thoroughout. * fhandler.h: Redefine all set_close_on_exec methods to take a bool argument. (enum conn_state): Rename from connect_state. (class fhandler_base): Rename some status flags to align with accessor method names. Drop encoded flag entirely. Unify status accessor methods. Const'ify all read accessor methods. (class fhandler_socket): Ditto. (class fhandler_dev_raw): Ditto. * fhandler_disk_file.cc (fhandler_base::fstat_fs): Use fs.fs_is_fat() instead of evaluating FATness of file system here. (fhandler_disk_file::opendir): Drop call to set_encoded(). (fhandler_disk_file::readdir): Use pc.isencoded() directly. * mtinfo.h (class mtinfo_drive): Const'ify all read accessor methods. * path.cc (fsinfo_cnt): Add. (fs_info::update): Accomodate class changes. Evaluate file system name specific flags right here. Add thread safety for reading and writing global fsinfo array. * path.h (enum path_types): Drop values for flags kept in fs already. (struct fs_info): Move status informatin into private struct type status_flags. Add accessor methods. Remove path and file system name string arrays in favor of status bits. (class path_conv): Use new fs_info status information where appropriate. (path_conf::fs_has_ea): Rename from fs_fast_ea. (path_conf::fs_has_acls): New method. (path_conf::root_dir): Remove. (path_conf::volname): Remove. * syscalls (statfs): Evaluate root dir locally. * tty.h (class tty_min): Unify status accessor methods. Const'ify all read accessor methods.
2004-04-10 15:45:10 +02:00
void set_close_on_exec (bool val);
Reintegrate socket duplication via WSADuplicateSocket/WSASocket. * autoload.cc (WSADuplicateSocketW): Define. (WSASocketW): Define. * dtable.cc (dtable::release): Call dec_need_fixup_before if necessary. (dtable::fixup_before_fork): New function. (dtable::fixup_before_exec): New function. * dtable.h (class dtable): Add member cnt_need_fixup_before. Add declarations for above new functions. (dtable::dec_need_fixup_before): New inline method. (dtable::inc_need_fixup_before): New inline method. (dtable::need_fixup_before): New inline method. * fhandler.h (fhandler_base::fixup_before_fork_exec): New virtual method. (fhandler_base::need_fixup_before): New virtual method. (class fhandler_socket): Add member prot_info_ptr. (fhandler_socket::init_fixup_before): Declare. (fhandler_socket::need_fixup_before): New inline method. (fhandler_socket::fixup_before_fork_exec): Declare. (fhandler_socket::fixup_after_exec): Declare. * fhandler_socket.cc (fhandler_socket::fhandler_socket): Initialize prot_info_ptr to NULL. (fhandler_socket::~fhandler_socket): Free prot_info_ptr conditionally. (fhandler_socket::init_fixup_before): New method. (fhandler_socket::fixup_before_fork_exec): Ditto. (fhandler_socket::fixup_after_fork): Use WSASocketW to duplicate socket if necessary. (fhandler_socket::fixup_after_exec): New method. (fhandler_socket::dup): Use fixup_before_fork_exec/fixup_after_fork to duplicate socket if necessary. * fork.cc (frok::parent): Start child suspended if some fhandler needs fixup before fork. If so, call dtable::fixup_before_fork after CreateProcess and resume child. * net.cc (fdsock): Try to find out if socket needs fixup before and initialize socket accordingly. Add HUGE comment to explain what happens and why. * spawn.cc (spawn_guts): Start child suspended if some fhandler needs fixup before exec. If so, call dtable::fixup_before_exec after CreateProcess.
2009-11-17 11:43:01 +01:00
int fixup_before_fork_exec (DWORD);
* dtable.cc (dtable::release): Check for socket. Change cnt_need_fixup_before accordingly. (dtable::dup2): Ditto. (dtable::fixup_before_fork): New method. (dtable::fixup_before_exec): Ditto. * dtable.h (class dtable): Add member `cnt_need_fixup_before'. Add definition for methods `dec_need_fixup_before', `inc_need_fixup_before', `need_fixup_before', `fixup_before_exec' and `fixup_before_fork'. * fhandler.h (class fhandler_base): Slight rearrangements. Add definitions for methods `fixup_before_fork_exec'. (class fhandler_socket): Eliminate superfluous constructor. Add member `prot_info_ptr'. Add destructor. Add definitions for methods `dup', `fixup_before_fork_exec', `fixup_after_fork' and `fixup_after_exec'. * fork.cc (fork_parent): Care for file types which need a fixup before fork. Start child in suspended state then. * net.cc: New global variable `ws2_32_handle' and `wsadata'. (fdsock): Check for Winsock version. Call `set_socket_inheritance' only if Winsock version < 2.0. Care for `need_fixup' count in fdtab. (cygwin_socket): Eliminate call to `set_socket_inheritance'. (cygwin_accept): Ditto. (cygwin_rcmd): Ditto. (cygwin_rresvport): Ditto. (cygwin_rexec): Ditto. (socketpair): Ditto. (fhandler_socket::fhandler_socket): Set `need_fork_fixup'. Allocate space for the WSAPROTOCOL_INFOA struct used in fixup. (fhandler_socket::~fhandler_socket): New destructor. (fhandler_socket::fixup_before_fork_exec): New method. (fhandler_socket::fixup_after_fork): Ditto. (fhandler_socket::dup): Ditto. (wsock_init): New static function. (LoadDLLinitfunc (wsock32)): Rearranged. (LoadDLLinitfunc (ws2_32)): New function. (dummy_autoload): Add autoload statemants for `WSADuplicateSocketA' and `WSASocketA'. * spawn.cc (spawn_guts): Care for file types which need a fixup before exec. Start child in suspended state then.
2000-10-26 12:13:41 +02:00
void fixup_after_fork (HANDLE);
Reintegrate socket duplication via WSADuplicateSocket/WSASocket. * autoload.cc (WSADuplicateSocketW): Define. (WSASocketW): Define. * dtable.cc (dtable::release): Call dec_need_fixup_before if necessary. (dtable::fixup_before_fork): New function. (dtable::fixup_before_exec): New function. * dtable.h (class dtable): Add member cnt_need_fixup_before. Add declarations for above new functions. (dtable::dec_need_fixup_before): New inline method. (dtable::inc_need_fixup_before): New inline method. (dtable::need_fixup_before): New inline method. * fhandler.h (fhandler_base::fixup_before_fork_exec): New virtual method. (fhandler_base::need_fixup_before): New virtual method. (class fhandler_socket): Add member prot_info_ptr. (fhandler_socket::init_fixup_before): Declare. (fhandler_socket::need_fixup_before): New inline method. (fhandler_socket::fixup_before_fork_exec): Declare. (fhandler_socket::fixup_after_exec): Declare. * fhandler_socket.cc (fhandler_socket::fhandler_socket): Initialize prot_info_ptr to NULL. (fhandler_socket::~fhandler_socket): Free prot_info_ptr conditionally. (fhandler_socket::init_fixup_before): New method. (fhandler_socket::fixup_before_fork_exec): Ditto. (fhandler_socket::fixup_after_fork): Use WSASocketW to duplicate socket if necessary. (fhandler_socket::fixup_after_exec): New method. (fhandler_socket::dup): Use fixup_before_fork_exec/fixup_after_fork to duplicate socket if necessary. * fork.cc (frok::parent): Start child suspended if some fhandler needs fixup before fork. If so, call dtable::fixup_before_fork after CreateProcess and resume child. * net.cc (fdsock): Try to find out if socket needs fixup before and initialize socket accordingly. Add HUGE comment to explain what happens and why. * spawn.cc (spawn_guts): Start child suspended if some fhandler needs fixup before exec. If so, call dtable::fixup_before_exec after CreateProcess.
2009-11-17 11:43:01 +01:00
void fixup_after_exec ();
* cygheap.h (class cygheap_fdenum): New class to enumerate used fhandlers. * dtable.h (class dtable): Add cygheap_fdenum as friend class. * fhandler.h (fhandler_base::get_proc_fd_name): New virtual method to return a name for /proc/<pid>/fd. (fhandler_socket::get_proc_fd_name): Ditto. (fhandler_pipe::get_proc_fd_name): Ditto. (fhandler_virtual::opendir): Make virtual method. (fhandler_process::opendir): New method. * fhandler.cc (fhandler_base::get_proc_fd_name): New method. * fhandler_process.cc: Include ctype.h. (PROCESS_FD): Define. (process_listing): Add "fd". (fhandler_process::exists): Fix comment. Return 1 in case of "fd" directory. Handle files below "fd". (fhandler_process::fstat): Drop "self" handling. Set correct link count for directories. (fhandler_process::opendir): New method to handle "fd" directory. (fhandler_process::readdir): Add "fd" handling. (fhandler_process::open): Drop "self" handling. (fhandler_process::fill_filebuf): Ditto. Add "fd" handling. Fix "maps" output string. * fhandler_registry.cc (fhandler_registry::fstat): Set correct link count for directories. * fhandler_socket.cc (fhandler_socket::get_proc_fd_name): New method. * path.cc (symlink_info::set): Fix thinko. * pinfo.cc (_pinfo::commune_recv): Rename pathbuf to path throughout. Drop local path variable in PICOM_FIFO case. Fix debug output. Close handles as early as possible. Add PICOM_FDS and PICOM_FD handling. (_pinfo::commune_send): Add PICOM_FDS and PICOM_FD handling. (_pinfo::fd): New method. (_pinfo::fds): New method. * pinfo.h (enum picom): Add PICOM_FDS and PICOM_FD. (_pinfo::fd): Declare. (_pinfo::fds): Declare. * pipe.cc (fhandler_pipe::get_proc_fd_name): New method.
2005-01-31 11:28:55 +01:00
char *get_proc_fd_name (char *buf);
2000-02-17 20:38:33 +01:00
* select.h: New file split from fhandler.h. (select_record::select_record): Define do-nothing constructor for "new" to avoid gratuitous zeroing. (select_info): New base class. (select_pipe_info): New class with methods for dealing with pipes. (select_socket_info): New class with methods for dealing with sockets. (select_serial_info): Dummy class for serial. (select_mailslot_info): Dummy class for mailslots. (select_stuff): Define device_specific_* as actual classes rather than void *. * dtable.h (dtable::select_read): Accommodate return value change to 'bool' and argument change to "select_stuff". (dtable::select_write): Ditto. (dtable::select_except): Ditto. * dtable.cc (dtable::select_read): Accommodate return value change to 'bool' and argument change to "select_stuff". (dtable::select_write): Ditto. (dtable::select_except): Ditto. * fhandler.h: Excise select-related classes. (fhandler_*::select_read): Change argument to select_stuff. (fhandler_*::select_write): Ditto. (fhandler_*::select_except): Ditto. * select.cc (UNIX_FD_ZERO): Use memset rather than bzero. (select_stuff::test_and_set): Change return type to bool. Allocate select_record on entry and let fhandler_*::select_* operate on the start.next field of select_stuff. (pipeinf): Delete. (select_pipe_info::select_pipe_info): New constructor. Allocates event for controlling pipe waits. (select_pipe_info::~select_pipe_info): New destructor. Destroy event. Stop thread. (select_pipe_info::add_watch_handle): New function. (thread_pipe): Wait for the hEvent part of any overlapped pipes before peeking. (start_thread_pipe): Don't allocate device_specific_pipe stuff here. Assume that it has been allocated earlier. (pipe_cleanup): Rely on select_pipe_info destructor to clean up pipe paraphenalia. (fhandler_*::select_*): Derive select_record from new select_stuff argument. (fhandler_pipe::select_*): Ditto. Allocate pipe-specific field if not already allocated. (serialinf): Delete. (thread_serial): serialinf -> select_serial_info. (fhandler_base::ready_for_read): Rewrite to accommodate change in argument to fhandler_*::select_*. (socketinf): Delete. (thread_socket): socketinf -> select_socket_info. (mailslotinf): Delete. (thread_mailslot): mailslotinf -> select_mailslot_info.
2009-06-30 23:18:44 +02:00
select_record *select_read (select_stuff *);
select_record *select_write (select_stuff *);
select_record *select_except (select_stuff *);
2000-02-17 20:38:33 +01:00
void set_addr_family (int af) {addr_family = af;}
int get_addr_family () {return addr_family;}
void set_socket_type (int st) { type = st;}
int get_socket_type () {return type;}
void set_sun_path (const char *path);
char *get_sun_path () {return sun_path;}
void set_peer_sun_path (const char *path);
char *get_peer_sun_path () {return peer_sun_path;}
* fhandler.h (fhandler_socket::eid_connect): Make private. (fhandler_socket::set_connect_secret): Ditto. (fhandler_socket::get_connect_secret): Ditto. (fhandler_socket::create_secret_event): Ditto. Remove secret argument. (fhandler_socket::check_peer_secret_event): Ditto. (fhandler_socket::signal_secret_event): Make private. (fhandler_socket::close_secret_event): Ditto. (fhandler_socket::sec_event_accept): New private method. (fhandler_socket::sec_event_connect): Ditto. (fhandler_socket::af_local_connect): New public method. * fhandler_socket.cc: Use 'struct sockaddr' and 'struct sockaddr_in' rather than just 'sockaddr' and 'sockaddr_in' throughout. (fhandler_socket::eid_connect): Drop AF_LOCAL/SOCK_STREAM test. (fhandler_socket::create_secret_event): Remove secret argument. Always use connect_secret instead. (fhandler_socket::check_peer_secret_event): Ditto. (fhandler_socket::sec_event_connect): New method, combining entire secret event handshake on connect side. (fhandler_socket::af_local_connect): New method, combining secret event handshake and eid credential transaction on connect side, to be called from select. (fhandler_socket::sec_event_accept): New method, combining entire secret event handshake on accept side. (fhandler_socket::connect): Drop secret, use connect_secret instead. Move entire secret event handshake to sec_event_connect. (fhandler_socket::accept): Move entire secret event handshake to sec_event_accept. * select.cc (set_bits): Just call af_local_connect here.
2005-03-23 18:27:18 +01:00
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
int __stdcall fstat (struct __stat64 *buf) __attribute__ ((regparm (2)));
int __stdcall fstatvfs (struct statvfs *buf) __attribute__ ((regparm (2)));
int __stdcall fchmod (mode_t mode) __attribute__ ((regparm (1)));
int __stdcall fchown (__uid32_t uid, __gid32_t gid) __attribute__ ((regparm (2)));
int __stdcall facl (int, int, __acl32 *) __attribute__ ((regparm (3)));
int __stdcall link (const char *) __attribute__ ((regparm (2)));
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
fhandler_socket (void *) {}
void copyto (fhandler_base *x)
{
x->pc.free_strings ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
*reinterpret_cast<fhandler_socket *> (x) = *this;
x->reset (this);
}
fhandler_socket *clone (cygheap_types malloc_type = HEAP_FHANDLER)
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
{
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_socket));
* fhandler.h (fhandler_pipe::create_selectable): Remove optional argument, take an options argument for CreateNamedPipe/CreateFile. Change handle arguments to expect pointers. (fhandler_fifo::fifo_state): Delete. (fhandler_fifo::dummy_client): Ditto. (fhandler_fifo::open_nonserver): Ditto. (fhandler_fifo::wait_state): Ditto. (fhandler_fifo::raw_write): Ditto. (fhandler_fifo::read_ready): New field. (fhandler_fifo::write_ready): Ditto. (fhandler_fifo::wait): Modify argument. (fhandler_fifo::fifo_name): Add a new argument. (fhandler_fifo::fixup_after_fork): New function. * fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Remove initialization of expunged elements. Initialize new handles to NULL. (fhandler_fifo::open_nonserver): Delete. (fnevent): New macro for creating a named event. (fnpipe): New macro for creating a unique named pipe name. (create_pipe): New macro for simplification of named pipe creation. (fhandler_fifo::fifo_name): Use new argument when creating a shared name. (fhandler_fifo::open): Rewrite. Use events to synchronize. (pure_debug_printf): New macro, active only when DEBUGGING. (fhandler_fifo::wait): Rewrite to wait for new fifo events which are supplied as a parameter. (fhandler_fifo::raw_read): Rewrite to use handle mechanism to detect client-side disconnect. (fhandler_fifo::raw_write): Delete. (fhandler_fifo::close): Remove accommodations for expunged fields. Close event handles. (fhandler_fifo::dup): Remove accommodations for expunged fields. Duplicate event handles. (fhandler_fifo::fixup_after_fork): New function. Perform fixups on event handles. (fhandler_fifo::set_close_on_exec): Remove accommodations for expunged fields. Set inheritance for new handle fields. * miscfuncs.cc (CreatePipeOverlapped): Accommodate changes in fhandler_pipe::create_selectable. * tty.cc (tty::not_allocated): Ditto. * pipe.cc (fhandler_pipe::create): Ditto. (fhandler_pipe::create_selectable): Accept an extra open_mode argument. Pass arguments by reference and allow opening one end of the pipe at a time. * sys/strace.h (debug_only_printf): Define new macro which calls debug_printf only when DEBUGGING is defined.
2011-10-30 05:50:36 +01:00
fhandler_socket *fh = new (ptr) fhandler_socket (ptr);
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
copyto (fh);
return fh;
}
2000-02-17 20:38:33 +01:00
};
class fhandler_base_overlapped: public fhandler_base
2000-02-17 20:38:33 +01:00
{
static HANDLE asio_done;
static LONG asio_close_counter;
protected:
* 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-09 17:47:44 +01:00
enum wait_return
{
overlapped_unknown = 0,
overlapped_success,
overlapped_nonblocking_no_data,
overlapped_nullread,
overlapped_error
* 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-09 17:47:44 +01:00
};
bool io_pending;
Preliminary change to make fifos/pipes interruptible and fifos reliable. * dtable.cc (dtable::find_fifo): Eliminate definition. * dtable.h (dtable::find_fifo): Ditto for declaration. * fhandler.cc (fhandler_base::raw_read): Remove pipe-specific stuff. (fhandler_base::fhandler_base): Ditto. (fhandler_base::close): Handle overlapped I/O structure if appropriate. (fhandler_base::dup): Ditto. (fhandler_base::fork_fixup): Ditto. (fhandler_base::setup_overlapped): Define new function. (fhandler_base::destroy_overlapped): Ditto. (fhandler_base::wait_overlapped): Ditto. (fhandler_base::read_overlapped): Ditto. (fhandler_base::write_overlapped): Ditto. * fhandler.h (fhandler_base::get_overlapped): Declare new function. (fhandler_base::setup_overlapped): Ditto. (fhandler_base::destroy_overlapped): Ditto. (fhandler_base::wait_overlapped): Ditto. (fhandler_base::read_overlapped): Ditto. (fhandler_base::write_overlapped): Ditto. (fhandler_base::get_guard): Eliminate. (fhandler_pipe::*): Rework to eliminate most Win9x related cruft, removing many variables and defining a new overlapped capability. (fhandler_fifo::*): Ditto. (fifo_state): Declare new enum. * fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Remove old Win9x stuff. Initialize overlapped handle to NULL. (fhandler_fifo::set_use): Eliminate. (fhandler_fifo::open_nonserver): Define. (fhandler_fifo::open): Rework to use named pipes and overlapped I/O. (fhandler_fifo::wait): Define new function to wait for named pipe connection. (fhandler_fifo::read): Rework to use wait() and new overlapped I/O functionality. (fhandler_fifo::write): Ditto. (fhandler_fifo::dup): Eliminate. * pinfo.cc (commune_process): Remove fifo handling. (_pinfo::commune_request): Ditto. * pinfo.h (picom): Ditto. * pipe.cc (fhandler_pipe::fhandler_pipe): Remove Win9x stuff. Initialize overlapped handle to NULL. (fhandler_pipe::open): Eliminate Win9x stuff. (fhandler_pipe::set_close_on_exec): Eliminate. (read_pipe): Eliminate. (fhandler_pipe::close): Ditto. (fhandler_pipe::fixup_after_exec): Ditto. (fhandler_pipe::fixup_in_child): Ditto. (fhandler_pipe::read): Rework to use overlapped I/O. (fhandler_pipe::write): New function using overlapped I/O. (fhandler_pipe::dup): Rework to eliminate Win9x stuff. (fhandler_pipe::create_selectable): Rework to eliminate Win9x and use overlapped I/O. * select.cc (peek_pipe): Rework to eliminate Win9x stuff and use overlapped I/O. (fhandler_base::ready_for_read): Ditto.
2007-07-07 19:00:33 +02:00
OVERLAPPED io_status;
OVERLAPPED *overlapped;
* 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-09 17:47:44 +01:00
size_t max_atomic_write;
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
public:
* 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-09 17:47:44 +01:00
wait_return __stdcall wait_overlapped (bool, bool, DWORD *, bool, DWORD = 0) __attribute__ ((regparm (3)));
int __stdcall setup_overlapped () __attribute__ ((regparm (1)));
void __stdcall destroy_overlapped () __attribute__ ((regparm (1)));
virtual void __stdcall raw_read (void *ptr, size_t& len) __attribute__ ((regparm (3)));
virtual ssize_t __stdcall raw_write (const void *ptr, size_t len) __attribute__ ((regparm (3)));
OVERLAPPED *&get_overlapped () {return overlapped;}
OVERLAPPED *get_overlapped_buffer () {return &io_status;}
void set_overlapped (OVERLAPPED *ov) {overlapped = ov;}
* 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-09 17:47:44 +01:00
fhandler_base_overlapped (): io_pending (false), overlapped (NULL), max_atomic_write (0)
{
memset (&io_status, 0, sizeof io_status);
}
* 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-09 17:47:44 +01:00
bool __stdcall has_ongoing_io () __attribute__ ((regparm (1)));
void fixup_after_fork (HANDLE);
void fixup_after_exec ();
int close ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
int dup (fhandler_base *child, int);
void check_later ();
static void flush_all_async_io () __attribute__ ((regparm (1)));;
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
fhandler_base_overlapped (void *) {}
virtual void copyto (fhandler_base *x)
{
x->pc.free_strings ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
*reinterpret_cast<fhandler_base_overlapped *> (x) = *this;
x->reset (this);
}
virtual fhandler_base_overlapped *clone (cygheap_types malloc_type = HEAP_FHANDLER)
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
{
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_base_overlapped));
* fhandler.h (fhandler_pipe::create_selectable): Remove optional argument, take an options argument for CreateNamedPipe/CreateFile. Change handle arguments to expect pointers. (fhandler_fifo::fifo_state): Delete. (fhandler_fifo::dummy_client): Ditto. (fhandler_fifo::open_nonserver): Ditto. (fhandler_fifo::wait_state): Ditto. (fhandler_fifo::raw_write): Ditto. (fhandler_fifo::read_ready): New field. (fhandler_fifo::write_ready): Ditto. (fhandler_fifo::wait): Modify argument. (fhandler_fifo::fifo_name): Add a new argument. (fhandler_fifo::fixup_after_fork): New function. * fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Remove initialization of expunged elements. Initialize new handles to NULL. (fhandler_fifo::open_nonserver): Delete. (fnevent): New macro for creating a named event. (fnpipe): New macro for creating a unique named pipe name. (create_pipe): New macro for simplification of named pipe creation. (fhandler_fifo::fifo_name): Use new argument when creating a shared name. (fhandler_fifo::open): Rewrite. Use events to synchronize. (pure_debug_printf): New macro, active only when DEBUGGING. (fhandler_fifo::wait): Rewrite to wait for new fifo events which are supplied as a parameter. (fhandler_fifo::raw_read): Rewrite to use handle mechanism to detect client-side disconnect. (fhandler_fifo::raw_write): Delete. (fhandler_fifo::close): Remove accommodations for expunged fields. Close event handles. (fhandler_fifo::dup): Remove accommodations for expunged fields. Duplicate event handles. (fhandler_fifo::fixup_after_fork): New function. Perform fixups on event handles. (fhandler_fifo::set_close_on_exec): Remove accommodations for expunged fields. Set inheritance for new handle fields. * miscfuncs.cc (CreatePipeOverlapped): Accommodate changes in fhandler_pipe::create_selectable. * tty.cc (tty::not_allocated): Ditto. * pipe.cc (fhandler_pipe::create): Ditto. (fhandler_pipe::create_selectable): Accept an extra open_mode argument. Pass arguments by reference and allow opening one end of the pipe at a time. * sys/strace.h (debug_only_printf): Define new macro which calls debug_printf only when DEBUGGING is defined.
2011-10-30 05:50:36 +01:00
fhandler_base_overlapped *fh = new (ptr) fhandler_base_overlapped (ptr);
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
copyto (fh);
return fh;
}
friend DWORD WINAPI flush_async_io (void *);
};
class fhandler_pipe: public fhandler_base_overlapped
{
private:
pid_t popen_pid;
public:
fhandler_pipe ();
bool ispipe() const { return true; }
* child_info.h (child_info_spawn::__stdin): New element. (child_info_spawn::__stdin): Ditto. (CURR_CHILD_INFO_MAGIC): Regenerate. * dcrt0.cc (check_sanity_and_sync): Minor cleanup. (child_info_spawn::handle_spawn): Handle new __std* elements by calling move_fd. * dtable.cc (dtable::move_fd): Define new function. * dtable.h (dtable::move_fd): Declare new function. * fhandler.h (fhandler_pipe::popen_pid): Declare new element. * fhandler.h (fhandler_pipe::get_popen_pid): Define new function. * fhandler.h (fhandler_pipe::set_popen_pid): Ditto. * pipe.cc (fhandler_pipe::fhandler_pipe): Zero popen_pid. (fhandler_pipe::dup): Ditto. * spawn.cc (handle): Change second argument to bool. (spawn_guts): Accept __stdin/__stdout arguments and set them appropriately in child_info structure and in STARTUPINFO structure. * syscalls.cc (popen): New cygwin-specific implementation using spawn. (pclose): Ditto. * winsup.h (spawn_guts): Accommodate new arguments for spawn_guts. * fhandler.cc (fhandler_base::set_no_inheritance): Make second arg a bool. * fhandler.h (fhandler_base::set_no_inheritance): Ditto for declaration. * child_info.h (child_info::msv_count): Rename from the now-inappropriate "zero". (child_info_spawn::filler): Add filler to work around Vista bug. (child_info_fork::filler): Ditto. * dcrt0.cc (get_cygwin_startup_info): Remove "zero" check since it is now always filled out. * fork.cc (frok::parent): Move ch.zero manipulation to constructor. * spawn.cc (spawn_guts): Ditto. Remove _ch wrapper. * sigproc.cc (child_info::child_info): Initialize starter[]. * shared.cc (shared_info::heap_slop_size): Remove noisy system_printfs. * shared_info.h (CURR_SHARED_MAGIC): Regenerate.
2006-12-11 19:55:29 +01:00
void set_popen_pid (pid_t pid) {popen_pid = pid;}
pid_t get_popen_pid () const {return popen_pid;}
_off64_t lseek (_off64_t offset, int whence);
* select.h: New file split from fhandler.h. (select_record::select_record): Define do-nothing constructor for "new" to avoid gratuitous zeroing. (select_info): New base class. (select_pipe_info): New class with methods for dealing with pipes. (select_socket_info): New class with methods for dealing with sockets. (select_serial_info): Dummy class for serial. (select_mailslot_info): Dummy class for mailslots. (select_stuff): Define device_specific_* as actual classes rather than void *. * dtable.h (dtable::select_read): Accommodate return value change to 'bool' and argument change to "select_stuff". (dtable::select_write): Ditto. (dtable::select_except): Ditto. * dtable.cc (dtable::select_read): Accommodate return value change to 'bool' and argument change to "select_stuff". (dtable::select_write): Ditto. (dtable::select_except): Ditto. * fhandler.h: Excise select-related classes. (fhandler_*::select_read): Change argument to select_stuff. (fhandler_*::select_write): Ditto. (fhandler_*::select_except): Ditto. * select.cc (UNIX_FD_ZERO): Use memset rather than bzero. (select_stuff::test_and_set): Change return type to bool. Allocate select_record on entry and let fhandler_*::select_* operate on the start.next field of select_stuff. (pipeinf): Delete. (select_pipe_info::select_pipe_info): New constructor. Allocates event for controlling pipe waits. (select_pipe_info::~select_pipe_info): New destructor. Destroy event. Stop thread. (select_pipe_info::add_watch_handle): New function. (thread_pipe): Wait for the hEvent part of any overlapped pipes before peeking. (start_thread_pipe): Don't allocate device_specific_pipe stuff here. Assume that it has been allocated earlier. (pipe_cleanup): Rely on select_pipe_info destructor to clean up pipe paraphenalia. (fhandler_*::select_*): Derive select_record from new select_stuff argument. (fhandler_pipe::select_*): Ditto. Allocate pipe-specific field if not already allocated. (serialinf): Delete. (thread_serial): serialinf -> select_serial_info. (fhandler_base::ready_for_read): Rewrite to accommodate change in argument to fhandler_*::select_*. (socketinf): Delete. (thread_socket): socketinf -> select_socket_info. (mailslotinf): Delete. (thread_mailslot): mailslotinf -> select_mailslot_info.
2009-06-30 23:18:44 +02:00
select_record *select_read (select_stuff *);
select_record *select_write (select_stuff *);
select_record *select_except (select_stuff *);
* cygheap.h (class cygheap_fdenum): New class to enumerate used fhandlers. * dtable.h (class dtable): Add cygheap_fdenum as friend class. * fhandler.h (fhandler_base::get_proc_fd_name): New virtual method to return a name for /proc/<pid>/fd. (fhandler_socket::get_proc_fd_name): Ditto. (fhandler_pipe::get_proc_fd_name): Ditto. (fhandler_virtual::opendir): Make virtual method. (fhandler_process::opendir): New method. * fhandler.cc (fhandler_base::get_proc_fd_name): New method. * fhandler_process.cc: Include ctype.h. (PROCESS_FD): Define. (process_listing): Add "fd". (fhandler_process::exists): Fix comment. Return 1 in case of "fd" directory. Handle files below "fd". (fhandler_process::fstat): Drop "self" handling. Set correct link count for directories. (fhandler_process::opendir): New method to handle "fd" directory. (fhandler_process::readdir): Add "fd" handling. (fhandler_process::open): Drop "self" handling. (fhandler_process::fill_filebuf): Ditto. Add "fd" handling. Fix "maps" output string. * fhandler_registry.cc (fhandler_registry::fstat): Set correct link count for directories. * fhandler_socket.cc (fhandler_socket::get_proc_fd_name): New method. * path.cc (symlink_info::set): Fix thinko. * pinfo.cc (_pinfo::commune_recv): Rename pathbuf to path throughout. Drop local path variable in PICOM_FIFO case. Fix debug output. Close handles as early as possible. Add PICOM_FDS and PICOM_FD handling. (_pinfo::commune_send): Add PICOM_FDS and PICOM_FD handling. (_pinfo::fd): New method. (_pinfo::fds): New method. * pinfo.h (enum picom): Add PICOM_FDS and PICOM_FD. (_pinfo::fd): Declare. (_pinfo::fds): Declare. * pipe.cc (fhandler_pipe::get_proc_fd_name): New method.
2005-01-31 11:28:55 +01:00
char *get_proc_fd_name (char *buf);
int open (int flags, mode_t mode = 0);
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
int dup (fhandler_base *child, int);
int ioctl (unsigned int cmd, void *);
int __stdcall fstatvfs (struct statvfs *buf) __attribute__ ((regparm (2)));
int __stdcall fadvise (_off64_t, _off64_t, int) __attribute__ ((regparm (3)));
int __stdcall ftruncate (_off64_t, bool) __attribute__ ((regparm (3)));
int init (HANDLE, DWORD, mode_t);
static int create (fhandler_pipe *[2], unsigned, int);
static DWORD create (LPSECURITY_ATTRIBUTES, HANDLE *, HANDLE *, DWORD,
const char *, DWORD);
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
fhandler_pipe (void *) {}
void copyto (fhandler_base *x)
{
x->pc.free_strings ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
*reinterpret_cast<fhandler_pipe *> (x) = *this;
x->reset (this);
}
fhandler_pipe *clone (cygheap_types malloc_type = HEAP_FHANDLER)
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
{
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_pipe));
* fhandler.h (fhandler_pipe::create_selectable): Remove optional argument, take an options argument for CreateNamedPipe/CreateFile. Change handle arguments to expect pointers. (fhandler_fifo::fifo_state): Delete. (fhandler_fifo::dummy_client): Ditto. (fhandler_fifo::open_nonserver): Ditto. (fhandler_fifo::wait_state): Ditto. (fhandler_fifo::raw_write): Ditto. (fhandler_fifo::read_ready): New field. (fhandler_fifo::write_ready): Ditto. (fhandler_fifo::wait): Modify argument. (fhandler_fifo::fifo_name): Add a new argument. (fhandler_fifo::fixup_after_fork): New function. * fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Remove initialization of expunged elements. Initialize new handles to NULL. (fhandler_fifo::open_nonserver): Delete. (fnevent): New macro for creating a named event. (fnpipe): New macro for creating a unique named pipe name. (create_pipe): New macro for simplification of named pipe creation. (fhandler_fifo::fifo_name): Use new argument when creating a shared name. (fhandler_fifo::open): Rewrite. Use events to synchronize. (pure_debug_printf): New macro, active only when DEBUGGING. (fhandler_fifo::wait): Rewrite to wait for new fifo events which are supplied as a parameter. (fhandler_fifo::raw_read): Rewrite to use handle mechanism to detect client-side disconnect. (fhandler_fifo::raw_write): Delete. (fhandler_fifo::close): Remove accommodations for expunged fields. Close event handles. (fhandler_fifo::dup): Remove accommodations for expunged fields. Duplicate event handles. (fhandler_fifo::fixup_after_fork): New function. Perform fixups on event handles. (fhandler_fifo::set_close_on_exec): Remove accommodations for expunged fields. Set inheritance for new handle fields. * miscfuncs.cc (CreatePipeOverlapped): Accommodate changes in fhandler_pipe::create_selectable. * tty.cc (tty::not_allocated): Ditto. * pipe.cc (fhandler_pipe::create): Ditto. (fhandler_pipe::create_selectable): Accept an extra open_mode argument. Pass arguments by reference and allow opening one end of the pipe at a time. * sys/strace.h (debug_only_printf): Define new macro which calls debug_printf only when DEBUGGING is defined.
2011-10-30 05:50:36 +01:00
fhandler_pipe *fh = new (ptr) fhandler_pipe (ptr);
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
copyto (fh);
return fh;
}
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
};
class fhandler_fifo: public fhandler_base_overlapped
Preliminary change to make fifos/pipes interruptible and fifos reliable. * dtable.cc (dtable::find_fifo): Eliminate definition. * dtable.h (dtable::find_fifo): Ditto for declaration. * fhandler.cc (fhandler_base::raw_read): Remove pipe-specific stuff. (fhandler_base::fhandler_base): Ditto. (fhandler_base::close): Handle overlapped I/O structure if appropriate. (fhandler_base::dup): Ditto. (fhandler_base::fork_fixup): Ditto. (fhandler_base::setup_overlapped): Define new function. (fhandler_base::destroy_overlapped): Ditto. (fhandler_base::wait_overlapped): Ditto. (fhandler_base::read_overlapped): Ditto. (fhandler_base::write_overlapped): Ditto. * fhandler.h (fhandler_base::get_overlapped): Declare new function. (fhandler_base::setup_overlapped): Ditto. (fhandler_base::destroy_overlapped): Ditto. (fhandler_base::wait_overlapped): Ditto. (fhandler_base::read_overlapped): Ditto. (fhandler_base::write_overlapped): Ditto. (fhandler_base::get_guard): Eliminate. (fhandler_pipe::*): Rework to eliminate most Win9x related cruft, removing many variables and defining a new overlapped capability. (fhandler_fifo::*): Ditto. (fifo_state): Declare new enum. * fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Remove old Win9x stuff. Initialize overlapped handle to NULL. (fhandler_fifo::set_use): Eliminate. (fhandler_fifo::open_nonserver): Define. (fhandler_fifo::open): Rework to use named pipes and overlapped I/O. (fhandler_fifo::wait): Define new function to wait for named pipe connection. (fhandler_fifo::read): Rework to use wait() and new overlapped I/O functionality. (fhandler_fifo::write): Ditto. (fhandler_fifo::dup): Eliminate. * pinfo.cc (commune_process): Remove fifo handling. (_pinfo::commune_request): Ditto. * pinfo.h (picom): Ditto. * pipe.cc (fhandler_pipe::fhandler_pipe): Remove Win9x stuff. Initialize overlapped handle to NULL. (fhandler_pipe::open): Eliminate Win9x stuff. (fhandler_pipe::set_close_on_exec): Eliminate. (read_pipe): Eliminate. (fhandler_pipe::close): Ditto. (fhandler_pipe::fixup_after_exec): Ditto. (fhandler_pipe::fixup_in_child): Ditto. (fhandler_pipe::read): Rework to use overlapped I/O. (fhandler_pipe::write): New function using overlapped I/O. (fhandler_pipe::dup): Rework to eliminate Win9x stuff. (fhandler_pipe::create_selectable): Rework to eliminate Win9x and use overlapped I/O. * select.cc (peek_pipe): Rework to eliminate Win9x stuff and use overlapped I/O. (fhandler_base::ready_for_read): Ditto.
2007-07-07 19:00:33 +02:00
{
* fhandler.h (fhandler_pipe::create_selectable): Remove optional argument, take an options argument for CreateNamedPipe/CreateFile. Change handle arguments to expect pointers. (fhandler_fifo::fifo_state): Delete. (fhandler_fifo::dummy_client): Ditto. (fhandler_fifo::open_nonserver): Ditto. (fhandler_fifo::wait_state): Ditto. (fhandler_fifo::raw_write): Ditto. (fhandler_fifo::read_ready): New field. (fhandler_fifo::write_ready): Ditto. (fhandler_fifo::wait): Modify argument. (fhandler_fifo::fifo_name): Add a new argument. (fhandler_fifo::fixup_after_fork): New function. * fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Remove initialization of expunged elements. Initialize new handles to NULL. (fhandler_fifo::open_nonserver): Delete. (fnevent): New macro for creating a named event. (fnpipe): New macro for creating a unique named pipe name. (create_pipe): New macro for simplification of named pipe creation. (fhandler_fifo::fifo_name): Use new argument when creating a shared name. (fhandler_fifo::open): Rewrite. Use events to synchronize. (pure_debug_printf): New macro, active only when DEBUGGING. (fhandler_fifo::wait): Rewrite to wait for new fifo events which are supplied as a parameter. (fhandler_fifo::raw_read): Rewrite to use handle mechanism to detect client-side disconnect. (fhandler_fifo::raw_write): Delete. (fhandler_fifo::close): Remove accommodations for expunged fields. Close event handles. (fhandler_fifo::dup): Remove accommodations for expunged fields. Duplicate event handles. (fhandler_fifo::fixup_after_fork): New function. Perform fixups on event handles. (fhandler_fifo::set_close_on_exec): Remove accommodations for expunged fields. Set inheritance for new handle fields. * miscfuncs.cc (CreatePipeOverlapped): Accommodate changes in fhandler_pipe::create_selectable. * tty.cc (tty::not_allocated): Ditto. * pipe.cc (fhandler_pipe::create): Ditto. (fhandler_pipe::create_selectable): Accept an extra open_mode argument. Pass arguments by reference and allow opening one end of the pipe at a time. * sys/strace.h (debug_only_printf): Define new macro which calls debug_printf only when DEBUGGING is defined.
2011-10-30 05:50:36 +01:00
HANDLE read_ready;
HANDLE write_ready;
bool wait (HANDLE) __attribute__ ((regparm (2)));
char *fifo_name (char *, const char *) __attribute__ ((regparm (2)));
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
public:
fhandler_fifo ();
Preliminary change to make fifos/pipes interruptible and fifos reliable. * dtable.cc (dtable::find_fifo): Eliminate definition. * dtable.h (dtable::find_fifo): Ditto for declaration. * fhandler.cc (fhandler_base::raw_read): Remove pipe-specific stuff. (fhandler_base::fhandler_base): Ditto. (fhandler_base::close): Handle overlapped I/O structure if appropriate. (fhandler_base::dup): Ditto. (fhandler_base::fork_fixup): Ditto. (fhandler_base::setup_overlapped): Define new function. (fhandler_base::destroy_overlapped): Ditto. (fhandler_base::wait_overlapped): Ditto. (fhandler_base::read_overlapped): Ditto. (fhandler_base::write_overlapped): Ditto. * fhandler.h (fhandler_base::get_overlapped): Declare new function. (fhandler_base::setup_overlapped): Ditto. (fhandler_base::destroy_overlapped): Ditto. (fhandler_base::wait_overlapped): Ditto. (fhandler_base::read_overlapped): Ditto. (fhandler_base::write_overlapped): Ditto. (fhandler_base::get_guard): Eliminate. (fhandler_pipe::*): Rework to eliminate most Win9x related cruft, removing many variables and defining a new overlapped capability. (fhandler_fifo::*): Ditto. (fifo_state): Declare new enum. * fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Remove old Win9x stuff. Initialize overlapped handle to NULL. (fhandler_fifo::set_use): Eliminate. (fhandler_fifo::open_nonserver): Define. (fhandler_fifo::open): Rework to use named pipes and overlapped I/O. (fhandler_fifo::wait): Define new function to wait for named pipe connection. (fhandler_fifo::read): Rework to use wait() and new overlapped I/O functionality. (fhandler_fifo::write): Ditto. (fhandler_fifo::dup): Eliminate. * pinfo.cc (commune_process): Remove fifo handling. (_pinfo::commune_request): Ditto. * pinfo.h (picom): Ditto. * pipe.cc (fhandler_pipe::fhandler_pipe): Remove Win9x stuff. Initialize overlapped handle to NULL. (fhandler_pipe::open): Eliminate Win9x stuff. (fhandler_pipe::set_close_on_exec): Eliminate. (read_pipe): Eliminate. (fhandler_pipe::close): Ditto. (fhandler_pipe::fixup_after_exec): Ditto. (fhandler_pipe::fixup_in_child): Ditto. (fhandler_pipe::read): Rework to use overlapped I/O. (fhandler_pipe::write): New function using overlapped I/O. (fhandler_pipe::dup): Rework to eliminate Win9x stuff. (fhandler_pipe::create_selectable): Rework to eliminate Win9x and use overlapped I/O. * select.cc (peek_pipe): Rework to eliminate Win9x stuff and use overlapped I/O. (fhandler_base::ready_for_read): Ditto.
2007-07-07 19:00:33 +02:00
int open (int, mode_t);
* sigproc.h (wait_for_sigthread): Eliminate parameter. * sigproc.cc (wait_for_sigthread): Ditto. Don't synchronize with wait_sig after receiving an event that it is ready to go. (init_sig_pipe): New function. (wait_sig): Call init_sig_pipe to create pipes for communicating signals to this process. Don't send sigCONT signal when initializing. * fork.cc (frok::child): Accommodate wait_for_sigpipe parameter change. * fhandler.h (fhandler_*::write): Make ssize_t/__stdcall. (fhandler_*::write_overlapped): Ditto. (fhandler_*::raw_write): Ditto. (fhandler_*::readv): Ditto. (fhandler_*::writev): Ditto. (fhandler_*::raw_read): Make __stdcall. * fhandler: Accommodate changes to read/write functions throughout. * fhandler_clipboard.cc: Ditto. * fhandler_console.cc: Ditto. * fhandler_dsp.cc: Ditto. * fhandler_fifo.cc: Ditto. * fhandler_mailslot.cc: Ditto. * fhandler_mem.cc: Ditto. * fhandler_mem.cc: Ditto. * fhandler_random.cc: Ditto. * fhandler_tape.cc: Ditto. * fhandler_tty.cc: Ditto. * fhandler_virtual.cc: Ditto. * fhandler_windows.cc: Ditto. * fhandler_zero.cc: Ditto. * syscalls.cc (readv): Use ssize_t as temp variable. * fhandler.cc (fhandler_base::read): Coerce returned len to signed or it will never be treated as < 0. (fhandler_base::wait_overlapped): Minimize calls to GetLastError. Remove duplicate debugging test. Fix error return. * fhandler.h (fhandler_fifo::fifo_name): Declare new function. (fhandler_fifo::close): Ditto. (fhandler_fifo::dup): Ditto. (fhandler_fifo::close_on_exec): Ditto. * fhandler.cc (fhandler_fifo::fifo_name): Define new function. (FIFO_BUF_SIZE): New define. (cnp): Ditto. (fhandler_fifo::open): Rework. Use cnp to open named pipe. Always open write side as a client. Open dummy client when writing and can't connect. (wait): Rework. Implement fifo_wait_for_next_client. Handle signals during connect better. Add new fifo_wait_for_server code which polls (sigh) waiting for server. (fhandler_fifo::raw_read): Handle transition states when one client closes and another is available. (fhandler_fifo::close): Define. (fhandler_fifo::dup): Ditto. (fhandler_fifo::close_on_exec): Ditto.
2009-07-24 22:54:33 +02:00
int close ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
int dup (fhandler_base *child, int);
bool isfifo () const { return true; }
* sigproc.h (wait_for_sigthread): Eliminate parameter. * sigproc.cc (wait_for_sigthread): Ditto. Don't synchronize with wait_sig after receiving an event that it is ready to go. (init_sig_pipe): New function. (wait_sig): Call init_sig_pipe to create pipes for communicating signals to this process. Don't send sigCONT signal when initializing. * fork.cc (frok::child): Accommodate wait_for_sigpipe parameter change. * fhandler.h (fhandler_*::write): Make ssize_t/__stdcall. (fhandler_*::write_overlapped): Ditto. (fhandler_*::raw_write): Ditto. (fhandler_*::readv): Ditto. (fhandler_*::writev): Ditto. (fhandler_*::raw_read): Make __stdcall. * fhandler: Accommodate changes to read/write functions throughout. * fhandler_clipboard.cc: Ditto. * fhandler_console.cc: Ditto. * fhandler_dsp.cc: Ditto. * fhandler_fifo.cc: Ditto. * fhandler_mailslot.cc: Ditto. * fhandler_mem.cc: Ditto. * fhandler_mem.cc: Ditto. * fhandler_random.cc: Ditto. * fhandler_tape.cc: Ditto. * fhandler_tty.cc: Ditto. * fhandler_virtual.cc: Ditto. * fhandler_windows.cc: Ditto. * fhandler_zero.cc: Ditto. * syscalls.cc (readv): Use ssize_t as temp variable. * fhandler.cc (fhandler_base::read): Coerce returned len to signed or it will never be treated as < 0. (fhandler_base::wait_overlapped): Minimize calls to GetLastError. Remove duplicate debugging test. Fix error return. * fhandler.h (fhandler_fifo::fifo_name): Declare new function. (fhandler_fifo::close): Ditto. (fhandler_fifo::dup): Ditto. (fhandler_fifo::close_on_exec): Ditto. * fhandler.cc (fhandler_fifo::fifo_name): Define new function. (FIFO_BUF_SIZE): New define. (cnp): Ditto. (fhandler_fifo::open): Rework. Use cnp to open named pipe. Always open write side as a client. Open dummy client when writing and can't connect. (wait): Rework. Implement fifo_wait_for_next_client. Handle signals during connect better. Add new fifo_wait_for_server code which polls (sigh) waiting for server. (fhandler_fifo::raw_read): Handle transition states when one client closes and another is available. (fhandler_fifo::close): Define. (fhandler_fifo::dup): Ditto. (fhandler_fifo::close_on_exec): Ditto.
2009-07-24 22:54:33 +02:00
void set_close_on_exec (bool val);
* fhandler.h (fhandler_pipe::create_selectable): Remove optional argument, take an options argument for CreateNamedPipe/CreateFile. Change handle arguments to expect pointers. (fhandler_fifo::fifo_state): Delete. (fhandler_fifo::dummy_client): Ditto. (fhandler_fifo::open_nonserver): Ditto. (fhandler_fifo::wait_state): Ditto. (fhandler_fifo::raw_write): Ditto. (fhandler_fifo::read_ready): New field. (fhandler_fifo::write_ready): Ditto. (fhandler_fifo::wait): Modify argument. (fhandler_fifo::fifo_name): Add a new argument. (fhandler_fifo::fixup_after_fork): New function. * fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Remove initialization of expunged elements. Initialize new handles to NULL. (fhandler_fifo::open_nonserver): Delete. (fnevent): New macro for creating a named event. (fnpipe): New macro for creating a unique named pipe name. (create_pipe): New macro for simplification of named pipe creation. (fhandler_fifo::fifo_name): Use new argument when creating a shared name. (fhandler_fifo::open): Rewrite. Use events to synchronize. (pure_debug_printf): New macro, active only when DEBUGGING. (fhandler_fifo::wait): Rewrite to wait for new fifo events which are supplied as a parameter. (fhandler_fifo::raw_read): Rewrite to use handle mechanism to detect client-side disconnect. (fhandler_fifo::raw_write): Delete. (fhandler_fifo::close): Remove accommodations for expunged fields. Close event handles. (fhandler_fifo::dup): Remove accommodations for expunged fields. Duplicate event handles. (fhandler_fifo::fixup_after_fork): New function. Perform fixups on event handles. (fhandler_fifo::set_close_on_exec): Remove accommodations for expunged fields. Set inheritance for new handle fields. * miscfuncs.cc (CreatePipeOverlapped): Accommodate changes in fhandler_pipe::create_selectable. * tty.cc (tty::not_allocated): Ditto. * pipe.cc (fhandler_pipe::create): Ditto. (fhandler_pipe::create_selectable): Accept an extra open_mode argument. Pass arguments by reference and allow opening one end of the pipe at a time. * sys/strace.h (debug_only_printf): Define new macro which calls debug_printf only when DEBUGGING is defined.
2011-10-30 05:50:36 +01:00
void __stdcall raw_read (void *ptr, size_t& ulen) __attribute__ ((regparm (3)));
bool arm (HANDLE h);
* fhandler.h (fhandler_pipe::create_selectable): Remove optional argument, take an options argument for CreateNamedPipe/CreateFile. Change handle arguments to expect pointers. (fhandler_fifo::fifo_state): Delete. (fhandler_fifo::dummy_client): Ditto. (fhandler_fifo::open_nonserver): Ditto. (fhandler_fifo::wait_state): Ditto. (fhandler_fifo::raw_write): Ditto. (fhandler_fifo::read_ready): New field. (fhandler_fifo::write_ready): Ditto. (fhandler_fifo::wait): Modify argument. (fhandler_fifo::fifo_name): Add a new argument. (fhandler_fifo::fixup_after_fork): New function. * fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Remove initialization of expunged elements. Initialize new handles to NULL. (fhandler_fifo::open_nonserver): Delete. (fnevent): New macro for creating a named event. (fnpipe): New macro for creating a unique named pipe name. (create_pipe): New macro for simplification of named pipe creation. (fhandler_fifo::fifo_name): Use new argument when creating a shared name. (fhandler_fifo::open): Rewrite. Use events to synchronize. (pure_debug_printf): New macro, active only when DEBUGGING. (fhandler_fifo::wait): Rewrite to wait for new fifo events which are supplied as a parameter. (fhandler_fifo::raw_read): Rewrite to use handle mechanism to detect client-side disconnect. (fhandler_fifo::raw_write): Delete. (fhandler_fifo::close): Remove accommodations for expunged fields. Close event handles. (fhandler_fifo::dup): Remove accommodations for expunged fields. Duplicate event handles. (fhandler_fifo::fixup_after_fork): New function. Perform fixups on event handles. (fhandler_fifo::set_close_on_exec): Remove accommodations for expunged fields. Set inheritance for new handle fields. * miscfuncs.cc (CreatePipeOverlapped): Accommodate changes in fhandler_pipe::create_selectable. * tty.cc (tty::not_allocated): Ditto. * pipe.cc (fhandler_pipe::create): Ditto. (fhandler_pipe::create_selectable): Accept an extra open_mode argument. Pass arguments by reference and allow opening one end of the pipe at a time. * sys/strace.h (debug_only_printf): Define new macro which calls debug_printf only when DEBUGGING is defined.
2011-10-30 05:50:36 +01:00
void fixup_after_fork (HANDLE);
int __stdcall fstatvfs (struct statvfs *buf) __attribute__ ((regparm (2)));
* select.h: New file split from fhandler.h. (select_record::select_record): Define do-nothing constructor for "new" to avoid gratuitous zeroing. (select_info): New base class. (select_pipe_info): New class with methods for dealing with pipes. (select_socket_info): New class with methods for dealing with sockets. (select_serial_info): Dummy class for serial. (select_mailslot_info): Dummy class for mailslots. (select_stuff): Define device_specific_* as actual classes rather than void *. * dtable.h (dtable::select_read): Accommodate return value change to 'bool' and argument change to "select_stuff". (dtable::select_write): Ditto. (dtable::select_except): Ditto. * dtable.cc (dtable::select_read): Accommodate return value change to 'bool' and argument change to "select_stuff". (dtable::select_write): Ditto. (dtable::select_except): Ditto. * fhandler.h: Excise select-related classes. (fhandler_*::select_read): Change argument to select_stuff. (fhandler_*::select_write): Ditto. (fhandler_*::select_except): Ditto. * select.cc (UNIX_FD_ZERO): Use memset rather than bzero. (select_stuff::test_and_set): Change return type to bool. Allocate select_record on entry and let fhandler_*::select_* operate on the start.next field of select_stuff. (pipeinf): Delete. (select_pipe_info::select_pipe_info): New constructor. Allocates event for controlling pipe waits. (select_pipe_info::~select_pipe_info): New destructor. Destroy event. Stop thread. (select_pipe_info::add_watch_handle): New function. (thread_pipe): Wait for the hEvent part of any overlapped pipes before peeking. (start_thread_pipe): Don't allocate device_specific_pipe stuff here. Assume that it has been allocated earlier. (pipe_cleanup): Rely on select_pipe_info destructor to clean up pipe paraphenalia. (fhandler_*::select_*): Derive select_record from new select_stuff argument. (fhandler_pipe::select_*): Ditto. Allocate pipe-specific field if not already allocated. (serialinf): Delete. (thread_serial): serialinf -> select_serial_info. (fhandler_base::ready_for_read): Rewrite to accommodate change in argument to fhandler_*::select_*. (socketinf): Delete. (thread_socket): socketinf -> select_socket_info. (mailslotinf): Delete. (thread_mailslot): mailslotinf -> select_mailslot_info.
2009-06-30 23:18:44 +02:00
select_record *select_read (select_stuff *);
select_record *select_write (select_stuff *);
select_record *select_except (select_stuff *);
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
fhandler_fifo (void *) {}
void copyto (fhandler_base *x)
{
x->pc.free_strings ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
*reinterpret_cast<fhandler_fifo *> (x) = *this;
x->reset (this);
}
fhandler_fifo *clone (cygheap_types malloc_type = HEAP_FHANDLER)
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
{
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_fifo));
* fhandler.h (fhandler_pipe::create_selectable): Remove optional argument, take an options argument for CreateNamedPipe/CreateFile. Change handle arguments to expect pointers. (fhandler_fifo::fifo_state): Delete. (fhandler_fifo::dummy_client): Ditto. (fhandler_fifo::open_nonserver): Ditto. (fhandler_fifo::wait_state): Ditto. (fhandler_fifo::raw_write): Ditto. (fhandler_fifo::read_ready): New field. (fhandler_fifo::write_ready): Ditto. (fhandler_fifo::wait): Modify argument. (fhandler_fifo::fifo_name): Add a new argument. (fhandler_fifo::fixup_after_fork): New function. * fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Remove initialization of expunged elements. Initialize new handles to NULL. (fhandler_fifo::open_nonserver): Delete. (fnevent): New macro for creating a named event. (fnpipe): New macro for creating a unique named pipe name. (create_pipe): New macro for simplification of named pipe creation. (fhandler_fifo::fifo_name): Use new argument when creating a shared name. (fhandler_fifo::open): Rewrite. Use events to synchronize. (pure_debug_printf): New macro, active only when DEBUGGING. (fhandler_fifo::wait): Rewrite to wait for new fifo events which are supplied as a parameter. (fhandler_fifo::raw_read): Rewrite to use handle mechanism to detect client-side disconnect. (fhandler_fifo::raw_write): Delete. (fhandler_fifo::close): Remove accommodations for expunged fields. Close event handles. (fhandler_fifo::dup): Remove accommodations for expunged fields. Duplicate event handles. (fhandler_fifo::fixup_after_fork): New function. Perform fixups on event handles. (fhandler_fifo::set_close_on_exec): Remove accommodations for expunged fields. Set inheritance for new handle fields. * miscfuncs.cc (CreatePipeOverlapped): Accommodate changes in fhandler_pipe::create_selectable. * tty.cc (tty::not_allocated): Ditto. * pipe.cc (fhandler_pipe::create): Ditto. (fhandler_pipe::create_selectable): Accept an extra open_mode argument. Pass arguments by reference and allow opening one end of the pipe at a time. * sys/strace.h (debug_only_printf): Define new macro which calls debug_printf only when DEBUGGING is defined.
2011-10-30 05:50:36 +01:00
fhandler_fifo *fh = new (ptr) fhandler_fifo (ptr);
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
copyto (fh);
return fh;
}
2000-02-17 20:38:33 +01:00
};
class fhandler_mailslot : public fhandler_base_overlapped
{
POBJECT_ATTRIBUTES get_object_attr (OBJECT_ATTRIBUTES &, PUNICODE_STRING, int);
public:
fhandler_mailslot ();
int __stdcall fstat (struct __stat64 *buf) __attribute__ ((regparm (2)));
int open (int flags, mode_t mode = 0);
ssize_t __stdcall raw_write (const void *, size_t) __attribute__ ((regparm (3)));
int ioctl (unsigned int cmd, void *);
select_record *select_read (select_stuff *);
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
fhandler_mailslot (void *) {}
void copyto (fhandler_base *x)
{
x->pc.free_strings ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
*reinterpret_cast<fhandler_mailslot *> (x) = *this;
x->reset (this);
}
fhandler_mailslot *clone (cygheap_types malloc_type = HEAP_FHANDLER)
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
{
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_mailslot));
* fhandler.h (fhandler_pipe::create_selectable): Remove optional argument, take an options argument for CreateNamedPipe/CreateFile. Change handle arguments to expect pointers. (fhandler_fifo::fifo_state): Delete. (fhandler_fifo::dummy_client): Ditto. (fhandler_fifo::open_nonserver): Ditto. (fhandler_fifo::wait_state): Ditto. (fhandler_fifo::raw_write): Ditto. (fhandler_fifo::read_ready): New field. (fhandler_fifo::write_ready): Ditto. (fhandler_fifo::wait): Modify argument. (fhandler_fifo::fifo_name): Add a new argument. (fhandler_fifo::fixup_after_fork): New function. * fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Remove initialization of expunged elements. Initialize new handles to NULL. (fhandler_fifo::open_nonserver): Delete. (fnevent): New macro for creating a named event. (fnpipe): New macro for creating a unique named pipe name. (create_pipe): New macro for simplification of named pipe creation. (fhandler_fifo::fifo_name): Use new argument when creating a shared name. (fhandler_fifo::open): Rewrite. Use events to synchronize. (pure_debug_printf): New macro, active only when DEBUGGING. (fhandler_fifo::wait): Rewrite to wait for new fifo events which are supplied as a parameter. (fhandler_fifo::raw_read): Rewrite to use handle mechanism to detect client-side disconnect. (fhandler_fifo::raw_write): Delete. (fhandler_fifo::close): Remove accommodations for expunged fields. Close event handles. (fhandler_fifo::dup): Remove accommodations for expunged fields. Duplicate event handles. (fhandler_fifo::fixup_after_fork): New function. Perform fixups on event handles. (fhandler_fifo::set_close_on_exec): Remove accommodations for expunged fields. Set inheritance for new handle fields. * miscfuncs.cc (CreatePipeOverlapped): Accommodate changes in fhandler_pipe::create_selectable. * tty.cc (tty::not_allocated): Ditto. * pipe.cc (fhandler_pipe::create): Ditto. (fhandler_pipe::create_selectable): Accept an extra open_mode argument. Pass arguments by reference and allow opening one end of the pipe at a time. * sys/strace.h (debug_only_printf): Define new macro which calls debug_printf only when DEBUGGING is defined.
2011-10-30 05:50:36 +01:00
fhandler_mailslot *fh = new (ptr) fhandler_mailslot (ptr);
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
copyto (fh);
return fh;
}
};
2000-02-17 20:38:33 +01:00
class fhandler_dev_raw: public fhandler_base
{
* dtable.cc (dtable::build_fhandler): Issue internal error on unknown device. * fhandler.cc (fhandler_base::close): Show both name and handle in debugging output. * fhandler.h (fhandler_base::get_guard): New virtual method. (fhandler_pipe::get_guard): New method. (fhandler_socket::ready_for_read): Delete declaration. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (struct select_record::peek): Declare new method. * select.cc (MAKEready): Delete. (peek_pipe): Use get_guard method to retrieve potential guard mutex handle. (fhandler_base::ready_for_read): Rewrite as generic ready-for-read handler. Should only be called for "slow" devices. (fhandler_socket::ready_for_read): Delete definition. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (fhandler_pipe::select_read): Fill in new peek record in select_record structure. (fhandler_console::select_read): Ditto. (fhandler_tty_common::select_read): Ditto. (fhandler_serial::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_tty_slave::ready_for_read): Check for tty not open. Set errnos appropriately. * syscalls.cc (_read): Allow ready_for_read to set errno. * pinfo.cc (pinfo::init): Return spawn/NO_WAIT process as valid if it is initializing. * sigproc.cc (getsem): Adjust wait for process to initialize downward to avoid huge waits.
2001-11-01 22:15:53 +01:00
protected:
2000-02-17 20:38:33 +01:00
char *devbuf;
size_t devbufsiz;
size_t devbufstart;
size_t devbufend;
struct status_flags
{
unsigned lastblk_to_read : 1;
public:
* fhandler.h (class fhandler_dev_raw): Delete current_position and eof_detected status flag. Delete is_eom and is_eof methods. Move drive_size, bytes_per_sector, eom_detected status flag, as well as the methods read_file, write_file, raw_read and raw_write to ... (class fhandler_dev_floppy): ... here. Remove is_eom and is_eof methods. Add dup method. * fhandler_floppy.cc (IS_EOM): New macro. (fhandler_dev_floppy::is_eom): Remove. (fhandler_dev_floppy::is_eof): Remove. (fhandler_dev_floppy::fhandler_dev_floppy): Initialize status flags. (fhandler_dev_floppy::get_drive_info): Only call EX functions on systems supporting them and stop suffering strange delays. (fhandler_dev_floppy::read_file): Move here, drop setting current_position. (fhandler_dev_floppy::write_file): Move here, drop setting current_position. (fhandler_dev_floppy::open): Rearrange comment. (fhandler_dev_floppy::dup): New method. (fhandler_dev_floppy::get_current_position): New inline method. Use instead of former current_position were appropriate. (fhandler_dev_floppy::raw_read): Move here. Drop EOF handling. (fhandler_dev_floppy::raw_write): Move here. Drop EOF handling. (fhandler_dev_floppy::lseek): Remove useless conditions. Convert sector_aligned_offset to LARGE_INTEGER to improve SetFilePointer call. (fhandler_dev_floppy::ioctl): Move blocksize check in RDSETBLK case to here. * fhandler_raw.cc (fhandler_dev_raw::is_eom): Remove. (fhandler_dev_raw::is_eof): Remove. (fhandler_dev_raw::write_file): Remove. (fhandler_dev_raw::read_file): Remove. (fhandler_dev_raw::raw_read): Remove. (fhandler_dev_raw::raw_write): Remove. (fhandler_dev_raw::dup): Drop copying removed members. (fhandler_dev_raw::ioctl): Drop blocksize testing. * wincap.h: Implement has_disk_ex_ioctls throughout. * wincap.cc: Ditto. (wincap_vista): Preliminary wincaps for Windows Vista/Longhorn. (wincapc::init): Add Vista/Longhorn handling.
2005-09-28 21:33:18 +02:00
status_flags () : lastblk_to_read (0) {}
} status;
2005-02-13 19:17:29 +01:00
IMPLEMENT_STATUS_FLAG (bool, lastblk_to_read)
2000-02-17 20:38:33 +01:00
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
fhandler_dev_raw ();
2000-02-17 20:38:33 +01:00
* dtable.cc (dtable::build_fhandler): Issue internal error on unknown device. * fhandler.cc (fhandler_base::close): Show both name and handle in debugging output. * fhandler.h (fhandler_base::get_guard): New virtual method. (fhandler_pipe::get_guard): New method. (fhandler_socket::ready_for_read): Delete declaration. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (struct select_record::peek): Declare new method. * select.cc (MAKEready): Delete. (peek_pipe): Use get_guard method to retrieve potential guard mutex handle. (fhandler_base::ready_for_read): Rewrite as generic ready-for-read handler. Should only be called for "slow" devices. (fhandler_socket::ready_for_read): Delete definition. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (fhandler_pipe::select_read): Fill in new peek record in select_record structure. (fhandler_console::select_read): Ditto. (fhandler_tty_common::select_read): Ditto. (fhandler_serial::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_tty_slave::ready_for_read): Check for tty not open. Set errnos appropriately. * syscalls.cc (_read): Allow ready_for_read to set errno. * pinfo.cc (pinfo::init): Return spawn/NO_WAIT process as valid if it is initializing. * sigproc.cc (getsem): Adjust wait for process to initialize downward to avoid huge waits.
2001-11-01 22:15:53 +01:00
public:
~fhandler_dev_raw ();
2000-02-17 20:38:33 +01:00
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
int open (int flags, mode_t mode = 0);
2000-02-17 20:38:33 +01:00
int __stdcall fstat (struct __stat64 *buf) __attribute__ ((regparm (2)));
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
int dup (fhandler_base *child, int);
2000-02-17 20:38:33 +01:00
int ioctl (unsigned int cmd, void *buf);
void fixup_after_fork (HANDLE);
void fixup_after_exec ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
fhandler_dev_raw (void *) {}
void copyto (fhandler_base *x)
{
x->pc.free_strings ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
*reinterpret_cast<fhandler_dev_raw *> (x) = *this;
x->reset (this);
}
fhandler_dev_raw *clone (cygheap_types malloc_type = HEAP_FHANDLER)
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
{
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_dev_raw));
* fhandler.h (fhandler_pipe::create_selectable): Remove optional argument, take an options argument for CreateNamedPipe/CreateFile. Change handle arguments to expect pointers. (fhandler_fifo::fifo_state): Delete. (fhandler_fifo::dummy_client): Ditto. (fhandler_fifo::open_nonserver): Ditto. (fhandler_fifo::wait_state): Ditto. (fhandler_fifo::raw_write): Ditto. (fhandler_fifo::read_ready): New field. (fhandler_fifo::write_ready): Ditto. (fhandler_fifo::wait): Modify argument. (fhandler_fifo::fifo_name): Add a new argument. (fhandler_fifo::fixup_after_fork): New function. * fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Remove initialization of expunged elements. Initialize new handles to NULL. (fhandler_fifo::open_nonserver): Delete. (fnevent): New macro for creating a named event. (fnpipe): New macro for creating a unique named pipe name. (create_pipe): New macro for simplification of named pipe creation. (fhandler_fifo::fifo_name): Use new argument when creating a shared name. (fhandler_fifo::open): Rewrite. Use events to synchronize. (pure_debug_printf): New macro, active only when DEBUGGING. (fhandler_fifo::wait): Rewrite to wait for new fifo events which are supplied as a parameter. (fhandler_fifo::raw_read): Rewrite to use handle mechanism to detect client-side disconnect. (fhandler_fifo::raw_write): Delete. (fhandler_fifo::close): Remove accommodations for expunged fields. Close event handles. (fhandler_fifo::dup): Remove accommodations for expunged fields. Duplicate event handles. (fhandler_fifo::fixup_after_fork): New function. Perform fixups on event handles. (fhandler_fifo::set_close_on_exec): Remove accommodations for expunged fields. Set inheritance for new handle fields. * miscfuncs.cc (CreatePipeOverlapped): Accommodate changes in fhandler_pipe::create_selectable. * tty.cc (tty::not_allocated): Ditto. * pipe.cc (fhandler_pipe::create): Ditto. (fhandler_pipe::create_selectable): Accept an extra open_mode argument. Pass arguments by reference and allow opening one end of the pipe at a time. * sys/strace.h (debug_only_printf): Define new macro which calls debug_printf only when DEBUGGING is defined.
2011-10-30 05:50:36 +01:00
fhandler_dev_raw *fh = new (ptr) fhandler_dev_raw (ptr);
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
copyto (fh);
return fh;
}
2000-02-17 20:38:33 +01:00
};
#define MAX_PARTITIONS 15
struct part_t
{
LONG refcnt;
HANDLE hdl[MAX_PARTITIONS];
};
2000-02-17 20:38:33 +01:00
class fhandler_dev_floppy: public fhandler_dev_raw
{
private:
* fhandler.h (class fhandler_dev_raw): Delete current_position and eof_detected status flag. Delete is_eom and is_eof methods. Move drive_size, bytes_per_sector, eom_detected status flag, as well as the methods read_file, write_file, raw_read and raw_write to ... (class fhandler_dev_floppy): ... here. Remove is_eom and is_eof methods. Add dup method. * fhandler_floppy.cc (IS_EOM): New macro. (fhandler_dev_floppy::is_eom): Remove. (fhandler_dev_floppy::is_eof): Remove. (fhandler_dev_floppy::fhandler_dev_floppy): Initialize status flags. (fhandler_dev_floppy::get_drive_info): Only call EX functions on systems supporting them and stop suffering strange delays. (fhandler_dev_floppy::read_file): Move here, drop setting current_position. (fhandler_dev_floppy::write_file): Move here, drop setting current_position. (fhandler_dev_floppy::open): Rearrange comment. (fhandler_dev_floppy::dup): New method. (fhandler_dev_floppy::get_current_position): New inline method. Use instead of former current_position were appropriate. (fhandler_dev_floppy::raw_read): Move here. Drop EOF handling. (fhandler_dev_floppy::raw_write): Move here. Drop EOF handling. (fhandler_dev_floppy::lseek): Remove useless conditions. Convert sector_aligned_offset to LARGE_INTEGER to improve SetFilePointer call. (fhandler_dev_floppy::ioctl): Move blocksize check in RDSETBLK case to here. * fhandler_raw.cc (fhandler_dev_raw::is_eom): Remove. (fhandler_dev_raw::is_eof): Remove. (fhandler_dev_raw::write_file): Remove. (fhandler_dev_raw::read_file): Remove. (fhandler_dev_raw::raw_read): Remove. (fhandler_dev_raw::raw_write): Remove. (fhandler_dev_raw::dup): Drop copying removed members. (fhandler_dev_raw::ioctl): Drop blocksize testing. * wincap.h: Implement has_disk_ex_ioctls throughout. * wincap.cc: Ditto. (wincap_vista): Preliminary wincaps for Windows Vista/Longhorn. (wincapc::init): Add Vista/Longhorn handling.
2005-09-28 21:33:18 +02:00
_off64_t drive_size;
unsigned long bytes_per_sector;
part_t *partitions;
* fhandler.h (class fhandler_dev_raw): Delete current_position and eof_detected status flag. Delete is_eom and is_eof methods. Move drive_size, bytes_per_sector, eom_detected status flag, as well as the methods read_file, write_file, raw_read and raw_write to ... (class fhandler_dev_floppy): ... here. Remove is_eom and is_eof methods. Add dup method. * fhandler_floppy.cc (IS_EOM): New macro. (fhandler_dev_floppy::is_eom): Remove. (fhandler_dev_floppy::is_eof): Remove. (fhandler_dev_floppy::fhandler_dev_floppy): Initialize status flags. (fhandler_dev_floppy::get_drive_info): Only call EX functions on systems supporting them and stop suffering strange delays. (fhandler_dev_floppy::read_file): Move here, drop setting current_position. (fhandler_dev_floppy::write_file): Move here, drop setting current_position. (fhandler_dev_floppy::open): Rearrange comment. (fhandler_dev_floppy::dup): New method. (fhandler_dev_floppy::get_current_position): New inline method. Use instead of former current_position were appropriate. (fhandler_dev_floppy::raw_read): Move here. Drop EOF handling. (fhandler_dev_floppy::raw_write): Move here. Drop EOF handling. (fhandler_dev_floppy::lseek): Remove useless conditions. Convert sector_aligned_offset to LARGE_INTEGER to improve SetFilePointer call. (fhandler_dev_floppy::ioctl): Move blocksize check in RDSETBLK case to here. * fhandler_raw.cc (fhandler_dev_raw::is_eom): Remove. (fhandler_dev_raw::is_eof): Remove. (fhandler_dev_raw::write_file): Remove. (fhandler_dev_raw::read_file): Remove. (fhandler_dev_raw::raw_read): Remove. (fhandler_dev_raw::raw_write): Remove. (fhandler_dev_raw::dup): Drop copying removed members. (fhandler_dev_raw::ioctl): Drop blocksize testing. * wincap.h: Implement has_disk_ex_ioctls throughout. * wincap.cc: Ditto. (wincap_vista): Preliminary wincaps for Windows Vista/Longhorn. (wincapc::init): Add Vista/Longhorn handling.
2005-09-28 21:33:18 +02:00
struct status_flags
{
unsigned eom_detected : 1;
public:
status_flags () : eom_detected (0) {}
} status;
IMPLEMENT_STATUS_FLAG (bool, eom_detected)
inline _off64_t get_current_position ();
int get_drive_info (struct hd_geometry *geo);
int lock_partition (DWORD to_write);
* fhandler.h (class fhandler_dev_raw): Delete current_position and eof_detected status flag. Delete is_eom and is_eof methods. Move drive_size, bytes_per_sector, eom_detected status flag, as well as the methods read_file, write_file, raw_read and raw_write to ... (class fhandler_dev_floppy): ... here. Remove is_eom and is_eof methods. Add dup method. * fhandler_floppy.cc (IS_EOM): New macro. (fhandler_dev_floppy::is_eom): Remove. (fhandler_dev_floppy::is_eof): Remove. (fhandler_dev_floppy::fhandler_dev_floppy): Initialize status flags. (fhandler_dev_floppy::get_drive_info): Only call EX functions on systems supporting them and stop suffering strange delays. (fhandler_dev_floppy::read_file): Move here, drop setting current_position. (fhandler_dev_floppy::write_file): Move here, drop setting current_position. (fhandler_dev_floppy::open): Rearrange comment. (fhandler_dev_floppy::dup): New method. (fhandler_dev_floppy::get_current_position): New inline method. Use instead of former current_position were appropriate. (fhandler_dev_floppy::raw_read): Move here. Drop EOF handling. (fhandler_dev_floppy::raw_write): Move here. Drop EOF handling. (fhandler_dev_floppy::lseek): Remove useless conditions. Convert sector_aligned_offset to LARGE_INTEGER to improve SetFilePointer call. (fhandler_dev_floppy::ioctl): Move blocksize check in RDSETBLK case to here. * fhandler_raw.cc (fhandler_dev_raw::is_eom): Remove. (fhandler_dev_raw::is_eof): Remove. (fhandler_dev_raw::write_file): Remove. (fhandler_dev_raw::read_file): Remove. (fhandler_dev_raw::raw_read): Remove. (fhandler_dev_raw::raw_write): Remove. (fhandler_dev_raw::dup): Drop copying removed members. (fhandler_dev_raw::ioctl): Drop blocksize testing. * wincap.h: Implement has_disk_ex_ioctls throughout. * wincap.cc: Ditto. (wincap_vista): Preliminary wincaps for Windows Vista/Longhorn. (wincapc::init): Add Vista/Longhorn handling.
2005-09-28 21:33:18 +02:00
BOOL write_file (const void *buf, DWORD to_write, DWORD *written, int *err);
BOOL read_file (void *buf, DWORD to_read, DWORD *read, int *err);
2000-02-17 20:38:33 +01:00
* dtable.cc (dtable::build_fhandler): Issue internal error on unknown device. * fhandler.cc (fhandler_base::close): Show both name and handle in debugging output. * fhandler.h (fhandler_base::get_guard): New virtual method. (fhandler_pipe::get_guard): New method. (fhandler_socket::ready_for_read): Delete declaration. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (struct select_record::peek): Declare new method. * select.cc (MAKEready): Delete. (peek_pipe): Use get_guard method to retrieve potential guard mutex handle. (fhandler_base::ready_for_read): Rewrite as generic ready-for-read handler. Should only be called for "slow" devices. (fhandler_socket::ready_for_read): Delete definition. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (fhandler_pipe::select_read): Fill in new peek record in select_record structure. (fhandler_console::select_read): Ditto. (fhandler_tty_common::select_read): Ditto. (fhandler_serial::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_tty_slave::ready_for_read): Check for tty not open. Set errnos appropriately. * syscalls.cc (_read): Allow ready_for_read to set errno. * pinfo.cc (pinfo::init): Return spawn/NO_WAIT process as valid if it is initializing. * sigproc.cc (getsem): Adjust wait for process to initialize downward to avoid huge waits.
2001-11-01 22:15:53 +01:00
public:
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
fhandler_dev_floppy ();
2000-02-17 20:38:33 +01:00
* fhandler.h (class fhandler_dev_raw): Delete current_position and eof_detected status flag. Delete is_eom and is_eof methods. Move drive_size, bytes_per_sector, eom_detected status flag, as well as the methods read_file, write_file, raw_read and raw_write to ... (class fhandler_dev_floppy): ... here. Remove is_eom and is_eof methods. Add dup method. * fhandler_floppy.cc (IS_EOM): New macro. (fhandler_dev_floppy::is_eom): Remove. (fhandler_dev_floppy::is_eof): Remove. (fhandler_dev_floppy::fhandler_dev_floppy): Initialize status flags. (fhandler_dev_floppy::get_drive_info): Only call EX functions on systems supporting them and stop suffering strange delays. (fhandler_dev_floppy::read_file): Move here, drop setting current_position. (fhandler_dev_floppy::write_file): Move here, drop setting current_position. (fhandler_dev_floppy::open): Rearrange comment. (fhandler_dev_floppy::dup): New method. (fhandler_dev_floppy::get_current_position): New inline method. Use instead of former current_position were appropriate. (fhandler_dev_floppy::raw_read): Move here. Drop EOF handling. (fhandler_dev_floppy::raw_write): Move here. Drop EOF handling. (fhandler_dev_floppy::lseek): Remove useless conditions. Convert sector_aligned_offset to LARGE_INTEGER to improve SetFilePointer call. (fhandler_dev_floppy::ioctl): Move blocksize check in RDSETBLK case to here. * fhandler_raw.cc (fhandler_dev_raw::is_eom): Remove. (fhandler_dev_raw::is_eof): Remove. (fhandler_dev_raw::write_file): Remove. (fhandler_dev_raw::read_file): Remove. (fhandler_dev_raw::raw_read): Remove. (fhandler_dev_raw::raw_write): Remove. (fhandler_dev_raw::dup): Drop copying removed members. (fhandler_dev_raw::ioctl): Drop blocksize testing. * wincap.h: Implement has_disk_ex_ioctls throughout. * wincap.cc: Ditto. (wincap_vista): Preliminary wincaps for Windows Vista/Longhorn. (wincapc::init): Add Vista/Longhorn handling.
2005-09-28 21:33:18 +02:00
int open (int flags, mode_t mode = 0);
int close ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
int dup (fhandler_base *child, int);
void __stdcall raw_read (void *ptr, size_t& ulen) __attribute__ ((regparm (3)));
ssize_t __stdcall raw_write (const void *ptr, size_t ulen) __attribute__ ((regparm (3)));
* fhandler.h (class fhandler_dev_raw): Delete current_position and eof_detected status flag. Delete is_eom and is_eof methods. Move drive_size, bytes_per_sector, eom_detected status flag, as well as the methods read_file, write_file, raw_read and raw_write to ... (class fhandler_dev_floppy): ... here. Remove is_eom and is_eof methods. Add dup method. * fhandler_floppy.cc (IS_EOM): New macro. (fhandler_dev_floppy::is_eom): Remove. (fhandler_dev_floppy::is_eof): Remove. (fhandler_dev_floppy::fhandler_dev_floppy): Initialize status flags. (fhandler_dev_floppy::get_drive_info): Only call EX functions on systems supporting them and stop suffering strange delays. (fhandler_dev_floppy::read_file): Move here, drop setting current_position. (fhandler_dev_floppy::write_file): Move here, drop setting current_position. (fhandler_dev_floppy::open): Rearrange comment. (fhandler_dev_floppy::dup): New method. (fhandler_dev_floppy::get_current_position): New inline method. Use instead of former current_position were appropriate. (fhandler_dev_floppy::raw_read): Move here. Drop EOF handling. (fhandler_dev_floppy::raw_write): Move here. Drop EOF handling. (fhandler_dev_floppy::lseek): Remove useless conditions. Convert sector_aligned_offset to LARGE_INTEGER to improve SetFilePointer call. (fhandler_dev_floppy::ioctl): Move blocksize check in RDSETBLK case to here. * fhandler_raw.cc (fhandler_dev_raw::is_eom): Remove. (fhandler_dev_raw::is_eof): Remove. (fhandler_dev_raw::write_file): Remove. (fhandler_dev_raw::read_file): Remove. (fhandler_dev_raw::raw_read): Remove. (fhandler_dev_raw::raw_write): Remove. (fhandler_dev_raw::dup): Drop copying removed members. (fhandler_dev_raw::ioctl): Drop blocksize testing. * wincap.h: Implement has_disk_ex_ioctls throughout. * wincap.cc: Ditto. (wincap_vista): Preliminary wincaps for Windows Vista/Longhorn. (wincapc::init): Add Vista/Longhorn handling.
2005-09-28 21:33:18 +02:00
_off64_t lseek (_off64_t offset, int whence);
int ioctl (unsigned int cmd, void *buf);
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
fhandler_dev_floppy (void *) {}
void copyto (fhandler_base *x)
{
x->pc.free_strings ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
*reinterpret_cast<fhandler_dev_floppy *> (x) = *this;
x->reset (this);
}
fhandler_dev_floppy *clone (cygheap_types malloc_type = HEAP_FHANDLER)
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
{
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_dev_floppy));
* fhandler.h (fhandler_pipe::create_selectable): Remove optional argument, take an options argument for CreateNamedPipe/CreateFile. Change handle arguments to expect pointers. (fhandler_fifo::fifo_state): Delete. (fhandler_fifo::dummy_client): Ditto. (fhandler_fifo::open_nonserver): Ditto. (fhandler_fifo::wait_state): Ditto. (fhandler_fifo::raw_write): Ditto. (fhandler_fifo::read_ready): New field. (fhandler_fifo::write_ready): Ditto. (fhandler_fifo::wait): Modify argument. (fhandler_fifo::fifo_name): Add a new argument. (fhandler_fifo::fixup_after_fork): New function. * fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Remove initialization of expunged elements. Initialize new handles to NULL. (fhandler_fifo::open_nonserver): Delete. (fnevent): New macro for creating a named event. (fnpipe): New macro for creating a unique named pipe name. (create_pipe): New macro for simplification of named pipe creation. (fhandler_fifo::fifo_name): Use new argument when creating a shared name. (fhandler_fifo::open): Rewrite. Use events to synchronize. (pure_debug_printf): New macro, active only when DEBUGGING. (fhandler_fifo::wait): Rewrite to wait for new fifo events which are supplied as a parameter. (fhandler_fifo::raw_read): Rewrite to use handle mechanism to detect client-side disconnect. (fhandler_fifo::raw_write): Delete. (fhandler_fifo::close): Remove accommodations for expunged fields. Close event handles. (fhandler_fifo::dup): Remove accommodations for expunged fields. Duplicate event handles. (fhandler_fifo::fixup_after_fork): New function. Perform fixups on event handles. (fhandler_fifo::set_close_on_exec): Remove accommodations for expunged fields. Set inheritance for new handle fields. * miscfuncs.cc (CreatePipeOverlapped): Accommodate changes in fhandler_pipe::create_selectable. * tty.cc (tty::not_allocated): Ditto. * pipe.cc (fhandler_pipe::create): Ditto. (fhandler_pipe::create_selectable): Accept an extra open_mode argument. Pass arguments by reference and allow opening one end of the pipe at a time. * sys/strace.h (debug_only_printf): Define new macro which calls debug_printf only when DEBUGGING is defined.
2011-10-30 05:50:36 +01:00
fhandler_dev_floppy *fh = new (ptr) fhandler_dev_floppy (ptr);
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
copyto (fh);
return fh;
}
2000-02-17 20:38:33 +01:00
};
class fhandler_dev_tape: public fhandler_dev_raw
{
* errno.cc (errmap): Map ERROR_SHARING_VIOLATION to EBUSY, ERROR_EOM_OVERFLOW and ERROR_NO_DATA_DETECTED to EIO. Add mappings for ERROR_NO_MEDIA_IN_DRIVE, ERROR_DEVICE_REQUIRES_CLEANING and ERROR_DEVICE_DOOR_OPEN. * fhandler.h (class fhandler_dev_raw): Drop varblkop member. (fhandler_dev_raw::is_eom): De-virtualize. (fhandler_dev_raw::is_eof): Ditto. (class fhandler_dev_tape): Drop lasterr and dp member. Add mt_mtx member. Drop all private methods formerly used by ioctl. (fhandler_dev_tape::is_rewind_device): Use get_minor for clarity. (fhandler_dev_tape::driveno): New method. (fhandler_dev_tape::drive_init): New method. (fhandler_dev_tape::clear): Remove method. (fhandler_dev_tape::is_eom): Ditto. (fhandler_dev_tape::is_eof): Ditto. (fhandler_dev_tape::write_file): Ditto. (fhandler_dev_tape::read_file): Ditto. (fhandler_dev_tape::_lock): New method. (fhandler_dev_tape::unlock): New method. (fhandler_dev_tape::raw_read): New method. (fhandler_dev_tape::raw_write): New method. * fhandler_raw.cc (fhandler_dev_raw::is_eom): New method. (fhandler_dev_raw::is_eof): New method. (fhandler_dev_raw::open): Allow setting write through option by using the O_TEXT flag as ... flag. (fhandler_dev_raw::writebuf): Remove usage of varblkop and other tape specific code. (fhandler_dev_raw::raw_read): Ditto. (fhandler_dev_raw::dup): Ditto. * fhandler_tape.cc: Rewrite tape operations entirely. Implement new tape driver classes mtinfo, mtinfo_drive and mtinfo_part. Reduce fhandler_dev_tape methods to mostly just calling appropriate mtinfo_drive methods. (mtinfo_init): New function adding the mtinfo shared memory area. * mtinfo.h: New file, containing the definition of the new tape driver classes. * shared.cc: Include mtinfo.h. (offsets): Add entry for mtinfo shared memory area. (memory_init): Call mtinfo_init. * shared_info.h (shared_locations): Add SH_MTINFO shared location. * include/cygwin/mtio.h: Change and add various comments. Add GMT_xxx macros for new generic flags. Add MT_ST_xxx bitfield definitions for MTSETDRVBUFFER ioctl. * include/cygwin/version.h: Bump API minor version number.
2004-03-26 22:43:49 +01:00
HANDLE mt_mtx;
HANDLE mt_evt;
2000-02-17 20:38:33 +01:00
* errno.cc (errmap): Map ERROR_SHARING_VIOLATION to EBUSY, ERROR_EOM_OVERFLOW and ERROR_NO_DATA_DETECTED to EIO. Add mappings for ERROR_NO_MEDIA_IN_DRIVE, ERROR_DEVICE_REQUIRES_CLEANING and ERROR_DEVICE_DOOR_OPEN. * fhandler.h (class fhandler_dev_raw): Drop varblkop member. (fhandler_dev_raw::is_eom): De-virtualize. (fhandler_dev_raw::is_eof): Ditto. (class fhandler_dev_tape): Drop lasterr and dp member. Add mt_mtx member. Drop all private methods formerly used by ioctl. (fhandler_dev_tape::is_rewind_device): Use get_minor for clarity. (fhandler_dev_tape::driveno): New method. (fhandler_dev_tape::drive_init): New method. (fhandler_dev_tape::clear): Remove method. (fhandler_dev_tape::is_eom): Ditto. (fhandler_dev_tape::is_eof): Ditto. (fhandler_dev_tape::write_file): Ditto. (fhandler_dev_tape::read_file): Ditto. (fhandler_dev_tape::_lock): New method. (fhandler_dev_tape::unlock): New method. (fhandler_dev_tape::raw_read): New method. (fhandler_dev_tape::raw_write): New method. * fhandler_raw.cc (fhandler_dev_raw::is_eom): New method. (fhandler_dev_raw::is_eof): New method. (fhandler_dev_raw::open): Allow setting write through option by using the O_TEXT flag as ... flag. (fhandler_dev_raw::writebuf): Remove usage of varblkop and other tape specific code. (fhandler_dev_raw::raw_read): Ditto. (fhandler_dev_raw::dup): Ditto. * fhandler_tape.cc: Rewrite tape operations entirely. Implement new tape driver classes mtinfo, mtinfo_drive and mtinfo_part. Reduce fhandler_dev_tape methods to mostly just calling appropriate mtinfo_drive methods. (mtinfo_init): New function adding the mtinfo shared memory area. * mtinfo.h: New file, containing the definition of the new tape driver classes. * shared.cc: Include mtinfo.h. (offsets): Add entry for mtinfo shared memory area. (memory_init): Call mtinfo_init. * shared_info.h (shared_locations): Add SH_MTINFO shared location. * include/cygwin/mtio.h: Change and add various comments. Add GMT_xxx macros for new generic flags. Add MT_ST_xxx bitfield definitions for MTSETDRVBUFFER ioctl. * include/cygwin/version.h: Bump API minor version number.
2004-03-26 22:43:49 +01:00
bool is_rewind_device () { return get_minor () < 128; }
unsigned int driveno () { return (unsigned int) get_minor () & 0x7f; }
void drive_init ();
inline bool _lock (bool);
* errno.cc (errmap): Map ERROR_SHARING_VIOLATION to EBUSY, ERROR_EOM_OVERFLOW and ERROR_NO_DATA_DETECTED to EIO. Add mappings for ERROR_NO_MEDIA_IN_DRIVE, ERROR_DEVICE_REQUIRES_CLEANING and ERROR_DEVICE_DOOR_OPEN. * fhandler.h (class fhandler_dev_raw): Drop varblkop member. (fhandler_dev_raw::is_eom): De-virtualize. (fhandler_dev_raw::is_eof): Ditto. (class fhandler_dev_tape): Drop lasterr and dp member. Add mt_mtx member. Drop all private methods formerly used by ioctl. (fhandler_dev_tape::is_rewind_device): Use get_minor for clarity. (fhandler_dev_tape::driveno): New method. (fhandler_dev_tape::drive_init): New method. (fhandler_dev_tape::clear): Remove method. (fhandler_dev_tape::is_eom): Ditto. (fhandler_dev_tape::is_eof): Ditto. (fhandler_dev_tape::write_file): Ditto. (fhandler_dev_tape::read_file): Ditto. (fhandler_dev_tape::_lock): New method. (fhandler_dev_tape::unlock): New method. (fhandler_dev_tape::raw_read): New method. (fhandler_dev_tape::raw_write): New method. * fhandler_raw.cc (fhandler_dev_raw::is_eom): New method. (fhandler_dev_raw::is_eof): New method. (fhandler_dev_raw::open): Allow setting write through option by using the O_TEXT flag as ... flag. (fhandler_dev_raw::writebuf): Remove usage of varblkop and other tape specific code. (fhandler_dev_raw::raw_read): Ditto. (fhandler_dev_raw::dup): Ditto. * fhandler_tape.cc: Rewrite tape operations entirely. Implement new tape driver classes mtinfo, mtinfo_drive and mtinfo_part. Reduce fhandler_dev_tape methods to mostly just calling appropriate mtinfo_drive methods. (mtinfo_init): New function adding the mtinfo shared memory area. * mtinfo.h: New file, containing the definition of the new tape driver classes. * shared.cc: Include mtinfo.h. (offsets): Add entry for mtinfo shared memory area. (memory_init): Call mtinfo_init. * shared_info.h (shared_locations): Add SH_MTINFO shared location. * include/cygwin/mtio.h: Change and add various comments. Add GMT_xxx macros for new generic flags. Add MT_ST_xxx bitfield definitions for MTSETDRVBUFFER ioctl. * include/cygwin/version.h: Bump API minor version number.
2004-03-26 22:43:49 +01:00
inline int unlock (int ret = 0);
2000-02-17 20:38:33 +01:00
* dtable.cc (dtable::build_fhandler): Issue internal error on unknown device. * fhandler.cc (fhandler_base::close): Show both name and handle in debugging output. * fhandler.h (fhandler_base::get_guard): New virtual method. (fhandler_pipe::get_guard): New method. (fhandler_socket::ready_for_read): Delete declaration. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (struct select_record::peek): Declare new method. * select.cc (MAKEready): Delete. (peek_pipe): Use get_guard method to retrieve potential guard mutex handle. (fhandler_base::ready_for_read): Rewrite as generic ready-for-read handler. Should only be called for "slow" devices. (fhandler_socket::ready_for_read): Delete definition. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (fhandler_pipe::select_read): Fill in new peek record in select_record structure. (fhandler_console::select_read): Ditto. (fhandler_tty_common::select_read): Ditto. (fhandler_serial::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_tty_slave::ready_for_read): Check for tty not open. Set errnos appropriately. * syscalls.cc (_read): Allow ready_for_read to set errno. * pinfo.cc (pinfo::init): Return spawn/NO_WAIT process as valid if it is initializing. * sigproc.cc (getsem): Adjust wait for process to initialize downward to avoid huge waits.
2001-11-01 22:15:53 +01:00
public:
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
fhandler_dev_tape ();
2000-02-17 20:38:33 +01:00
* 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-06 00:30:53 +02:00
int open (int flags, mode_t mode = 0);
virtual int close ();
2000-02-17 20:38:33 +01:00
void __stdcall raw_read (void *ptr, size_t& ulen) __attribute__ ((regparm (3)));
ssize_t __stdcall raw_write (const void *ptr, size_t ulen) __attribute__ ((regparm (3)));
* errno.cc (errmap): Map ERROR_SHARING_VIOLATION to EBUSY, ERROR_EOM_OVERFLOW and ERROR_NO_DATA_DETECTED to EIO. Add mappings for ERROR_NO_MEDIA_IN_DRIVE, ERROR_DEVICE_REQUIRES_CLEANING and ERROR_DEVICE_DOOR_OPEN. * fhandler.h (class fhandler_dev_raw): Drop varblkop member. (fhandler_dev_raw::is_eom): De-virtualize. (fhandler_dev_raw::is_eof): Ditto. (class fhandler_dev_tape): Drop lasterr and dp member. Add mt_mtx member. Drop all private methods formerly used by ioctl. (fhandler_dev_tape::is_rewind_device): Use get_minor for clarity. (fhandler_dev_tape::driveno): New method. (fhandler_dev_tape::drive_init): New method. (fhandler_dev_tape::clear): Remove method. (fhandler_dev_tape::is_eom): Ditto. (fhandler_dev_tape::is_eof): Ditto. (fhandler_dev_tape::write_file): Ditto. (fhandler_dev_tape::read_file): Ditto. (fhandler_dev_tape::_lock): New method. (fhandler_dev_tape::unlock): New method. (fhandler_dev_tape::raw_read): New method. (fhandler_dev_tape::raw_write): New method. * fhandler_raw.cc (fhandler_dev_raw::is_eom): New method. (fhandler_dev_raw::is_eof): New method. (fhandler_dev_raw::open): Allow setting write through option by using the O_TEXT flag as ... flag. (fhandler_dev_raw::writebuf): Remove usage of varblkop and other tape specific code. (fhandler_dev_raw::raw_read): Ditto. (fhandler_dev_raw::dup): Ditto. * fhandler_tape.cc: Rewrite tape operations entirely. Implement new tape driver classes mtinfo, mtinfo_drive and mtinfo_part. Reduce fhandler_dev_tape methods to mostly just calling appropriate mtinfo_drive methods. (mtinfo_init): New function adding the mtinfo shared memory area. * mtinfo.h: New file, containing the definition of the new tape driver classes. * shared.cc: Include mtinfo.h. (offsets): Add entry for mtinfo shared memory area. (memory_init): Call mtinfo_init. * shared_info.h (shared_locations): Add SH_MTINFO shared location. * include/cygwin/mtio.h: Change and add various comments. Add GMT_xxx macros for new generic flags. Add MT_ST_xxx bitfield definitions for MTSETDRVBUFFER ioctl. * include/cygwin/version.h: Bump API minor version number.
2004-03-26 22:43:49 +01:00
virtual _off64_t lseek (_off64_t offset, int whence);
2000-02-17 20:38:33 +01:00
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
virtual int __stdcall fstat (struct __stat64 *buf) __attribute__ ((regparm (2)));
2000-02-17 20:38:33 +01:00
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
virtual int dup (fhandler_base *child, int);
virtual void fixup_after_fork (HANDLE parent);
virtual void set_close_on_exec (bool val);
* path.h (pathconv_arg): Add PC_POSIX. (path_conv): Add normalized_path field. * path.cc (path_conv::~path_conv): New destructor. (path_conv::check): Set normalized_path, where appropriate. * dtable.cc (build_fhandler_from_name): Use normalized path from path_conv. * syscalls.cc (chroot): Ditto. * cygheap.h: Remove path_prefix_p declaration. Christopher Faylor <cgf@redhat.com> (minor fixups) * Makefile.in: Add fhandler_proc.o, fhandler_registry.o, fhandler_process.o and fhandler_virtual.o. * dtable.cc (dtable::build_fhandler): Add entries for FH_PROC, FH_REGISTRY and FH_PROCESS. Set unix_name to the normalized posix path. * fhandler.h: Add constants for FH_PROC, FH_REGISTRY and FH_PROCESS. Add class declarations for fhandler_virtual, fhandler_proc, fhandler_registry and fhandler_virtual. Update fhandler_union accordingly. * fhandler_proc.cc: New file. Add implementation for fhandler_proc. * fhandler_virtual.cc: New file. Add implementation for fhandler_virtual. * fhandler_process.cc: New file. Add implementation for fhandler_process. * fhandler_registry.cc: New file. Add implementation for fhandler_registry. * path.cc: Add isproc and isvirtual_dev macros. * path.cc (path_conv::check): Add check for virtual devices. * path.cc (mount_info::conv_to_win32_path): Convert paths in /proc to empty Win32 paths. * path.cc (chdir): Replace check for FH_CYGDRIVE with more generic isvirtual_dev macro. Force setting of posix path for virtual fhandlers. * path.h: Add externally visible path_prefix_p and normalized_posix_path prototypes.
2002-05-02 06:13:48 +02:00
virtual int ioctl (unsigned int cmd, void *buf);
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
fhandler_dev_tape (void *) {}
void copyto (fhandler_base *x)
{
x->pc.free_strings ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
*reinterpret_cast<fhandler_dev_tape *> (x) = *this;
x->reset (this);
}
fhandler_dev_tape *clone (cygheap_types malloc_type = HEAP_FHANDLER)
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
{
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_dev_tape));
* fhandler.h (fhandler_pipe::create_selectable): Remove optional argument, take an options argument for CreateNamedPipe/CreateFile. Change handle arguments to expect pointers. (fhandler_fifo::fifo_state): Delete. (fhandler_fifo::dummy_client): Ditto. (fhandler_fifo::open_nonserver): Ditto. (fhandler_fifo::wait_state): Ditto. (fhandler_fifo::raw_write): Ditto. (fhandler_fifo::read_ready): New field. (fhandler_fifo::write_ready): Ditto. (fhandler_fifo::wait): Modify argument. (fhandler_fifo::fifo_name): Add a new argument. (fhandler_fifo::fixup_after_fork): New function. * fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Remove initialization of expunged elements. Initialize new handles to NULL. (fhandler_fifo::open_nonserver): Delete. (fnevent): New macro for creating a named event. (fnpipe): New macro for creating a unique named pipe name. (create_pipe): New macro for simplification of named pipe creation. (fhandler_fifo::fifo_name): Use new argument when creating a shared name. (fhandler_fifo::open): Rewrite. Use events to synchronize. (pure_debug_printf): New macro, active only when DEBUGGING. (fhandler_fifo::wait): Rewrite to wait for new fifo events which are supplied as a parameter. (fhandler_fifo::raw_read): Rewrite to use handle mechanism to detect client-side disconnect. (fhandler_fifo::raw_write): Delete. (fhandler_fifo::close): Remove accommodations for expunged fields. Close event handles. (fhandler_fifo::dup): Remove accommodations for expunged fields. Duplicate event handles. (fhandler_fifo::fixup_after_fork): New function. Perform fixups on event handles. (fhandler_fifo::set_close_on_exec): Remove accommodations for expunged fields. Set inheritance for new handle fields. * miscfuncs.cc (CreatePipeOverlapped): Accommodate changes in fhandler_pipe::create_selectable. * tty.cc (tty::not_allocated): Ditto. * pipe.cc (fhandler_pipe::create): Ditto. (fhandler_pipe::create_selectable): Accept an extra open_mode argument. Pass arguments by reference and allow opening one end of the pipe at a time. * sys/strace.h (debug_only_printf): Define new macro which calls debug_printf only when DEBUGGING is defined.
2011-10-30 05:50:36 +01:00
fhandler_dev_tape *fh = new (ptr) fhandler_dev_tape (ptr);
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
copyto (fh);
return fh;
}
2000-02-17 20:38:33 +01:00
};
/* Standard disk file */
class fhandler_disk_file: public fhandler_base
{
HANDLE prw_handle;
* dir.cc (readdir_worker): Drop dir parameter from call to readdir_get_ino. * fhandler.h (fhandler_disk_file::readdir_helper): Switch file name parameter to PUNICODE_STRING. * fhandler_disk_file.cc: Drop including ntdef.h. (class __DIR_mounts): Store mount points in UNICODE. Additionally store cygdrive prefix in unicode here. Change methods accordingly. (__DIR_mounts::eval_ino): Call new stat_worker instead of lstat64. (__DIR_mounts::~__DIR_mounts): New destructor to free UNICODE buffers. (path_conv::ndisk_links): Rewrite using native NT functions. (fhandler_base::fstat_by_handle): Use NAME_MAX instead of CYG_MAX_PATH. Always set pfvi->VolumeSerialNumber to non-0. Remove last resort code. (fhandler_base::fstat_by_name): Rewrite using native NT functions. (fhandler_base::fstat_fs): Always call fstat_by_name if fstat_by_handle fails. (fhandler_base::fstat_helper): Rely on dwVolumeSerialNumber. (fhandler_disk_file::facl): Call fstat_by_name if fstat_by_handle fails. (DIR_BUF_SIZE): Define using NAME_MAX instead of CYG_MAX_PATH. (__DIR_cache): Remove __name. (d_dirname): Remove. (fhandler_disk_file::opendir): Drop pathname length check. Remove outdated comment. Use get_name method instead of accessing pc.normalized_path directly. (readdir_get_ino): Drop unused dir parameter. Accomodate throughout. Allocate fname dynamically. Call new stat_worker instead of lstat64. Call NtOpenFile instead of CreateFile. Call NtClose instead of CloseHandle. (fhandler_disk_file::readdir_helper): Use native NT functions. Check for volume mount points and use correct inode number. (fhandler_disk_file::readdir): Simplify slightly. Use get_name instead of pc.normalized_path. (fhandler_disk_file::rewinddir): Use RtlInitUnicodeString. (fhandler_cygdrive::fstat): Ignore floppy drives. Set st_nlink correctly. (fhandler_cygdrive::readdir): Ignore floppy drives. * fhandler_netdrive.cc (fhandler_netdrive::readdir): Accommodate change to readdir_get_ino. * fhandler_proc.cc (PROC_DIR_COUNT): Define. (fhandler_proc::fstat): Evaluate correct link count for /proc. * ntdll.h (struct _FILE_DIRECTORY_INFORMATION): Define. (NtFsControlFile): Declare. (RtlAppendUnicodeToString): Declare. (RtlAppendUnicodeStringToString): Declare. (RtlCompareUnicodeString): Declare. (RtlCopyUnicodeString): Declare. (RtlCreateUnicodeStringFromAsciiz): Declare. (RtlEqualUnicodeString): Declare. (RtlFreeUnicodeString): Declare. (RtlInitEmptyUnicodeString): Declare. (RtlSecondsSince1970ToTime): Declare. (RtlInitEmptyUnicodeString): Define as inline function. (RtlInitCountedUnicodeString): Define as inline function. * path.cc (path_conv::check): New method with PUNICODE_STRING as path, preliminary implementation. (mount_info::get_mounts_here): Change to create UNICODE_STRINGs. Also copy cygpath prefix into UNICODE_STRING. (is_floppy): Drop 9x consideration. * path.h: Drop including ntdef.h. (path_conv::check): Add declaration. (path_conv::path_conv): Add constructor for UNICODE_STRING paths. * shared_info.h (mount_info::get_mounts_here): Change declaration. * syscalls.cc: Drop forward declaration of stat_worker. (stat_worke): Take path_conv as parameter. Drop nofollow flag. (stat64): Create matching path_conv and call stat_worker with it. (lstat64): Ditto. * winsup.h: Include ntdef.h. (stat_worker): Declare. (readdir_get_ino): Change declaration.
2007-07-26 19:30:54 +02:00
int readdir_helper (DIR *, dirent *, DWORD, DWORD, PUNICODE_STRING fname) __attribute__ ((regparm (3)));
int prw_open (bool);
* dtable.cc (dtable::build_fhandler): Issue internal error on unknown device. * fhandler.cc (fhandler_base::close): Show both name and handle in debugging output. * fhandler.h (fhandler_base::get_guard): New virtual method. (fhandler_pipe::get_guard): New method. (fhandler_socket::ready_for_read): Delete declaration. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (struct select_record::peek): Declare new method. * select.cc (MAKEready): Delete. (peek_pipe): Use get_guard method to retrieve potential guard mutex handle. (fhandler_base::ready_for_read): Rewrite as generic ready-for-read handler. Should only be called for "slow" devices. (fhandler_socket::ready_for_read): Delete definition. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (fhandler_pipe::select_read): Fill in new peek record in select_record structure. (fhandler_console::select_read): Ditto. (fhandler_tty_common::select_read): Ditto. (fhandler_serial::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_tty_slave::ready_for_read): Check for tty not open. Set errnos appropriately. * syscalls.cc (_read): Allow ready_for_read to set errno. * pinfo.cc (pinfo::init): Return spawn/NO_WAIT process as valid if it is initializing. * sigproc.cc (getsem): Adjust wait for process to initialize downward to avoid huge waits.
2001-11-01 22:15:53 +01:00
public:
fhandler_disk_file ();
fhandler_disk_file (path_conv &pc);
2000-02-17 20:38:33 +01:00
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
int open (int flags, mode_t mode);
int close ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
int dup (fhandler_base *child, int);
void fixup_after_fork (HANDLE parent);
int lock (int, struct __flock64 *);
bool isdevice () const { return false; }
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
int __stdcall fstat (struct __stat64 *buf) __attribute__ ((regparm (2)));
int __stdcall fchmod (mode_t mode) __attribute__ ((regparm (1)));
int __stdcall fchown (__uid32_t uid, __gid32_t gid) __attribute__ ((regparm (2)));
int __stdcall facl (int, int, __acl32 *) __attribute__ ((regparm (3)));
* Makefile.in (DLL_OFILES): Add ntea.o. * cygwin.din (getxattr, listxattr, removexattr, setxattr, lgetxattr, llistxattr, lremovexattr, lsetxattr, fgetxattr, flistxattr, fremovexattr, fsetxattr): Export Linux extended attribute functions. Sort. * errno.cc (errmap): Add mappings for ERROR_EAS_DIDNT_FIT, ERROR_EAS_NOT_SUPPORTED, ERROR_EA_LIST_INCONSISTENT, ERROR_EA_TABLE_FULL, ERROR_FILE_CORRUPT, ERROR_INVALID_EA_NAME. * fhandler.h (class fhandler_base): Declare new fgetxattr and fsetxattr methods. (class fhandler_disk_file): Ditto. * fhandler.cc (fhandler_base::fgetxattr): New method. (fhandler_base::fsetxattr): New method. * fhandler_disk_file.cc (fhandler_disk_file::fgetxattr): New method. (fhandler_disk_file::fsetxattr): New method. * ntdll.h (STATUS_EA_TOO_LARGE): Define. (STATUS_NONEXISTENT_EA_ENTRY): Define. (STATUS_NO_EAS_ON_FILE): Define. * ntea.cc (read_ea): Rewrite for long pathnames and for using with Linux extended attribute functions. (write_ea): Ditto. (getxattr_worker): New static function. (getxattr): New function. (lgetxattr): New function. (fgetxattr): New function. (listxattr): New function. (llistxattr): New function. (flistxattr): New function. (setxattr_worker): New static function. (setxattr): New function. (lsetxattr): New function. (fsetxattr): New function. (removexattr): New function. (lsetxattr): New function. (fsetxattr): New function. * security.h (read_ea): Change declaration according to above changes. (write_ea): Ditto. * include/cygwin/version.h: Bump API minor version.
2008-02-10 16:43:04 +01:00
ssize_t __stdcall fgetxattr (const char *, void *, size_t) __attribute__ ((regparm (3)));
int __stdcall fsetxattr (const char *, const void *, size_t, int) __attribute__ ((regparm (3)));
int __stdcall fadvise (_off64_t, _off64_t, int) __attribute__ ((regparm (3)));
int __stdcall ftruncate (_off64_t, bool) __attribute__ ((regparm (3)));
int __stdcall link (const char *) __attribute__ ((regparm (2)));
int __stdcall utimens (const struct timespec *) __attribute__ ((regparm (2)));
int __stdcall fstatvfs (struct statvfs *buf) __attribute__ ((regparm (2)));
* autoload.cc (NtCreateSection): Define. * cygheap.cc (_csbrk): Call getpagesize instead of getshmlba. * dcrt0.cc (dll_crt0_0): Call mmap_init. * external.cc (cygwin_internal): Call getpagesize instead of getshmlba. * fhandler.h (fhandler_base::mmap): Change access to prot parameter. (fhandler_base::fixup_mmap_after_fork): Ditto. (fhandler_disk_file::mmap): Ditto. (fhandler_disk_file::fixup_mmap_after_fork): Ditto. (fhandler_dev_mem::mmap): Ditto. (fhandler_dev_mem::fixup_mmap_after_fork): Ditto. * fhandler_mem.cc (fhandler_dev_mem::write): Call getsystempagesize instead of getpagesize. (fhandler_dev_mem::read): Ditto. (fhandler_dev_mem::fstat): Ditto. (fhandler_dev_mem::mmap): Move to mmap.cc. (fhandler_dev_mem::munmap): Ditto. (fhandler_dev_mem::msync): Ditto. (fhandler_dev_mem::fixup_mmap_after_fork): Ditto. * fhandler_proc.cc (format_proc_meminfo): Call getsystempagesize instead of getpagesize. * fhandler_process.cc (format_process_stat): Ditto. (format_process_status): Ditto. (get_mem_values): Ditto. * mmap.cc: Fix formatting. Try to make more readable and modular. Take advantage of pagesize==granularity. (gen_protect): New static function to evaluate Windows protection bits from POSIX protection and flags. (gen_access): Ditto for Windows access mode. (VirtualProt9x): Wrapper function to call VirtualProtect on 9x. (VirtualProtNT): Ditto for NT. (VirtualProtEx9x): Ditto for VirtualProtectEx on 9x. (VirtualProtExNT): Ditto for NT. (CreateMapping9x): Wrapper function for creating a mapping handle on 9x. (CreateMappingNT): Ditto for NT. (MapView9x): Wrapper function to map a view on 9x. (MapViewNT): Ditto for NT. (mmap_funcs_9x): Structure containing function pointers to wrapper functions for 9x. (mmap_funcs_nt): Ditto for NT. (mmap_func): Pointer to wrapper functions used in subsequent code. (mmap_init): Initialize mmap_func depending on OS. (class mmap_record): Use sensible member names. Add POSIX protection member. Drop Windows access flags member. Constify more methods. Use accessors instead of direct member access inside of own methods. (mmap_record::gen_protect): Class wrapper to evaluate matching Windows protection bits. (mmap_record::gen_access): Ditto for Windows access flags. (mmap_record::compatible_flags): New function to check if flags are compatible with flags of existing map. (list::add_record): Drop offset and length arguments. (class map): Change counters to unsigned. Match usage throughout. (mmapped_areas): Convert from pointer to global struct. (mmap_record::alloc_page_map): Simplify. (mmap_record::map_pages): Ditto. (mmap_record::fixup_page_map): Delete. (mmap64): Simplify. Add workaround for Windows 98 bug. Fix bug on NT that existing anonymous mappings weren't searched for a match. (munmap): Add workaround for Windows 98 bug. (msync): Simplify. (mprotect): Handle existing maps correctly. (mlock): Add local pagesize variable and enlightening comment. (fhandler_disk_file::mmap): Main functionality now in CreateMapping/ MapView wrapper functions. (fhandler_disk_file::fixup_mmap_after_fork): Call MapView wrapper. (fhandler_dev_mem::mmap): Moved from fhandler_mem.cc. Simplify by calling MapViewNT. (fhandler_dev_mem::munmap): Moved from fhandler_mem.cc. (fhandler_dev_mem::msync): Ditto. (fhandler_dev_mem::fixup_mmap_after_fork): Ditto. Call MapViewNT. (fixup_mmaps_after_fork): Restructure and hopefully speed up loop for setting protection and memory content on MAP_PRIVATE maps. * ntdll.h (AT_ROUND_TO_PAGE): Remove define. (AT_EXTENDABLE_FILE): Add define. (NtCreateSection): Add prototype. * syscalls.cc (getpagesize): Return granularity as pagesize now. (getsystempagesize): New function to retrieve "real" pagesize. (getshmlba): Delete since it's replaced by getpagesize now. * wincap.h (wincaps::has_mmap_alignment_bug): New element. * wincap.cc: Implement above element throughout. * winsup.h (getshmlba): Drop prototype. (getsystempagesize): Add prototype. (mmap_init): Ditto. * include/sys/mman.h: (Not yet) define MAP_NORESERVE.
2005-11-28 23:32:29 +01:00
HANDLE mmap (caddr_t *addr, size_t len, int prot, int flags, _off64_t off);
int munmap (HANDLE h, caddr_t addr, size_t len);
int msync (HANDLE h, caddr_t addr, size_t len, int flags);
* autoload.cc (NtCreateSection): Define. * cygheap.cc (_csbrk): Call getpagesize instead of getshmlba. * dcrt0.cc (dll_crt0_0): Call mmap_init. * external.cc (cygwin_internal): Call getpagesize instead of getshmlba. * fhandler.h (fhandler_base::mmap): Change access to prot parameter. (fhandler_base::fixup_mmap_after_fork): Ditto. (fhandler_disk_file::mmap): Ditto. (fhandler_disk_file::fixup_mmap_after_fork): Ditto. (fhandler_dev_mem::mmap): Ditto. (fhandler_dev_mem::fixup_mmap_after_fork): Ditto. * fhandler_mem.cc (fhandler_dev_mem::write): Call getsystempagesize instead of getpagesize. (fhandler_dev_mem::read): Ditto. (fhandler_dev_mem::fstat): Ditto. (fhandler_dev_mem::mmap): Move to mmap.cc. (fhandler_dev_mem::munmap): Ditto. (fhandler_dev_mem::msync): Ditto. (fhandler_dev_mem::fixup_mmap_after_fork): Ditto. * fhandler_proc.cc (format_proc_meminfo): Call getsystempagesize instead of getpagesize. * fhandler_process.cc (format_process_stat): Ditto. (format_process_status): Ditto. (get_mem_values): Ditto. * mmap.cc: Fix formatting. Try to make more readable and modular. Take advantage of pagesize==granularity. (gen_protect): New static function to evaluate Windows protection bits from POSIX protection and flags. (gen_access): Ditto for Windows access mode. (VirtualProt9x): Wrapper function to call VirtualProtect on 9x. (VirtualProtNT): Ditto for NT. (VirtualProtEx9x): Ditto for VirtualProtectEx on 9x. (VirtualProtExNT): Ditto for NT. (CreateMapping9x): Wrapper function for creating a mapping handle on 9x. (CreateMappingNT): Ditto for NT. (MapView9x): Wrapper function to map a view on 9x. (MapViewNT): Ditto for NT. (mmap_funcs_9x): Structure containing function pointers to wrapper functions for 9x. (mmap_funcs_nt): Ditto for NT. (mmap_func): Pointer to wrapper functions used in subsequent code. (mmap_init): Initialize mmap_func depending on OS. (class mmap_record): Use sensible member names. Add POSIX protection member. Drop Windows access flags member. Constify more methods. Use accessors instead of direct member access inside of own methods. (mmap_record::gen_protect): Class wrapper to evaluate matching Windows protection bits. (mmap_record::gen_access): Ditto for Windows access flags. (mmap_record::compatible_flags): New function to check if flags are compatible with flags of existing map. (list::add_record): Drop offset and length arguments. (class map): Change counters to unsigned. Match usage throughout. (mmapped_areas): Convert from pointer to global struct. (mmap_record::alloc_page_map): Simplify. (mmap_record::map_pages): Ditto. (mmap_record::fixup_page_map): Delete. (mmap64): Simplify. Add workaround for Windows 98 bug. Fix bug on NT that existing anonymous mappings weren't searched for a match. (munmap): Add workaround for Windows 98 bug. (msync): Simplify. (mprotect): Handle existing maps correctly. (mlock): Add local pagesize variable and enlightening comment. (fhandler_disk_file::mmap): Main functionality now in CreateMapping/ MapView wrapper functions. (fhandler_disk_file::fixup_mmap_after_fork): Call MapView wrapper. (fhandler_dev_mem::mmap): Moved from fhandler_mem.cc. Simplify by calling MapViewNT. (fhandler_dev_mem::munmap): Moved from fhandler_mem.cc. (fhandler_dev_mem::msync): Ditto. (fhandler_dev_mem::fixup_mmap_after_fork): Ditto. Call MapViewNT. (fixup_mmaps_after_fork): Restructure and hopefully speed up loop for setting protection and memory content on MAP_PRIVATE maps. * ntdll.h (AT_ROUND_TO_PAGE): Remove define. (AT_EXTENDABLE_FILE): Add define. (NtCreateSection): Add prototype. * syscalls.cc (getpagesize): Return granularity as pagesize now. (getsystempagesize): New function to retrieve "real" pagesize. (getshmlba): Delete since it's replaced by getpagesize now. * wincap.h (wincaps::has_mmap_alignment_bug): New element. * wincap.cc: Implement above element throughout. * winsup.h (getshmlba): Drop prototype. (getsystempagesize): Add prototype. (mmap_init): Ditto. * include/sys/mman.h: (Not yet) define MAP_NORESERVE.
2005-11-28 23:32:29 +01:00
bool fixup_mmap_after_fork (HANDLE h, int prot, int flags,
_off64_t offset, DWORD size, void *address);
int mkdir (mode_t mode);
int rmdir ();
DIR *opendir (int fd) __attribute__ ((regparm (2)));
int readdir (DIR *, dirent *) __attribute__ ((regparm (3)));
long telldir (DIR *);
void seekdir (DIR *, long);
void rewinddir (DIR *);
int closedir (DIR *);
ssize_t __stdcall pread (void *, size_t, _off64_t) __attribute__ ((regparm (3)));
ssize_t __stdcall pwrite (void *, size_t, _off64_t) __attribute__ ((regparm (3)));
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
fhandler_disk_file (void *) {}
void copyto (fhandler_base *x)
{
x->pc.free_strings ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
*reinterpret_cast<fhandler_disk_file *> (x) = *this;
x->reset (this);
}
fhandler_disk_file *clone (cygheap_types malloc_type = HEAP_FHANDLER)
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
{
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_disk_file));
* fhandler.h (fhandler_pipe::create_selectable): Remove optional argument, take an options argument for CreateNamedPipe/CreateFile. Change handle arguments to expect pointers. (fhandler_fifo::fifo_state): Delete. (fhandler_fifo::dummy_client): Ditto. (fhandler_fifo::open_nonserver): Ditto. (fhandler_fifo::wait_state): Ditto. (fhandler_fifo::raw_write): Ditto. (fhandler_fifo::read_ready): New field. (fhandler_fifo::write_ready): Ditto. (fhandler_fifo::wait): Modify argument. (fhandler_fifo::fifo_name): Add a new argument. (fhandler_fifo::fixup_after_fork): New function. * fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Remove initialization of expunged elements. Initialize new handles to NULL. (fhandler_fifo::open_nonserver): Delete. (fnevent): New macro for creating a named event. (fnpipe): New macro for creating a unique named pipe name. (create_pipe): New macro for simplification of named pipe creation. (fhandler_fifo::fifo_name): Use new argument when creating a shared name. (fhandler_fifo::open): Rewrite. Use events to synchronize. (pure_debug_printf): New macro, active only when DEBUGGING. (fhandler_fifo::wait): Rewrite to wait for new fifo events which are supplied as a parameter. (fhandler_fifo::raw_read): Rewrite to use handle mechanism to detect client-side disconnect. (fhandler_fifo::raw_write): Delete. (fhandler_fifo::close): Remove accommodations for expunged fields. Close event handles. (fhandler_fifo::dup): Remove accommodations for expunged fields. Duplicate event handles. (fhandler_fifo::fixup_after_fork): New function. Perform fixups on event handles. (fhandler_fifo::set_close_on_exec): Remove accommodations for expunged fields. Set inheritance for new handle fields. * miscfuncs.cc (CreatePipeOverlapped): Accommodate changes in fhandler_pipe::create_selectable. * tty.cc (tty::not_allocated): Ditto. * pipe.cc (fhandler_pipe::create): Ditto. (fhandler_pipe::create_selectable): Accept an extra open_mode argument. Pass arguments by reference and allow opening one end of the pipe at a time. * sys/strace.h (debug_only_printf): Define new macro which calls debug_printf only when DEBUGGING is defined.
2011-10-30 05:50:36 +01:00
fhandler_disk_file *fh = new (ptr) fhandler_disk_file (ptr);
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
copyto (fh);
return fh;
}
2000-02-17 20:38:33 +01:00
};
class fhandler_dev: public fhandler_disk_file
{
(Interim checkin while we work on this) * 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.
2012-03-31 19:38:00 +02:00
const struct device *devidx;
bool dir_exists;
public:
fhandler_dev ();
int open (int flags, mode_t mode);
int close ();
int __stdcall fstat (struct __stat64 *buf) __attribute__ ((regparm (2)));
int __stdcall fstatvfs (struct statvfs *buf) __attribute__ ((regparm (2)));
DIR *opendir (int fd) __attribute__ ((regparm (2)));
int readdir (DIR *, dirent *) __attribute__ ((regparm (3)));
void rewinddir (DIR *);
fhandler_dev (void *) {}
void copyto (fhandler_base *x)
{
x->pc.free_strings ();
*reinterpret_cast<fhandler_dev *> (x) = *this;
x->reset (this);
}
fhandler_dev *clone (cygheap_types malloc_type = HEAP_FHANDLER)
{
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_dev));
fhandler_dev *fh = new (ptr) fhandler_dev (ptr);
copyto (fh);
return fh;
}
};
* path.cc (conv_path_list): Fix wild indexing into path due to conflicting methods for setting src pointer. * dir.cc (opendir): Only pass path_conv argument to opendir, since name is already part of the fhandler. * dtable.cc (dtable::build_fhandler): Accomodate new FH_CYGDRIVE type. * fhandler.cc (fhandler_base::opendir): Nuke name argument. * fhandler.h: Add FH_CYGDRIVE to "device" enum. (fhandler_base::opendir): Nuke name argument. (fhandler_disk_file::opendir): Ditto. (fhandler_disk_file::fhandler_disk_file): Declare new method which passes devtype through. (fhandler_cygdrive): Add elements for tracking drives. (fhandler_cygdrive::set_drives): Declare new method. (fhandler_cygdrive::iscygdrive_root): Declare new method. (fhandler_cygdrive::opendir): Declare new method. (fhandler_cygdrive::readdir): Declare new method. (fhandler_cygdrive::telldir): Declare new method. (fhandler_cygdrive::seekdir): Declare new method. (fhandler_cygdrive::rewinddir): Declare new method. (fhandler_cygdrive::closedir): Declare new method. (fhandler_cygdrive::fstat): Declare new method. * fhandler_disk_file.cc (fhandler_disk_file::fhandler_disk_file): Define new method which passes devtype through. (fhandler_disk_file::open): Tweak debug output. (fhandler_disk_file::opendir): Nuke first argument. Use info from path_conv and class rather than calling fstat. (fhandler_cygdrive::set_drives): New method. (fhandler_cygdrive::iscygdrive_root): New method. (fhandler_cygdrive::opendir): New method. (fhandler_cygdrive::readdir): New method. (fhandler_cygdrive::telldir): New method. (fhandler_cygdrive::seekdir): New method. (fhandler_cygdrive::rewinddir): New method. (fhandler_cygdrive::closedir): New method. (fhandler_cygdrive::fstat): New method. * path.cc (iscygdrive_device): Assume cygdriveness is already verified. (path_conv::check): Treat FH_CYGDRIVE "method" as a special case, setting file attributes as needed. (mount_info::conv_to_win32_path): Allow stand-alone /cygdrive, meaning "the directory which contains all of the drives on the system". (fillout_mntent): Use cyg_tolower for conversions. (mount_info::cygdrive_win32_path): Replace unused argument with unit number. * shared_info.h (mount_info::cygdrive_win32_path): Reflect argument change.
2001-11-22 06:59:07 +01:00
class fhandler_cygdrive: public fhandler_disk_file
{
enum
{
DRVSZ = sizeof ("x:\\")
};
* path.cc (conv_path_list): Fix wild indexing into path due to conflicting methods for setting src pointer. * dir.cc (opendir): Only pass path_conv argument to opendir, since name is already part of the fhandler. * dtable.cc (dtable::build_fhandler): Accomodate new FH_CYGDRIVE type. * fhandler.cc (fhandler_base::opendir): Nuke name argument. * fhandler.h: Add FH_CYGDRIVE to "device" enum. (fhandler_base::opendir): Nuke name argument. (fhandler_disk_file::opendir): Ditto. (fhandler_disk_file::fhandler_disk_file): Declare new method which passes devtype through. (fhandler_cygdrive): Add elements for tracking drives. (fhandler_cygdrive::set_drives): Declare new method. (fhandler_cygdrive::iscygdrive_root): Declare new method. (fhandler_cygdrive::opendir): Declare new method. (fhandler_cygdrive::readdir): Declare new method. (fhandler_cygdrive::telldir): Declare new method. (fhandler_cygdrive::seekdir): Declare new method. (fhandler_cygdrive::rewinddir): Declare new method. (fhandler_cygdrive::closedir): Declare new method. (fhandler_cygdrive::fstat): Declare new method. * fhandler_disk_file.cc (fhandler_disk_file::fhandler_disk_file): Define new method which passes devtype through. (fhandler_disk_file::open): Tweak debug output. (fhandler_disk_file::opendir): Nuke first argument. Use info from path_conv and class rather than calling fstat. (fhandler_cygdrive::set_drives): New method. (fhandler_cygdrive::iscygdrive_root): New method. (fhandler_cygdrive::opendir): New method. (fhandler_cygdrive::readdir): New method. (fhandler_cygdrive::telldir): New method. (fhandler_cygdrive::seekdir): New method. (fhandler_cygdrive::rewinddir): New method. (fhandler_cygdrive::closedir): New method. (fhandler_cygdrive::fstat): New method. * path.cc (iscygdrive_device): Assume cygdriveness is already verified. (path_conv::check): Treat FH_CYGDRIVE "method" as a special case, setting file attributes as needed. (mount_info::conv_to_win32_path): Allow stand-alone /cygdrive, meaning "the directory which contains all of the drives on the system". (fillout_mntent): Use cyg_tolower for conversions. (mount_info::cygdrive_win32_path): Replace unused argument with unit number. * shared_info.h (mount_info::cygdrive_win32_path): Reflect argument change.
2001-11-22 06:59:07 +01:00
int ndrives;
const char *pdrive;
char pdrive_buf[1 + (2 * 26 * DRVSZ)];
* path.cc (conv_path_list): Fix wild indexing into path due to conflicting methods for setting src pointer. * dir.cc (opendir): Only pass path_conv argument to opendir, since name is already part of the fhandler. * dtable.cc (dtable::build_fhandler): Accomodate new FH_CYGDRIVE type. * fhandler.cc (fhandler_base::opendir): Nuke name argument. * fhandler.h: Add FH_CYGDRIVE to "device" enum. (fhandler_base::opendir): Nuke name argument. (fhandler_disk_file::opendir): Ditto. (fhandler_disk_file::fhandler_disk_file): Declare new method which passes devtype through. (fhandler_cygdrive): Add elements for tracking drives. (fhandler_cygdrive::set_drives): Declare new method. (fhandler_cygdrive::iscygdrive_root): Declare new method. (fhandler_cygdrive::opendir): Declare new method. (fhandler_cygdrive::readdir): Declare new method. (fhandler_cygdrive::telldir): Declare new method. (fhandler_cygdrive::seekdir): Declare new method. (fhandler_cygdrive::rewinddir): Declare new method. (fhandler_cygdrive::closedir): Declare new method. (fhandler_cygdrive::fstat): Declare new method. * fhandler_disk_file.cc (fhandler_disk_file::fhandler_disk_file): Define new method which passes devtype through. (fhandler_disk_file::open): Tweak debug output. (fhandler_disk_file::opendir): Nuke first argument. Use info from path_conv and class rather than calling fstat. (fhandler_cygdrive::set_drives): New method. (fhandler_cygdrive::iscygdrive_root): New method. (fhandler_cygdrive::opendir): New method. (fhandler_cygdrive::readdir): New method. (fhandler_cygdrive::telldir): New method. (fhandler_cygdrive::seekdir): New method. (fhandler_cygdrive::rewinddir): New method. (fhandler_cygdrive::closedir): New method. (fhandler_cygdrive::fstat): New method. * path.cc (iscygdrive_device): Assume cygdriveness is already verified. (path_conv::check): Treat FH_CYGDRIVE "method" as a special case, setting file attributes as needed. (mount_info::conv_to_win32_path): Allow stand-alone /cygdrive, meaning "the directory which contains all of the drives on the system". (fillout_mntent): Use cyg_tolower for conversions. (mount_info::cygdrive_win32_path): Replace unused argument with unit number. * shared_info.h (mount_info::cygdrive_win32_path): Reflect argument change.
2001-11-22 06:59:07 +01:00
void set_drives ();
public:
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
fhandler_cygdrive ();
int open (int flags, mode_t mode);
int close ();
DIR *opendir (int fd) __attribute__ ((regparm (2)));
int readdir (DIR *, dirent *) __attribute__ ((regparm (3)));
* path.cc (conv_path_list): Fix wild indexing into path due to conflicting methods for setting src pointer. * dir.cc (opendir): Only pass path_conv argument to opendir, since name is already part of the fhandler. * dtable.cc (dtable::build_fhandler): Accomodate new FH_CYGDRIVE type. * fhandler.cc (fhandler_base::opendir): Nuke name argument. * fhandler.h: Add FH_CYGDRIVE to "device" enum. (fhandler_base::opendir): Nuke name argument. (fhandler_disk_file::opendir): Ditto. (fhandler_disk_file::fhandler_disk_file): Declare new method which passes devtype through. (fhandler_cygdrive): Add elements for tracking drives. (fhandler_cygdrive::set_drives): Declare new method. (fhandler_cygdrive::iscygdrive_root): Declare new method. (fhandler_cygdrive::opendir): Declare new method. (fhandler_cygdrive::readdir): Declare new method. (fhandler_cygdrive::telldir): Declare new method. (fhandler_cygdrive::seekdir): Declare new method. (fhandler_cygdrive::rewinddir): Declare new method. (fhandler_cygdrive::closedir): Declare new method. (fhandler_cygdrive::fstat): Declare new method. * fhandler_disk_file.cc (fhandler_disk_file::fhandler_disk_file): Define new method which passes devtype through. (fhandler_disk_file::open): Tweak debug output. (fhandler_disk_file::opendir): Nuke first argument. Use info from path_conv and class rather than calling fstat. (fhandler_cygdrive::set_drives): New method. (fhandler_cygdrive::iscygdrive_root): New method. (fhandler_cygdrive::opendir): New method. (fhandler_cygdrive::readdir): New method. (fhandler_cygdrive::telldir): New method. (fhandler_cygdrive::seekdir): New method. (fhandler_cygdrive::rewinddir): New method. (fhandler_cygdrive::closedir): New method. (fhandler_cygdrive::fstat): New method. * path.cc (iscygdrive_device): Assume cygdriveness is already verified. (path_conv::check): Treat FH_CYGDRIVE "method" as a special case, setting file attributes as needed. (mount_info::conv_to_win32_path): Allow stand-alone /cygdrive, meaning "the directory which contains all of the drives on the system". (fillout_mntent): Use cyg_tolower for conversions. (mount_info::cygdrive_win32_path): Replace unused argument with unit number. * shared_info.h (mount_info::cygdrive_win32_path): Reflect argument change.
2001-11-22 06:59:07 +01:00
void rewinddir (DIR *);
int closedir (DIR *);
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
int __stdcall fstat (struct __stat64 *buf) __attribute__ ((regparm (2)));
int __stdcall fstatvfs (struct statvfs *buf) __attribute__ ((regparm (2)));
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
fhandler_cygdrive (void *) {}
void copyto (fhandler_base *x)
{
x->pc.free_strings ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
*reinterpret_cast<fhandler_cygdrive *> (x) = *this;
x->reset (this);
}
fhandler_cygdrive *clone (cygheap_types malloc_type = HEAP_FHANDLER)
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
{
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_cygdrive));
* fhandler.h (fhandler_pipe::create_selectable): Remove optional argument, take an options argument for CreateNamedPipe/CreateFile. Change handle arguments to expect pointers. (fhandler_fifo::fifo_state): Delete. (fhandler_fifo::dummy_client): Ditto. (fhandler_fifo::open_nonserver): Ditto. (fhandler_fifo::wait_state): Ditto. (fhandler_fifo::raw_write): Ditto. (fhandler_fifo::read_ready): New field. (fhandler_fifo::write_ready): Ditto. (fhandler_fifo::wait): Modify argument. (fhandler_fifo::fifo_name): Add a new argument. (fhandler_fifo::fixup_after_fork): New function. * fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Remove initialization of expunged elements. Initialize new handles to NULL. (fhandler_fifo::open_nonserver): Delete. (fnevent): New macro for creating a named event. (fnpipe): New macro for creating a unique named pipe name. (create_pipe): New macro for simplification of named pipe creation. (fhandler_fifo::fifo_name): Use new argument when creating a shared name. (fhandler_fifo::open): Rewrite. Use events to synchronize. (pure_debug_printf): New macro, active only when DEBUGGING. (fhandler_fifo::wait): Rewrite to wait for new fifo events which are supplied as a parameter. (fhandler_fifo::raw_read): Rewrite to use handle mechanism to detect client-side disconnect. (fhandler_fifo::raw_write): Delete. (fhandler_fifo::close): Remove accommodations for expunged fields. Close event handles. (fhandler_fifo::dup): Remove accommodations for expunged fields. Duplicate event handles. (fhandler_fifo::fixup_after_fork): New function. Perform fixups on event handles. (fhandler_fifo::set_close_on_exec): Remove accommodations for expunged fields. Set inheritance for new handle fields. * miscfuncs.cc (CreatePipeOverlapped): Accommodate changes in fhandler_pipe::create_selectable. * tty.cc (tty::not_allocated): Ditto. * pipe.cc (fhandler_pipe::create): Ditto. (fhandler_pipe::create_selectable): Accept an extra open_mode argument. Pass arguments by reference and allow opening one end of the pipe at a time. * sys/strace.h (debug_only_printf): Define new macro which calls debug_printf only when DEBUGGING is defined.
2011-10-30 05:50:36 +01:00
fhandler_cygdrive *fh = new (ptr) fhandler_cygdrive (ptr);
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
copyto (fh);
return fh;
}
* path.cc (conv_path_list): Fix wild indexing into path due to conflicting methods for setting src pointer. * dir.cc (opendir): Only pass path_conv argument to opendir, since name is already part of the fhandler. * dtable.cc (dtable::build_fhandler): Accomodate new FH_CYGDRIVE type. * fhandler.cc (fhandler_base::opendir): Nuke name argument. * fhandler.h: Add FH_CYGDRIVE to "device" enum. (fhandler_base::opendir): Nuke name argument. (fhandler_disk_file::opendir): Ditto. (fhandler_disk_file::fhandler_disk_file): Declare new method which passes devtype through. (fhandler_cygdrive): Add elements for tracking drives. (fhandler_cygdrive::set_drives): Declare new method. (fhandler_cygdrive::iscygdrive_root): Declare new method. (fhandler_cygdrive::opendir): Declare new method. (fhandler_cygdrive::readdir): Declare new method. (fhandler_cygdrive::telldir): Declare new method. (fhandler_cygdrive::seekdir): Declare new method. (fhandler_cygdrive::rewinddir): Declare new method. (fhandler_cygdrive::closedir): Declare new method. (fhandler_cygdrive::fstat): Declare new method. * fhandler_disk_file.cc (fhandler_disk_file::fhandler_disk_file): Define new method which passes devtype through. (fhandler_disk_file::open): Tweak debug output. (fhandler_disk_file::opendir): Nuke first argument. Use info from path_conv and class rather than calling fstat. (fhandler_cygdrive::set_drives): New method. (fhandler_cygdrive::iscygdrive_root): New method. (fhandler_cygdrive::opendir): New method. (fhandler_cygdrive::readdir): New method. (fhandler_cygdrive::telldir): New method. (fhandler_cygdrive::seekdir): New method. (fhandler_cygdrive::rewinddir): New method. (fhandler_cygdrive::closedir): New method. (fhandler_cygdrive::fstat): New method. * path.cc (iscygdrive_device): Assume cygdriveness is already verified. (path_conv::check): Treat FH_CYGDRIVE "method" as a special case, setting file attributes as needed. (mount_info::conv_to_win32_path): Allow stand-alone /cygdrive, meaning "the directory which contains all of the drives on the system". (fillout_mntent): Use cyg_tolower for conversions. (mount_info::cygdrive_win32_path): Replace unused argument with unit number. * shared_info.h (mount_info::cygdrive_win32_path): Reflect argument change.
2001-11-22 06:59:07 +01:00
};
2000-02-17 20:38:33 +01:00
class fhandler_serial: public fhandler_base
{
* dtable.cc (dtable::build_fhandler): Issue internal error on unknown device. * fhandler.cc (fhandler_base::close): Show both name and handle in debugging output. * fhandler.h (fhandler_base::get_guard): New virtual method. (fhandler_pipe::get_guard): New method. (fhandler_socket::ready_for_read): Delete declaration. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (struct select_record::peek): Declare new method. * select.cc (MAKEready): Delete. (peek_pipe): Use get_guard method to retrieve potential guard mutex handle. (fhandler_base::ready_for_read): Rewrite as generic ready-for-read handler. Should only be called for "slow" devices. (fhandler_socket::ready_for_read): Delete definition. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (fhandler_pipe::select_read): Fill in new peek record in select_record structure. (fhandler_console::select_read): Ditto. (fhandler_tty_common::select_read): Ditto. (fhandler_serial::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_tty_slave::ready_for_read): Check for tty not open. Set errnos appropriately. * syscalls.cc (_read): Allow ready_for_read to set errno. * pinfo.cc (pinfo::init): Return spawn/NO_WAIT process as valid if it is initializing. * sigproc.cc (getsem): Adjust wait for process to initialize downward to avoid huge waits.
2001-11-01 22:15:53 +01:00
private:
size_t vmin_; /* from termios */
2000-02-17 20:38:33 +01:00
unsigned int vtime_; /* from termios */
pid_t pgrp_;
int rts; /* for Windows 9x purposes only */
int dtr; /* for Windows 9x purposes only */
2000-02-17 20:38:33 +01:00
* dtable.cc (dtable::build_fhandler): Issue internal error on unknown device. * fhandler.cc (fhandler_base::close): Show both name and handle in debugging output. * fhandler.h (fhandler_base::get_guard): New virtual method. (fhandler_pipe::get_guard): New method. (fhandler_socket::ready_for_read): Delete declaration. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (struct select_record::peek): Declare new method. * select.cc (MAKEready): Delete. (peek_pipe): Use get_guard method to retrieve potential guard mutex handle. (fhandler_base::ready_for_read): Rewrite as generic ready-for-read handler. Should only be called for "slow" devices. (fhandler_socket::ready_for_read): Delete definition. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (fhandler_pipe::select_read): Fill in new peek record in select_record structure. (fhandler_console::select_read): Ditto. (fhandler_tty_common::select_read): Ditto. (fhandler_serial::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_tty_slave::ready_for_read): Check for tty not open. Set errnos appropriately. * syscalls.cc (_read): Allow ready_for_read to set errno. * pinfo.cc (pinfo::init): Return spawn/NO_WAIT process as valid if it is initializing. * sigproc.cc (getsem): Adjust wait for process to initialize downward to avoid huge waits.
2001-11-01 22:15:53 +01:00
public:
2000-02-17 20:38:33 +01:00
int overlapped_armed;
OVERLAPPED io_status;
DWORD ev;
2000-02-17 20:38:33 +01:00
/* Constructor */
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
fhandler_serial ();
2000-02-17 20:38:33 +01:00
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
int open (int flags, mode_t mode);
2000-02-17 20:38:33 +01:00
int close ();
int init (HANDLE h, DWORD a, mode_t flags);
2000-02-17 20:38:33 +01:00
void overlapped_setup ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
int dup (fhandler_base *child, int);
void __stdcall raw_read (void *ptr, size_t& ulen) __attribute__ ((regparm (3)));
ssize_t __stdcall raw_write (const void *ptr, size_t ulen) __attribute__ ((regparm (3)));
2000-02-17 20:38:33 +01:00
int tcsendbreak (int);
int tcdrain ();
int tcflow (int);
int ioctl (unsigned int cmd, void *);
int switch_modem_lines (int set, int clr);
2000-02-17 20:38:33 +01:00
int tcsetattr (int a, const struct termios *t);
int tcgetattr (struct termios *t);
_off64_t lseek (_off64_t, int) { return 0; }
2000-02-17 20:38:33 +01:00
int tcflush (int);
bool is_tty () const { return true; }
2000-02-17 20:38:33 +01:00
void fixup_after_fork (HANDLE parent);
void fixup_after_exec ();
2000-02-17 20:38:33 +01:00
/* We maintain a pgrp so that tcsetpgrp and tcgetpgrp work, but we
* 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-14 23:48:43 +02:00
don't use it for permissions checking. fhandler_pty_slave does
2000-02-17 20:38:33 +01:00
permission checking on pgrps. */
virtual int tcgetpgrp () { return pgrp_; }
virtual int tcsetpgrp (const pid_t pid) { pgrp_ = pid; return 0; }
* select.h: New file split from fhandler.h. (select_record::select_record): Define do-nothing constructor for "new" to avoid gratuitous zeroing. (select_info): New base class. (select_pipe_info): New class with methods for dealing with pipes. (select_socket_info): New class with methods for dealing with sockets. (select_serial_info): Dummy class for serial. (select_mailslot_info): Dummy class for mailslots. (select_stuff): Define device_specific_* as actual classes rather than void *. * dtable.h (dtable::select_read): Accommodate return value change to 'bool' and argument change to "select_stuff". (dtable::select_write): Ditto. (dtable::select_except): Ditto. * dtable.cc (dtable::select_read): Accommodate return value change to 'bool' and argument change to "select_stuff". (dtable::select_write): Ditto. (dtable::select_except): Ditto. * fhandler.h: Excise select-related classes. (fhandler_*::select_read): Change argument to select_stuff. (fhandler_*::select_write): Ditto. (fhandler_*::select_except): Ditto. * select.cc (UNIX_FD_ZERO): Use memset rather than bzero. (select_stuff::test_and_set): Change return type to bool. Allocate select_record on entry and let fhandler_*::select_* operate on the start.next field of select_stuff. (pipeinf): Delete. (select_pipe_info::select_pipe_info): New constructor. Allocates event for controlling pipe waits. (select_pipe_info::~select_pipe_info): New destructor. Destroy event. Stop thread. (select_pipe_info::add_watch_handle): New function. (thread_pipe): Wait for the hEvent part of any overlapped pipes before peeking. (start_thread_pipe): Don't allocate device_specific_pipe stuff here. Assume that it has been allocated earlier. (pipe_cleanup): Rely on select_pipe_info destructor to clean up pipe paraphenalia. (fhandler_*::select_*): Derive select_record from new select_stuff argument. (fhandler_pipe::select_*): Ditto. Allocate pipe-specific field if not already allocated. (serialinf): Delete. (thread_serial): serialinf -> select_serial_info. (fhandler_base::ready_for_read): Rewrite to accommodate change in argument to fhandler_*::select_*. (socketinf): Delete. (thread_socket): socketinf -> select_socket_info. (mailslotinf): Delete. (thread_mailslot): mailslotinf -> select_mailslot_info.
2009-06-30 23:18:44 +02:00
select_record *select_read (select_stuff *);
select_record *select_write (select_stuff *);
select_record *select_except (select_stuff *);
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
fhandler_serial (void *) {}
void copyto (fhandler_base *x)
{
x->pc.free_strings ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
*reinterpret_cast<fhandler_serial *> (x) = *this;
x->reset (this);
}
fhandler_serial *clone (cygheap_types malloc_type = HEAP_FHANDLER)
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
{
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_serial));
* fhandler.h (fhandler_pipe::create_selectable): Remove optional argument, take an options argument for CreateNamedPipe/CreateFile. Change handle arguments to expect pointers. (fhandler_fifo::fifo_state): Delete. (fhandler_fifo::dummy_client): Ditto. (fhandler_fifo::open_nonserver): Ditto. (fhandler_fifo::wait_state): Ditto. (fhandler_fifo::raw_write): Ditto. (fhandler_fifo::read_ready): New field. (fhandler_fifo::write_ready): Ditto. (fhandler_fifo::wait): Modify argument. (fhandler_fifo::fifo_name): Add a new argument. (fhandler_fifo::fixup_after_fork): New function. * fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Remove initialization of expunged elements. Initialize new handles to NULL. (fhandler_fifo::open_nonserver): Delete. (fnevent): New macro for creating a named event. (fnpipe): New macro for creating a unique named pipe name. (create_pipe): New macro for simplification of named pipe creation. (fhandler_fifo::fifo_name): Use new argument when creating a shared name. (fhandler_fifo::open): Rewrite. Use events to synchronize. (pure_debug_printf): New macro, active only when DEBUGGING. (fhandler_fifo::wait): Rewrite to wait for new fifo events which are supplied as a parameter. (fhandler_fifo::raw_read): Rewrite to use handle mechanism to detect client-side disconnect. (fhandler_fifo::raw_write): Delete. (fhandler_fifo::close): Remove accommodations for expunged fields. Close event handles. (fhandler_fifo::dup): Remove accommodations for expunged fields. Duplicate event handles. (fhandler_fifo::fixup_after_fork): New function. Perform fixups on event handles. (fhandler_fifo::set_close_on_exec): Remove accommodations for expunged fields. Set inheritance for new handle fields. * miscfuncs.cc (CreatePipeOverlapped): Accommodate changes in fhandler_pipe::create_selectable. * tty.cc (tty::not_allocated): Ditto. * pipe.cc (fhandler_pipe::create): Ditto. (fhandler_pipe::create_selectable): Accept an extra open_mode argument. Pass arguments by reference and allow opening one end of the pipe at a time. * sys/strace.h (debug_only_printf): Define new macro which calls debug_printf only when DEBUGGING is defined.
2011-10-30 05:50:36 +01:00
fhandler_serial *fh = new (ptr) fhandler_serial (ptr);
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
copyto (fh);
return fh;
}
2000-02-17 20:38:33 +01:00
};
#define acquire_output_mutex(ms) \
__acquire_output_mutex (__PRETTY_FUNCTION__, __LINE__, ms)
#define release_output_mutex() \
__release_output_mutex (__PRETTY_FUNCTION__, __LINE__)
class tty;
class tty_min;
2000-02-17 20:38:33 +01:00
class fhandler_termios: public fhandler_base
{
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
private:
2000-02-17 20:38:33 +01:00
HANDLE output_handle;
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
protected:
virtual void doecho (const void *, DWORD) {};
2000-02-17 20:38:33 +01:00
virtual int accept_input () {return 1;};
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
int ioctl (int, void *);
* 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-06-04 02:12:29 +02:00
tty_min *_tc;
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
tty *get_ttyp () {return (tty *) tc ();}
public:
tty_min*& tc () {return _tc;}
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
fhandler_termios () :
fhandler_base ()
2000-02-17 20:38:33 +01:00
{
* Use new unified status_flag accessor methods from classes fhandler_*, tty_min, mtinfo and fs_info thoroughout. * fhandler.h: Redefine all set_close_on_exec methods to take a bool argument. (enum conn_state): Rename from connect_state. (class fhandler_base): Rename some status flags to align with accessor method names. Drop encoded flag entirely. Unify status accessor methods. Const'ify all read accessor methods. (class fhandler_socket): Ditto. (class fhandler_dev_raw): Ditto. * fhandler_disk_file.cc (fhandler_base::fstat_fs): Use fs.fs_is_fat() instead of evaluating FATness of file system here. (fhandler_disk_file::opendir): Drop call to set_encoded(). (fhandler_disk_file::readdir): Use pc.isencoded() directly. * mtinfo.h (class mtinfo_drive): Const'ify all read accessor methods. * path.cc (fsinfo_cnt): Add. (fs_info::update): Accomodate class changes. Evaluate file system name specific flags right here. Add thread safety for reading and writing global fsinfo array. * path.h (enum path_types): Drop values for flags kept in fs already. (struct fs_info): Move status informatin into private struct type status_flags. Add accessor methods. Remove path and file system name string arrays in favor of status bits. (class path_conv): Use new fs_info status information where appropriate. (path_conf::fs_has_ea): Rename from fs_fast_ea. (path_conf::fs_has_acls): New method. (path_conf::root_dir): Remove. (path_conf::volname): Remove. * syscalls (statfs): Evaluate root dir locally. * tty.h (class tty_min): Unify status accessor methods. Const'ify all read accessor methods.
2004-04-10 15:45:10 +02:00
need_fork_fixup (true);
2000-02-17 20:38:33 +01:00
}
HANDLE& get_output_handle () { return output_handle; }
line_edit_status line_edit (const char *rptr, int nread, termios&);
2000-02-17 20:38:33 +01:00
void set_output_handle (HANDLE h) { output_handle = h; }
* 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-06-04 02:12:29 +02:00
void tcinit (bool force);
bool is_tty () const { return true; }
void sigflush ();
2000-02-17 20:38:33 +01:00
int tcgetpgrp ();
int tcsetpgrp (int pid);
bg_check_types bg_check (int sig);
virtual DWORD __acquire_output_mutex (const char *fn, int ln, DWORD ms) {return 1;}
virtual void __release_output_mutex (const char *fn, int ln) {}
void echo_erase (int force = 0);
virtual _off64_t lseek (_off64_t, int);
pid_t tcgetsid ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
fhandler_termios (void *) {}
virtual void copyto (fhandler_base *x)
{
x->pc.free_strings ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
*reinterpret_cast<fhandler_termios *> (x) = *this;
x->reset (this);
}
virtual fhandler_termios *clone (cygheap_types malloc_type = HEAP_FHANDLER)
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
{
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_termios));
* fhandler.h (fhandler_pipe::create_selectable): Remove optional argument, take an options argument for CreateNamedPipe/CreateFile. Change handle arguments to expect pointers. (fhandler_fifo::fifo_state): Delete. (fhandler_fifo::dummy_client): Ditto. (fhandler_fifo::open_nonserver): Ditto. (fhandler_fifo::wait_state): Ditto. (fhandler_fifo::raw_write): Ditto. (fhandler_fifo::read_ready): New field. (fhandler_fifo::write_ready): Ditto. (fhandler_fifo::wait): Modify argument. (fhandler_fifo::fifo_name): Add a new argument. (fhandler_fifo::fixup_after_fork): New function. * fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Remove initialization of expunged elements. Initialize new handles to NULL. (fhandler_fifo::open_nonserver): Delete. (fnevent): New macro for creating a named event. (fnpipe): New macro for creating a unique named pipe name. (create_pipe): New macro for simplification of named pipe creation. (fhandler_fifo::fifo_name): Use new argument when creating a shared name. (fhandler_fifo::open): Rewrite. Use events to synchronize. (pure_debug_printf): New macro, active only when DEBUGGING. (fhandler_fifo::wait): Rewrite to wait for new fifo events which are supplied as a parameter. (fhandler_fifo::raw_read): Rewrite to use handle mechanism to detect client-side disconnect. (fhandler_fifo::raw_write): Delete. (fhandler_fifo::close): Remove accommodations for expunged fields. Close event handles. (fhandler_fifo::dup): Remove accommodations for expunged fields. Duplicate event handles. (fhandler_fifo::fixup_after_fork): New function. Perform fixups on event handles. (fhandler_fifo::set_close_on_exec): Remove accommodations for expunged fields. Set inheritance for new handle fields. * miscfuncs.cc (CreatePipeOverlapped): Accommodate changes in fhandler_pipe::create_selectable. * tty.cc (tty::not_allocated): Ditto. * pipe.cc (fhandler_pipe::create): Ditto. (fhandler_pipe::create_selectable): Accept an extra open_mode argument. Pass arguments by reference and allow opening one end of the pipe at a time. * sys/strace.h (debug_only_printf): Define new macro which calls debug_printf only when DEBUGGING is defined.
2011-10-30 05:50:36 +01:00
fhandler_termios *fh = new (ptr) fhandler_termios (ptr);
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
copyto (fh);
return fh;
}
2000-02-17 20:38:33 +01:00
};
* fhandler.h (class fhandler_console): Make all variables that describe "state" of console to be members of fhandler_console. default_color is now the color which is set when console recieves reset command. * fhandler_console.cc (fhandler_console::fhandler_console): Turn mouse handling and raw keyboard mode off by default. Initialize state information. * fhandler.cc (fhandler_console::set_raw_win32_keyboard_mode): New function. * fhandler_console.cc (fhandler_console::set_default_attr): New function. Reset console attributes to default values. * fhandler_console.cc (fhandler_console::open): Reset attributes. * fhandler_console.cc (fhandler_console::get_win32_attr): New function. Calculate win32-style console attribute based on terminal attributes. * fhandler_console.cc (fhandler_console::set_cursor_maybe): Use member variable. * fhandler_console.cc (fhandler_console::read): If in raw-win32 keyboard mode, encode win32 keyboard events in \033{x;y;z;t;u;wK sequences. * fhandler_console.cc (fhandler_console::dup): Copy all state information to the dup()ed handle. * fhandler_console.cc (fhandler_console::scroll_screen): Use current fill-in attribute. * fhandler_console.cc (fhandler_console::clear_screen): Ditto. * fhandler_console.cc (fhandler_console::char_command): Check if we saw '?' symbol by member variable. Set terminal attributes on \033[Xm commands. \033[24m - turn off underline mode, \033[27m - turn off reverse mode, \033[39m - restore default foreground color. \033[49m - restore default background color. \033[2000h - turn on raw keyboard mode, \033[2000l - turn off raw keyboard mode. * fhandler_console.cc (fhandler_console::write): Set attribues to default values on reset command.
2001-02-27 10:14:35 +01:00
enum ansi_intensity
2000-02-17 20:38:33 +01:00
{
* fhandler.h (class fhandler_console): Make all variables that describe "state" of console to be members of fhandler_console. default_color is now the color which is set when console recieves reset command. * fhandler_console.cc (fhandler_console::fhandler_console): Turn mouse handling and raw keyboard mode off by default. Initialize state information. * fhandler.cc (fhandler_console::set_raw_win32_keyboard_mode): New function. * fhandler_console.cc (fhandler_console::set_default_attr): New function. Reset console attributes to default values. * fhandler_console.cc (fhandler_console::open): Reset attributes. * fhandler_console.cc (fhandler_console::get_win32_attr): New function. Calculate win32-style console attribute based on terminal attributes. * fhandler_console.cc (fhandler_console::set_cursor_maybe): Use member variable. * fhandler_console.cc (fhandler_console::read): If in raw-win32 keyboard mode, encode win32 keyboard events in \033{x;y;z;t;u;wK sequences. * fhandler_console.cc (fhandler_console::dup): Copy all state information to the dup()ed handle. * fhandler_console.cc (fhandler_console::scroll_screen): Use current fill-in attribute. * fhandler_console.cc (fhandler_console::clear_screen): Ditto. * fhandler_console.cc (fhandler_console::char_command): Check if we saw '?' symbol by member variable. Set terminal attributes on \033[Xm commands. \033[24m - turn off underline mode, \033[27m - turn off reverse mode, \033[39m - restore default foreground color. \033[49m - restore default background color. \033[2000h - turn on raw keyboard mode, \033[2000l - turn off raw keyboard mode. * fhandler_console.cc (fhandler_console::write): Set attribues to default values on reset command.
2001-02-27 10:14:35 +01:00
INTENSITY_INVISIBLE,
INTENSITY_DIM,
INTENSITY_NORMAL,
INTENSITY_BOLD
};
2000-02-17 20:38:33 +01:00
#define normal 0
#define gotesc 1
#define gotsquare 2
#define gotarg1 3
#define gotrsquare 4
#define gotcommand 5
#define gettitle 6
#define eattitle 7
#define gotparen 8
#define gotrparen 9
2000-02-17 20:38:33 +01:00
#define MAXARGS 10
* fhandler.h (class fhandler_console): Make all variables that describe "state" of console to be members of fhandler_console. default_color is now the color which is set when console recieves reset command. * fhandler_console.cc (fhandler_console::fhandler_console): Turn mouse handling and raw keyboard mode off by default. Initialize state information. * fhandler.cc (fhandler_console::set_raw_win32_keyboard_mode): New function. * fhandler_console.cc (fhandler_console::set_default_attr): New function. Reset console attributes to default values. * fhandler_console.cc (fhandler_console::open): Reset attributes. * fhandler_console.cc (fhandler_console::get_win32_attr): New function. Calculate win32-style console attribute based on terminal attributes. * fhandler_console.cc (fhandler_console::set_cursor_maybe): Use member variable. * fhandler_console.cc (fhandler_console::read): If in raw-win32 keyboard mode, encode win32 keyboard events in \033{x;y;z;t;u;wK sequences. * fhandler_console.cc (fhandler_console::dup): Copy all state information to the dup()ed handle. * fhandler_console.cc (fhandler_console::scroll_screen): Use current fill-in attribute. * fhandler_console.cc (fhandler_console::clear_screen): Ditto. * fhandler_console.cc (fhandler_console::char_command): Check if we saw '?' symbol by member variable. Set terminal attributes on \033[Xm commands. \033[24m - turn off underline mode, \033[27m - turn off reverse mode, \033[39m - restore default foreground color. \033[49m - restore default background color. \033[2000h - turn on raw keyboard mode, \033[2000l - turn off raw keyboard mode. * fhandler_console.cc (fhandler_console::write): Set attribues to default values on reset command.
2001-02-27 10:14:35 +01:00
class dev_console
* fhandler.h (class fhandler_console): Make all variables that describe "state" of console to be members of fhandler_console. default_color is now the color which is set when console recieves reset command. * fhandler_console.cc (fhandler_console::fhandler_console): Turn mouse handling and raw keyboard mode off by default. Initialize state information. * fhandler.cc (fhandler_console::set_raw_win32_keyboard_mode): New function. * fhandler_console.cc (fhandler_console::set_default_attr): New function. Reset console attributes to default values. * fhandler_console.cc (fhandler_console::open): Reset attributes. * fhandler_console.cc (fhandler_console::get_win32_attr): New function. Calculate win32-style console attribute based on terminal attributes. * fhandler_console.cc (fhandler_console::set_cursor_maybe): Use member variable. * fhandler_console.cc (fhandler_console::read): If in raw-win32 keyboard mode, encode win32 keyboard events in \033{x;y;z;t;u;wK sequences. * fhandler_console.cc (fhandler_console::dup): Copy all state information to the dup()ed handle. * fhandler_console.cc (fhandler_console::scroll_screen): Use current fill-in attribute. * fhandler_console.cc (fhandler_console::clear_screen): Ditto. * fhandler_console.cc (fhandler_console::char_command): Check if we saw '?' symbol by member variable. Set terminal attributes on \033[Xm commands. \033[24m - turn off underline mode, \033[27m - turn off reverse mode, \033[39m - restore default foreground color. \033[49m - restore default background color. \033[2000h - turn on raw keyboard mode, \033[2000l - turn off raw keyboard mode. * fhandler_console.cc (fhandler_console::write): Set attribues to default values on reset command.
2001-02-27 10:14:35 +01:00
{
WORD default_color, underline_color, dim_color;
/* Used to determine if an input keystroke should be modified with META. */
int meta_mask;
* fhandler.h (class fhandler_console): Make all variables that describe "state" of console to be members of fhandler_console. default_color is now the color which is set when console recieves reset command. * fhandler_console.cc (fhandler_console::fhandler_console): Turn mouse handling and raw keyboard mode off by default. Initialize state information. * fhandler.cc (fhandler_console::set_raw_win32_keyboard_mode): New function. * fhandler_console.cc (fhandler_console::set_default_attr): New function. Reset console attributes to default values. * fhandler_console.cc (fhandler_console::open): Reset attributes. * fhandler_console.cc (fhandler_console::get_win32_attr): New function. Calculate win32-style console attribute based on terminal attributes. * fhandler_console.cc (fhandler_console::set_cursor_maybe): Use member variable. * fhandler_console.cc (fhandler_console::read): If in raw-win32 keyboard mode, encode win32 keyboard events in \033{x;y;z;t;u;wK sequences. * fhandler_console.cc (fhandler_console::dup): Copy all state information to the dup()ed handle. * fhandler_console.cc (fhandler_console::scroll_screen): Use current fill-in attribute. * fhandler_console.cc (fhandler_console::clear_screen): Ditto. * fhandler_console.cc (fhandler_console::char_command): Check if we saw '?' symbol by member variable. Set terminal attributes on \033[Xm commands. \033[24m - turn off underline mode, \033[27m - turn off reverse mode, \033[39m - restore default foreground color. \033[49m - restore default background color. \033[2000h - turn on raw keyboard mode, \033[2000l - turn off raw keyboard mode. * fhandler_console.cc (fhandler_console::write): Set attribues to default values on reset command.
2001-02-27 10:14:35 +01:00
/* Output state */
2000-02-17 20:38:33 +01:00
int state_;
int args_[MAXARGS];
int nargs_;
* fhandler.h (class fhandler_console): Make all variables that describe "state" of console to be members of fhandler_console. default_color is now the color which is set when console recieves reset command. * fhandler_console.cc (fhandler_console::fhandler_console): Turn mouse handling and raw keyboard mode off by default. Initialize state information. * fhandler.cc (fhandler_console::set_raw_win32_keyboard_mode): New function. * fhandler_console.cc (fhandler_console::set_default_attr): New function. Reset console attributes to default values. * fhandler_console.cc (fhandler_console::open): Reset attributes. * fhandler_console.cc (fhandler_console::get_win32_attr): New function. Calculate win32-style console attribute based on terminal attributes. * fhandler_console.cc (fhandler_console::set_cursor_maybe): Use member variable. * fhandler_console.cc (fhandler_console::read): If in raw-win32 keyboard mode, encode win32 keyboard events in \033{x;y;z;t;u;wK sequences. * fhandler_console.cc (fhandler_console::dup): Copy all state information to the dup()ed handle. * fhandler_console.cc (fhandler_console::scroll_screen): Use current fill-in attribute. * fhandler_console.cc (fhandler_console::clear_screen): Ditto. * fhandler_console.cc (fhandler_console::char_command): Check if we saw '?' symbol by member variable. Set terminal attributes on \033[Xm commands. \033[24m - turn off underline mode, \033[27m - turn off reverse mode, \033[39m - restore default foreground color. \033[49m - restore default background color. \033[2000h - turn on raw keyboard mode, \033[2000l - turn off raw keyboard mode. * fhandler_console.cc (fhandler_console::write): Set attribues to default values on reset command.
2001-02-27 10:14:35 +01:00
unsigned rarg;
bool saw_question_mark;
bool saw_greater_than_sign;
bool vt100_graphics_mode_G0;
bool vt100_graphics_mode_G1;
bool iso_2022_G1;
bool alternate_charset_active;
bool metabit;
char backspace_keycode;
* fhandler.h (class fhandler_console): Make all variables that describe "state" of console to be members of fhandler_console. default_color is now the color which is set when console recieves reset command. * fhandler_console.cc (fhandler_console::fhandler_console): Turn mouse handling and raw keyboard mode off by default. Initialize state information. * fhandler.cc (fhandler_console::set_raw_win32_keyboard_mode): New function. * fhandler_console.cc (fhandler_console::set_default_attr): New function. Reset console attributes to default values. * fhandler_console.cc (fhandler_console::open): Reset attributes. * fhandler_console.cc (fhandler_console::get_win32_attr): New function. Calculate win32-style console attribute based on terminal attributes. * fhandler_console.cc (fhandler_console::set_cursor_maybe): Use member variable. * fhandler_console.cc (fhandler_console::read): If in raw-win32 keyboard mode, encode win32 keyboard events in \033{x;y;z;t;u;wK sequences. * fhandler_console.cc (fhandler_console::dup): Copy all state information to the dup()ed handle. * fhandler_console.cc (fhandler_console::scroll_screen): Use current fill-in attribute. * fhandler_console.cc (fhandler_console::clear_screen): Ditto. * fhandler_console.cc (fhandler_console::char_command): Check if we saw '?' symbol by member variable. Set terminal attributes on \033[Xm commands. \033[24m - turn off underline mode, \033[27m - turn off reverse mode, \033[39m - restore default foreground color. \033[49m - restore default background color. \033[2000h - turn on raw keyboard mode, \033[2000l - turn off raw keyboard mode. * fhandler_console.cc (fhandler_console::write): Set attribues to default values on reset command.
2001-02-27 10:14:35 +01:00
char my_title_buf [TITLESIZE + 1];
WORD current_win32_attr;
ansi_intensity intensity;
bool underline, blink, reverse;
* fhandler.h (class fhandler_console): Make all variables that describe "state" of console to be members of fhandler_console. default_color is now the color which is set when console recieves reset command. * fhandler_console.cc (fhandler_console::fhandler_console): Turn mouse handling and raw keyboard mode off by default. Initialize state information. * fhandler.cc (fhandler_console::set_raw_win32_keyboard_mode): New function. * fhandler_console.cc (fhandler_console::set_default_attr): New function. Reset console attributes to default values. * fhandler_console.cc (fhandler_console::open): Reset attributes. * fhandler_console.cc (fhandler_console::get_win32_attr): New function. Calculate win32-style console attribute based on terminal attributes. * fhandler_console.cc (fhandler_console::set_cursor_maybe): Use member variable. * fhandler_console.cc (fhandler_console::read): If in raw-win32 keyboard mode, encode win32 keyboard events in \033{x;y;z;t;u;wK sequences. * fhandler_console.cc (fhandler_console::dup): Copy all state information to the dup()ed handle. * fhandler_console.cc (fhandler_console::scroll_screen): Use current fill-in attribute. * fhandler_console.cc (fhandler_console::clear_screen): Ditto. * fhandler_console.cc (fhandler_console::char_command): Check if we saw '?' symbol by member variable. Set terminal attributes on \033[Xm commands. \033[24m - turn off underline mode, \033[27m - turn off reverse mode, \033[39m - restore default foreground color. \033[49m - restore default background color. \033[2000h - turn on raw keyboard mode, \033[2000l - turn off raw keyboard mode. * fhandler_console.cc (fhandler_console::write): Set attribues to default values on reset command.
2001-02-27 10:14:35 +01:00
WORD fg, bg;
/* saved cursor coordinates */
int savex, savey;
/* saved screen */
COORD savebufsiz;
PCHAR_INFO savebuf;
* fhandler.h (class fhandler_console): Make all variables that describe "state" of console to be members of fhandler_console. default_color is now the color which is set when console recieves reset command. * fhandler_console.cc (fhandler_console::fhandler_console): Turn mouse handling and raw keyboard mode off by default. Initialize state information. * fhandler.cc (fhandler_console::set_raw_win32_keyboard_mode): New function. * fhandler_console.cc (fhandler_console::set_default_attr): New function. Reset console attributes to default values. * fhandler_console.cc (fhandler_console::open): Reset attributes. * fhandler_console.cc (fhandler_console::get_win32_attr): New function. Calculate win32-style console attribute based on terminal attributes. * fhandler_console.cc (fhandler_console::set_cursor_maybe): Use member variable. * fhandler_console.cc (fhandler_console::read): If in raw-win32 keyboard mode, encode win32 keyboard events in \033{x;y;z;t;u;wK sequences. * fhandler_console.cc (fhandler_console::dup): Copy all state information to the dup()ed handle. * fhandler_console.cc (fhandler_console::scroll_screen): Use current fill-in attribute. * fhandler_console.cc (fhandler_console::clear_screen): Ditto. * fhandler_console.cc (fhandler_console::char_command): Check if we saw '?' symbol by member variable. Set terminal attributes on \033[Xm commands. \033[24m - turn off underline mode, \033[27m - turn off reverse mode, \033[39m - restore default foreground color. \033[49m - restore default background color. \033[2000h - turn on raw keyboard mode, \033[2000l - turn off raw keyboard mode. * fhandler_console.cc (fhandler_console::write): Set attribues to default values on reset command.
2001-02-27 10:14:35 +01:00
struct
{
short Top, Bottom;
} scroll_region;
struct
{
SHORT winTop;
SHORT winBottom;
COORD dwWinSize;
COORD dwBufferSize;
COORD dwCursorPosition;
WORD wAttributes;
} info;
COORD dwLastCursorPosition;
COORD dwMousePosition; /* scroll-adjusted coord of mouse event */
COORD dwLastMousePosition; /* scroll-adjusted coord of previous mouse event */
DWORD dwLastButtonState; /* (not noting mouse wheel events) */
int last_button_code; /* transformed mouse report button code */
* fhandler.h (class fhandler_console): Make all variables that describe "state" of console to be members of fhandler_console. default_color is now the color which is set when console recieves reset command. * fhandler_console.cc (fhandler_console::fhandler_console): Turn mouse handling and raw keyboard mode off by default. Initialize state information. * fhandler.cc (fhandler_console::set_raw_win32_keyboard_mode): New function. * fhandler_console.cc (fhandler_console::set_default_attr): New function. Reset console attributes to default values. * fhandler_console.cc (fhandler_console::open): Reset attributes. * fhandler_console.cc (fhandler_console::get_win32_attr): New function. Calculate win32-style console attribute based on terminal attributes. * fhandler_console.cc (fhandler_console::set_cursor_maybe): Use member variable. * fhandler_console.cc (fhandler_console::read): If in raw-win32 keyboard mode, encode win32 keyboard events in \033{x;y;z;t;u;wK sequences. * fhandler_console.cc (fhandler_console::dup): Copy all state information to the dup()ed handle. * fhandler_console.cc (fhandler_console::scroll_screen): Use current fill-in attribute. * fhandler_console.cc (fhandler_console::clear_screen): Ditto. * fhandler_console.cc (fhandler_console::char_command): Check if we saw '?' symbol by member variable. Set terminal attributes on \033[Xm commands. \033[24m - turn off underline mode, \033[27m - turn off reverse mode, \033[39m - restore default foreground color. \033[49m - restore default background color. \033[2000h - turn on raw keyboard mode, \033[2000l - turn off raw keyboard mode. * fhandler_console.cc (fhandler_console::write): Set attribues to default values on reset command.
2001-02-27 10:14:35 +01:00
int nModifiers;
bool insert_mode;
int use_mouse;
bool ext_mouse_mode5;
bool ext_mouse_mode6;
bool ext_mouse_mode15;
bool use_focus;
bool raw_win32_keyboard_mode;
inline UINT get_console_cp ();
DWORD con_to_str (char *d, int dlen, WCHAR w);
DWORD str_to_con (mbtowc_p, const char *, PWCHAR d, const char *s, DWORD sz);
void set_color (HANDLE);
bool fillin_info (HANDLE);
void set_default_attr ();
friend class fhandler_console;
};
/* This is a input and output console handle */
class fhandler_console: public fhandler_termios
{
* 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-06-04 02:12:29 +02:00
public:
struct console_state
{
tty_min tty_min_state;
dev_console dev_state;
};
private:
static const unsigned MAX_WRITE_CHARS;
* 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-06-04 02:12:29 +02:00
static console_state *shared_console_info;
static bool invisible_console;
2000-02-17 20:38:33 +01:00
/* Used when we encounter a truncated multi-byte sequence. The
lead bytes are stored here and revisited in the next write call. */
struct {
int len;
unsigned char buf[4]; /* Max len of valid UTF-8 sequence. */
} trunc_buf;
PWCHAR write_buf;
2000-02-17 20:38:33 +01:00
/* Output calls */
* fhandler.h (class fhandler_console): Make all variables that describe "state" of console to be members of fhandler_console. default_color is now the color which is set when console recieves reset command. * fhandler_console.cc (fhandler_console::fhandler_console): Turn mouse handling and raw keyboard mode off by default. Initialize state information. * fhandler.cc (fhandler_console::set_raw_win32_keyboard_mode): New function. * fhandler_console.cc (fhandler_console::set_default_attr): New function. Reset console attributes to default values. * fhandler_console.cc (fhandler_console::open): Reset attributes. * fhandler_console.cc (fhandler_console::get_win32_attr): New function. Calculate win32-style console attribute based on terminal attributes. * fhandler_console.cc (fhandler_console::set_cursor_maybe): Use member variable. * fhandler_console.cc (fhandler_console::read): If in raw-win32 keyboard mode, encode win32 keyboard events in \033{x;y;z;t;u;wK sequences. * fhandler_console.cc (fhandler_console::dup): Copy all state information to the dup()ed handle. * fhandler_console.cc (fhandler_console::scroll_screen): Use current fill-in attribute. * fhandler_console.cc (fhandler_console::clear_screen): Ditto. * fhandler_console.cc (fhandler_console::char_command): Check if we saw '?' symbol by member variable. Set terminal attributes on \033[Xm commands. \033[24m - turn off underline mode, \033[27m - turn off reverse mode, \033[39m - restore default foreground color. \033[49m - restore default background color. \033[2000h - turn on raw keyboard mode, \033[2000l - turn off raw keyboard mode. * fhandler_console.cc (fhandler_console::write): Set attribues to default values on reset command.
2001-02-27 10:14:35 +01:00
void set_default_attr ();
2000-02-17 20:38:33 +01:00
void clear_screen (int, int, int, int);
void scroll_screen (int, int, int, int, int, int);
void cursor_set (bool, int, int);
2000-02-17 20:38:33 +01:00
void cursor_get (int *, int *);
void cursor_rel (int, int);
inline void write_replacement_char ();
inline bool write_console (PWCHAR, DWORD, DWORD&);
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
const unsigned char *write_normal (unsigned const char*, unsigned const char *);
* fhandler.h (class fhandler_console): Make all variables that describe "state" of console to be members of fhandler_console. default_color is now the color which is set when console recieves reset command. * fhandler_console.cc (fhandler_console::fhandler_console): Turn mouse handling and raw keyboard mode off by default. Initialize state information. * fhandler.cc (fhandler_console::set_raw_win32_keyboard_mode): New function. * fhandler_console.cc (fhandler_console::set_default_attr): New function. Reset console attributes to default values. * fhandler_console.cc (fhandler_console::open): Reset attributes. * fhandler_console.cc (fhandler_console::get_win32_attr): New function. Calculate win32-style console attribute based on terminal attributes. * fhandler_console.cc (fhandler_console::set_cursor_maybe): Use member variable. * fhandler_console.cc (fhandler_console::read): If in raw-win32 keyboard mode, encode win32 keyboard events in \033{x;y;z;t;u;wK sequences. * fhandler_console.cc (fhandler_console::dup): Copy all state information to the dup()ed handle. * fhandler_console.cc (fhandler_console::scroll_screen): Use current fill-in attribute. * fhandler_console.cc (fhandler_console::clear_screen): Ditto. * fhandler_console.cc (fhandler_console::char_command): Check if we saw '?' symbol by member variable. Set terminal attributes on \033[Xm commands. \033[24m - turn off underline mode, \033[27m - turn off reverse mode, \033[39m - restore default foreground color. \033[49m - restore default background color. \033[2000h - turn on raw keyboard mode, \033[2000l - turn off raw keyboard mode. * fhandler_console.cc (fhandler_console::write): Set attribues to default values on reset command.
2001-02-27 10:14:35 +01:00
void char_command (char);
bool set_raw_win32_keyboard_mode (bool);
2000-02-17 20:38:33 +01:00
int output_tcsetattr (int a, const struct termios *t);
/* Input calls */
int igncr_enabled ();
int input_tcsetattr (int a, const struct termios *t);
void set_cursor_maybe ();
static bool create_invisible_console (HWINSTA);
static bool create_invisible_console_workaround ();
* 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-06-04 02:12:29 +02:00
static console_state *open_shared_console (HWND, HANDLE&, bool&);
2000-02-17 20:38:33 +01:00
* dtable.cc (dtable::build_fhandler): Issue internal error on unknown device. * fhandler.cc (fhandler_base::close): Show both name and handle in debugging output. * fhandler.h (fhandler_base::get_guard): New virtual method. (fhandler_pipe::get_guard): New method. (fhandler_socket::ready_for_read): Delete declaration. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (struct select_record::peek): Declare new method. * select.cc (MAKEready): Delete. (peek_pipe): Use get_guard method to retrieve potential guard mutex handle. (fhandler_base::ready_for_read): Rewrite as generic ready-for-read handler. Should only be called for "slow" devices. (fhandler_socket::ready_for_read): Delete definition. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (fhandler_pipe::select_read): Fill in new peek record in select_record structure. (fhandler_console::select_read): Ditto. (fhandler_tty_common::select_read): Ditto. (fhandler_serial::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_tty_slave::ready_for_read): Check for tty not open. Set errnos appropriately. * syscalls.cc (_read): Allow ready_for_read to set errno. * pinfo.cc (pinfo::init): Return spawn/NO_WAIT process as valid if it is initializing. * sigproc.cc (getsem): Adjust wait for process to initialize downward to avoid huge waits.
2001-11-01 22:15:53 +01:00
public:
static pid_t tc_getpgid ()
{
return shared_console_info ? shared_console_info->tty_min_state.getpgid () : myself->pgid;
}
fhandler_console (fh_devices);
* 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-06-04 02:12:29 +02:00
static console_state *open_shared_console (HWND hw, HANDLE& h)
{
bool createit = false;
return open_shared_console (hw, h, createit);
}
2000-02-17 20:38:33 +01:00
fhandler_console* is_console () { return this; }
* 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-06 00:30:53 +02:00
bool use_archetype () const {return true;}
int open (int flags, mode_t mode);
void open_setup (int flags);
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
int dup (fhandler_base *, int);
2000-02-17 20:38:33 +01:00
void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3)));
* sigproc.h (wait_for_sigthread): Eliminate parameter. * sigproc.cc (wait_for_sigthread): Ditto. Don't synchronize with wait_sig after receiving an event that it is ready to go. (init_sig_pipe): New function. (wait_sig): Call init_sig_pipe to create pipes for communicating signals to this process. Don't send sigCONT signal when initializing. * fork.cc (frok::child): Accommodate wait_for_sigpipe parameter change. * fhandler.h (fhandler_*::write): Make ssize_t/__stdcall. (fhandler_*::write_overlapped): Ditto. (fhandler_*::raw_write): Ditto. (fhandler_*::readv): Ditto. (fhandler_*::writev): Ditto. (fhandler_*::raw_read): Make __stdcall. * fhandler: Accommodate changes to read/write functions throughout. * fhandler_clipboard.cc: Ditto. * fhandler_console.cc: Ditto. * fhandler_dsp.cc: Ditto. * fhandler_fifo.cc: Ditto. * fhandler_mailslot.cc: Ditto. * fhandler_mem.cc: Ditto. * fhandler_mem.cc: Ditto. * fhandler_random.cc: Ditto. * fhandler_tape.cc: Ditto. * fhandler_tty.cc: Ditto. * fhandler_virtual.cc: Ditto. * fhandler_windows.cc: Ditto. * fhandler_zero.cc: Ditto. * syscalls.cc (readv): Use ssize_t as temp variable. * fhandler.cc (fhandler_base::read): Coerce returned len to signed or it will never be treated as < 0. (fhandler_base::wait_overlapped): Minimize calls to GetLastError. Remove duplicate debugging test. Fix error return. * fhandler.h (fhandler_fifo::fifo_name): Declare new function. (fhandler_fifo::close): Ditto. (fhandler_fifo::dup): Ditto. (fhandler_fifo::close_on_exec): Ditto. * fhandler.cc (fhandler_fifo::fifo_name): Define new function. (FIFO_BUF_SIZE): New define. (cnp): Ditto. (fhandler_fifo::open): Rework. Use cnp to open named pipe. Always open write side as a client. Open dummy client when writing and can't connect. (wait): Rework. Implement fifo_wait_for_next_client. Handle signals during connect better. Add new fifo_wait_for_server code which polls (sigh) waiting for server. (fhandler_fifo::raw_read): Handle transition states when one client closes and another is available. (fhandler_fifo::close): Define. (fhandler_fifo::dup): Ditto. (fhandler_fifo::close_on_exec): Ditto.
2009-07-24 22:54:33 +02:00
ssize_t __stdcall write (const void *ptr, size_t len);
void doecho (const void *str, DWORD len) { (void) write (str, len); }
2000-02-17 20:38:33 +01:00
int close ();
static bool exists () {return !!GetConsoleCP ();}
2000-02-17 20:38:33 +01:00
int tcflush (int);
int tcsetattr (int a, const struct termios *t);
int tcgetattr (struct termios *t);
int ioctl (unsigned int cmd, void *);
int init (HANDLE, DWORD, mode_t);
bool mouse_aware (MOUSE_EVENT_RECORD& mouse_event);
* 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-06-04 02:12:29 +02:00
bool focus_aware () {return shared_console_info->dev_state.use_focus;}
2000-02-17 20:38:33 +01:00
* select.h: New file split from fhandler.h. (select_record::select_record): Define do-nothing constructor for "new" to avoid gratuitous zeroing. (select_info): New base class. (select_pipe_info): New class with methods for dealing with pipes. (select_socket_info): New class with methods for dealing with sockets. (select_serial_info): Dummy class for serial. (select_mailslot_info): Dummy class for mailslots. (select_stuff): Define device_specific_* as actual classes rather than void *. * dtable.h (dtable::select_read): Accommodate return value change to 'bool' and argument change to "select_stuff". (dtable::select_write): Ditto. (dtable::select_except): Ditto. * dtable.cc (dtable::select_read): Accommodate return value change to 'bool' and argument change to "select_stuff". (dtable::select_write): Ditto. (dtable::select_except): Ditto. * fhandler.h: Excise select-related classes. (fhandler_*::select_read): Change argument to select_stuff. (fhandler_*::select_write): Ditto. (fhandler_*::select_except): Ditto. * select.cc (UNIX_FD_ZERO): Use memset rather than bzero. (select_stuff::test_and_set): Change return type to bool. Allocate select_record on entry and let fhandler_*::select_* operate on the start.next field of select_stuff. (pipeinf): Delete. (select_pipe_info::select_pipe_info): New constructor. Allocates event for controlling pipe waits. (select_pipe_info::~select_pipe_info): New destructor. Destroy event. Stop thread. (select_pipe_info::add_watch_handle): New function. (thread_pipe): Wait for the hEvent part of any overlapped pipes before peeking. (start_thread_pipe): Don't allocate device_specific_pipe stuff here. Assume that it has been allocated earlier. (pipe_cleanup): Rely on select_pipe_info destructor to clean up pipe paraphenalia. (fhandler_*::select_*): Derive select_record from new select_stuff argument. (fhandler_pipe::select_*): Ditto. Allocate pipe-specific field if not already allocated. (serialinf): Delete. (thread_serial): serialinf -> select_serial_info. (fhandler_base::ready_for_read): Rewrite to accommodate change in argument to fhandler_*::select_*. (socketinf): Delete. (thread_socket): socketinf -> select_socket_info. (mailslotinf): Delete. (thread_mailslot): mailslotinf -> select_mailslot_info.
2009-06-30 23:18:44 +02:00
select_record *select_read (select_stuff *);
select_record *select_write (select_stuff *);
select_record *select_except (select_stuff *);
void fixup_after_fork_exec (bool);
void fixup_after_exec () {fixup_after_fork_exec (true);}
void fixup_after_fork (HANDLE) {fixup_after_fork_exec (false);}
* Use new unified status_flag accessor methods from classes fhandler_*, tty_min, mtinfo and fs_info thoroughout. * fhandler.h: Redefine all set_close_on_exec methods to take a bool argument. (enum conn_state): Rename from connect_state. (class fhandler_base): Rename some status flags to align with accessor method names. Drop encoded flag entirely. Unify status accessor methods. Const'ify all read accessor methods. (class fhandler_socket): Ditto. (class fhandler_dev_raw): Ditto. * fhandler_disk_file.cc (fhandler_base::fstat_fs): Use fs.fs_is_fat() instead of evaluating FATness of file system here. (fhandler_disk_file::opendir): Drop call to set_encoded(). (fhandler_disk_file::readdir): Use pc.isencoded() directly. * mtinfo.h (class mtinfo_drive): Const'ify all read accessor methods. * path.cc (fsinfo_cnt): Add. (fs_info::update): Accomodate class changes. Evaluate file system name specific flags right here. Add thread safety for reading and writing global fsinfo array. * path.h (enum path_types): Drop values for flags kept in fs already. (struct fs_info): Move status informatin into private struct type status_flags. Add accessor methods. Remove path and file system name string arrays in favor of status bits. (class path_conv): Use new fs_info status information where appropriate. (path_conf::fs_has_ea): Rename from fs_fast_ea. (path_conf::fs_has_acls): New method. (path_conf::root_dir): Remove. (path_conf::volname): Remove. * syscalls (statfs): Evaluate root dir locally. * tty.h (class tty_min): Unify status accessor methods. Const'ify all read accessor methods.
2004-04-10 15:45:10 +02:00
void set_close_on_exec (bool val);
void set_input_state ();
void send_winch_maybe ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
void setup ();
* 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-28 20:17:09 +02:00
bool set_unit ();
static bool need_invisible ();
static void free_console ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
fhandler_console (void *) {}
void copyto (fhandler_base *x)
{
x->pc.free_strings ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
*reinterpret_cast<fhandler_console *> (x) = *this;
x->reset (this);
}
fhandler_console *clone (cygheap_types malloc_type = HEAP_FHANDLER)
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
{
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_console));
* fhandler.h (fhandler_pipe::create_selectable): Remove optional argument, take an options argument for CreateNamedPipe/CreateFile. Change handle arguments to expect pointers. (fhandler_fifo::fifo_state): Delete. (fhandler_fifo::dummy_client): Ditto. (fhandler_fifo::open_nonserver): Ditto. (fhandler_fifo::wait_state): Ditto. (fhandler_fifo::raw_write): Ditto. (fhandler_fifo::read_ready): New field. (fhandler_fifo::write_ready): Ditto. (fhandler_fifo::wait): Modify argument. (fhandler_fifo::fifo_name): Add a new argument. (fhandler_fifo::fixup_after_fork): New function. * fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Remove initialization of expunged elements. Initialize new handles to NULL. (fhandler_fifo::open_nonserver): Delete. (fnevent): New macro for creating a named event. (fnpipe): New macro for creating a unique named pipe name. (create_pipe): New macro for simplification of named pipe creation. (fhandler_fifo::fifo_name): Use new argument when creating a shared name. (fhandler_fifo::open): Rewrite. Use events to synchronize. (pure_debug_printf): New macro, active only when DEBUGGING. (fhandler_fifo::wait): Rewrite to wait for new fifo events which are supplied as a parameter. (fhandler_fifo::raw_read): Rewrite to use handle mechanism to detect client-side disconnect. (fhandler_fifo::raw_write): Delete. (fhandler_fifo::close): Remove accommodations for expunged fields. Close event handles. (fhandler_fifo::dup): Remove accommodations for expunged fields. Duplicate event handles. (fhandler_fifo::fixup_after_fork): New function. Perform fixups on event handles. (fhandler_fifo::set_close_on_exec): Remove accommodations for expunged fields. Set inheritance for new handle fields. * miscfuncs.cc (CreatePipeOverlapped): Accommodate changes in fhandler_pipe::create_selectable. * tty.cc (tty::not_allocated): Ditto. * pipe.cc (fhandler_pipe::create): Ditto. (fhandler_pipe::create_selectable): Accept an extra open_mode argument. Pass arguments by reference and allow opening one end of the pipe at a time. * sys/strace.h (debug_only_printf): Define new macro which calls debug_printf only when DEBUGGING is defined.
2011-10-30 05:50:36 +01:00
fhandler_console *fh = new (ptr) fhandler_console (ptr);
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
copyto (fh);
return fh;
}
* 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-06-04 02:12:29 +02:00
friend tty_min * tty_list::get_cttyp ();
2000-02-17 20:38:33 +01:00
};
* 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-14 23:48:43 +02:00
class fhandler_pty_common: public fhandler_termios
2000-02-17 20:38:33 +01:00
{
* dtable.cc (dtable::build_fhandler): Issue internal error on unknown device. * fhandler.cc (fhandler_base::close): Show both name and handle in debugging output. * fhandler.h (fhandler_base::get_guard): New virtual method. (fhandler_pipe::get_guard): New method. (fhandler_socket::ready_for_read): Delete declaration. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (struct select_record::peek): Declare new method. * select.cc (MAKEready): Delete. (peek_pipe): Use get_guard method to retrieve potential guard mutex handle. (fhandler_base::ready_for_read): Rewrite as generic ready-for-read handler. Should only be called for "slow" devices. (fhandler_socket::ready_for_read): Delete definition. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (fhandler_pipe::select_read): Fill in new peek record in select_record structure. (fhandler_console::select_read): Ditto. (fhandler_tty_common::select_read): Ditto. (fhandler_serial::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_tty_slave::ready_for_read): Check for tty not open. Set errnos appropriately. * syscalls.cc (_read): Allow ready_for_read to set errno. * pinfo.cc (pinfo::init): Return spawn/NO_WAIT process as valid if it is initializing. * sigproc.cc (getsem): Adjust wait for process to initialize downward to avoid huge waits.
2001-11-01 22:15:53 +01:00
public:
* 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-14 23:48:43 +02:00
fhandler_pty_common ()
: fhandler_termios (),
output_mutex (NULL),
* fhandler.cc (fhandler_base::fixup_after_exec): Declare here. * fhandler.h (fhandler_base::fixup_after_exec): Make non-inline. (fhandler_termios::fixup_after_fork): Delete declaration. (fhandler_termios::fixup_after_exec): Ditto. (fhandler_tty_common::inuse): Remove. (fhandler_tty_common::dup): Delete declaration. (fhandler_tty_common::fixup_after_fork): Ditto. (fhandler_tty_slave::fixup_after_exec): Declare new function. (fhandler_pty_master::dwProcessId): New variable. (fhandler_pty_master::from_master): Ditto. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::setup): New function. (fhandler_pty_master::fixup_after_fork): Ditto. (fhandler_pty_master::fixup_after_exec): Ditto. * fhandler_termios.cc (fhandler_termios::fixup_after_exec): Delete definition. (fhandler_termios::fixup_after_fork): Ditto. * fhandler_tty.cc (fhandler_tty_master::init): Use fhandler_pty_master setup function rather than obsolete tty::common_init. Delete obsolete inuse setting. (fhandler_tty_slave::fhandler_tty_slave): Set inuse to NULL here. (fhandler_tty_slave::open): Change debugging output for clarity. Check for different things when doing a sanity check on the tty. Reflect the fact that master_pid now is the cygwin pid rather than the windows pid. Use "arch" rather than "archetype" for consistency. (fhandler_tty_slave::close): Close inuse here. (fhandler_tty_slave::dup): Remove old if 0'ed code. (fhandler_pty_master::dup): New function. Handles pty master archetype. (fhandler_pty_master::fhandler_pty_master): Zero pty_master specific fields. (fhandler_pty_master::open): Implement using archetypes, similar to slave. Use fhandler_pty_master setup function rather than obsolete tty::common_init. Don't set inuse. (fhandler_tty_common::close): Don't deal with inuse. Delete old if 0'ed code. (fhandler_pty_master::close): Implement using archetypes. Close from_master and to_master. (fhandler_tty_common::set_close_on_exec): Just set close_on_exec flag here since everything uses archetypes now. (fhandler_tty_common::fixup_after_fork): Delete definition. (fhandler_tty_slave::fixup_after_exec): Define new function. (fhandler_pty_master::setup): New function, derived from tty::common_init. (fhandler_pty_master::fixup_after_fork): New function. (shared_info.h): Reset SHARED_INFO_CB to reflect new tty size. * tty.cc (tty_list::terminate): Close individual handles from tty_master. (tty::master_alive): Delete. (tty::make_pipes): Ditto. (tty::common_init): Ditto. * tty.h (tty::from_slave): Delete. (tty::to_slave): Ditto. (tty::common_init): Delete declaration. (tty::make_pipes): Ditto. (tty::master_pid): Define as pid_t since it is now a cygwin pid.
2006-06-02 17:41:34 +02:00
input_mutex (NULL), input_available_event (NULL)
2000-02-17 20:38:33 +01:00
{
pc.file_attributes (FILE_ATTRIBUTE_NORMAL);
2000-02-17 20:38:33 +01:00
}
static const unsigned pipesize = 128 * 1024;
HANDLE output_mutex, input_mutex;
HANDLE input_available_event;
2000-02-17 20:38:33 +01:00
bool use_archetype () const {return true;}
2000-02-17 20:38:33 +01:00
DWORD __acquire_output_mutex (const char *fn, int ln, DWORD ms);
void __release_output_mutex (const char *fn, int ln);
int close ();
_off64_t lseek (_off64_t, int);
bool bytes_available (DWORD& n);
* Use new unified status_flag accessor methods from classes fhandler_*, tty_min, mtinfo and fs_info thoroughout. * fhandler.h: Redefine all set_close_on_exec methods to take a bool argument. (enum conn_state): Rename from connect_state. (class fhandler_base): Rename some status flags to align with accessor method names. Drop encoded flag entirely. Unify status accessor methods. Const'ify all read accessor methods. (class fhandler_socket): Ditto. (class fhandler_dev_raw): Ditto. * fhandler_disk_file.cc (fhandler_base::fstat_fs): Use fs.fs_is_fat() instead of evaluating FATness of file system here. (fhandler_disk_file::opendir): Drop call to set_encoded(). (fhandler_disk_file::readdir): Use pc.isencoded() directly. * mtinfo.h (class mtinfo_drive): Const'ify all read accessor methods. * path.cc (fsinfo_cnt): Add. (fs_info::update): Accomodate class changes. Evaluate file system name specific flags right here. Add thread safety for reading and writing global fsinfo array. * path.h (enum path_types): Drop values for flags kept in fs already. (struct fs_info): Move status informatin into private struct type status_flags. Add accessor methods. Remove path and file system name string arrays in favor of status bits. (class path_conv): Use new fs_info status information where appropriate. (path_conf::fs_has_ea): Rename from fs_fast_ea. (path_conf::fs_has_acls): New method. (path_conf::root_dir): Remove. (path_conf::volname): Remove. * syscalls (statfs): Evaluate root dir locally. * tty.h (class tty_min): Unify status accessor methods. Const'ify all read accessor methods.
2004-04-10 15:45:10 +02:00
void set_close_on_exec (bool val);
* select.h: New file split from fhandler.h. (select_record::select_record): Define do-nothing constructor for "new" to avoid gratuitous zeroing. (select_info): New base class. (select_pipe_info): New class with methods for dealing with pipes. (select_socket_info): New class with methods for dealing with sockets. (select_serial_info): Dummy class for serial. (select_mailslot_info): Dummy class for mailslots. (select_stuff): Define device_specific_* as actual classes rather than void *. * dtable.h (dtable::select_read): Accommodate return value change to 'bool' and argument change to "select_stuff". (dtable::select_write): Ditto. (dtable::select_except): Ditto. * dtable.cc (dtable::select_read): Accommodate return value change to 'bool' and argument change to "select_stuff". (dtable::select_write): Ditto. (dtable::select_except): Ditto. * fhandler.h: Excise select-related classes. (fhandler_*::select_read): Change argument to select_stuff. (fhandler_*::select_write): Ditto. (fhandler_*::select_except): Ditto. * select.cc (UNIX_FD_ZERO): Use memset rather than bzero. (select_stuff::test_and_set): Change return type to bool. Allocate select_record on entry and let fhandler_*::select_* operate on the start.next field of select_stuff. (pipeinf): Delete. (select_pipe_info::select_pipe_info): New constructor. Allocates event for controlling pipe waits. (select_pipe_info::~select_pipe_info): New destructor. Destroy event. Stop thread. (select_pipe_info::add_watch_handle): New function. (thread_pipe): Wait for the hEvent part of any overlapped pipes before peeking. (start_thread_pipe): Don't allocate device_specific_pipe stuff here. Assume that it has been allocated earlier. (pipe_cleanup): Rely on select_pipe_info destructor to clean up pipe paraphenalia. (fhandler_*::select_*): Derive select_record from new select_stuff argument. (fhandler_pipe::select_*): Ditto. Allocate pipe-specific field if not already allocated. (serialinf): Delete. (thread_serial): serialinf -> select_serial_info. (fhandler_base::ready_for_read): Rewrite to accommodate change in argument to fhandler_*::select_*. (socketinf): Delete. (thread_socket): socketinf -> select_socket_info. (mailslotinf): Delete. (thread_mailslot): mailslotinf -> select_mailslot_info.
2009-06-30 23:18:44 +02:00
select_record *select_read (select_stuff *);
select_record *select_write (select_stuff *);
select_record *select_except (select_stuff *);
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
fhandler_pty_common (void *) {}
virtual void copyto (fhandler_base *x)
{
x->pc.free_strings ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
*reinterpret_cast<fhandler_pty_common *> (x) = *this;
x->reset (this);
}
virtual fhandler_pty_common *clone (cygheap_types malloc_type = HEAP_FHANDLER)
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
{
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_pty_common));
* fhandler.h (fhandler_pipe::create_selectable): Remove optional argument, take an options argument for CreateNamedPipe/CreateFile. Change handle arguments to expect pointers. (fhandler_fifo::fifo_state): Delete. (fhandler_fifo::dummy_client): Ditto. (fhandler_fifo::open_nonserver): Ditto. (fhandler_fifo::wait_state): Ditto. (fhandler_fifo::raw_write): Ditto. (fhandler_fifo::read_ready): New field. (fhandler_fifo::write_ready): Ditto. (fhandler_fifo::wait): Modify argument. (fhandler_fifo::fifo_name): Add a new argument. (fhandler_fifo::fixup_after_fork): New function. * fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Remove initialization of expunged elements. Initialize new handles to NULL. (fhandler_fifo::open_nonserver): Delete. (fnevent): New macro for creating a named event. (fnpipe): New macro for creating a unique named pipe name. (create_pipe): New macro for simplification of named pipe creation. (fhandler_fifo::fifo_name): Use new argument when creating a shared name. (fhandler_fifo::open): Rewrite. Use events to synchronize. (pure_debug_printf): New macro, active only when DEBUGGING. (fhandler_fifo::wait): Rewrite to wait for new fifo events which are supplied as a parameter. (fhandler_fifo::raw_read): Rewrite to use handle mechanism to detect client-side disconnect. (fhandler_fifo::raw_write): Delete. (fhandler_fifo::close): Remove accommodations for expunged fields. Close event handles. (fhandler_fifo::dup): Remove accommodations for expunged fields. Duplicate event handles. (fhandler_fifo::fixup_after_fork): New function. Perform fixups on event handles. (fhandler_fifo::set_close_on_exec): Remove accommodations for expunged fields. Set inheritance for new handle fields. * miscfuncs.cc (CreatePipeOverlapped): Accommodate changes in fhandler_pipe::create_selectable. * tty.cc (tty::not_allocated): Ditto. * pipe.cc (fhandler_pipe::create): Ditto. (fhandler_pipe::create_selectable): Accept an extra open_mode argument. Pass arguments by reference and allow opening one end of the pipe at a time. * sys/strace.h (debug_only_printf): Define new macro which calls debug_printf only when DEBUGGING is defined.
2011-10-30 05:50:36 +01:00
fhandler_pty_common *fh = new (ptr) fhandler_pty_common (ptr);
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
copyto (fh);
return fh;
}
2000-02-17 20:38:33 +01:00
};
* 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-14 23:48:43 +02:00
class fhandler_pty_slave: public fhandler_pty_common
2000-02-17 20:38:33 +01:00
{
* fhandler.cc (fhandler_base::fixup_after_exec): Declare here. * fhandler.h (fhandler_base::fixup_after_exec): Make non-inline. (fhandler_termios::fixup_after_fork): Delete declaration. (fhandler_termios::fixup_after_exec): Ditto. (fhandler_tty_common::inuse): Remove. (fhandler_tty_common::dup): Delete declaration. (fhandler_tty_common::fixup_after_fork): Ditto. (fhandler_tty_slave::fixup_after_exec): Declare new function. (fhandler_pty_master::dwProcessId): New variable. (fhandler_pty_master::from_master): Ditto. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::setup): New function. (fhandler_pty_master::fixup_after_fork): Ditto. (fhandler_pty_master::fixup_after_exec): Ditto. * fhandler_termios.cc (fhandler_termios::fixup_after_exec): Delete definition. (fhandler_termios::fixup_after_fork): Ditto. * fhandler_tty.cc (fhandler_tty_master::init): Use fhandler_pty_master setup function rather than obsolete tty::common_init. Delete obsolete inuse setting. (fhandler_tty_slave::fhandler_tty_slave): Set inuse to NULL here. (fhandler_tty_slave::open): Change debugging output for clarity. Check for different things when doing a sanity check on the tty. Reflect the fact that master_pid now is the cygwin pid rather than the windows pid. Use "arch" rather than "archetype" for consistency. (fhandler_tty_slave::close): Close inuse here. (fhandler_tty_slave::dup): Remove old if 0'ed code. (fhandler_pty_master::dup): New function. Handles pty master archetype. (fhandler_pty_master::fhandler_pty_master): Zero pty_master specific fields. (fhandler_pty_master::open): Implement using archetypes, similar to slave. Use fhandler_pty_master setup function rather than obsolete tty::common_init. Don't set inuse. (fhandler_tty_common::close): Don't deal with inuse. Delete old if 0'ed code. (fhandler_pty_master::close): Implement using archetypes. Close from_master and to_master. (fhandler_tty_common::set_close_on_exec): Just set close_on_exec flag here since everything uses archetypes now. (fhandler_tty_common::fixup_after_fork): Delete definition. (fhandler_tty_slave::fixup_after_exec): Define new function. (fhandler_pty_master::setup): New function, derived from tty::common_init. (fhandler_pty_master::fixup_after_fork): New function. (shared_info.h): Reset SHARED_INFO_CB to reflect new tty size. * tty.cc (tty_list::terminate): Close individual handles from tty_master. (tty::master_alive): Delete. (tty::make_pipes): Ditto. (tty::common_init): Ditto. * tty.h (tty::from_slave): Delete. (tty::to_slave): Ditto. (tty::common_init): Delete declaration. (tty::make_pipes): Ditto. (tty::master_pid): Define as pid_t since it is now a cygwin pid.
2006-06-02 17:41:34 +02:00
HANDLE inuse; // used to indicate that a tty is in use
* autoload.cc (GetNamedPipeClientProcessId): Define. * fhandler.h (fhandler_tty_slave::fch_open_handles): Declare private. (fhandler_tty_slave::fch_close_handles): Ditto. (fhandler_tty_slave::cygserver_attach_tty): Drop declaration. (fhandler_tty_slave::fstat): Declare public. (fhandler_tty_slave::fchmod): Declare public. (fhandler_tty_slave::fchown): Declare public. (class fhandler_pty_master): Add master_ctl handle. (fhandler_pty_master::pty_master_thread): Declare public. * fhandler_termios.cc (fhandler_termios::tcinit): If the process is started from a non-Cygwin process, make it tty process group leader. * fhandler_tty.cc: Throughout accommodate additional security related arguments in calls to functions creating or opening objects. (close_maybe): Move to start of file to reuse it in other methods. (struct pipe_request): Define. (struct pipe_reply): Define. (fhandler_tty_slave::open): Throughout, try to open synchronization objects with MAXIMUM_ALLOWED permissions. Drop call to cygserver. Try to duplicate pipe handles via master_ctl pipe if duplicating directly doesn't work. (fhandler_tty_slave::cygserver_attach_tty): Remove. (fhandler_tty_slave::init): Close unused incoming pipe handle. (fhandler_pty_master::close): Send exit message to master control thread and close master_ctl handle. (fhandler_pty_master::pty_master_thread): New method, implementing the master control thread. (pty_master_thread): Static helper to start master control thread. (fhandler_pty_master::setup): Simplify creating pipe inheritance. Make sure we're the one creating the input_available_event. Add comment to explain why. Create master_ctl pipe and start master control thread. Close master_ctl handle in case of error. * security.cc (alloc_sd): Add code to handle tty objects. Add comments to explain what exactly is required. (get_object_sd): New function. (get_object_attribute): New function. (create_object_sd_from_attribute): New function. (set_object_sd): New function. (set_object_attribute): New function. (set_file_attribute): Change attribute type to mode_t. * security.h (set_file_attribute): Change attribute type to mode_t. (get_object_sd): Declare. (get_object_attribute): Declare. (create_object_sd_from_attribute): Declare. (set_object_sd): Declare. (set_object_attribute): Declare. * tty.cc (tty::slave_alive): Implement directly instead of via alive. (tty::exists): Open mutex handle with READ_CONTROL access. (tty::alive): Remove. (tty::open_output_mutex): Convert to inline method. (tty::open_input_mutex): Ditto. (tty::open_mutex): Take additional ACCESS_MASK parameter for the mutex open access mask. (tty::open_inuse): New method. (tty::create_inuse): Take PSECURITY_ATTRIBUTES parameter. Drop fmt name parameter. Always create TTY_SLAVE_ALIVE event. (tty::get_event): Take additional PSECURITY_ATTRIBUTES parameter for CreateEvent. * tty.h (class tty): Change declarations according to aforementioned changes. (tty::open_output_mutex): Implement as inline method. (tty::open_input_mutex): Ditto.
2010-04-19 21:52:43 +02:00
/* Helper functions for fchmod and fchown. */
bool fch_open_handles ();
int fch_set_sd (security_descriptor &sd, bool chown);
void fch_close_handles ();
* dtable.cc (dtable::build_fhandler): Issue internal error on unknown device. * fhandler.cc (fhandler_base::close): Show both name and handle in debugging output. * fhandler.h (fhandler_base::get_guard): New virtual method. (fhandler_pipe::get_guard): New method. (fhandler_socket::ready_for_read): Delete declaration. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (struct select_record::peek): Declare new method. * select.cc (MAKEready): Delete. (peek_pipe): Use get_guard method to retrieve potential guard mutex handle. (fhandler_base::ready_for_read): Rewrite as generic ready-for-read handler. Should only be called for "slow" devices. (fhandler_socket::ready_for_read): Delete definition. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (fhandler_pipe::select_read): Fill in new peek record in select_record structure. (fhandler_console::select_read): Ditto. (fhandler_tty_common::select_read): Ditto. (fhandler_serial::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_tty_slave::ready_for_read): Check for tty not open. Set errnos appropriately. * syscalls.cc (_read): Allow ready_for_read to set errno. * pinfo.cc (pinfo::init): Return spawn/NO_WAIT process as valid if it is initializing. * sigproc.cc (getsem): Adjust wait for process to initialize downward to avoid huge waits.
2001-11-01 22:15:53 +01:00
public:
2000-02-17 20:38:33 +01:00
/* Constructor */
* 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-14 23:48:43 +02:00
fhandler_pty_slave (int);
2000-02-17 20:38:33 +01:00
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
int open (int flags, mode_t mode = 0);
* 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-06 00:30:53 +02:00
void open_setup (int flags);
* sigproc.h (wait_for_sigthread): Eliminate parameter. * sigproc.cc (wait_for_sigthread): Ditto. Don't synchronize with wait_sig after receiving an event that it is ready to go. (init_sig_pipe): New function. (wait_sig): Call init_sig_pipe to create pipes for communicating signals to this process. Don't send sigCONT signal when initializing. * fork.cc (frok::child): Accommodate wait_for_sigpipe parameter change. * fhandler.h (fhandler_*::write): Make ssize_t/__stdcall. (fhandler_*::write_overlapped): Ditto. (fhandler_*::raw_write): Ditto. (fhandler_*::readv): Ditto. (fhandler_*::writev): Ditto. (fhandler_*::raw_read): Make __stdcall. * fhandler: Accommodate changes to read/write functions throughout. * fhandler_clipboard.cc: Ditto. * fhandler_console.cc: Ditto. * fhandler_dsp.cc: Ditto. * fhandler_fifo.cc: Ditto. * fhandler_mailslot.cc: Ditto. * fhandler_mem.cc: Ditto. * fhandler_mem.cc: Ditto. * fhandler_random.cc: Ditto. * fhandler_tape.cc: Ditto. * fhandler_tty.cc: Ditto. * fhandler_virtual.cc: Ditto. * fhandler_windows.cc: Ditto. * fhandler_zero.cc: Ditto. * syscalls.cc (readv): Use ssize_t as temp variable. * fhandler.cc (fhandler_base::read): Coerce returned len to signed or it will never be treated as < 0. (fhandler_base::wait_overlapped): Minimize calls to GetLastError. Remove duplicate debugging test. Fix error return. * fhandler.h (fhandler_fifo::fifo_name): Declare new function. (fhandler_fifo::close): Ditto. (fhandler_fifo::dup): Ditto. (fhandler_fifo::close_on_exec): Ditto. * fhandler.cc (fhandler_fifo::fifo_name): Define new function. (FIFO_BUF_SIZE): New define. (cnp): Ditto. (fhandler_fifo::open): Rework. Use cnp to open named pipe. Always open write side as a client. Open dummy client when writing and can't connect. (wait): Rework. Implement fifo_wait_for_next_client. Handle signals during connect better. Add new fifo_wait_for_server code which polls (sigh) waiting for server. (fhandler_fifo::raw_read): Handle transition states when one client closes and another is available. (fhandler_fifo::close): Define. (fhandler_fifo::dup): Ditto. (fhandler_fifo::close_on_exec): Ditto.
2009-07-24 22:54:33 +02:00
ssize_t __stdcall write (const void *ptr, size_t len);
void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3)));
int init (HANDLE, DWORD, mode_t);
2000-02-17 20:38:33 +01:00
int tcsetattr (int a, const struct termios *t);
int tcgetattr (struct termios *t);
int tcflush (int);
int ioctl (unsigned int cmd, void *);
int close ();
* 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-06 00:30:53 +02:00
void cleanup ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
int dup (fhandler_base *child, int);
void fixup_after_fork (HANDLE parent);
* fhandler.cc (fhandler_base::fixup_after_exec): Declare here. * fhandler.h (fhandler_base::fixup_after_exec): Make non-inline. (fhandler_termios::fixup_after_fork): Delete declaration. (fhandler_termios::fixup_after_exec): Ditto. (fhandler_tty_common::inuse): Remove. (fhandler_tty_common::dup): Delete declaration. (fhandler_tty_common::fixup_after_fork): Ditto. (fhandler_tty_slave::fixup_after_exec): Declare new function. (fhandler_pty_master::dwProcessId): New variable. (fhandler_pty_master::from_master): Ditto. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::setup): New function. (fhandler_pty_master::fixup_after_fork): Ditto. (fhandler_pty_master::fixup_after_exec): Ditto. * fhandler_termios.cc (fhandler_termios::fixup_after_exec): Delete definition. (fhandler_termios::fixup_after_fork): Ditto. * fhandler_tty.cc (fhandler_tty_master::init): Use fhandler_pty_master setup function rather than obsolete tty::common_init. Delete obsolete inuse setting. (fhandler_tty_slave::fhandler_tty_slave): Set inuse to NULL here. (fhandler_tty_slave::open): Change debugging output for clarity. Check for different things when doing a sanity check on the tty. Reflect the fact that master_pid now is the cygwin pid rather than the windows pid. Use "arch" rather than "archetype" for consistency. (fhandler_tty_slave::close): Close inuse here. (fhandler_tty_slave::dup): Remove old if 0'ed code. (fhandler_pty_master::dup): New function. Handles pty master archetype. (fhandler_pty_master::fhandler_pty_master): Zero pty_master specific fields. (fhandler_pty_master::open): Implement using archetypes, similar to slave. Use fhandler_pty_master setup function rather than obsolete tty::common_init. Don't set inuse. (fhandler_tty_common::close): Don't deal with inuse. Delete old if 0'ed code. (fhandler_pty_master::close): Implement using archetypes. Close from_master and to_master. (fhandler_tty_common::set_close_on_exec): Just set close_on_exec flag here since everything uses archetypes now. (fhandler_tty_common::fixup_after_fork): Delete definition. (fhandler_tty_slave::fixup_after_exec): Define new function. (fhandler_pty_master::setup): New function, derived from tty::common_init. (fhandler_pty_master::fixup_after_fork): New function. (shared_info.h): Reset SHARED_INFO_CB to reflect new tty size. * tty.cc (tty_list::terminate): Close individual handles from tty_master. (tty::master_alive): Delete. (tty::make_pipes): Ditto. (tty::common_init): Ditto. * tty.h (tty::from_slave): Delete. (tty::to_slave): Ditto. (tty::common_init): Delete declaration. (tty::make_pipes): Ditto. (tty::master_pid): Define as pid_t since it is now a cygwin pid.
2006-06-02 17:41:34 +02:00
void fixup_after_exec ();
2000-02-17 20:38:33 +01:00
* select.h: New file split from fhandler.h. (select_record::select_record): Define do-nothing constructor for "new" to avoid gratuitous zeroing. (select_info): New base class. (select_pipe_info): New class with methods for dealing with pipes. (select_socket_info): New class with methods for dealing with sockets. (select_serial_info): Dummy class for serial. (select_mailslot_info): Dummy class for mailslots. (select_stuff): Define device_specific_* as actual classes rather than void *. * dtable.h (dtable::select_read): Accommodate return value change to 'bool' and argument change to "select_stuff". (dtable::select_write): Ditto. (dtable::select_except): Ditto. * dtable.cc (dtable::select_read): Accommodate return value change to 'bool' and argument change to "select_stuff". (dtable::select_write): Ditto. (dtable::select_except): Ditto. * fhandler.h: Excise select-related classes. (fhandler_*::select_read): Change argument to select_stuff. (fhandler_*::select_write): Ditto. (fhandler_*::select_except): Ditto. * select.cc (UNIX_FD_ZERO): Use memset rather than bzero. (select_stuff::test_and_set): Change return type to bool. Allocate select_record on entry and let fhandler_*::select_* operate on the start.next field of select_stuff. (pipeinf): Delete. (select_pipe_info::select_pipe_info): New constructor. Allocates event for controlling pipe waits. (select_pipe_info::~select_pipe_info): New destructor. Destroy event. Stop thread. (select_pipe_info::add_watch_handle): New function. (thread_pipe): Wait for the hEvent part of any overlapped pipes before peeking. (start_thread_pipe): Don't allocate device_specific_pipe stuff here. Assume that it has been allocated earlier. (pipe_cleanup): Rely on select_pipe_info destructor to clean up pipe paraphenalia. (fhandler_*::select_*): Derive select_record from new select_stuff argument. (fhandler_pipe::select_*): Ditto. Allocate pipe-specific field if not already allocated. (serialinf): Delete. (thread_serial): serialinf -> select_serial_info. (fhandler_base::ready_for_read): Rewrite to accommodate change in argument to fhandler_*::select_*. (socketinf): Delete. (thread_socket): socketinf -> select_socket_info. (mailslotinf): Delete. (thread_mailslot): mailslotinf -> select_mailslot_info.
2009-06-30 23:18:44 +02:00
select_record *select_read (select_stuff *);
int get_unit ();
virtual char const *ttyname () { return pc.dev.name; }
* autoload.cc (GetNamedPipeClientProcessId): Define. * fhandler.h (fhandler_tty_slave::fch_open_handles): Declare private. (fhandler_tty_slave::fch_close_handles): Ditto. (fhandler_tty_slave::cygserver_attach_tty): Drop declaration. (fhandler_tty_slave::fstat): Declare public. (fhandler_tty_slave::fchmod): Declare public. (fhandler_tty_slave::fchown): Declare public. (class fhandler_pty_master): Add master_ctl handle. (fhandler_pty_master::pty_master_thread): Declare public. * fhandler_termios.cc (fhandler_termios::tcinit): If the process is started from a non-Cygwin process, make it tty process group leader. * fhandler_tty.cc: Throughout accommodate additional security related arguments in calls to functions creating or opening objects. (close_maybe): Move to start of file to reuse it in other methods. (struct pipe_request): Define. (struct pipe_reply): Define. (fhandler_tty_slave::open): Throughout, try to open synchronization objects with MAXIMUM_ALLOWED permissions. Drop call to cygserver. Try to duplicate pipe handles via master_ctl pipe if duplicating directly doesn't work. (fhandler_tty_slave::cygserver_attach_tty): Remove. (fhandler_tty_slave::init): Close unused incoming pipe handle. (fhandler_pty_master::close): Send exit message to master control thread and close master_ctl handle. (fhandler_pty_master::pty_master_thread): New method, implementing the master control thread. (pty_master_thread): Static helper to start master control thread. (fhandler_pty_master::setup): Simplify creating pipe inheritance. Make sure we're the one creating the input_available_event. Add comment to explain why. Create master_ctl pipe and start master control thread. Close master_ctl handle in case of error. * security.cc (alloc_sd): Add code to handle tty objects. Add comments to explain what exactly is required. (get_object_sd): New function. (get_object_attribute): New function. (create_object_sd_from_attribute): New function. (set_object_sd): New function. (set_object_attribute): New function. (set_file_attribute): Change attribute type to mode_t. * security.h (set_file_attribute): Change attribute type to mode_t. (get_object_sd): Declare. (get_object_attribute): Declare. (create_object_sd_from_attribute): Declare. (set_object_sd): Declare. (set_object_attribute): Declare. * tty.cc (tty::slave_alive): Implement directly instead of via alive. (tty::exists): Open mutex handle with READ_CONTROL access. (tty::alive): Remove. (tty::open_output_mutex): Convert to inline method. (tty::open_input_mutex): Ditto. (tty::open_mutex): Take additional ACCESS_MASK parameter for the mutex open access mask. (tty::open_inuse): New method. (tty::create_inuse): Take PSECURITY_ATTRIBUTES parameter. Drop fmt name parameter. Always create TTY_SLAVE_ALIVE event. (tty::get_event): Take additional PSECURITY_ATTRIBUTES parameter for CreateEvent. * tty.h (class tty): Change declarations according to aforementioned changes. (tty::open_output_mutex): Implement as inline method. (tty::open_input_mutex): Ditto.
2010-04-19 21:52:43 +02:00
int __stdcall fstat (struct __stat64 *buf) __attribute__ ((regparm (2)));
int __stdcall fchmod (mode_t mode) __attribute__ ((regparm (1)));
int __stdcall fchown (__uid32_t uid, __gid32_t gid) __attribute__ ((regparm (2)));
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
fhandler_pty_slave (void *) {}
void copyto (fhandler_base *x)
{
x->pc.free_strings ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
*reinterpret_cast<fhandler_pty_slave *> (x) = *this;
x->reset (this);
}
fhandler_pty_slave *clone (cygheap_types malloc_type = HEAP_FHANDLER)
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
{
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_pty_slave));
* fhandler.h (fhandler_pipe::create_selectable): Remove optional argument, take an options argument for CreateNamedPipe/CreateFile. Change handle arguments to expect pointers. (fhandler_fifo::fifo_state): Delete. (fhandler_fifo::dummy_client): Ditto. (fhandler_fifo::open_nonserver): Ditto. (fhandler_fifo::wait_state): Ditto. (fhandler_fifo::raw_write): Ditto. (fhandler_fifo::read_ready): New field. (fhandler_fifo::write_ready): Ditto. (fhandler_fifo::wait): Modify argument. (fhandler_fifo::fifo_name): Add a new argument. (fhandler_fifo::fixup_after_fork): New function. * fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Remove initialization of expunged elements. Initialize new handles to NULL. (fhandler_fifo::open_nonserver): Delete. (fnevent): New macro for creating a named event. (fnpipe): New macro for creating a unique named pipe name. (create_pipe): New macro for simplification of named pipe creation. (fhandler_fifo::fifo_name): Use new argument when creating a shared name. (fhandler_fifo::open): Rewrite. Use events to synchronize. (pure_debug_printf): New macro, active only when DEBUGGING. (fhandler_fifo::wait): Rewrite to wait for new fifo events which are supplied as a parameter. (fhandler_fifo::raw_read): Rewrite to use handle mechanism to detect client-side disconnect. (fhandler_fifo::raw_write): Delete. (fhandler_fifo::close): Remove accommodations for expunged fields. Close event handles. (fhandler_fifo::dup): Remove accommodations for expunged fields. Duplicate event handles. (fhandler_fifo::fixup_after_fork): New function. Perform fixups on event handles. (fhandler_fifo::set_close_on_exec): Remove accommodations for expunged fields. Set inheritance for new handle fields. * miscfuncs.cc (CreatePipeOverlapped): Accommodate changes in fhandler_pipe::create_selectable. * tty.cc (tty::not_allocated): Ditto. * pipe.cc (fhandler_pipe::create): Ditto. (fhandler_pipe::create_selectable): Accept an extra open_mode argument. Pass arguments by reference and allow opening one end of the pipe at a time. * sys/strace.h (debug_only_printf): Define new macro which calls debug_printf only when DEBUGGING is defined.
2011-10-30 05:50:36 +01:00
fhandler_pty_slave *fh = new (ptr) fhandler_pty_slave (ptr);
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
copyto (fh);
return fh;
}
2000-02-17 20:38:33 +01:00
};
#define __ptsname(buf, unit) __small_sprintf ((buf), "/dev/pty%d", (unit))
* 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-14 23:48:43 +02:00
class fhandler_pty_master: public fhandler_pty_common
2000-02-17 20:38:33 +01:00
{
int pktmode; // non-zero if pty in a packet mode.
* autoload.cc (GetNamedPipeClientProcessId): Define. * fhandler.h (fhandler_tty_slave::fch_open_handles): Declare private. (fhandler_tty_slave::fch_close_handles): Ditto. (fhandler_tty_slave::cygserver_attach_tty): Drop declaration. (fhandler_tty_slave::fstat): Declare public. (fhandler_tty_slave::fchmod): Declare public. (fhandler_tty_slave::fchown): Declare public. (class fhandler_pty_master): Add master_ctl handle. (fhandler_pty_master::pty_master_thread): Declare public. * fhandler_termios.cc (fhandler_termios::tcinit): If the process is started from a non-Cygwin process, make it tty process group leader. * fhandler_tty.cc: Throughout accommodate additional security related arguments in calls to functions creating or opening objects. (close_maybe): Move to start of file to reuse it in other methods. (struct pipe_request): Define. (struct pipe_reply): Define. (fhandler_tty_slave::open): Throughout, try to open synchronization objects with MAXIMUM_ALLOWED permissions. Drop call to cygserver. Try to duplicate pipe handles via master_ctl pipe if duplicating directly doesn't work. (fhandler_tty_slave::cygserver_attach_tty): Remove. (fhandler_tty_slave::init): Close unused incoming pipe handle. (fhandler_pty_master::close): Send exit message to master control thread and close master_ctl handle. (fhandler_pty_master::pty_master_thread): New method, implementing the master control thread. (pty_master_thread): Static helper to start master control thread. (fhandler_pty_master::setup): Simplify creating pipe inheritance. Make sure we're the one creating the input_available_event. Add comment to explain why. Create master_ctl pipe and start master control thread. Close master_ctl handle in case of error. * security.cc (alloc_sd): Add code to handle tty objects. Add comments to explain what exactly is required. (get_object_sd): New function. (get_object_attribute): New function. (create_object_sd_from_attribute): New function. (set_object_sd): New function. (set_object_attribute): New function. (set_file_attribute): Change attribute type to mode_t. * security.h (set_file_attribute): Change attribute type to mode_t. (get_object_sd): Declare. (get_object_attribute): Declare. (create_object_sd_from_attribute): Declare. (set_object_sd): Declare. (set_object_attribute): Declare. * tty.cc (tty::slave_alive): Implement directly instead of via alive. (tty::exists): Open mutex handle with READ_CONTROL access. (tty::alive): Remove. (tty::open_output_mutex): Convert to inline method. (tty::open_input_mutex): Ditto. (tty::open_mutex): Take additional ACCESS_MASK parameter for the mutex open access mask. (tty::open_inuse): New method. (tty::create_inuse): Take PSECURITY_ATTRIBUTES parameter. Drop fmt name parameter. Always create TTY_SLAVE_ALIVE event. (tty::get_event): Take additional PSECURITY_ATTRIBUTES parameter for CreateEvent. * tty.h (class tty): Change declarations according to aforementioned changes. (tty::open_output_mutex): Implement as inline method. (tty::open_input_mutex): Ditto.
2010-04-19 21:52:43 +02:00
HANDLE master_ctl; // Control socket for handle duplication
cygthread *master_thread; // Master control thread
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
HANDLE from_master, to_master;
DWORD dwProcessId; // Owner of master handles
* autoload.cc (GetNamedPipeClientProcessId): Define. * fhandler.h (fhandler_tty_slave::fch_open_handles): Declare private. (fhandler_tty_slave::fch_close_handles): Ditto. (fhandler_tty_slave::cygserver_attach_tty): Drop declaration. (fhandler_tty_slave::fstat): Declare public. (fhandler_tty_slave::fchmod): Declare public. (fhandler_tty_slave::fchown): Declare public. (class fhandler_pty_master): Add master_ctl handle. (fhandler_pty_master::pty_master_thread): Declare public. * fhandler_termios.cc (fhandler_termios::tcinit): If the process is started from a non-Cygwin process, make it tty process group leader. * fhandler_tty.cc: Throughout accommodate additional security related arguments in calls to functions creating or opening objects. (close_maybe): Move to start of file to reuse it in other methods. (struct pipe_request): Define. (struct pipe_reply): Define. (fhandler_tty_slave::open): Throughout, try to open synchronization objects with MAXIMUM_ALLOWED permissions. Drop call to cygserver. Try to duplicate pipe handles via master_ctl pipe if duplicating directly doesn't work. (fhandler_tty_slave::cygserver_attach_tty): Remove. (fhandler_tty_slave::init): Close unused incoming pipe handle. (fhandler_pty_master::close): Send exit message to master control thread and close master_ctl handle. (fhandler_pty_master::pty_master_thread): New method, implementing the master control thread. (pty_master_thread): Static helper to start master control thread. (fhandler_pty_master::setup): Simplify creating pipe inheritance. Make sure we're the one creating the input_available_event. Add comment to explain why. Create master_ctl pipe and start master control thread. Close master_ctl handle in case of error. * security.cc (alloc_sd): Add code to handle tty objects. Add comments to explain what exactly is required. (get_object_sd): New function. (get_object_attribute): New function. (create_object_sd_from_attribute): New function. (set_object_sd): New function. (set_object_attribute): New function. (set_file_attribute): Change attribute type to mode_t. * security.h (set_file_attribute): Change attribute type to mode_t. (get_object_sd): Declare. (get_object_attribute): Declare. (create_object_sd_from_attribute): Declare. (set_object_sd): Declare. (set_object_attribute): Declare. * tty.cc (tty::slave_alive): Implement directly instead of via alive. (tty::exists): Open mutex handle with READ_CONTROL access. (tty::alive): Remove. (tty::open_output_mutex): Convert to inline method. (tty::open_input_mutex): Ditto. (tty::open_mutex): Take additional ACCESS_MASK parameter for the mutex open access mask. (tty::open_inuse): New method. (tty::create_inuse): Take PSECURITY_ATTRIBUTES parameter. Drop fmt name parameter. Always create TTY_SLAVE_ALIVE event. (tty::get_event): Take additional PSECURITY_ATTRIBUTES parameter for CreateEvent. * tty.h (class tty): Change declarations according to aforementioned changes. (tty::open_output_mutex): Implement as inline method. (tty::open_input_mutex): Ditto.
2010-04-19 21:52:43 +02:00
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
public:
int need_nl; // Next read should start with \n
2000-02-17 20:38:33 +01:00
/* Constructor */
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
fhandler_pty_master (int);
2000-02-17 20:38:33 +01:00
* autoload.cc (GetNamedPipeClientProcessId): Define. * fhandler.h (fhandler_tty_slave::fch_open_handles): Declare private. (fhandler_tty_slave::fch_close_handles): Ditto. (fhandler_tty_slave::cygserver_attach_tty): Drop declaration. (fhandler_tty_slave::fstat): Declare public. (fhandler_tty_slave::fchmod): Declare public. (fhandler_tty_slave::fchown): Declare public. (class fhandler_pty_master): Add master_ctl handle. (fhandler_pty_master::pty_master_thread): Declare public. * fhandler_termios.cc (fhandler_termios::tcinit): If the process is started from a non-Cygwin process, make it tty process group leader. * fhandler_tty.cc: Throughout accommodate additional security related arguments in calls to functions creating or opening objects. (close_maybe): Move to start of file to reuse it in other methods. (struct pipe_request): Define. (struct pipe_reply): Define. (fhandler_tty_slave::open): Throughout, try to open synchronization objects with MAXIMUM_ALLOWED permissions. Drop call to cygserver. Try to duplicate pipe handles via master_ctl pipe if duplicating directly doesn't work. (fhandler_tty_slave::cygserver_attach_tty): Remove. (fhandler_tty_slave::init): Close unused incoming pipe handle. (fhandler_pty_master::close): Send exit message to master control thread and close master_ctl handle. (fhandler_pty_master::pty_master_thread): New method, implementing the master control thread. (pty_master_thread): Static helper to start master control thread. (fhandler_pty_master::setup): Simplify creating pipe inheritance. Make sure we're the one creating the input_available_event. Add comment to explain why. Create master_ctl pipe and start master control thread. Close master_ctl handle in case of error. * security.cc (alloc_sd): Add code to handle tty objects. Add comments to explain what exactly is required. (get_object_sd): New function. (get_object_attribute): New function. (create_object_sd_from_attribute): New function. (set_object_sd): New function. (set_object_attribute): New function. (set_file_attribute): Change attribute type to mode_t. * security.h (set_file_attribute): Change attribute type to mode_t. (get_object_sd): Declare. (get_object_attribute): Declare. (create_object_sd_from_attribute): Declare. (set_object_sd): Declare. (set_object_attribute): Declare. * tty.cc (tty::slave_alive): Implement directly instead of via alive. (tty::exists): Open mutex handle with READ_CONTROL access. (tty::alive): Remove. (tty::open_output_mutex): Convert to inline method. (tty::open_input_mutex): Ditto. (tty::open_mutex): Take additional ACCESS_MASK parameter for the mutex open access mask. (tty::open_inuse): New method. (tty::create_inuse): Take PSECURITY_ATTRIBUTES parameter. Drop fmt name parameter. Always create TTY_SLAVE_ALIVE event. (tty::get_event): Take additional PSECURITY_ATTRIBUTES parameter for CreateEvent. * tty.h (class tty): Change declarations according to aforementioned changes. (tty::open_output_mutex): Implement as inline method. (tty::open_input_mutex): Ditto.
2010-04-19 21:52:43 +02:00
DWORD pty_master_thread ();
int process_slave_output (char *buf, size_t len, int pktmode_on);
2000-02-17 20:38:33 +01:00
void doecho (const void *str, DWORD len);
int accept_input ();
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
int open (int flags, mode_t mode = 0);
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
void open_setup (int flags);
* sigproc.h (wait_for_sigthread): Eliminate parameter. * sigproc.cc (wait_for_sigthread): Ditto. Don't synchronize with wait_sig after receiving an event that it is ready to go. (init_sig_pipe): New function. (wait_sig): Call init_sig_pipe to create pipes for communicating signals to this process. Don't send sigCONT signal when initializing. * fork.cc (frok::child): Accommodate wait_for_sigpipe parameter change. * fhandler.h (fhandler_*::write): Make ssize_t/__stdcall. (fhandler_*::write_overlapped): Ditto. (fhandler_*::raw_write): Ditto. (fhandler_*::readv): Ditto. (fhandler_*::writev): Ditto. (fhandler_*::raw_read): Make __stdcall. * fhandler: Accommodate changes to read/write functions throughout. * fhandler_clipboard.cc: Ditto. * fhandler_console.cc: Ditto. * fhandler_dsp.cc: Ditto. * fhandler_fifo.cc: Ditto. * fhandler_mailslot.cc: Ditto. * fhandler_mem.cc: Ditto. * fhandler_mem.cc: Ditto. * fhandler_random.cc: Ditto. * fhandler_tape.cc: Ditto. * fhandler_tty.cc: Ditto. * fhandler_virtual.cc: Ditto. * fhandler_windows.cc: Ditto. * fhandler_zero.cc: Ditto. * syscalls.cc (readv): Use ssize_t as temp variable. * fhandler.cc (fhandler_base::read): Coerce returned len to signed or it will never be treated as < 0. (fhandler_base::wait_overlapped): Minimize calls to GetLastError. Remove duplicate debugging test. Fix error return. * fhandler.h (fhandler_fifo::fifo_name): Declare new function. (fhandler_fifo::close): Ditto. (fhandler_fifo::dup): Ditto. (fhandler_fifo::close_on_exec): Ditto. * fhandler.cc (fhandler_fifo::fifo_name): Define new function. (FIFO_BUF_SIZE): New define. (cnp): Ditto. (fhandler_fifo::open): Rework. Use cnp to open named pipe. Always open write side as a client. Open dummy client when writing and can't connect. (wait): Rework. Implement fifo_wait_for_next_client. Handle signals during connect better. Add new fifo_wait_for_server code which polls (sigh) waiting for server. (fhandler_fifo::raw_read): Handle transition states when one client closes and another is available. (fhandler_fifo::close): Define. (fhandler_fifo::dup): Ditto. (fhandler_fifo::close_on_exec): Ditto.
2009-07-24 22:54:33 +02:00
ssize_t __stdcall write (const void *ptr, size_t len);
void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3)));
2000-02-17 20:38:33 +01:00
int close ();
* 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-06 00:30:53 +02:00
void cleanup ();
2000-02-17 20:38:33 +01:00
int tcsetattr (int a, const struct termios *t);
int tcgetattr (struct termios *t);
int tcflush (int);
int ioctl (unsigned int cmd, void *);
int ptsname_r (char *, size_t);
2000-02-17 20:38:33 +01:00
bool hit_eof ();
* 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-14 23:48:43 +02:00
bool setup ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
int dup (fhandler_base *, int);
* fhandler.cc (fhandler_base::fixup_after_exec): Declare here. * fhandler.h (fhandler_base::fixup_after_exec): Make non-inline. (fhandler_termios::fixup_after_fork): Delete declaration. (fhandler_termios::fixup_after_exec): Ditto. (fhandler_tty_common::inuse): Remove. (fhandler_tty_common::dup): Delete declaration. (fhandler_tty_common::fixup_after_fork): Ditto. (fhandler_tty_slave::fixup_after_exec): Declare new function. (fhandler_pty_master::dwProcessId): New variable. (fhandler_pty_master::from_master): Ditto. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::setup): New function. (fhandler_pty_master::fixup_after_fork): Ditto. (fhandler_pty_master::fixup_after_exec): Ditto. * fhandler_termios.cc (fhandler_termios::fixup_after_exec): Delete definition. (fhandler_termios::fixup_after_fork): Ditto. * fhandler_tty.cc (fhandler_tty_master::init): Use fhandler_pty_master setup function rather than obsolete tty::common_init. Delete obsolete inuse setting. (fhandler_tty_slave::fhandler_tty_slave): Set inuse to NULL here. (fhandler_tty_slave::open): Change debugging output for clarity. Check for different things when doing a sanity check on the tty. Reflect the fact that master_pid now is the cygwin pid rather than the windows pid. Use "arch" rather than "archetype" for consistency. (fhandler_tty_slave::close): Close inuse here. (fhandler_tty_slave::dup): Remove old if 0'ed code. (fhandler_pty_master::dup): New function. Handles pty master archetype. (fhandler_pty_master::fhandler_pty_master): Zero pty_master specific fields. (fhandler_pty_master::open): Implement using archetypes, similar to slave. Use fhandler_pty_master setup function rather than obsolete tty::common_init. Don't set inuse. (fhandler_tty_common::close): Don't deal with inuse. Delete old if 0'ed code. (fhandler_pty_master::close): Implement using archetypes. Close from_master and to_master. (fhandler_tty_common::set_close_on_exec): Just set close_on_exec flag here since everything uses archetypes now. (fhandler_tty_common::fixup_after_fork): Delete definition. (fhandler_tty_slave::fixup_after_exec): Define new function. (fhandler_pty_master::setup): New function, derived from tty::common_init. (fhandler_pty_master::fixup_after_fork): New function. (shared_info.h): Reset SHARED_INFO_CB to reflect new tty size. * tty.cc (tty_list::terminate): Close individual handles from tty_master. (tty::master_alive): Delete. (tty::make_pipes): Ditto. (tty::common_init): Ditto. * tty.h (tty::from_slave): Delete. (tty::to_slave): Ditto. (tty::common_init): Delete declaration. (tty::make_pipes): Ditto. (tty::master_pid): Define as pid_t since it is now a cygwin pid.
2006-06-02 17:41:34 +02:00
void fixup_after_fork (HANDLE parent);
void fixup_after_exec ();
int tcgetpgrp ();
void flush_to_slave ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
fhandler_pty_master (void *) {}
~fhandler_pty_master ();
void copyto (fhandler_base *x)
{
x->pc.free_strings ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
*reinterpret_cast<fhandler_pty_master *> (x) = *this;
x->reset (this);
}
fhandler_pty_master *clone (cygheap_types malloc_type = HEAP_FHANDLER)
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
{
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_pty_master));
* fhandler.h (fhandler_pipe::create_selectable): Remove optional argument, take an options argument for CreateNamedPipe/CreateFile. Change handle arguments to expect pointers. (fhandler_fifo::fifo_state): Delete. (fhandler_fifo::dummy_client): Ditto. (fhandler_fifo::open_nonserver): Ditto. (fhandler_fifo::wait_state): Ditto. (fhandler_fifo::raw_write): Ditto. (fhandler_fifo::read_ready): New field. (fhandler_fifo::write_ready): Ditto. (fhandler_fifo::wait): Modify argument. (fhandler_fifo::fifo_name): Add a new argument. (fhandler_fifo::fixup_after_fork): New function. * fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Remove initialization of expunged elements. Initialize new handles to NULL. (fhandler_fifo::open_nonserver): Delete. (fnevent): New macro for creating a named event. (fnpipe): New macro for creating a unique named pipe name. (create_pipe): New macro for simplification of named pipe creation. (fhandler_fifo::fifo_name): Use new argument when creating a shared name. (fhandler_fifo::open): Rewrite. Use events to synchronize. (pure_debug_printf): New macro, active only when DEBUGGING. (fhandler_fifo::wait): Rewrite to wait for new fifo events which are supplied as a parameter. (fhandler_fifo::raw_read): Rewrite to use handle mechanism to detect client-side disconnect. (fhandler_fifo::raw_write): Delete. (fhandler_fifo::close): Remove accommodations for expunged fields. Close event handles. (fhandler_fifo::dup): Remove accommodations for expunged fields. Duplicate event handles. (fhandler_fifo::fixup_after_fork): New function. Perform fixups on event handles. (fhandler_fifo::set_close_on_exec): Remove accommodations for expunged fields. Set inheritance for new handle fields. * miscfuncs.cc (CreatePipeOverlapped): Accommodate changes in fhandler_pipe::create_selectable. * tty.cc (tty::not_allocated): Ditto. * pipe.cc (fhandler_pipe::create): Ditto. (fhandler_pipe::create_selectable): Accept an extra open_mode argument. Pass arguments by reference and allow opening one end of the pipe at a time. * sys/strace.h (debug_only_printf): Define new macro which calls debug_printf only when DEBUGGING is defined.
2011-10-30 05:50:36 +01:00
fhandler_pty_master *fh = new (ptr) fhandler_pty_master (ptr);
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
copyto (fh);
return fh;
}
2000-02-17 20:38:33 +01:00
};
class fhandler_dev_null: public fhandler_base
{
* dtable.cc (dtable::build_fhandler): Issue internal error on unknown device. * fhandler.cc (fhandler_base::close): Show both name and handle in debugging output. * fhandler.h (fhandler_base::get_guard): New virtual method. (fhandler_pipe::get_guard): New method. (fhandler_socket::ready_for_read): Delete declaration. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (struct select_record::peek): Declare new method. * select.cc (MAKEready): Delete. (peek_pipe): Use get_guard method to retrieve potential guard mutex handle. (fhandler_base::ready_for_read): Rewrite as generic ready-for-read handler. Should only be called for "slow" devices. (fhandler_socket::ready_for_read): Delete definition. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (fhandler_pipe::select_read): Fill in new peek record in select_record structure. (fhandler_console::select_read): Ditto. (fhandler_tty_common::select_read): Ditto. (fhandler_serial::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_tty_slave::ready_for_read): Check for tty not open. Set errnos appropriately. * syscalls.cc (_read): Allow ready_for_read to set errno. * pinfo.cc (pinfo::init): Return spawn/NO_WAIT process as valid if it is initializing. * sigproc.cc (getsem): Adjust wait for process to initialize downward to avoid huge waits.
2001-11-01 22:15:53 +01:00
public:
fhandler_dev_null ();
2000-02-17 20:38:33 +01:00
* select.h: New file split from fhandler.h. (select_record::select_record): Define do-nothing constructor for "new" to avoid gratuitous zeroing. (select_info): New base class. (select_pipe_info): New class with methods for dealing with pipes. (select_socket_info): New class with methods for dealing with sockets. (select_serial_info): Dummy class for serial. (select_mailslot_info): Dummy class for mailslots. (select_stuff): Define device_specific_* as actual classes rather than void *. * dtable.h (dtable::select_read): Accommodate return value change to 'bool' and argument change to "select_stuff". (dtable::select_write): Ditto. (dtable::select_except): Ditto. * dtable.cc (dtable::select_read): Accommodate return value change to 'bool' and argument change to "select_stuff". (dtable::select_write): Ditto. (dtable::select_except): Ditto. * fhandler.h: Excise select-related classes. (fhandler_*::select_read): Change argument to select_stuff. (fhandler_*::select_write): Ditto. (fhandler_*::select_except): Ditto. * select.cc (UNIX_FD_ZERO): Use memset rather than bzero. (select_stuff::test_and_set): Change return type to bool. Allocate select_record on entry and let fhandler_*::select_* operate on the start.next field of select_stuff. (pipeinf): Delete. (select_pipe_info::select_pipe_info): New constructor. Allocates event for controlling pipe waits. (select_pipe_info::~select_pipe_info): New destructor. Destroy event. Stop thread. (select_pipe_info::add_watch_handle): New function. (thread_pipe): Wait for the hEvent part of any overlapped pipes before peeking. (start_thread_pipe): Don't allocate device_specific_pipe stuff here. Assume that it has been allocated earlier. (pipe_cleanup): Rely on select_pipe_info destructor to clean up pipe paraphenalia. (fhandler_*::select_*): Derive select_record from new select_stuff argument. (fhandler_pipe::select_*): Ditto. Allocate pipe-specific field if not already allocated. (serialinf): Delete. (thread_serial): serialinf -> select_serial_info. (fhandler_base::ready_for_read): Rewrite to accommodate change in argument to fhandler_*::select_*. (socketinf): Delete. (thread_socket): socketinf -> select_socket_info. (mailslotinf): Delete. (thread_mailslot): mailslotinf -> select_mailslot_info.
2009-06-30 23:18:44 +02:00
select_record *select_read (select_stuff *);
select_record *select_write (select_stuff *);
select_record *select_except (select_stuff *);
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
fhandler_dev_null (void *) {}
void copyto (fhandler_base *x)
{
x->pc.free_strings ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
*reinterpret_cast<fhandler_dev_null *> (x) = *this;
x->reset (this);
}
fhandler_dev_null *clone (cygheap_types malloc_type = HEAP_FHANDLER)
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
{
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_dev_null));
* fhandler.h (fhandler_pipe::create_selectable): Remove optional argument, take an options argument for CreateNamedPipe/CreateFile. Change handle arguments to expect pointers. (fhandler_fifo::fifo_state): Delete. (fhandler_fifo::dummy_client): Ditto. (fhandler_fifo::open_nonserver): Ditto. (fhandler_fifo::wait_state): Ditto. (fhandler_fifo::raw_write): Ditto. (fhandler_fifo::read_ready): New field. (fhandler_fifo::write_ready): Ditto. (fhandler_fifo::wait): Modify argument. (fhandler_fifo::fifo_name): Add a new argument. (fhandler_fifo::fixup_after_fork): New function. * fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Remove initialization of expunged elements. Initialize new handles to NULL. (fhandler_fifo::open_nonserver): Delete. (fnevent): New macro for creating a named event. (fnpipe): New macro for creating a unique named pipe name. (create_pipe): New macro for simplification of named pipe creation. (fhandler_fifo::fifo_name): Use new argument when creating a shared name. (fhandler_fifo::open): Rewrite. Use events to synchronize. (pure_debug_printf): New macro, active only when DEBUGGING. (fhandler_fifo::wait): Rewrite to wait for new fifo events which are supplied as a parameter. (fhandler_fifo::raw_read): Rewrite to use handle mechanism to detect client-side disconnect. (fhandler_fifo::raw_write): Delete. (fhandler_fifo::close): Remove accommodations for expunged fields. Close event handles. (fhandler_fifo::dup): Remove accommodations for expunged fields. Duplicate event handles. (fhandler_fifo::fixup_after_fork): New function. Perform fixups on event handles. (fhandler_fifo::set_close_on_exec): Remove accommodations for expunged fields. Set inheritance for new handle fields. * miscfuncs.cc (CreatePipeOverlapped): Accommodate changes in fhandler_pipe::create_selectable. * tty.cc (tty::not_allocated): Ditto. * pipe.cc (fhandler_pipe::create): Ditto. (fhandler_pipe::create_selectable): Accept an extra open_mode argument. Pass arguments by reference and allow opening one end of the pipe at a time. * sys/strace.h (debug_only_printf): Define new macro which calls debug_printf only when DEBUGGING is defined.
2011-10-30 05:50:36 +01:00
fhandler_dev_null *fh = new (ptr) fhandler_dev_null (ptr);
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
copyto (fh);
return fh;
}
2000-02-17 20:38:33 +01:00
};
class fhandler_dev_zero: public fhandler_base
{
* dtable.cc (dtable::build_fhandler): Issue internal error on unknown device. * fhandler.cc (fhandler_base::close): Show both name and handle in debugging output. * fhandler.h (fhandler_base::get_guard): New virtual method. (fhandler_pipe::get_guard): New method. (fhandler_socket::ready_for_read): Delete declaration. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (struct select_record::peek): Declare new method. * select.cc (MAKEready): Delete. (peek_pipe): Use get_guard method to retrieve potential guard mutex handle. (fhandler_base::ready_for_read): Rewrite as generic ready-for-read handler. Should only be called for "slow" devices. (fhandler_socket::ready_for_read): Delete definition. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (fhandler_pipe::select_read): Fill in new peek record in select_record structure. (fhandler_console::select_read): Ditto. (fhandler_tty_common::select_read): Ditto. (fhandler_serial::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_tty_slave::ready_for_read): Check for tty not open. Set errnos appropriately. * syscalls.cc (_read): Allow ready_for_read to set errno. * pinfo.cc (pinfo::init): Return spawn/NO_WAIT process as valid if it is initializing. * sigproc.cc (getsem): Adjust wait for process to initialize downward to avoid huge waits.
2001-11-01 22:15:53 +01:00
public:
fhandler_dev_zero ();
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
int open (int flags, mode_t mode = 0);
* sigproc.h (wait_for_sigthread): Eliminate parameter. * sigproc.cc (wait_for_sigthread): Ditto. Don't synchronize with wait_sig after receiving an event that it is ready to go. (init_sig_pipe): New function. (wait_sig): Call init_sig_pipe to create pipes for communicating signals to this process. Don't send sigCONT signal when initializing. * fork.cc (frok::child): Accommodate wait_for_sigpipe parameter change. * fhandler.h (fhandler_*::write): Make ssize_t/__stdcall. (fhandler_*::write_overlapped): Ditto. (fhandler_*::raw_write): Ditto. (fhandler_*::readv): Ditto. (fhandler_*::writev): Ditto. (fhandler_*::raw_read): Make __stdcall. * fhandler: Accommodate changes to read/write functions throughout. * fhandler_clipboard.cc: Ditto. * fhandler_console.cc: Ditto. * fhandler_dsp.cc: Ditto. * fhandler_fifo.cc: Ditto. * fhandler_mailslot.cc: Ditto. * fhandler_mem.cc: Ditto. * fhandler_mem.cc: Ditto. * fhandler_random.cc: Ditto. * fhandler_tape.cc: Ditto. * fhandler_tty.cc: Ditto. * fhandler_virtual.cc: Ditto. * fhandler_windows.cc: Ditto. * fhandler_zero.cc: Ditto. * syscalls.cc (readv): Use ssize_t as temp variable. * fhandler.cc (fhandler_base::read): Coerce returned len to signed or it will never be treated as < 0. (fhandler_base::wait_overlapped): Minimize calls to GetLastError. Remove duplicate debugging test. Fix error return. * fhandler.h (fhandler_fifo::fifo_name): Declare new function. (fhandler_fifo::close): Ditto. (fhandler_fifo::dup): Ditto. (fhandler_fifo::close_on_exec): Ditto. * fhandler.cc (fhandler_fifo::fifo_name): Define new function. (FIFO_BUF_SIZE): New define. (cnp): Ditto. (fhandler_fifo::open): Rework. Use cnp to open named pipe. Always open write side as a client. Open dummy client when writing and can't connect. (wait): Rework. Implement fifo_wait_for_next_client. Handle signals during connect better. Add new fifo_wait_for_server code which polls (sigh) waiting for server. (fhandler_fifo::raw_read): Handle transition states when one client closes and another is available. (fhandler_fifo::close): Define. (fhandler_fifo::dup): Ditto. (fhandler_fifo::close_on_exec): Ditto.
2009-07-24 22:54:33 +02:00
ssize_t __stdcall write (const void *ptr, size_t len);
void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3)));
_off64_t lseek (_off64_t offset, int whence);
* fhandler.h (fhandler_dev_zero::mmap): Add method. (fhandler_dev_zero::munmap): Ditto. (fhandler_dev_zero::msync): Ditto. (fhandler_dev_zero::fixup_mmap_after_fork): Ditto. * mmap.cc: Implement anonymous mapping using fhandler_dev_zero class. Implement private anonymous maps using VirtualAlloc/VirtualFree. Fix or add some more comments. (fh_paging_file): Change to type fhandler_dev_zero. (priv): New static inline function to avoid having lots of flag bit tests in the code. Use throughout were appropriate. (fixed): Ditto. (anonymous): Ditto. (noreserve): Ditto. (autogrow): Ditto. (gen_protect): Never generate PAGE_WRITECOPY protection for private anonymous maps. (gen_access): Drop FILE_MAP_EXECUTE handling since it's not supported correctly on 9x. (VirtualProt9x): Move comment from mmap64 here. (mmap_record::mmap_record): Gegerate correct device entry for anonymous maps, though unused right now. (mmap_record::priv): Call global priv function. (mmap_record::fixed): Call global fixed function. (mmap_record::anonymous): Call global anonymous function. (mmap_record::noreserve): Call global noreserve function. (mmap_record::autogrow): Call global autogrow function. (list::anonymous): New method. Use throughout were appropriate. (mmap_record::compatible_flags): Drop now useless ifdef. (mmap_record::alloc_page_map): Accomodate private anonymous maps. (mmap_record::map_pages): Accomodate MAP_NORESERVE mappings. (mmap_record::unmap_pages): Accomodate private anonymous maps. (mmap64): Simplify argument check. Don't remove the MAP_PRIVATE flag for anonymous mappings on 9x anymore since that's now handled gracefully. (mprotect): Accomodate MAP_NORESERVE mappings. Fix case when non-mmap areas are just MEM_RESERVEd. (fhandler_dev_zero::mmap): Implement anonymous mapping here. (fhandler_dev_zero::munmap): Ditto. (fhandler_dev_zero::msyn): Ditto. (fhandler_dev_zero::fixup_mmap_after_fork): Ditto. (fixup_mmaps_after_fork): Accomodate private anonymous maps. Enhance debug output in case VirtualProtect fails. * include/sys/mman.h: Really define MAP_NORESERVE now.
2005-11-29 17:28:05 +01:00
virtual HANDLE mmap (caddr_t *addr, size_t len, int prot,
int flags, _off64_t off);
virtual int munmap (HANDLE h, caddr_t addr, size_t len);
virtual int msync (HANDLE h, caddr_t addr, size_t len, int flags);
virtual bool fixup_mmap_after_fork (HANDLE h, int prot, int flags,
_off64_t offset, DWORD size,
void *address);
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
fhandler_dev_zero (void *) {}
void copyto (fhandler_base *x)
{
x->pc.free_strings ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
*reinterpret_cast<fhandler_dev_zero *> (x) = *this;
x->reset (this);
}
fhandler_dev_zero *clone (cygheap_types malloc_type = HEAP_FHANDLER)
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
{
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_dev_zero));
* fhandler.h (fhandler_pipe::create_selectable): Remove optional argument, take an options argument for CreateNamedPipe/CreateFile. Change handle arguments to expect pointers. (fhandler_fifo::fifo_state): Delete. (fhandler_fifo::dummy_client): Ditto. (fhandler_fifo::open_nonserver): Ditto. (fhandler_fifo::wait_state): Ditto. (fhandler_fifo::raw_write): Ditto. (fhandler_fifo::read_ready): New field. (fhandler_fifo::write_ready): Ditto. (fhandler_fifo::wait): Modify argument. (fhandler_fifo::fifo_name): Add a new argument. (fhandler_fifo::fixup_after_fork): New function. * fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Remove initialization of expunged elements. Initialize new handles to NULL. (fhandler_fifo::open_nonserver): Delete. (fnevent): New macro for creating a named event. (fnpipe): New macro for creating a unique named pipe name. (create_pipe): New macro for simplification of named pipe creation. (fhandler_fifo::fifo_name): Use new argument when creating a shared name. (fhandler_fifo::open): Rewrite. Use events to synchronize. (pure_debug_printf): New macro, active only when DEBUGGING. (fhandler_fifo::wait): Rewrite to wait for new fifo events which are supplied as a parameter. (fhandler_fifo::raw_read): Rewrite to use handle mechanism to detect client-side disconnect. (fhandler_fifo::raw_write): Delete. (fhandler_fifo::close): Remove accommodations for expunged fields. Close event handles. (fhandler_fifo::dup): Remove accommodations for expunged fields. Duplicate event handles. (fhandler_fifo::fixup_after_fork): New function. Perform fixups on event handles. (fhandler_fifo::set_close_on_exec): Remove accommodations for expunged fields. Set inheritance for new handle fields. * miscfuncs.cc (CreatePipeOverlapped): Accommodate changes in fhandler_pipe::create_selectable. * tty.cc (tty::not_allocated): Ditto. * pipe.cc (fhandler_pipe::create): Ditto. (fhandler_pipe::create_selectable): Accept an extra open_mode argument. Pass arguments by reference and allow opening one end of the pipe at a time. * sys/strace.h (debug_only_printf): Define new macro which calls debug_printf only when DEBUGGING is defined.
2011-10-30 05:50:36 +01:00
fhandler_dev_zero *fh = new (ptr) fhandler_dev_zero (ptr);
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
copyto (fh);
return fh;
}
2000-02-17 20:38:33 +01:00
};
class fhandler_dev_random: public fhandler_base
{
* dtable.cc (dtable::build_fhandler): Issue internal error on unknown device. * fhandler.cc (fhandler_base::close): Show both name and handle in debugging output. * fhandler.h (fhandler_base::get_guard): New virtual method. (fhandler_pipe::get_guard): New method. (fhandler_socket::ready_for_read): Delete declaration. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (struct select_record::peek): Declare new method. * select.cc (MAKEready): Delete. (peek_pipe): Use get_guard method to retrieve potential guard mutex handle. (fhandler_base::ready_for_read): Rewrite as generic ready-for-read handler. Should only be called for "slow" devices. (fhandler_socket::ready_for_read): Delete definition. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (fhandler_pipe::select_read): Fill in new peek record in select_record structure. (fhandler_console::select_read): Ditto. (fhandler_tty_common::select_read): Ditto. (fhandler_serial::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_tty_slave::ready_for_read): Check for tty not open. Set errnos appropriately. * syscalls.cc (_read): Allow ready_for_read to set errno. * pinfo.cc (pinfo::init): Return spawn/NO_WAIT process as valid if it is initializing. * sigproc.cc (getsem): Adjust wait for process to initialize downward to avoid huge waits.
2001-11-01 22:15:53 +01:00
protected:
HCRYPTPROV crypt_prov;
long pseudo;
_off64_t dummy_offset;
bool crypt_gen_random (void *ptr, size_t len);
int pseudo_write (const void *ptr, size_t len);
int pseudo_read (void *ptr, size_t len);
2000-07-23 23:13:05 +02:00
* dtable.cc (dtable::build_fhandler): Issue internal error on unknown device. * fhandler.cc (fhandler_base::close): Show both name and handle in debugging output. * fhandler.h (fhandler_base::get_guard): New virtual method. (fhandler_pipe::get_guard): New method. (fhandler_socket::ready_for_read): Delete declaration. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (struct select_record::peek): Declare new method. * select.cc (MAKEready): Delete. (peek_pipe): Use get_guard method to retrieve potential guard mutex handle. (fhandler_base::ready_for_read): Rewrite as generic ready-for-read handler. Should only be called for "slow" devices. (fhandler_socket::ready_for_read): Delete definition. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (fhandler_pipe::select_read): Fill in new peek record in select_record structure. (fhandler_console::select_read): Ditto. (fhandler_tty_common::select_read): Ditto. (fhandler_serial::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_tty_slave::ready_for_read): Check for tty not open. Set errnos appropriately. * syscalls.cc (_read): Allow ready_for_read to set errno. * pinfo.cc (pinfo::init): Return spawn/NO_WAIT process as valid if it is initializing. * sigproc.cc (getsem): Adjust wait for process to initialize downward to avoid huge waits.
2001-11-01 22:15:53 +01:00
public:
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
fhandler_dev_random ();
int open (int flags, mode_t mode = 0);
* sigproc.h (wait_for_sigthread): Eliminate parameter. * sigproc.cc (wait_for_sigthread): Ditto. Don't synchronize with wait_sig after receiving an event that it is ready to go. (init_sig_pipe): New function. (wait_sig): Call init_sig_pipe to create pipes for communicating signals to this process. Don't send sigCONT signal when initializing. * fork.cc (frok::child): Accommodate wait_for_sigpipe parameter change. * fhandler.h (fhandler_*::write): Make ssize_t/__stdcall. (fhandler_*::write_overlapped): Ditto. (fhandler_*::raw_write): Ditto. (fhandler_*::readv): Ditto. (fhandler_*::writev): Ditto. (fhandler_*::raw_read): Make __stdcall. * fhandler: Accommodate changes to read/write functions throughout. * fhandler_clipboard.cc: Ditto. * fhandler_console.cc: Ditto. * fhandler_dsp.cc: Ditto. * fhandler_fifo.cc: Ditto. * fhandler_mailslot.cc: Ditto. * fhandler_mem.cc: Ditto. * fhandler_mem.cc: Ditto. * fhandler_random.cc: Ditto. * fhandler_tape.cc: Ditto. * fhandler_tty.cc: Ditto. * fhandler_virtual.cc: Ditto. * fhandler_windows.cc: Ditto. * fhandler_zero.cc: Ditto. * syscalls.cc (readv): Use ssize_t as temp variable. * fhandler.cc (fhandler_base::read): Coerce returned len to signed or it will never be treated as < 0. (fhandler_base::wait_overlapped): Minimize calls to GetLastError. Remove duplicate debugging test. Fix error return. * fhandler.h (fhandler_fifo::fifo_name): Declare new function. (fhandler_fifo::close): Ditto. (fhandler_fifo::dup): Ditto. (fhandler_fifo::close_on_exec): Ditto. * fhandler.cc (fhandler_fifo::fifo_name): Define new function. (FIFO_BUF_SIZE): New define. (cnp): Ditto. (fhandler_fifo::open): Rework. Use cnp to open named pipe. Always open write side as a client. Open dummy client when writing and can't connect. (wait): Rework. Implement fifo_wait_for_next_client. Handle signals during connect better. Add new fifo_wait_for_server code which polls (sigh) waiting for server. (fhandler_fifo::raw_read): Handle transition states when one client closes and another is available. (fhandler_fifo::close): Define. (fhandler_fifo::dup): Ditto. (fhandler_fifo::close_on_exec): Ditto.
2009-07-24 22:54:33 +02:00
ssize_t __stdcall write (const void *ptr, size_t len);
void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3)));
_off64_t lseek (_off64_t offset, int whence);
int close ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
int dup (fhandler_base *child, int);
fhandler_dev_random (void *) {}
void copyto (fhandler_base *x)
{
x->pc.free_strings ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
*reinterpret_cast<fhandler_dev_random *> (x) = *this;
x->reset (this);
}
fhandler_dev_random *clone (cygheap_types malloc_type = HEAP_FHANDLER)
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
{
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_dev_random));
* fhandler.h (fhandler_pipe::create_selectable): Remove optional argument, take an options argument for CreateNamedPipe/CreateFile. Change handle arguments to expect pointers. (fhandler_fifo::fifo_state): Delete. (fhandler_fifo::dummy_client): Ditto. (fhandler_fifo::open_nonserver): Ditto. (fhandler_fifo::wait_state): Ditto. (fhandler_fifo::raw_write): Ditto. (fhandler_fifo::read_ready): New field. (fhandler_fifo::write_ready): Ditto. (fhandler_fifo::wait): Modify argument. (fhandler_fifo::fifo_name): Add a new argument. (fhandler_fifo::fixup_after_fork): New function. * fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Remove initialization of expunged elements. Initialize new handles to NULL. (fhandler_fifo::open_nonserver): Delete. (fnevent): New macro for creating a named event. (fnpipe): New macro for creating a unique named pipe name. (create_pipe): New macro for simplification of named pipe creation. (fhandler_fifo::fifo_name): Use new argument when creating a shared name. (fhandler_fifo::open): Rewrite. Use events to synchronize. (pure_debug_printf): New macro, active only when DEBUGGING. (fhandler_fifo::wait): Rewrite to wait for new fifo events which are supplied as a parameter. (fhandler_fifo::raw_read): Rewrite to use handle mechanism to detect client-side disconnect. (fhandler_fifo::raw_write): Delete. (fhandler_fifo::close): Remove accommodations for expunged fields. Close event handles. (fhandler_fifo::dup): Remove accommodations for expunged fields. Duplicate event handles. (fhandler_fifo::fixup_after_fork): New function. Perform fixups on event handles. (fhandler_fifo::set_close_on_exec): Remove accommodations for expunged fields. Set inheritance for new handle fields. * miscfuncs.cc (CreatePipeOverlapped): Accommodate changes in fhandler_pipe::create_selectable. * tty.cc (tty::not_allocated): Ditto. * pipe.cc (fhandler_pipe::create): Ditto. (fhandler_pipe::create_selectable): Accept an extra open_mode argument. Pass arguments by reference and allow opening one end of the pipe at a time. * sys/strace.h (debug_only_printf): Define new macro which calls debug_printf only when DEBUGGING is defined.
2011-10-30 05:50:36 +01:00
fhandler_dev_random *fh = new (ptr) fhandler_dev_random (ptr);
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
copyto (fh);
return fh;
}
};
class fhandler_dev_mem: public fhandler_base
{
* dtable.cc (dtable::build_fhandler): Issue internal error on unknown device. * fhandler.cc (fhandler_base::close): Show both name and handle in debugging output. * fhandler.h (fhandler_base::get_guard): New virtual method. (fhandler_pipe::get_guard): New method. (fhandler_socket::ready_for_read): Delete declaration. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (struct select_record::peek): Declare new method. * select.cc (MAKEready): Delete. (peek_pipe): Use get_guard method to retrieve potential guard mutex handle. (fhandler_base::ready_for_read): Rewrite as generic ready-for-read handler. Should only be called for "slow" devices. (fhandler_socket::ready_for_read): Delete definition. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (fhandler_pipe::select_read): Fill in new peek record in select_record structure. (fhandler_console::select_read): Ditto. (fhandler_tty_common::select_read): Ditto. (fhandler_serial::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_tty_slave::ready_for_read): Check for tty not open. Set errnos appropriately. * syscalls.cc (_read): Allow ready_for_read to set errno. * pinfo.cc (pinfo::init): Return spawn/NO_WAIT process as valid if it is initializing. * sigproc.cc (getsem): Adjust wait for process to initialize downward to avoid huge waits.
2001-11-01 22:15:53 +01:00
protected:
DWORD mem_size;
_off64_t pos;
* dtable.cc (dtable::build_fhandler): Issue internal error on unknown device. * fhandler.cc (fhandler_base::close): Show both name and handle in debugging output. * fhandler.h (fhandler_base::get_guard): New virtual method. (fhandler_pipe::get_guard): New method. (fhandler_socket::ready_for_read): Delete declaration. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (struct select_record::peek): Declare new method. * select.cc (MAKEready): Delete. (peek_pipe): Use get_guard method to retrieve potential guard mutex handle. (fhandler_base::ready_for_read): Rewrite as generic ready-for-read handler. Should only be called for "slow" devices. (fhandler_socket::ready_for_read): Delete definition. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (fhandler_pipe::select_read): Fill in new peek record in select_record structure. (fhandler_console::select_read): Ditto. (fhandler_tty_common::select_read): Ditto. (fhandler_serial::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_tty_slave::ready_for_read): Check for tty not open. Set errnos appropriately. * syscalls.cc (_read): Allow ready_for_read to set errno. * pinfo.cc (pinfo::init): Return spawn/NO_WAIT process as valid if it is initializing. * sigproc.cc (getsem): Adjust wait for process to initialize downward to avoid huge waits.
2001-11-01 22:15:53 +01:00
public:
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
fhandler_dev_mem ();
~fhandler_dev_mem ();
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
int open (int flags, mode_t mode = 0);
* sigproc.h (wait_for_sigthread): Eliminate parameter. * sigproc.cc (wait_for_sigthread): Ditto. Don't synchronize with wait_sig after receiving an event that it is ready to go. (init_sig_pipe): New function. (wait_sig): Call init_sig_pipe to create pipes for communicating signals to this process. Don't send sigCONT signal when initializing. * fork.cc (frok::child): Accommodate wait_for_sigpipe parameter change. * fhandler.h (fhandler_*::write): Make ssize_t/__stdcall. (fhandler_*::write_overlapped): Ditto. (fhandler_*::raw_write): Ditto. (fhandler_*::readv): Ditto. (fhandler_*::writev): Ditto. (fhandler_*::raw_read): Make __stdcall. * fhandler: Accommodate changes to read/write functions throughout. * fhandler_clipboard.cc: Ditto. * fhandler_console.cc: Ditto. * fhandler_dsp.cc: Ditto. * fhandler_fifo.cc: Ditto. * fhandler_mailslot.cc: Ditto. * fhandler_mem.cc: Ditto. * fhandler_mem.cc: Ditto. * fhandler_random.cc: Ditto. * fhandler_tape.cc: Ditto. * fhandler_tty.cc: Ditto. * fhandler_virtual.cc: Ditto. * fhandler_windows.cc: Ditto. * fhandler_zero.cc: Ditto. * syscalls.cc (readv): Use ssize_t as temp variable. * fhandler.cc (fhandler_base::read): Coerce returned len to signed or it will never be treated as < 0. (fhandler_base::wait_overlapped): Minimize calls to GetLastError. Remove duplicate debugging test. Fix error return. * fhandler.h (fhandler_fifo::fifo_name): Declare new function. (fhandler_fifo::close): Ditto. (fhandler_fifo::dup): Ditto. (fhandler_fifo::close_on_exec): Ditto. * fhandler.cc (fhandler_fifo::fifo_name): Define new function. (FIFO_BUF_SIZE): New define. (cnp): Ditto. (fhandler_fifo::open): Rework. Use cnp to open named pipe. Always open write side as a client. Open dummy client when writing and can't connect. (wait): Rework. Implement fifo_wait_for_next_client. Handle signals during connect better. Add new fifo_wait_for_server code which polls (sigh) waiting for server. (fhandler_fifo::raw_read): Handle transition states when one client closes and another is available. (fhandler_fifo::close): Define. (fhandler_fifo::dup): Ditto. (fhandler_fifo::close_on_exec): Ditto.
2009-07-24 22:54:33 +02:00
ssize_t __stdcall write (const void *ptr, size_t ulen);
void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3)));
_off64_t lseek (_off64_t offset, int whence);
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
int __stdcall fstat (struct __stat64 *buf) __attribute__ ((regparm (2)));
* autoload.cc (NtCreateSection): Define. * cygheap.cc (_csbrk): Call getpagesize instead of getshmlba. * dcrt0.cc (dll_crt0_0): Call mmap_init. * external.cc (cygwin_internal): Call getpagesize instead of getshmlba. * fhandler.h (fhandler_base::mmap): Change access to prot parameter. (fhandler_base::fixup_mmap_after_fork): Ditto. (fhandler_disk_file::mmap): Ditto. (fhandler_disk_file::fixup_mmap_after_fork): Ditto. (fhandler_dev_mem::mmap): Ditto. (fhandler_dev_mem::fixup_mmap_after_fork): Ditto. * fhandler_mem.cc (fhandler_dev_mem::write): Call getsystempagesize instead of getpagesize. (fhandler_dev_mem::read): Ditto. (fhandler_dev_mem::fstat): Ditto. (fhandler_dev_mem::mmap): Move to mmap.cc. (fhandler_dev_mem::munmap): Ditto. (fhandler_dev_mem::msync): Ditto. (fhandler_dev_mem::fixup_mmap_after_fork): Ditto. * fhandler_proc.cc (format_proc_meminfo): Call getsystempagesize instead of getpagesize. * fhandler_process.cc (format_process_stat): Ditto. (format_process_status): Ditto. (get_mem_values): Ditto. * mmap.cc: Fix formatting. Try to make more readable and modular. Take advantage of pagesize==granularity. (gen_protect): New static function to evaluate Windows protection bits from POSIX protection and flags. (gen_access): Ditto for Windows access mode. (VirtualProt9x): Wrapper function to call VirtualProtect on 9x. (VirtualProtNT): Ditto for NT. (VirtualProtEx9x): Ditto for VirtualProtectEx on 9x. (VirtualProtExNT): Ditto for NT. (CreateMapping9x): Wrapper function for creating a mapping handle on 9x. (CreateMappingNT): Ditto for NT. (MapView9x): Wrapper function to map a view on 9x. (MapViewNT): Ditto for NT. (mmap_funcs_9x): Structure containing function pointers to wrapper functions for 9x. (mmap_funcs_nt): Ditto for NT. (mmap_func): Pointer to wrapper functions used in subsequent code. (mmap_init): Initialize mmap_func depending on OS. (class mmap_record): Use sensible member names. Add POSIX protection member. Drop Windows access flags member. Constify more methods. Use accessors instead of direct member access inside of own methods. (mmap_record::gen_protect): Class wrapper to evaluate matching Windows protection bits. (mmap_record::gen_access): Ditto for Windows access flags. (mmap_record::compatible_flags): New function to check if flags are compatible with flags of existing map. (list::add_record): Drop offset and length arguments. (class map): Change counters to unsigned. Match usage throughout. (mmapped_areas): Convert from pointer to global struct. (mmap_record::alloc_page_map): Simplify. (mmap_record::map_pages): Ditto. (mmap_record::fixup_page_map): Delete. (mmap64): Simplify. Add workaround for Windows 98 bug. Fix bug on NT that existing anonymous mappings weren't searched for a match. (munmap): Add workaround for Windows 98 bug. (msync): Simplify. (mprotect): Handle existing maps correctly. (mlock): Add local pagesize variable and enlightening comment. (fhandler_disk_file::mmap): Main functionality now in CreateMapping/ MapView wrapper functions. (fhandler_disk_file::fixup_mmap_after_fork): Call MapView wrapper. (fhandler_dev_mem::mmap): Moved from fhandler_mem.cc. Simplify by calling MapViewNT. (fhandler_dev_mem::munmap): Moved from fhandler_mem.cc. (fhandler_dev_mem::msync): Ditto. (fhandler_dev_mem::fixup_mmap_after_fork): Ditto. Call MapViewNT. (fixup_mmaps_after_fork): Restructure and hopefully speed up loop for setting protection and memory content on MAP_PRIVATE maps. * ntdll.h (AT_ROUND_TO_PAGE): Remove define. (AT_EXTENDABLE_FILE): Add define. (NtCreateSection): Add prototype. * syscalls.cc (getpagesize): Return granularity as pagesize now. (getsystempagesize): New function to retrieve "real" pagesize. (getshmlba): Delete since it's replaced by getpagesize now. * wincap.h (wincaps::has_mmap_alignment_bug): New element. * wincap.cc: Implement above element throughout. * winsup.h (getshmlba): Drop prototype. (getsystempagesize): Add prototype. (mmap_init): Ditto. * include/sys/mman.h: (Not yet) define MAP_NORESERVE.
2005-11-28 23:32:29 +01:00
HANDLE mmap (caddr_t *addr, size_t len, int prot, int flags, _off64_t off);
int munmap (HANDLE h, caddr_t addr, size_t len);
int msync (HANDLE h, caddr_t addr, size_t len, int flags);
* autoload.cc (NtCreateSection): Define. * cygheap.cc (_csbrk): Call getpagesize instead of getshmlba. * dcrt0.cc (dll_crt0_0): Call mmap_init. * external.cc (cygwin_internal): Call getpagesize instead of getshmlba. * fhandler.h (fhandler_base::mmap): Change access to prot parameter. (fhandler_base::fixup_mmap_after_fork): Ditto. (fhandler_disk_file::mmap): Ditto. (fhandler_disk_file::fixup_mmap_after_fork): Ditto. (fhandler_dev_mem::mmap): Ditto. (fhandler_dev_mem::fixup_mmap_after_fork): Ditto. * fhandler_mem.cc (fhandler_dev_mem::write): Call getsystempagesize instead of getpagesize. (fhandler_dev_mem::read): Ditto. (fhandler_dev_mem::fstat): Ditto. (fhandler_dev_mem::mmap): Move to mmap.cc. (fhandler_dev_mem::munmap): Ditto. (fhandler_dev_mem::msync): Ditto. (fhandler_dev_mem::fixup_mmap_after_fork): Ditto. * fhandler_proc.cc (format_proc_meminfo): Call getsystempagesize instead of getpagesize. * fhandler_process.cc (format_process_stat): Ditto. (format_process_status): Ditto. (get_mem_values): Ditto. * mmap.cc: Fix formatting. Try to make more readable and modular. Take advantage of pagesize==granularity. (gen_protect): New static function to evaluate Windows protection bits from POSIX protection and flags. (gen_access): Ditto for Windows access mode. (VirtualProt9x): Wrapper function to call VirtualProtect on 9x. (VirtualProtNT): Ditto for NT. (VirtualProtEx9x): Ditto for VirtualProtectEx on 9x. (VirtualProtExNT): Ditto for NT. (CreateMapping9x): Wrapper function for creating a mapping handle on 9x. (CreateMappingNT): Ditto for NT. (MapView9x): Wrapper function to map a view on 9x. (MapViewNT): Ditto for NT. (mmap_funcs_9x): Structure containing function pointers to wrapper functions for 9x. (mmap_funcs_nt): Ditto for NT. (mmap_func): Pointer to wrapper functions used in subsequent code. (mmap_init): Initialize mmap_func depending on OS. (class mmap_record): Use sensible member names. Add POSIX protection member. Drop Windows access flags member. Constify more methods. Use accessors instead of direct member access inside of own methods. (mmap_record::gen_protect): Class wrapper to evaluate matching Windows protection bits. (mmap_record::gen_access): Ditto for Windows access flags. (mmap_record::compatible_flags): New function to check if flags are compatible with flags of existing map. (list::add_record): Drop offset and length arguments. (class map): Change counters to unsigned. Match usage throughout. (mmapped_areas): Convert from pointer to global struct. (mmap_record::alloc_page_map): Simplify. (mmap_record::map_pages): Ditto. (mmap_record::fixup_page_map): Delete. (mmap64): Simplify. Add workaround for Windows 98 bug. Fix bug on NT that existing anonymous mappings weren't searched for a match. (munmap): Add workaround for Windows 98 bug. (msync): Simplify. (mprotect): Handle existing maps correctly. (mlock): Add local pagesize variable and enlightening comment. (fhandler_disk_file::mmap): Main functionality now in CreateMapping/ MapView wrapper functions. (fhandler_disk_file::fixup_mmap_after_fork): Call MapView wrapper. (fhandler_dev_mem::mmap): Moved from fhandler_mem.cc. Simplify by calling MapViewNT. (fhandler_dev_mem::munmap): Moved from fhandler_mem.cc. (fhandler_dev_mem::msync): Ditto. (fhandler_dev_mem::fixup_mmap_after_fork): Ditto. Call MapViewNT. (fixup_mmaps_after_fork): Restructure and hopefully speed up loop for setting protection and memory content on MAP_PRIVATE maps. * ntdll.h (AT_ROUND_TO_PAGE): Remove define. (AT_EXTENDABLE_FILE): Add define. (NtCreateSection): Add prototype. * syscalls.cc (getpagesize): Return granularity as pagesize now. (getsystempagesize): New function to retrieve "real" pagesize. (getshmlba): Delete since it's replaced by getpagesize now. * wincap.h (wincaps::has_mmap_alignment_bug): New element. * wincap.cc: Implement above element throughout. * winsup.h (getshmlba): Drop prototype. (getsystempagesize): Add prototype. (mmap_init): Ditto. * include/sys/mman.h: (Not yet) define MAP_NORESERVE.
2005-11-28 23:32:29 +01:00
bool fixup_mmap_after_fork (HANDLE h, int prot, int flags,
_off64_t offset, DWORD size, void *address);
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
fhandler_dev_mem (void *) {}
void copyto (fhandler_base *x)
{
x->pc.free_strings ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
*reinterpret_cast<fhandler_dev_mem *> (x) = *this;
x->reset (this);
}
fhandler_dev_mem *clone (cygheap_types malloc_type = HEAP_FHANDLER)
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
{
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_dev_mem));
* fhandler.h (fhandler_pipe::create_selectable): Remove optional argument, take an options argument for CreateNamedPipe/CreateFile. Change handle arguments to expect pointers. (fhandler_fifo::fifo_state): Delete. (fhandler_fifo::dummy_client): Ditto. (fhandler_fifo::open_nonserver): Ditto. (fhandler_fifo::wait_state): Ditto. (fhandler_fifo::raw_write): Ditto. (fhandler_fifo::read_ready): New field. (fhandler_fifo::write_ready): Ditto. (fhandler_fifo::wait): Modify argument. (fhandler_fifo::fifo_name): Add a new argument. (fhandler_fifo::fixup_after_fork): New function. * fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Remove initialization of expunged elements. Initialize new handles to NULL. (fhandler_fifo::open_nonserver): Delete. (fnevent): New macro for creating a named event. (fnpipe): New macro for creating a unique named pipe name. (create_pipe): New macro for simplification of named pipe creation. (fhandler_fifo::fifo_name): Use new argument when creating a shared name. (fhandler_fifo::open): Rewrite. Use events to synchronize. (pure_debug_printf): New macro, active only when DEBUGGING. (fhandler_fifo::wait): Rewrite to wait for new fifo events which are supplied as a parameter. (fhandler_fifo::raw_read): Rewrite to use handle mechanism to detect client-side disconnect. (fhandler_fifo::raw_write): Delete. (fhandler_fifo::close): Remove accommodations for expunged fields. Close event handles. (fhandler_fifo::dup): Remove accommodations for expunged fields. Duplicate event handles. (fhandler_fifo::fixup_after_fork): New function. Perform fixups on event handles. (fhandler_fifo::set_close_on_exec): Remove accommodations for expunged fields. Set inheritance for new handle fields. * miscfuncs.cc (CreatePipeOverlapped): Accommodate changes in fhandler_pipe::create_selectable. * tty.cc (tty::not_allocated): Ditto. * pipe.cc (fhandler_pipe::create): Ditto. (fhandler_pipe::create_selectable): Accept an extra open_mode argument. Pass arguments by reference and allow opening one end of the pipe at a time. * sys/strace.h (debug_only_printf): Define new macro which calls debug_printf only when DEBUGGING is defined.
2011-10-30 05:50:36 +01:00
fhandler_dev_mem *fh = new (ptr) fhandler_dev_mem (ptr);
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
copyto (fh);
return fh;
}
* 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-06 00:30:53 +02:00
};
class fhandler_dev_clipboard: public fhandler_base
{
_off64_t pos;
void *membuffer;
size_t msize;
* dtable.cc (dtable::build_fhandler): Issue internal error on unknown device. * fhandler.cc (fhandler_base::close): Show both name and handle in debugging output. * fhandler.h (fhandler_base::get_guard): New virtual method. (fhandler_pipe::get_guard): New method. (fhandler_socket::ready_for_read): Delete declaration. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (struct select_record::peek): Declare new method. * select.cc (MAKEready): Delete. (peek_pipe): Use get_guard method to retrieve potential guard mutex handle. (fhandler_base::ready_for_read): Rewrite as generic ready-for-read handler. Should only be called for "slow" devices. (fhandler_socket::ready_for_read): Delete definition. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (fhandler_pipe::select_read): Fill in new peek record in select_record structure. (fhandler_console::select_read): Ditto. (fhandler_tty_common::select_read): Ditto. (fhandler_serial::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_tty_slave::ready_for_read): Check for tty not open. Set errnos appropriately. * syscalls.cc (_read): Allow ready_for_read to set errno. * pinfo.cc (pinfo::init): Return spawn/NO_WAIT process as valid if it is initializing. * sigproc.cc (getsem): Adjust wait for process to initialize downward to avoid huge waits.
2001-11-01 22:15:53 +01:00
public:
fhandler_dev_clipboard ();
int is_windows () { return 1; }
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
int open (int flags, mode_t mode = 0);
int __stdcall fstat (struct __stat64 *buf) __attribute__ ((regparm (2)));
* sigproc.h (wait_for_sigthread): Eliminate parameter. * sigproc.cc (wait_for_sigthread): Ditto. Don't synchronize with wait_sig after receiving an event that it is ready to go. (init_sig_pipe): New function. (wait_sig): Call init_sig_pipe to create pipes for communicating signals to this process. Don't send sigCONT signal when initializing. * fork.cc (frok::child): Accommodate wait_for_sigpipe parameter change. * fhandler.h (fhandler_*::write): Make ssize_t/__stdcall. (fhandler_*::write_overlapped): Ditto. (fhandler_*::raw_write): Ditto. (fhandler_*::readv): Ditto. (fhandler_*::writev): Ditto. (fhandler_*::raw_read): Make __stdcall. * fhandler: Accommodate changes to read/write functions throughout. * fhandler_clipboard.cc: Ditto. * fhandler_console.cc: Ditto. * fhandler_dsp.cc: Ditto. * fhandler_fifo.cc: Ditto. * fhandler_mailslot.cc: Ditto. * fhandler_mem.cc: Ditto. * fhandler_mem.cc: Ditto. * fhandler_random.cc: Ditto. * fhandler_tape.cc: Ditto. * fhandler_tty.cc: Ditto. * fhandler_virtual.cc: Ditto. * fhandler_windows.cc: Ditto. * fhandler_zero.cc: Ditto. * syscalls.cc (readv): Use ssize_t as temp variable. * fhandler.cc (fhandler_base::read): Coerce returned len to signed or it will never be treated as < 0. (fhandler_base::wait_overlapped): Minimize calls to GetLastError. Remove duplicate debugging test. Fix error return. * fhandler.h (fhandler_fifo::fifo_name): Declare new function. (fhandler_fifo::close): Ditto. (fhandler_fifo::dup): Ditto. (fhandler_fifo::close_on_exec): Ditto. * fhandler.cc (fhandler_fifo::fifo_name): Define new function. (FIFO_BUF_SIZE): New define. (cnp): Ditto. (fhandler_fifo::open): Rework. Use cnp to open named pipe. Always open write side as a client. Open dummy client when writing and can't connect. (wait): Rework. Implement fifo_wait_for_next_client. Handle signals during connect better. Add new fifo_wait_for_server code which polls (sigh) waiting for server. (fhandler_fifo::raw_read): Handle transition states when one client closes and another is available. (fhandler_fifo::close): Define. (fhandler_fifo::dup): Ditto. (fhandler_fifo::close_on_exec): Ditto.
2009-07-24 22:54:33 +02:00
ssize_t __stdcall write (const void *ptr, size_t len);
void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3)));
_off64_t lseek (_off64_t offset, int whence);
int close ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
int dup (fhandler_base *child, int);
void fixup_after_exec ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
fhandler_dev_clipboard (void *) {}
void copyto (fhandler_base *x)
{
x->pc.free_strings ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
*reinterpret_cast<fhandler_dev_clipboard *> (x) = *this;
x->reset (this);
}
fhandler_dev_clipboard *clone (cygheap_types malloc_type = HEAP_FHANDLER)
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
{
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_dev_clipboard));
* fhandler.h (fhandler_pipe::create_selectable): Remove optional argument, take an options argument for CreateNamedPipe/CreateFile. Change handle arguments to expect pointers. (fhandler_fifo::fifo_state): Delete. (fhandler_fifo::dummy_client): Ditto. (fhandler_fifo::open_nonserver): Ditto. (fhandler_fifo::wait_state): Ditto. (fhandler_fifo::raw_write): Ditto. (fhandler_fifo::read_ready): New field. (fhandler_fifo::write_ready): Ditto. (fhandler_fifo::wait): Modify argument. (fhandler_fifo::fifo_name): Add a new argument. (fhandler_fifo::fixup_after_fork): New function. * fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Remove initialization of expunged elements. Initialize new handles to NULL. (fhandler_fifo::open_nonserver): Delete. (fnevent): New macro for creating a named event. (fnpipe): New macro for creating a unique named pipe name. (create_pipe): New macro for simplification of named pipe creation. (fhandler_fifo::fifo_name): Use new argument when creating a shared name. (fhandler_fifo::open): Rewrite. Use events to synchronize. (pure_debug_printf): New macro, active only when DEBUGGING. (fhandler_fifo::wait): Rewrite to wait for new fifo events which are supplied as a parameter. (fhandler_fifo::raw_read): Rewrite to use handle mechanism to detect client-side disconnect. (fhandler_fifo::raw_write): Delete. (fhandler_fifo::close): Remove accommodations for expunged fields. Close event handles. (fhandler_fifo::dup): Remove accommodations for expunged fields. Duplicate event handles. (fhandler_fifo::fixup_after_fork): New function. Perform fixups on event handles. (fhandler_fifo::set_close_on_exec): Remove accommodations for expunged fields. Set inheritance for new handle fields. * miscfuncs.cc (CreatePipeOverlapped): Accommodate changes in fhandler_pipe::create_selectable. * tty.cc (tty::not_allocated): Ditto. * pipe.cc (fhandler_pipe::create): Ditto. (fhandler_pipe::create_selectable): Accept an extra open_mode argument. Pass arguments by reference and allow opening one end of the pipe at a time. * sys/strace.h (debug_only_printf): Define new macro which calls debug_printf only when DEBUGGING is defined.
2011-10-30 05:50:36 +01:00
fhandler_dev_clipboard *fh = new (ptr) fhandler_dev_clipboard (ptr);
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
copyto (fh);
return fh;
}
};
2000-02-17 20:38:33 +01:00
class fhandler_windows: public fhandler_base
{
* dtable.cc (dtable::build_fhandler): Issue internal error on unknown device. * fhandler.cc (fhandler_base::close): Show both name and handle in debugging output. * fhandler.h (fhandler_base::get_guard): New virtual method. (fhandler_pipe::get_guard): New method. (fhandler_socket::ready_for_read): Delete declaration. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (struct select_record::peek): Declare new method. * select.cc (MAKEready): Delete. (peek_pipe): Use get_guard method to retrieve potential guard mutex handle. (fhandler_base::ready_for_read): Rewrite as generic ready-for-read handler. Should only be called for "slow" devices. (fhandler_socket::ready_for_read): Delete definition. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (fhandler_pipe::select_read): Fill in new peek record in select_record structure. (fhandler_console::select_read): Ditto. (fhandler_tty_common::select_read): Ditto. (fhandler_serial::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_tty_slave::ready_for_read): Check for tty not open. Set errnos appropriately. * syscalls.cc (_read): Allow ready_for_read to set errno. * pinfo.cc (pinfo::init): Return spawn/NO_WAIT process as valid if it is initializing. * sigproc.cc (getsem): Adjust wait for process to initialize downward to avoid huge waits.
2001-11-01 22:15:53 +01:00
private:
2000-02-17 20:38:33 +01:00
HWND hWnd_; // the window whose messages are to be retrieved by read() call
int method_; // write method (Post or Send)
* dtable.cc (dtable::build_fhandler): Issue internal error on unknown device. * fhandler.cc (fhandler_base::close): Show both name and handle in debugging output. * fhandler.h (fhandler_base::get_guard): New virtual method. (fhandler_pipe::get_guard): New method. (fhandler_socket::ready_for_read): Delete declaration. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (struct select_record::peek): Declare new method. * select.cc (MAKEready): Delete. (peek_pipe): Use get_guard method to retrieve potential guard mutex handle. (fhandler_base::ready_for_read): Rewrite as generic ready-for-read handler. Should only be called for "slow" devices. (fhandler_socket::ready_for_read): Delete definition. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (fhandler_pipe::select_read): Fill in new peek record in select_record structure. (fhandler_console::select_read): Ditto. (fhandler_tty_common::select_read): Ditto. (fhandler_serial::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_tty_slave::ready_for_read): Check for tty not open. Set errnos appropriately. * syscalls.cc (_read): Allow ready_for_read to set errno. * pinfo.cc (pinfo::init): Return spawn/NO_WAIT process as valid if it is initializing. * sigproc.cc (getsem): Adjust wait for process to initialize downward to avoid huge waits.
2001-11-01 22:15:53 +01:00
public:
fhandler_windows ();
int is_windows () { return 1; }
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
int open (int flags, mode_t mode = 0);
* sigproc.h (wait_for_sigthread): Eliminate parameter. * sigproc.cc (wait_for_sigthread): Ditto. Don't synchronize with wait_sig after receiving an event that it is ready to go. (init_sig_pipe): New function. (wait_sig): Call init_sig_pipe to create pipes for communicating signals to this process. Don't send sigCONT signal when initializing. * fork.cc (frok::child): Accommodate wait_for_sigpipe parameter change. * fhandler.h (fhandler_*::write): Make ssize_t/__stdcall. (fhandler_*::write_overlapped): Ditto. (fhandler_*::raw_write): Ditto. (fhandler_*::readv): Ditto. (fhandler_*::writev): Ditto. (fhandler_*::raw_read): Make __stdcall. * fhandler: Accommodate changes to read/write functions throughout. * fhandler_clipboard.cc: Ditto. * fhandler_console.cc: Ditto. * fhandler_dsp.cc: Ditto. * fhandler_fifo.cc: Ditto. * fhandler_mailslot.cc: Ditto. * fhandler_mem.cc: Ditto. * fhandler_mem.cc: Ditto. * fhandler_random.cc: Ditto. * fhandler_tape.cc: Ditto. * fhandler_tty.cc: Ditto. * fhandler_virtual.cc: Ditto. * fhandler_windows.cc: Ditto. * fhandler_zero.cc: Ditto. * syscalls.cc (readv): Use ssize_t as temp variable. * fhandler.cc (fhandler_base::read): Coerce returned len to signed or it will never be treated as < 0. (fhandler_base::wait_overlapped): Minimize calls to GetLastError. Remove duplicate debugging test. Fix error return. * fhandler.h (fhandler_fifo::fifo_name): Declare new function. (fhandler_fifo::close): Ditto. (fhandler_fifo::dup): Ditto. (fhandler_fifo::close_on_exec): Ditto. * fhandler.cc (fhandler_fifo::fifo_name): Define new function. (FIFO_BUF_SIZE): New define. (cnp): Ditto. (fhandler_fifo::open): Rework. Use cnp to open named pipe. Always open write side as a client. Open dummy client when writing and can't connect. (wait): Rework. Implement fifo_wait_for_next_client. Handle signals during connect better. Add new fifo_wait_for_server code which polls (sigh) waiting for server. (fhandler_fifo::raw_read): Handle transition states when one client closes and another is available. (fhandler_fifo::close): Define. (fhandler_fifo::dup): Ditto. (fhandler_fifo::close_on_exec): Ditto.
2009-07-24 22:54:33 +02:00
ssize_t __stdcall write (const void *ptr, size_t len);
void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3)));
2000-02-17 20:38:33 +01:00
int ioctl (unsigned int cmd, void *);
_off64_t lseek (_off64_t, int) { return 0; }
int close () { return 0; }
2000-02-17 20:38:33 +01:00
* Use new unified status_flag accessor methods from classes fhandler_*, tty_min, mtinfo and fs_info thoroughout. * fhandler.h: Redefine all set_close_on_exec methods to take a bool argument. (enum conn_state): Rename from connect_state. (class fhandler_base): Rename some status flags to align with accessor method names. Drop encoded flag entirely. Unify status accessor methods. Const'ify all read accessor methods. (class fhandler_socket): Ditto. (class fhandler_dev_raw): Ditto. * fhandler_disk_file.cc (fhandler_base::fstat_fs): Use fs.fs_is_fat() instead of evaluating FATness of file system here. (fhandler_disk_file::opendir): Drop call to set_encoded(). (fhandler_disk_file::readdir): Use pc.isencoded() directly. * mtinfo.h (class mtinfo_drive): Const'ify all read accessor methods. * path.cc (fsinfo_cnt): Add. (fs_info::update): Accomodate class changes. Evaluate file system name specific flags right here. Add thread safety for reading and writing global fsinfo array. * path.h (enum path_types): Drop values for flags kept in fs already. (struct fs_info): Move status informatin into private struct type status_flags. Add accessor methods. Remove path and file system name string arrays in favor of status bits. (class path_conv): Use new fs_info status information where appropriate. (path_conf::fs_has_ea): Rename from fs_fast_ea. (path_conf::fs_has_acls): New method. (path_conf::root_dir): Remove. (path_conf::volname): Remove. * syscalls (statfs): Evaluate root dir locally. * tty.h (class tty_min): Unify status accessor methods. Const'ify all read accessor methods.
2004-04-10 15:45:10 +02:00
void set_close_on_exec (bool val);
2000-02-17 20:38:33 +01:00
void fixup_after_fork (HANDLE parent);
* select.h: New file split from fhandler.h. (select_record::select_record): Define do-nothing constructor for "new" to avoid gratuitous zeroing. (select_info): New base class. (select_pipe_info): New class with methods for dealing with pipes. (select_socket_info): New class with methods for dealing with sockets. (select_serial_info): Dummy class for serial. (select_mailslot_info): Dummy class for mailslots. (select_stuff): Define device_specific_* as actual classes rather than void *. * dtable.h (dtable::select_read): Accommodate return value change to 'bool' and argument change to "select_stuff". (dtable::select_write): Ditto. (dtable::select_except): Ditto. * dtable.cc (dtable::select_read): Accommodate return value change to 'bool' and argument change to "select_stuff". (dtable::select_write): Ditto. (dtable::select_except): Ditto. * fhandler.h: Excise select-related classes. (fhandler_*::select_read): Change argument to select_stuff. (fhandler_*::select_write): Ditto. (fhandler_*::select_except): Ditto. * select.cc (UNIX_FD_ZERO): Use memset rather than bzero. (select_stuff::test_and_set): Change return type to bool. Allocate select_record on entry and let fhandler_*::select_* operate on the start.next field of select_stuff. (pipeinf): Delete. (select_pipe_info::select_pipe_info): New constructor. Allocates event for controlling pipe waits. (select_pipe_info::~select_pipe_info): New destructor. Destroy event. Stop thread. (select_pipe_info::add_watch_handle): New function. (thread_pipe): Wait for the hEvent part of any overlapped pipes before peeking. (start_thread_pipe): Don't allocate device_specific_pipe stuff here. Assume that it has been allocated earlier. (pipe_cleanup): Rely on select_pipe_info destructor to clean up pipe paraphenalia. (fhandler_*::select_*): Derive select_record from new select_stuff argument. (fhandler_pipe::select_*): Ditto. Allocate pipe-specific field if not already allocated. (serialinf): Delete. (thread_serial): serialinf -> select_serial_info. (fhandler_base::ready_for_read): Rewrite to accommodate change in argument to fhandler_*::select_*. (socketinf): Delete. (thread_socket): socketinf -> select_socket_info. (mailslotinf): Delete. (thread_mailslot): mailslotinf -> select_mailslot_info.
2009-06-30 23:18:44 +02:00
select_record *select_read (select_stuff *);
select_record *select_write (select_stuff *);
select_record *select_except (select_stuff *);
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
fhandler_windows (void *) {}
void copyto (fhandler_base *x)
{
x->pc.free_strings ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
*reinterpret_cast<fhandler_windows *> (x) = *this;
x->reset (this);
}
fhandler_windows *clone (cygheap_types malloc_type = HEAP_FHANDLER)
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
{
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_windows));
* fhandler.h (fhandler_pipe::create_selectable): Remove optional argument, take an options argument for CreateNamedPipe/CreateFile. Change handle arguments to expect pointers. (fhandler_fifo::fifo_state): Delete. (fhandler_fifo::dummy_client): Ditto. (fhandler_fifo::open_nonserver): Ditto. (fhandler_fifo::wait_state): Ditto. (fhandler_fifo::raw_write): Ditto. (fhandler_fifo::read_ready): New field. (fhandler_fifo::write_ready): Ditto. (fhandler_fifo::wait): Modify argument. (fhandler_fifo::fifo_name): Add a new argument. (fhandler_fifo::fixup_after_fork): New function. * fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Remove initialization of expunged elements. Initialize new handles to NULL. (fhandler_fifo::open_nonserver): Delete. (fnevent): New macro for creating a named event. (fnpipe): New macro for creating a unique named pipe name. (create_pipe): New macro for simplification of named pipe creation. (fhandler_fifo::fifo_name): Use new argument when creating a shared name. (fhandler_fifo::open): Rewrite. Use events to synchronize. (pure_debug_printf): New macro, active only when DEBUGGING. (fhandler_fifo::wait): Rewrite to wait for new fifo events which are supplied as a parameter. (fhandler_fifo::raw_read): Rewrite to use handle mechanism to detect client-side disconnect. (fhandler_fifo::raw_write): Delete. (fhandler_fifo::close): Remove accommodations for expunged fields. Close event handles. (fhandler_fifo::dup): Remove accommodations for expunged fields. Duplicate event handles. (fhandler_fifo::fixup_after_fork): New function. Perform fixups on event handles. (fhandler_fifo::set_close_on_exec): Remove accommodations for expunged fields. Set inheritance for new handle fields. * miscfuncs.cc (CreatePipeOverlapped): Accommodate changes in fhandler_pipe::create_selectable. * tty.cc (tty::not_allocated): Ditto. * pipe.cc (fhandler_pipe::create): Ditto. (fhandler_pipe::create_selectable): Accept an extra open_mode argument. Pass arguments by reference and allow opening one end of the pipe at a time. * sys/strace.h (debug_only_printf): Define new macro which calls debug_printf only when DEBUGGING is defined.
2011-10-30 05:50:36 +01:00
fhandler_windows *fh = new (ptr) fhandler_windows (ptr);
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
copyto (fh);
return fh;
}
2000-02-17 20:38:33 +01:00
};
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 12:05:56 +01:00
class fhandler_dev_dsp: public fhandler_base
{
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 12:05:56 +01:00
public:
class Audio;
class Audio_out;
class Audio_in;
* dtable.cc (dtable::build_fhandler): Issue internal error on unknown device. * fhandler.cc (fhandler_base::close): Show both name and handle in debugging output. * fhandler.h (fhandler_base::get_guard): New virtual method. (fhandler_pipe::get_guard): New method. (fhandler_socket::ready_for_read): Delete declaration. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (struct select_record::peek): Declare new method. * select.cc (MAKEready): Delete. (peek_pipe): Use get_guard method to retrieve potential guard mutex handle. (fhandler_base::ready_for_read): Rewrite as generic ready-for-read handler. Should only be called for "slow" devices. (fhandler_socket::ready_for_read): Delete definition. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (fhandler_pipe::select_read): Fill in new peek record in select_record structure. (fhandler_console::select_read): Ditto. (fhandler_tty_common::select_read): Ditto. (fhandler_serial::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_tty_slave::ready_for_read): Check for tty not open. Set errnos appropriately. * syscalls.cc (_read): Allow ready_for_read to set errno. * pinfo.cc (pinfo::init): Return spawn/NO_WAIT process as valid if it is initializing. * sigproc.cc (getsem): Adjust wait for process to initialize downward to avoid huge waits.
2001-11-01 22:15:53 +01:00
private:
int audioformat_;
int audiofreq_;
int audiobits_;
int audiochannels_;
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 12:05:56 +01:00
Audio_out *audio_out_;
Audio_in *audio_in_;
* dtable.cc (dtable::build_fhandler): Issue internal error on unknown device. * fhandler.cc (fhandler_base::close): Show both name and handle in debugging output. * fhandler.h (fhandler_base::get_guard): New virtual method. (fhandler_pipe::get_guard): New method. (fhandler_socket::ready_for_read): Delete declaration. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (struct select_record::peek): Declare new method. * select.cc (MAKEready): Delete. (peek_pipe): Use get_guard method to retrieve potential guard mutex handle. (fhandler_base::ready_for_read): Rewrite as generic ready-for-read handler. Should only be called for "slow" devices. (fhandler_socket::ready_for_read): Delete definition. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (fhandler_pipe::select_read): Fill in new peek record in select_record structure. (fhandler_console::select_read): Ditto. (fhandler_tty_common::select_read): Ditto. (fhandler_serial::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_tty_slave::ready_for_read): Check for tty not open. Set errnos appropriately. * syscalls.cc (_read): Allow ready_for_read to set errno. * pinfo.cc (pinfo::init): Return spawn/NO_WAIT process as valid if it is initializing. * sigproc.cc (getsem): Adjust wait for process to initialize downward to avoid huge waits.
2001-11-01 22:15:53 +01:00
public:
fhandler_dev_dsp ();
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
int open (int flags, mode_t mode = 0);
* sigproc.h (wait_for_sigthread): Eliminate parameter. * sigproc.cc (wait_for_sigthread): Ditto. Don't synchronize with wait_sig after receiving an event that it is ready to go. (init_sig_pipe): New function. (wait_sig): Call init_sig_pipe to create pipes for communicating signals to this process. Don't send sigCONT signal when initializing. * fork.cc (frok::child): Accommodate wait_for_sigpipe parameter change. * fhandler.h (fhandler_*::write): Make ssize_t/__stdcall. (fhandler_*::write_overlapped): Ditto. (fhandler_*::raw_write): Ditto. (fhandler_*::readv): Ditto. (fhandler_*::writev): Ditto. (fhandler_*::raw_read): Make __stdcall. * fhandler: Accommodate changes to read/write functions throughout. * fhandler_clipboard.cc: Ditto. * fhandler_console.cc: Ditto. * fhandler_dsp.cc: Ditto. * fhandler_fifo.cc: Ditto. * fhandler_mailslot.cc: Ditto. * fhandler_mem.cc: Ditto. * fhandler_mem.cc: Ditto. * fhandler_random.cc: Ditto. * fhandler_tape.cc: Ditto. * fhandler_tty.cc: Ditto. * fhandler_virtual.cc: Ditto. * fhandler_windows.cc: Ditto. * fhandler_zero.cc: Ditto. * syscalls.cc (readv): Use ssize_t as temp variable. * fhandler.cc (fhandler_base::read): Coerce returned len to signed or it will never be treated as < 0. (fhandler_base::wait_overlapped): Minimize calls to GetLastError. Remove duplicate debugging test. Fix error return. * fhandler.h (fhandler_fifo::fifo_name): Declare new function. (fhandler_fifo::close): Ditto. (fhandler_fifo::dup): Ditto. (fhandler_fifo::close_on_exec): Ditto. * fhandler.cc (fhandler_fifo::fifo_name): Define new function. (FIFO_BUF_SIZE): New define. (cnp): Ditto. (fhandler_fifo::open): Rework. Use cnp to open named pipe. Always open write side as a client. Open dummy client when writing and can't connect. (wait): Rework. Implement fifo_wait_for_next_client. Handle signals during connect better. Add new fifo_wait_for_server code which polls (sigh) waiting for server. (fhandler_fifo::raw_read): Handle transition states when one client closes and another is available. (fhandler_fifo::close): Define. (fhandler_fifo::dup): Ditto. (fhandler_fifo::close_on_exec): Ditto.
2009-07-24 22:54:33 +02:00
ssize_t __stdcall write (const void *ptr, size_t len);
void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3)));
int ioctl (unsigned int cmd, void *);
_off64_t lseek (_off64_t, int);
int close ();
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 12:05:56 +01:00
void fixup_after_fork (HANDLE parent);
void fixup_after_exec ();
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 11:52:50 +02:00
private:
void close_audio_in ();
void close_audio_out (bool immediately = false);
* 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-06 00:30:53 +02:00
bool use_archetype () const {return true;}
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
fhandler_dev_dsp (void *) {}
void copyto (fhandler_base *x)
{
x->pc.free_strings ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
*reinterpret_cast<fhandler_dev_dsp *> (x) = *this;
x->reset (this);
}
fhandler_dev_dsp *clone (cygheap_types malloc_type = HEAP_FHANDLER)
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
{
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_dev_dsp));
* fhandler.h (fhandler_pipe::create_selectable): Remove optional argument, take an options argument for CreateNamedPipe/CreateFile. Change handle arguments to expect pointers. (fhandler_fifo::fifo_state): Delete. (fhandler_fifo::dummy_client): Ditto. (fhandler_fifo::open_nonserver): Ditto. (fhandler_fifo::wait_state): Ditto. (fhandler_fifo::raw_write): Ditto. (fhandler_fifo::read_ready): New field. (fhandler_fifo::write_ready): Ditto. (fhandler_fifo::wait): Modify argument. (fhandler_fifo::fifo_name): Add a new argument. (fhandler_fifo::fixup_after_fork): New function. * fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Remove initialization of expunged elements. Initialize new handles to NULL. (fhandler_fifo::open_nonserver): Delete. (fnevent): New macro for creating a named event. (fnpipe): New macro for creating a unique named pipe name. (create_pipe): New macro for simplification of named pipe creation. (fhandler_fifo::fifo_name): Use new argument when creating a shared name. (fhandler_fifo::open): Rewrite. Use events to synchronize. (pure_debug_printf): New macro, active only when DEBUGGING. (fhandler_fifo::wait): Rewrite to wait for new fifo events which are supplied as a parameter. (fhandler_fifo::raw_read): Rewrite to use handle mechanism to detect client-side disconnect. (fhandler_fifo::raw_write): Delete. (fhandler_fifo::close): Remove accommodations for expunged fields. Close event handles. (fhandler_fifo::dup): Remove accommodations for expunged fields. Duplicate event handles. (fhandler_fifo::fixup_after_fork): New function. Perform fixups on event handles. (fhandler_fifo::set_close_on_exec): Remove accommodations for expunged fields. Set inheritance for new handle fields. * miscfuncs.cc (CreatePipeOverlapped): Accommodate changes in fhandler_pipe::create_selectable. * tty.cc (tty::not_allocated): Ditto. * pipe.cc (fhandler_pipe::create): Ditto. (fhandler_pipe::create_selectable): Accept an extra open_mode argument. Pass arguments by reference and allow opening one end of the pipe at a time. * sys/strace.h (debug_only_printf): Define new macro which calls debug_printf only when DEBUGGING is defined.
2011-10-30 05:50:36 +01:00
fhandler_dev_dsp *fh = new (ptr) fhandler_dev_dsp (ptr);
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
copyto (fh);
return fh;
}
};
* path.h (pathconv_arg): Add PC_POSIX. (path_conv): Add normalized_path field. * path.cc (path_conv::~path_conv): New destructor. (path_conv::check): Set normalized_path, where appropriate. * dtable.cc (build_fhandler_from_name): Use normalized path from path_conv. * syscalls.cc (chroot): Ditto. * cygheap.h: Remove path_prefix_p declaration. Christopher Faylor <cgf@redhat.com> (minor fixups) * Makefile.in: Add fhandler_proc.o, fhandler_registry.o, fhandler_process.o and fhandler_virtual.o. * dtable.cc (dtable::build_fhandler): Add entries for FH_PROC, FH_REGISTRY and FH_PROCESS. Set unix_name to the normalized posix path. * fhandler.h: Add constants for FH_PROC, FH_REGISTRY and FH_PROCESS. Add class declarations for fhandler_virtual, fhandler_proc, fhandler_registry and fhandler_virtual. Update fhandler_union accordingly. * fhandler_proc.cc: New file. Add implementation for fhandler_proc. * fhandler_virtual.cc: New file. Add implementation for fhandler_virtual. * fhandler_process.cc: New file. Add implementation for fhandler_process. * fhandler_registry.cc: New file. Add implementation for fhandler_registry. * path.cc: Add isproc and isvirtual_dev macros. * path.cc (path_conv::check): Add check for virtual devices. * path.cc (mount_info::conv_to_win32_path): Convert paths in /proc to empty Win32 paths. * path.cc (chdir): Replace check for FH_CYGDRIVE with more generic isvirtual_dev macro. Force setting of posix path for virtual fhandlers. * path.h: Add externally visible path_prefix_p and normalized_posix_path prototypes.
2002-05-02 06:13:48 +02:00
class fhandler_virtual : public fhandler_base
{
protected:
char *filebuf;
_off64_t filesize;
_off64_t position;
* autoload.cc: Add dynamic load statements for 'ZwQueryInformationProcess' and 'ZwQueryVirtualMemory'. * fhandler.h: Change type of bufalloc and filesize members of fhandler_virtual from int to size_t. Change type of position member from __off32_t to __off64_t. Add new fileid member to fhandler_virtual class. Make seekdir take an __off64_t argument. Make lseek take an __off64_t argument. Add fill_filebuf method to fhandler_virtual. Add fill_filebuf method to fhandler_proc. Add fill_filebuf method to fhandler_registry. Add fill_filebuf method to fhandler_process. Add saved_pid and saved_p members to fhandler_process. * fhandler_proc.cc (proc_listing_array): Add 'loadavg', 'meminfo', and 'stat'. (proc_fhandlers array): Ditto. (fhandler_proc::open): Use fill_filebuf to flesh out the file contents. (fhandler_proc::fill_filebuf): New method. (fhandler_proc::format_proc_meminfo): Ditto. (fhandler_proc::format_proc_stat): Ditto. (fhandler_proc::format_proc_uptime): Ditto. * fhandler_process.cc (process_listing): Add 'stat' and 'statm'. (fhandler_process::fstat): Find the _pinfo structure for the process named in the filename. Return ENOENT if the process is no longer around. Set the gid and uid fields of the stat structure. (fhandler_process::open): Store pid and pointer to _pinfo structure in saved_pid and saved_p respectively. Use fill_filebuf to flesh out file contents. (fhandler_proc::fill_filebuf): New method. (format_process_stat): New function. (format_process_status): Ditto. (format_process_statm): Ditto. (get_process_state): Ditto. (get_mem_values): Ditto. * fhandler_registry.cc (fhandler_registry::seekdir): Change argument type from __off32_t to __off64_t. (fhandler_registry::fill_filebuf): New method. * fhandler_virtual.cc (fhandler_virtual::seekdir): Change argument type from __off32_t to __off64_t. (fhandler_virtual::lseek): Ditto. (fhandler_virtual::fill_filebuf): New method. (fhandler_virtual::fhandler_virtual): Initialise fileid to -1. * wincap.cc: Set flag has_process_io_counters appropriately. * wincap.h: Add flag has_process_io_counters.
2002-05-12 03:37:48 +02:00
int fileid; // unique within each class
* path.h (pathconv_arg): Add PC_POSIX. (path_conv): Add normalized_path field. * path.cc (path_conv::~path_conv): New destructor. (path_conv::check): Set normalized_path, where appropriate. * dtable.cc (build_fhandler_from_name): Use normalized path from path_conv. * syscalls.cc (chroot): Ditto. * cygheap.h: Remove path_prefix_p declaration. Christopher Faylor <cgf@redhat.com> (minor fixups) * Makefile.in: Add fhandler_proc.o, fhandler_registry.o, fhandler_process.o and fhandler_virtual.o. * dtable.cc (dtable::build_fhandler): Add entries for FH_PROC, FH_REGISTRY and FH_PROCESS. Set unix_name to the normalized posix path. * fhandler.h: Add constants for FH_PROC, FH_REGISTRY and FH_PROCESS. Add class declarations for fhandler_virtual, fhandler_proc, fhandler_registry and fhandler_virtual. Update fhandler_union accordingly. * fhandler_proc.cc: New file. Add implementation for fhandler_proc. * fhandler_virtual.cc: New file. Add implementation for fhandler_virtual. * fhandler_process.cc: New file. Add implementation for fhandler_process. * fhandler_registry.cc: New file. Add implementation for fhandler_registry. * path.cc: Add isproc and isvirtual_dev macros. * path.cc (path_conv::check): Add check for virtual devices. * path.cc (mount_info::conv_to_win32_path): Convert paths in /proc to empty Win32 paths. * path.cc (chdir): Replace check for FH_CYGDRIVE with more generic isvirtual_dev macro. Force setting of posix path for virtual fhandlers. * path.h: Add externally visible path_prefix_p and normalized_posix_path prototypes.
2002-05-02 06:13:48 +02:00
public:
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
fhandler_virtual ();
* path.h (pathconv_arg): Add PC_POSIX. (path_conv): Add normalized_path field. * path.cc (path_conv::~path_conv): New destructor. (path_conv::check): Set normalized_path, where appropriate. * dtable.cc (build_fhandler_from_name): Use normalized path from path_conv. * syscalls.cc (chroot): Ditto. * cygheap.h: Remove path_prefix_p declaration. Christopher Faylor <cgf@redhat.com> (minor fixups) * Makefile.in: Add fhandler_proc.o, fhandler_registry.o, fhandler_process.o and fhandler_virtual.o. * dtable.cc (dtable::build_fhandler): Add entries for FH_PROC, FH_REGISTRY and FH_PROCESS. Set unix_name to the normalized posix path. * fhandler.h: Add constants for FH_PROC, FH_REGISTRY and FH_PROCESS. Add class declarations for fhandler_virtual, fhandler_proc, fhandler_registry and fhandler_virtual. Update fhandler_union accordingly. * fhandler_proc.cc: New file. Add implementation for fhandler_proc. * fhandler_virtual.cc: New file. Add implementation for fhandler_virtual. * fhandler_process.cc: New file. Add implementation for fhandler_process. * fhandler_registry.cc: New file. Add implementation for fhandler_registry. * path.cc: Add isproc and isvirtual_dev macros. * path.cc (path_conv::check): Add check for virtual devices. * path.cc (mount_info::conv_to_win32_path): Convert paths in /proc to empty Win32 paths. * path.cc (chdir): Replace check for FH_CYGDRIVE with more generic isvirtual_dev macro. Force setting of posix path for virtual fhandlers. * path.h: Add externally visible path_prefix_p and normalized_posix_path prototypes.
2002-05-02 06:13:48 +02:00
virtual ~fhandler_virtual();
* Makefile.in (DLL_OFILES): Add fhandler_procsys.o. * devices.h (enum fh_devices): Add FH_PROCSYS. * devices.in (dev_procsys_storage): New device. * devices.cc: Regenerate. * dtable.cc (build_fh_pc): Add code to allocate fhandler_procsys. * fhandler.h (proc_len): Convert to size_t. (procsys): Declare. (procsys_len): Declare. (enum virtual_ftype_t): Move here from fhandler_virtual.h. Add members supported by fhandler_procsys. (fhandler_virtual::exists): Return virtual_ftype_t. Change in all derived classes. (class fhandler_procsys): New class. (fhandler_union): Add fhandler_procnet and fhandler_procsys members. * fhandler_disk_file.cc (__DIR_mounts::check_missing_mount): Use ro_u_proc. (fhandler_base::fstat_by_handle): Don't copy attributes if file is an NT device. (fhandler_base::fstat_by_name): Ditto. * fhandler_netdrive.cc (fhandler_netdrive::exists): Return virtual_ftype_t. * fhandler_proc.cc (proc_tab): Sort alphabetically. Use _VN macro to store length. (proc_len): Change to size_t. (proc_tab_cmp): New static function. (virt_tab_search): New function to search entry in virt_tab_t arrays. Use throughout in /proc and sibling classes instead of loop. (fhandler_proc::exists): Return virtual_ftype_t. * fhandler_process.cc (process_tab): Sort alphabetically. Use _VN macro to store length. (fhandler_process::exists): Return virtual_ftype_t. (fhandler_process::open): Simplify code. * fhandler_procnet.cc (procnet_tab): Sort alphabetically. Use _VN macro to store length. (fhandler_procnet::exists): Return virtual_ftype_t. (fhandler_procnet::open): Simplify. * fhandler_procsys.cc: New file. * fhandler_registry.cc (fhandler_registry::exists): Return virtual_ftype_t. * fhandler_virtual.cc (fhandler_virtual::exists): Ditto. * fhandler_virtual.h (enum virtual_ftype_t): Move to fhandler.h. (virt_tab_t): Add name_len member. (_VN): New macro. (virt_tab_search): Declare. * mount.cc (mount_info::conv_to_win32_path): Fix comment. Backslashify isprocsys_dev paths. * ntdll.h (STATUS_OBJECT_TYPE_MISMATCH): Define (STATUS_INSTANCE_NOT_AVAILABLE): Define. (STATUS_PIPE_NOT_AVAILABLE): Define. (STATUS_INVALID_PIPE_STATE): Define. (STATUS_PIPE_BUSY): Define. (SYMBOLIC_LINK_QUERY): Define. (NtOpenSymbolicLinkObject): Declare. (NtQuerySymbolicLinkObject): Declare. * path.cc (path_conv::check): Accommodate fact that exists method returns virtual_ftype_t now. Add cases for new virtual_ftype_t types. (cygwin_conv_path): Add GLOBALROOT prefix to native device paths. Make sure to strip \\?\ prefix only for actual filesystem-based paths, not for all paths. * path.h (isproc_dev): Add FH_PROCSYS. (isprocsys_dev): Define.
2010-09-06 11:47:01 +02:00
virtual virtual_ftype_t exists();
DIR *opendir (int fd) __attribute__ ((regparm (2)));
long telldir (DIR *);
void seekdir (DIR *, long);
* path.h (pathconv_arg): Add PC_POSIX. (path_conv): Add normalized_path field. * path.cc (path_conv::~path_conv): New destructor. (path_conv::check): Set normalized_path, where appropriate. * dtable.cc (build_fhandler_from_name): Use normalized path from path_conv. * syscalls.cc (chroot): Ditto. * cygheap.h: Remove path_prefix_p declaration. Christopher Faylor <cgf@redhat.com> (minor fixups) * Makefile.in: Add fhandler_proc.o, fhandler_registry.o, fhandler_process.o and fhandler_virtual.o. * dtable.cc (dtable::build_fhandler): Add entries for FH_PROC, FH_REGISTRY and FH_PROCESS. Set unix_name to the normalized posix path. * fhandler.h: Add constants for FH_PROC, FH_REGISTRY and FH_PROCESS. Add class declarations for fhandler_virtual, fhandler_proc, fhandler_registry and fhandler_virtual. Update fhandler_union accordingly. * fhandler_proc.cc: New file. Add implementation for fhandler_proc. * fhandler_virtual.cc: New file. Add implementation for fhandler_virtual. * fhandler_process.cc: New file. Add implementation for fhandler_process. * fhandler_registry.cc: New file. Add implementation for fhandler_registry. * path.cc: Add isproc and isvirtual_dev macros. * path.cc (path_conv::check): Add check for virtual devices. * path.cc (mount_info::conv_to_win32_path): Convert paths in /proc to empty Win32 paths. * path.cc (chdir): Replace check for FH_CYGDRIVE with more generic isvirtual_dev macro. Force setting of posix path for virtual fhandlers. * path.h: Add externally visible path_prefix_p and normalized_posix_path prototypes.
2002-05-02 06:13:48 +02:00
void rewinddir (DIR *);
int closedir (DIR *);
* sigproc.h (wait_for_sigthread): Eliminate parameter. * sigproc.cc (wait_for_sigthread): Ditto. Don't synchronize with wait_sig after receiving an event that it is ready to go. (init_sig_pipe): New function. (wait_sig): Call init_sig_pipe to create pipes for communicating signals to this process. Don't send sigCONT signal when initializing. * fork.cc (frok::child): Accommodate wait_for_sigpipe parameter change. * fhandler.h (fhandler_*::write): Make ssize_t/__stdcall. (fhandler_*::write_overlapped): Ditto. (fhandler_*::raw_write): Ditto. (fhandler_*::readv): Ditto. (fhandler_*::writev): Ditto. (fhandler_*::raw_read): Make __stdcall. * fhandler: Accommodate changes to read/write functions throughout. * fhandler_clipboard.cc: Ditto. * fhandler_console.cc: Ditto. * fhandler_dsp.cc: Ditto. * fhandler_fifo.cc: Ditto. * fhandler_mailslot.cc: Ditto. * fhandler_mem.cc: Ditto. * fhandler_mem.cc: Ditto. * fhandler_random.cc: Ditto. * fhandler_tape.cc: Ditto. * fhandler_tty.cc: Ditto. * fhandler_virtual.cc: Ditto. * fhandler_windows.cc: Ditto. * fhandler_zero.cc: Ditto. * syscalls.cc (readv): Use ssize_t as temp variable. * fhandler.cc (fhandler_base::read): Coerce returned len to signed or it will never be treated as < 0. (fhandler_base::wait_overlapped): Minimize calls to GetLastError. Remove duplicate debugging test. Fix error return. * fhandler.h (fhandler_fifo::fifo_name): Declare new function. (fhandler_fifo::close): Ditto. (fhandler_fifo::dup): Ditto. (fhandler_fifo::close_on_exec): Ditto. * fhandler.cc (fhandler_fifo::fifo_name): Define new function. (FIFO_BUF_SIZE): New define. (cnp): Ditto. (fhandler_fifo::open): Rework. Use cnp to open named pipe. Always open write side as a client. Open dummy client when writing and can't connect. (wait): Rework. Implement fifo_wait_for_next_client. Handle signals during connect better. Add new fifo_wait_for_server code which polls (sigh) waiting for server. (fhandler_fifo::raw_read): Handle transition states when one client closes and another is available. (fhandler_fifo::close): Define. (fhandler_fifo::dup): Ditto. (fhandler_fifo::close_on_exec): Ditto.
2009-07-24 22:54:33 +02:00
ssize_t __stdcall write (const void *ptr, size_t len);
void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3)));
_off64_t lseek (_off64_t, int);
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
int dup (fhandler_base *child, int);
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
int open (int flags, mode_t mode = 0);
int close ();
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
int __stdcall fstat (struct stat *buf) __attribute__ ((regparm (2)));
int __stdcall fstatvfs (struct statvfs *buf) __attribute__ ((regparm (2)));
int __stdcall fchmod (mode_t mode) __attribute__ ((regparm (1)));
int __stdcall fchown (__uid32_t uid, __gid32_t gid) __attribute__ ((regparm (2)));
int __stdcall facl (int, int, __acl32 *) __attribute__ ((regparm (3)));
* autoload.cc (GetSecurityInfo): Define new autoload function. (RegQueryInfoKeyA): Ditto. * fhandler.h (fhandler_virtual::fill_filebuf): Change return type to bool. (fhandler_proc::fill_filebuf): Ditto. (fhandler_registry::fill_filebuf): Ditto. (fhandler_process::fill_filebuf): Ditto. (fhandler_registry::value_name): Add new member. (fhandler_registry::close): Add new method. (fhandler_process::p): Remove member. * fhandler_proc.cc (fhandler_proc::open): Add set_nohandle after calling superclass method. Check return value of fill_filebuf. (fhandler_proc::fill_filebuf): Change return type to bool. Add return statement. * fhandler_process.cc (fhandler_process::open): Add set_nohandle after calling superclass method. Remove references to p. Check return value of fill_filebuf. (fhandler_process::fill_filebuf): Change return type to bool. Don't use dereference operator on p. Add return statement. (fhandler_process::format_process_stat): Fix typo. * fhandler_registry.cc: Add static open_key declaration. (fhandler_registry::exists): Assume path is already normalised. Try opening the path as a key in its own right first, before reverting to enumerating subkeys and values of the parent key. (fhandler_registry::fstat): Add additional code to return more relevant information about the registry key/value. (fhandler_registry::readdir): Explicitly set desired access when opening registry key. Remove output of buf from debug_printf format string. (fhandler_registry::open): Use set_io_handle to store registry key handle. Set value_name member. Move code to read a value from the registry to fill_filebuf. Add call to fill_filebuf. (fhandler_registry::close): New method. (fhandler_registry::fill_filebuf): Change return type to bool. Add code to read a value from registry. (fhandler_registry::open_key): Make function static. Use KEY_READ as desired access unless this is the last path component. Check the return value of RegOpenKeyEx for an error instead of hKey. * fhandler_virtual.cc (fhandler_virtual::lseek): Check the return value of fill_filebuf. (fhandler_virtual::open): Remove call to set_nohandle. (fhandler_virtual::fill_filebuf): Change return type to bool. Add return statement. * security.cc (get_nt_object_attribute): New function. (get_object_attribute): New function. * security.h (get_object_attribute): New function declaration.
2002-07-02 03:36:15 +02:00
virtual bool fill_filebuf ();
char *get_filebuf () { return filebuf; }
void fixup_after_exec ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
fhandler_virtual (void *) {}
virtual void copyto (fhandler_base *x)
{
x->pc.free_strings ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
*reinterpret_cast<fhandler_virtual *> (x) = *this;
x->reset (this);
}
virtual fhandler_virtual *clone (cygheap_types malloc_type = HEAP_FHANDLER)
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
{
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_virtual));
* fhandler.h (fhandler_pipe::create_selectable): Remove optional argument, take an options argument for CreateNamedPipe/CreateFile. Change handle arguments to expect pointers. (fhandler_fifo::fifo_state): Delete. (fhandler_fifo::dummy_client): Ditto. (fhandler_fifo::open_nonserver): Ditto. (fhandler_fifo::wait_state): Ditto. (fhandler_fifo::raw_write): Ditto. (fhandler_fifo::read_ready): New field. (fhandler_fifo::write_ready): Ditto. (fhandler_fifo::wait): Modify argument. (fhandler_fifo::fifo_name): Add a new argument. (fhandler_fifo::fixup_after_fork): New function. * fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Remove initialization of expunged elements. Initialize new handles to NULL. (fhandler_fifo::open_nonserver): Delete. (fnevent): New macro for creating a named event. (fnpipe): New macro for creating a unique named pipe name. (create_pipe): New macro for simplification of named pipe creation. (fhandler_fifo::fifo_name): Use new argument when creating a shared name. (fhandler_fifo::open): Rewrite. Use events to synchronize. (pure_debug_printf): New macro, active only when DEBUGGING. (fhandler_fifo::wait): Rewrite to wait for new fifo events which are supplied as a parameter. (fhandler_fifo::raw_read): Rewrite to use handle mechanism to detect client-side disconnect. (fhandler_fifo::raw_write): Delete. (fhandler_fifo::close): Remove accommodations for expunged fields. Close event handles. (fhandler_fifo::dup): Remove accommodations for expunged fields. Duplicate event handles. (fhandler_fifo::fixup_after_fork): New function. Perform fixups on event handles. (fhandler_fifo::set_close_on_exec): Remove accommodations for expunged fields. Set inheritance for new handle fields. * miscfuncs.cc (CreatePipeOverlapped): Accommodate changes in fhandler_pipe::create_selectable. * tty.cc (tty::not_allocated): Ditto. * pipe.cc (fhandler_pipe::create): Ditto. (fhandler_pipe::create_selectable): Accept an extra open_mode argument. Pass arguments by reference and allow opening one end of the pipe at a time. * sys/strace.h (debug_only_printf): Define new macro which calls debug_printf only when DEBUGGING is defined.
2011-10-30 05:50:36 +01:00
fhandler_virtual *fh = new (ptr) fhandler_virtual (ptr);
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
copyto (fh);
return fh;
}
* path.h (pathconv_arg): Add PC_POSIX. (path_conv): Add normalized_path field. * path.cc (path_conv::~path_conv): New destructor. (path_conv::check): Set normalized_path, where appropriate. * dtable.cc (build_fhandler_from_name): Use normalized path from path_conv. * syscalls.cc (chroot): Ditto. * cygheap.h: Remove path_prefix_p declaration. Christopher Faylor <cgf@redhat.com> (minor fixups) * Makefile.in: Add fhandler_proc.o, fhandler_registry.o, fhandler_process.o and fhandler_virtual.o. * dtable.cc (dtable::build_fhandler): Add entries for FH_PROC, FH_REGISTRY and FH_PROCESS. Set unix_name to the normalized posix path. * fhandler.h: Add constants for FH_PROC, FH_REGISTRY and FH_PROCESS. Add class declarations for fhandler_virtual, fhandler_proc, fhandler_registry and fhandler_virtual. Update fhandler_union accordingly. * fhandler_proc.cc: New file. Add implementation for fhandler_proc. * fhandler_virtual.cc: New file. Add implementation for fhandler_virtual. * fhandler_process.cc: New file. Add implementation for fhandler_process. * fhandler_registry.cc: New file. Add implementation for fhandler_registry. * path.cc: Add isproc and isvirtual_dev macros. * path.cc (path_conv::check): Add check for virtual devices. * path.cc (mount_info::conv_to_win32_path): Convert paths in /proc to empty Win32 paths. * path.cc (chdir): Replace check for FH_CYGDRIVE with more generic isvirtual_dev macro. Force setting of posix path for virtual fhandlers. * path.h: Add externally visible path_prefix_p and normalized_posix_path prototypes.
2002-05-02 06:13:48 +02:00
};
class fhandler_proc: public fhandler_virtual
{
public:
fhandler_proc ();
* Makefile.in (DLL_OFILES): Add fhandler_procsys.o. * devices.h (enum fh_devices): Add FH_PROCSYS. * devices.in (dev_procsys_storage): New device. * devices.cc: Regenerate. * dtable.cc (build_fh_pc): Add code to allocate fhandler_procsys. * fhandler.h (proc_len): Convert to size_t. (procsys): Declare. (procsys_len): Declare. (enum virtual_ftype_t): Move here from fhandler_virtual.h. Add members supported by fhandler_procsys. (fhandler_virtual::exists): Return virtual_ftype_t. Change in all derived classes. (class fhandler_procsys): New class. (fhandler_union): Add fhandler_procnet and fhandler_procsys members. * fhandler_disk_file.cc (__DIR_mounts::check_missing_mount): Use ro_u_proc. (fhandler_base::fstat_by_handle): Don't copy attributes if file is an NT device. (fhandler_base::fstat_by_name): Ditto. * fhandler_netdrive.cc (fhandler_netdrive::exists): Return virtual_ftype_t. * fhandler_proc.cc (proc_tab): Sort alphabetically. Use _VN macro to store length. (proc_len): Change to size_t. (proc_tab_cmp): New static function. (virt_tab_search): New function to search entry in virt_tab_t arrays. Use throughout in /proc and sibling classes instead of loop. (fhandler_proc::exists): Return virtual_ftype_t. * fhandler_process.cc (process_tab): Sort alphabetically. Use _VN macro to store length. (fhandler_process::exists): Return virtual_ftype_t. (fhandler_process::open): Simplify code. * fhandler_procnet.cc (procnet_tab): Sort alphabetically. Use _VN macro to store length. (fhandler_procnet::exists): Return virtual_ftype_t. (fhandler_procnet::open): Simplify. * fhandler_procsys.cc: New file. * fhandler_registry.cc (fhandler_registry::exists): Return virtual_ftype_t. * fhandler_virtual.cc (fhandler_virtual::exists): Ditto. * fhandler_virtual.h (enum virtual_ftype_t): Move to fhandler.h. (virt_tab_t): Add name_len member. (_VN): New macro. (virt_tab_search): Declare. * mount.cc (mount_info::conv_to_win32_path): Fix comment. Backslashify isprocsys_dev paths. * ntdll.h (STATUS_OBJECT_TYPE_MISMATCH): Define (STATUS_INSTANCE_NOT_AVAILABLE): Define. (STATUS_PIPE_NOT_AVAILABLE): Define. (STATUS_INVALID_PIPE_STATE): Define. (STATUS_PIPE_BUSY): Define. (SYMBOLIC_LINK_QUERY): Define. (NtOpenSymbolicLinkObject): Declare. (NtQuerySymbolicLinkObject): Declare. * path.cc (path_conv::check): Accommodate fact that exists method returns virtual_ftype_t now. Add cases for new virtual_ftype_t types. (cygwin_conv_path): Add GLOBALROOT prefix to native device paths. Make sure to strip \\?\ prefix only for actual filesystem-based paths, not for all paths. * path.h (isproc_dev): Add FH_PROCSYS. (isprocsys_dev): Define.
2010-09-06 11:47:01 +02:00
virtual_ftype_t exists();
DIR *opendir (int fd) __attribute__ ((regparm (2)));
int closedir (DIR *);
int readdir (DIR *, dirent *) __attribute__ ((regparm (3)));
* 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-28 20:17:09 +02:00
static fh_devices get_proc_fhandler (const char *path);
* path.h (pathconv_arg): Add PC_POSIX. (path_conv): Add normalized_path field. * path.cc (path_conv::~path_conv): New destructor. (path_conv::check): Set normalized_path, where appropriate. * dtable.cc (build_fhandler_from_name): Use normalized path from path_conv. * syscalls.cc (chroot): Ditto. * cygheap.h: Remove path_prefix_p declaration. Christopher Faylor <cgf@redhat.com> (minor fixups) * Makefile.in: Add fhandler_proc.o, fhandler_registry.o, fhandler_process.o and fhandler_virtual.o. * dtable.cc (dtable::build_fhandler): Add entries for FH_PROC, FH_REGISTRY and FH_PROCESS. Set unix_name to the normalized posix path. * fhandler.h: Add constants for FH_PROC, FH_REGISTRY and FH_PROCESS. Add class declarations for fhandler_virtual, fhandler_proc, fhandler_registry and fhandler_virtual. Update fhandler_union accordingly. * fhandler_proc.cc: New file. Add implementation for fhandler_proc. * fhandler_virtual.cc: New file. Add implementation for fhandler_virtual. * fhandler_process.cc: New file. Add implementation for fhandler_process. * fhandler_registry.cc: New file. Add implementation for fhandler_registry. * path.cc: Add isproc and isvirtual_dev macros. * path.cc (path_conv::check): Add check for virtual devices. * path.cc (mount_info::conv_to_win32_path): Convert paths in /proc to empty Win32 paths. * path.cc (chdir): Replace check for FH_CYGDRIVE with more generic isvirtual_dev macro. Force setting of posix path for virtual fhandlers. * path.h: Add externally visible path_prefix_p and normalized_posix_path prototypes.
2002-05-02 06:13:48 +02:00
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
int open (int flags, mode_t mode = 0);
int __stdcall fstat (struct __stat64 *buf) __attribute__ ((regparm (2)));
* autoload.cc (GetSecurityInfo): Define new autoload function. (RegQueryInfoKeyA): Ditto. * fhandler.h (fhandler_virtual::fill_filebuf): Change return type to bool. (fhandler_proc::fill_filebuf): Ditto. (fhandler_registry::fill_filebuf): Ditto. (fhandler_process::fill_filebuf): Ditto. (fhandler_registry::value_name): Add new member. (fhandler_registry::close): Add new method. (fhandler_process::p): Remove member. * fhandler_proc.cc (fhandler_proc::open): Add set_nohandle after calling superclass method. Check return value of fill_filebuf. (fhandler_proc::fill_filebuf): Change return type to bool. Add return statement. * fhandler_process.cc (fhandler_process::open): Add set_nohandle after calling superclass method. Remove references to p. Check return value of fill_filebuf. (fhandler_process::fill_filebuf): Change return type to bool. Don't use dereference operator on p. Add return statement. (fhandler_process::format_process_stat): Fix typo. * fhandler_registry.cc: Add static open_key declaration. (fhandler_registry::exists): Assume path is already normalised. Try opening the path as a key in its own right first, before reverting to enumerating subkeys and values of the parent key. (fhandler_registry::fstat): Add additional code to return more relevant information about the registry key/value. (fhandler_registry::readdir): Explicitly set desired access when opening registry key. Remove output of buf from debug_printf format string. (fhandler_registry::open): Use set_io_handle to store registry key handle. Set value_name member. Move code to read a value from the registry to fill_filebuf. Add call to fill_filebuf. (fhandler_registry::close): New method. (fhandler_registry::fill_filebuf): Change return type to bool. Add code to read a value from registry. (fhandler_registry::open_key): Make function static. Use KEY_READ as desired access unless this is the last path component. Check the return value of RegOpenKeyEx for an error instead of hKey. * fhandler_virtual.cc (fhandler_virtual::lseek): Check the return value of fill_filebuf. (fhandler_virtual::open): Remove call to set_nohandle. (fhandler_virtual::fill_filebuf): Change return type to bool. Add return statement. * security.cc (get_nt_object_attribute): New function. (get_object_attribute): New function. * security.h (get_object_attribute): New function declaration.
2002-07-02 03:36:15 +02:00
bool fill_filebuf ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
fhandler_proc (void *) {}
virtual void copyto (fhandler_base *x)
{
x->pc.free_strings ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
*reinterpret_cast<fhandler_proc *> (x) = *this;
x->reset (this);
}
virtual fhandler_proc *clone (cygheap_types malloc_type = HEAP_FHANDLER)
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
{
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_proc));
* fhandler.h (fhandler_pipe::create_selectable): Remove optional argument, take an options argument for CreateNamedPipe/CreateFile. Change handle arguments to expect pointers. (fhandler_fifo::fifo_state): Delete. (fhandler_fifo::dummy_client): Ditto. (fhandler_fifo::open_nonserver): Ditto. (fhandler_fifo::wait_state): Ditto. (fhandler_fifo::raw_write): Ditto. (fhandler_fifo::read_ready): New field. (fhandler_fifo::write_ready): Ditto. (fhandler_fifo::wait): Modify argument. (fhandler_fifo::fifo_name): Add a new argument. (fhandler_fifo::fixup_after_fork): New function. * fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Remove initialization of expunged elements. Initialize new handles to NULL. (fhandler_fifo::open_nonserver): Delete. (fnevent): New macro for creating a named event. (fnpipe): New macro for creating a unique named pipe name. (create_pipe): New macro for simplification of named pipe creation. (fhandler_fifo::fifo_name): Use new argument when creating a shared name. (fhandler_fifo::open): Rewrite. Use events to synchronize. (pure_debug_printf): New macro, active only when DEBUGGING. (fhandler_fifo::wait): Rewrite to wait for new fifo events which are supplied as a parameter. (fhandler_fifo::raw_read): Rewrite to use handle mechanism to detect client-side disconnect. (fhandler_fifo::raw_write): Delete. (fhandler_fifo::close): Remove accommodations for expunged fields. Close event handles. (fhandler_fifo::dup): Remove accommodations for expunged fields. Duplicate event handles. (fhandler_fifo::fixup_after_fork): New function. Perform fixups on event handles. (fhandler_fifo::set_close_on_exec): Remove accommodations for expunged fields. Set inheritance for new handle fields. * miscfuncs.cc (CreatePipeOverlapped): Accommodate changes in fhandler_pipe::create_selectable. * tty.cc (tty::not_allocated): Ditto. * pipe.cc (fhandler_pipe::create): Ditto. (fhandler_pipe::create_selectable): Accept an extra open_mode argument. Pass arguments by reference and allow opening one end of the pipe at a time. * sys/strace.h (debug_only_printf): Define new macro which calls debug_printf only when DEBUGGING is defined.
2011-10-30 05:50:36 +01:00
fhandler_proc *fh = new (ptr) fhandler_proc (ptr);
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
copyto (fh);
return fh;
}
* path.h (pathconv_arg): Add PC_POSIX. (path_conv): Add normalized_path field. * path.cc (path_conv::~path_conv): New destructor. (path_conv::check): Set normalized_path, where appropriate. * dtable.cc (build_fhandler_from_name): Use normalized path from path_conv. * syscalls.cc (chroot): Ditto. * cygheap.h: Remove path_prefix_p declaration. Christopher Faylor <cgf@redhat.com> (minor fixups) * Makefile.in: Add fhandler_proc.o, fhandler_registry.o, fhandler_process.o and fhandler_virtual.o. * dtable.cc (dtable::build_fhandler): Add entries for FH_PROC, FH_REGISTRY and FH_PROCESS. Set unix_name to the normalized posix path. * fhandler.h: Add constants for FH_PROC, FH_REGISTRY and FH_PROCESS. Add class declarations for fhandler_virtual, fhandler_proc, fhandler_registry and fhandler_virtual. Update fhandler_union accordingly. * fhandler_proc.cc: New file. Add implementation for fhandler_proc. * fhandler_virtual.cc: New file. Add implementation for fhandler_virtual. * fhandler_process.cc: New file. Add implementation for fhandler_process. * fhandler_registry.cc: New file. Add implementation for fhandler_registry. * path.cc: Add isproc and isvirtual_dev macros. * path.cc (path_conv::check): Add check for virtual devices. * path.cc (mount_info::conv_to_win32_path): Convert paths in /proc to empty Win32 paths. * path.cc (chdir): Replace check for FH_CYGDRIVE with more generic isvirtual_dev macro. Force setting of posix path for virtual fhandlers. * path.h: Add externally visible path_prefix_p and normalized_posix_path prototypes.
2002-05-02 06:13:48 +02:00
};
* Makefile.in (DLL_OFILES): Add fhandler_procsys.o. * devices.h (enum fh_devices): Add FH_PROCSYS. * devices.in (dev_procsys_storage): New device. * devices.cc: Regenerate. * dtable.cc (build_fh_pc): Add code to allocate fhandler_procsys. * fhandler.h (proc_len): Convert to size_t. (procsys): Declare. (procsys_len): Declare. (enum virtual_ftype_t): Move here from fhandler_virtual.h. Add members supported by fhandler_procsys. (fhandler_virtual::exists): Return virtual_ftype_t. Change in all derived classes. (class fhandler_procsys): New class. (fhandler_union): Add fhandler_procnet and fhandler_procsys members. * fhandler_disk_file.cc (__DIR_mounts::check_missing_mount): Use ro_u_proc. (fhandler_base::fstat_by_handle): Don't copy attributes if file is an NT device. (fhandler_base::fstat_by_name): Ditto. * fhandler_netdrive.cc (fhandler_netdrive::exists): Return virtual_ftype_t. * fhandler_proc.cc (proc_tab): Sort alphabetically. Use _VN macro to store length. (proc_len): Change to size_t. (proc_tab_cmp): New static function. (virt_tab_search): New function to search entry in virt_tab_t arrays. Use throughout in /proc and sibling classes instead of loop. (fhandler_proc::exists): Return virtual_ftype_t. * fhandler_process.cc (process_tab): Sort alphabetically. Use _VN macro to store length. (fhandler_process::exists): Return virtual_ftype_t. (fhandler_process::open): Simplify code. * fhandler_procnet.cc (procnet_tab): Sort alphabetically. Use _VN macro to store length. (fhandler_procnet::exists): Return virtual_ftype_t. (fhandler_procnet::open): Simplify. * fhandler_procsys.cc: New file. * fhandler_registry.cc (fhandler_registry::exists): Return virtual_ftype_t. * fhandler_virtual.cc (fhandler_virtual::exists): Ditto. * fhandler_virtual.h (enum virtual_ftype_t): Move to fhandler.h. (virt_tab_t): Add name_len member. (_VN): New macro. (virt_tab_search): Declare. * mount.cc (mount_info::conv_to_win32_path): Fix comment. Backslashify isprocsys_dev paths. * ntdll.h (STATUS_OBJECT_TYPE_MISMATCH): Define (STATUS_INSTANCE_NOT_AVAILABLE): Define. (STATUS_PIPE_NOT_AVAILABLE): Define. (STATUS_INVALID_PIPE_STATE): Define. (STATUS_PIPE_BUSY): Define. (SYMBOLIC_LINK_QUERY): Define. (NtOpenSymbolicLinkObject): Declare. (NtQuerySymbolicLinkObject): Declare. * path.cc (path_conv::check): Accommodate fact that exists method returns virtual_ftype_t now. Add cases for new virtual_ftype_t types. (cygwin_conv_path): Add GLOBALROOT prefix to native device paths. Make sure to strip \\?\ prefix only for actual filesystem-based paths, not for all paths. * path.h (isproc_dev): Add FH_PROCSYS. (isprocsys_dev): Define.
2010-09-06 11:47:01 +02:00
class fhandler_procsys: public fhandler_virtual
{
public:
fhandler_procsys ();
virtual_ftype_t exists(struct __stat64 *buf) __attribute__ ((regparm (2)));
virtual_ftype_t exists();
DIR *opendir (int fd) __attribute__ ((regparm (2)));
int readdir (DIR *, dirent *) __attribute__ ((regparm (3)));
long telldir (DIR *);
void seekdir (DIR *, long);
int closedir (DIR *);
int open (int flags, mode_t mode = 0);
int close ();
void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3)));
ssize_t __stdcall write (const void *ptr, size_t len);
int __stdcall fstat (struct __stat64 *buf) __attribute__ ((regparm (2)));
bool fill_filebuf ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
fhandler_procsys (void *) {}
void copyto (fhandler_base *x)
{
x->pc.free_strings ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
*reinterpret_cast<fhandler_procsys *> (x) = *this;
x->reset (this);
}
fhandler_procsys *clone (cygheap_types malloc_type = HEAP_FHANDLER)
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
{
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_procsys));
* fhandler.h (fhandler_pipe::create_selectable): Remove optional argument, take an options argument for CreateNamedPipe/CreateFile. Change handle arguments to expect pointers. (fhandler_fifo::fifo_state): Delete. (fhandler_fifo::dummy_client): Ditto. (fhandler_fifo::open_nonserver): Ditto. (fhandler_fifo::wait_state): Ditto. (fhandler_fifo::raw_write): Ditto. (fhandler_fifo::read_ready): New field. (fhandler_fifo::write_ready): Ditto. (fhandler_fifo::wait): Modify argument. (fhandler_fifo::fifo_name): Add a new argument. (fhandler_fifo::fixup_after_fork): New function. * fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Remove initialization of expunged elements. Initialize new handles to NULL. (fhandler_fifo::open_nonserver): Delete. (fnevent): New macro for creating a named event. (fnpipe): New macro for creating a unique named pipe name. (create_pipe): New macro for simplification of named pipe creation. (fhandler_fifo::fifo_name): Use new argument when creating a shared name. (fhandler_fifo::open): Rewrite. Use events to synchronize. (pure_debug_printf): New macro, active only when DEBUGGING. (fhandler_fifo::wait): Rewrite to wait for new fifo events which are supplied as a parameter. (fhandler_fifo::raw_read): Rewrite to use handle mechanism to detect client-side disconnect. (fhandler_fifo::raw_write): Delete. (fhandler_fifo::close): Remove accommodations for expunged fields. Close event handles. (fhandler_fifo::dup): Remove accommodations for expunged fields. Duplicate event handles. (fhandler_fifo::fixup_after_fork): New function. Perform fixups on event handles. (fhandler_fifo::set_close_on_exec): Remove accommodations for expunged fields. Set inheritance for new handle fields. * miscfuncs.cc (CreatePipeOverlapped): Accommodate changes in fhandler_pipe::create_selectable. * tty.cc (tty::not_allocated): Ditto. * pipe.cc (fhandler_pipe::create): Ditto. (fhandler_pipe::create_selectable): Accept an extra open_mode argument. Pass arguments by reference and allow opening one end of the pipe at a time. * sys/strace.h (debug_only_printf): Define new macro which calls debug_printf only when DEBUGGING is defined.
2011-10-30 05:50:36 +01:00
fhandler_procsys *fh = new (ptr) fhandler_procsys (ptr);
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
copyto (fh);
return fh;
}
* Makefile.in (DLL_OFILES): Add fhandler_procsys.o. * devices.h (enum fh_devices): Add FH_PROCSYS. * devices.in (dev_procsys_storage): New device. * devices.cc: Regenerate. * dtable.cc (build_fh_pc): Add code to allocate fhandler_procsys. * fhandler.h (proc_len): Convert to size_t. (procsys): Declare. (procsys_len): Declare. (enum virtual_ftype_t): Move here from fhandler_virtual.h. Add members supported by fhandler_procsys. (fhandler_virtual::exists): Return virtual_ftype_t. Change in all derived classes. (class fhandler_procsys): New class. (fhandler_union): Add fhandler_procnet and fhandler_procsys members. * fhandler_disk_file.cc (__DIR_mounts::check_missing_mount): Use ro_u_proc. (fhandler_base::fstat_by_handle): Don't copy attributes if file is an NT device. (fhandler_base::fstat_by_name): Ditto. * fhandler_netdrive.cc (fhandler_netdrive::exists): Return virtual_ftype_t. * fhandler_proc.cc (proc_tab): Sort alphabetically. Use _VN macro to store length. (proc_len): Change to size_t. (proc_tab_cmp): New static function. (virt_tab_search): New function to search entry in virt_tab_t arrays. Use throughout in /proc and sibling classes instead of loop. (fhandler_proc::exists): Return virtual_ftype_t. * fhandler_process.cc (process_tab): Sort alphabetically. Use _VN macro to store length. (fhandler_process::exists): Return virtual_ftype_t. (fhandler_process::open): Simplify code. * fhandler_procnet.cc (procnet_tab): Sort alphabetically. Use _VN macro to store length. (fhandler_procnet::exists): Return virtual_ftype_t. (fhandler_procnet::open): Simplify. * fhandler_procsys.cc: New file. * fhandler_registry.cc (fhandler_registry::exists): Return virtual_ftype_t. * fhandler_virtual.cc (fhandler_virtual::exists): Ditto. * fhandler_virtual.h (enum virtual_ftype_t): Move to fhandler.h. (virt_tab_t): Add name_len member. (_VN): New macro. (virt_tab_search): Declare. * mount.cc (mount_info::conv_to_win32_path): Fix comment. Backslashify isprocsys_dev paths. * ntdll.h (STATUS_OBJECT_TYPE_MISMATCH): Define (STATUS_INSTANCE_NOT_AVAILABLE): Define. (STATUS_PIPE_NOT_AVAILABLE): Define. (STATUS_INVALID_PIPE_STATE): Define. (STATUS_PIPE_BUSY): Define. (SYMBOLIC_LINK_QUERY): Define. (NtOpenSymbolicLinkObject): Declare. (NtQuerySymbolicLinkObject): Declare. * path.cc (path_conv::check): Accommodate fact that exists method returns virtual_ftype_t now. Add cases for new virtual_ftype_t types. (cygwin_conv_path): Add GLOBALROOT prefix to native device paths. Make sure to strip \\?\ prefix only for actual filesystem-based paths, not for all paths. * path.h (isproc_dev): Add FH_PROCSYS. (isprocsys_dev): Define.
2010-09-06 11:47:01 +02:00
};
class fhandler_procsysvipc: public fhandler_proc
{
pid_t pid;
public:
fhandler_procsysvipc ();
virtual_ftype_t exists();
int readdir (DIR *, dirent *) __attribute__ ((regparm (3)));
int open (int flags, mode_t mode = 0);
int __stdcall fstat (struct __stat64 *buf) __attribute__ ((regparm (2)));
bool fill_filebuf ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
fhandler_procsysvipc (void *) {}
void copyto (fhandler_base *x)
{
x->pc.free_strings ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
*reinterpret_cast<fhandler_procsysvipc *> (x) = *this;
x->reset (this);
}
fhandler_procsysvipc *clone (cygheap_types malloc_type = HEAP_FHANDLER)
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
{
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_procsysvipc));
* fhandler.h (fhandler_pipe::create_selectable): Remove optional argument, take an options argument for CreateNamedPipe/CreateFile. Change handle arguments to expect pointers. (fhandler_fifo::fifo_state): Delete. (fhandler_fifo::dummy_client): Ditto. (fhandler_fifo::open_nonserver): Ditto. (fhandler_fifo::wait_state): Ditto. (fhandler_fifo::raw_write): Ditto. (fhandler_fifo::read_ready): New field. (fhandler_fifo::write_ready): Ditto. (fhandler_fifo::wait): Modify argument. (fhandler_fifo::fifo_name): Add a new argument. (fhandler_fifo::fixup_after_fork): New function. * fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Remove initialization of expunged elements. Initialize new handles to NULL. (fhandler_fifo::open_nonserver): Delete. (fnevent): New macro for creating a named event. (fnpipe): New macro for creating a unique named pipe name. (create_pipe): New macro for simplification of named pipe creation. (fhandler_fifo::fifo_name): Use new argument when creating a shared name. (fhandler_fifo::open): Rewrite. Use events to synchronize. (pure_debug_printf): New macro, active only when DEBUGGING. (fhandler_fifo::wait): Rewrite to wait for new fifo events which are supplied as a parameter. (fhandler_fifo::raw_read): Rewrite to use handle mechanism to detect client-side disconnect. (fhandler_fifo::raw_write): Delete. (fhandler_fifo::close): Remove accommodations for expunged fields. Close event handles. (fhandler_fifo::dup): Remove accommodations for expunged fields. Duplicate event handles. (fhandler_fifo::fixup_after_fork): New function. Perform fixups on event handles. (fhandler_fifo::set_close_on_exec): Remove accommodations for expunged fields. Set inheritance for new handle fields. * miscfuncs.cc (CreatePipeOverlapped): Accommodate changes in fhandler_pipe::create_selectable. * tty.cc (tty::not_allocated): Ditto. * pipe.cc (fhandler_pipe::create): Ditto. (fhandler_pipe::create_selectable): Accept an extra open_mode argument. Pass arguments by reference and allow opening one end of the pipe at a time. * sys/strace.h (debug_only_printf): Define new macro which calls debug_printf only when DEBUGGING is defined.
2011-10-30 05:50:36 +01:00
fhandler_procsysvipc *fh = new (ptr) fhandler_procsysvipc (ptr);
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
copyto (fh);
return fh;
}
};
class fhandler_netdrive: public fhandler_virtual
{
public:
fhandler_netdrive ();
* Makefile.in (DLL_OFILES): Add fhandler_procsys.o. * devices.h (enum fh_devices): Add FH_PROCSYS. * devices.in (dev_procsys_storage): New device. * devices.cc: Regenerate. * dtable.cc (build_fh_pc): Add code to allocate fhandler_procsys. * fhandler.h (proc_len): Convert to size_t. (procsys): Declare. (procsys_len): Declare. (enum virtual_ftype_t): Move here from fhandler_virtual.h. Add members supported by fhandler_procsys. (fhandler_virtual::exists): Return virtual_ftype_t. Change in all derived classes. (class fhandler_procsys): New class. (fhandler_union): Add fhandler_procnet and fhandler_procsys members. * fhandler_disk_file.cc (__DIR_mounts::check_missing_mount): Use ro_u_proc. (fhandler_base::fstat_by_handle): Don't copy attributes if file is an NT device. (fhandler_base::fstat_by_name): Ditto. * fhandler_netdrive.cc (fhandler_netdrive::exists): Return virtual_ftype_t. * fhandler_proc.cc (proc_tab): Sort alphabetically. Use _VN macro to store length. (proc_len): Change to size_t. (proc_tab_cmp): New static function. (virt_tab_search): New function to search entry in virt_tab_t arrays. Use throughout in /proc and sibling classes instead of loop. (fhandler_proc::exists): Return virtual_ftype_t. * fhandler_process.cc (process_tab): Sort alphabetically. Use _VN macro to store length. (fhandler_process::exists): Return virtual_ftype_t. (fhandler_process::open): Simplify code. * fhandler_procnet.cc (procnet_tab): Sort alphabetically. Use _VN macro to store length. (fhandler_procnet::exists): Return virtual_ftype_t. (fhandler_procnet::open): Simplify. * fhandler_procsys.cc: New file. * fhandler_registry.cc (fhandler_registry::exists): Return virtual_ftype_t. * fhandler_virtual.cc (fhandler_virtual::exists): Ditto. * fhandler_virtual.h (enum virtual_ftype_t): Move to fhandler.h. (virt_tab_t): Add name_len member. (_VN): New macro. (virt_tab_search): Declare. * mount.cc (mount_info::conv_to_win32_path): Fix comment. Backslashify isprocsys_dev paths. * ntdll.h (STATUS_OBJECT_TYPE_MISMATCH): Define (STATUS_INSTANCE_NOT_AVAILABLE): Define. (STATUS_PIPE_NOT_AVAILABLE): Define. (STATUS_INVALID_PIPE_STATE): Define. (STATUS_PIPE_BUSY): Define. (SYMBOLIC_LINK_QUERY): Define. (NtOpenSymbolicLinkObject): Declare. (NtQuerySymbolicLinkObject): Declare. * path.cc (path_conv::check): Accommodate fact that exists method returns virtual_ftype_t now. Add cases for new virtual_ftype_t types. (cygwin_conv_path): Add GLOBALROOT prefix to native device paths. Make sure to strip \\?\ prefix only for actual filesystem-based paths, not for all paths. * path.h (isproc_dev): Add FH_PROCSYS. (isprocsys_dev): Define.
2010-09-06 11:47:01 +02:00
virtual_ftype_t exists();
int readdir (DIR *, dirent *) __attribute__ ((regparm (3)));
void seekdir (DIR *, long);
void rewinddir (DIR *);
int closedir (DIR *);
int open (int flags, mode_t mode = 0);
int __stdcall fstat (struct __stat64 *buf) __attribute__ ((regparm (2)));
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
fhandler_netdrive (void *) {}
void copyto (fhandler_base *x)
{
x->pc.free_strings ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
*reinterpret_cast<fhandler_netdrive *> (x) = *this;
x->reset (this);
}
fhandler_netdrive *clone (cygheap_types malloc_type = HEAP_FHANDLER)
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
{
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_netdrive));
* fhandler.h (fhandler_pipe::create_selectable): Remove optional argument, take an options argument for CreateNamedPipe/CreateFile. Change handle arguments to expect pointers. (fhandler_fifo::fifo_state): Delete. (fhandler_fifo::dummy_client): Ditto. (fhandler_fifo::open_nonserver): Ditto. (fhandler_fifo::wait_state): Ditto. (fhandler_fifo::raw_write): Ditto. (fhandler_fifo::read_ready): New field. (fhandler_fifo::write_ready): Ditto. (fhandler_fifo::wait): Modify argument. (fhandler_fifo::fifo_name): Add a new argument. (fhandler_fifo::fixup_after_fork): New function. * fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Remove initialization of expunged elements. Initialize new handles to NULL. (fhandler_fifo::open_nonserver): Delete. (fnevent): New macro for creating a named event. (fnpipe): New macro for creating a unique named pipe name. (create_pipe): New macro for simplification of named pipe creation. (fhandler_fifo::fifo_name): Use new argument when creating a shared name. (fhandler_fifo::open): Rewrite. Use events to synchronize. (pure_debug_printf): New macro, active only when DEBUGGING. (fhandler_fifo::wait): Rewrite to wait for new fifo events which are supplied as a parameter. (fhandler_fifo::raw_read): Rewrite to use handle mechanism to detect client-side disconnect. (fhandler_fifo::raw_write): Delete. (fhandler_fifo::close): Remove accommodations for expunged fields. Close event handles. (fhandler_fifo::dup): Remove accommodations for expunged fields. Duplicate event handles. (fhandler_fifo::fixup_after_fork): New function. Perform fixups on event handles. (fhandler_fifo::set_close_on_exec): Remove accommodations for expunged fields. Set inheritance for new handle fields. * miscfuncs.cc (CreatePipeOverlapped): Accommodate changes in fhandler_pipe::create_selectable. * tty.cc (tty::not_allocated): Ditto. * pipe.cc (fhandler_pipe::create): Ditto. (fhandler_pipe::create_selectable): Accept an extra open_mode argument. Pass arguments by reference and allow opening one end of the pipe at a time. * sys/strace.h (debug_only_printf): Define new macro which calls debug_printf only when DEBUGGING is defined.
2011-10-30 05:50:36 +01:00
fhandler_netdrive *fh = new (ptr) fhandler_netdrive (ptr);
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
copyto (fh);
return fh;
}
};
* path.h (pathconv_arg): Add PC_POSIX. (path_conv): Add normalized_path field. * path.cc (path_conv::~path_conv): New destructor. (path_conv::check): Set normalized_path, where appropriate. * dtable.cc (build_fhandler_from_name): Use normalized path from path_conv. * syscalls.cc (chroot): Ditto. * cygheap.h: Remove path_prefix_p declaration. Christopher Faylor <cgf@redhat.com> (minor fixups) * Makefile.in: Add fhandler_proc.o, fhandler_registry.o, fhandler_process.o and fhandler_virtual.o. * dtable.cc (dtable::build_fhandler): Add entries for FH_PROC, FH_REGISTRY and FH_PROCESS. Set unix_name to the normalized posix path. * fhandler.h: Add constants for FH_PROC, FH_REGISTRY and FH_PROCESS. Add class declarations for fhandler_virtual, fhandler_proc, fhandler_registry and fhandler_virtual. Update fhandler_union accordingly. * fhandler_proc.cc: New file. Add implementation for fhandler_proc. * fhandler_virtual.cc: New file. Add implementation for fhandler_virtual. * fhandler_process.cc: New file. Add implementation for fhandler_process. * fhandler_registry.cc: New file. Add implementation for fhandler_registry. * path.cc: Add isproc and isvirtual_dev macros. * path.cc (path_conv::check): Add check for virtual devices. * path.cc (mount_info::conv_to_win32_path): Convert paths in /proc to empty Win32 paths. * path.cc (chdir): Replace check for FH_CYGDRIVE with more generic isvirtual_dev macro. Force setting of posix path for virtual fhandlers. * path.h: Add externally visible path_prefix_p and normalized_posix_path prototypes.
2002-05-02 06:13:48 +02:00
class fhandler_registry: public fhandler_proc
{
* autoload.cc (GetSecurityInfo): Define new autoload function. (RegQueryInfoKeyA): Ditto. * fhandler.h (fhandler_virtual::fill_filebuf): Change return type to bool. (fhandler_proc::fill_filebuf): Ditto. (fhandler_registry::fill_filebuf): Ditto. (fhandler_process::fill_filebuf): Ditto. (fhandler_registry::value_name): Add new member. (fhandler_registry::close): Add new method. (fhandler_process::p): Remove member. * fhandler_proc.cc (fhandler_proc::open): Add set_nohandle after calling superclass method. Check return value of fill_filebuf. (fhandler_proc::fill_filebuf): Change return type to bool. Add return statement. * fhandler_process.cc (fhandler_process::open): Add set_nohandle after calling superclass method. Remove references to p. Check return value of fill_filebuf. (fhandler_process::fill_filebuf): Change return type to bool. Don't use dereference operator on p. Add return statement. (fhandler_process::format_process_stat): Fix typo. * fhandler_registry.cc: Add static open_key declaration. (fhandler_registry::exists): Assume path is already normalised. Try opening the path as a key in its own right first, before reverting to enumerating subkeys and values of the parent key. (fhandler_registry::fstat): Add additional code to return more relevant information about the registry key/value. (fhandler_registry::readdir): Explicitly set desired access when opening registry key. Remove output of buf from debug_printf format string. (fhandler_registry::open): Use set_io_handle to store registry key handle. Set value_name member. Move code to read a value from the registry to fill_filebuf. Add call to fill_filebuf. (fhandler_registry::close): New method. (fhandler_registry::fill_filebuf): Change return type to bool. Add code to read a value from registry. (fhandler_registry::open_key): Make function static. Use KEY_READ as desired access unless this is the last path component. Check the return value of RegOpenKeyEx for an error instead of hKey. * fhandler_virtual.cc (fhandler_virtual::lseek): Check the return value of fill_filebuf. (fhandler_virtual::open): Remove call to set_nohandle. (fhandler_virtual::fill_filebuf): Change return type to bool. Add return statement. * security.cc (get_nt_object_attribute): New function. (get_object_attribute): New function. * security.h (get_object_attribute): New function declaration.
2002-07-02 03:36:15 +02:00
private:
wchar_t *value_name;
DWORD wow64;
int prefix_len;
* path.h (pathconv_arg): Add PC_POSIX. (path_conv): Add normalized_path field. * path.cc (path_conv::~path_conv): New destructor. (path_conv::check): Set normalized_path, where appropriate. * dtable.cc (build_fhandler_from_name): Use normalized path from path_conv. * syscalls.cc (chroot): Ditto. * cygheap.h: Remove path_prefix_p declaration. Christopher Faylor <cgf@redhat.com> (minor fixups) * Makefile.in: Add fhandler_proc.o, fhandler_registry.o, fhandler_process.o and fhandler_virtual.o. * dtable.cc (dtable::build_fhandler): Add entries for FH_PROC, FH_REGISTRY and FH_PROCESS. Set unix_name to the normalized posix path. * fhandler.h: Add constants for FH_PROC, FH_REGISTRY and FH_PROCESS. Add class declarations for fhandler_virtual, fhandler_proc, fhandler_registry and fhandler_virtual. Update fhandler_union accordingly. * fhandler_proc.cc: New file. Add implementation for fhandler_proc. * fhandler_virtual.cc: New file. Add implementation for fhandler_virtual. * fhandler_process.cc: New file. Add implementation for fhandler_process. * fhandler_registry.cc: New file. Add implementation for fhandler_registry. * path.cc: Add isproc and isvirtual_dev macros. * path.cc (path_conv::check): Add check for virtual devices. * path.cc (mount_info::conv_to_win32_path): Convert paths in /proc to empty Win32 paths. * path.cc (chdir): Replace check for FH_CYGDRIVE with more generic isvirtual_dev macro. Force setting of posix path for virtual fhandlers. * path.h: Add externally visible path_prefix_p and normalized_posix_path prototypes.
2002-05-02 06:13:48 +02:00
public:
fhandler_registry ();
void set_name (path_conv &pc);
* Makefile.in (DLL_OFILES): Add fhandler_procsys.o. * devices.h (enum fh_devices): Add FH_PROCSYS. * devices.in (dev_procsys_storage): New device. * devices.cc: Regenerate. * dtable.cc (build_fh_pc): Add code to allocate fhandler_procsys. * fhandler.h (proc_len): Convert to size_t. (procsys): Declare. (procsys_len): Declare. (enum virtual_ftype_t): Move here from fhandler_virtual.h. Add members supported by fhandler_procsys. (fhandler_virtual::exists): Return virtual_ftype_t. Change in all derived classes. (class fhandler_procsys): New class. (fhandler_union): Add fhandler_procnet and fhandler_procsys members. * fhandler_disk_file.cc (__DIR_mounts::check_missing_mount): Use ro_u_proc. (fhandler_base::fstat_by_handle): Don't copy attributes if file is an NT device. (fhandler_base::fstat_by_name): Ditto. * fhandler_netdrive.cc (fhandler_netdrive::exists): Return virtual_ftype_t. * fhandler_proc.cc (proc_tab): Sort alphabetically. Use _VN macro to store length. (proc_len): Change to size_t. (proc_tab_cmp): New static function. (virt_tab_search): New function to search entry in virt_tab_t arrays. Use throughout in /proc and sibling classes instead of loop. (fhandler_proc::exists): Return virtual_ftype_t. * fhandler_process.cc (process_tab): Sort alphabetically. Use _VN macro to store length. (fhandler_process::exists): Return virtual_ftype_t. (fhandler_process::open): Simplify code. * fhandler_procnet.cc (procnet_tab): Sort alphabetically. Use _VN macro to store length. (fhandler_procnet::exists): Return virtual_ftype_t. (fhandler_procnet::open): Simplify. * fhandler_procsys.cc: New file. * fhandler_registry.cc (fhandler_registry::exists): Return virtual_ftype_t. * fhandler_virtual.cc (fhandler_virtual::exists): Ditto. * fhandler_virtual.h (enum virtual_ftype_t): Move to fhandler.h. (virt_tab_t): Add name_len member. (_VN): New macro. (virt_tab_search): Declare. * mount.cc (mount_info::conv_to_win32_path): Fix comment. Backslashify isprocsys_dev paths. * ntdll.h (STATUS_OBJECT_TYPE_MISMATCH): Define (STATUS_INSTANCE_NOT_AVAILABLE): Define. (STATUS_PIPE_NOT_AVAILABLE): Define. (STATUS_INVALID_PIPE_STATE): Define. (STATUS_PIPE_BUSY): Define. (SYMBOLIC_LINK_QUERY): Define. (NtOpenSymbolicLinkObject): Declare. (NtQuerySymbolicLinkObject): Declare. * path.cc (path_conv::check): Accommodate fact that exists method returns virtual_ftype_t now. Add cases for new virtual_ftype_t types. (cygwin_conv_path): Add GLOBALROOT prefix to native device paths. Make sure to strip \\?\ prefix only for actual filesystem-based paths, not for all paths. * path.h (isproc_dev): Add FH_PROCSYS. (isprocsys_dev): Define.
2010-09-06 11:47:01 +02:00
virtual_ftype_t exists();
DIR *opendir (int fd) __attribute__ ((regparm (2)));
int readdir (DIR *, dirent *) __attribute__ ((regparm (3)));
long telldir (DIR *);
void seekdir (DIR *, long);
* path.h (pathconv_arg): Add PC_POSIX. (path_conv): Add normalized_path field. * path.cc (path_conv::~path_conv): New destructor. (path_conv::check): Set normalized_path, where appropriate. * dtable.cc (build_fhandler_from_name): Use normalized path from path_conv. * syscalls.cc (chroot): Ditto. * cygheap.h: Remove path_prefix_p declaration. Christopher Faylor <cgf@redhat.com> (minor fixups) * Makefile.in: Add fhandler_proc.o, fhandler_registry.o, fhandler_process.o and fhandler_virtual.o. * dtable.cc (dtable::build_fhandler): Add entries for FH_PROC, FH_REGISTRY and FH_PROCESS. Set unix_name to the normalized posix path. * fhandler.h: Add constants for FH_PROC, FH_REGISTRY and FH_PROCESS. Add class declarations for fhandler_virtual, fhandler_proc, fhandler_registry and fhandler_virtual. Update fhandler_union accordingly. * fhandler_proc.cc: New file. Add implementation for fhandler_proc. * fhandler_virtual.cc: New file. Add implementation for fhandler_virtual. * fhandler_process.cc: New file. Add implementation for fhandler_process. * fhandler_registry.cc: New file. Add implementation for fhandler_registry. * path.cc: Add isproc and isvirtual_dev macros. * path.cc (path_conv::check): Add check for virtual devices. * path.cc (mount_info::conv_to_win32_path): Convert paths in /proc to empty Win32 paths. * path.cc (chdir): Replace check for FH_CYGDRIVE with more generic isvirtual_dev macro. Force setting of posix path for virtual fhandlers. * path.h: Add externally visible path_prefix_p and normalized_posix_path prototypes.
2002-05-02 06:13:48 +02:00
void rewinddir (DIR *);
int closedir (DIR *);
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
int open (int flags, mode_t mode = 0);
int __stdcall fstat (struct __stat64 *buf) __attribute__ ((regparm (2)));
* autoload.cc (GetSecurityInfo): Define new autoload function. (RegQueryInfoKeyA): Ditto. * fhandler.h (fhandler_virtual::fill_filebuf): Change return type to bool. (fhandler_proc::fill_filebuf): Ditto. (fhandler_registry::fill_filebuf): Ditto. (fhandler_process::fill_filebuf): Ditto. (fhandler_registry::value_name): Add new member. (fhandler_registry::close): Add new method. (fhandler_process::p): Remove member. * fhandler_proc.cc (fhandler_proc::open): Add set_nohandle after calling superclass method. Check return value of fill_filebuf. (fhandler_proc::fill_filebuf): Change return type to bool. Add return statement. * fhandler_process.cc (fhandler_process::open): Add set_nohandle after calling superclass method. Remove references to p. Check return value of fill_filebuf. (fhandler_process::fill_filebuf): Change return type to bool. Don't use dereference operator on p. Add return statement. (fhandler_process::format_process_stat): Fix typo. * fhandler_registry.cc: Add static open_key declaration. (fhandler_registry::exists): Assume path is already normalised. Try opening the path as a key in its own right first, before reverting to enumerating subkeys and values of the parent key. (fhandler_registry::fstat): Add additional code to return more relevant information about the registry key/value. (fhandler_registry::readdir): Explicitly set desired access when opening registry key. Remove output of buf from debug_printf format string. (fhandler_registry::open): Use set_io_handle to store registry key handle. Set value_name member. Move code to read a value from the registry to fill_filebuf. Add call to fill_filebuf. (fhandler_registry::close): New method. (fhandler_registry::fill_filebuf): Change return type to bool. Add code to read a value from registry. (fhandler_registry::open_key): Make function static. Use KEY_READ as desired access unless this is the last path component. Check the return value of RegOpenKeyEx for an error instead of hKey. * fhandler_virtual.cc (fhandler_virtual::lseek): Check the return value of fill_filebuf. (fhandler_virtual::open): Remove call to set_nohandle. (fhandler_virtual::fill_filebuf): Change return type to bool. Add return statement. * security.cc (get_nt_object_attribute): New function. (get_object_attribute): New function. * security.h (get_object_attribute): New function declaration.
2002-07-02 03:36:15 +02:00
bool fill_filebuf ();
int close ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
int dup (fhandler_base *child, int);
fhandler_registry (void *) {}
void copyto (fhandler_base *x)
{
x->pc.free_strings ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
*reinterpret_cast<fhandler_registry *> (x) = *this;
x->reset (this);
}
fhandler_registry *clone (cygheap_types malloc_type = HEAP_FHANDLER)
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
{
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_registry));
* fhandler.h (fhandler_pipe::create_selectable): Remove optional argument, take an options argument for CreateNamedPipe/CreateFile. Change handle arguments to expect pointers. (fhandler_fifo::fifo_state): Delete. (fhandler_fifo::dummy_client): Ditto. (fhandler_fifo::open_nonserver): Ditto. (fhandler_fifo::wait_state): Ditto. (fhandler_fifo::raw_write): Ditto. (fhandler_fifo::read_ready): New field. (fhandler_fifo::write_ready): Ditto. (fhandler_fifo::wait): Modify argument. (fhandler_fifo::fifo_name): Add a new argument. (fhandler_fifo::fixup_after_fork): New function. * fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Remove initialization of expunged elements. Initialize new handles to NULL. (fhandler_fifo::open_nonserver): Delete. (fnevent): New macro for creating a named event. (fnpipe): New macro for creating a unique named pipe name. (create_pipe): New macro for simplification of named pipe creation. (fhandler_fifo::fifo_name): Use new argument when creating a shared name. (fhandler_fifo::open): Rewrite. Use events to synchronize. (pure_debug_printf): New macro, active only when DEBUGGING. (fhandler_fifo::wait): Rewrite to wait for new fifo events which are supplied as a parameter. (fhandler_fifo::raw_read): Rewrite to use handle mechanism to detect client-side disconnect. (fhandler_fifo::raw_write): Delete. (fhandler_fifo::close): Remove accommodations for expunged fields. Close event handles. (fhandler_fifo::dup): Remove accommodations for expunged fields. Duplicate event handles. (fhandler_fifo::fixup_after_fork): New function. Perform fixups on event handles. (fhandler_fifo::set_close_on_exec): Remove accommodations for expunged fields. Set inheritance for new handle fields. * miscfuncs.cc (CreatePipeOverlapped): Accommodate changes in fhandler_pipe::create_selectable. * tty.cc (tty::not_allocated): Ditto. * pipe.cc (fhandler_pipe::create): Ditto. (fhandler_pipe::create_selectable): Accept an extra open_mode argument. Pass arguments by reference and allow opening one end of the pipe at a time. * sys/strace.h (debug_only_printf): Define new macro which calls debug_printf only when DEBUGGING is defined.
2011-10-30 05:50:36 +01:00
fhandler_registry *fh = new (ptr) fhandler_registry (ptr);
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
copyto (fh);
return fh;
}
* path.h (pathconv_arg): Add PC_POSIX. (path_conv): Add normalized_path field. * path.cc (path_conv::~path_conv): New destructor. (path_conv::check): Set normalized_path, where appropriate. * dtable.cc (build_fhandler_from_name): Use normalized path from path_conv. * syscalls.cc (chroot): Ditto. * cygheap.h: Remove path_prefix_p declaration. Christopher Faylor <cgf@redhat.com> (minor fixups) * Makefile.in: Add fhandler_proc.o, fhandler_registry.o, fhandler_process.o and fhandler_virtual.o. * dtable.cc (dtable::build_fhandler): Add entries for FH_PROC, FH_REGISTRY and FH_PROCESS. Set unix_name to the normalized posix path. * fhandler.h: Add constants for FH_PROC, FH_REGISTRY and FH_PROCESS. Add class declarations for fhandler_virtual, fhandler_proc, fhandler_registry and fhandler_virtual. Update fhandler_union accordingly. * fhandler_proc.cc: New file. Add implementation for fhandler_proc. * fhandler_virtual.cc: New file. Add implementation for fhandler_virtual. * fhandler_process.cc: New file. Add implementation for fhandler_process. * fhandler_registry.cc: New file. Add implementation for fhandler_registry. * path.cc: Add isproc and isvirtual_dev macros. * path.cc (path_conv::check): Add check for virtual devices. * path.cc (mount_info::conv_to_win32_path): Convert paths in /proc to empty Win32 paths. * path.cc (chdir): Replace check for FH_CYGDRIVE with more generic isvirtual_dev macro. Force setting of posix path for virtual fhandlers. * path.h: Add externally visible path_prefix_p and normalized_posix_path prototypes.
2002-05-02 06:13:48 +02:00
};
class pinfo;
* path.h (pathconv_arg): Add PC_POSIX. (path_conv): Add normalized_path field. * path.cc (path_conv::~path_conv): New destructor. (path_conv::check): Set normalized_path, where appropriate. * dtable.cc (build_fhandler_from_name): Use normalized path from path_conv. * syscalls.cc (chroot): Ditto. * cygheap.h: Remove path_prefix_p declaration. Christopher Faylor <cgf@redhat.com> (minor fixups) * Makefile.in: Add fhandler_proc.o, fhandler_registry.o, fhandler_process.o and fhandler_virtual.o. * dtable.cc (dtable::build_fhandler): Add entries for FH_PROC, FH_REGISTRY and FH_PROCESS. Set unix_name to the normalized posix path. * fhandler.h: Add constants for FH_PROC, FH_REGISTRY and FH_PROCESS. Add class declarations for fhandler_virtual, fhandler_proc, fhandler_registry and fhandler_virtual. Update fhandler_union accordingly. * fhandler_proc.cc: New file. Add implementation for fhandler_proc. * fhandler_virtual.cc: New file. Add implementation for fhandler_virtual. * fhandler_process.cc: New file. Add implementation for fhandler_process. * fhandler_registry.cc: New file. Add implementation for fhandler_registry. * path.cc: Add isproc and isvirtual_dev macros. * path.cc (path_conv::check): Add check for virtual devices. * path.cc (mount_info::conv_to_win32_path): Convert paths in /proc to empty Win32 paths. * path.cc (chdir): Replace check for FH_CYGDRIVE with more generic isvirtual_dev macro. Force setting of posix path for virtual fhandlers. * path.h: Add externally visible path_prefix_p and normalized_posix_path prototypes.
2002-05-02 06:13:48 +02:00
class fhandler_process: public fhandler_proc
{
pid_t pid;
* path.h (pathconv_arg): Add PC_POSIX. (path_conv): Add normalized_path field. * path.cc (path_conv::~path_conv): New destructor. (path_conv::check): Set normalized_path, where appropriate. * dtable.cc (build_fhandler_from_name): Use normalized path from path_conv. * syscalls.cc (chroot): Ditto. * cygheap.h: Remove path_prefix_p declaration. Christopher Faylor <cgf@redhat.com> (minor fixups) * Makefile.in: Add fhandler_proc.o, fhandler_registry.o, fhandler_process.o and fhandler_virtual.o. * dtable.cc (dtable::build_fhandler): Add entries for FH_PROC, FH_REGISTRY and FH_PROCESS. Set unix_name to the normalized posix path. * fhandler.h: Add constants for FH_PROC, FH_REGISTRY and FH_PROCESS. Add class declarations for fhandler_virtual, fhandler_proc, fhandler_registry and fhandler_virtual. Update fhandler_union accordingly. * fhandler_proc.cc: New file. Add implementation for fhandler_proc. * fhandler_virtual.cc: New file. Add implementation for fhandler_virtual. * fhandler_process.cc: New file. Add implementation for fhandler_process. * fhandler_registry.cc: New file. Add implementation for fhandler_registry. * path.cc: Add isproc and isvirtual_dev macros. * path.cc (path_conv::check): Add check for virtual devices. * path.cc (mount_info::conv_to_win32_path): Convert paths in /proc to empty Win32 paths. * path.cc (chdir): Replace check for FH_CYGDRIVE with more generic isvirtual_dev macro. Force setting of posix path for virtual fhandlers. * path.h: Add externally visible path_prefix_p and normalized_posix_path prototypes.
2002-05-02 06:13:48 +02:00
public:
fhandler_process ();
* Makefile.in (DLL_OFILES): Add fhandler_procsys.o. * devices.h (enum fh_devices): Add FH_PROCSYS. * devices.in (dev_procsys_storage): New device. * devices.cc: Regenerate. * dtable.cc (build_fh_pc): Add code to allocate fhandler_procsys. * fhandler.h (proc_len): Convert to size_t. (procsys): Declare. (procsys_len): Declare. (enum virtual_ftype_t): Move here from fhandler_virtual.h. Add members supported by fhandler_procsys. (fhandler_virtual::exists): Return virtual_ftype_t. Change in all derived classes. (class fhandler_procsys): New class. (fhandler_union): Add fhandler_procnet and fhandler_procsys members. * fhandler_disk_file.cc (__DIR_mounts::check_missing_mount): Use ro_u_proc. (fhandler_base::fstat_by_handle): Don't copy attributes if file is an NT device. (fhandler_base::fstat_by_name): Ditto. * fhandler_netdrive.cc (fhandler_netdrive::exists): Return virtual_ftype_t. * fhandler_proc.cc (proc_tab): Sort alphabetically. Use _VN macro to store length. (proc_len): Change to size_t. (proc_tab_cmp): New static function. (virt_tab_search): New function to search entry in virt_tab_t arrays. Use throughout in /proc and sibling classes instead of loop. (fhandler_proc::exists): Return virtual_ftype_t. * fhandler_process.cc (process_tab): Sort alphabetically. Use _VN macro to store length. (fhandler_process::exists): Return virtual_ftype_t. (fhandler_process::open): Simplify code. * fhandler_procnet.cc (procnet_tab): Sort alphabetically. Use _VN macro to store length. (fhandler_procnet::exists): Return virtual_ftype_t. (fhandler_procnet::open): Simplify. * fhandler_procsys.cc: New file. * fhandler_registry.cc (fhandler_registry::exists): Return virtual_ftype_t. * fhandler_virtual.cc (fhandler_virtual::exists): Ditto. * fhandler_virtual.h (enum virtual_ftype_t): Move to fhandler.h. (virt_tab_t): Add name_len member. (_VN): New macro. (virt_tab_search): Declare. * mount.cc (mount_info::conv_to_win32_path): Fix comment. Backslashify isprocsys_dev paths. * ntdll.h (STATUS_OBJECT_TYPE_MISMATCH): Define (STATUS_INSTANCE_NOT_AVAILABLE): Define. (STATUS_PIPE_NOT_AVAILABLE): Define. (STATUS_INVALID_PIPE_STATE): Define. (STATUS_PIPE_BUSY): Define. (SYMBOLIC_LINK_QUERY): Define. (NtOpenSymbolicLinkObject): Declare. (NtQuerySymbolicLinkObject): Declare. * path.cc (path_conv::check): Accommodate fact that exists method returns virtual_ftype_t now. Add cases for new virtual_ftype_t types. (cygwin_conv_path): Add GLOBALROOT prefix to native device paths. Make sure to strip \\?\ prefix only for actual filesystem-based paths, not for all paths. * path.h (isproc_dev): Add FH_PROCSYS. (isprocsys_dev): Define.
2010-09-06 11:47:01 +02:00
virtual_ftype_t exists();
DIR *opendir (int fd) __attribute__ ((regparm (2)));
int closedir (DIR *);
int readdir (DIR *, dirent *) __attribute__ ((regparm (3)));
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
int open (int flags, mode_t mode = 0);
int __stdcall fstat (struct __stat64 *buf) __attribute__ ((regparm (2)));
* autoload.cc (GetSecurityInfo): Define new autoload function. (RegQueryInfoKeyA): Ditto. * fhandler.h (fhandler_virtual::fill_filebuf): Change return type to bool. (fhandler_proc::fill_filebuf): Ditto. (fhandler_registry::fill_filebuf): Ditto. (fhandler_process::fill_filebuf): Ditto. (fhandler_registry::value_name): Add new member. (fhandler_registry::close): Add new method. (fhandler_process::p): Remove member. * fhandler_proc.cc (fhandler_proc::open): Add set_nohandle after calling superclass method. Check return value of fill_filebuf. (fhandler_proc::fill_filebuf): Change return type to bool. Add return statement. * fhandler_process.cc (fhandler_process::open): Add set_nohandle after calling superclass method. Remove references to p. Check return value of fill_filebuf. (fhandler_process::fill_filebuf): Change return type to bool. Don't use dereference operator on p. Add return statement. (fhandler_process::format_process_stat): Fix typo. * fhandler_registry.cc: Add static open_key declaration. (fhandler_registry::exists): Assume path is already normalised. Try opening the path as a key in its own right first, before reverting to enumerating subkeys and values of the parent key. (fhandler_registry::fstat): Add additional code to return more relevant information about the registry key/value. (fhandler_registry::readdir): Explicitly set desired access when opening registry key. Remove output of buf from debug_printf format string. (fhandler_registry::open): Use set_io_handle to store registry key handle. Set value_name member. Move code to read a value from the registry to fill_filebuf. Add call to fill_filebuf. (fhandler_registry::close): New method. (fhandler_registry::fill_filebuf): Change return type to bool. Add code to read a value from registry. (fhandler_registry::open_key): Make function static. Use KEY_READ as desired access unless this is the last path component. Check the return value of RegOpenKeyEx for an error instead of hKey. * fhandler_virtual.cc (fhandler_virtual::lseek): Check the return value of fill_filebuf. (fhandler_virtual::open): Remove call to set_nohandle. (fhandler_virtual::fill_filebuf): Change return type to bool. Add return statement. * security.cc (get_nt_object_attribute): New function. (get_object_attribute): New function. * security.h (get_object_attribute): New function declaration.
2002-07-02 03:36:15 +02:00
bool fill_filebuf ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
fhandler_process (void *) {}
void copyto (fhandler_base *x)
{
x->pc.free_strings ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
*reinterpret_cast<fhandler_process *> (x) = *this;
x->reset (this);
}
fhandler_process *clone (cygheap_types malloc_type = HEAP_FHANDLER)
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
{
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_process));
* fhandler.h (fhandler_pipe::create_selectable): Remove optional argument, take an options argument for CreateNamedPipe/CreateFile. Change handle arguments to expect pointers. (fhandler_fifo::fifo_state): Delete. (fhandler_fifo::dummy_client): Ditto. (fhandler_fifo::open_nonserver): Ditto. (fhandler_fifo::wait_state): Ditto. (fhandler_fifo::raw_write): Ditto. (fhandler_fifo::read_ready): New field. (fhandler_fifo::write_ready): Ditto. (fhandler_fifo::wait): Modify argument. (fhandler_fifo::fifo_name): Add a new argument. (fhandler_fifo::fixup_after_fork): New function. * fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Remove initialization of expunged elements. Initialize new handles to NULL. (fhandler_fifo::open_nonserver): Delete. (fnevent): New macro for creating a named event. (fnpipe): New macro for creating a unique named pipe name. (create_pipe): New macro for simplification of named pipe creation. (fhandler_fifo::fifo_name): Use new argument when creating a shared name. (fhandler_fifo::open): Rewrite. Use events to synchronize. (pure_debug_printf): New macro, active only when DEBUGGING. (fhandler_fifo::wait): Rewrite to wait for new fifo events which are supplied as a parameter. (fhandler_fifo::raw_read): Rewrite to use handle mechanism to detect client-side disconnect. (fhandler_fifo::raw_write): Delete. (fhandler_fifo::close): Remove accommodations for expunged fields. Close event handles. (fhandler_fifo::dup): Remove accommodations for expunged fields. Duplicate event handles. (fhandler_fifo::fixup_after_fork): New function. Perform fixups on event handles. (fhandler_fifo::set_close_on_exec): Remove accommodations for expunged fields. Set inheritance for new handle fields. * miscfuncs.cc (CreatePipeOverlapped): Accommodate changes in fhandler_pipe::create_selectable. * tty.cc (tty::not_allocated): Ditto. * pipe.cc (fhandler_pipe::create): Ditto. (fhandler_pipe::create_selectable): Accept an extra open_mode argument. Pass arguments by reference and allow opening one end of the pipe at a time. * sys/strace.h (debug_only_printf): Define new macro which calls debug_printf only when DEBUGGING is defined.
2011-10-30 05:50:36 +01:00
fhandler_process *fh = new (ptr) fhandler_process (ptr);
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
copyto (fh);
return fh;
}
* path.h (pathconv_arg): Add PC_POSIX. (path_conv): Add normalized_path field. * path.cc (path_conv::~path_conv): New destructor. (path_conv::check): Set normalized_path, where appropriate. * dtable.cc (build_fhandler_from_name): Use normalized path from path_conv. * syscalls.cc (chroot): Ditto. * cygheap.h: Remove path_prefix_p declaration. Christopher Faylor <cgf@redhat.com> (minor fixups) * Makefile.in: Add fhandler_proc.o, fhandler_registry.o, fhandler_process.o and fhandler_virtual.o. * dtable.cc (dtable::build_fhandler): Add entries for FH_PROC, FH_REGISTRY and FH_PROCESS. Set unix_name to the normalized posix path. * fhandler.h: Add constants for FH_PROC, FH_REGISTRY and FH_PROCESS. Add class declarations for fhandler_virtual, fhandler_proc, fhandler_registry and fhandler_virtual. Update fhandler_union accordingly. * fhandler_proc.cc: New file. Add implementation for fhandler_proc. * fhandler_virtual.cc: New file. Add implementation for fhandler_virtual. * fhandler_process.cc: New file. Add implementation for fhandler_process. * fhandler_registry.cc: New file. Add implementation for fhandler_registry. * path.cc: Add isproc and isvirtual_dev macros. * path.cc (path_conv::check): Add check for virtual devices. * path.cc (mount_info::conv_to_win32_path): Convert paths in /proc to empty Win32 paths. * path.cc (chdir): Replace check for FH_CYGDRIVE with more generic isvirtual_dev macro. Force setting of posix path for virtual fhandlers. * path.h: Add externally visible path_prefix_p and normalized_posix_path prototypes.
2002-05-02 06:13:48 +02:00
};
class fhandler_procnet: public fhandler_proc
{
pid_t pid;
public:
fhandler_procnet ();
* Makefile.in (DLL_OFILES): Add fhandler_procsys.o. * devices.h (enum fh_devices): Add FH_PROCSYS. * devices.in (dev_procsys_storage): New device. * devices.cc: Regenerate. * dtable.cc (build_fh_pc): Add code to allocate fhandler_procsys. * fhandler.h (proc_len): Convert to size_t. (procsys): Declare. (procsys_len): Declare. (enum virtual_ftype_t): Move here from fhandler_virtual.h. Add members supported by fhandler_procsys. (fhandler_virtual::exists): Return virtual_ftype_t. Change in all derived classes. (class fhandler_procsys): New class. (fhandler_union): Add fhandler_procnet and fhandler_procsys members. * fhandler_disk_file.cc (__DIR_mounts::check_missing_mount): Use ro_u_proc. (fhandler_base::fstat_by_handle): Don't copy attributes if file is an NT device. (fhandler_base::fstat_by_name): Ditto. * fhandler_netdrive.cc (fhandler_netdrive::exists): Return virtual_ftype_t. * fhandler_proc.cc (proc_tab): Sort alphabetically. Use _VN macro to store length. (proc_len): Change to size_t. (proc_tab_cmp): New static function. (virt_tab_search): New function to search entry in virt_tab_t arrays. Use throughout in /proc and sibling classes instead of loop. (fhandler_proc::exists): Return virtual_ftype_t. * fhandler_process.cc (process_tab): Sort alphabetically. Use _VN macro to store length. (fhandler_process::exists): Return virtual_ftype_t. (fhandler_process::open): Simplify code. * fhandler_procnet.cc (procnet_tab): Sort alphabetically. Use _VN macro to store length. (fhandler_procnet::exists): Return virtual_ftype_t. (fhandler_procnet::open): Simplify. * fhandler_procsys.cc: New file. * fhandler_registry.cc (fhandler_registry::exists): Return virtual_ftype_t. * fhandler_virtual.cc (fhandler_virtual::exists): Ditto. * fhandler_virtual.h (enum virtual_ftype_t): Move to fhandler.h. (virt_tab_t): Add name_len member. (_VN): New macro. (virt_tab_search): Declare. * mount.cc (mount_info::conv_to_win32_path): Fix comment. Backslashify isprocsys_dev paths. * ntdll.h (STATUS_OBJECT_TYPE_MISMATCH): Define (STATUS_INSTANCE_NOT_AVAILABLE): Define. (STATUS_PIPE_NOT_AVAILABLE): Define. (STATUS_INVALID_PIPE_STATE): Define. (STATUS_PIPE_BUSY): Define. (SYMBOLIC_LINK_QUERY): Define. (NtOpenSymbolicLinkObject): Declare. (NtQuerySymbolicLinkObject): Declare. * path.cc (path_conv::check): Accommodate fact that exists method returns virtual_ftype_t now. Add cases for new virtual_ftype_t types. (cygwin_conv_path): Add GLOBALROOT prefix to native device paths. Make sure to strip \\?\ prefix only for actual filesystem-based paths, not for all paths. * path.h (isproc_dev): Add FH_PROCSYS. (isprocsys_dev): Define.
2010-09-06 11:47:01 +02:00
virtual_ftype_t exists();
int readdir (DIR *, dirent *) __attribute__ ((regparm (3)));
int open (int flags, mode_t mode = 0);
int __stdcall fstat (struct __stat64 *buf) __attribute__ ((regparm (2)));
bool fill_filebuf ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
fhandler_procnet (void *) {}
void copyto (fhandler_base *x)
{
x->pc.free_strings ();
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
*reinterpret_cast<fhandler_procnet *> (x) = *this;
x->reset (this);
}
fhandler_procnet *clone (cygheap_types malloc_type = HEAP_FHANDLER)
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
{
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_procnet));
* fhandler.h (fhandler_pipe::create_selectable): Remove optional argument, take an options argument for CreateNamedPipe/CreateFile. Change handle arguments to expect pointers. (fhandler_fifo::fifo_state): Delete. (fhandler_fifo::dummy_client): Ditto. (fhandler_fifo::open_nonserver): Ditto. (fhandler_fifo::wait_state): Ditto. (fhandler_fifo::raw_write): Ditto. (fhandler_fifo::read_ready): New field. (fhandler_fifo::write_ready): Ditto. (fhandler_fifo::wait): Modify argument. (fhandler_fifo::fifo_name): Add a new argument. (fhandler_fifo::fixup_after_fork): New function. * fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Remove initialization of expunged elements. Initialize new handles to NULL. (fhandler_fifo::open_nonserver): Delete. (fnevent): New macro for creating a named event. (fnpipe): New macro for creating a unique named pipe name. (create_pipe): New macro for simplification of named pipe creation. (fhandler_fifo::fifo_name): Use new argument when creating a shared name. (fhandler_fifo::open): Rewrite. Use events to synchronize. (pure_debug_printf): New macro, active only when DEBUGGING. (fhandler_fifo::wait): Rewrite to wait for new fifo events which are supplied as a parameter. (fhandler_fifo::raw_read): Rewrite to use handle mechanism to detect client-side disconnect. (fhandler_fifo::raw_write): Delete. (fhandler_fifo::close): Remove accommodations for expunged fields. Close event handles. (fhandler_fifo::dup): Remove accommodations for expunged fields. Duplicate event handles. (fhandler_fifo::fixup_after_fork): New function. Perform fixups on event handles. (fhandler_fifo::set_close_on_exec): Remove accommodations for expunged fields. Set inheritance for new handle fields. * miscfuncs.cc (CreatePipeOverlapped): Accommodate changes in fhandler_pipe::create_selectable. * tty.cc (tty::not_allocated): Ditto. * pipe.cc (fhandler_pipe::create): Ditto. (fhandler_pipe::create_selectable): Accept an extra open_mode argument. Pass arguments by reference and allow opening one end of the pipe at a time. * sys/strace.h (debug_only_printf): Define new macro which calls debug_printf only when DEBUGGING is defined.
2011-10-30 05:50:36 +01:00
fhandler_procnet *fh = new (ptr) fhandler_procnet (ptr);
* cygerrno.h (__set_errno): Modify debugging output to make searching strace logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-10-16 00:37:30 +02:00
copyto (fh);
return fh;
}
};
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
struct fhandler_nodevice: public fhandler_base
{
fhandler_nodevice ();
int open (int flags, mode_t mode = 0);
};
* cygheap.h (init_cygheap::manage_console_count): Declare new function. (init_cygheap::console_count): Renamed from open_fhs. Make private. * cygheap.cc (init_cygheap::manage_console_count): Define new function. * dtable.cc (dtable::fixup_after_exec): Always call fixup_after_exec on elements of fd even when they are about to be closed. * fhandler.h (report_tty_counts): Remove open_fhs from debugging output. * fhandler_console.cc (fhandler_console::open): Use manage_console_count rather than manipulating count directly. (fhandler_console::close): Ditto. (fhandler_console::fixup_after_fork): Ditto. (fhandler_console::fixup_after_exec): Ditto. Don't close handles if close_on_exec. * fhandler_tty.cc (fhandler_tty_slave::open): Use manage_console_count() rather than manipulating count directly. Reflect change in arguments to report_tty_counts(). (fhandler_tty_slave::close): Ditto for both. (fhandler_tty_slave::dup): Ditto for both. (fhandler_tty_slave::ioctl): Use myctty() rather than raw ctty #. (fhandler_tty_slave::fixup_after_fork): Reflect change in arguments to report_tty_counts(). (fhandler_tty_master::init_console): Use manage_console_count() rather than manipulating count directly. * fhandler_clipboard.cc (fhandler_dev_clipboard::fixup_after_exec): Don't perform any operations if close_on_exec. * fhandler_dsp.cc (fhandler_dev_dsp::fixup_after_exec): Ditto. * fhandler_raw.cc (fhandler_dev_raw::fixup_after_exec): Ditto. * fhandler_serial.cc (fhandler_serial::fixup_after_exec): Ditto. * pinfo.h (_pinfo::_ctty): Declare new function. (myctty): Declare new macro. (__ctty): Declare new macro. * pinfo.cc (_pinfo::_ctty): Define new function. (_pinfo::set_ctty): Use manage_console_count() rather than manipulating count directly. * signal.cc (kill_pgrp): Use myctty() and __ctty() macros rather than raw ctty #. * syscalls.cc (setsid): Ditto. Use manage_console_count() rather than manipulating count directly.
2005-11-14 05:28:45 +01:00
#define report_tty_counts(fh, call, use_op) \
termios_printf ("%s %s, %susecount %d",\
fh->ttyname (), call,\
* 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-14 23:48:43 +02:00
use_op, ((fhandler_pty_slave *) (fh->archetype ?: fh))->usecount);
2000-02-17 20:38:33 +01:00
typedef union
{
char __base[sizeof (fhandler_base)];
char __console[sizeof (fhandler_console)];
char __dev[sizeof (fhandler_dev)];
char __cygdrive[sizeof (fhandler_cygdrive)];
char __dev_clipboard[sizeof (fhandler_dev_clipboard)];
char __dev_dsp[sizeof (fhandler_dev_dsp)];
char __dev_floppy[sizeof (fhandler_dev_floppy)];
char __dev_mem[sizeof (fhandler_dev_mem)];
char __dev_null[sizeof (fhandler_dev_null)];
char __dev_random[sizeof (fhandler_dev_random)];
char __dev_raw[sizeof (fhandler_dev_raw)];
char __dev_tape[sizeof (fhandler_dev_tape)];
char __dev_zero[sizeof (fhandler_dev_zero)];
char __disk_file[sizeof (fhandler_disk_file)];
char __fifo[sizeof (fhandler_fifo)];
char __mailslot[sizeof (fhandler_mailslot)];
char __netdrive[sizeof (fhandler_netdrive)];
char __nodevice[sizeof (fhandler_nodevice)];
char __pipe[sizeof (fhandler_pipe)];
char __proc[sizeof (fhandler_proc)];
char __process[sizeof (fhandler_process)];
* Makefile.in (DLL_OFILES): Add fhandler_procsys.o. * devices.h (enum fh_devices): Add FH_PROCSYS. * devices.in (dev_procsys_storage): New device. * devices.cc: Regenerate. * dtable.cc (build_fh_pc): Add code to allocate fhandler_procsys. * fhandler.h (proc_len): Convert to size_t. (procsys): Declare. (procsys_len): Declare. (enum virtual_ftype_t): Move here from fhandler_virtual.h. Add members supported by fhandler_procsys. (fhandler_virtual::exists): Return virtual_ftype_t. Change in all derived classes. (class fhandler_procsys): New class. (fhandler_union): Add fhandler_procnet and fhandler_procsys members. * fhandler_disk_file.cc (__DIR_mounts::check_missing_mount): Use ro_u_proc. (fhandler_base::fstat_by_handle): Don't copy attributes if file is an NT device. (fhandler_base::fstat_by_name): Ditto. * fhandler_netdrive.cc (fhandler_netdrive::exists): Return virtual_ftype_t. * fhandler_proc.cc (proc_tab): Sort alphabetically. Use _VN macro to store length. (proc_len): Change to size_t. (proc_tab_cmp): New static function. (virt_tab_search): New function to search entry in virt_tab_t arrays. Use throughout in /proc and sibling classes instead of loop. (fhandler_proc::exists): Return virtual_ftype_t. * fhandler_process.cc (process_tab): Sort alphabetically. Use _VN macro to store length. (fhandler_process::exists): Return virtual_ftype_t. (fhandler_process::open): Simplify code. * fhandler_procnet.cc (procnet_tab): Sort alphabetically. Use _VN macro to store length. (fhandler_procnet::exists): Return virtual_ftype_t. (fhandler_procnet::open): Simplify. * fhandler_procsys.cc: New file. * fhandler_registry.cc (fhandler_registry::exists): Return virtual_ftype_t. * fhandler_virtual.cc (fhandler_virtual::exists): Ditto. * fhandler_virtual.h (enum virtual_ftype_t): Move to fhandler.h. (virt_tab_t): Add name_len member. (_VN): New macro. (virt_tab_search): Declare. * mount.cc (mount_info::conv_to_win32_path): Fix comment. Backslashify isprocsys_dev paths. * ntdll.h (STATUS_OBJECT_TYPE_MISMATCH): Define (STATUS_INSTANCE_NOT_AVAILABLE): Define. (STATUS_PIPE_NOT_AVAILABLE): Define. (STATUS_INVALID_PIPE_STATE): Define. (STATUS_PIPE_BUSY): Define. (SYMBOLIC_LINK_QUERY): Define. (NtOpenSymbolicLinkObject): Declare. (NtQuerySymbolicLinkObject): Declare. * path.cc (path_conv::check): Accommodate fact that exists method returns virtual_ftype_t now. Add cases for new virtual_ftype_t types. (cygwin_conv_path): Add GLOBALROOT prefix to native device paths. Make sure to strip \\?\ prefix only for actual filesystem-based paths, not for all paths. * path.h (isproc_dev): Add FH_PROCSYS. (isprocsys_dev): Define.
2010-09-06 11:47:01 +02:00
char __procnet[sizeof (fhandler_procnet)];
char __procsys[sizeof (fhandler_procsys)];
char __procsysvipc[sizeof (fhandler_procsysvipc)];
char __pty_master[sizeof (fhandler_pty_master)];
char __registry[sizeof (fhandler_registry)];
char __serial[sizeof (fhandler_serial)];
char __socket[sizeof (fhandler_socket)];
char __termios[sizeof (fhandler_termios)];
* 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-14 23:48:43 +02:00
char __pty_common[sizeof (fhandler_pty_common)];
char __pty_slave[sizeof (fhandler_pty_slave)];
char __virtual[sizeof (fhandler_virtual)];
char __windows[sizeof (fhandler_windows)];
2000-02-17 20:38:33 +01:00
} fhandler_union;