2000-02-18 03:38:33 +08:00
|
|
|
/* fhandler.h
|
|
|
|
|
|
|
|
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. */
|
|
|
|
|
2012-01-12 03:07:11 +08:00
|
|
|
#pragma once
|
|
|
|
#include "pinfo.h"
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2011-06-04 08:12:29 +08:00
|
|
|
#include "tty.h"
|
2021-05-21 18:01:56 +08:00
|
|
|
#include "mqueue_types.h"
|
2018-02-22 05:00:04 +08:00
|
|
|
#include <cygwin/_socketflags.h>
|
2018-03-01 02:01:29 +08:00
|
|
|
#include <cygwin/_ucred.h>
|
2018-03-01 02:06:41 +08:00
|
|
|
#include <sys/un.h>
|
2018-02-22 05:00:04 +08:00
|
|
|
|
2007-01-04 17:17:55 +08:00
|
|
|
/* 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)
|
2011-03-18 22:25:33 +08:00
|
|
|
|
|
|
|
/* 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
|
2007-01-04 17:17:55 +08:00
|
|
|
|
2012-04-30 23:38:45 +08:00
|
|
|
/* Used for fhandler_pipe::create. Use an available flag which will
|
|
|
|
never be used in Cygwin for this function. */
|
2012-05-13 03:17:17 +08:00
|
|
|
#define PIPE_ADD_PID FILE_FLAG_FIRST_PIPE_INSTANCE
|
2012-04-30 23:38:45 +08:00
|
|
|
|
2018-02-14 19:55:24 +08:00
|
|
|
#define O_TMPFILE_FILE_ATTRS (FILE_ATTRIBUTE_TEMPORARY | FILE_ATTRIBUTE_HIDDEN)
|
|
|
|
|
2019-09-19 04:49:55 +08:00
|
|
|
/* Buffer size for ReadConsoleInput() and PeekConsoleInput(). */
|
|
|
|
/* Per MSDN, max size of buffer required is below 64K. */
|
|
|
|
/* (65536 / sizeof (INPUT_RECORD)) is 3276, however,
|
|
|
|
ERROR_NOT_ENOUGH_MEMORY occurs in win7 if this value is used. */
|
|
|
|
#define INREC_SIZE 2048
|
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
extern const char *windows_device_names[];
|
2000-07-09 13:29:51 +08:00
|
|
|
extern struct __cygwin_perfile *perfile_table;
|
2000-02-18 03:38:33 +08:00
|
|
|
#define __fmode (*(user_data->fmode_ptr))
|
2002-05-02 12:13:48 +08:00
|
|
|
extern const char proc[];
|
2010-09-06 17:47:01 +08:00
|
|
|
extern const size_t proc_len;
|
|
|
|
extern const char procsys[];
|
|
|
|
extern const size_t procsys_len;
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
class select_record;
|
2009-07-01 05:18:44 +08:00
|
|
|
class select_stuff;
|
2000-02-18 03:38:33 +08:00
|
|
|
class fhandler_disk_file;
|
2008-03-24 22:48:58 +08:00
|
|
|
class inode_t;
|
2001-11-21 14:47:57 +08:00
|
|
|
typedef struct __DIR DIR;
|
|
|
|
struct dirent;
|
2002-08-30 23:47:10 +08:00
|
|
|
struct iovec;
|
2013-04-23 17:44:36 +08:00
|
|
|
struct acl;
|
2016-01-07 01:41:36 +08:00
|
|
|
struct __acl_t;
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2005-03-17 05:20:56 +08:00
|
|
|
enum dirent_states
|
|
|
|
{
|
2005-08-20 00:18:42 +08:00
|
|
|
dirent_ok = 0x0000,
|
|
|
|
dirent_saw_dot = 0x0001,
|
|
|
|
dirent_saw_dot_dot = 0x0002,
|
|
|
|
dirent_saw_eof = 0x0004,
|
|
|
|
dirent_isroot = 0x0008,
|
2006-03-02 06:37:25 +08:00
|
|
|
dirent_set_d_ino = 0x0010,
|
2007-06-29 23:13:01 +08:00
|
|
|
dirent_get_d_ino = 0x0020,
|
2008-05-21 17:02:42 +08:00
|
|
|
dirent_nfs_d_ino = 0x0040,
|
2007-06-29 23:13:01 +08:00
|
|
|
|
|
|
|
/* Global flags which must not be deleted on rewinddir or seekdir. */
|
2008-05-21 17:02:42 +08:00
|
|
|
dirent_info_mask = 0x0078
|
2005-03-17 05:20:56 +08:00
|
|
|
};
|
|
|
|
|
2018-03-06 00:59:04 +08:00
|
|
|
enum bind_state
|
|
|
|
{
|
|
|
|
unbound = 0,
|
|
|
|
bind_pending = 1,
|
|
|
|
bound = 2
|
|
|
|
};
|
|
|
|
|
2004-04-10 21:45:10 +08:00
|
|
|
enum conn_state
|
2004-04-09 16:43:29 +08:00
|
|
|
{
|
|
|
|
unconnected = 0,
|
2014-10-27 02:47:24 +08:00
|
|
|
connect_pending = 1,
|
|
|
|
connected = 2,
|
|
|
|
listener = 3,
|
2018-03-06 00:59:04 +08:00
|
|
|
connect_failed = 4 /* FIXME: Do we really need this? It's basically
|
|
|
|
the same thing as unconnected. */
|
2004-04-09 16:43:29 +08:00
|
|
|
};
|
|
|
|
|
2002-12-06 00:24:52 +08:00
|
|
|
enum line_edit_status
|
|
|
|
{
|
|
|
|
line_edit_ok = 0,
|
|
|
|
line_edit_input_done = 1,
|
2002-12-21 12:38:12 +08:00
|
|
|
line_edit_signalled = 2,
|
|
|
|
line_edit_error = 3,
|
|
|
|
line_edit_pipe_full = 4
|
2002-12-06 00:24:52 +08:00
|
|
|
};
|
|
|
|
|
2001-01-17 22:57:09 +08:00
|
|
|
enum bg_check_types
|
|
|
|
{
|
|
|
|
bg_error = -1,
|
|
|
|
bg_eof = 0,
|
|
|
|
bg_ok = 1,
|
|
|
|
bg_signalled = 2
|
|
|
|
};
|
|
|
|
|
2004-04-08 15:57:28 +08:00
|
|
|
enum query_state {
|
|
|
|
no_query = 0,
|
2004-04-17 05:22:13 +08:00
|
|
|
query_read_control = 1,
|
2007-02-27 20:58:56 +08:00
|
|
|
query_read_attributes = 2,
|
2007-07-27 16:38:00 +08:00
|
|
|
query_write_control = 3,
|
2010-09-25 00:22:53 +08:00
|
|
|
query_write_dac = 4,
|
|
|
|
query_write_attributes = 5
|
2004-04-08 15:57:28 +08:00
|
|
|
};
|
|
|
|
|
2009-07-22 23:46:36 +08:00
|
|
|
enum del_lock_called_from {
|
|
|
|
on_close,
|
|
|
|
after_fork,
|
|
|
|
after_exec
|
|
|
|
};
|
|
|
|
|
2010-09-06 17:47:01 +08:00
|
|
|
enum virtual_ftype_t {
|
2019-07-23 00:40:33 +08:00
|
|
|
virt_none = 0x0000, /* Invalid, Error */
|
|
|
|
virt_file = 0x0001, /* Regular file */
|
|
|
|
virt_symlink = 0x0002, /* Symlink */
|
|
|
|
virt_pipe = 0x0003, /* Pipe */
|
|
|
|
virt_socket = 0x0004, /* Socket */
|
|
|
|
virt_chr = 0x0005, /* Character special */
|
|
|
|
virt_blk = 0x0006, /* Block special */
|
|
|
|
virt_fdsymlink = 0x0007, /* Fd symlink (e.g. /proc/<PID>/fd/0) */
|
|
|
|
virt_fsfile = 0x0008, /* FS-based file via /proc/sys */
|
|
|
|
virt_dir_type = 0x1000,
|
|
|
|
virt_directory = 0x1001, /* Directory */
|
|
|
|
virt_rootdir = 0x1002, /* Root directory of virtual FS */
|
|
|
|
virt_fsdir = 0x1003, /* FS-based directory via /proc/sys */
|
2010-09-06 17:47:01 +08:00
|
|
|
};
|
|
|
|
|
2019-07-23 00:40:33 +08:00
|
|
|
static inline bool
|
|
|
|
virt_ftype_isfile (virtual_ftype_t _f)
|
|
|
|
{
|
|
|
|
return _f != virt_none && !(_f & virt_dir_type);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool
|
|
|
|
virt_ftype_isdir (virtual_ftype_t _f)
|
|
|
|
{
|
|
|
|
return _f & virt_dir_type;
|
|
|
|
}
|
|
|
|
|
2000-02-18 03:38:33 +08: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 08:37:18 +08:00
|
|
|
friend class dtable;
|
2005-07-05 10:05:07 +08:00
|
|
|
friend void close_all_files (bool);
|
2004-04-09 16:43:29 +08:00
|
|
|
|
|
|
|
struct status_flags
|
|
|
|
{
|
2011-10-30 12:50:36 +08:00
|
|
|
unsigned rbinary : 1; /* binary read mode */
|
2020-03-11 20:23:55 +08:00
|
|
|
unsigned rbinset : 1; /* binary read mode explicitly set */
|
2011-10-30 12:50:36 +08:00
|
|
|
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
|
2004-04-09 16:43:29 +08:00
|
|
|
_write should check if we've moved
|
|
|
|
beyond EOF, zero filling or making
|
|
|
|
file sparse if so. */
|
2011-10-30 12:50:36 +08:00
|
|
|
unsigned query_open : 3; /* open file without requesting either
|
2005-02-14 02:17:29 +08:00
|
|
|
read or write access */
|
2004-04-09 16:43:29 +08:00
|
|
|
unsigned close_on_exec : 1; /* close-on-exec */
|
|
|
|
unsigned need_fork_fixup : 1; /* Set if need to fixup after fork. */
|
2011-12-17 08:03:31 +08:00
|
|
|
unsigned isclosed : 1; /* Set when fhandler is closed. */
|
2013-06-04 18:24:43 +08:00
|
|
|
unsigned mandatory_locking : 1; /* Windows mandatory locking */
|
2004-04-09 16:43:29 +08:00
|
|
|
|
2004-04-09 20:09:45 +08:00
|
|
|
public:
|
2004-04-09 16:43:29 +08:00
|
|
|
status_flags () :
|
2004-04-10 21:45:10 +08:00
|
|
|
rbinary (0), rbinset (0), wbinary (0), wbinset (0), nohandle (0),
|
2011-05-04 21:06:10 +08:00
|
|
|
did_lseek (0), query_open (no_query), close_on_exec (0),
|
2021-08-27 06:00:27 +08:00
|
|
|
need_fork_fixup (0), isclosed (0), mandatory_locking (0)
|
2004-04-09 16:43:29 +08:00
|
|
|
{}
|
|
|
|
} status, open_status;
|
|
|
|
|
2001-11-02 05:15:53 +08:00
|
|
|
private:
|
2011-06-17 19:04:44 +08:00
|
|
|
ACCESS_MASK access;
|
|
|
|
ULONG options;
|
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
HANDLE io_handle;
|
|
|
|
|
2013-04-23 17:44:36 +08:00
|
|
|
ino_t ino; /* file ID or hashed filename, depends on FS. */
|
|
|
|
LONG _refcnt;
|
2020-01-27 20:14:32 +08:00
|
|
|
public:
|
|
|
|
struct rabuf_t
|
|
|
|
{
|
|
|
|
char *rabuf; /* used for crlf conversion in text files */
|
|
|
|
size_t ralen;
|
|
|
|
size_t raixget;
|
|
|
|
size_t raixput;
|
|
|
|
size_t rabuflen;
|
|
|
|
};
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2001-11-02 05:15:53 +08:00
|
|
|
protected:
|
2000-02-18 03:38:33 +08:00
|
|
|
/* File open flags from open () and fcntl () calls */
|
2001-04-24 10:07:58 +08:00
|
|
|
int openflags;
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2020-01-27 20:14:32 +08:00
|
|
|
struct rabuf_t ra;
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2008-04-01 02:03:25 +08:00
|
|
|
/* Used for advisory file locking. See flock.cc. */
|
2016-01-11 19:35:41 +08:00
|
|
|
int64_t unique_id;
|
2009-07-22 23:46:36 +08:00
|
|
|
void del_my_locks (del_lock_called_from);
|
2016-01-11 19:35:41 +08:00
|
|
|
void set_ino (ino_t i) { ino = i; }
|
2008-03-24 22:48:58 +08:00
|
|
|
|
2002-12-14 12:01:32 +08:00
|
|
|
HANDLE read_state;
|
2021-09-08 16:18:35 +08:00
|
|
|
HANDLE select_sem;
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2001-11-02 05:15:53 +08:00
|
|
|
public:
|
2013-04-23 17:44:36 +08:00
|
|
|
LONG inc_refcnt () {return InterlockedIncrement (&_refcnt);}
|
|
|
|
LONG dec_refcnt () {return InterlockedDecrement (&_refcnt);}
|
2003-12-28 01:41:17 +08:00
|
|
|
class fhandler_base *archetype;
|
2003-12-11 14:12:41 +08:00
|
|
|
int usecount;
|
|
|
|
|
2007-08-14 22:48:52 +08:00
|
|
|
path_conv pc;
|
|
|
|
|
2011-05-06 06:30:53 +08:00
|
|
|
virtual bool use_archetype () const {return false;}
|
2006-10-19 18:01:03 +08:00
|
|
|
virtual void set_name (path_conv &pc);
|
2011-05-06 06:30:53 +08:00
|
|
|
virtual void set_name (const char *s)
|
|
|
|
{
|
2015-02-15 16:59:55 +08:00
|
|
|
pc.set_posix (s);
|
2011-05-06 06:30:53 +08:00
|
|
|
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 08:37:18 +08:00
|
|
|
int error () const {return pc.error;}
|
2003-11-25 10:03:17 +08:00
|
|
|
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 08:37:18 +08:00
|
|
|
bool exists () const {return pc.exists ();}
|
|
|
|
int pc_binmode () const {return pc.binmode ();}
|
|
|
|
device& dev () {return pc.dev;}
|
2005-03-20 05:45:15 +08:00
|
|
|
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 08:37:18 +08:00
|
|
|
fhandler_base ();
|
2000-02-18 03:38:33 +08:00
|
|
|
virtual ~fhandler_base ();
|
|
|
|
|
|
|
|
/* Non-virtual simple accessor functions. */
|
2019-03-30 15:12:02 +08:00
|
|
|
void set_handle (HANDLE x) { io_handle = x; }
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2013-04-23 17:44:36 +08:00
|
|
|
dev_t& get_device () { return dev (); }
|
|
|
|
_major_t get_major () { return dev ().get_major (); }
|
|
|
|
_minor_t get_minor () { return dev ().get_minor (); }
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2011-06-17 19:04:44 +08: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-18 03:38:33 +08:00
|
|
|
|
2001-04-24 10:07:58 +08:00
|
|
|
int get_flags () { return openflags; }
|
2002-06-05 09:42:28 +08:00
|
|
|
void set_flags (int x, int supplied_bin = 0);
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2001-11-24 11:11:39 +08:00
|
|
|
bool is_nonblocking ();
|
2006-12-12 02:55:29 +08:00
|
|
|
void set_nonblocking (int);
|
2001-08-15 15:49:15 +08:00
|
|
|
|
2004-04-10 21:45:10 +08:00
|
|
|
bool wbinary () const { return status.wbinset ? status.wbinary : 1; }
|
|
|
|
bool rbinary () const { return status.rbinset ? status.rbinary : 1; }
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2004-04-10 21:45:10 +08:00
|
|
|
void wbinary (bool b) {status.wbinary = b; status.wbinset = 1;}
|
|
|
|
void rbinary (bool b) {status.rbinary = b; status.rbinset = 1;}
|
2001-11-24 11:11:39 +08:00
|
|
|
|
2001-04-24 10:07:58 +08:00
|
|
|
void set_open_status () {open_status = status;}
|
|
|
|
void reset_to_open_binmode ()
|
|
|
|
{
|
2002-06-05 09:42:28 +08:00
|
|
|
set_flags ((get_flags () & ~(O_TEXT | O_BINARY))
|
2021-02-20 01:12:37 +08:00
|
|
|
| (((open_status.wbinset ? open_status.wbinary : 1)
|
|
|
|
|| (open_status.rbinset ? open_status.rbinary : 1))
|
2004-04-09 16:43:29 +08:00
|
|
|
? O_BINARY : O_TEXT));
|
2001-04-24 10:07:58 +08:00
|
|
|
}
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2004-04-13 17:04:22 +08:00
|
|
|
IMPLEMENT_STATUS_FLAG (bool, wbinset)
|
|
|
|
IMPLEMENT_STATUS_FLAG (bool, rbinset)
|
2012-04-18 13:57:38 +08:00
|
|
|
IMPLEMENT_STATUS_FLAG (bool, nohandle)
|
2004-04-13 17:04:22 +08:00
|
|
|
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)
|
2011-12-17 08:03:31 +08:00
|
|
|
IMPLEMENT_STATUS_FLAG (bool, isclosed)
|
2013-06-04 18:24:43 +08:00
|
|
|
IMPLEMENT_STATUS_FLAG (bool, mandatory_locking)
|
2004-04-10 21:45:10 +08:00
|
|
|
|
|
|
|
int get_default_fmode (int flags);
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2004-04-10 21:45:10 +08:00
|
|
|
virtual void set_close_on_exec (bool val);
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2001-07-27 03:22:24 +08:00
|
|
|
LPSECURITY_ATTRIBUTES get_inheritance (bool all = 0)
|
|
|
|
{
|
|
|
|
if (all)
|
2004-04-10 21:45:10 +08:00
|
|
|
return close_on_exec () ? &sec_all_nih : &sec_all;
|
2001-07-27 03:22:24 +08:00
|
|
|
else
|
2004-04-10 21:45:10 +08:00
|
|
|
return close_on_exec () ? &sec_none_nih : &sec_none;
|
2001-07-27 03:22:24 +08:00
|
|
|
}
|
|
|
|
|
2009-11-17 18:43:01 +08:00
|
|
|
virtual int fixup_before_fork_exec (DWORD) { return 0; }
|
2000-10-26 18:13:41 +08:00
|
|
|
virtual void fixup_after_fork (HANDLE);
|
2006-06-02 23:41:34 +08:00
|
|
|
virtual void fixup_after_exec ();
|
2005-02-06 13:04:34 +08:00
|
|
|
void create_read_state (LONG n)
|
|
|
|
{
|
|
|
|
read_state = CreateSemaphore (&sec_none_nih, 0, n, NULL);
|
2006-05-21 13:25:49 +08:00
|
|
|
ProtectHandle (read_state);
|
2005-02-06 13:04:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void signal_read_state (LONG n)
|
|
|
|
{
|
2005-07-07 04:05:03 +08:00
|
|
|
ReleaseSemaphore (read_state, n, NULL);
|
2005-02-06 13:04:34 +08:00
|
|
|
}
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2020-01-27 20:14:32 +08:00
|
|
|
virtual char *&rabuf () { return ra.rabuf; };
|
|
|
|
virtual size_t &ralen () { return ra.ralen; };
|
|
|
|
virtual size_t &raixget () { return ra.raixget; };
|
|
|
|
virtual size_t &raixput () { return ra.raixput; };
|
|
|
|
virtual size_t &rabuflen () { return ra.rabuflen; };
|
|
|
|
|
2020-08-19 19:25:21 +08:00
|
|
|
bool get_readahead_valid () { return raixget () < ralen (); }
|
2000-02-18 03:38:33 +08:00
|
|
|
int puts_readahead (const char *s, size_t len = (size_t) -1);
|
2020-08-19 19:25:21 +08:00
|
|
|
int put_readahead (char value);
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
int get_readahead ();
|
|
|
|
int peek_readahead (int queryput = 0);
|
|
|
|
|
|
|
|
void set_readahead_valid (int val, int ch = -1);
|
|
|
|
|
2020-08-19 19:25:21 +08:00
|
|
|
int get_readahead_into_buffer (char *buf, size_t buflen);
|
2000-03-12 14:29:54 +08:00
|
|
|
|
2004-01-24 11:40:33 +08:00
|
|
|
bool has_acls () const { return pc.has_acls (); }
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2004-01-24 11:40:33 +08:00
|
|
|
bool isremote () { return pc.isremote (); }
|
2001-05-31 13:25:46 +08:00
|
|
|
|
2004-01-24 11:40:33 +08:00
|
|
|
bool has_attribute (DWORD x) const {return pc.has_attribute (x);}
|
2015-02-15 16:59:55 +08:00
|
|
|
const char *get_name () const { return pc.get_posix (); }
|
* 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 08:37:18 +08:00
|
|
|
const char *get_win32_name () { return pc.get_win32 (); }
|
2013-10-24 17:41:17 +08:00
|
|
|
virtual dev_t get_dev () { return get_device (); }
|
2016-01-12 02:10:45 +08:00
|
|
|
/* Use get_plain_ino if the caller needs to avoid hashing if ino is 0. */
|
|
|
|
ino_t get_plain_ino () { return ino; }
|
2013-04-23 17:44:36 +08:00
|
|
|
ino_t get_ino () { return ino ?: ino = hash_path_name (0, pc.get_nt_native_path ()); }
|
2016-01-11 19:35:41 +08:00
|
|
|
int64_t get_unique_id () const { return unique_id; }
|
2005-01-31 18:28:55 +08:00
|
|
|
/* Returns name used for /proc/<pid>/fd in buf. */
|
|
|
|
virtual char *get_proc_fd_name (char *buf);
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2006-12-12 02:55:29 +08:00
|
|
|
virtual void set_no_inheritance (HANDLE &, bool);
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
/* fixup fd possibly non-inherited handles after fork */
|
2006-12-12 02:55:29 +08:00
|
|
|
bool fork_fixup (HANDLE, HANDLE &, const char *);
|
2009-11-17 18:43:01 +08:00
|
|
|
virtual bool need_fixup_before () const {return false;}
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2011-05-06 06:30:53 +08:00
|
|
|
int open_with_arch (int, mode_t = 0);
|
2013-10-31 22:26:42 +08:00
|
|
|
int open_null (int flags);
|
2011-05-06 06:30:53 +08:00
|
|
|
virtual int open (int, mode_t);
|
2019-02-05 22:20:13 +08:00
|
|
|
virtual fhandler_base *fd_reopen (int, mode_t);
|
2021-09-18 20:13:55 +08:00
|
|
|
virtual bool open_setup (int flags);
|
2022-02-15 22:23:50 +08:00
|
|
|
virtual void post_open_setup (int fd) {}
|
2016-01-11 19:35:41 +08:00
|
|
|
void set_unique_id (int64_t u) { unique_id = u; }
|
2013-10-24 17:41:17 +08:00
|
|
|
void set_unique_id () { NtAllocateLocallyUniqueId ((PLUID) &unique_id); }
|
2011-05-06 06:30:53 +08:00
|
|
|
|
2011-05-07 04:22:45 +08:00
|
|
|
int close_with_arch ();
|
2000-02-18 03:38:33 +08:00
|
|
|
virtual int close ();
|
2013-10-23 04:41:09 +08:00
|
|
|
virtual void cleanup ();
|
2011-05-06 06:30:53 +08:00
|
|
|
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;
|
|
|
|
}
|
2011-05-07 04:22:45 +08:00
|
|
|
|
|
|
|
int open_fs (int, mode_t = 0);
|
2011-05-06 06:30:53 +08:00
|
|
|
# define archetype_usecount(n) _archetype_usecount (__PRETTY_FUNCTION__, __LINE__, (n))
|
2007-08-14 03:15:47 +08:00
|
|
|
int close_fs () { return fhandler_base::close (); }
|
2022-05-24 03:52:52 +08:00
|
|
|
virtual int fstat (struct stat *buf);
|
|
|
|
void stat_fixup (struct stat *buf);
|
|
|
|
int fstat_fs (struct stat *buf);
|
2010-09-13 19:17:36 +08:00
|
|
|
private:
|
2022-05-24 03:52:52 +08:00
|
|
|
int fstat_helper (struct stat *buf);
|
|
|
|
int fstat_by_nfs_ea (struct stat *buf);
|
|
|
|
int fstat_by_handle (struct stat *buf);
|
|
|
|
int fstat_by_name (struct stat *buf);
|
2010-09-13 19:17:36 +08:00
|
|
|
public:
|
2022-05-24 03:52:52 +08:00
|
|
|
virtual int fstatvfs (struct statvfs *buf);
|
|
|
|
int fstatvfs_by_handle (HANDLE h, struct statvfs *buf);
|
|
|
|
int utimens_fs (const struct timespec *);
|
|
|
|
virtual int fchmod (mode_t mode);
|
|
|
|
virtual int fchown (uid_t uid, gid_t gid);
|
|
|
|
virtual int facl (int, int, struct acl *);
|
|
|
|
virtual struct __acl_t *acl_get (uint32_t);
|
|
|
|
virtual int acl_set (struct __acl_t *, uint32_t);
|
|
|
|
virtual ssize_t fgetxattr (const char *, void *, size_t);
|
|
|
|
virtual int fsetxattr (const char *, const void *, size_t, int);
|
|
|
|
virtual int fadvise (off_t, off_t, int);
|
|
|
|
virtual int ftruncate (off_t, bool);
|
|
|
|
virtual int link (const char *);
|
|
|
|
virtual int utimens (const struct timespec *);
|
|
|
|
virtual int fsync ();
|
2000-02-18 03:38:33 +08:00
|
|
|
virtual int ioctl (unsigned int cmd, void *);
|
2013-04-23 17:44:36 +08:00
|
|
|
virtual int fcntl (int cmd, intptr_t);
|
2003-09-27 13:35:02 +08:00
|
|
|
virtual char const *ttyname () { return get_name (); }
|
2022-05-24 03:52:52 +08:00
|
|
|
virtual void read (void *ptr, size_t& len);
|
2022-06-07 00:00:45 +08:00
|
|
|
virtual ssize_t write (const void *ptr, size_t len);
|
|
|
|
virtual ssize_t readv (const struct iovec *, int iovcnt, ssize_t tot = -1);
|
|
|
|
virtual ssize_t writev (const struct iovec *, int iovcnt, ssize_t tot = -1);
|
2022-05-24 03:52:52 +08:00
|
|
|
virtual ssize_t pread (void *, size_t, off_t, void *aio = NULL);
|
|
|
|
virtual ssize_t pwrite (void *, size_t, off_t, void *aio = NULL);
|
2013-04-23 17:44:36 +08:00
|
|
|
virtual off_t lseek (off_t offset, int whence);
|
|
|
|
virtual int lock (int, struct flock *);
|
2013-06-04 18:24:43 +08:00
|
|
|
virtual int mand_lock (int, struct flock *);
|
2011-10-16 06:37:30 +08:00
|
|
|
virtual int dup (fhandler_base *child, int flags);
|
2006-11-08 01:59:54 +08:00
|
|
|
virtual int fpathconf (int);
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2021-08-27 06:05:53 +08:00
|
|
|
/* Get a handle to the named pipe file system directory. Used by
|
|
|
|
fhandler_pipe, fhandler_fifo, and fhandler_socket_unix. */
|
|
|
|
static NTSTATUS npfs_handle (HANDLE &);
|
|
|
|
|
2005-11-29 06:32:29 +08:00
|
|
|
virtual HANDLE mmap (caddr_t *addr, size_t len, int prot,
|
2013-04-23 17:44:36 +08:00
|
|
|
int flags, off_t off);
|
2000-10-05 21:07:02 +08:00
|
|
|
virtual int munmap (HANDLE h, caddr_t addr, size_t len);
|
|
|
|
virtual int msync (HANDLE h, caddr_t addr, size_t len, int flags);
|
2005-11-29 06:32:29 +08:00
|
|
|
virtual bool fixup_mmap_after_fork (HANDLE h, int prot, int flags,
|
2016-05-21 03:48:10 +08:00
|
|
|
off_t offset, SIZE_T size,
|
2005-02-26 05:23:15 +08:00
|
|
|
void *address);
|
2000-10-05 21:07:02 +08:00
|
|
|
|
2005-08-08 12:06:07 +08:00
|
|
|
void *operator new (size_t, void *p) __attribute__ ((nothrow)) {return p;}
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2009-07-04 02:05:51 +08:00
|
|
|
virtual int init (HANDLE, DWORD, mode_t);
|
2000-02-18 03:38:33 +08: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 ();
|
2012-02-28 22:03:03 +08:00
|
|
|
virtual pid_t tcgetsid ();
|
2008-01-07 02:37:20 +08:00
|
|
|
virtual bool is_tty () const { return false; }
|
2009-08-18 23:21:47 +08:00
|
|
|
virtual bool ispipe () const { return false; }
|
|
|
|
virtual pid_t get_popen_pid () const {return 0;}
|
|
|
|
virtual bool isfifo () const { return false; }
|
2011-11-08 04:05:49 +08:00
|
|
|
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 08:37:18 +08:00
|
|
|
virtual class fhandler_socket *is_socket () { return NULL; }
|
2018-02-23 22:24:18 +08:00
|
|
|
virtual class fhandler_socket_wsock *is_wsock_socket () { return NULL; }
|
2000-02-18 03:38:33 +08:00
|
|
|
virtual class fhandler_console *is_console () { return 0; }
|
2019-01-14 06:13:33 +08:00
|
|
|
virtual class fhandler_signalfd *is_signalfd () { return NULL; }
|
2019-01-16 05:02:33 +08:00
|
|
|
virtual class fhandler_timerfd *is_timerfd () { return NULL; }
|
2021-05-21 18:01:56 +08:00
|
|
|
virtual class fhandler_mqueue *is_mqueue () { return NULL; }
|
2000-02-18 03:38:33 +08:00
|
|
|
virtual int is_windows () {return 0; }
|
|
|
|
|
2022-05-24 03:52:52 +08:00
|
|
|
virtual void raw_read (void *ptr, size_t& ulen);
|
|
|
|
virtual ssize_t raw_write (const void *ptr, size_t ulen);
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
/* Virtual accessor functions to hide the fact
|
|
|
|
that some fd's have two handles. */
|
2001-03-11 09:58:23 +08:00
|
|
|
virtual HANDLE& get_handle () { return io_handle; }
|
2021-04-05 16:30:41 +08:00
|
|
|
virtual HANDLE& get_handle_nat () { return io_handle; }
|
2001-03-11 09:58:23 +08:00
|
|
|
virtual HANDLE& get_output_handle () { return io_handle; }
|
2021-04-05 16:30:41 +08:00
|
|
|
virtual HANDLE& get_output_handle_nat () { return io_handle; }
|
2010-06-15 20:05:15 +08:00
|
|
|
virtual HANDLE get_stat_handle () { return pc.handle () ?: io_handle; }
|
2015-03-05 20:57:34 +08:00
|
|
|
virtual HANDLE get_echo_handle () const { return NULL; }
|
2003-12-08 06:37:12 +08:00
|
|
|
virtual bool hit_eof () {return false;}
|
2009-07-01 05:18:44 +08: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 08:37:18 +08:00
|
|
|
virtual const char *get_native_name ()
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2016-06-23 22:56:41 +08:00
|
|
|
return dev ().native ();
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
2016-07-27 02:03:07 +08:00
|
|
|
virtual bg_check_types bg_check (int, bool = false) {return bg_ok;}
|
2019-03-28 05:29:21 +08:00
|
|
|
virtual void clear_readahead ()
|
2000-09-03 12:16:35 +08:00
|
|
|
{
|
2020-01-27 20:14:32 +08:00
|
|
|
raixput () = raixget () = ralen () = rabuflen () = 0;
|
|
|
|
rabuf () = NULL;
|
2000-09-03 12:16:35 +08:00
|
|
|
}
|
2011-11-29 23:34:49 +08:00
|
|
|
void operator delete (void *p) {cfree (p);}
|
2001-11-03 13:42:21 +08:00
|
|
|
virtual void set_eof () {}
|
2005-05-25 12:32:59 +08:00
|
|
|
virtual int mkdir (mode_t mode);
|
|
|
|
virtual int rmdir ();
|
2022-05-24 03:52:52 +08:00
|
|
|
virtual DIR *opendir (int fd);
|
|
|
|
virtual int readdir (DIR *, dirent *);
|
2010-07-06 00:59:56 +08:00
|
|
|
virtual long telldir (DIR *);
|
|
|
|
virtual void seekdir (DIR *, long);
|
2001-11-21 14:47:57 +08:00
|
|
|
virtual void rewinddir (DIR *);
|
|
|
|
virtual int closedir (DIR *);
|
2004-01-24 11:40:33 +08:00
|
|
|
bool is_fs_special () {return pc.is_fs_special ();}
|
2005-12-23 00:45:15 +08:00
|
|
|
bool issymlink () {return pc.issymlink ();}
|
2022-05-24 03:52:52 +08:00
|
|
|
bool device_access_denied (int);
|
|
|
|
int fhaccess (int flags, bool);
|
2011-10-16 06:37:30 +08:00
|
|
|
|
|
|
|
fhandler_base (void *) {}
|
|
|
|
|
2021-02-10 17:42:05 +08:00
|
|
|
protected:
|
|
|
|
void _copy_from_reset_helper ()
|
|
|
|
{
|
|
|
|
ra.rabuf = NULL;
|
|
|
|
ra.ralen = 0;
|
|
|
|
ra.raixget = 0;
|
|
|
|
ra.raixput = 0;
|
|
|
|
ra.rabuflen = 0;
|
|
|
|
_refcnt = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual void copy_from (fhandler_base *x)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2021-02-10 17:42:05 +08:00
|
|
|
pc.free_strings ();
|
|
|
|
*this = *reinterpret_cast<fhandler_base *> (x);
|
|
|
|
_copy_from_reset_helper ();
|
2011-10-16 06:37:30 +08:00
|
|
|
}
|
|
|
|
|
2011-11-29 23:34:49 +08:00
|
|
|
virtual fhandler_base *clone (cygheap_types malloc_type = HEAP_FHANDLER)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2011-11-29 23:34:49 +08:00
|
|
|
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_base));
|
2011-10-30 12:50:36 +08:00
|
|
|
fhandler_base *fh = new (ptr) fhandler_base (ptr);
|
2021-02-10 17:42:05 +08:00
|
|
|
fh->copy_from (this);
|
2011-10-16 06:37:30 +08:00
|
|
|
return fh;
|
|
|
|
}
|
2021-09-08 16:18:35 +08:00
|
|
|
|
|
|
|
HANDLE get_select_sem () { return select_sem; }
|
2000-02-18 03:38:33 +08:00
|
|
|
};
|
|
|
|
|
2008-11-27 01:21:04 +08:00
|
|
|
struct wsa_event
|
2008-04-19 04:30:04 +08:00
|
|
|
{
|
|
|
|
LONG serial_number;
|
|
|
|
long events;
|
|
|
|
int connect_errorcode;
|
|
|
|
pid_t owner;
|
2008-11-27 01:21:04 +08:00
|
|
|
};
|
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-26 03:23:23 +08:00
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
class fhandler_socket: public fhandler_base
|
|
|
|
{
|
2001-11-02 05:15:53 +08:00
|
|
|
private:
|
2018-02-22 04:40:01 +08:00
|
|
|
/* permission fake following Linux rules */
|
|
|
|
uid_t uid;
|
|
|
|
uid_t gid;
|
|
|
|
mode_t mode;
|
|
|
|
|
|
|
|
protected:
|
2000-02-18 03:38:33 +08:00
|
|
|
int addr_family;
|
2002-04-12 22:52:36 +08:00
|
|
|
int type;
|
2018-02-22 05:00:04 +08:00
|
|
|
inline int get_socket_flags ()
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
if (is_nonblocking ())
|
|
|
|
ret |= SOCK_NONBLOCK;
|
|
|
|
if (close_on_exec ())
|
|
|
|
ret |= SOCK_CLOEXEC;
|
|
|
|
return ret;
|
|
|
|
}
|
2018-02-22 23:54:08 +08:00
|
|
|
|
2018-02-22 04:40:01 +08:00
|
|
|
protected:
|
2009-07-01 17:16:17 +08:00
|
|
|
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; }
|
|
|
|
|
2018-02-22 04:40:01 +08:00
|
|
|
protected:
|
2018-02-07 23:16:51 +08:00
|
|
|
DWORD _rcvtimeo; /* msecs */
|
|
|
|
DWORD _sndtimeo; /* msecs */
|
|
|
|
public:
|
|
|
|
DWORD &rcvtimeo () { return _rcvtimeo; }
|
|
|
|
DWORD &sndtimeo () { return _sndtimeo; }
|
|
|
|
|
2018-02-23 22:24:18 +08:00
|
|
|
public:
|
|
|
|
fhandler_socket ();
|
|
|
|
~fhandler_socket ();
|
|
|
|
fhandler_socket *is_socket () { return this; }
|
|
|
|
|
2018-02-22 23:54:08 +08:00
|
|
|
char *get_proc_fd_name (char *buf);
|
|
|
|
|
2018-02-22 04:40:01 +08:00
|
|
|
virtual int socket (int af, int type, int protocol, int flags) = 0;
|
2018-02-27 00:53:50 +08:00
|
|
|
virtual int socketpair (int af, int type, int protocol, int flags,
|
|
|
|
fhandler_socket *fh_out) = 0;
|
2018-02-22 04:40:01 +08:00
|
|
|
virtual int bind (const struct sockaddr *name, int namelen) = 0;
|
|
|
|
virtual int listen (int backlog) = 0;
|
|
|
|
virtual int accept4 (struct sockaddr *peer, int *len, int flags) = 0;
|
|
|
|
virtual int connect (const struct sockaddr *name, int namelen) = 0;
|
|
|
|
virtual int getsockname (struct sockaddr *name, int *namelen) = 0;
|
|
|
|
virtual int getpeername (struct sockaddr *name, int *namelen) = 0;
|
2018-02-22 23:28:14 +08:00
|
|
|
virtual int shutdown (int how) = 0;
|
|
|
|
virtual int close () = 0;
|
2018-02-22 04:40:01 +08:00
|
|
|
virtual int getpeereid (pid_t *pid, uid_t *euid, gid_t *egid);
|
|
|
|
virtual ssize_t recvfrom (void *ptr, size_t len, int flags,
|
|
|
|
struct sockaddr *from, int *fromlen) = 0;
|
|
|
|
virtual ssize_t recvmsg (struct msghdr *msg, int flags) = 0;
|
2022-05-24 03:52:52 +08:00
|
|
|
virtual void read (void *ptr, size_t& len) = 0;
|
2022-06-07 00:00:45 +08:00
|
|
|
virtual ssize_t readv (const struct iovec *, int iovcnt,
|
2018-02-22 04:40:01 +08:00
|
|
|
ssize_t tot = -1) = 0;
|
|
|
|
|
|
|
|
virtual ssize_t sendto (const void *ptr, size_t len, int flags,
|
|
|
|
const struct sockaddr *to, int tolen) = 0;
|
|
|
|
virtual ssize_t sendmsg (const struct msghdr *msg, int flags) = 0;
|
2022-06-07 00:00:45 +08:00
|
|
|
virtual ssize_t write (const void *ptr, size_t len) = 0;
|
|
|
|
virtual ssize_t writev (const struct iovec *, int iovcnt, ssize_t tot = -1) = 0;
|
2018-02-22 23:54:08 +08:00
|
|
|
virtual int setsockopt (int level, int optname, const void *optval,
|
|
|
|
__socklen_t optlen) = 0;
|
|
|
|
virtual int getsockopt (int level, int optname, const void *optval,
|
|
|
|
__socklen_t *optlen) = 0;
|
2002-06-27 03:25:09 +08:00
|
|
|
|
2018-02-22 23:37:12 +08:00
|
|
|
virtual int ioctl (unsigned int cmd, void *);
|
|
|
|
virtual int fcntl (int cmd, intptr_t);
|
|
|
|
|
2018-02-22 23:54:08 +08:00
|
|
|
int open (int flags, mode_t mode = 0);
|
2022-05-24 03:52:52 +08:00
|
|
|
int fstat (struct stat *buf);
|
|
|
|
int fstatvfs (struct statvfs *buf);
|
|
|
|
int fchmod (mode_t newmode);
|
|
|
|
int fchown (uid_t newuid, gid_t newgid);
|
|
|
|
int facl (int, int, struct acl *);
|
|
|
|
int link (const char *);
|
2014-08-18 19:09:56 +08:00
|
|
|
off_t lseek (off_t, int)
|
2020-03-11 20:36:41 +08:00
|
|
|
{
|
2014-08-18 19:09:56 +08:00
|
|
|
set_errno (ESPIPE);
|
|
|
|
return -1;
|
|
|
|
}
|
2000-10-26 18:13:41 +08:00
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
void set_addr_family (int af) {addr_family = af;}
|
2002-02-08 19:54:10 +08:00
|
|
|
int get_addr_family () {return addr_family;}
|
2018-03-19 03:46:43 +08:00
|
|
|
virtual void set_socket_type (int st) { type = st;}
|
|
|
|
virtual int get_socket_type () {return type;}
|
2018-02-22 23:59:55 +08:00
|
|
|
|
|
|
|
/* select.cc */
|
|
|
|
virtual select_record *select_read (select_stuff *) = 0;
|
|
|
|
virtual select_record *select_write (select_stuff *) = 0;
|
|
|
|
virtual select_record *select_except (select_stuff *) = 0;
|
2018-02-22 04:40:01 +08:00
|
|
|
};
|
|
|
|
|
2018-02-23 22:24:18 +08:00
|
|
|
/* Encapsulate wsock-based socket classes fhandler_socket_inet and
|
|
|
|
fhandler_socket_local during development of fhandler_socket_unix.
|
|
|
|
TODO: Perhaps we should keep it that way, under the assumption that
|
|
|
|
the Windows 10 AF_UNIX class will eventually get useful at one point. */
|
|
|
|
class fhandler_socket_wsock: public fhandler_socket
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
virtual int af_local_connect () = 0;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
wsa_event *wsock_events;
|
|
|
|
HANDLE wsock_mtx;
|
|
|
|
HANDLE wsock_evt;
|
|
|
|
bool init_events ();
|
|
|
|
int wait_for_events (const long event_mask, const DWORD flags);
|
|
|
|
void release_events ();
|
|
|
|
public:
|
|
|
|
const HANDLE wsock_event () const { return wsock_evt; }
|
|
|
|
int evaluate_events (const long event_mask, long &events, const bool erase);
|
|
|
|
const LONG serial_number () const { return wsock_events->serial_number; }
|
|
|
|
|
2018-03-12 22:26:12 +08:00
|
|
|
protected:
|
|
|
|
struct status_flags
|
|
|
|
{
|
|
|
|
unsigned async_io : 1; /* async I/O */
|
|
|
|
unsigned saw_shutdown_read : 1; /* Socket saw a SHUT_RD */
|
|
|
|
unsigned saw_shutdown_write : 1; /* Socket saw a SHUT_WR */
|
|
|
|
unsigned saw_reuseaddr : 1; /* Socket saw SO_REUSEADDR call */
|
|
|
|
unsigned connect_state : 3;
|
|
|
|
public:
|
|
|
|
status_flags () :
|
|
|
|
async_io (0), saw_shutdown_read (0), saw_shutdown_write (0),
|
|
|
|
saw_reuseaddr (0), connect_state (unconnected)
|
|
|
|
{}
|
|
|
|
} status;
|
|
|
|
public:
|
|
|
|
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)
|
|
|
|
IMPLEMENT_STATUS_FLAG (conn_state, connect_state)
|
|
|
|
|
2018-02-23 22:24:18 +08:00
|
|
|
protected:
|
|
|
|
struct _WSAPROTOCOL_INFOW *prot_info_ptr;
|
|
|
|
public:
|
|
|
|
bool need_fixup_before () const {return prot_info_ptr != NULL;}
|
|
|
|
void set_close_on_exec (bool val);
|
|
|
|
void init_fixup_before ();
|
|
|
|
int fixup_before_fork_exec (DWORD);
|
|
|
|
void fixup_after_fork (HANDLE);
|
|
|
|
void fixup_after_exec ();
|
|
|
|
int dup (fhandler_base *child, int);
|
|
|
|
|
|
|
|
#ifdef __INSIDE_CYGWIN_NET__
|
|
|
|
protected:
|
|
|
|
int set_socket_handle (SOCKET sock, int af, int type, int flags);
|
|
|
|
public:
|
|
|
|
/* Originally get_socket returned an int, which is not a good idea
|
|
|
|
to cast a handle to on 64 bit. The right type here is very certainly
|
|
|
|
SOCKET instead. On the other hand, we don't want to have to include
|
|
|
|
winsock.h just to build fhandler.h. Therefore we define get_socket
|
|
|
|
now only when building network related code. */
|
|
|
|
SOCKET get_socket () { return (SOCKET) get_handle(); }
|
|
|
|
#endif
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual ssize_t recv_internal (struct _WSAMSG *wsamsg, bool use_recvmsg) = 0;
|
|
|
|
ssize_t send_internal (struct _WSAMSG *wsamsg, int flags);
|
|
|
|
|
|
|
|
public:
|
|
|
|
fhandler_socket_wsock ();
|
|
|
|
~fhandler_socket_wsock ();
|
|
|
|
|
|
|
|
fhandler_socket_wsock *is_wsock_socket () { return this; }
|
|
|
|
|
|
|
|
ssize_t recvfrom (void *ptr, size_t len, int flags,
|
|
|
|
struct sockaddr *from, int *fromlen);
|
|
|
|
ssize_t recvmsg (struct msghdr *msg, int flags);
|
2022-05-24 03:52:52 +08:00
|
|
|
void read (void *ptr, size_t& len);
|
2022-06-07 00:00:45 +08:00
|
|
|
ssize_t readv (const struct iovec *, int iovcnt, ssize_t tot = -1);
|
|
|
|
ssize_t write (const void *ptr, size_t len);
|
|
|
|
ssize_t writev (const struct iovec *, int iovcnt, ssize_t tot = -1);
|
2018-02-23 22:24:18 +08:00
|
|
|
int shutdown (int how);
|
|
|
|
int close ();
|
|
|
|
|
|
|
|
int ioctl (unsigned int cmd, void *);
|
|
|
|
int fcntl (int cmd, intptr_t);
|
|
|
|
|
|
|
|
/* select.cc */
|
|
|
|
select_record *select_read (select_stuff *);
|
|
|
|
select_record *select_write (select_stuff *);
|
|
|
|
select_record *select_except (select_stuff *);
|
|
|
|
};
|
|
|
|
|
|
|
|
class fhandler_socket_inet: public fhandler_socket_wsock
|
2018-02-22 04:40:01 +08:00
|
|
|
{
|
2018-06-21 22:11:49 +08:00
|
|
|
private:
|
2020-06-30 20:34:19 +08:00
|
|
|
bool oobinline; /* True if option SO_OOBINLINE is set */
|
2020-07-02 03:26:59 +08:00
|
|
|
bool tcp_quickack; /* True if quickack is enabled */
|
2020-06-30 20:34:19 +08:00
|
|
|
bool tcp_fastopen; /* True if TCP_FASTOPEN is set on older systems */
|
2020-07-02 02:27:10 +08:00
|
|
|
int tcp_keepidle; /* TCP_KEEPIDLE value in secs on older systems */
|
|
|
|
int tcp_keepcnt; /* TCP_KEEPCNT value on older systems */
|
|
|
|
int tcp_keepintvl; /* TCP_KEEPINTVL value in secs on older systems */
|
|
|
|
|
|
|
|
int set_keepalive (int keepidle, int keepcnt, int keepintvl);
|
2018-02-22 04:40:01 +08:00
|
|
|
protected:
|
|
|
|
int af_local_connect () { return 0; }
|
|
|
|
|
2018-02-23 22:24:18 +08:00
|
|
|
protected:
|
|
|
|
ssize_t recv_internal (struct _WSAMSG *wsamsg, bool use_recvmsg);
|
2018-02-22 04:40:01 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
fhandler_socket_inet ();
|
|
|
|
~fhandler_socket_inet ();
|
|
|
|
|
|
|
|
int socket (int af, int type, int protocol, int flags);
|
2018-02-27 00:53:50 +08:00
|
|
|
int socketpair (int af, int type, int protocol, int flags,
|
|
|
|
fhandler_socket *fh_out);
|
2018-02-22 04:40:01 +08:00
|
|
|
int bind (const struct sockaddr *name, int namelen);
|
|
|
|
int listen (int backlog);
|
|
|
|
int accept4 (struct sockaddr *peer, int *len, int flags);
|
|
|
|
int connect (const struct sockaddr *name, int namelen);
|
|
|
|
int getsockname (struct sockaddr *name, int *namelen);
|
|
|
|
int getpeername (struct sockaddr *name, int *namelen);
|
|
|
|
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);
|
2018-02-22 23:54:08 +08:00
|
|
|
int setsockopt (int level, int optname, const void *optval,
|
|
|
|
__socklen_t optlen);
|
|
|
|
int getsockopt (int level, int optname, const void *optval,
|
|
|
|
__socklen_t *optlen);
|
|
|
|
|
2018-02-22 04:40:01 +08:00
|
|
|
/* from here on: CLONING */
|
|
|
|
fhandler_socket_inet (void *) {}
|
|
|
|
|
2021-02-10 17:42:05 +08:00
|
|
|
void copy_from (fhandler_base *x)
|
2018-02-22 04:40:01 +08:00
|
|
|
{
|
2021-02-10 17:42:05 +08:00
|
|
|
pc.free_strings ();
|
|
|
|
*this = *reinterpret_cast<fhandler_socket_inet *> (x);
|
|
|
|
_copy_from_reset_helper ();
|
2018-02-22 04:40:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
fhandler_socket_inet *clone (cygheap_types malloc_type = HEAP_FHANDLER)
|
|
|
|
{
|
|
|
|
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_socket_inet));
|
|
|
|
fhandler_socket_inet *fh = new (ptr) fhandler_socket_inet (ptr);
|
2021-02-10 17:42:05 +08:00
|
|
|
fh->copy_from (this);
|
2018-02-22 04:40:01 +08:00
|
|
|
return fh;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-02-23 22:24:18 +08:00
|
|
|
class fhandler_socket_local: public fhandler_socket_wsock
|
2018-02-22 04:40:01 +08:00
|
|
|
{
|
|
|
|
protected:
|
|
|
|
char *sun_path;
|
|
|
|
char *peer_sun_path;
|
2002-01-02 00:25:31 +08:00
|
|
|
void set_sun_path (const char *path);
|
|
|
|
char *get_sun_path () {return sun_path;}
|
2009-08-13 18:26:42 +08:00
|
|
|
void set_peer_sun_path (const char *path);
|
|
|
|
char *get_peer_sun_path () {return peer_sun_path;}
|
2005-03-24 01:27:18 +08:00
|
|
|
|
2018-02-22 04:40:01 +08:00
|
|
|
protected:
|
|
|
|
int connect_secret[4];
|
|
|
|
pid_t sec_pid;
|
|
|
|
uid_t sec_uid;
|
|
|
|
gid_t sec_gid;
|
|
|
|
pid_t sec_peer_pid;
|
|
|
|
uid_t sec_peer_uid;
|
|
|
|
gid_t sec_peer_gid;
|
|
|
|
void af_local_set_secret (char *);
|
|
|
|
void af_local_setblocking (bool &, bool &);
|
|
|
|
void af_local_unsetblocking (bool, bool);
|
|
|
|
void af_local_set_cred ();
|
|
|
|
void af_local_copy (fhandler_socket_local *);
|
|
|
|
bool af_local_recv_secret ();
|
|
|
|
bool af_local_send_secret ();
|
|
|
|
bool af_local_recv_cred ();
|
|
|
|
bool af_local_send_cred ();
|
|
|
|
int af_local_accept ();
|
|
|
|
int af_local_connect ();
|
|
|
|
int af_local_set_no_getpeereid ();
|
|
|
|
void af_local_set_sockpair_cred ();
|
|
|
|
|
2018-02-23 22:24:18 +08:00
|
|
|
protected:
|
|
|
|
ssize_t recv_internal (struct _WSAMSG *wsamsg, bool use_recvmsg);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
struct status_flags
|
|
|
|
{
|
|
|
|
unsigned no_getpeereid : 1;
|
|
|
|
public:
|
|
|
|
status_flags () : no_getpeereid (0) {}
|
|
|
|
} status;
|
|
|
|
public:
|
|
|
|
IMPLEMENT_STATUS_FLAG (bool, no_getpeereid)
|
2018-02-22 04:40:01 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
fhandler_socket_local ();
|
|
|
|
~fhandler_socket_local ();
|
|
|
|
|
|
|
|
int dup (fhandler_base *child, int);
|
|
|
|
|
|
|
|
int socket (int af, int type, int protocol, int flags);
|
|
|
|
int socketpair (int af, int type, int protocol, int flags,
|
2018-02-27 00:53:50 +08:00
|
|
|
fhandler_socket *fh_out);
|
2018-02-22 04:40:01 +08:00
|
|
|
int bind (const struct sockaddr *name, int namelen);
|
|
|
|
int listen (int backlog);
|
|
|
|
int accept4 (struct sockaddr *peer, int *len, int flags);
|
|
|
|
int connect (const struct sockaddr *name, int namelen);
|
|
|
|
int getsockname (struct sockaddr *name, int *namelen);
|
|
|
|
int getpeername (struct sockaddr *name, int *namelen);
|
|
|
|
int getpeereid (pid_t *pid, uid_t *euid, gid_t *egid);
|
|
|
|
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);
|
2018-02-22 23:54:08 +08:00
|
|
|
int setsockopt (int level, int optname, const void *optval,
|
|
|
|
__socklen_t optlen);
|
|
|
|
int getsockopt (int level, int optname, const void *optval,
|
|
|
|
__socklen_t *optlen);
|
|
|
|
|
2020-01-24 03:39:15 +08:00
|
|
|
int open (int flags, mode_t mode = 0);
|
|
|
|
int close ();
|
2020-01-26 02:08:00 +08:00
|
|
|
int fcntl (int cmd, intptr_t);
|
2022-05-24 03:52:52 +08:00
|
|
|
int fstat (struct stat *buf);
|
|
|
|
int fstatvfs (struct statvfs *buf);
|
|
|
|
int fchmod (mode_t newmode);
|
|
|
|
int fchown (uid_t newuid, gid_t newgid);
|
|
|
|
int facl (int, int, struct acl *);
|
2022-07-03 03:12:40 +08:00
|
|
|
struct __acl_t *acl_get (uint32_t);
|
|
|
|
int acl_set (struct __acl_t *, uint32_t);
|
2022-05-24 03:52:52 +08:00
|
|
|
int link (const char *);
|
2011-10-16 06:37:30 +08:00
|
|
|
|
2018-02-22 04:40:01 +08:00
|
|
|
/* from here on: CLONING */
|
|
|
|
fhandler_socket_local (void *) {}
|
2011-10-16 06:37:30 +08:00
|
|
|
|
2021-02-10 17:42:05 +08:00
|
|
|
void copy_from (fhandler_base *x)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2021-02-10 17:42:05 +08:00
|
|
|
pc.free_strings ();
|
|
|
|
*this = *reinterpret_cast<fhandler_socket_local *> (x);
|
|
|
|
_copy_from_reset_helper ();
|
2011-10-16 06:37:30 +08:00
|
|
|
}
|
|
|
|
|
2018-02-22 04:40:01 +08:00
|
|
|
fhandler_socket_local *clone (cygheap_types malloc_type = HEAP_FHANDLER)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2018-02-22 04:40:01 +08:00
|
|
|
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_socket_local));
|
|
|
|
fhandler_socket_local *fh = new (ptr) fhandler_socket_local (ptr);
|
2021-02-10 17:42:05 +08:00
|
|
|
fh->copy_from (this);
|
2011-10-16 06:37:30 +08:00
|
|
|
return fh;
|
|
|
|
}
|
2000-02-18 03:38:33 +08:00
|
|
|
};
|
|
|
|
|
2018-03-19 01:46:15 +08:00
|
|
|
/* Sharable spinlock with low CPU profile. These locks are NOT recursive! */
|
|
|
|
class af_unix_spinlock_t
|
|
|
|
{
|
2019-01-11 01:56:55 +08:00
|
|
|
LONG locked; /* 0 or 1 */
|
2018-03-19 01:46:15 +08:00
|
|
|
|
|
|
|
public:
|
2019-01-11 01:56:55 +08:00
|
|
|
af_unix_spinlock_t () : locked (0) {}
|
2018-03-19 01:46:15 +08:00
|
|
|
void lock ()
|
|
|
|
{
|
|
|
|
LONG ret = InterlockedExchange (&locked, 1);
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
/* This loop counts the ms Sleep up from 0 to 45 in loop, 15ms steps,
|
|
|
|
with 256 iterations each, . */
|
|
|
|
for (uint16_t i = 0; ret; i += 64)
|
|
|
|
{
|
|
|
|
Sleep (15 * (i >> 14));
|
|
|
|
ret = InterlockedExchange (&locked, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void unlock ()
|
|
|
|
{
|
|
|
|
InterlockedExchange (&locked, 0);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-03-19 03:46:43 +08:00
|
|
|
/* Internal representation of shutdown states */
|
|
|
|
enum shut_state {
|
|
|
|
_SHUT_NONE = 0,
|
|
|
|
_SHUT_RECV = 1,
|
|
|
|
_SHUT_SEND = 2,
|
|
|
|
_SHUT_MASK = 3
|
|
|
|
};
|
|
|
|
|
2018-03-02 01:14:23 +08:00
|
|
|
class sun_name_t
|
2018-03-01 02:06:41 +08:00
|
|
|
{
|
2018-03-02 01:14:23 +08:00
|
|
|
public:
|
2018-03-01 02:06:41 +08:00
|
|
|
__socklen_t un_len;
|
|
|
|
union
|
|
|
|
{
|
|
|
|
struct sockaddr_un un;
|
|
|
|
/* Allows 108 bytes sun_path plus trailing NUL */
|
|
|
|
char _nul[sizeof (struct sockaddr_un) + 1];
|
|
|
|
};
|
2018-03-19 03:46:43 +08:00
|
|
|
sun_name_t () { set (NULL, 0); }
|
|
|
|
sun_name_t (const struct sockaddr *name, __socklen_t namelen)
|
|
|
|
{ set ((const struct sockaddr_un *) name, namelen); }
|
|
|
|
void set (const struct sockaddr_un *name, __socklen_t namelen);
|
2018-03-12 22:26:12 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* For each AF_UNIX socket, we need to maintain socket-wide data,
|
|
|
|
regardless of the number of descriptors. The shmem region gets created
|
|
|
|
in socket, socketpair or accept4 and reopened by dup, fork or exec. */
|
|
|
|
class af_unix_shmem_t
|
|
|
|
{
|
2018-03-19 01:46:15 +08:00
|
|
|
/* Don't use SRWLOCKs here. They are not sharable. If you must lock
|
|
|
|
multiple locks at the same time, always lock in the order bind ->
|
|
|
|
conn -> state -> io and unlock io -> state -> conn -> bind to avoid
|
|
|
|
deadlocks. */
|
|
|
|
af_unix_spinlock_t _bind_lock;
|
|
|
|
af_unix_spinlock_t _conn_lock;
|
2018-03-19 03:06:43 +08:00
|
|
|
af_unix_spinlock_t _state_lock;
|
2018-03-19 01:46:15 +08:00
|
|
|
af_unix_spinlock_t _io_lock;
|
2018-03-12 22:26:12 +08:00
|
|
|
LONG _connection_state; /* conn_state */
|
|
|
|
LONG _binding_state; /* bind_state */
|
|
|
|
LONG _shutdown; /* shut_state */
|
|
|
|
LONG _so_error; /* SO_ERROR */
|
2018-03-19 03:46:43 +08:00
|
|
|
LONG _so_passcred; /* SO_PASSCRED */
|
2018-03-12 22:26:12 +08:00
|
|
|
LONG _reuseaddr; /* dummy */
|
2018-03-19 03:46:43 +08:00
|
|
|
int _type; /* socket type */
|
|
|
|
sun_name_t _sun_path;
|
|
|
|
sun_name_t _peer_sun_path;
|
|
|
|
struct ucred _sock_cred; /* filled at listen time */
|
|
|
|
struct ucred _peer_cred; /* filled at connect time */
|
2018-03-12 22:26:12 +08:00
|
|
|
|
|
|
|
public:
|
2018-03-19 01:46:15 +08:00
|
|
|
void bind_lock () { _bind_lock.lock (); }
|
|
|
|
void bind_unlock () { _bind_lock.unlock (); }
|
|
|
|
void conn_lock () { _conn_lock.lock (); }
|
|
|
|
void conn_unlock () { _conn_lock.unlock (); }
|
2018-03-19 03:06:43 +08:00
|
|
|
void state_lock () { _state_lock.lock (); }
|
|
|
|
void state_unlock () { _state_lock.unlock (); }
|
2018-03-19 01:46:15 +08:00
|
|
|
void io_lock () { _io_lock.lock (); }
|
|
|
|
void io_unlock () { _io_lock.unlock (); }
|
2018-03-12 22:26:12 +08:00
|
|
|
|
|
|
|
conn_state connect_state (conn_state val)
|
|
|
|
{ return (conn_state) InterlockedExchange (&_connection_state, val); }
|
|
|
|
conn_state connect_state () const { return (conn_state) _connection_state; }
|
|
|
|
|
|
|
|
bind_state binding_state (bind_state val)
|
|
|
|
{ return (bind_state) InterlockedExchange (&_binding_state, val); }
|
|
|
|
bind_state binding_state () const { return (bind_state) _binding_state; }
|
|
|
|
|
|
|
|
int shutdown (int shut)
|
|
|
|
{ return (int) InterlockedExchange (&_shutdown, shut); }
|
|
|
|
int shutdown () const { return (int) _shutdown; }
|
|
|
|
|
2018-03-19 03:46:43 +08:00
|
|
|
int so_error (int err) { return (int) InterlockedExchange (&_so_error, err); }
|
2018-03-12 22:26:12 +08:00
|
|
|
int so_error () const { return _so_error; }
|
|
|
|
|
2018-03-19 03:46:43 +08:00
|
|
|
bool so_passcred (bool pc)
|
|
|
|
{ return (bool) InterlockedExchange (&_so_passcred, pc); }
|
|
|
|
bool so_passcred () const { return _so_passcred; }
|
|
|
|
|
2018-03-12 22:26:12 +08:00
|
|
|
int reuseaddr (int val)
|
|
|
|
{ return (int) InterlockedExchange (&_reuseaddr, val); }
|
|
|
|
int reuseaddr () const { return _reuseaddr; }
|
2018-03-19 03:46:43 +08:00
|
|
|
|
|
|
|
void set_socket_type (int val) { _type = val; }
|
|
|
|
int get_socket_type () const { return _type; }
|
|
|
|
|
|
|
|
void sun_path (struct sockaddr_un *un, __socklen_t unlen)
|
|
|
|
{ _sun_path.set (un, unlen); }
|
|
|
|
void peer_sun_path (struct sockaddr_un *un, __socklen_t unlen)
|
|
|
|
{ _peer_sun_path.set (un, unlen); }
|
|
|
|
sun_name_t *sun_path () {return &_sun_path;}
|
|
|
|
sun_name_t *peer_sun_path () {return &_peer_sun_path;}
|
|
|
|
|
|
|
|
void sock_cred (struct ucred *uc) { _sock_cred = *uc; }
|
|
|
|
struct ucred *sock_cred () { return &_sock_cred; }
|
|
|
|
void peer_cred (struct ucred *uc) { _peer_cred = *uc; }
|
|
|
|
struct ucred *peer_cred () { return &_peer_cred; }
|
2018-03-12 22:26:12 +08:00
|
|
|
};
|
|
|
|
|
2018-06-26 22:31:17 +08:00
|
|
|
#ifdef __WITH_AF_UNIX
|
|
|
|
|
2018-02-24 03:59:21 +08:00
|
|
|
class fhandler_socket_unix : public fhandler_socket
|
|
|
|
{
|
|
|
|
protected:
|
2018-03-12 22:26:12 +08:00
|
|
|
HANDLE shmem_handle; /* Shared memory region used to share
|
|
|
|
socket-wide state. */
|
|
|
|
af_unix_shmem_t *shmem;
|
2018-03-07 01:55:03 +08:00
|
|
|
HANDLE backing_file_handle; /* Either NT symlink or INVALID_HANDLE_VALUE,
|
|
|
|
if the socket is backed by a file in the
|
|
|
|
file system (actually a reparse point) */
|
|
|
|
HANDLE connect_wait_thr;
|
2018-03-07 23:19:32 +08:00
|
|
|
HANDLE cwt_termination_evt;
|
2018-03-07 01:55:03 +08:00
|
|
|
PVOID cwt_param;
|
|
|
|
|
2018-03-12 22:26:12 +08:00
|
|
|
void bind_lock () { shmem->bind_lock (); }
|
|
|
|
void bind_unlock () { shmem->bind_unlock (); }
|
|
|
|
void conn_lock () { shmem->conn_lock (); }
|
|
|
|
void conn_unlock () { shmem->conn_unlock (); }
|
2018-03-19 03:06:43 +08:00
|
|
|
void state_lock () { shmem->state_lock (); }
|
|
|
|
void state_unlock () { shmem->state_unlock (); }
|
2018-03-12 22:26:12 +08:00
|
|
|
void io_lock () { shmem->io_lock (); }
|
|
|
|
void io_unlock () { shmem->io_unlock (); }
|
|
|
|
conn_state connect_state (conn_state val)
|
|
|
|
{ return shmem->connect_state (val); }
|
|
|
|
conn_state connect_state () const { return shmem->connect_state (); }
|
|
|
|
bind_state binding_state (bind_state val)
|
|
|
|
{ return shmem->binding_state (val); }
|
|
|
|
bind_state binding_state () const { return shmem->binding_state (); }
|
|
|
|
int saw_shutdown (int shut) { return shmem->shutdown (shut); }
|
|
|
|
int saw_shutdown () const { return shmem->shutdown (); }
|
|
|
|
int so_error (int err) { return shmem->so_error (err); }
|
|
|
|
int so_error () const { return shmem->so_error (); }
|
2018-03-19 03:46:43 +08:00
|
|
|
bool so_passcred (bool pc) { return shmem->so_passcred (pc); }
|
|
|
|
bool so_passcred () const { return shmem->so_passcred (); }
|
2018-03-12 22:26:12 +08:00
|
|
|
int reuseaddr (int err) { return shmem->reuseaddr (err); }
|
|
|
|
int reuseaddr () const { return shmem->reuseaddr (); }
|
2018-03-19 03:46:43 +08:00
|
|
|
void set_socket_type (int val) { shmem->set_socket_type (val); }
|
|
|
|
int get_socket_type () const { return shmem->get_socket_type (); }
|
2018-03-12 22:26:12 +08:00
|
|
|
|
|
|
|
int create_shmem ();
|
|
|
|
int reopen_shmem ();
|
2018-03-07 01:55:03 +08:00
|
|
|
void gen_pipe_name ();
|
|
|
|
static HANDLE create_abstract_link (const sun_name_t *sun,
|
|
|
|
PUNICODE_STRING pipe_name);
|
|
|
|
static HANDLE create_reparse_point (const sun_name_t *sun,
|
|
|
|
PUNICODE_STRING pipe_name);
|
|
|
|
HANDLE create_file (const sun_name_t *sun);
|
|
|
|
static int open_abstract_link (sun_name_t *sun, PUNICODE_STRING pipe_name);
|
|
|
|
static int open_reparse_point (sun_name_t *sun, PUNICODE_STRING pipe_name);
|
|
|
|
static int open_file (sun_name_t *sun, int &type, PUNICODE_STRING pipe_name);
|
|
|
|
HANDLE autobind (sun_name_t *sun);
|
|
|
|
wchar_t get_type_char ();
|
|
|
|
void set_pipe_non_blocking (bool nonblocking);
|
2018-03-19 03:46:43 +08:00
|
|
|
int send_sock_info (bool from_bind);
|
|
|
|
int grab_admin_pkg ();
|
|
|
|
int recv_peer_info ();
|
2018-03-09 21:19:36 +08:00
|
|
|
HANDLE create_pipe (bool single_instance);
|
2018-03-07 01:55:03 +08:00
|
|
|
HANDLE create_pipe_instance ();
|
2018-03-19 03:46:43 +08:00
|
|
|
NTSTATUS open_pipe (PUNICODE_STRING pipe_name, bool xchg_sock_info);
|
2018-03-07 01:55:03 +08:00
|
|
|
int wait_pipe (PUNICODE_STRING pipe_name);
|
|
|
|
int connect_pipe (PUNICODE_STRING pipe_name);
|
|
|
|
int listen_pipe ();
|
2018-03-19 03:46:43 +08:00
|
|
|
ULONG peek_pipe (PFILE_PIPE_PEEK_BUFFER pbuf, ULONG psize, HANDLE evt);
|
2018-03-07 01:55:03 +08:00
|
|
|
int disconnect_pipe (HANDLE ph);
|
2018-03-19 03:46:43 +08:00
|
|
|
/* The NULL pointer check is required for FS methods like fstat. When
|
|
|
|
called via stat or lstat, there's no shared memory, just a path in pc. */
|
|
|
|
sun_name_t *sun_path () {return shmem ? shmem->sun_path () : NULL;}
|
|
|
|
sun_name_t *peer_sun_path () {return shmem->peer_sun_path ();}
|
|
|
|
void sun_path (struct sockaddr_un *un, __socklen_t unlen)
|
|
|
|
{ shmem->sun_path (un, unlen); }
|
|
|
|
void sun_path (sun_name_t *snt)
|
|
|
|
{ snt ? sun_path (&snt->un, snt->un_len) : sun_path (NULL, 0); }
|
|
|
|
void peer_sun_path (struct sockaddr_un *un, __socklen_t unlen)
|
|
|
|
{ shmem->peer_sun_path (un, unlen); }
|
|
|
|
void peer_sun_path (sun_name_t *snt)
|
|
|
|
{ snt ? peer_sun_path (&snt->un, snt->un_len)
|
|
|
|
: peer_sun_path (NULL, 0); }
|
|
|
|
void init_cred ();
|
2018-03-01 02:01:29 +08:00
|
|
|
void set_cred ();
|
2018-03-19 03:46:43 +08:00
|
|
|
void sock_cred (struct ucred *uc) { shmem->sock_cred (uc); }
|
|
|
|
struct ucred *sock_cred () { return shmem->sock_cred (); }
|
|
|
|
void peer_cred (struct ucred *uc) { shmem->peer_cred (uc); }
|
|
|
|
struct ucred *peer_cred () { return shmem->peer_cred (); }
|
2018-03-07 01:55:03 +08:00
|
|
|
void fixup_after_fork (HANDLE parent);
|
2018-03-11 04:09:28 +08:00
|
|
|
void fixup_after_exec ();
|
2018-03-07 01:55:03 +08:00
|
|
|
void set_close_on_exec (bool val);
|
2020-02-28 20:21:05 +08:00
|
|
|
void fixup_helper ();
|
2018-02-24 03:59:21 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
fhandler_socket_unix ();
|
|
|
|
~fhandler_socket_unix ();
|
|
|
|
|
|
|
|
int dup (fhandler_base *child, int);
|
|
|
|
|
2018-03-07 01:55:03 +08:00
|
|
|
DWORD wait_pipe_thread (PUNICODE_STRING pipe_name);
|
|
|
|
|
2018-02-24 03:59:21 +08:00
|
|
|
int socket (int af, int type, int protocol, int flags);
|
|
|
|
int socketpair (int af, int type, int protocol, int flags,
|
2018-02-27 00:53:50 +08:00
|
|
|
fhandler_socket *fh_out);
|
2018-02-24 03:59:21 +08:00
|
|
|
int bind (const struct sockaddr *name, int namelen);
|
|
|
|
int listen (int backlog);
|
|
|
|
int accept4 (struct sockaddr *peer, int *len, int flags);
|
|
|
|
int connect (const struct sockaddr *name, int namelen);
|
|
|
|
int getsockname (struct sockaddr *name, int *namelen);
|
|
|
|
int getpeername (struct sockaddr *name, int *namelen);
|
|
|
|
int shutdown (int how);
|
2021-02-24 00:48:46 +08:00
|
|
|
int open (int flags, mode_t mode = 0);
|
2018-02-24 03:59:21 +08:00
|
|
|
int close ();
|
|
|
|
int getpeereid (pid_t *pid, uid_t *euid, gid_t *egid);
|
2018-03-08 04:52:29 +08:00
|
|
|
ssize_t recvmsg (struct msghdr *msg, int flags);
|
2018-02-24 03:59:21 +08:00
|
|
|
ssize_t recvfrom (void *ptr, size_t len, int flags,
|
|
|
|
struct sockaddr *from, int *fromlen);
|
2022-05-24 03:52:52 +08:00
|
|
|
void read (void *ptr, size_t& len);
|
2022-06-07 00:00:45 +08:00
|
|
|
ssize_t readv (const struct iovec *const iov, int iovcnt,
|
2018-02-24 03:59:21 +08:00
|
|
|
ssize_t tot = -1);
|
|
|
|
|
2018-03-08 04:52:29 +08:00
|
|
|
ssize_t sendmsg (const struct msghdr *msg, int flags);
|
2018-02-24 03:59:21 +08:00
|
|
|
ssize_t sendto (const void *ptr, size_t len, int flags,
|
|
|
|
const struct sockaddr *to, int tolen);
|
2022-06-07 00:00:45 +08:00
|
|
|
ssize_t write (const void *ptr, size_t len);
|
|
|
|
ssize_t writev (const struct iovec *const iov, int iovcnt,
|
2018-03-08 04:52:29 +08:00
|
|
|
ssize_t tot = -1);
|
2018-02-24 03:59:21 +08:00
|
|
|
int setsockopt (int level, int optname, const void *optval,
|
|
|
|
__socklen_t optlen);
|
|
|
|
int getsockopt (int level, int optname, const void *optval,
|
|
|
|
__socklen_t *optlen);
|
|
|
|
|
|
|
|
virtual int ioctl (unsigned int cmd, void *);
|
|
|
|
virtual int fcntl (int cmd, intptr_t);
|
|
|
|
|
2022-05-24 03:52:52 +08:00
|
|
|
int fstat (struct stat *buf);
|
|
|
|
int fstatvfs (struct statvfs *buf);
|
|
|
|
int fchmod (mode_t newmode);
|
|
|
|
int fchown (uid_t newuid, gid_t newgid);
|
|
|
|
int facl (int, int, struct acl *);
|
2022-07-03 03:12:40 +08:00
|
|
|
struct __acl_t *acl_get (uint32_t);
|
|
|
|
int acl_set (struct __acl_t *, uint32_t);
|
2022-05-24 03:52:52 +08:00
|
|
|
int link (const char *);
|
2018-02-24 03:59:21 +08:00
|
|
|
|
|
|
|
/* select.cc */
|
|
|
|
select_record *select_read (select_stuff *);
|
|
|
|
select_record *select_write (select_stuff *);
|
|
|
|
select_record *select_except (select_stuff *);
|
|
|
|
|
|
|
|
/* from here on: CLONING */
|
|
|
|
fhandler_socket_unix (void *) {}
|
|
|
|
|
2021-02-10 17:42:05 +08:00
|
|
|
void copy_from (fhandler_base *x)
|
2018-02-24 03:59:21 +08:00
|
|
|
{
|
2021-02-10 17:42:05 +08:00
|
|
|
pc.free_strings ();
|
|
|
|
*this = *reinterpret_cast<fhandler_socket_unix *> (x);
|
|
|
|
_copy_from_reset_helper ();
|
2018-02-24 03:59:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
fhandler_socket_unix *clone (cygheap_types malloc_type = HEAP_FHANDLER)
|
|
|
|
{
|
|
|
|
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_socket_unix));
|
|
|
|
fhandler_socket_unix *fh = new (ptr) fhandler_socket_unix (ptr);
|
2021-02-10 17:42:05 +08:00
|
|
|
fh->copy_from (this);
|
2018-02-24 03:59:21 +08:00
|
|
|
return fh;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-06-26 22:31:17 +08:00
|
|
|
#endif /* __WITH_AF_UNIX */
|
|
|
|
|
2021-09-04 07:41:52 +08:00
|
|
|
/* A parent of fhandler_pipe and fhandler_fifo. */
|
|
|
|
class fhandler_pipe_fifo: public fhandler_base
|
|
|
|
{
|
|
|
|
protected:
|
2021-09-08 05:40:21 +08:00
|
|
|
size_t pipe_buf_size;
|
2021-09-14 17:50:49 +08:00
|
|
|
virtual void release_select_sem (const char *) {};
|
2021-09-04 07:41:52 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
fhandler_pipe_fifo ();
|
|
|
|
|
2021-09-17 03:23:12 +08:00
|
|
|
virtual bool reader_closed () { return false; };
|
2022-05-24 03:52:52 +08:00
|
|
|
ssize_t raw_write (const void *ptr, size_t len);
|
2021-09-04 07:41:52 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class fhandler_pipe: public fhandler_pipe_fifo
|
2010-03-31 12:26:11 +08:00
|
|
|
{
|
|
|
|
private:
|
2021-09-03 16:48:40 +08:00
|
|
|
HANDLE read_mtx;
|
2010-03-31 12:26:11 +08:00
|
|
|
pid_t popen_pid;
|
2021-09-17 03:23:12 +08:00
|
|
|
HANDLE query_hdl;
|
|
|
|
HANDLE hdl_cnt_mtx;
|
2021-09-21 07:02:43 +08:00
|
|
|
HANDLE query_hdl_proc;
|
|
|
|
HANDLE query_hdl_value;
|
2022-03-22 21:49:46 +08:00
|
|
|
HANDLE query_hdl_close_req_evt;
|
2021-09-21 07:02:43 +08:00
|
|
|
uint64_t pipename_key;
|
|
|
|
DWORD pipename_pid;
|
|
|
|
LONG pipename_id;
|
2021-09-14 17:50:49 +08:00
|
|
|
void release_select_sem (const char *);
|
2021-09-23 22:33:55 +08:00
|
|
|
HANDLE get_query_hdl_per_process (WCHAR *, OBJECT_NAME_INFORMATION *);
|
2010-03-31 12:26:11 +08:00
|
|
|
public:
|
|
|
|
fhandler_pipe ();
|
|
|
|
|
2009-08-18 23:21:47 +08:00
|
|
|
bool ispipe() const { return true; }
|
2021-09-08 05:40:21 +08:00
|
|
|
void set_pipe_buf_size ();
|
2009-08-18 23:21:47 +08:00
|
|
|
|
2006-12-12 02:55:29 +08:00
|
|
|
void set_popen_pid (pid_t pid) {popen_pid = pid;}
|
|
|
|
pid_t get_popen_pid () const {return popen_pid;}
|
2013-04-23 17:44:36 +08:00
|
|
|
off_t lseek (off_t offset, int whence);
|
2009-07-01 05:18:44 +08:00
|
|
|
select_record *select_read (select_stuff *);
|
|
|
|
select_record *select_write (select_stuff *);
|
|
|
|
select_record *select_except (select_stuff *);
|
2005-01-31 18:28:55 +08:00
|
|
|
char *get_proc_fd_name (char *buf);
|
2005-02-01 23:11:47 +08:00
|
|
|
int open (int flags, mode_t mode = 0);
|
2021-09-18 20:13:55 +08:00
|
|
|
bool open_setup (int flags);
|
2021-09-03 16:48:40 +08:00
|
|
|
void fixup_after_fork (HANDLE);
|
2011-10-16 06:37:30 +08:00
|
|
|
int dup (fhandler_base *child, int);
|
2021-09-14 11:49:35 +08:00
|
|
|
void set_close_on_exec (bool val);
|
2021-09-03 16:48:40 +08:00
|
|
|
int close ();
|
2022-05-24 03:52:52 +08:00
|
|
|
void raw_read (void *ptr, size_t& len);
|
2002-11-09 11:17:40 +08:00
|
|
|
int ioctl (unsigned int cmd, void *);
|
2019-05-26 01:05:49 +08:00
|
|
|
int fcntl (int cmd, intptr_t);
|
2022-05-24 03:52:52 +08:00
|
|
|
int fstat (struct stat *buf);
|
|
|
|
int fstatvfs (struct statvfs *buf);
|
|
|
|
int fadvise (off_t, off_t, int);
|
|
|
|
int ftruncate (off_t, bool);
|
2016-01-11 19:35:41 +08:00
|
|
|
int init (HANDLE, DWORD, mode_t, int64_t);
|
2007-07-10 09:21:03 +08:00
|
|
|
static int create (fhandler_pipe *[2], unsigned, int);
|
2011-11-24 02:56:57 +08:00
|
|
|
static DWORD create (LPSECURITY_ATTRIBUTES, HANDLE *, HANDLE *, DWORD,
|
2016-01-11 19:35:41 +08:00
|
|
|
const char *, DWORD, int64_t *unique_id = NULL);
|
2011-10-16 06:37:30 +08:00
|
|
|
fhandler_pipe (void *) {}
|
|
|
|
|
2021-02-10 17:42:05 +08:00
|
|
|
void copy_from (fhandler_base *x)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2021-02-10 17:42:05 +08:00
|
|
|
pc.free_strings ();
|
|
|
|
*this = *reinterpret_cast<fhandler_pipe *> (x);
|
|
|
|
_copy_from_reset_helper ();
|
2011-10-16 06:37:30 +08:00
|
|
|
}
|
|
|
|
|
2011-11-29 23:34:49 +08:00
|
|
|
fhandler_pipe *clone (cygheap_types malloc_type = HEAP_FHANDLER)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2011-11-29 23:34:49 +08:00
|
|
|
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_pipe));
|
2011-10-30 12:50:36 +08:00
|
|
|
fhandler_pipe *fh = new (ptr) fhandler_pipe (ptr);
|
2021-02-10 17:42:05 +08:00
|
|
|
fh->copy_from (this);
|
2011-10-16 06:37:30 +08:00
|
|
|
return fh;
|
|
|
|
}
|
Cygwin: pipe: Use read pipe handle for select() on write pipe.
- Usually WriteQuotaAvailable retrieved by NtQueryInformationFile()
on the write side reflects the space available in the inbound buffer
on the read side. However, if a pipe read is currently pending,
WriteQuotaAvailable on the write side is decremented by the number
of bytes the read side is requesting. So it's possible (even likely)
that WriteQuotaAvailable is 0, even if the inbound buffer on the
read side is not full. This can lead to a deadlock situation:
The reader is waiting for data, but select on the writer side
assumes that no space is available in the read side inbound buffer.
Currently, to avoid this stuation, read() does not request larger
block than pipe size - 1. However, this mechanism does not take
effect if the reader side is non-cygwin app.
The only reliable information is available on the read side, so
fetch info from the read side via the pipe-specific query handle
(query_hdl) introduced.
If the query_hdl (read handle) is kept in write side, writer can
not detect closure of read pipe. Therefore, raw_write() counts
write handle and query_hdl. If they are equal, only the pairs of
write handle and query_hdl are alive. In this case, raw_write()
returns EPIPE and raises SIGPIPE.
- Nonblocking pipes (PIPE_NOWAIT) are not well handled by non-Cygwin
tools, so convert pipe handles to PIPE_WAIT handles when spawning
a non-Cygwin process.
2021-09-14 18:10:48 +08:00
|
|
|
void set_pipe_non_blocking (bool nonblocking);
|
2021-09-17 03:23:12 +08:00
|
|
|
HANDLE get_query_handle () const { return query_hdl; }
|
|
|
|
void close_query_handle ()
|
|
|
|
{
|
|
|
|
if (query_hdl)
|
|
|
|
{
|
|
|
|
CloseHandle (query_hdl);
|
|
|
|
query_hdl = NULL;
|
|
|
|
}
|
2022-03-22 21:49:46 +08:00
|
|
|
if (query_hdl_close_req_evt)
|
|
|
|
{
|
|
|
|
CloseHandle (query_hdl_close_req_evt);
|
|
|
|
query_hdl_close_req_evt = NULL;
|
|
|
|
}
|
2021-09-17 03:23:12 +08:00
|
|
|
}
|
|
|
|
bool reader_closed ();
|
2021-09-21 07:02:43 +08:00
|
|
|
HANDLE temporary_query_hdl ();
|
2022-03-22 21:49:46 +08:00
|
|
|
bool need_close_query_hdl ()
|
|
|
|
{
|
|
|
|
return query_hdl_close_req_evt ?
|
|
|
|
IsEventSignalled (query_hdl_close_req_evt) : false;
|
|
|
|
}
|
|
|
|
bool request_close_query_hdl ()
|
|
|
|
{
|
|
|
|
if (query_hdl_close_req_evt)
|
|
|
|
{
|
|
|
|
SetEvent (query_hdl_close_req_evt);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
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 08:37:18 +08:00
|
|
|
};
|
|
|
|
|
2019-03-23 03:30:36 +08:00
|
|
|
#define CYGWIN_FIFO_PIPE_NAME_LEN 47
|
2019-03-23 03:30:37 +08:00
|
|
|
|
|
|
|
enum fifo_client_connect_state
|
2019-06-22 23:49:44 +08:00
|
|
|
{
|
|
|
|
fc_unknown,
|
2020-05-07 06:39:26 +08:00
|
|
|
fc_error,
|
|
|
|
fc_disconnected,
|
|
|
|
fc_closing,
|
2020-08-03 21:35:00 +08:00
|
|
|
fc_listening,
|
2020-05-10 05:25:39 +08:00
|
|
|
fc_connected,
|
2020-05-07 06:39:26 +08:00
|
|
|
fc_input_avail,
|
2019-06-22 23:49:44 +08:00
|
|
|
};
|
2019-03-23 03:30:37 +08:00
|
|
|
|
|
|
|
struct fifo_client_handler
|
|
|
|
{
|
2020-03-17 06:04:28 +08:00
|
|
|
HANDLE h;
|
2020-08-03 21:32:30 +08:00
|
|
|
fifo_client_connect_state _state;
|
2020-07-12 02:34:24 +08:00
|
|
|
bool last_read; /* true if our last successful read was from this client. */
|
2020-08-03 21:32:30 +08:00
|
|
|
fifo_client_handler () : h (NULL), _state (fc_unknown), last_read (false) {}
|
2020-03-17 06:04:28 +08:00
|
|
|
void close () { NtClose (h); }
|
2020-08-03 21:32:30 +08:00
|
|
|
fifo_client_connect_state get_state () const { return _state; }
|
|
|
|
void set_state (fifo_client_connect_state s) { _state = s; }
|
|
|
|
/* Query O/S. Return previous state. */
|
|
|
|
fifo_client_connect_state query_and_set_state ();
|
2019-03-23 03:30:37 +08:00
|
|
|
};
|
2019-03-23 03:30:36 +08:00
|
|
|
|
2020-03-26 07:22:10 +08:00
|
|
|
class fhandler_fifo;
|
|
|
|
|
|
|
|
struct fifo_reader_id_t
|
|
|
|
{
|
|
|
|
DWORD winpid;
|
|
|
|
fhandler_fifo *fh;
|
|
|
|
|
|
|
|
operator bool () const { return winpid != 0 || fh != NULL; }
|
|
|
|
|
2020-05-09 02:00:24 +08:00
|
|
|
friend bool operator == (const fifo_reader_id_t &l, const fifo_reader_id_t &r)
|
2020-03-26 07:22:10 +08:00
|
|
|
{
|
|
|
|
return l.winpid == r.winpid && l.fh == r.fh;
|
|
|
|
}
|
|
|
|
|
2020-05-09 02:00:24 +08:00
|
|
|
friend bool operator != (const fifo_reader_id_t &l, const fifo_reader_id_t &r)
|
2020-03-26 07:22:10 +08:00
|
|
|
{
|
|
|
|
return l.winpid != r.winpid || l.fh != r.fh;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
Cygwin: FIFO: keep a writer count in shared memory
When a reader opens, it needs to block if there are no writers open
(unless is is opened with O_NONBLOCK). This is easy for the first
reader to test, since it can just wait for a writer to signal that it
is open (via the write_ready event). But when a second reader wants
to open, all writers might have closed.
To check this, use a new '_nwriters' member of struct fifo_shmem_t,
which keeps track of the number of open writers. This should be more
reliable than the previous method.
Add nwriters_lock to control access to shmem->_nwriters, and remove
reader_opening_lock, which is no longer needed.
Previously only readers had access to the shared memory, but now
writers access it too so that they can increment _nwriters during
open/dup/fork/exec and decrement it during close.
Add an optional 'only_open' argument to create_shmem for use by
writers, which only open the shared memory rather than first trying to
create it. Since writers don't need to access the shared memory until
they have successfully connected to a pipe instance, they can safely
assume that a reader has already created the shared memory.
For debugging purposes, change create_shmem to return 1 instead of 0
when a reader successfully opens the shared memory after finding that
it had already been created.
Remove check_write_ready_evt, write_ready_ok_evt, and
check_write_ready(), which are no longer needed.
When opening a writer and looping to try to get a connection, recheck
read_ready at the top of the loop since the number of readers might
have changed.
To slightly speed up the process of opening the first reader, take
ownership immediately rather than waiting for the fifo_reader_thread
to handle it.
2020-07-12 02:05:23 +08:00
|
|
|
/* Info needed by all fhandlers for a given FIFO, stored in named
|
|
|
|
shared memory. This is mostly for readers, but writers need access
|
|
|
|
in order to update the count of open writers. */
|
2020-03-18 00:29:56 +08:00
|
|
|
class fifo_shmem_t
|
|
|
|
{
|
Cygwin: FIFO: keep a writer count in shared memory
When a reader opens, it needs to block if there are no writers open
(unless is is opened with O_NONBLOCK). This is easy for the first
reader to test, since it can just wait for a writer to signal that it
is open (via the write_ready event). But when a second reader wants
to open, all writers might have closed.
To check this, use a new '_nwriters' member of struct fifo_shmem_t,
which keeps track of the number of open writers. This should be more
reliable than the previous method.
Add nwriters_lock to control access to shmem->_nwriters, and remove
reader_opening_lock, which is no longer needed.
Previously only readers had access to the shared memory, but now
writers access it too so that they can increment _nwriters during
open/dup/fork/exec and decrement it during close.
Add an optional 'only_open' argument to create_shmem for use by
writers, which only open the shared memory rather than first trying to
create it. Since writers don't need to access the shared memory until
they have successfully connected to a pipe instance, they can safely
assume that a reader has already created the shared memory.
For debugging purposes, change create_shmem to return 1 instead of 0
when a reader successfully opens the shared memory after finding that
it had already been created.
Remove check_write_ready_evt, write_ready_ok_evt, and
check_write_ready(), which are no longer needed.
When opening a writer and looping to try to get a connection, recheck
read_ready at the top of the loop since the number of readers might
have changed.
To slightly speed up the process of opening the first reader, take
ownership immediately rather than waiting for the fifo_reader_thread
to handle it.
2020-07-12 02:05:23 +08:00
|
|
|
LONG _nreaders, _nwriters;
|
2022-09-23 22:24:04 +08:00
|
|
|
/* Set to 1 the first time a writer opens. */
|
|
|
|
LONG _writer_opened;
|
2020-04-25 21:54:18 +08:00
|
|
|
fifo_reader_id_t _owner, _prev_owner, _pending_owner;
|
Cygwin: FIFO: keep a writer count in shared memory
When a reader opens, it needs to block if there are no writers open
(unless is is opened with O_NONBLOCK). This is easy for the first
reader to test, since it can just wait for a writer to signal that it
is open (via the write_ready event). But when a second reader wants
to open, all writers might have closed.
To check this, use a new '_nwriters' member of struct fifo_shmem_t,
which keeps track of the number of open writers. This should be more
reliable than the previous method.
Add nwriters_lock to control access to shmem->_nwriters, and remove
reader_opening_lock, which is no longer needed.
Previously only readers had access to the shared memory, but now
writers access it too so that they can increment _nwriters during
open/dup/fork/exec and decrement it during close.
Add an optional 'only_open' argument to create_shmem for use by
writers, which only open the shared memory rather than first trying to
create it. Since writers don't need to access the shared memory until
they have successfully connected to a pipe instance, they can safely
assume that a reader has already created the shared memory.
For debugging purposes, change create_shmem to return 1 instead of 0
when a reader successfully opens the shared memory after finding that
it had already been created.
Remove check_write_ready_evt, write_ready_ok_evt, and
check_write_ready(), which are no longer needed.
When opening a writer and looping to try to get a connection, recheck
read_ready at the top of the loop since the number of readers might
have changed.
To slightly speed up the process of opening the first reader, take
ownership immediately rather than waiting for the fifo_reader_thread
to handle it.
2020-07-12 02:05:23 +08:00
|
|
|
af_unix_spinlock_t _owner_lock, _reading_lock, _nreaders_lock, _nwriters_lock;
|
2020-03-27 21:43:30 +08:00
|
|
|
|
2020-04-24 06:43:42 +08:00
|
|
|
/* Info about shared memory block used for temporary storage of the
|
|
|
|
owner's fc_handler list. */
|
2020-04-25 21:54:18 +08:00
|
|
|
LONG _sh_nhandlers, _sh_shandlers, _sh_fc_handler_committed,
|
|
|
|
_sh_fc_handler_updated;
|
2020-04-24 06:43:42 +08:00
|
|
|
|
2020-03-27 21:43:30 +08:00
|
|
|
public:
|
2020-07-15 21:46:42 +08:00
|
|
|
int nreaders () const { return (int) _nreaders; }
|
2020-03-27 21:43:30 +08:00
|
|
|
int inc_nreaders () { return (int) InterlockedIncrement (&_nreaders); }
|
|
|
|
int dec_nreaders () { return (int) InterlockedDecrement (&_nreaders); }
|
Cygwin: FIFO: keep a writer count in shared memory
When a reader opens, it needs to block if there are no writers open
(unless is is opened with O_NONBLOCK). This is easy for the first
reader to test, since it can just wait for a writer to signal that it
is open (via the write_ready event). But when a second reader wants
to open, all writers might have closed.
To check this, use a new '_nwriters' member of struct fifo_shmem_t,
which keeps track of the number of open writers. This should be more
reliable than the previous method.
Add nwriters_lock to control access to shmem->_nwriters, and remove
reader_opening_lock, which is no longer needed.
Previously only readers had access to the shared memory, but now
writers access it too so that they can increment _nwriters during
open/dup/fork/exec and decrement it during close.
Add an optional 'only_open' argument to create_shmem for use by
writers, which only open the shared memory rather than first trying to
create it. Since writers don't need to access the shared memory until
they have successfully connected to a pipe instance, they can safely
assume that a reader has already created the shared memory.
For debugging purposes, change create_shmem to return 1 instead of 0
when a reader successfully opens the shared memory after finding that
it had already been created.
Remove check_write_ready_evt, write_ready_ok_evt, and
check_write_ready(), which are no longer needed.
When opening a writer and looping to try to get a connection, recheck
read_ready at the top of the loop since the number of readers might
have changed.
To slightly speed up the process of opening the first reader, take
ownership immediately rather than waiting for the fifo_reader_thread
to handle it.
2020-07-12 02:05:23 +08:00
|
|
|
int nwriters () const { return (int) _nwriters; }
|
|
|
|
int inc_nwriters () { return (int) InterlockedIncrement (&_nwriters); }
|
|
|
|
int dec_nwriters () { return (int) InterlockedDecrement (&_nwriters); }
|
Cygwin: FIFO: designate one reader as owner
Among all the open readers of a FIFO, one is declared to be the owner.
This is the only reader that listens for client connections, and it is
the only one that has an accurate fc_handler list.
Add shared data and methods for getting and setting the owner, as well
as a lock to prevent more than one reader from accessing these data
simultaneously.
Modify the fifo_reader_thread so that it checks the owner at the
beginning of its loop. If there is no owner, it takes ownership. If
there is an owner but it is a different reader, the thread just waits
to be canceled. Otherwise, it listens for client connections as
before.
Remove the 'first' argument from create_pipe_instance. It is not
needed, and it may be confusing in the future since only the owner
knows whether a pipe instance is the first.
When opening a reader, don't return until the fifo_reader_thread has
time to set an owner.
If the owner closes, indicate that there is no longer an owner.
Clear the child's fc_handler list in dup, and don't bother duplicating
the handles. The child never starts out as owner, so it can't use
those handles.
Do the same thing in fixup_after_fork in the close-on-exec case. In
the non-close-on-exec case, the child inherits an fc_handler list that
it can't use, but we can just leave it alone; the handles will be
closed when the child is closed.
2020-03-27 02:32:10 +08:00
|
|
|
|
2022-09-23 22:24:04 +08:00
|
|
|
bool writer_opened () const { return (bool) _writer_opened; }
|
|
|
|
void set_writer_opened () { InterlockedExchange (&_writer_opened, 1); }
|
|
|
|
|
Cygwin: FIFO: designate one reader as owner
Among all the open readers of a FIFO, one is declared to be the owner.
This is the only reader that listens for client connections, and it is
the only one that has an accurate fc_handler list.
Add shared data and methods for getting and setting the owner, as well
as a lock to prevent more than one reader from accessing these data
simultaneously.
Modify the fifo_reader_thread so that it checks the owner at the
beginning of its loop. If there is no owner, it takes ownership. If
there is an owner but it is a different reader, the thread just waits
to be canceled. Otherwise, it listens for client connections as
before.
Remove the 'first' argument from create_pipe_instance. It is not
needed, and it may be confusing in the future since only the owner
knows whether a pipe instance is the first.
When opening a reader, don't return until the fifo_reader_thread has
time to set an owner.
If the owner closes, indicate that there is no longer an owner.
Clear the child's fc_handler list in dup, and don't bother duplicating
the handles. The child never starts out as owner, so it can't use
those handles.
Do the same thing in fixup_after_fork in the close-on-exec case. In
the non-close-on-exec case, the child inherits an fc_handler list that
it can't use, but we can just leave it alone; the handles will be
closed when the child is closed.
2020-03-27 02:32:10 +08:00
|
|
|
fifo_reader_id_t get_owner () const { return _owner; }
|
|
|
|
void set_owner (fifo_reader_id_t fr_id) { _owner = fr_id; }
|
2020-04-24 06:43:42 +08:00
|
|
|
fifo_reader_id_t get_prev_owner () const { return _prev_owner; }
|
|
|
|
void set_prev_owner (fifo_reader_id_t fr_id) { _prev_owner = fr_id; }
|
2020-04-25 21:54:18 +08:00
|
|
|
fifo_reader_id_t get_pending_owner () const { return _pending_owner; }
|
|
|
|
void set_pending_owner (fifo_reader_id_t fr_id) { _pending_owner = fr_id; }
|
2020-04-24 06:43:42 +08:00
|
|
|
|
Cygwin: FIFO: designate one reader as owner
Among all the open readers of a FIFO, one is declared to be the owner.
This is the only reader that listens for client connections, and it is
the only one that has an accurate fc_handler list.
Add shared data and methods for getting and setting the owner, as well
as a lock to prevent more than one reader from accessing these data
simultaneously.
Modify the fifo_reader_thread so that it checks the owner at the
beginning of its loop. If there is no owner, it takes ownership. If
there is an owner but it is a different reader, the thread just waits
to be canceled. Otherwise, it listens for client connections as
before.
Remove the 'first' argument from create_pipe_instance. It is not
needed, and it may be confusing in the future since only the owner
knows whether a pipe instance is the first.
When opening a reader, don't return until the fifo_reader_thread has
time to set an owner.
If the owner closes, indicate that there is no longer an owner.
Clear the child's fc_handler list in dup, and don't bother duplicating
the handles. The child never starts out as owner, so it can't use
those handles.
Do the same thing in fixup_after_fork in the close-on-exec case. In
the non-close-on-exec case, the child inherits an fc_handler list that
it can't use, but we can just leave it alone; the handles will be
closed when the child is closed.
2020-03-27 02:32:10 +08:00
|
|
|
void owner_lock () { _owner_lock.lock (); }
|
|
|
|
void owner_unlock () { _owner_lock.unlock (); }
|
2020-04-25 21:54:18 +08:00
|
|
|
void reading_lock () { _reading_lock.lock (); }
|
|
|
|
void reading_unlock () { _reading_lock.unlock (); }
|
2020-07-15 21:46:42 +08:00
|
|
|
void nreaders_lock () { _nreaders_lock.lock (); }
|
|
|
|
void nreaders_unlock () { _nreaders_lock.unlock (); }
|
Cygwin: FIFO: keep a writer count in shared memory
When a reader opens, it needs to block if there are no writers open
(unless is is opened with O_NONBLOCK). This is easy for the first
reader to test, since it can just wait for a writer to signal that it
is open (via the write_ready event). But when a second reader wants
to open, all writers might have closed.
To check this, use a new '_nwriters' member of struct fifo_shmem_t,
which keeps track of the number of open writers. This should be more
reliable than the previous method.
Add nwriters_lock to control access to shmem->_nwriters, and remove
reader_opening_lock, which is no longer needed.
Previously only readers had access to the shared memory, but now
writers access it too so that they can increment _nwriters during
open/dup/fork/exec and decrement it during close.
Add an optional 'only_open' argument to create_shmem for use by
writers, which only open the shared memory rather than first trying to
create it. Since writers don't need to access the shared memory until
they have successfully connected to a pipe instance, they can safely
assume that a reader has already created the shared memory.
For debugging purposes, change create_shmem to return 1 instead of 0
when a reader successfully opens the shared memory after finding that
it had already been created.
Remove check_write_ready_evt, write_ready_ok_evt, and
check_write_ready(), which are no longer needed.
When opening a writer and looping to try to get a connection, recheck
read_ready at the top of the loop since the number of readers might
have changed.
To slightly speed up the process of opening the first reader, take
ownership immediately rather than waiting for the fifo_reader_thread
to handle it.
2020-07-12 02:05:23 +08:00
|
|
|
void nwriters_lock () { _nwriters_lock.lock (); }
|
|
|
|
void nwriters_unlock () { _nwriters_lock.unlock (); }
|
2020-04-24 06:43:42 +08:00
|
|
|
|
|
|
|
int get_shared_nhandlers () const { return (int) _sh_nhandlers; }
|
|
|
|
void set_shared_nhandlers (int n) { InterlockedExchange (&_sh_nhandlers, n); }
|
|
|
|
int get_shared_shandlers () const { return (int) _sh_shandlers; }
|
|
|
|
void set_shared_shandlers (int n) { InterlockedExchange (&_sh_shandlers, n); }
|
|
|
|
size_t get_shared_fc_handler_committed () const
|
|
|
|
{ return (size_t) _sh_fc_handler_committed; }
|
|
|
|
void set_shared_fc_handler_committed (size_t n)
|
|
|
|
{ InterlockedExchange (&_sh_fc_handler_committed, (LONG) n); }
|
2020-04-25 21:54:18 +08:00
|
|
|
bool shared_fc_handler_updated () const { return _sh_fc_handler_updated; }
|
|
|
|
void shared_fc_handler_updated (bool val)
|
|
|
|
{ InterlockedExchange (&_sh_fc_handler_updated, val); }
|
2020-03-18 00:29:56 +08:00
|
|
|
};
|
|
|
|
|
2021-09-04 07:41:52 +08:00
|
|
|
class fhandler_fifo: public fhandler_pipe_fifo
|
2007-07-08 01:00:33 +08:00
|
|
|
{
|
2020-04-26 21:38:46 +08:00
|
|
|
/* Handles to named events shared by all fhandlers for a given FIFO. */
|
|
|
|
HANDLE read_ready; /* A reader is open; OK for a writer to open. */
|
|
|
|
HANDLE write_ready; /* A writer is open; OK for a reader to open. */
|
|
|
|
HANDLE writer_opening; /* A writer is opening; no EOF. */
|
|
|
|
|
2020-04-24 21:05:12 +08:00
|
|
|
/* Handles to named events needed by all readers of a given FIFO. */
|
|
|
|
HANDLE owner_needed_evt; /* The owner is closing. */
|
|
|
|
HANDLE owner_found_evt; /* A new owner has taken over. */
|
2020-04-25 21:54:18 +08:00
|
|
|
HANDLE update_needed_evt; /* shared_fc_handler needs updating. */
|
2020-04-24 21:05:12 +08:00
|
|
|
|
2020-03-27 02:29:50 +08:00
|
|
|
/* Handles to non-shared events needed for fifo_reader_threads. */
|
|
|
|
HANDLE cancel_evt; /* Signal thread to terminate. */
|
|
|
|
HANDLE thr_sync_evt; /* The thread has terminated. */
|
2020-04-26 21:38:46 +08:00
|
|
|
|
2019-03-23 03:30:36 +08:00
|
|
|
UNICODE_STRING pipe_name;
|
2020-11-09 01:02:39 +08:00
|
|
|
PWCHAR pipe_name_buf;
|
2020-04-03 01:47:18 +08:00
|
|
|
fifo_client_handler *fc_handler; /* Dynamically growing array. */
|
|
|
|
int shandlers; /* Size (capacity) of the array. */
|
|
|
|
int nhandlers; /* Number of elements in the array. */
|
2019-03-23 03:30:38 +08:00
|
|
|
af_unix_spinlock_t _fifo_client_lock;
|
2019-04-15 03:15:57 +08:00
|
|
|
bool reader, writer, duplexer;
|
2020-03-26 07:22:10 +08:00
|
|
|
fifo_reader_id_t me;
|
2020-03-18 00:29:56 +08:00
|
|
|
|
|
|
|
HANDLE shmem_handle;
|
|
|
|
fifo_shmem_t *shmem;
|
2020-04-24 06:43:42 +08:00
|
|
|
HANDLE shared_fc_hdl;
|
|
|
|
/* Dynamically growing array in shared memory. */
|
|
|
|
fifo_client_handler *shared_fc_handler;
|
2020-03-18 00:29:56 +08:00
|
|
|
|
2022-05-24 03:52:52 +08:00
|
|
|
bool wait (HANDLE);
|
Cygwin: FIFO: designate one reader as owner
Among all the open readers of a FIFO, one is declared to be the owner.
This is the only reader that listens for client connections, and it is
the only one that has an accurate fc_handler list.
Add shared data and methods for getting and setting the owner, as well
as a lock to prevent more than one reader from accessing these data
simultaneously.
Modify the fifo_reader_thread so that it checks the owner at the
beginning of its loop. If there is no owner, it takes ownership. If
there is an owner but it is a different reader, the thread just waits
to be canceled. Otherwise, it listens for client connections as
before.
Remove the 'first' argument from create_pipe_instance. It is not
needed, and it may be confusing in the future since only the owner
knows whether a pipe instance is the first.
When opening a reader, don't return until the fifo_reader_thread has
time to set an owner.
If the owner closes, indicate that there is no longer an owner.
Clear the child's fc_handler list in dup, and don't bother duplicating
the handles. The child never starts out as owner, so it can't use
those handles.
Do the same thing in fixup_after_fork in the close-on-exec case. In
the non-close-on-exec case, the child inherits an fc_handler list that
it can't use, but we can just leave it alone; the handles will be
closed when the child is closed.
2020-03-27 02:32:10 +08:00
|
|
|
HANDLE create_pipe_instance ();
|
2019-05-09 23:36:26 +08:00
|
|
|
NTSTATUS open_pipe (HANDLE&);
|
2020-03-18 02:14:47 +08:00
|
|
|
NTSTATUS wait_open_pipe (HANDLE&);
|
2020-04-24 06:43:42 +08:00
|
|
|
int add_client_handler (bool new_pipe_instance = true);
|
2020-03-17 06:04:28 +08:00
|
|
|
void delete_client_handler (int);
|
2020-04-24 06:43:42 +08:00
|
|
|
void cleanup_handlers ();
|
|
|
|
void close_all_handlers ();
|
2020-03-27 02:29:50 +08:00
|
|
|
void cancel_reader_thread ();
|
|
|
|
|
Cygwin: FIFO: keep a writer count in shared memory
When a reader opens, it needs to block if there are no writers open
(unless is is opened with O_NONBLOCK). This is easy for the first
reader to test, since it can just wait for a writer to signal that it
is open (via the write_ready event). But when a second reader wants
to open, all writers might have closed.
To check this, use a new '_nwriters' member of struct fifo_shmem_t,
which keeps track of the number of open writers. This should be more
reliable than the previous method.
Add nwriters_lock to control access to shmem->_nwriters, and remove
reader_opening_lock, which is no longer needed.
Previously only readers had access to the shared memory, but now
writers access it too so that they can increment _nwriters during
open/dup/fork/exec and decrement it during close.
Add an optional 'only_open' argument to create_shmem for use by
writers, which only open the shared memory rather than first trying to
create it. Since writers don't need to access the shared memory until
they have successfully connected to a pipe instance, they can safely
assume that a reader has already created the shared memory.
For debugging purposes, change create_shmem to return 1 instead of 0
when a reader successfully opens the shared memory after finding that
it had already been created.
Remove check_write_ready_evt, write_ready_ok_evt, and
check_write_ready(), which are no longer needed.
When opening a writer and looping to try to get a connection, recheck
read_ready at the top of the loop since the number of readers might
have changed.
To slightly speed up the process of opening the first reader, take
ownership immediately rather than waiting for the fifo_reader_thread
to handle it.
2020-07-12 02:05:23 +08:00
|
|
|
int create_shmem (bool only_open = false);
|
2020-03-18 00:29:56 +08:00
|
|
|
int reopen_shmem ();
|
2020-04-24 06:43:42 +08:00
|
|
|
int create_shared_fc_handler ();
|
|
|
|
int reopen_shared_fc_handler ();
|
|
|
|
int remap_shared_fc_handler (size_t);
|
2020-03-18 00:29:56 +08:00
|
|
|
|
2020-07-15 21:46:42 +08:00
|
|
|
int nreaders () const { return shmem->nreaders (); }
|
2020-03-27 21:43:30 +08:00
|
|
|
int inc_nreaders () { return shmem->inc_nreaders (); }
|
|
|
|
int dec_nreaders () { return shmem->dec_nreaders (); }
|
Cygwin: FIFO: keep a writer count in shared memory
When a reader opens, it needs to block if there are no writers open
(unless is is opened with O_NONBLOCK). This is easy for the first
reader to test, since it can just wait for a writer to signal that it
is open (via the write_ready event). But when a second reader wants
to open, all writers might have closed.
To check this, use a new '_nwriters' member of struct fifo_shmem_t,
which keeps track of the number of open writers. This should be more
reliable than the previous method.
Add nwriters_lock to control access to shmem->_nwriters, and remove
reader_opening_lock, which is no longer needed.
Previously only readers had access to the shared memory, but now
writers access it too so that they can increment _nwriters during
open/dup/fork/exec and decrement it during close.
Add an optional 'only_open' argument to create_shmem for use by
writers, which only open the shared memory rather than first trying to
create it. Since writers don't need to access the shared memory until
they have successfully connected to a pipe instance, they can safely
assume that a reader has already created the shared memory.
For debugging purposes, change create_shmem to return 1 instead of 0
when a reader successfully opens the shared memory after finding that
it had already been created.
Remove check_write_ready_evt, write_ready_ok_evt, and
check_write_ready(), which are no longer needed.
When opening a writer and looping to try to get a connection, recheck
read_ready at the top of the loop since the number of readers might
have changed.
To slightly speed up the process of opening the first reader, take
ownership immediately rather than waiting for the fifo_reader_thread
to handle it.
2020-07-12 02:05:23 +08:00
|
|
|
int nwriters () const { return shmem->nwriters (); }
|
|
|
|
int inc_nwriters () { return shmem->inc_nwriters (); }
|
|
|
|
int dec_nwriters () { return shmem->dec_nwriters (); }
|
2022-09-23 22:24:04 +08:00
|
|
|
bool writer_opened () const { return shmem->writer_opened (); }
|
|
|
|
void set_writer_opened () { shmem->set_writer_opened (); }
|
2020-07-15 21:46:42 +08:00
|
|
|
void nreaders_lock () { shmem->nreaders_lock (); }
|
|
|
|
void nreaders_unlock () { shmem->nreaders_unlock (); }
|
Cygwin: FIFO: keep a writer count in shared memory
When a reader opens, it needs to block if there are no writers open
(unless is is opened with O_NONBLOCK). This is easy for the first
reader to test, since it can just wait for a writer to signal that it
is open (via the write_ready event). But when a second reader wants
to open, all writers might have closed.
To check this, use a new '_nwriters' member of struct fifo_shmem_t,
which keeps track of the number of open writers. This should be more
reliable than the previous method.
Add nwriters_lock to control access to shmem->_nwriters, and remove
reader_opening_lock, which is no longer needed.
Previously only readers had access to the shared memory, but now
writers access it too so that they can increment _nwriters during
open/dup/fork/exec and decrement it during close.
Add an optional 'only_open' argument to create_shmem for use by
writers, which only open the shared memory rather than first trying to
create it. Since writers don't need to access the shared memory until
they have successfully connected to a pipe instance, they can safely
assume that a reader has already created the shared memory.
For debugging purposes, change create_shmem to return 1 instead of 0
when a reader successfully opens the shared memory after finding that
it had already been created.
Remove check_write_ready_evt, write_ready_ok_evt, and
check_write_ready(), which are no longer needed.
When opening a writer and looping to try to get a connection, recheck
read_ready at the top of the loop since the number of readers might
have changed.
To slightly speed up the process of opening the first reader, take
ownership immediately rather than waiting for the fifo_reader_thread
to handle it.
2020-07-12 02:05:23 +08:00
|
|
|
void nwriters_lock () { shmem->nwriters_lock (); }
|
|
|
|
void nwriters_unlock () { shmem->nwriters_unlock (); }
|
2020-03-27 21:43:30 +08:00
|
|
|
|
2020-07-16 04:58:18 +08:00
|
|
|
fifo_reader_id_t get_owner () const { return shmem->get_owner (); }
|
|
|
|
void set_owner (fifo_reader_id_t fr_id) { shmem->set_owner (fr_id); }
|
2020-04-24 06:43:42 +08:00
|
|
|
fifo_reader_id_t get_prev_owner () const { return shmem->get_prev_owner (); }
|
|
|
|
void set_prev_owner (fifo_reader_id_t fr_id)
|
|
|
|
{ shmem->set_prev_owner (fr_id); }
|
2020-04-25 21:54:18 +08:00
|
|
|
fifo_reader_id_t get_pending_owner () const
|
|
|
|
{ return shmem->get_pending_owner (); }
|
|
|
|
void set_pending_owner (fifo_reader_id_t fr_id)
|
|
|
|
{ shmem->set_pending_owner (fr_id); }
|
2020-07-16 04:58:18 +08:00
|
|
|
void owner_lock () { shmem->owner_lock (); }
|
|
|
|
void owner_unlock () { shmem->owner_unlock (); }
|
2020-04-25 21:54:18 +08:00
|
|
|
|
2020-04-24 21:05:12 +08:00
|
|
|
void owner_needed ()
|
|
|
|
{
|
|
|
|
ResetEvent (owner_found_evt);
|
|
|
|
SetEvent (owner_needed_evt);
|
|
|
|
}
|
|
|
|
void owner_found ()
|
|
|
|
{
|
|
|
|
ResetEvent (owner_needed_evt);
|
|
|
|
SetEvent (owner_found_evt);
|
|
|
|
}
|
2020-04-24 06:43:42 +08:00
|
|
|
|
|
|
|
int get_shared_nhandlers () { return shmem->get_shared_nhandlers (); }
|
|
|
|
void set_shared_nhandlers (int n) { shmem->set_shared_nhandlers (n); }
|
|
|
|
int get_shared_shandlers () { return shmem->get_shared_shandlers (); }
|
|
|
|
void set_shared_shandlers (int n) { shmem->set_shared_shandlers (n); }
|
|
|
|
size_t get_shared_fc_handler_committed () const
|
|
|
|
{ return shmem->get_shared_fc_handler_committed (); }
|
|
|
|
void set_shared_fc_handler_committed (size_t n)
|
|
|
|
{ shmem->set_shared_fc_handler_committed (n); }
|
2020-05-19 22:14:10 +08:00
|
|
|
int update_my_handlers ();
|
2020-04-24 06:43:42 +08:00
|
|
|
int update_shared_handlers ();
|
2020-04-25 21:54:18 +08:00
|
|
|
bool shared_fc_handler_updated () const
|
|
|
|
{ return shmem->shared_fc_handler_updated (); }
|
|
|
|
void shared_fc_handler_updated (bool val)
|
|
|
|
{ shmem->shared_fc_handler_updated (val); }
|
2020-04-24 06:43:42 +08:00
|
|
|
|
2021-09-14 17:50:49 +08:00
|
|
|
void release_select_sem (const char *);
|
|
|
|
|
* 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 08:37:18 +08:00
|
|
|
public:
|
|
|
|
fhandler_fifo ();
|
2020-11-09 01:02:39 +08:00
|
|
|
~fhandler_fifo ()
|
|
|
|
{
|
|
|
|
if (pipe_name_buf)
|
|
|
|
cfree (pipe_name_buf);
|
|
|
|
}
|
2020-07-12 02:23:11 +08:00
|
|
|
/* Called if we appear to be at EOF after polling fc_handlers. */
|
|
|
|
bool hit_eof () const
|
|
|
|
{ return !nwriters () && !IsEventSignalled (writer_opening); }
|
2022-09-23 22:24:04 +08:00
|
|
|
/* Special EOF test needed by select.cc:peek_fifo(). */
|
|
|
|
bool select_hit_eof () const { return hit_eof () && writer_opened (); }
|
2019-04-15 03:15:56 +08:00
|
|
|
int get_nhandlers () const { return nhandlers; }
|
2020-05-10 05:25:39 +08:00
|
|
|
fifo_client_handler &get_fc_handler (int i) { return fc_handler[i]; }
|
2019-03-23 03:30:36 +08:00
|
|
|
PUNICODE_STRING get_pipe_name ();
|
2020-03-27 02:29:50 +08:00
|
|
|
DWORD fifo_reader_thread_func ();
|
2019-03-23 03:30:38 +08:00
|
|
|
void fifo_client_lock () { _fifo_client_lock.lock (); }
|
|
|
|
void fifo_client_unlock () { _fifo_client_lock.unlock (); }
|
2020-08-03 21:38:08 +08:00
|
|
|
void record_connection (fifo_client_handler&, bool = true,
|
|
|
|
fifo_client_connect_state = fc_connected);
|
2020-03-18 00:29:56 +08:00
|
|
|
|
2020-08-03 21:17:06 +08:00
|
|
|
int take_ownership (DWORD timeout = INFINITE);
|
2020-04-25 21:54:18 +08:00
|
|
|
void reading_lock () { shmem->reading_lock (); }
|
|
|
|
void reading_unlock () { shmem->reading_unlock (); }
|
|
|
|
|
2007-07-08 01:00:33 +08:00
|
|
|
int open (int, mode_t);
|
2018-10-10 19:20:04 +08:00
|
|
|
off_t lseek (off_t offset, int whence);
|
2009-07-25 04:54:33 +08:00
|
|
|
int close ();
|
2019-04-26 06:21:11 +08:00
|
|
|
int fcntl (int cmd, intptr_t);
|
2011-10-16 06:37:30 +08:00
|
|
|
int dup (fhandler_base *child, int);
|
2009-08-18 23:21:47 +08:00
|
|
|
bool isfifo () const { return true; }
|
2009-07-25 04:54:33 +08:00
|
|
|
void set_close_on_exec (bool val);
|
2022-05-24 03:52:52 +08:00
|
|
|
void raw_read (void *ptr, size_t& ulen);
|
2011-10-30 12:50:36 +08:00
|
|
|
void fixup_after_fork (HANDLE);
|
2019-04-18 23:39:52 +08:00
|
|
|
void fixup_after_exec ();
|
2022-05-24 03:52:52 +08:00
|
|
|
int fstat (struct stat *buf);
|
|
|
|
int fstatvfs (struct statvfs *buf);
|
2009-07-01 05:18:44 +08:00
|
|
|
select_record *select_read (select_stuff *);
|
|
|
|
select_record *select_write (select_stuff *);
|
|
|
|
select_record *select_except (select_stuff *);
|
2011-10-16 06:37:30 +08:00
|
|
|
|
|
|
|
fhandler_fifo (void *) {}
|
|
|
|
|
2021-02-10 17:42:05 +08:00
|
|
|
void copy_from (fhandler_base *x)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2021-02-10 17:42:05 +08:00
|
|
|
pc.free_strings ();
|
|
|
|
*this = *reinterpret_cast<fhandler_fifo *> (x);
|
|
|
|
_copy_from_reset_helper ();
|
2011-10-16 06:37:30 +08:00
|
|
|
}
|
|
|
|
|
2011-11-29 23:34:49 +08:00
|
|
|
fhandler_fifo *clone (cygheap_types malloc_type = HEAP_FHANDLER)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2011-11-29 23:34:49 +08:00
|
|
|
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_fifo));
|
2019-03-23 03:30:39 +08:00
|
|
|
fhandler_fifo *fhf = new (ptr) fhandler_fifo (ptr);
|
2021-02-10 17:42:05 +08:00
|
|
|
fhf->copy_from (this);
|
2020-11-09 01:02:39 +08:00
|
|
|
fhf->pipe_name_buf = NULL;
|
2019-03-23 03:30:39 +08:00
|
|
|
return fhf;
|
2011-10-16 06:37:30 +08:00
|
|
|
}
|
2000-02-18 03:38:33 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class fhandler_dev_raw: public fhandler_base
|
|
|
|
{
|
2001-11-02 05:15:53 +08:00
|
|
|
protected:
|
2012-10-13 20:34:18 +08:00
|
|
|
char *devbufalloc;
|
2000-02-18 03:38:33 +08:00
|
|
|
char *devbuf;
|
2013-04-23 17:44:36 +08:00
|
|
|
DWORD devbufalign;
|
|
|
|
DWORD devbufsiz;
|
|
|
|
DWORD devbufstart;
|
|
|
|
DWORD devbufend;
|
2004-04-10 04:39:19 +08:00
|
|
|
struct status_flags
|
|
|
|
{
|
|
|
|
unsigned lastblk_to_read : 1;
|
|
|
|
public:
|
2005-09-29 03:33:18 +08:00
|
|
|
status_flags () : lastblk_to_read (0) {}
|
2004-04-10 04:39:19 +08:00
|
|
|
} status;
|
2005-02-14 02:17:29 +08:00
|
|
|
|
2004-04-13 17:04:22 +08:00
|
|
|
IMPLEMENT_STATUS_FLAG (bool, lastblk_to_read)
|
2000-02-18 03:38:33 +08: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 08:37:18 +08:00
|
|
|
fhandler_dev_raw ();
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2001-11-02 05:15:53 +08:00
|
|
|
public:
|
2005-07-05 11:16:46 +08:00
|
|
|
~fhandler_dev_raw ();
|
2000-02-18 03:38:33 +08: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 08:37:18 +08:00
|
|
|
int open (int flags, mode_t mode = 0);
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2022-05-24 03:52:52 +08:00
|
|
|
int fstat (struct stat *buf);
|
2003-10-01 05:43:40 +08:00
|
|
|
|
2011-10-16 06:37:30 +08:00
|
|
|
int dup (fhandler_base *child, int);
|
2000-02-18 03:38:33 +08:00
|
|
|
int ioctl (unsigned int cmd, void *buf);
|
2000-11-01 06:20:59 +08:00
|
|
|
|
|
|
|
void fixup_after_fork (HANDLE);
|
2004-02-03 05:00:07 +08:00
|
|
|
void fixup_after_exec ();
|
2011-10-16 06:37:30 +08:00
|
|
|
|
|
|
|
fhandler_dev_raw (void *) {}
|
|
|
|
|
2021-02-10 17:42:05 +08:00
|
|
|
void copy_from (fhandler_base *x)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2021-02-10 17:42:05 +08:00
|
|
|
pc.free_strings ();
|
|
|
|
*this = *reinterpret_cast<fhandler_dev_raw *> (x);
|
|
|
|
_copy_from_reset_helper ();
|
2011-10-16 06:37:30 +08:00
|
|
|
}
|
|
|
|
|
2011-11-29 23:34:49 +08:00
|
|
|
fhandler_dev_raw *clone (cygheap_types malloc_type = HEAP_FHANDLER)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2011-11-29 23:34:49 +08:00
|
|
|
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_dev_raw));
|
2011-10-30 12:50:36 +08:00
|
|
|
fhandler_dev_raw *fh = new (ptr) fhandler_dev_raw (ptr);
|
2021-02-10 17:42:05 +08:00
|
|
|
fh->copy_from (this);
|
2011-10-16 06:37:30 +08:00
|
|
|
return fh;
|
|
|
|
}
|
2000-02-18 03:38:33 +08:00
|
|
|
};
|
|
|
|
|
2011-01-11 22:50:45 +08:00
|
|
|
#define MAX_PARTITIONS 15
|
|
|
|
|
2011-01-12 17:16:51 +08:00
|
|
|
struct part_t
|
|
|
|
{
|
|
|
|
LONG refcnt;
|
|
|
|
HANDLE hdl[MAX_PARTITIONS];
|
|
|
|
};
|
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
class fhandler_dev_floppy: public fhandler_dev_raw
|
|
|
|
{
|
2005-09-26 22:55:40 +08:00
|
|
|
private:
|
2013-04-23 17:44:36 +08:00
|
|
|
off_t drive_size;
|
2011-01-12 17:16:51 +08:00
|
|
|
part_t *partitions;
|
2005-09-29 03:33:18 +08:00
|
|
|
struct status_flags
|
|
|
|
{
|
|
|
|
unsigned eom_detected : 1;
|
|
|
|
public:
|
|
|
|
status_flags () : eom_detected (0) {}
|
|
|
|
} status;
|
|
|
|
|
|
|
|
IMPLEMENT_STATUS_FLAG (bool, eom_detected)
|
|
|
|
|
2013-04-23 17:44:36 +08:00
|
|
|
inline off_t get_current_position ();
|
2006-07-18 03:30:30 +08:00
|
|
|
int get_drive_info (struct hd_geometry *geo);
|
2005-09-26 22:55:40 +08:00
|
|
|
|
2011-01-12 17:16:51 +08:00
|
|
|
int lock_partition (DWORD to_write);
|
|
|
|
|
2005-09-29 03:33:18 +08: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-18 03:38:33 +08:00
|
|
|
|
2001-11-02 05:15:53 +08: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 08:37:18 +08:00
|
|
|
fhandler_dev_floppy ();
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2005-09-29 03:33:18 +08:00
|
|
|
int open (int flags, mode_t mode = 0);
|
2011-01-11 22:50:45 +08:00
|
|
|
int close ();
|
2011-10-16 06:37:30 +08:00
|
|
|
int dup (fhandler_base *child, int);
|
2022-05-24 03:52:52 +08:00
|
|
|
void raw_read (void *ptr, size_t& ulen);
|
|
|
|
ssize_t raw_write (const void *ptr, size_t ulen);
|
2013-04-23 17:44:36 +08:00
|
|
|
off_t lseek (off_t offset, int whence);
|
2005-09-29 03:33:18 +08:00
|
|
|
int ioctl (unsigned int cmd, void *buf);
|
2011-10-16 06:37:30 +08:00
|
|
|
|
|
|
|
fhandler_dev_floppy (void *) {}
|
|
|
|
|
2021-02-10 17:42:05 +08:00
|
|
|
void copy_from (fhandler_base *x)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2021-02-10 17:42:05 +08:00
|
|
|
pc.free_strings ();
|
|
|
|
*this = *reinterpret_cast<fhandler_dev_floppy *> (x);
|
|
|
|
_copy_from_reset_helper ();
|
2011-10-16 06:37:30 +08:00
|
|
|
}
|
|
|
|
|
2011-11-29 23:34:49 +08:00
|
|
|
fhandler_dev_floppy *clone (cygheap_types malloc_type = HEAP_FHANDLER)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2011-11-29 23:34:49 +08:00
|
|
|
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_dev_floppy));
|
2011-10-30 12:50:36 +08:00
|
|
|
fhandler_dev_floppy *fh = new (ptr) fhandler_dev_floppy (ptr);
|
2021-02-10 17:42:05 +08:00
|
|
|
fh->copy_from (this);
|
2011-10-16 06:37:30 +08:00
|
|
|
return fh;
|
|
|
|
}
|
2000-02-18 03:38:33 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class fhandler_dev_tape: public fhandler_dev_raw
|
|
|
|
{
|
2004-03-27 05:43:49 +08:00
|
|
|
HANDLE mt_mtx;
|
2013-04-23 17:44:36 +08:00
|
|
|
OVERLAPPED ov;
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2004-03-27 05:43:49 +08:00
|
|
|
bool is_rewind_device () { return get_minor () < 128; }
|
|
|
|
unsigned int driveno () { return (unsigned int) get_minor () & 0x7f; }
|
2005-07-05 11:16:46 +08:00
|
|
|
void drive_init ();
|
2001-10-16 22:53:26 +08:00
|
|
|
|
2011-05-04 20:23:00 +08:00
|
|
|
inline bool _lock (bool);
|
2004-03-27 05:43:49 +08:00
|
|
|
inline int unlock (int ret = 0);
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2001-11-02 05:15:53 +08: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 08:37:18 +08:00
|
|
|
fhandler_dev_tape ();
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2011-05-06 06:30:53 +08:00
|
|
|
int open (int flags, mode_t mode = 0);
|
2005-07-05 11:16:46 +08:00
|
|
|
virtual int close ();
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2022-05-24 03:52:52 +08:00
|
|
|
void raw_read (void *ptr, size_t& ulen);
|
|
|
|
ssize_t raw_write (const void *ptr, size_t ulen);
|
2004-03-27 05:43:49 +08:00
|
|
|
|
2013-04-23 17:44:36 +08:00
|
|
|
virtual off_t lseek (off_t offset, int whence);
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2022-05-24 03:52:52 +08:00
|
|
|
virtual int fstat (struct stat *buf);
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2011-10-16 06:37:30 +08:00
|
|
|
virtual int dup (fhandler_base *child, int);
|
2005-06-23 03:59:19 +08:00
|
|
|
virtual void fixup_after_fork (HANDLE parent);
|
|
|
|
virtual void set_close_on_exec (bool val);
|
2002-05-02 12:13:48 +08:00
|
|
|
virtual int ioctl (unsigned int cmd, void *buf);
|
2011-10-16 06:37:30 +08:00
|
|
|
|
|
|
|
fhandler_dev_tape (void *) {}
|
|
|
|
|
2021-02-10 17:42:05 +08:00
|
|
|
void copy_from (fhandler_base *x)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2021-02-10 17:42:05 +08:00
|
|
|
pc.free_strings ();
|
|
|
|
*this = *reinterpret_cast<fhandler_dev_tape *> (x);
|
|
|
|
_copy_from_reset_helper ();
|
2011-10-16 06:37:30 +08:00
|
|
|
}
|
|
|
|
|
2011-11-29 23:34:49 +08:00
|
|
|
fhandler_dev_tape *clone (cygheap_types malloc_type = HEAP_FHANDLER)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2011-11-29 23:34:49 +08:00
|
|
|
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_dev_tape));
|
2011-10-30 12:50:36 +08:00
|
|
|
fhandler_dev_tape *fh = new (ptr) fhandler_dev_tape (ptr);
|
2021-02-10 17:42:05 +08:00
|
|
|
fh->copy_from (this);
|
2011-10-16 06:37:30 +08:00
|
|
|
return fh;
|
|
|
|
}
|
2000-02-18 03:38:33 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Standard disk file */
|
|
|
|
|
|
|
|
class fhandler_disk_file: public fhandler_base
|
|
|
|
{
|
2011-06-17 19:04:44 +08:00
|
|
|
HANDLE prw_handle;
|
2018-07-24 13:31:58 +08:00
|
|
|
bool prw_handle_isasync;
|
2022-05-24 03:52:52 +08:00
|
|
|
int readdir_helper (DIR *, dirent *, DWORD, DWORD, PUNICODE_STRING fname);
|
2005-01-14 06:56:20 +08:00
|
|
|
|
2018-07-24 13:31:58 +08:00
|
|
|
int prw_open (bool, void *);
|
2018-12-26 06:38:52 +08:00
|
|
|
uint64_t fs_ioc_getflags ();
|
|
|
|
int fs_ioc_setflags (uint64_t);
|
2011-06-17 19:04:44 +08:00
|
|
|
|
2001-11-02 05:15:53 +08:00
|
|
|
public:
|
2001-10-14 01:23:35 +08:00
|
|
|
fhandler_disk_file ();
|
2005-02-20 19:44:32 +08:00
|
|
|
fhandler_disk_file (path_conv &pc);
|
2000-02-18 03:38:33 +08: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 08:37:18 +08:00
|
|
|
int open (int flags, mode_t mode);
|
2011-06-17 19:04:44 +08:00
|
|
|
int close ();
|
2013-06-02 18:22:14 +08:00
|
|
|
int fcntl (int cmd, intptr_t);
|
2011-10-16 06:37:30 +08:00
|
|
|
int dup (fhandler_base *child, int);
|
2011-06-17 19:04:44 +08:00
|
|
|
void fixup_after_fork (HANDLE parent);
|
2013-06-02 18:22:14 +08:00
|
|
|
int mand_lock (int, struct flock *);
|
2022-05-24 03:52:52 +08:00
|
|
|
int fstat (struct stat *buf);
|
|
|
|
int fchmod (mode_t mode);
|
|
|
|
int fchown (uid_t uid, gid_t gid);
|
|
|
|
int facl (int, int, struct acl *);
|
|
|
|
struct __acl_t *acl_get (uint32_t);
|
|
|
|
int acl_set (struct __acl_t *, uint32_t);
|
|
|
|
ssize_t fgetxattr (const char *, void *, size_t);
|
|
|
|
int fsetxattr (const char *, const void *, size_t, int);
|
|
|
|
int fadvise (off_t, off_t, int);
|
|
|
|
int ftruncate (off_t, bool);
|
|
|
|
int link (const char *);
|
|
|
|
int utimens (const struct timespec *);
|
|
|
|
int fstatvfs (struct statvfs *buf);
|
2018-12-26 06:38:52 +08:00
|
|
|
int ioctl (unsigned int cmd, void *buf);
|
2000-10-05 21:07:02 +08:00
|
|
|
|
2013-04-23 17:44:36 +08:00
|
|
|
HANDLE mmap (caddr_t *addr, size_t len, int prot, int flags, off_t off);
|
2000-10-08 01:35:36 +08:00
|
|
|
int munmap (HANDLE h, caddr_t addr, size_t len);
|
|
|
|
int msync (HANDLE h, caddr_t addr, size_t len, int flags);
|
2005-11-29 06:32:29 +08:00
|
|
|
bool fixup_mmap_after_fork (HANDLE h, int prot, int flags,
|
2016-05-21 03:48:10 +08:00
|
|
|
off_t offset, SIZE_T size, void *address);
|
2005-05-25 12:32:59 +08:00
|
|
|
int mkdir (mode_t mode);
|
|
|
|
int rmdir ();
|
2022-05-24 03:52:52 +08:00
|
|
|
DIR *opendir (int fd);
|
|
|
|
int readdir (DIR *, dirent *);
|
2010-07-06 00:59:56 +08:00
|
|
|
long telldir (DIR *);
|
|
|
|
void seekdir (DIR *, long);
|
2001-11-21 14:47:57 +08:00
|
|
|
void rewinddir (DIR *);
|
|
|
|
int closedir (DIR *);
|
2005-07-30 01:04:46 +08:00
|
|
|
|
2022-05-24 03:52:52 +08:00
|
|
|
ssize_t pread (void *, size_t, off_t, void *aio = NULL);
|
|
|
|
ssize_t pwrite (void *, size_t, off_t, void *aio = NULL);
|
2011-10-16 06:37:30 +08:00
|
|
|
|
|
|
|
fhandler_disk_file (void *) {}
|
2013-10-24 17:41:17 +08:00
|
|
|
dev_t get_dev () { return pc.fs_serial_number (); }
|
2011-10-16 06:37:30 +08:00
|
|
|
|
2021-02-10 17:42:05 +08:00
|
|
|
void copy_from (fhandler_base *x)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2021-02-10 17:42:05 +08:00
|
|
|
pc.free_strings ();
|
|
|
|
*this = *reinterpret_cast<fhandler_disk_file *> (x);
|
|
|
|
_copy_from_reset_helper ();
|
2011-10-16 06:37:30 +08:00
|
|
|
}
|
|
|
|
|
2011-11-29 23:34:49 +08:00
|
|
|
fhandler_disk_file *clone (cygheap_types malloc_type = HEAP_FHANDLER)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2011-11-29 23:34:49 +08:00
|
|
|
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_disk_file));
|
2011-10-30 12:50:36 +08:00
|
|
|
fhandler_disk_file *fh = new (ptr) fhandler_disk_file (ptr);
|
2021-02-10 17:42:05 +08:00
|
|
|
fh->copy_from (this);
|
2011-10-16 06:37:30 +08:00
|
|
|
return fh;
|
|
|
|
}
|
2000-02-18 03:38:33 +08:00
|
|
|
};
|
|
|
|
|
2012-03-30 02:02:54 +08:00
|
|
|
class fhandler_dev: public fhandler_disk_file
|
|
|
|
{
|
2016-06-23 22:56:41 +08:00
|
|
|
const struct _device *devidx;
|
2012-03-30 02:02:54 +08:00
|
|
|
bool dir_exists;
|
2016-06-23 22:56:41 +08:00
|
|
|
int drive, part;
|
2012-03-30 02:02:54 +08:00
|
|
|
public:
|
|
|
|
fhandler_dev ();
|
2012-04-02 19:08:07 +08:00
|
|
|
int open (int flags, mode_t mode);
|
|
|
|
int close ();
|
2022-05-24 03:52:52 +08:00
|
|
|
int fstat (struct stat *buf);
|
|
|
|
int fstatvfs (struct statvfs *buf);
|
2021-01-19 17:50:36 +08:00
|
|
|
int rmdir ();
|
2022-05-24 03:52:52 +08:00
|
|
|
DIR *opendir (int fd);
|
|
|
|
int readdir (DIR *, dirent *);
|
2012-03-30 02:02:54 +08:00
|
|
|
void rewinddir (DIR *);
|
|
|
|
|
|
|
|
fhandler_dev (void *) {}
|
2013-10-30 17:44:47 +08:00
|
|
|
dev_t get_dev () { return dir_exists ? pc.fs_serial_number ()
|
|
|
|
: get_device (); }
|
2012-03-30 02:02:54 +08:00
|
|
|
|
2021-02-10 17:42:05 +08:00
|
|
|
void copy_from (fhandler_base *x)
|
2012-03-30 02:02:54 +08:00
|
|
|
{
|
2021-02-10 17:42:05 +08:00
|
|
|
pc.free_strings ();
|
|
|
|
*this = *reinterpret_cast<fhandler_dev *> (x);
|
|
|
|
_copy_from_reset_helper ();
|
2012-03-30 02:02:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2021-02-10 17:42:05 +08:00
|
|
|
fh->copy_from (this);
|
2012-03-30 02:02:54 +08:00
|
|
|
return fh;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2001-11-22 13:59:07 +08:00
|
|
|
class fhandler_cygdrive: public fhandler_disk_file
|
|
|
|
{
|
|
|
|
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 08:37:18 +08:00
|
|
|
fhandler_cygdrive ();
|
2006-03-02 06:37:25 +08:00
|
|
|
int open (int flags, mode_t mode);
|
2022-05-24 03:52:52 +08:00
|
|
|
DIR *opendir (int fd);
|
|
|
|
int readdir (DIR *, dirent *);
|
2001-11-22 13:59:07 +08:00
|
|
|
void rewinddir (DIR *);
|
|
|
|
int closedir (DIR *);
|
2022-05-24 03:52:52 +08:00
|
|
|
int fstat (struct stat *buf);
|
|
|
|
int fstatvfs (struct statvfs *buf);
|
2011-10-16 06:37:30 +08:00
|
|
|
|
|
|
|
fhandler_cygdrive (void *) {}
|
2013-10-30 17:44:47 +08:00
|
|
|
dev_t get_dev () { return get_device (); }
|
2011-10-16 06:37:30 +08:00
|
|
|
|
2021-02-10 17:42:05 +08:00
|
|
|
void copy_from (fhandler_base *x)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2021-02-10 17:42:05 +08:00
|
|
|
pc.free_strings ();
|
|
|
|
*this = *reinterpret_cast<fhandler_cygdrive *> (x);
|
|
|
|
_copy_from_reset_helper ();
|
2011-10-16 06:37:30 +08:00
|
|
|
}
|
|
|
|
|
2011-11-29 23:34:49 +08:00
|
|
|
fhandler_cygdrive *clone (cygheap_types malloc_type = HEAP_FHANDLER)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2011-11-29 23:34:49 +08:00
|
|
|
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_cygdrive));
|
2011-10-30 12:50:36 +08:00
|
|
|
fhandler_cygdrive *fh = new (ptr) fhandler_cygdrive (ptr);
|
2021-02-10 17:42:05 +08:00
|
|
|
fh->copy_from (this);
|
2011-10-16 06:37:30 +08:00
|
|
|
return fh;
|
|
|
|
}
|
2001-11-22 13:59:07 +08:00
|
|
|
};
|
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
class fhandler_serial: public fhandler_base
|
|
|
|
{
|
2001-11-02 05:15:53 +08:00
|
|
|
private:
|
2020-03-18 00:45:05 +08:00
|
|
|
cc_t vmin_; /* from termios */
|
|
|
|
cc_t vtime_; /* from termios */
|
2000-02-18 03:38:33 +08:00
|
|
|
pid_t pgrp_;
|
2002-07-22 17:11:45 +08:00
|
|
|
int rts; /* for Windows 9x purposes only */
|
|
|
|
int dtr; /* for Windows 9x purposes only */
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2001-11-02 05:15:53 +08:00
|
|
|
public:
|
2000-02-18 03:38:33 +08: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 08:37:18 +08:00
|
|
|
fhandler_serial ();
|
2000-02-18 03:38:33 +08: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 08:37:18 +08:00
|
|
|
int open (int flags, mode_t mode);
|
2009-07-04 02:05:51 +08:00
|
|
|
int init (HANDLE h, DWORD a, mode_t flags);
|
2022-05-24 03:52:52 +08:00
|
|
|
void raw_read (void *ptr, size_t& ulen);
|
|
|
|
ssize_t raw_write (const void *ptr, size_t ulen);
|
2000-02-18 03:38:33 +08:00
|
|
|
int tcsendbreak (int);
|
|
|
|
int tcdrain ();
|
|
|
|
int tcflow (int);
|
2002-07-22 17:11:45 +08:00
|
|
|
int ioctl (unsigned int cmd, void *);
|
2005-08-02 17:17:15 +08:00
|
|
|
int switch_modem_lines (int set, int clr);
|
2000-02-18 03:38:33 +08:00
|
|
|
int tcsetattr (int a, const struct termios *t);
|
|
|
|
int tcgetattr (struct termios *t);
|
2014-08-18 19:09:56 +08:00
|
|
|
off_t lseek (off_t, int)
|
2020-03-11 20:36:41 +08:00
|
|
|
{
|
2014-08-18 19:09:56 +08:00
|
|
|
set_errno (ESPIPE);
|
|
|
|
return -1;
|
|
|
|
}
|
2000-02-18 03:38:33 +08:00
|
|
|
int tcflush (int);
|
2014-08-19 16:31:10 +08:00
|
|
|
bool is_tty () const { return true; }
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
/* We maintain a pgrp so that tcsetpgrp and tcgetpgrp work, but we
|
2011-06-15 05:48:43 +08:00
|
|
|
don't use it for permissions checking. fhandler_pty_slave does
|
2000-02-18 03:38:33 +08:00
|
|
|
permission checking on pgrps. */
|
|
|
|
virtual int tcgetpgrp () { return pgrp_; }
|
|
|
|
virtual int tcsetpgrp (const pid_t pid) { pgrp_ = pid; return 0; }
|
2009-07-01 05:18:44 +08:00
|
|
|
select_record *select_read (select_stuff *);
|
|
|
|
select_record *select_write (select_stuff *);
|
|
|
|
select_record *select_except (select_stuff *);
|
2011-10-16 06:37:30 +08:00
|
|
|
|
|
|
|
fhandler_serial (void *) {}
|
|
|
|
|
2021-02-10 17:42:05 +08:00
|
|
|
void copy_from (fhandler_base *x)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2021-02-10 17:42:05 +08:00
|
|
|
pc.free_strings ();
|
|
|
|
*this = *reinterpret_cast<fhandler_serial *> (x);
|
|
|
|
_copy_from_reset_helper ();
|
2011-10-16 06:37:30 +08:00
|
|
|
}
|
|
|
|
|
2011-11-29 23:34:49 +08:00
|
|
|
fhandler_serial *clone (cygheap_types malloc_type = HEAP_FHANDLER)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2011-11-29 23:34:49 +08:00
|
|
|
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_serial));
|
2011-10-30 12:50:36 +08:00
|
|
|
fhandler_serial *fh = new (ptr) fhandler_serial (ptr);
|
2021-02-10 17:42:05 +08:00
|
|
|
fh->copy_from (this);
|
2011-10-16 06:37:30 +08:00
|
|
|
return fh;
|
|
|
|
}
|
2000-02-18 03:38:33 +08:00
|
|
|
};
|
|
|
|
|
2019-03-31 23:47:48 +08:00
|
|
|
#define acquire_input_mutex(ms) \
|
|
|
|
__acquire_input_mutex (__PRETTY_FUNCTION__, __LINE__, ms)
|
|
|
|
|
|
|
|
#define release_input_mutex() \
|
|
|
|
__release_input_mutex (__PRETTY_FUNCTION__, __LINE__)
|
|
|
|
|
2000-09-07 09:18:37 +08:00
|
|
|
#define acquire_output_mutex(ms) \
|
2009-04-06 00:49:15 +08:00
|
|
|
__acquire_output_mutex (__PRETTY_FUNCTION__, __LINE__, ms)
|
2000-09-07 09:18:37 +08:00
|
|
|
|
|
|
|
#define release_output_mutex() \
|
2009-04-06 00:49:15 +08:00
|
|
|
__release_output_mutex (__PRETTY_FUNCTION__, __LINE__)
|
2000-09-07 09:18:37 +08:00
|
|
|
|
2022-03-02 15:00:31 +08:00
|
|
|
extern DWORD mutex_timeout;
|
2022-01-13 18:44:43 +08:00
|
|
|
DWORD acquire_attach_mutex (DWORD t);
|
|
|
|
void release_attach_mutex (void);
|
|
|
|
|
2000-09-08 00:23:51 +08:00
|
|
|
class tty;
|
|
|
|
class tty_min;
|
2000-02-18 03:38:33 +08:00
|
|
|
class fhandler_termios: public fhandler_base
|
|
|
|
{
|
2011-10-16 06:37:30 +08:00
|
|
|
private:
|
2000-02-18 03:38:33 +08:00
|
|
|
HANDLE output_handle;
|
2011-10-16 06:37:30 +08:00
|
|
|
protected:
|
2000-02-21 13:20:38 +08:00
|
|
|
virtual void doecho (const void *, DWORD) {};
|
2000-02-18 03:38:33 +08:00
|
|
|
virtual int accept_input () {return 1;};
|
2011-10-16 06:37:30 +08:00
|
|
|
int ioctl (int, void *);
|
2011-06-04 08:12:29 +08:00
|
|
|
tty_min *_tc;
|
2011-10-16 06:37:30 +08:00
|
|
|
tty *get_ttyp () {return (tty *) tc ();}
|
2020-08-19 19:25:21 +08:00
|
|
|
int eat_readahead (int n);
|
2021-01-28 22:11:32 +08:00
|
|
|
virtual void acquire_input_mutex_if_necessary (DWORD ms) {};
|
|
|
|
virtual void release_input_mutex_if_necessary (void) {};
|
2021-03-05 17:01:50 +08:00
|
|
|
virtual void discard_input () {};
|
2017-01-31 22:36:24 +08:00
|
|
|
|
2022-02-27 19:40:24 +08:00
|
|
|
/* Result status of processing keys in process_sigs(). */
|
2022-02-15 22:23:50 +08:00
|
|
|
enum process_sig_state {
|
2022-02-27 19:40:24 +08:00
|
|
|
signalled, /* Signalled normally */
|
|
|
|
not_signalled, /* Not signalled at all */
|
|
|
|
not_signalled_but_done, /* Not signalled, but CTRL_C_EVENT was sent. */
|
|
|
|
not_signalled_with_nat_reader, /* Not signalled, but detected non-cygwin
|
|
|
|
process may be reading the tty. */
|
|
|
|
done_with_debugger /* The key was processed (CTRL_C_EVENT was sent)
|
|
|
|
for inferior of GDB. */
|
2022-02-15 22:23:50 +08:00
|
|
|
};
|
|
|
|
|
2011-10-16 06:37:30 +08:00
|
|
|
public:
|
2022-03-10 19:20:00 +08:00
|
|
|
virtual pid_t tc_getpgid () { return 0; };
|
2011-10-16 06:37:30 +08:00
|
|
|
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 08:37:18 +08:00
|
|
|
fhandler_termios () :
|
|
|
|
fhandler_base ()
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2004-04-10 21:45:10 +08:00
|
|
|
need_fork_fixup (true);
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
2001-03-11 09:58:23 +08:00
|
|
|
HANDLE& get_output_handle () { return output_handle; }
|
2021-04-05 16:30:41 +08:00
|
|
|
HANDLE& get_output_handle_nat () { return output_handle; }
|
2022-02-15 22:23:50 +08:00
|
|
|
static process_sig_state process_sigs (char c, tty *ttyp,
|
|
|
|
fhandler_termios *fh);
|
2022-02-25 15:23:58 +08:00
|
|
|
static bool process_stop_start (char c, tty *ttyp);
|
2014-11-14 02:37:15 +08:00
|
|
|
line_edit_status line_edit (const char *rptr, size_t nread, termios&,
|
|
|
|
ssize_t *bytes_read = NULL);
|
2000-02-18 03:38:33 +08:00
|
|
|
void set_output_handle (HANDLE h) { output_handle = h; }
|
2011-06-04 08:12:29 +08:00
|
|
|
void tcinit (bool force);
|
2008-01-07 02:37:20 +08:00
|
|
|
bool is_tty () const { return true; }
|
2011-04-18 03:56:25 +08:00
|
|
|
void sigflush ();
|
2000-02-18 03:38:33 +08:00
|
|
|
int tcgetpgrp ();
|
|
|
|
int tcsetpgrp (int pid);
|
2016-07-27 02:03:07 +08:00
|
|
|
bg_check_types bg_check (int sig, bool dontsignal = false);
|
2000-09-07 09:18:37 +08:00
|
|
|
virtual DWORD __acquire_output_mutex (const char *fn, int ln, DWORD ms) {return 1;}
|
|
|
|
virtual void __release_output_mutex (const char *fn, int ln) {}
|
2001-05-10 02:53:55 +08:00
|
|
|
void echo_erase (int force = 0);
|
2013-04-23 17:44:36 +08:00
|
|
|
virtual off_t lseek (off_t, int);
|
2012-02-28 22:03:03 +08:00
|
|
|
pid_t tcgetsid ();
|
2011-10-16 06:37:30 +08:00
|
|
|
|
|
|
|
fhandler_termios (void *) {}
|
|
|
|
|
2021-02-10 17:42:05 +08:00
|
|
|
virtual void copy_from (fhandler_base *x)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2021-02-10 17:42:05 +08:00
|
|
|
pc.free_strings ();
|
|
|
|
*this = *reinterpret_cast<fhandler_termios *> (x);
|
|
|
|
_copy_from_reset_helper ();
|
2011-10-16 06:37:30 +08:00
|
|
|
}
|
|
|
|
|
2011-11-29 23:34:49 +08:00
|
|
|
virtual fhandler_termios *clone (cygheap_types malloc_type = HEAP_FHANDLER)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2011-11-29 23:34:49 +08:00
|
|
|
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_termios));
|
2011-10-30 12:50:36 +08:00
|
|
|
fhandler_termios *fh = new (ptr) fhandler_termios (ptr);
|
2021-02-10 17:42:05 +08:00
|
|
|
fh->copy_from (this);
|
2011-10-16 06:37:30 +08:00
|
|
|
return fh;
|
|
|
|
}
|
2022-02-13 11:03:45 +08:00
|
|
|
static bool path_iscygexec_a (LPCSTR n, LPSTR c);
|
|
|
|
static bool path_iscygexec_w (LPCWSTR n, LPWSTR c);
|
2022-02-15 22:23:50 +08:00
|
|
|
virtual void cleanup_before_exit () {}
|
2022-02-21 21:40:48 +08:00
|
|
|
virtual void setpgid_aux (pid_t pid) {}
|
2022-02-23 12:24:39 +08:00
|
|
|
virtual bool need_console_handler () { return false; }
|
2022-02-26 03:19:03 +08:00
|
|
|
virtual bool need_send_ctrl_c_event () { return true; }
|
2022-11-19 16:28:15 +08:00
|
|
|
|
|
|
|
struct ptys_handle_set_t
|
|
|
|
{
|
|
|
|
HANDLE from_master_nat;
|
|
|
|
HANDLE input_available_event;
|
|
|
|
HANDLE input_mutex;
|
|
|
|
HANDLE pipe_sw_mutex;
|
|
|
|
};
|
|
|
|
struct cons_handle_set_t
|
|
|
|
{
|
|
|
|
HANDLE input_handle;
|
|
|
|
HANDLE output_handle;
|
|
|
|
HANDLE input_mutex;
|
|
|
|
HANDLE output_mutex;
|
2022-12-22 20:05:31 +08:00
|
|
|
_minor_t unit;
|
2022-11-19 16:28:15 +08:00
|
|
|
};
|
|
|
|
class spawn_worker
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
ptys_handle_set_t ptys_handle_set;
|
|
|
|
cons_handle_set_t cons_handle_set;
|
|
|
|
bool ptys_need_cleanup;
|
|
|
|
bool cons_need_cleanup;
|
|
|
|
bool stdin_is_ptys;
|
|
|
|
tty *ptys_ttyp;
|
|
|
|
public:
|
|
|
|
spawn_worker () :
|
|
|
|
ptys_need_cleanup (false), cons_need_cleanup (false),
|
|
|
|
stdin_is_ptys (false), ptys_ttyp (NULL) {}
|
|
|
|
void setup (bool iscygwin, HANDLE h_stdin, const WCHAR *runpath,
|
|
|
|
bool nopcon, bool reset_sendsig, const WCHAR *envblock);
|
|
|
|
bool need_cleanup () { return ptys_need_cleanup || cons_need_cleanup; }
|
|
|
|
void cleanup ();
|
|
|
|
void close_handle_set ();
|
|
|
|
};
|
2000-02-18 03:38:33 +08:00
|
|
|
};
|
|
|
|
|
2001-02-27 17:14:35 +08:00
|
|
|
enum ansi_intensity
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2001-02-27 17:14:35 +08:00
|
|
|
INTENSITY_INVISIBLE,
|
|
|
|
INTENSITY_DIM,
|
|
|
|
INTENSITY_NORMAL,
|
|
|
|
INTENSITY_BOLD
|
|
|
|
};
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2002-10-08 14:16:16 +08: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
|
2009-12-19 23:37:10 +08:00
|
|
|
#define gotparen 8
|
|
|
|
#define gotrparen 9
|
2019-03-31 23:47:46 +08:00
|
|
|
#define eatpalette 10
|
|
|
|
#define endpalette 11
|
2020-02-01 12:28:39 +08:00
|
|
|
#define MAXARGS 16
|
2001-02-27 17:14:35 +08:00
|
|
|
|
2014-01-05 07:58:32 +08:00
|
|
|
enum cltype
|
|
|
|
{
|
|
|
|
cl_curr_pos = 1,
|
|
|
|
cl_disp_beg,
|
2014-01-31 12:23:22 +08:00
|
|
|
cl_disp_end,
|
|
|
|
cl_buf_beg,
|
|
|
|
cl_buf_end
|
2014-01-05 07:58:32 +08:00
|
|
|
};
|
|
|
|
|
2002-10-08 14:16:16 +08:00
|
|
|
class dev_console
|
2001-02-27 17:14:35 +08:00
|
|
|
{
|
2019-03-31 23:47:46 +08:00
|
|
|
pid_t owner;
|
2019-11-07 00:29:29 +08:00
|
|
|
bool is_legacy;
|
2022-06-14 20:01:58 +08:00
|
|
|
bool orig_virtual_terminal_processing_mode;
|
2019-03-31 23:47:46 +08:00
|
|
|
|
2001-02-27 17:14:35 +08:00
|
|
|
WORD default_color, underline_color, dim_color;
|
|
|
|
|
2001-03-06 20:05:45 +08:00
|
|
|
/* Used to determine if an input keystroke should be modified with META. */
|
|
|
|
int meta_mask;
|
|
|
|
|
2001-02-27 17:14:35 +08:00
|
|
|
/* Output state */
|
2014-02-16 09:48:25 +08:00
|
|
|
int state;
|
|
|
|
int args[MAXARGS];
|
|
|
|
int nargs;
|
2001-02-27 17:14:35 +08:00
|
|
|
unsigned rarg;
|
2001-11-02 12:44:06 +08:00
|
|
|
bool saw_question_mark;
|
2009-12-19 23:37:10 +08:00
|
|
|
bool saw_greater_than_sign;
|
2013-01-11 19:04:50 +08:00
|
|
|
bool saw_space;
|
2020-02-27 10:33:50 +08:00
|
|
|
bool saw_exclamation_mark;
|
2010-03-31 12:39:13 +08:00
|
|
|
bool vt100_graphics_mode_G0;
|
|
|
|
bool vt100_graphics_mode_G1;
|
|
|
|
bool iso_2022_G1;
|
2003-10-16 22:08:28 +08:00
|
|
|
bool alternate_charset_active;
|
2006-07-03 23:29:10 +08:00
|
|
|
bool metabit;
|
2010-04-12 03:11:17 +08:00
|
|
|
char backspace_keycode;
|
2020-03-02 09:12:57 +08:00
|
|
|
bool screen_alternated; /* For xterm compatible mode only */
|
2001-02-27 17:14:35 +08:00
|
|
|
|
|
|
|
char my_title_buf [TITLESIZE + 1];
|
|
|
|
|
|
|
|
WORD current_win32_attr;
|
|
|
|
ansi_intensity intensity;
|
2001-11-02 12:44:06 +08:00
|
|
|
bool underline, blink, reverse;
|
2001-02-27 17:14:35 +08:00
|
|
|
WORD fg, bg;
|
|
|
|
|
|
|
|
/* saved cursor coordinates */
|
|
|
|
int savex, savey;
|
|
|
|
|
2001-03-30 19:10:13 +08:00
|
|
|
|
2001-02-27 17:14:35 +08:00
|
|
|
struct
|
|
|
|
{
|
2014-03-10 06:49:56 +08:00
|
|
|
short Top;
|
|
|
|
short Bottom;
|
2001-02-27 17:14:35 +08:00
|
|
|
} scroll_region;
|
2014-02-16 09:48:25 +08:00
|
|
|
|
2014-03-11 02:18:56 +08:00
|
|
|
CONSOLE_SCREEN_BUFFER_INFO b;
|
2014-02-16 09:48:25 +08:00
|
|
|
COORD dwWinSize;
|
|
|
|
COORD dwEnd;
|
2001-02-27 17:14:35 +08:00
|
|
|
|
2014-03-10 06:49:56 +08:00
|
|
|
/* saved screen */
|
|
|
|
COORD save_bufsize;
|
|
|
|
PCHAR_INFO save_buf;
|
|
|
|
COORD save_cursor;
|
2014-04-27 01:38:22 +08:00
|
|
|
SHORT save_top;
|
2014-03-10 06:49:56 +08:00
|
|
|
|
2001-02-27 17:14:35 +08:00
|
|
|
COORD dwLastCursorPosition;
|
2009-12-16 22:56:10 +08:00
|
|
|
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 */
|
2001-02-27 17:14:35 +08:00
|
|
|
int nModifiers;
|
|
|
|
|
2001-11-02 12:44:06 +08:00
|
|
|
bool insert_mode;
|
2009-12-16 22:56:10 +08:00
|
|
|
int use_mouse;
|
2012-04-25 15:25:00 +08:00
|
|
|
bool ext_mouse_mode5;
|
2012-04-24 22:29:37 +08:00
|
|
|
bool ext_mouse_mode6;
|
|
|
|
bool ext_mouse_mode15;
|
2009-12-16 22:56:10 +08:00
|
|
|
bool use_focus;
|
2001-11-02 12:44:06 +08:00
|
|
|
bool raw_win32_keyboard_mode;
|
2016-03-16 17:25:16 +08:00
|
|
|
char cons_rabuf[40]; // cannot get longer than char buf[40] in char_command
|
|
|
|
char *cons_rapoi;
|
2020-05-30 17:25:03 +08:00
|
|
|
bool cursor_key_app_mode;
|
2022-02-23 12:24:39 +08:00
|
|
|
bool disable_master_thread;
|
2022-07-01 11:08:41 +08:00
|
|
|
bool master_thread_suspended;
|
2022-03-02 08:55:52 +08:00
|
|
|
int num_processed; /* Number of input events in the current input buffer
|
|
|
|
already processed by cons_master_thread(). */
|
2003-10-16 22:08:28 +08:00
|
|
|
|
2008-02-06 01:37:10 +08:00
|
|
|
inline UINT get_console_cp ();
|
2008-03-11 01:23:50 +08:00
|
|
|
DWORD con_to_str (char *d, int dlen, WCHAR w);
|
2016-07-21 04:05:59 +08:00
|
|
|
DWORD str_to_con (mbtowc_p, PWCHAR d, const char *s, DWORD sz);
|
2005-04-23 01:03:38 +08:00
|
|
|
void set_color (HANDLE);
|
|
|
|
void set_default_attr ();
|
2014-02-16 09:48:25 +08:00
|
|
|
int set_cl_x (cltype);
|
|
|
|
int set_cl_y (cltype);
|
|
|
|
bool fillin (HANDLE);
|
2022-05-24 03:52:52 +08:00
|
|
|
bool scroll_window (HANDLE, int, int, int, int);
|
|
|
|
void scroll_buffer (HANDLE, int, int, int, int, int, int);
|
|
|
|
void clear_screen (HANDLE, int, int, int, int);
|
|
|
|
void save_restore (HANDLE, char);
|
2003-10-16 22:08:28 +08:00
|
|
|
|
2002-10-08 14:16:16 +08:00
|
|
|
friend class fhandler_console;
|
|
|
|
};
|
|
|
|
|
2022-12-22 20:05:31 +08:00
|
|
|
#define MAX_CONS_DEV (sizeof (unsigned long) * 8)
|
|
|
|
|
2002-10-08 14:16:16 +08:00
|
|
|
/* This is a input and output console handle */
|
|
|
|
class fhandler_console: public fhandler_termios
|
|
|
|
{
|
2011-06-04 08:12:29 +08:00
|
|
|
public:
|
|
|
|
struct console_state
|
|
|
|
{
|
|
|
|
tty_min tty_min_state;
|
2014-03-10 06:49:56 +08:00
|
|
|
dev_console con;
|
2011-06-04 08:12:29 +08:00
|
|
|
};
|
2019-03-31 23:47:47 +08:00
|
|
|
bool input_ready;
|
|
|
|
enum input_states
|
|
|
|
{
|
|
|
|
input_error = -1,
|
|
|
|
input_processing = 0,
|
|
|
|
input_ok = 1,
|
|
|
|
input_signalled = 2,
|
|
|
|
input_winch = 3
|
|
|
|
};
|
2022-11-19 16:28:15 +08:00
|
|
|
typedef cons_handle_set_t handle_set_t;
|
2021-02-16 19:37:05 +08:00
|
|
|
HANDLE thread_sync_event;
|
2011-06-04 08:12:29 +08:00
|
|
|
private:
|
2009-05-04 11:51:16 +08:00
|
|
|
static const unsigned MAX_WRITE_CHARS;
|
2022-12-22 20:05:31 +08:00
|
|
|
static console_state *shared_console_info[MAX_CONS_DEV + 1];
|
2005-12-19 12:34:13 +08:00
|
|
|
static bool invisible_console;
|
2019-03-31 23:47:48 +08:00
|
|
|
HANDLE input_mutex, output_mutex;
|
2021-01-15 16:32:10 +08:00
|
|
|
handle_set_t handle_set;
|
2022-12-22 20:05:31 +08:00
|
|
|
_minor_t unit;
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2008-02-07 02:24:50 +08: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;
|
2008-03-11 01:23:50 +08:00
|
|
|
PWCHAR write_buf;
|
2008-02-07 02:24:50 +08:00
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
/* Output calls */
|
2001-02-27 17:14:35 +08:00
|
|
|
void set_default_attr ();
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2014-02-16 09:48:25 +08:00
|
|
|
void scroll_buffer (int, int, int, int, int, int);
|
2014-02-26 11:58:37 +08:00
|
|
|
void scroll_buffer_screen (int, int, int, int, int, int);
|
2022-05-24 03:52:52 +08:00
|
|
|
void clear_screen (cltype, cltype, cltype, cltype);
|
|
|
|
void cursor_set (bool, int, int);
|
|
|
|
void cursor_get (int *, int *);
|
|
|
|
void cursor_rel (int, int);
|
2009-05-04 11:51:16 +08:00
|
|
|
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 08:37:18 +08:00
|
|
|
const unsigned char *write_normal (unsigned const char*, unsigned const char *);
|
2001-02-27 17:14:35 +08:00
|
|
|
void char_command (char);
|
2003-12-08 06:37:12 +08:00
|
|
|
bool set_raw_win32_keyboard_mode (bool);
|
2022-12-22 20:05:31 +08:00
|
|
|
void set_console_title (char *);
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
/* Input calls */
|
|
|
|
int igncr_enabled ();
|
2000-07-29 12:19:24 +08:00
|
|
|
void set_cursor_maybe ();
|
2021-01-18 21:10:57 +08:00
|
|
|
static bool create_invisible_console_workaround (bool force);
|
2011-06-04 08:12:29 +08:00
|
|
|
static console_state *open_shared_console (HWND, HANDLE&, bool&);
|
2022-12-22 20:05:31 +08:00
|
|
|
static void fix_tab_position (HANDLE h, pid_t owner);
|
2022-02-16 14:43:42 +08:00
|
|
|
|
|
|
|
/* console mode calls */
|
|
|
|
const handle_set_t *get_handle_set (void) {return &handle_set;}
|
|
|
|
static void set_input_mode (tty::cons_mode m, const termios *t,
|
|
|
|
const handle_set_t *p);
|
|
|
|
static void set_output_mode (tty::cons_mode m, const termios *t,
|
|
|
|
const handle_set_t *p);
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2001-11-02 05:15:53 +08:00
|
|
|
public:
|
2022-03-10 19:20:00 +08:00
|
|
|
pid_t tc_getpgid ()
|
2012-01-12 03:07:11 +08:00
|
|
|
{
|
2022-12-22 20:05:31 +08:00
|
|
|
return shared_console_info[unit] ?
|
|
|
|
shared_console_info[unit]->tty_min_state.getpgid () : 0;
|
2012-01-12 03:07:11 +08:00
|
|
|
}
|
2011-06-13 04:15:26 +08:00
|
|
|
fhandler_console (fh_devices);
|
2011-06-04 08:12:29 +08:00
|
|
|
static console_state *open_shared_console (HWND hw, HANDLE& h)
|
|
|
|
{
|
|
|
|
bool createit = false;
|
|
|
|
return open_shared_console (hw, h, createit);
|
|
|
|
}
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
fhandler_console* is_console () { return this; }
|
|
|
|
|
2011-05-06 06:30:53 +08:00
|
|
|
bool use_archetype () const {return true;}
|
|
|
|
|
|
|
|
int open (int flags, mode_t mode);
|
2021-09-18 20:13:55 +08:00
|
|
|
bool open_setup (int flags);
|
2022-02-15 22:23:50 +08:00
|
|
|
void post_open_setup (int fd);
|
2011-10-16 06:37:30 +08:00
|
|
|
int dup (fhandler_base *, int);
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2022-05-24 03:52:52 +08:00
|
|
|
void read (void *ptr, size_t& len);
|
2022-06-07 00:00:45 +08:00
|
|
|
ssize_t write (const void *ptr, size_t len);
|
2021-02-16 19:37:05 +08:00
|
|
|
void doecho (const void *str, DWORD len);
|
2000-02-18 03:38:33 +08:00
|
|
|
int close ();
|
2022-03-02 15:00:31 +08:00
|
|
|
static bool exists ()
|
|
|
|
{
|
|
|
|
acquire_attach_mutex (mutex_timeout);
|
|
|
|
UINT cp = GetConsoleCP ();
|
|
|
|
release_attach_mutex ();
|
|
|
|
return !!cp;
|
|
|
|
}
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
int tcflush (int);
|
|
|
|
int tcsetattr (int a, const struct termios *t);
|
|
|
|
int tcgetattr (struct termios *t);
|
|
|
|
|
|
|
|
int ioctl (unsigned int cmd, void *);
|
2009-07-04 02:05:51 +08:00
|
|
|
int init (HANDLE, DWORD, mode_t);
|
2009-12-16 22:56:10 +08:00
|
|
|
bool mouse_aware (MOUSE_EVENT_RECORD& mouse_event);
|
2022-12-22 20:05:31 +08:00
|
|
|
bool focus_aware () {return shared_console_info[unit]->con.use_focus;}
|
2016-03-16 17:25:16 +08:00
|
|
|
bool get_cons_readahead_valid ()
|
|
|
|
{
|
2019-03-31 23:47:48 +08:00
|
|
|
acquire_input_mutex (INFINITE);
|
2022-12-22 20:05:31 +08:00
|
|
|
bool ret = shared_console_info[unit]->con.cons_rapoi != NULL &&
|
|
|
|
*shared_console_info[unit]->con.cons_rapoi;
|
2019-03-31 23:47:48 +08:00
|
|
|
release_input_mutex ();
|
|
|
|
return ret;
|
2016-03-16 17:25:16 +08:00
|
|
|
}
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2009-07-01 05:18:44 +08:00
|
|
|
select_record *select_read (select_stuff *);
|
|
|
|
select_record *select_write (select_stuff *);
|
|
|
|
select_record *select_except (select_stuff *);
|
2005-11-14 22:15:51 +08:00
|
|
|
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);}
|
2004-04-10 21:45:10 +08:00
|
|
|
void set_close_on_exec (bool val);
|
2019-03-31 23:47:47 +08:00
|
|
|
bool send_winch_maybe ();
|
2011-10-16 06:37:30 +08:00
|
|
|
void setup ();
|
2011-05-29 02:17:09 +08:00
|
|
|
bool set_unit ();
|
2021-01-18 21:10:57 +08:00
|
|
|
static bool need_invisible (bool force = false);
|
2012-02-08 00:54:14 +08:00
|
|
|
static void free_console ();
|
2016-01-31 06:33:36 +08:00
|
|
|
static const char *get_nonascii_key (INPUT_RECORD& input_rec, char *);
|
2011-10-16 06:37:30 +08:00
|
|
|
|
|
|
|
fhandler_console (void *) {}
|
|
|
|
|
2021-02-10 17:42:05 +08:00
|
|
|
void copy_from (fhandler_base *x)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2021-02-10 17:42:05 +08:00
|
|
|
pc.free_strings ();
|
|
|
|
*this = *reinterpret_cast<fhandler_console *> (x);
|
|
|
|
_copy_from_reset_helper ();
|
2011-10-16 06:37:30 +08:00
|
|
|
}
|
|
|
|
|
2011-11-29 23:34:49 +08:00
|
|
|
fhandler_console *clone (cygheap_types malloc_type = HEAP_FHANDLER)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2011-11-29 23:34:49 +08:00
|
|
|
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_console));
|
2011-10-30 12:50:36 +08:00
|
|
|
fhandler_console *fh = new (ptr) fhandler_console (ptr);
|
2021-02-10 17:42:05 +08:00
|
|
|
fh->copy_from (this);
|
2011-10-16 06:37:30 +08:00
|
|
|
return fh;
|
|
|
|
}
|
2019-03-31 23:47:47 +08:00
|
|
|
input_states process_input_message ();
|
2022-02-16 14:43:42 +08:00
|
|
|
bg_check_types bg_check (int sig, bool dontsignal = false);
|
2019-03-31 23:47:48 +08:00
|
|
|
void setup_io_mutex (void);
|
|
|
|
DWORD __acquire_input_mutex (const char *fn, int ln, DWORD ms);
|
|
|
|
void __release_input_mutex (const char *fn, int ln);
|
|
|
|
DWORD __acquire_output_mutex (const char *fn, int ln, DWORD ms);
|
|
|
|
void __release_output_mutex (const char *fn, int ln);
|
2021-01-28 22:11:32 +08:00
|
|
|
void acquire_input_mutex_if_necessary (DWORD ms)
|
|
|
|
{
|
|
|
|
acquire_input_mutex (ms);
|
|
|
|
}
|
|
|
|
void release_input_mutex_if_necessary (void)
|
|
|
|
{
|
|
|
|
release_input_mutex ();
|
|
|
|
}
|
2019-03-31 23:47:48 +08:00
|
|
|
|
2020-01-27 20:14:32 +08:00
|
|
|
char *&rabuf ();
|
|
|
|
size_t &ralen ();
|
|
|
|
size_t &raixget ();
|
|
|
|
size_t &raixput ();
|
|
|
|
size_t &rabuflen ();
|
|
|
|
|
2021-01-15 16:32:10 +08:00
|
|
|
void get_duplicated_handle_set (handle_set_t *p);
|
|
|
|
static void close_handle_set (handle_set_t *p);
|
|
|
|
|
2021-02-16 19:37:05 +08:00
|
|
|
static void cons_master_thread (handle_set_t *p, tty *ttyp);
|
2022-02-21 20:20:48 +08:00
|
|
|
void setup_for_non_cygwin_app ();
|
|
|
|
static void cleanup_for_non_cygwin_app (handle_set_t *p);
|
2022-02-16 14:43:42 +08:00
|
|
|
static void set_console_mode_to_native ();
|
2022-02-23 12:24:39 +08:00
|
|
|
bool need_console_handler ();
|
2022-07-29 20:40:18 +08:00
|
|
|
static void set_disable_master_thread (bool x, fhandler_console *cons = NULL);
|
2022-12-22 20:05:31 +08:00
|
|
|
static DWORD attach_console (pid_t, bool *err = NULL);
|
|
|
|
static void detach_console (DWORD, pid_t);
|
|
|
|
pid_t get_owner ();
|
|
|
|
void wpbuf_put (char c);
|
|
|
|
void wpbuf_send ();
|
|
|
|
int fstat (struct stat *buf);
|
2021-02-16 19:37:05 +08:00
|
|
|
|
2011-06-04 08:12:29 +08:00
|
|
|
friend tty_min * tty_list::get_cttyp ();
|
2000-02-18 03:38:33 +08:00
|
|
|
};
|
|
|
|
|
2011-06-15 05:48:43 +08:00
|
|
|
class fhandler_pty_common: public fhandler_termios
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2001-11-02 05:15:53 +08:00
|
|
|
public:
|
2011-06-15 05:48:43 +08:00
|
|
|
fhandler_pty_common ()
|
|
|
|
: fhandler_termios (),
|
2022-03-01 21:09:01 +08:00
|
|
|
output_mutex (NULL), input_mutex (NULL), pipe_sw_mutex (NULL),
|
2019-08-28 02:04:02 +08:00
|
|
|
input_available_event (NULL)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2011-06-17 07:00:00 +08:00
|
|
|
pc.file_attributes (FILE_ATTRIBUTE_NORMAL);
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
2011-11-24 02:56:57 +08:00
|
|
|
static const unsigned pipesize = 128 * 1024;
|
2022-03-01 21:09:01 +08:00
|
|
|
HANDLE output_mutex, input_mutex, pipe_sw_mutex;
|
2001-03-04 23:34:25 +08:00
|
|
|
HANDLE input_available_event;
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2011-10-12 07:20:38 +08:00
|
|
|
bool use_archetype () const {return true;}
|
2000-02-18 03:38:33 +08:00
|
|
|
DWORD __acquire_output_mutex (const char *fn, int ln, DWORD ms);
|
|
|
|
void __release_output_mutex (const char *fn, int ln);
|
|
|
|
|
|
|
|
int close ();
|
2013-04-23 17:44:36 +08:00
|
|
|
off_t lseek (off_t, int);
|
2012-04-05 10:54:51 +08:00
|
|
|
bool bytes_available (DWORD& n);
|
2004-04-10 21:45:10 +08:00
|
|
|
void set_close_on_exec (bool val);
|
2009-07-01 05:18:44 +08:00
|
|
|
select_record *select_read (select_stuff *);
|
|
|
|
select_record *select_write (select_stuff *);
|
|
|
|
select_record *select_except (select_stuff *);
|
2011-10-16 06:37:30 +08:00
|
|
|
|
|
|
|
fhandler_pty_common (void *) {}
|
|
|
|
|
2021-02-10 17:42:05 +08:00
|
|
|
virtual void copy_from (fhandler_base *x)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2021-02-10 17:42:05 +08:00
|
|
|
pc.free_strings ();
|
|
|
|
*this = *reinterpret_cast<fhandler_pty_common *> (x);
|
|
|
|
_copy_from_reset_helper ();
|
2011-10-16 06:37:30 +08:00
|
|
|
}
|
|
|
|
|
2011-11-29 23:34:49 +08:00
|
|
|
virtual fhandler_pty_common *clone (cygheap_types malloc_type = HEAP_FHANDLER)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2011-11-29 23:34:49 +08:00
|
|
|
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_pty_common));
|
2011-10-30 12:50:36 +08:00
|
|
|
fhandler_pty_common *fh = new (ptr) fhandler_pty_common (ptr);
|
2021-02-10 17:42:05 +08:00
|
|
|
fh->copy_from (this);
|
2011-10-16 06:37:30 +08:00
|
|
|
return fh;
|
|
|
|
}
|
2015-03-25 19:42:38 +08:00
|
|
|
|
2020-08-19 19:25:21 +08:00
|
|
|
void resize_pseudo_console (struct winsize *);
|
2021-01-28 11:26:14 +08:00
|
|
|
static DWORD get_console_process_id (DWORD pid, bool match,
|
|
|
|
bool cygwin = false,
|
|
|
|
bool stub_only = false);
|
2022-03-01 21:09:01 +08:00
|
|
|
bool to_be_read_from_nat_pipe (void);
|
2022-11-16 00:39:10 +08:00
|
|
|
static DWORD attach_console_temporarily (DWORD target_pid);
|
2022-03-02 20:35:40 +08:00
|
|
|
static void resume_from_temporarily_attach (DWORD resume_pid);
|
2019-08-28 02:04:02 +08:00
|
|
|
|
2015-03-25 19:42:38 +08:00
|
|
|
protected:
|
2021-01-15 16:32:13 +08:00
|
|
|
static BOOL process_opost_output (HANDLE h, const void *ptr, ssize_t& len,
|
|
|
|
bool is_echo, tty *ttyp,
|
|
|
|
bool is_nonblocking);
|
2000-02-18 03:38:33 +08:00
|
|
|
};
|
|
|
|
|
2011-06-15 05:48:43 +08:00
|
|
|
class fhandler_pty_slave: public fhandler_pty_common
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2006-06-02 23:41:34 +08:00
|
|
|
HANDLE inuse; // used to indicate that a tty is in use
|
2021-04-05 16:30:41 +08:00
|
|
|
HANDLE output_handle_nat, io_handle_nat;
|
2021-01-28 11:26:13 +08:00
|
|
|
HANDLE slave_reading;
|
|
|
|
LONG num_reader;
|
2010-04-20 03:52:43 +08:00
|
|
|
|
|
|
|
/* Helper functions for fchmod and fchown. */
|
2014-08-27 19:42:17 +08:00
|
|
|
bool fch_open_handles (bool chown);
|
2010-04-20 03:52:43 +08:00
|
|
|
int fch_set_sd (security_descriptor &sd, bool chown);
|
|
|
|
void fch_close_handles ();
|
|
|
|
|
2001-11-02 05:15:53 +08:00
|
|
|
public:
|
2022-03-10 19:20:00 +08:00
|
|
|
pid_t tc_getpgid () { return _tc ? _tc->pgid : 0; }
|
|
|
|
|
2022-11-19 16:28:15 +08:00
|
|
|
typedef ptys_handle_set_t handle_set_t;
|
2022-02-21 20:20:48 +08:00
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
/* Constructor */
|
2011-06-15 05:48:43 +08:00
|
|
|
fhandler_pty_slave (int);
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2021-04-05 16:30:41 +08:00
|
|
|
void set_output_handle_nat (HANDLE h) { output_handle_nat = h; }
|
|
|
|
HANDLE& get_output_handle_nat () { return output_handle_nat; }
|
|
|
|
void set_handle_nat (HANDLE h) { io_handle_nat = h; }
|
|
|
|
HANDLE& get_handle_nat () { return io_handle_nat; }
|
Fix OPOST for non-Cygwin pty slaves
* fhandler.h (class fhandler_base): Add virtual function
get_io_handle_cyg() to get handle from which OPOST-processed output is
read on PTY master.
(class fhandler_pty_slave): Add variable output_handle_cyg to store a
handle to which OPOST-processed output is written. Add two functions,
i.e., set_output_handle_cyg() and get_output_handle_cyg(), regarding
variable output_handle_cyg. Now, output_handle is used only by native
windows program. The data before OPOST-processing is written to
output_handle and OPOST-processing is applied in the master-side. For a
cygwin process, OPOST-processing is applied in the slave-side, and the
data after OPOST-processing is written to output_handle_cyg.
(class fhandler_pty_master): Add two variables, i.e., io_handle_cyg and
to_master_cyg, to store handles of a pipe through which OPOST-processed
output passes. Add pty_master_fwd_thread and function
pty_master_fwd_thread() for a thread which applies OPOST-processing
and forwards data from io_handle to to_master_cyg. Add function
get_io_handle_cyg() regarding variable io_handle_cyg. Now, the pipe
between io_handle and to_master are used only by native windows program
for applying OPOST-processing in the master-side. For a cygwin process,
the pipe between io_handle_cyg and to_master_cyg is used for passing
through the data which is applied OPOST-processing in the slave-side.
* fhandler_tty.cc (struct pipe_reply): Add member to_master_cyg.
(fhandler_pty_master::process_slave_output): Read slave output from
io_handle_cyg rather than io_handle.
(fhandler_pty_slave::fhandler_pty_salve): Initialize output_handle_cyg.
(fhandler_pty_slave::open): Set output_handle_cyg by duplicating handle
to_master_cyg on PTY master.
(fhandler_pty_slave::close): Close handle output_handle_cyg.
(fhandler_pty_slave::write): Write data to output_handle_cyg rather
than output_handle.
(fhandler_pty_slave::fch_close_handles): Close handle output_handle_cyg.
(fhandler_pty_master::fhandler_pty_master): Initialize io_handle_cyg,
to_master_cyg and master_fwd_thread.
(fhandler_pty_master::cleanup): Clean up to_master_cyg as well.
(fhandler_pty_master::close): Print to_master_cyg as well in debug
message. Terminate master forwarding thread. Close handles
to_master_cyg and io_handle_cyg.
(fhandler_pty_master::ioctl): Use io_handle_cyg rather than to_master.
(fhandler_pty_master::pty_master_thread): Add code for duplicating
handle to_master_cyg.
(fhandler_pty_master::pty_master_fwd_thread): New function for a thread
to forward OPOST-processed data from io_handle to to_master_cyg. This
thread applies OPOST-processing to the output of native windows program.
(::pty_master_fwd_thread): Ditto.
(fhandler_pty_master::setup): Create a new pipe to pass thruegh OPOST-
processed output. Create new thread to forward data from io_handle to
to_master_cyg. Set handle to_master_cyg to tty. Print io_handle_cyg as
well in debug message. Close handles io_handle_cyg and to_master_cyg in
case of error.
(fhandler_pty_master::fixup_after_fork): Set handle to_master_cyg to
tty. Copy handle to_master_cyg from arch->to_master_cyg.
(fhandler_pty_master::fixup_after_exec): Clean up to_master_cyg.
* select.cc: Check handle returned by get_io_handle_cyg() rather than
get_handle().
* tty.h (class tty): Add variable _to_master_cyg to store a handle to
which OPOST-processed data is written. Add two functions,
to_master_cyg() and set_to_master_cyg(), regarding _to_master_cyg.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-04-22 19:22:59 +08: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 08:37:18 +08:00
|
|
|
int open (int flags, mode_t mode = 0);
|
2021-09-18 20:13:55 +08:00
|
|
|
bool open_setup (int flags);
|
2022-06-07 00:00:45 +08:00
|
|
|
ssize_t write (const void *ptr, size_t len);
|
2022-05-24 03:52:52 +08:00
|
|
|
void read (void *ptr, size_t& len);
|
2009-07-04 02:05:51 +08:00
|
|
|
int init (HANDLE, DWORD, mode_t);
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
int tcsetattr (int a, const struct termios *t);
|
|
|
|
int tcgetattr (struct termios *t);
|
|
|
|
int tcflush (int);
|
|
|
|
int ioctl (unsigned int cmd, void *);
|
2003-03-04 12:07:34 +08:00
|
|
|
int close ();
|
2011-05-06 06:30:53 +08:00
|
|
|
void cleanup ();
|
2011-10-16 06:37:30 +08:00
|
|
|
int dup (fhandler_base *child, int);
|
2003-03-04 12:07:34 +08:00
|
|
|
void fixup_after_fork (HANDLE parent);
|
2006-06-02 23:41:34 +08:00
|
|
|
void fixup_after_exec ();
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2009-07-01 05:18:44 +08:00
|
|
|
select_record *select_read (select_stuff *);
|
2019-09-05 12:22:54 +08:00
|
|
|
select_record *select_write (select_stuff *);
|
|
|
|
select_record *select_except (select_stuff *);
|
2022-03-04 13:42:46 +08:00
|
|
|
bg_check_types bg_check (int sig, bool dontsignal = false);
|
2016-06-23 22:56:41 +08:00
|
|
|
virtual char const *ttyname () { return pc.dev.name (); }
|
2022-05-24 03:52:52 +08:00
|
|
|
int fstat (struct stat *buf);
|
|
|
|
int facl (int, int, struct acl *);
|
|
|
|
int fchmod (mode_t mode);
|
|
|
|
int fchown (uid_t uid, gid_t gid);
|
2011-10-16 06:37:30 +08:00
|
|
|
|
|
|
|
fhandler_pty_slave (void *) {}
|
|
|
|
|
2021-02-10 17:42:05 +08:00
|
|
|
void copy_from (fhandler_base *x)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2021-02-10 17:42:05 +08:00
|
|
|
pc.free_strings ();
|
|
|
|
*this = *reinterpret_cast<fhandler_pty_slave *> (x);
|
|
|
|
_copy_from_reset_helper ();
|
2011-10-16 06:37:30 +08:00
|
|
|
}
|
|
|
|
|
2011-11-29 23:34:49 +08:00
|
|
|
fhandler_pty_slave *clone (cygheap_types malloc_type = HEAP_FHANDLER)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2011-11-29 23:34:49 +08:00
|
|
|
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_pty_slave));
|
2011-10-30 12:50:36 +08:00
|
|
|
fhandler_pty_slave *fh = new (ptr) fhandler_pty_slave (ptr);
|
2021-02-10 17:42:05 +08:00
|
|
|
fh->copy_from (this);
|
2011-10-16 06:37:30 +08:00
|
|
|
return fh;
|
|
|
|
}
|
2022-03-01 17:04:35 +08:00
|
|
|
bool setup_pseudoconsole ();
|
|
|
|
static DWORD get_winpid_to_hand_over (tty *ttyp, DWORD force_switch_to);
|
2021-04-06 08:40:13 +08:00
|
|
|
static void close_pseudoconsole (tty *ttyp, DWORD force_switch_to = 0);
|
2022-03-01 17:04:35 +08:00
|
|
|
static void hand_over_only (tty *ttyp, DWORD force_switch_to = 0);
|
2020-08-31 17:48:54 +08:00
|
|
|
bool term_has_pcon_cap (const WCHAR *env);
|
2022-03-01 21:09:01 +08:00
|
|
|
void set_switch_to_nat_pipe (void);
|
|
|
|
void reset_switch_to_nat_pipe (void);
|
|
|
|
void mask_switch_to_nat_pipe (bool mask, bool xfer);
|
2019-09-15 12:05:52 +08:00
|
|
|
void setup_locale (void);
|
2021-01-18 21:10:57 +08:00
|
|
|
void create_invisible_console (void);
|
2021-02-11 17:09:42 +08:00
|
|
|
static void transfer_input (tty::xfer_dir dir, HANDLE from, tty *ttyp,
|
|
|
|
HANDLE input_available_event);
|
2021-01-28 11:26:11 +08:00
|
|
|
HANDLE get_input_available_event (void) { return input_available_event; }
|
2021-01-28 11:26:14 +08:00
|
|
|
bool pcon_activated (void) { return get_ttyp ()->pcon_activated; }
|
2022-02-15 22:23:50 +08:00
|
|
|
void cleanup_before_exit ();
|
2022-02-21 20:20:48 +08:00
|
|
|
void get_duplicated_handle_set (handle_set_t *p);
|
|
|
|
static void close_handle_set (handle_set_t *p);
|
2022-11-19 16:28:15 +08:00
|
|
|
void setup_for_non_cygwin_app (bool nopcon, const WCHAR *envblock,
|
2022-02-21 20:20:48 +08:00
|
|
|
bool stdin_is_ptys);
|
|
|
|
static void cleanup_for_non_cygwin_app (handle_set_t *p, tty *ttyp,
|
2022-03-01 17:04:35 +08:00
|
|
|
bool stdin_is_ptys,
|
|
|
|
DWORD force_switch_to = 0);
|
2022-02-21 21:40:48 +08:00
|
|
|
void setpgid_aux (pid_t pid);
|
2022-03-01 17:04:35 +08:00
|
|
|
static void release_ownership_of_nat_pipe (tty *ttyp, fhandler_termios *fh);
|
2000-02-18 03:38:33 +08:00
|
|
|
};
|
|
|
|
|
2011-11-08 14:26:15 +08:00
|
|
|
#define __ptsname(buf, unit) __small_sprintf ((buf), "/dev/pty%d", (unit))
|
2011-06-15 05:48:43 +08:00
|
|
|
class fhandler_pty_master: public fhandler_pty_common
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2021-01-15 16:32:13 +08:00
|
|
|
public:
|
|
|
|
/* Parameter set for the static function pty_master_thread() */
|
|
|
|
struct master_thread_param_t {
|
2021-04-05 16:30:41 +08:00
|
|
|
HANDLE from_master_nat;
|
2021-01-15 16:32:13 +08:00
|
|
|
HANDLE from_master;
|
2021-04-05 16:30:41 +08:00
|
|
|
HANDLE to_master_nat;
|
2021-01-15 16:32:13 +08:00
|
|
|
HANDLE to_master;
|
2021-04-05 16:30:41 +08:00
|
|
|
HANDLE to_slave_nat;
|
2021-01-28 11:26:11 +08:00
|
|
|
HANDLE to_slave;
|
2021-01-15 16:32:13 +08:00
|
|
|
HANDLE master_ctl;
|
|
|
|
HANDLE input_available_event;
|
|
|
|
};
|
|
|
|
/* Parameter set for the static function pty_master_fwd_thread() */
|
|
|
|
struct master_fwd_thread_param_t {
|
2021-04-05 16:30:41 +08:00
|
|
|
HANDLE to_master;
|
|
|
|
HANDLE from_slave_nat;
|
2021-01-15 16:32:13 +08:00
|
|
|
HANDLE output_mutex;
|
|
|
|
tty *ttyp;
|
|
|
|
};
|
|
|
|
private:
|
2000-02-18 03:38:33 +08:00
|
|
|
int pktmode; // non-zero if pty in a packet mode.
|
2010-04-20 03:52:43 +08:00
|
|
|
HANDLE master_ctl; // Control socket for handle duplication
|
2010-05-26 21:10:55 +08:00
|
|
|
cygthread *master_thread; // Master control thread
|
2021-04-05 16:30:41 +08:00
|
|
|
HANDLE from_master_nat, to_master_nat, from_slave_nat, to_slave_nat;
|
2015-03-05 20:57:34 +08:00
|
|
|
HANDLE echo_r, echo_w;
|
2011-10-16 06:37:30 +08:00
|
|
|
DWORD dwProcessId; // Owner of master handles
|
2021-04-05 16:30:41 +08:00
|
|
|
HANDLE to_master, from_master;
|
Fix OPOST for non-Cygwin pty slaves
* fhandler.h (class fhandler_base): Add virtual function
get_io_handle_cyg() to get handle from which OPOST-processed output is
read on PTY master.
(class fhandler_pty_slave): Add variable output_handle_cyg to store a
handle to which OPOST-processed output is written. Add two functions,
i.e., set_output_handle_cyg() and get_output_handle_cyg(), regarding
variable output_handle_cyg. Now, output_handle is used only by native
windows program. The data before OPOST-processing is written to
output_handle and OPOST-processing is applied in the master-side. For a
cygwin process, OPOST-processing is applied in the slave-side, and the
data after OPOST-processing is written to output_handle_cyg.
(class fhandler_pty_master): Add two variables, i.e., io_handle_cyg and
to_master_cyg, to store handles of a pipe through which OPOST-processed
output passes. Add pty_master_fwd_thread and function
pty_master_fwd_thread() for a thread which applies OPOST-processing
and forwards data from io_handle to to_master_cyg. Add function
get_io_handle_cyg() regarding variable io_handle_cyg. Now, the pipe
between io_handle and to_master are used only by native windows program
for applying OPOST-processing in the master-side. For a cygwin process,
the pipe between io_handle_cyg and to_master_cyg is used for passing
through the data which is applied OPOST-processing in the slave-side.
* fhandler_tty.cc (struct pipe_reply): Add member to_master_cyg.
(fhandler_pty_master::process_slave_output): Read slave output from
io_handle_cyg rather than io_handle.
(fhandler_pty_slave::fhandler_pty_salve): Initialize output_handle_cyg.
(fhandler_pty_slave::open): Set output_handle_cyg by duplicating handle
to_master_cyg on PTY master.
(fhandler_pty_slave::close): Close handle output_handle_cyg.
(fhandler_pty_slave::write): Write data to output_handle_cyg rather
than output_handle.
(fhandler_pty_slave::fch_close_handles): Close handle output_handle_cyg.
(fhandler_pty_master::fhandler_pty_master): Initialize io_handle_cyg,
to_master_cyg and master_fwd_thread.
(fhandler_pty_master::cleanup): Clean up to_master_cyg as well.
(fhandler_pty_master::close): Print to_master_cyg as well in debug
message. Terminate master forwarding thread. Close handles
to_master_cyg and io_handle_cyg.
(fhandler_pty_master::ioctl): Use io_handle_cyg rather than to_master.
(fhandler_pty_master::pty_master_thread): Add code for duplicating
handle to_master_cyg.
(fhandler_pty_master::pty_master_fwd_thread): New function for a thread
to forward OPOST-processed data from io_handle to to_master_cyg. This
thread applies OPOST-processing to the output of native windows program.
(::pty_master_fwd_thread): Ditto.
(fhandler_pty_master::setup): Create a new pipe to pass thruegh OPOST-
processed output. Create new thread to forward data from io_handle to
to_master_cyg. Set handle to_master_cyg to tty. Print io_handle_cyg as
well in debug message. Close handles io_handle_cyg and to_master_cyg in
case of error.
(fhandler_pty_master::fixup_after_fork): Set handle to_master_cyg to
tty. Copy handle to_master_cyg from arch->to_master_cyg.
(fhandler_pty_master::fixup_after_exec): Clean up to_master_cyg.
* select.cc: Check handle returned by get_io_handle_cyg() rather than
get_handle().
* tty.h (class tty): Add variable _to_master_cyg to store a handle to
which OPOST-processed data is written. Add two functions,
to_master_cyg() and set_to_master_cyg(), regarding _to_master_cyg.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-04-22 19:22:59 +08:00
|
|
|
cygthread *master_fwd_thread; // Master forwarding thread
|
2021-01-15 16:32:13 +08:00
|
|
|
HANDLE thread_param_copied_event;
|
2022-05-14 19:39:42 +08:00
|
|
|
HANDLE helper_goodbye;
|
|
|
|
HANDLE helper_h_process;
|
2010-04-20 03:52:43 +08: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 08:37:18 +08:00
|
|
|
public:
|
2015-03-05 20:57:34 +08:00
|
|
|
HANDLE get_echo_handle () const { return echo_r; }
|
2000-02-18 03:38:33 +08:00
|
|
|
/* Constructor */
|
2011-10-16 06:37:30 +08:00
|
|
|
fhandler_pty_master (int);
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2021-01-15 16:32:13 +08:00
|
|
|
static DWORD pty_master_thread (const master_thread_param_t *p);
|
|
|
|
static DWORD pty_master_fwd_thread (const master_fwd_thread_param_t *p);
|
2000-03-12 14:29:54 +08:00
|
|
|
int process_slave_output (char *buf, size_t len, int pktmode_on);
|
2000-02-18 03:38:33 +08: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 08:37:18 +08:00
|
|
|
int open (int flags, mode_t mode = 0);
|
2021-09-18 20:13:55 +08:00
|
|
|
bool open_setup (int flags);
|
2022-06-07 00:00:45 +08:00
|
|
|
ssize_t write (const void *ptr, size_t len);
|
2022-05-24 03:52:52 +08:00
|
|
|
void read (void *ptr, size_t& len);
|
2000-02-18 03:38:33 +08:00
|
|
|
int close ();
|
2011-05-06 06:30:53 +08:00
|
|
|
void cleanup ();
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
int tcsetattr (int a, const struct termios *t);
|
|
|
|
int tcgetattr (struct termios *t);
|
|
|
|
int tcflush (int);
|
|
|
|
int ioctl (unsigned int cmd, void *);
|
|
|
|
|
2011-11-08 04:05:49 +08:00
|
|
|
int ptsname_r (char *, size_t);
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2001-09-25 05:50:44 +08:00
|
|
|
bool hit_eof ();
|
2011-06-15 05:48:43 +08:00
|
|
|
bool setup ();
|
2011-10-16 06:37:30 +08:00
|
|
|
int dup (fhandler_base *, int);
|
2006-06-02 23:41:34 +08:00
|
|
|
void fixup_after_fork (HANDLE parent);
|
|
|
|
void fixup_after_exec ();
|
2009-10-07 15:52:30 +08:00
|
|
|
int tcgetpgrp ();
|
2012-04-05 10:54:51 +08:00
|
|
|
void flush_to_slave ();
|
2021-03-05 17:01:50 +08:00
|
|
|
void discard_input ();
|
2011-10-16 06:37:30 +08:00
|
|
|
|
|
|
|
fhandler_pty_master (void *) {}
|
|
|
|
|
2021-02-10 17:42:05 +08:00
|
|
|
void copy_from (fhandler_base *x)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2021-02-10 17:42:05 +08:00
|
|
|
pc.free_strings ();
|
|
|
|
*this = *reinterpret_cast<fhandler_pty_master *> (x);
|
|
|
|
_copy_from_reset_helper ();
|
2011-10-16 06:37:30 +08:00
|
|
|
}
|
|
|
|
|
2011-11-29 23:34:49 +08:00
|
|
|
fhandler_pty_master *clone (cygheap_types malloc_type = HEAP_FHANDLER)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2011-11-29 23:34:49 +08:00
|
|
|
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_pty_master));
|
2011-10-30 12:50:36 +08:00
|
|
|
fhandler_pty_master *fh = new (ptr) fhandler_pty_master (ptr);
|
2021-02-10 17:42:05 +08:00
|
|
|
fh->copy_from (this);
|
2011-10-16 06:37:30 +08:00
|
|
|
return fh;
|
|
|
|
}
|
2021-01-15 16:32:13 +08:00
|
|
|
void get_master_thread_param (master_thread_param_t *p);
|
|
|
|
void get_master_fwd_thread_param (master_fwd_thread_param_t *p);
|
2021-02-19 16:44:01 +08:00
|
|
|
void set_mask_flusho (bool m) { get_ttyp ()->mask_flusho = m; }
|
2022-02-26 03:19:03 +08:00
|
|
|
bool need_send_ctrl_c_event ();
|
2000-02-18 03:38:33 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class fhandler_dev_null: public fhandler_base
|
|
|
|
{
|
2001-11-02 05:15:53 +08:00
|
|
|
public:
|
2001-10-14 01:23:35 +08:00
|
|
|
fhandler_dev_null ();
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2009-07-01 05:18:44 +08:00
|
|
|
select_record *select_read (select_stuff *);
|
|
|
|
select_record *select_write (select_stuff *);
|
|
|
|
select_record *select_except (select_stuff *);
|
2011-10-16 06:37:30 +08:00
|
|
|
|
|
|
|
fhandler_dev_null (void *) {}
|
|
|
|
|
2021-02-10 17:42:05 +08:00
|
|
|
void copy_from (fhandler_base *x)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2021-02-10 17:42:05 +08:00
|
|
|
pc.free_strings ();
|
|
|
|
*this = *reinterpret_cast<fhandler_dev_null *> (x);
|
|
|
|
_copy_from_reset_helper ();
|
2011-10-16 06:37:30 +08:00
|
|
|
}
|
|
|
|
|
2011-11-29 23:34:49 +08:00
|
|
|
fhandler_dev_null *clone (cygheap_types malloc_type = HEAP_FHANDLER)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2011-11-29 23:34:49 +08:00
|
|
|
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_dev_null));
|
2011-10-30 12:50:36 +08:00
|
|
|
fhandler_dev_null *fh = new (ptr) fhandler_dev_null (ptr);
|
2021-02-10 17:42:05 +08:00
|
|
|
fh->copy_from (this);
|
2011-10-16 06:37:30 +08:00
|
|
|
return fh;
|
|
|
|
}
|
2017-03-12 19:17:43 +08:00
|
|
|
|
2022-06-07 00:00:45 +08:00
|
|
|
ssize_t write (const void *ptr, size_t len);
|
2000-02-18 03:38:33 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class fhandler_dev_zero: public fhandler_base
|
|
|
|
{
|
2001-11-02 05:15:53 +08:00
|
|
|
public:
|
2001-10-14 01:23:35 +08:00
|
|
|
fhandler_dev_zero ();
|
2022-06-07 00:00:45 +08:00
|
|
|
ssize_t write (const void *ptr, size_t len);
|
2022-05-24 03:52:52 +08:00
|
|
|
void read (void *ptr, size_t& len);
|
2013-10-25 01:51:41 +08:00
|
|
|
off_t lseek (off_t, int) { return 0; }
|
2005-11-30 00:28:05 +08:00
|
|
|
|
|
|
|
virtual HANDLE mmap (caddr_t *addr, size_t len, int prot,
|
2013-04-23 17:44:36 +08:00
|
|
|
int flags, off_t off);
|
2005-11-30 00:28:05 +08:00
|
|
|
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,
|
2016-05-21 03:48:10 +08:00
|
|
|
off_t offset, SIZE_T size,
|
2005-11-30 00:28:05 +08:00
|
|
|
void *address);
|
2011-10-16 06:37:30 +08:00
|
|
|
|
|
|
|
fhandler_dev_zero (void *) {}
|
|
|
|
|
2021-02-10 17:42:05 +08:00
|
|
|
void copy_from (fhandler_base *x)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2021-02-10 17:42:05 +08:00
|
|
|
pc.free_strings ();
|
|
|
|
*this = *reinterpret_cast<fhandler_dev_zero *> (x);
|
|
|
|
_copy_from_reset_helper ();
|
2011-10-16 06:37:30 +08:00
|
|
|
}
|
|
|
|
|
2011-11-29 23:34:49 +08:00
|
|
|
fhandler_dev_zero *clone (cygheap_types malloc_type = HEAP_FHANDLER)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2011-11-29 23:34:49 +08:00
|
|
|
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_dev_zero));
|
2011-10-30 12:50:36 +08:00
|
|
|
fhandler_dev_zero *fh = new (ptr) fhandler_dev_zero (ptr);
|
2021-02-10 17:42:05 +08:00
|
|
|
fh->copy_from (this);
|
2011-10-16 06:37:30 +08:00
|
|
|
return fh;
|
|
|
|
}
|
2000-02-18 03:38:33 +08:00
|
|
|
};
|
|
|
|
|
2000-05-03 23:39:10 +08:00
|
|
|
class fhandler_dev_random: public fhandler_base
|
|
|
|
{
|
2001-11-02 05:15:53 +08:00
|
|
|
protected:
|
2013-05-22 02:51:36 +08:00
|
|
|
uint32_t pseudo;
|
2000-07-24 19:33:02 +08:00
|
|
|
|
|
|
|
int pseudo_write (const void *ptr, size_t len);
|
|
|
|
int pseudo_read (void *ptr, size_t len);
|
2000-07-24 05:13:05 +08:00
|
|
|
|
2001-11-02 05:15:53 +08:00
|
|
|
public:
|
2022-06-07 00:00:45 +08:00
|
|
|
ssize_t write (const void *ptr, size_t len);
|
2022-05-24 03:52:52 +08:00
|
|
|
void read (void *ptr, size_t& len);
|
2013-10-25 01:51:41 +08:00
|
|
|
off_t lseek (off_t, int) { return 0; }
|
2013-10-25 20:21:59 +08:00
|
|
|
|
2013-10-15 22:00:37 +08:00
|
|
|
fhandler_dev_random () : fhandler_base () {}
|
2011-10-16 06:37:30 +08:00
|
|
|
fhandler_dev_random (void *) {}
|
|
|
|
|
2021-02-10 17:42:05 +08:00
|
|
|
void copy_from (fhandler_base *x)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2021-02-10 17:42:05 +08:00
|
|
|
pc.free_strings ();
|
|
|
|
*this = *reinterpret_cast<fhandler_dev_random *> (x);
|
|
|
|
_copy_from_reset_helper ();
|
2011-10-16 06:37:30 +08:00
|
|
|
}
|
|
|
|
|
2011-11-29 23:34:49 +08:00
|
|
|
fhandler_dev_random *clone (cygheap_types malloc_type = HEAP_FHANDLER)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2011-11-29 23:34:49 +08:00
|
|
|
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_dev_random));
|
2011-10-30 12:50:36 +08:00
|
|
|
fhandler_dev_random *fh = new (ptr) fhandler_dev_random (ptr);
|
2021-02-10 17:42:05 +08:00
|
|
|
fh->copy_from (this);
|
2011-10-16 06:37:30 +08:00
|
|
|
return fh;
|
|
|
|
}
|
2000-05-03 23:39:10 +08:00
|
|
|
};
|
|
|
|
|
2000-10-17 09:46:26 +08:00
|
|
|
class fhandler_dev_clipboard: public fhandler_base
|
|
|
|
{
|
2013-12-11 05:05:23 +08:00
|
|
|
UINT cygnativeformat;
|
2013-04-23 17:44:36 +08:00
|
|
|
off_t pos;
|
2005-07-05 11:16:46 +08:00
|
|
|
void *membuffer;
|
|
|
|
size_t msize;
|
2013-12-11 05:05:23 +08:00
|
|
|
int set_clipboard (const void *buf, size_t len);
|
|
|
|
|
2001-11-02 05:15:53 +08:00
|
|
|
public:
|
2001-10-14 01:23:35 +08:00
|
|
|
fhandler_dev_clipboard ();
|
2005-07-05 11:16:46 +08:00
|
|
|
int is_windows () { return 1; }
|
2022-05-24 03:52:52 +08:00
|
|
|
int fstat (struct stat *buf);
|
2022-06-07 00:00:45 +08:00
|
|
|
ssize_t write (const void *ptr, size_t len);
|
2022-05-24 03:52:52 +08:00
|
|
|
void read (void *ptr, size_t& len);
|
2013-04-23 17:44:36 +08:00
|
|
|
off_t lseek (off_t offset, int whence);
|
2005-07-05 11:16:46 +08:00
|
|
|
int close ();
|
2000-10-17 09:46:26 +08:00
|
|
|
|
2011-10-16 06:37:30 +08:00
|
|
|
int dup (fhandler_base *child, int);
|
2005-07-05 11:16:46 +08:00
|
|
|
void fixup_after_exec ();
|
2011-10-16 06:37:30 +08:00
|
|
|
|
|
|
|
fhandler_dev_clipboard (void *) {}
|
|
|
|
|
2021-02-10 17:42:05 +08:00
|
|
|
void copy_from (fhandler_base *x)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2021-02-10 17:42:05 +08:00
|
|
|
pc.free_strings ();
|
|
|
|
*this = *reinterpret_cast<fhandler_dev_clipboard *> (x);
|
|
|
|
_copy_from_reset_helper ();
|
2011-10-16 06:37:30 +08:00
|
|
|
}
|
|
|
|
|
2011-11-29 23:34:49 +08:00
|
|
|
fhandler_dev_clipboard *clone (cygheap_types malloc_type = HEAP_FHANDLER)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2011-11-29 23:34:49 +08:00
|
|
|
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_dev_clipboard));
|
2011-10-30 12:50:36 +08:00
|
|
|
fhandler_dev_clipboard *fh = new (ptr) fhandler_dev_clipboard (ptr);
|
2021-02-10 17:42:05 +08:00
|
|
|
fh->copy_from (this);
|
2011-10-16 06:37:30 +08:00
|
|
|
return fh;
|
|
|
|
}
|
2000-10-01 09:02:40 +08:00
|
|
|
};
|
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
class fhandler_windows: public fhandler_base
|
|
|
|
{
|
2001-11-02 05:15:53 +08:00
|
|
|
private:
|
2000-02-18 03:38:33 +08:00
|
|
|
HWND hWnd_; // the window whose messages are to be retrieved by read() call
|
|
|
|
int method_; // write method (Post or Send)
|
2001-11-02 05:15:53 +08:00
|
|
|
public:
|
2001-10-14 01:23:35 +08:00
|
|
|
fhandler_windows ();
|
2005-07-05 11:16:46 +08:00
|
|
|
int is_windows () { return 1; }
|
2013-10-30 17:44:47 +08:00
|
|
|
HWND get_hwnd () { return hWnd_; }
|
* 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 08:37:18 +08:00
|
|
|
int open (int flags, mode_t mode = 0);
|
2022-06-07 00:00:45 +08:00
|
|
|
ssize_t write (const void *ptr, size_t len);
|
2022-05-24 03:52:52 +08:00
|
|
|
void read (void *ptr, size_t& len);
|
2000-02-18 03:38:33 +08:00
|
|
|
int ioctl (unsigned int cmd, void *);
|
2013-04-23 17:44:36 +08:00
|
|
|
off_t lseek (off_t, int) { return 0; }
|
2005-07-05 11:16:46 +08:00
|
|
|
int close () { return 0; }
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2009-07-01 05:18:44 +08:00
|
|
|
select_record *select_read (select_stuff *);
|
|
|
|
select_record *select_write (select_stuff *);
|
|
|
|
select_record *select_except (select_stuff *);
|
2011-10-16 06:37:30 +08:00
|
|
|
|
|
|
|
fhandler_windows (void *) {}
|
|
|
|
|
2021-02-10 17:42:05 +08:00
|
|
|
void copy_from (fhandler_base *x)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2021-02-10 17:42:05 +08:00
|
|
|
pc.free_strings ();
|
|
|
|
*this = *reinterpret_cast<fhandler_windows *> (x);
|
|
|
|
_copy_from_reset_helper ();
|
2011-10-16 06:37:30 +08:00
|
|
|
}
|
|
|
|
|
2011-11-29 23:34:49 +08:00
|
|
|
fhandler_windows *clone (cygheap_types malloc_type = HEAP_FHANDLER)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2011-11-29 23:34:49 +08:00
|
|
|
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_windows));
|
2011-10-30 12:50:36 +08:00
|
|
|
fhandler_windows *fh = new (ptr) fhandler_windows (ptr);
|
2021-02-10 17:42:05 +08:00
|
|
|
fh->copy_from (this);
|
2011-10-16 06:37:30 +08:00
|
|
|
return fh;
|
|
|
|
}
|
2000-02-18 03:38:33 +08:00
|
|
|
};
|
|
|
|
|
2004-03-23 19:05:56 +08:00
|
|
|
class fhandler_dev_dsp: public fhandler_base
|
2001-04-16 11:27:16 +08:00
|
|
|
{
|
2004-03-23 19:05:56 +08:00
|
|
|
public:
|
|
|
|
class Audio;
|
|
|
|
class Audio_out;
|
|
|
|
class Audio_in;
|
2001-11-02 05:15:53 +08:00
|
|
|
private:
|
2001-04-16 11:27:16 +08:00
|
|
|
int audioformat_;
|
|
|
|
int audiofreq_;
|
|
|
|
int audiobits_;
|
|
|
|
int audiochannels_;
|
2004-03-23 19:05:56 +08:00
|
|
|
Audio_out *audio_out_;
|
|
|
|
Audio_in *audio_in_;
|
2023-01-25 17:30:50 +08:00
|
|
|
bool being_closed;
|
2001-11-02 05:15:53 +08:00
|
|
|
public:
|
2001-10-14 01:23:35 +08:00
|
|
|
fhandler_dev_dsp ();
|
2014-03-17 12:41:35 +08:00
|
|
|
fhandler_dev_dsp *base () const {return (fhandler_dev_dsp *)archetype;}
|
2001-04-16 11:27:16 +08:00
|
|
|
|
2014-03-20 04:43:15 +08:00
|
|
|
int open (int, mode_t mode = 0);
|
2022-06-07 00:00:45 +08:00
|
|
|
ssize_t write (const void *, size_t);
|
2022-05-24 03:52:52 +08:00
|
|
|
void read (void *, size_t&);
|
2014-03-20 04:43:15 +08:00
|
|
|
int ioctl (unsigned int, void *);
|
2023-01-19 21:02:47 +08:00
|
|
|
int fcntl (int cmd, intptr_t);
|
2005-07-05 11:16:46 +08:00
|
|
|
int close ();
|
2014-03-20 04:43:15 +08:00
|
|
|
void fixup_after_fork (HANDLE);
|
2004-02-03 05:00:07 +08:00
|
|
|
void fixup_after_exec ();
|
2014-03-17 12:41:35 +08:00
|
|
|
|
2004-08-17 17:52:50 +08:00
|
|
|
private:
|
2022-06-07 00:00:45 +08:00
|
|
|
ssize_t _write (const void *, size_t);
|
2022-05-24 03:52:52 +08:00
|
|
|
void _read (void *, size_t&);
|
2014-03-20 04:43:15 +08:00
|
|
|
int _ioctl (unsigned int, void *);
|
2023-01-19 21:02:47 +08:00
|
|
|
int _fcntl (int cmd, intptr_t);
|
2014-03-20 04:43:15 +08:00
|
|
|
void _fixup_after_fork (HANDLE);
|
2014-03-17 12:41:35 +08:00
|
|
|
void _fixup_after_exec ();
|
|
|
|
|
2022-05-24 03:52:52 +08:00
|
|
|
void close_audio_in ();
|
|
|
|
void close_audio_out (bool = false);
|
2011-05-06 06:30:53 +08:00
|
|
|
bool use_archetype () const {return true;}
|
2011-10-16 06:37:30 +08:00
|
|
|
|
|
|
|
fhandler_dev_dsp (void *) {}
|
|
|
|
|
2021-02-10 17:42:05 +08:00
|
|
|
void copy_from (fhandler_base *x)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2021-02-10 17:42:05 +08:00
|
|
|
pc.free_strings ();
|
|
|
|
*this = *reinterpret_cast<fhandler_dev_dsp *> (x);
|
|
|
|
_copy_from_reset_helper ();
|
2011-10-16 06:37:30 +08:00
|
|
|
}
|
|
|
|
|
2011-11-29 23:34:49 +08:00
|
|
|
fhandler_dev_dsp *clone (cygheap_types malloc_type = HEAP_FHANDLER)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2011-11-29 23:34:49 +08:00
|
|
|
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_dev_dsp));
|
2011-10-30 12:50:36 +08:00
|
|
|
fhandler_dev_dsp *fh = new (ptr) fhandler_dev_dsp (ptr);
|
2021-02-10 17:42:05 +08:00
|
|
|
fh->copy_from (this);
|
2011-10-16 06:37:30 +08:00
|
|
|
return fh;
|
|
|
|
}
|
2001-04-16 11:27:16 +08:00
|
|
|
};
|
|
|
|
|
2002-05-02 12:13:48 +08:00
|
|
|
class fhandler_virtual : public fhandler_base
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
char *filebuf;
|
2013-04-23 17:44:36 +08:00
|
|
|
off_t filesize;
|
|
|
|
off_t position;
|
2002-05-12 09:37:48 +08:00
|
|
|
int fileid; // unique within each class
|
2020-09-08 04:45:38 +08:00
|
|
|
bool diropen;
|
2002-05-02 12:13:48 +08: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 08:37:18 +08:00
|
|
|
fhandler_virtual ();
|
2002-05-02 12:13:48 +08:00
|
|
|
virtual ~fhandler_virtual();
|
|
|
|
|
2010-09-06 17:47:01 +08:00
|
|
|
virtual virtual_ftype_t exists();
|
2022-05-24 03:52:52 +08:00
|
|
|
DIR *opendir (int fd);
|
2010-07-06 00:59:56 +08:00
|
|
|
long telldir (DIR *);
|
|
|
|
void seekdir (DIR *, long);
|
2002-05-02 12:13:48 +08:00
|
|
|
void rewinddir (DIR *);
|
|
|
|
int closedir (DIR *);
|
2022-06-07 00:00:45 +08:00
|
|
|
ssize_t write (const void *ptr, size_t len);
|
2022-05-24 03:52:52 +08:00
|
|
|
void read (void *ptr, size_t& len);
|
2013-04-23 17:44:36 +08:00
|
|
|
off_t lseek (off_t, int);
|
2011-10-16 06:37:30 +08: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 08:37:18 +08:00
|
|
|
int open (int flags, mode_t mode = 0);
|
2005-07-05 11:16:46 +08:00
|
|
|
int close ();
|
2022-05-24 03:52:52 +08:00
|
|
|
int fstatvfs (struct statvfs *buf);
|
|
|
|
int fchmod (mode_t mode);
|
|
|
|
int fchown (uid_t uid, gid_t gid);
|
|
|
|
int facl (int, int, struct acl *);
|
2002-07-02 09:36:15 +08:00
|
|
|
virtual bool fill_filebuf ();
|
2005-01-29 19:23:07 +08:00
|
|
|
char *get_filebuf () { return filebuf; }
|
2004-02-03 05:00:07 +08:00
|
|
|
void fixup_after_exec ();
|
2011-10-16 06:37:30 +08:00
|
|
|
|
|
|
|
fhandler_virtual (void *) {}
|
|
|
|
|
2021-02-10 17:42:05 +08:00
|
|
|
virtual void copy_from (fhandler_base *x)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2021-02-10 17:42:05 +08:00
|
|
|
pc.free_strings ();
|
|
|
|
*this = *reinterpret_cast<fhandler_virtual *> (x);
|
|
|
|
_copy_from_reset_helper ();
|
2011-10-16 06:37:30 +08:00
|
|
|
}
|
|
|
|
|
2011-11-29 23:34:49 +08:00
|
|
|
virtual fhandler_virtual *clone (cygheap_types malloc_type = HEAP_FHANDLER)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2011-11-29 23:34:49 +08:00
|
|
|
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_virtual));
|
2011-10-30 12:50:36 +08:00
|
|
|
fhandler_virtual *fh = new (ptr) fhandler_virtual (ptr);
|
2021-02-10 17:42:05 +08:00
|
|
|
fh->copy_from (this);
|
2011-10-16 06:37:30 +08:00
|
|
|
return fh;
|
|
|
|
}
|
2002-05-02 12:13:48 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class fhandler_proc: public fhandler_virtual
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
fhandler_proc ();
|
2010-09-06 17:47:01 +08:00
|
|
|
virtual_ftype_t exists();
|
2022-05-24 03:52:52 +08:00
|
|
|
DIR *opendir (int fd);
|
2011-08-12 20:31:08 +08:00
|
|
|
int closedir (DIR *);
|
2022-05-24 03:52:52 +08:00
|
|
|
int readdir (DIR *, dirent *);
|
2011-05-29 02:17:09 +08:00
|
|
|
static fh_devices get_proc_fhandler (const char *path);
|
2002-05-02 12:13:48 +08: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 08:37:18 +08:00
|
|
|
int open (int flags, mode_t mode = 0);
|
2022-05-24 03:52:52 +08:00
|
|
|
int fstat (struct stat *buf);
|
2002-07-02 09:36:15 +08:00
|
|
|
bool fill_filebuf ();
|
2011-10-16 06:37:30 +08:00
|
|
|
|
|
|
|
fhandler_proc (void *) {}
|
|
|
|
|
2021-02-10 17:42:05 +08:00
|
|
|
virtual void copy_from (fhandler_base *x)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2021-02-10 17:42:05 +08:00
|
|
|
pc.free_strings ();
|
|
|
|
*this = *reinterpret_cast<fhandler_proc *> (x);
|
|
|
|
_copy_from_reset_helper ();
|
2011-10-16 06:37:30 +08:00
|
|
|
}
|
|
|
|
|
2011-11-29 23:34:49 +08:00
|
|
|
virtual fhandler_proc *clone (cygheap_types malloc_type = HEAP_FHANDLER)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2011-11-29 23:34:49 +08:00
|
|
|
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_proc));
|
2011-10-30 12:50:36 +08:00
|
|
|
fhandler_proc *fh = new (ptr) fhandler_proc (ptr);
|
2021-02-10 17:42:05 +08:00
|
|
|
fh->copy_from (this);
|
2011-10-16 06:37:30 +08:00
|
|
|
return fh;
|
|
|
|
}
|
2002-05-02 12:13:48 +08:00
|
|
|
};
|
|
|
|
|
2010-09-06 17:47:01 +08:00
|
|
|
class fhandler_procsys: public fhandler_virtual
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
fhandler_procsys ();
|
2022-05-24 03:52:52 +08:00
|
|
|
virtual_ftype_t exists(struct stat *buf);
|
2010-09-06 17:47:01 +08:00
|
|
|
virtual_ftype_t exists();
|
2022-05-24 03:52:52 +08:00
|
|
|
DIR *opendir (int fd);
|
|
|
|
int readdir (DIR *, dirent *);
|
2010-09-06 17:47:01 +08:00
|
|
|
long telldir (DIR *);
|
|
|
|
void seekdir (DIR *, long);
|
|
|
|
int closedir (DIR *);
|
|
|
|
int open (int flags, mode_t mode = 0);
|
|
|
|
int close ();
|
2022-05-24 03:52:52 +08:00
|
|
|
void read (void *ptr, size_t& len);
|
2022-06-07 00:00:45 +08:00
|
|
|
ssize_t write (const void *ptr, size_t len);
|
2022-05-24 03:52:52 +08:00
|
|
|
int fstat (struct stat *buf);
|
2010-09-06 17:47:01 +08:00
|
|
|
bool fill_filebuf ();
|
2011-10-16 06:37:30 +08:00
|
|
|
|
|
|
|
fhandler_procsys (void *) {}
|
|
|
|
|
2021-02-10 17:42:05 +08:00
|
|
|
void copy_from (fhandler_base *x)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2021-02-10 17:42:05 +08:00
|
|
|
pc.free_strings ();
|
|
|
|
*this = *reinterpret_cast<fhandler_procsys *> (x);
|
|
|
|
_copy_from_reset_helper ();
|
2011-10-16 06:37:30 +08:00
|
|
|
}
|
|
|
|
|
2011-11-29 23:34:49 +08:00
|
|
|
fhandler_procsys *clone (cygheap_types malloc_type = HEAP_FHANDLER)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2011-11-29 23:34:49 +08:00
|
|
|
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_procsys));
|
2011-10-30 12:50:36 +08:00
|
|
|
fhandler_procsys *fh = new (ptr) fhandler_procsys (ptr);
|
2021-02-10 17:42:05 +08:00
|
|
|
fh->copy_from (this);
|
2011-10-16 06:37:30 +08:00
|
|
|
return fh;
|
|
|
|
}
|
2010-09-06 17:47:01 +08:00
|
|
|
};
|
|
|
|
|
2011-04-02 03:48:19 +08:00
|
|
|
class fhandler_procsysvipc: public fhandler_proc
|
|
|
|
{
|
|
|
|
pid_t pid;
|
|
|
|
public:
|
|
|
|
fhandler_procsysvipc ();
|
|
|
|
virtual_ftype_t exists();
|
2022-05-24 03:52:52 +08:00
|
|
|
int readdir (DIR *, dirent *);
|
2011-04-02 03:48:19 +08:00
|
|
|
int open (int flags, mode_t mode = 0);
|
2022-05-24 03:52:52 +08:00
|
|
|
int fstat (struct stat *buf);
|
2011-04-02 03:48:19 +08:00
|
|
|
bool fill_filebuf ();
|
2011-10-16 06:37:30 +08:00
|
|
|
|
|
|
|
fhandler_procsysvipc (void *) {}
|
|
|
|
|
2021-02-10 17:42:05 +08:00
|
|
|
void copy_from (fhandler_base *x)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2021-02-10 17:42:05 +08:00
|
|
|
pc.free_strings ();
|
|
|
|
*this = *reinterpret_cast<fhandler_procsysvipc *> (x);
|
|
|
|
_copy_from_reset_helper ();
|
2011-10-16 06:37:30 +08:00
|
|
|
}
|
|
|
|
|
2011-11-29 23:34:49 +08:00
|
|
|
fhandler_procsysvipc *clone (cygheap_types malloc_type = HEAP_FHANDLER)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2011-11-29 23:34:49 +08:00
|
|
|
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_procsysvipc));
|
2011-10-30 12:50:36 +08:00
|
|
|
fhandler_procsysvipc *fh = new (ptr) fhandler_procsysvipc (ptr);
|
2021-02-10 17:42:05 +08:00
|
|
|
fh->copy_from (this);
|
2011-10-16 06:37:30 +08:00
|
|
|
return fh;
|
|
|
|
}
|
2011-04-02 03:48:19 +08:00
|
|
|
};
|
|
|
|
|
2005-05-09 10:39:34 +08:00
|
|
|
class fhandler_netdrive: public fhandler_virtual
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
fhandler_netdrive ();
|
2010-09-06 17:47:01 +08:00
|
|
|
virtual_ftype_t exists();
|
2022-05-24 03:52:52 +08:00
|
|
|
int readdir (DIR *, dirent *);
|
2010-07-06 00:59:56 +08:00
|
|
|
void seekdir (DIR *, long);
|
2005-05-18 04:34:15 +08:00
|
|
|
void rewinddir (DIR *);
|
2005-05-14 04:20:02 +08:00
|
|
|
int closedir (DIR *);
|
2005-05-09 10:39:34 +08:00
|
|
|
int open (int flags, mode_t mode = 0);
|
2013-10-31 22:26:42 +08:00
|
|
|
int close ();
|
2022-05-24 03:52:52 +08:00
|
|
|
int fstat (struct stat *buf);
|
2011-10-16 06:37:30 +08:00
|
|
|
|
|
|
|
fhandler_netdrive (void *) {}
|
|
|
|
|
2021-02-10 17:42:05 +08:00
|
|
|
void copy_from (fhandler_base *x)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2021-02-10 17:42:05 +08:00
|
|
|
pc.free_strings ();
|
|
|
|
*this = *reinterpret_cast<fhandler_netdrive *> (x);
|
|
|
|
_copy_from_reset_helper ();
|
2011-10-16 06:37:30 +08:00
|
|
|
}
|
|
|
|
|
2011-11-29 23:34:49 +08:00
|
|
|
fhandler_netdrive *clone (cygheap_types malloc_type = HEAP_FHANDLER)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2011-11-29 23:34:49 +08:00
|
|
|
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_netdrive));
|
2011-10-30 12:50:36 +08:00
|
|
|
fhandler_netdrive *fh = new (ptr) fhandler_netdrive (ptr);
|
2021-02-10 17:42:05 +08:00
|
|
|
fh->copy_from (this);
|
2011-10-16 06:37:30 +08:00
|
|
|
return fh;
|
|
|
|
}
|
2005-05-09 10:39:34 +08:00
|
|
|
};
|
|
|
|
|
2002-05-02 12:13:48 +08:00
|
|
|
class fhandler_registry: public fhandler_proc
|
|
|
|
{
|
2002-07-02 09:36:15 +08:00
|
|
|
private:
|
2009-12-19 01:14:21 +08:00
|
|
|
wchar_t *value_name;
|
2006-10-19 18:01:03 +08:00
|
|
|
DWORD wow64;
|
|
|
|
int prefix_len;
|
2002-05-02 12:13:48 +08:00
|
|
|
public:
|
|
|
|
fhandler_registry ();
|
2006-10-19 18:01:03 +08:00
|
|
|
void set_name (path_conv &pc);
|
2010-09-06 17:47:01 +08:00
|
|
|
virtual_ftype_t exists();
|
2022-05-24 03:52:52 +08:00
|
|
|
DIR *opendir (int fd);
|
|
|
|
int readdir (DIR *, dirent *);
|
2010-07-06 00:59:56 +08:00
|
|
|
long telldir (DIR *);
|
|
|
|
void seekdir (DIR *, long);
|
2002-05-02 12:13:48 +08: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 08:37:18 +08:00
|
|
|
int open (int flags, mode_t mode = 0);
|
2022-05-24 03:52:52 +08:00
|
|
|
int fstat (struct stat *buf);
|
2002-07-02 09:36:15 +08:00
|
|
|
bool fill_filebuf ();
|
2005-07-05 11:16:46 +08:00
|
|
|
int close ();
|
2011-10-16 06:37:30 +08:00
|
|
|
int dup (fhandler_base *child, int);
|
|
|
|
|
|
|
|
fhandler_registry (void *) {}
|
|
|
|
|
2021-02-10 17:42:05 +08:00
|
|
|
void copy_from (fhandler_base *x)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2021-02-10 17:42:05 +08:00
|
|
|
pc.free_strings ();
|
|
|
|
*this = *reinterpret_cast<fhandler_registry *> (x);
|
|
|
|
_copy_from_reset_helper ();
|
2011-10-16 06:37:30 +08:00
|
|
|
}
|
|
|
|
|
2011-11-29 23:34:49 +08:00
|
|
|
fhandler_registry *clone (cygheap_types malloc_type = HEAP_FHANDLER)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2011-11-29 23:34:49 +08:00
|
|
|
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_registry));
|
2011-10-30 12:50:36 +08:00
|
|
|
fhandler_registry *fh = new (ptr) fhandler_registry (ptr);
|
2021-02-10 17:42:05 +08:00
|
|
|
fh->copy_from (this);
|
2011-10-16 06:37:30 +08:00
|
|
|
return fh;
|
|
|
|
}
|
2002-05-02 12:13:48 +08:00
|
|
|
};
|
|
|
|
|
2002-07-01 07:02:58 +08:00
|
|
|
class pinfo;
|
2002-05-02 12:13:48 +08:00
|
|
|
class fhandler_process: public fhandler_proc
|
|
|
|
{
|
2019-01-07 03:18:14 +08:00
|
|
|
protected:
|
2002-07-01 07:02:58 +08:00
|
|
|
pid_t pid;
|
2015-01-22 21:46:12 +08:00
|
|
|
virtual_ftype_t fd_type;
|
2002-05-02 12:13:48 +08:00
|
|
|
public:
|
|
|
|
fhandler_process ();
|
2010-09-06 17:47:01 +08:00
|
|
|
virtual_ftype_t exists();
|
2022-05-24 03:52:52 +08:00
|
|
|
DIR *opendir (int fd);
|
2011-10-11 02:59:56 +08:00
|
|
|
int closedir (DIR *);
|
2022-05-24 03:52:52 +08:00
|
|
|
int readdir (DIR *, dirent *);
|
* 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 08:37:18 +08:00
|
|
|
int open (int flags, mode_t mode = 0);
|
2022-05-24 03:52:52 +08:00
|
|
|
int fstat (struct stat *buf);
|
2002-07-02 09:36:15 +08:00
|
|
|
bool fill_filebuf ();
|
2011-10-16 06:37:30 +08:00
|
|
|
|
|
|
|
fhandler_process (void *) {}
|
|
|
|
|
2021-02-10 17:42:05 +08:00
|
|
|
void copy_from (fhandler_base *x)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2021-02-10 17:42:05 +08:00
|
|
|
pc.free_strings ();
|
|
|
|
*this = *reinterpret_cast<fhandler_process *> (x);
|
|
|
|
_copy_from_reset_helper ();
|
2011-10-16 06:37:30 +08:00
|
|
|
}
|
|
|
|
|
2011-11-29 23:34:49 +08:00
|
|
|
fhandler_process *clone (cygheap_types malloc_type = HEAP_FHANDLER)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2011-11-29 23:34:49 +08:00
|
|
|
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_process));
|
2011-10-30 12:50:36 +08:00
|
|
|
fhandler_process *fh = new (ptr) fhandler_process (ptr);
|
2021-02-10 17:42:05 +08:00
|
|
|
fh->copy_from (this);
|
2011-10-16 06:37:30 +08:00
|
|
|
return fh;
|
|
|
|
}
|
2002-05-02 12:13:48 +08:00
|
|
|
};
|
|
|
|
|
2019-01-07 03:18:14 +08:00
|
|
|
class fhandler_process_fd : public fhandler_process
|
|
|
|
{
|
2019-01-07 05:39:45 +08:00
|
|
|
fhandler_base *fetch_fh (HANDLE &, uint32_t);
|
2019-01-07 03:18:14 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
fhandler_process_fd () : fhandler_process () {}
|
|
|
|
fhandler_process_fd (void *) {}
|
|
|
|
|
2019-02-05 22:20:13 +08:00
|
|
|
virtual fhandler_base *fd_reopen (int, mode_t);
|
2022-05-24 03:52:52 +08:00
|
|
|
int fstat (struct stat *buf);
|
|
|
|
virtual int link (const char *);
|
2019-01-07 03:18:14 +08:00
|
|
|
|
2021-02-10 17:42:05 +08:00
|
|
|
void copy_from (fhandler_base *x)
|
2019-01-07 03:18:14 +08:00
|
|
|
{
|
2021-02-10 17:42:05 +08:00
|
|
|
pc.free_strings ();
|
|
|
|
*this = *reinterpret_cast<fhandler_process_fd *> (x);
|
|
|
|
_copy_from_reset_helper ();
|
2019-01-07 03:18:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
fhandler_process_fd *clone (cygheap_types malloc_type = HEAP_FHANDLER)
|
|
|
|
{
|
|
|
|
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_process_fd));
|
|
|
|
fhandler_process_fd *fh = new (ptr) fhandler_process_fd (ptr);
|
2021-02-10 17:42:05 +08:00
|
|
|
fh->copy_from (this);
|
2019-01-07 03:18:14 +08:00
|
|
|
return fh;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2007-01-18 03:26:58 +08:00
|
|
|
class fhandler_procnet: public fhandler_proc
|
|
|
|
{
|
|
|
|
pid_t pid;
|
|
|
|
public:
|
|
|
|
fhandler_procnet ();
|
2019-01-14 05:48:43 +08:00
|
|
|
fhandler_procnet (void *) {}
|
2010-09-06 17:47:01 +08:00
|
|
|
virtual_ftype_t exists();
|
2022-05-24 03:52:52 +08:00
|
|
|
int readdir (DIR *, dirent *);
|
2007-01-18 03:26:58 +08:00
|
|
|
int open (int flags, mode_t mode = 0);
|
2022-05-24 03:52:52 +08:00
|
|
|
int fstat (struct stat *buf);
|
2007-01-18 03:26:58 +08:00
|
|
|
bool fill_filebuf ();
|
2011-10-16 06:37:30 +08:00
|
|
|
|
2021-02-10 17:42:05 +08:00
|
|
|
void copy_from (fhandler_base *x)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2021-02-10 17:42:05 +08:00
|
|
|
pc.free_strings ();
|
|
|
|
*this = *reinterpret_cast<fhandler_procnet *> (x);
|
|
|
|
_copy_from_reset_helper ();
|
2011-10-16 06:37:30 +08:00
|
|
|
}
|
|
|
|
|
2011-11-29 23:34:49 +08:00
|
|
|
fhandler_procnet *clone (cygheap_types malloc_type = HEAP_FHANDLER)
|
2011-10-16 06:37:30 +08:00
|
|
|
{
|
2011-11-29 23:34:49 +08:00
|
|
|
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_procnet));
|
2011-10-30 12:50:36 +08:00
|
|
|
fhandler_procnet *fh = new (ptr) fhandler_procnet (ptr);
|
2021-02-10 17:42:05 +08:00
|
|
|
fh->copy_from (this);
|
2011-10-16 06:37:30 +08:00
|
|
|
return fh;
|
|
|
|
}
|
2007-01-18 03:26:58 +08:00
|
|
|
};
|
|
|
|
|
2022-02-21 21:36:37 +08:00
|
|
|
class fhandler_dev_fd: public fhandler_virtual
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
fhandler_dev_fd ();
|
|
|
|
virtual_ftype_t exists();
|
|
|
|
|
2022-05-24 03:52:52 +08:00
|
|
|
int fstat (struct stat *buf);
|
2022-02-21 21:36:37 +08:00
|
|
|
bool fill_filebuf ();
|
|
|
|
|
|
|
|
fhandler_dev_fd (void *) {}
|
|
|
|
|
|
|
|
virtual void copy_from (fhandler_base *x)
|
|
|
|
{
|
|
|
|
pc.free_strings ();
|
|
|
|
*this = *reinterpret_cast<fhandler_dev_fd *> (x);
|
|
|
|
_copy_from_reset_helper ();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual fhandler_dev_fd *clone (cygheap_types malloc_type = HEAP_FHANDLER)
|
|
|
|
{
|
|
|
|
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_dev_fd));
|
|
|
|
fhandler_dev_fd *fh = new (ptr) fhandler_dev_fd (ptr);
|
|
|
|
fh->copy_from (this);
|
|
|
|
return fh;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-01-14 06:13:33 +08:00
|
|
|
class fhandler_signalfd : public fhandler_base
|
|
|
|
{
|
|
|
|
sigset_t sigset;
|
|
|
|
|
|
|
|
public:
|
|
|
|
fhandler_signalfd ();
|
|
|
|
fhandler_signalfd (void *) {}
|
|
|
|
|
|
|
|
fhandler_signalfd *is_signalfd () { return this; }
|
|
|
|
|
|
|
|
char *get_proc_fd_name (char *buf);
|
|
|
|
|
|
|
|
int signalfd (const sigset_t *mask, int flags);
|
2022-05-24 03:52:52 +08:00
|
|
|
int fstat (struct stat *buf);
|
|
|
|
void read (void *ptr, size_t& len);
|
2022-06-07 00:00:45 +08:00
|
|
|
ssize_t write (const void *, size_t);
|
2019-01-14 06:13:33 +08:00
|
|
|
|
|
|
|
int poll ();
|
2019-01-15 00:19:37 +08:00
|
|
|
inline sigset_t get_sigset () const { return sigset; }
|
2019-01-14 06:13:33 +08:00
|
|
|
|
|
|
|
select_record *select_read (select_stuff *);
|
|
|
|
select_record *select_write (select_stuff *);
|
|
|
|
select_record *select_except (select_stuff *);
|
|
|
|
|
2021-02-10 17:42:05 +08:00
|
|
|
void copy_from (fhandler_base *x)
|
2019-01-14 06:13:33 +08:00
|
|
|
{
|
2021-02-10 17:42:05 +08:00
|
|
|
pc.free_strings ();
|
|
|
|
*this = *reinterpret_cast<fhandler_signalfd *> (x);
|
|
|
|
_copy_from_reset_helper ();
|
2019-01-14 06:13:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
fhandler_signalfd *clone (cygheap_types malloc_type = HEAP_FHANDLER)
|
|
|
|
{
|
|
|
|
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_signalfd));
|
|
|
|
fhandler_signalfd *fh = new (ptr) fhandler_signalfd (ptr);
|
2021-02-10 17:42:05 +08:00
|
|
|
fh->copy_from (this);
|
2019-01-14 06:13:33 +08:00
|
|
|
return fh;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-01-16 05:02:33 +08:00
|
|
|
class fhandler_timerfd : public fhandler_base
|
|
|
|
{
|
|
|
|
timer_t timerid;
|
|
|
|
|
|
|
|
public:
|
|
|
|
fhandler_timerfd ();
|
|
|
|
fhandler_timerfd (void *) {}
|
2019-02-26 03:58:12 +08:00
|
|
|
~fhandler_timerfd () {}
|
2019-01-16 05:02:33 +08:00
|
|
|
|
|
|
|
fhandler_timerfd *is_timerfd () { return this; }
|
|
|
|
|
|
|
|
char *get_proc_fd_name (char *buf);
|
|
|
|
|
|
|
|
int timerfd (clockid_t clock_id, int flags);
|
|
|
|
int settime (int flags, const struct itimerspec *value,
|
|
|
|
struct itimerspec *ovalue);
|
|
|
|
int gettime (struct itimerspec *ovalue);
|
|
|
|
|
2022-05-24 03:52:52 +08:00
|
|
|
int fstat (struct stat *buf);
|
|
|
|
void read (void *ptr, size_t& len);
|
2022-06-07 00:00:45 +08:00
|
|
|
ssize_t write (const void *, size_t);
|
2019-01-16 05:02:33 +08:00
|
|
|
int dup (fhandler_base *child, int);
|
|
|
|
int ioctl (unsigned int, void *);
|
|
|
|
int close ();
|
|
|
|
|
|
|
|
HANDLE get_timerfd_handle ();
|
|
|
|
|
2019-01-20 02:53:48 +08:00
|
|
|
void fixup_after_fork (HANDLE);
|
2019-01-16 22:33:15 +08:00
|
|
|
void fixup_after_exec ();
|
2019-01-16 05:02:33 +08:00
|
|
|
|
|
|
|
select_record *select_read (select_stuff *);
|
|
|
|
select_record *select_write (select_stuff *);
|
|
|
|
select_record *select_except (select_stuff *);
|
|
|
|
|
2021-02-10 17:42:05 +08:00
|
|
|
void copy_from (fhandler_base *x)
|
2019-01-16 05:02:33 +08:00
|
|
|
{
|
2021-02-10 17:42:05 +08:00
|
|
|
pc.free_strings ();
|
|
|
|
*this = *reinterpret_cast<fhandler_timerfd *> (x);
|
|
|
|
_copy_from_reset_helper ();
|
2019-01-16 05:02:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
fhandler_timerfd *clone (cygheap_types malloc_type = HEAP_FHANDLER)
|
|
|
|
{
|
|
|
|
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_timerfd));
|
|
|
|
fhandler_timerfd *fh = new (ptr) fhandler_timerfd (ptr);
|
2021-02-10 17:42:05 +08:00
|
|
|
fh->copy_from (this);
|
2019-01-16 05:02:33 +08:00
|
|
|
return fh;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-05-25 22:49:04 +08:00
|
|
|
class fhandler_mqueue: public fhandler_disk_file
|
2021-05-21 18:01:56 +08:00
|
|
|
{
|
|
|
|
struct mq_info mqi;
|
2021-05-26 02:19:19 +08:00
|
|
|
/* Duplicate filebuf usage of fhandler_virtual */
|
|
|
|
char *filebuf;
|
|
|
|
off_t filesize;
|
|
|
|
off_t position;
|
2021-05-21 18:01:56 +08:00
|
|
|
|
2021-05-26 04:03:36 +08:00
|
|
|
bool valid_path ();
|
|
|
|
|
2021-05-25 22:49:04 +08:00
|
|
|
struct mq_info *_mqinfo (SIZE_T, mode_t, int, bool);
|
|
|
|
|
|
|
|
struct mq_info *mqinfo_create (struct mq_attr *, mode_t, int);
|
|
|
|
struct mq_info *mqinfo_open (int);
|
2021-05-26 04:04:43 +08:00
|
|
|
void mq_open_finish (bool, bool);
|
2021-05-21 21:25:37 +08:00
|
|
|
|
2021-05-26 04:04:43 +08:00
|
|
|
int _dup (HANDLE, fhandler_mqueue *);
|
2021-05-25 22:50:16 +08:00
|
|
|
|
2021-05-26 02:19:19 +08:00
|
|
|
bool fill_filebuf ();
|
|
|
|
|
2021-05-26 04:04:43 +08:00
|
|
|
int mutex_lock (HANDLE, bool);
|
|
|
|
int mutex_unlock (HANDLE);
|
|
|
|
int cond_timedwait (HANDLE, HANDLE, const struct timespec *);
|
|
|
|
void cond_signal (HANDLE);
|
2021-05-26 02:15:16 +08:00
|
|
|
|
2021-05-21 18:01:56 +08:00
|
|
|
public:
|
|
|
|
fhandler_mqueue ();
|
|
|
|
fhandler_mqueue (void *) {}
|
2021-05-26 02:19:19 +08:00
|
|
|
~fhandler_mqueue ();
|
2021-05-21 18:01:56 +08:00
|
|
|
|
|
|
|
fhandler_mqueue *is_mqueue () { return this; }
|
|
|
|
|
|
|
|
char *get_proc_fd_name (char *);
|
|
|
|
|
2021-05-25 22:49:04 +08:00
|
|
|
int open (int, mode_t);
|
|
|
|
int mq_open (int, mode_t, struct mq_attr *);
|
2021-05-26 02:15:16 +08:00
|
|
|
int mq_getattr (struct mq_attr *);
|
|
|
|
int mq_setattr (const struct mq_attr *, struct mq_attr *);
|
|
|
|
int mq_notify (const struct sigevent *);
|
|
|
|
int mq_timedsend (const char *, size_t, unsigned int,
|
|
|
|
const struct timespec *);
|
|
|
|
ssize_t mq_timedrecv (char *, size_t, unsigned int *,
|
|
|
|
const struct timespec *);
|
2021-05-25 22:49:04 +08:00
|
|
|
|
2021-05-21 18:01:56 +08:00
|
|
|
struct mq_info *mqinfo () { return &mqi; }
|
|
|
|
|
|
|
|
void fixup_after_fork (HANDLE);
|
|
|
|
|
2021-05-26 05:00:32 +08:00
|
|
|
#define NO_IMPL { set_errno (EPERM); return -1; }
|
|
|
|
|
2022-05-24 03:52:52 +08:00
|
|
|
ssize_t fgetxattr (const char *, void *, size_t) NO_IMPL;
|
|
|
|
int fsetxattr (const char *, const void *, size_t, int) NO_IMPL;
|
|
|
|
int fadvise (off_t, off_t, int) NO_IMPL;
|
|
|
|
int ftruncate (off_t, bool) NO_IMPL;
|
|
|
|
int link (const char *) NO_IMPL;
|
2021-05-26 05:00:32 +08:00
|
|
|
int mkdir (mode_t) NO_IMPL;
|
2022-05-24 03:52:52 +08:00
|
|
|
ssize_t pread (void *, size_t, off_t, void *aio = NULL) NO_IMPL;
|
|
|
|
ssize_t pwrite (void *, size_t, off_t, void *aio = NULL) NO_IMPL;
|
2021-05-26 05:00:32 +08:00
|
|
|
int lock (int, struct flock *) NO_IMPL;
|
|
|
|
int mand_lock (int, struct flock *) NO_IMPL;
|
2022-05-24 03:52:52 +08:00
|
|
|
void read (void *, size_t&);
|
2021-05-26 02:19:19 +08:00
|
|
|
off_t lseek (off_t, int);
|
2022-05-24 03:52:52 +08:00
|
|
|
int fstat (struct stat *);
|
2021-05-26 02:19:19 +08:00
|
|
|
int dup (fhandler_base *, int);
|
2021-05-26 05:00:32 +08:00
|
|
|
int fcntl (int cmd, intptr_t);
|
2021-05-26 02:17:07 +08:00
|
|
|
int ioctl (unsigned int, void *);
|
2021-05-21 18:01:56 +08:00
|
|
|
int close ();
|
|
|
|
|
|
|
|
void copy_from (fhandler_base *x)
|
|
|
|
{
|
|
|
|
pc.free_strings ();
|
|
|
|
*this = *reinterpret_cast<fhandler_mqueue *> (x);
|
|
|
|
_copy_from_reset_helper ();
|
|
|
|
}
|
|
|
|
|
|
|
|
fhandler_mqueue *clone (cygheap_types malloc_type = HEAP_FHANDLER)
|
|
|
|
{
|
|
|
|
void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_mqueue));
|
|
|
|
fhandler_mqueue *fh = new (ptr) fhandler_mqueue (ptr);
|
|
|
|
fh->copy_from (this);
|
|
|
|
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 08:37:18 +08:00
|
|
|
struct fhandler_nodevice: public fhandler_base
|
|
|
|
{
|
|
|
|
fhandler_nodevice ();
|
|
|
|
int open (int flags, mode_t mode = 0);
|
|
|
|
};
|
|
|
|
|
2005-11-14 12:28:45 +08:00
|
|
|
#define report_tty_counts(fh, call, use_op) \
|
|
|
|
termios_printf ("%s %s, %susecount %d",\
|
2003-12-28 01:41:17 +08:00
|
|
|
fh->ttyname (), call,\
|
2011-06-15 05:48:43 +08:00
|
|
|
use_op, ((fhandler_pty_slave *) (fh->archetype ?: fh))->usecount);
|
2003-12-28 01:41:17 +08:00
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
typedef union
|
|
|
|
{
|
2002-10-09 12:08:05 +08:00
|
|
|
char __base[sizeof (fhandler_base)];
|
|
|
|
char __console[sizeof (fhandler_console)];
|
2012-03-30 02:02:54 +08:00
|
|
|
char __dev[sizeof (fhandler_dev)];
|
2002-10-09 12:08:05 +08:00
|
|
|
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_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)];
|
2022-02-21 21:36:37 +08:00
|
|
|
char __dev_fd[sizeof (fhandler_dev_fd)];
|
2002-10-09 12:08:05 +08:00
|
|
|
char __disk_file[sizeof (fhandler_disk_file)];
|
2005-06-17 19:44:45 +08:00
|
|
|
char __fifo[sizeof (fhandler_fifo)];
|
|
|
|
char __netdrive[sizeof (fhandler_netdrive)];
|
|
|
|
char __nodevice[sizeof (fhandler_nodevice)];
|
2002-10-09 12:08:05 +08:00
|
|
|
char __pipe[sizeof (fhandler_pipe)];
|
|
|
|
char __proc[sizeof (fhandler_proc)];
|
|
|
|
char __process[sizeof (fhandler_process)];
|
2019-01-07 03:18:14 +08:00
|
|
|
char __process_fd[sizeof (fhandler_process_fd)];
|
2010-09-06 17:47:01 +08:00
|
|
|
char __procnet[sizeof (fhandler_procnet)];
|
|
|
|
char __procsys[sizeof (fhandler_procsys)];
|
2011-04-02 03:48:19 +08:00
|
|
|
char __procsysvipc[sizeof (fhandler_procsysvipc)];
|
2002-10-09 12:08:05 +08:00
|
|
|
char __pty_master[sizeof (fhandler_pty_master)];
|
|
|
|
char __registry[sizeof (fhandler_registry)];
|
|
|
|
char __serial[sizeof (fhandler_serial)];
|
2019-01-14 06:13:33 +08:00
|
|
|
char __signalfd[sizeof (fhandler_signalfd)];
|
2019-01-16 05:02:33 +08:00
|
|
|
char __timerfd[sizeof (fhandler_timerfd)];
|
2021-05-21 18:01:56 +08:00
|
|
|
char __mqueue[sizeof (fhandler_mqueue)];
|
2018-02-22 04:40:01 +08:00
|
|
|
char __socket_inet[sizeof (fhandler_socket_inet)];
|
|
|
|
char __socket_local[sizeof (fhandler_socket_local)];
|
2018-06-26 22:31:17 +08:00
|
|
|
#ifdef __WITH_AF_UNIX
|
|
|
|
char __socket_unix[sizeof (fhandler_socket_unix)];
|
|
|
|
#endif /* __WITH_AF_UNIX */
|
2002-10-09 12:08:05 +08:00
|
|
|
char __termios[sizeof (fhandler_termios)];
|
2011-06-15 05:48:43 +08:00
|
|
|
char __pty_common[sizeof (fhandler_pty_common)];
|
|
|
|
char __pty_slave[sizeof (fhandler_pty_slave)];
|
2002-10-09 12:08:05 +08:00
|
|
|
char __virtual[sizeof (fhandler_virtual)];
|
|
|
|
char __windows[sizeof (fhandler_windows)];
|
2000-02-18 03:38:33 +08:00
|
|
|
} fhandler_union;
|