diff options
author | Christopher Faylor <me@cgf.cx> | 2003-09-25 00:37:18 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2003-09-25 00:37:18 +0000 |
commit | 7ac6173643b13a5a3bc7daf3649eb20c48c9c908 (patch) | |
tree | b6acd69d1804e5e8b7482e7b943e74aca80b5787 /winsup/cygwin/fhandler.h | |
parent | 2d9af27bf33f28984cf7b0e121bb56d1cb21897c (diff) | |
download | cygnal-7ac6173643b13a5a3bc7daf3649eb20c48c9c908.tar.gz cygnal-7ac6173643b13a5a3bc7daf3649eb20c48c9c908.tar.bz2 cygnal-7ac6173643b13a5a3bc7daf3649eb20c48c9c908.zip |
* 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.
Diffstat (limited to 'winsup/cygwin/fhandler.h')
-rw-r--r-- | winsup/cygwin/fhandler.h | 308 |
1 files changed, 154 insertions, 154 deletions
diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h index 5ab0ed51d..2ee82fcf9 100644 --- a/winsup/cygwin/fhandler.h +++ b/winsup/cygwin/fhandler.h @@ -11,9 +11,6 @@ details. */ #ifndef _FHANDLER_H_ #define _FHANDLER_H_ -#include <sys/ioctl.h> -#include <fcntl.h> - enum { FH_RBINARY = 0x00001000, /* binary read mode */ @@ -42,45 +39,9 @@ enum FH_HASACLS = 0x40000000, /* True if fs of file has ACLS */ FH_QUERYOPEN = 0x80000000, /* open file without requesting either read or write access */ - - /* Device flags */ - - /* Slow devices */ - FH_CONSOLE = 0x00000001, /* is a console */ - FH_CONIN = 0x00000002, /* console input */ - FH_CONOUT = 0x00000003, /* console output */ - FH_TTYM = 0x00000004, /* is a tty master */ - FH_TTYS = 0x00000005, /* is a tty slave */ - FH_PTYM = 0x00000006, /* is a pty master */ - FH_SERIAL = 0x00000007, /* is a serial port */ - FH_PIPE = 0x00000008, /* is a pipe */ - FH_PIPER = 0x00000009, /* read end of a pipe */ - FH_PIPEW = 0x0000000a, /* write end of a pipe */ - FH_SOCKET = 0x0000000b, /* is a socket */ - FH_WINDOWS = 0x0000000c, /* is a window */ - FH_SLOW = 0x00000010, /* "slow" device if below this */ - - /* Fast devices */ - FH_DISK = 0x00000010, /* is a disk */ - FH_FLOPPY = 0x00000011, /* is a floppy */ - FH_TAPE = 0x00000012, /* is a tape */ - FH_NULL = 0x00000013, /* is the null device */ - FH_ZERO = 0x00000014, /* is the zero device */ - FH_RANDOM = 0x00000015, /* is a random device */ - FH_MEM = 0x00000016, /* is a mem device */ - FH_CLIPBOARD = 0x00000017, /* is a clipboard device */ - FH_OSS_DSP = 0x00000018, /* is a dsp audio device */ - FH_CYGDRIVE= 0x00000019, /* /cygdrive/x */ - FH_PROC = 0x0000001a, /* /proc */ - FH_REGISTRY =0x0000001b, /* /proc/registry */ - FH_PROCESS = 0x0000001c, /* /proc/<n> */ - - FH_NDEV = 0x0000001d, /* Maximum number of devices */ - FH_DEVMASK = 0x00000fff, /* devices live here */ - FH_BAD = 0xffffffff }; -#define FHDEVN(n) ((n) & FH_DEVMASK) +#define FHDEVN(n) (n) #define FHISSETF(x) __ISSETF (this, x, FH) #define FHSETF(x) __SETF (this, x, FH) #define FHCLEARF(x) __CLEARF (this, x, FH) @@ -112,7 +73,6 @@ extern const char proc[]; extern const int proc_len; class select_record; -class path_conv; class fhandler_disk_file; typedef struct __DIR DIR; struct dirent; @@ -135,16 +95,9 @@ enum bg_check_types bg_signalled = 2 }; -enum executable_states -{ - is_executable, - dont_care_if_executable, - not_executable = dont_care_if_executable, - dont_know_if_executable -}; - class fhandler_base { + friend class dtable; protected: DWORD status; private: @@ -164,27 +117,32 @@ class fhandler_base size_t raixput; size_t rabuflen; - const char *unix_path_name; - const char *win32_path_name; DWORD open_status; DWORD fs_flags; HANDLE read_state; + path_conv pc; public: - bool set_name (const char * unix_path, const char *win32_path = NULL, int unit = 0); + void set_name (path_conv &pc); + int error () const {return pc.error;} + bool exists () const {return pc.exists ();} + int pc_binmode () const {return pc.binmode ();} + device& dev () {return pc.dev;} + operator DWORD& () {return (DWORD) pc;} virtual fhandler_base& operator =(fhandler_base &x); - fhandler_base (DWORD dev, int unit = 0); + fhandler_base (); virtual ~fhandler_base (); /* Non-virtual simple accessor functions. */ void set_io_handle (HANDLE x) { io_handle = x; } - DWORD get_device () { return status & FH_DEVMASK; } - virtual int get_unit () { return 0; } - virtual BOOL is_slow () { return get_device () < FH_SLOW; } + DWORD get_device () { return dev ().devn; } + DWORD get_major () { return dev ().major; } + DWORD get_minor () { return dev ().minor; } + virtual int get_unit () { return dev ().minor; } - int get_access () { return access; } + int get_access () const { return access; } void set_access (int x) { access = x; } bool get_async () { return FHISSETF (ASYNC); } @@ -298,8 +256,8 @@ class fhandler_base bool isremote () { return FHISSETF (ISREMOTE); } void set_isremote (int val) { FHCONDSETF (val, ISREMOTE); } - const char *get_name () { return unix_path_name; } - const char *get_win32_name () { return win32_path_name; } + const char *get_name () const { return pc.normalized_path; } + const char *get_win32_name () { return pc.get_win32 (); } __ino64_t get_namehash () { return namehash; } virtual void hclose (HANDLE h) {CloseHandle (h);} @@ -307,13 +265,29 @@ class fhandler_base /* fixup fd possibly non-inherited handles after fork */ void fork_fixup (HANDLE parent, HANDLE &h, const char *name); + virtual bool need_fixup_before () const {return false;} - virtual int open (path_conv *real_path, int flags, mode_t mode = 0); + virtual int open (int flags, mode_t mode = 0); + int open_fs (int flags, mode_t mode = 0); virtual int close (); - virtual int __stdcall fstat (struct __stat64 *buf, path_conv *) __attribute__ ((regparm (3))); + int close_fs (); + virtual int __stdcall fstat (struct __stat64 *buf) __attribute__ ((regparm (2))); + int __stdcall fstat_fs (struct __stat64 *buf) __attribute__ ((regparm (2))); + int __stdcall fstat_helper (struct __stat64 *buf, + FILETIME ftCreateionTime, + FILETIME ftLastAccessTime, + FILETIME ftLastWriteTime, + DWORD nFileSizeHigh, + DWORD nFileSizeLow, + DWORD nFileIndexHigh = 0, + DWORD nFileIndexLow = 0, + DWORD nNumberOfLinks = 1) + __attribute__ ((regparm (3))); + int __stdcall fstat_by_handle (struct __stat64 *buf) __attribute__ ((regparm (2))); + int __stdcall fstat_by_name (struct __stat64 *buf) __attribute__ ((regparm (2))); virtual int ioctl (unsigned int cmd, void *); virtual int fcntl (int cmd, void *); - virtual char const * ttyname () { return get_name(); } + virtual char const *ttyname () { return get_name(); } virtual void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3))); virtual int write (const void *ptr, size_t len); virtual ssize_t readv (const struct iovec *, int iovcnt, ssize_t tot = -1); @@ -343,9 +317,10 @@ class fhandler_base virtual int tcsetpgrp (const pid_t pid); virtual int tcgetpgrp (); virtual int is_tty () { return 0; } - virtual BOOL is_device () { return TRUE; } + virtual bool isdevice () { return true; } + virtual bool isfifo () { return false; } virtual char *ptsname () { return NULL;} - virtual class fhandler_socket *is_socket () { return 0; } + virtual class fhandler_socket *is_socket () { return NULL; } virtual class fhandler_console *is_console () { return 0; } virtual int is_windows () {return 0; } @@ -362,9 +337,9 @@ class fhandler_base virtual select_record *select_write (select_record *s); virtual select_record *select_except (select_record *s); virtual int ready_for_read (int fd, DWORD howlong); - virtual const char * get_native_name () + virtual const char *get_native_name () { - return windows_device_names[FHDEVN (status)]; + return dev ().fmt; } virtual bg_check_types bg_check (int) {return bg_ok;} void clear_readahead () @@ -375,12 +350,16 @@ class fhandler_base void operator delete (void *); virtual HANDLE get_guard () const {return NULL;} virtual void set_eof () {} - virtual DIR *opendir (path_conv& pc); + virtual DIR *opendir (); virtual dirent *readdir (DIR *); virtual _off64_t telldir (DIR *); virtual void seekdir (DIR *, _off64_t); virtual void rewinddir (DIR *); virtual int closedir (DIR *); + virtual bool is_slow () {return 0;} + bool is_auto_device () {return isdevice () && !dev ().isfs ();} + bool is_fs_special () {return dev ().isfs ();} + bool device_access_denied (int) __attribute__ ((regparm (1))); }; class fhandler_socket: public fhandler_base @@ -393,14 +372,12 @@ class fhandler_socket: public fhandler_base struct _WSAPROTOCOL_INFOA *prot_info_ptr; char *sun_path; int had_connect_or_listen; - int unit; public: - fhandler_socket (int unit); + fhandler_socket (); ~fhandler_socket (); int get_socket () { return (int) get_handle(); } - fhandler_socket * is_socket () { return this; } - int get_unit () { return unit; } + fhandler_socket *is_socket () { return this; } bool saw_shutdown_read () const {return FHISSETF (SHUTRD);} bool saw_shutdown_write () const {return FHISSETF (SHUTWR);} @@ -443,6 +420,7 @@ class fhandler_socket: public fhandler_base virtual void fixup_before_fork_exec (DWORD); void fixup_after_fork (HANDLE); void fixup_after_exec (HANDLE); + bool need_fixup_before () const {return true;} select_record *select_read (select_record *s); select_record *select_write (select_record *s); @@ -459,18 +437,20 @@ class fhandler_socket: public fhandler_base int check_peer_secret_event (struct sockaddr_in *peer, int *secret = NULL); void signal_secret_event (); void close_secret_event (); - int __stdcall fstat (struct __stat64 *buf, path_conv *) __attribute__ ((regparm (3))); + int __stdcall fstat (struct __stat64 *buf) __attribute__ ((regparm (2))); + bool is_slow () {return 1;} }; class fhandler_pipe: public fhandler_base { +protected: HANDLE guard; bool broken_pipe; HANDLE writepipe_exists; DWORD orig_pid; unsigned id; - public: - fhandler_pipe (DWORD devtype); +public: + fhandler_pipe (); _off64_t lseek (_off64_t offset, int whence); select_record *select_read (select_record *s); select_record *select_write (select_record *s); @@ -485,9 +465,33 @@ class fhandler_pipe: public fhandler_base void fixup_after_exec (HANDLE); bool hit_eof (); void set_eof () {broken_pipe = true;} - friend int make_pipe (int fildes[2], unsigned int psize, int mode); HANDLE get_guard () const {return guard;} int ready_for_read (int fd, DWORD howlong); + static int create (fhandler_pipe *[2], unsigned, int, bool = false); + bool is_slow () {return 1;} + friend class fhandler_fifo; +}; + +class fhandler_fifo: public fhandler_pipe +{ + HANDLE output_handle; + HANDLE owner; // You can't have too many mutexes, now, can you? + ATOM upand; + long read_use; + long write_use; +public: + fhandler_fifo (); + int open (int flags, mode_t mode = 0); + int open_not_mine (int flags) __attribute__ ((regparm (2))); + int close (); + void set_use (int flags) __attribute__ ((regparm (2))); + bool isfifo () { return true; } + HANDLE& get_output_handle () { return output_handle; } + void set_output_handle (HANDLE h) { output_handle = h; } + void set_use (); + int dup (fhandler_base *child); + bool is_slow () {return 1;} + ATOM& get_atom () {return upand;} }; class fhandler_dev_raw: public fhandler_base @@ -503,7 +507,6 @@ class fhandler_dev_raw: public fhandler_base int is_writing : 1; int has_written : 1; int varblkop : 1; - int unit; virtual void clear (void); virtual int writebuf (void); @@ -513,14 +516,12 @@ class fhandler_dev_raw: public fhandler_base /* returns not null, if `win_error' determines an end of file condition */ virtual int is_eof(int win_error) = 0; - fhandler_dev_raw (DWORD dev, int unit); + fhandler_dev_raw (); public: ~fhandler_dev_raw (void); - int get_unit () { return unit; } - - int open (path_conv *, int flags, mode_t mode = 0); + int open (int flags, mode_t mode = 0); int close (void); void raw_read (void *ptr, size_t& ulen); @@ -541,9 +542,9 @@ class fhandler_dev_floppy: public fhandler_dev_raw virtual int is_eof (int win_error); public: - fhandler_dev_floppy (int unit); + fhandler_dev_floppy (); - virtual int open (path_conv *, int flags, mode_t mode = 0); + virtual int open (int flags, mode_t mode = 0); virtual int close (void); virtual _off64_t lseek (_off64_t offset, int whence); @@ -564,14 +565,14 @@ class fhandler_dev_tape: public fhandler_dev_raw virtual int is_eof (int win_error); public: - fhandler_dev_tape (int unit); + fhandler_dev_tape (); - virtual int open (path_conv *, int flags, mode_t mode = 0); + virtual int open (int flags, mode_t mode = 0); virtual int close (void); virtual _off64_t lseek (_off64_t offset, int whence); - virtual int __stdcall fstat (struct __stat64 *buf, path_conv *) __attribute__ ((regparm (3))); + virtual int __stdcall fstat (struct __stat64 *buf) __attribute__ ((regparm (2))); virtual int dup (fhandler_base *child); @@ -596,32 +597,19 @@ class fhandler_disk_file: public fhandler_base { public: fhandler_disk_file (); - fhandler_disk_file (DWORD devtype); - int open (path_conv * real_path, int flags, mode_t mode); + int open (int flags, mode_t mode); int close (); int lock (int, struct flock *); - BOOL is_device () { return FALSE; } - int __stdcall fstat (struct __stat64 *buf, path_conv *pc) __attribute__ ((regparm (3))); - int __stdcall fstat_helper (struct __stat64 *buf, path_conv *pc, - FILETIME ftCreateionTime, - FILETIME ftLastAccessTime, - FILETIME ftLastWriteTime, - DWORD nFileSizeHigh, - DWORD nFileSizeLow, - DWORD nFileIndexHigh = 0, - DWORD nFileIndexLow = 0, - DWORD nNumberOfLinks = 1) - __attribute__ ((regparm (3))); - int __stdcall fstat_by_handle (struct __stat64 *buf, path_conv *pc) __attribute__ ((regparm (3))); - int __stdcall fstat_by_name (struct __stat64 *buf, path_conv *pc) __attribute__ ((regparm (3))); + bool isdevice () { return false; } + int __stdcall fstat (struct __stat64 *buf) __attribute__ ((regparm (2))); HANDLE mmap (caddr_t *addr, size_t len, DWORD access, int flags, _off64_t off); int munmap (HANDLE h, caddr_t addr, size_t len); int msync (HANDLE h, caddr_t addr, size_t len, int flags); BOOL fixup_mmap_after_fork (HANDLE h, DWORD access, DWORD offset, DWORD size, void *address); - DIR *opendir (path_conv& pc); + DIR *opendir (); struct dirent *readdir (DIR *); _off64_t telldir (DIR *); void seekdir (DIR *, _off64_t); @@ -631,20 +619,19 @@ class fhandler_disk_file: public fhandler_base class fhandler_cygdrive: public fhandler_disk_file { - int unit; int ndrives; const char *pdrive; void set_drives (); public: - bool iscygdrive_root () const { return !unit; } - fhandler_cygdrive (int unit); - DIR *opendir (path_conv& pc); + bool iscygdrive_root () { return !dev ().minor; } + fhandler_cygdrive (); + DIR *opendir (); struct dirent *readdir (DIR *); _off64_t telldir (DIR *); void seekdir (DIR *, _off64_t); void rewinddir (DIR *); int closedir (DIR *); - int __stdcall fstat (struct __stat64 *buf, path_conv *pc) __attribute__ ((regparm (3))); + int __stdcall fstat (struct __stat64 *buf) __attribute__ ((regparm (2))); }; class fhandler_serial: public fhandler_base @@ -662,9 +649,9 @@ class fhandler_serial: public fhandler_base DWORD ev; /* Constructor */ - fhandler_serial (int unit); + fhandler_serial (); - int open (path_conv *, int flags, mode_t mode); + int open (int flags, mode_t mode); int close (); void init (HANDLE h, DWORD a, mode_t flags); void overlapped_setup (); @@ -692,6 +679,7 @@ class fhandler_serial: public fhandler_base select_record *select_read (select_record *s); select_record *select_write (select_record *s); select_record *select_except (select_record *s); + bool is_slow () {return 1;} }; #define acquire_output_mutex(ms) \ @@ -710,8 +698,8 @@ class fhandler_termios: public fhandler_base virtual int accept_input () {return 1;}; public: tty_min *tc; - fhandler_termios (DWORD dev, int unit = 0) : - fhandler_base (dev, unit) + fhandler_termios () : + fhandler_base () { set_need_fork_fixup (); } @@ -817,7 +805,7 @@ class fhandler_console: public fhandler_termios void cursor_set (BOOL, int, int); void cursor_get (int *, int *); void cursor_rel (int, int); - const unsigned char * write_normal (unsigned const char*, unsigned const char *); + const unsigned char *write_normal (unsigned const char*, unsigned const char *); void char_command (char); BOOL set_raw_win32_keyboard_mode (BOOL); int output_tcsetattr (int a, const struct termios *t); @@ -834,7 +822,7 @@ class fhandler_console: public fhandler_termios fhandler_console* is_console () { return this; } - int open (path_conv *, int flags, mode_t mode = 0); + int open (int flags, mode_t mode = 0); int write (const void *ptr, size_t len); void doecho (const void *str, DWORD len) { (void) write (str, len); } @@ -861,15 +849,16 @@ class fhandler_console: public fhandler_termios void set_input_state (); void send_winch_maybe (); static tty_min *get_tty_stuff (int); + bool is_slow () {return 1;} }; class fhandler_tty_common: public fhandler_termios { public: - fhandler_tty_common (DWORD dev, int unit = 0) - : fhandler_termios (dev, unit), output_done_event (NULL), + fhandler_tty_common () + : fhandler_termios (), output_done_event (NULL), ioctl_request_event (NULL), ioctl_done_event (NULL), output_mutex (NULL), - input_mutex (NULL), input_available_event (NULL), inuse (NULL), ttynum (unit) + input_mutex (NULL), input_available_event (NULL), inuse (NULL) { // nothing to do } @@ -882,7 +871,6 @@ class fhandler_tty_common: public fhandler_termios HANDLE output_mutex, input_mutex; HANDLE input_available_event; HANDLE inuse; // used to indicate that a tty is in use - int ttynum; // Master tty num. DWORD __acquire_output_mutex (const char *fn, int ln, DWORD ms); void __release_output_mutex (const char *fn, int ln); @@ -890,7 +878,6 @@ class fhandler_tty_common: public fhandler_termios virtual int dup (fhandler_base *child); tty *get_ttyp () { return (tty *)tc; } - int get_unit () { return ttynum; } int close (); void set_close_on_exec (int val); @@ -898,6 +885,7 @@ class fhandler_tty_common: public fhandler_termios select_record *select_read (select_record *s); select_record *select_write (select_record *s); select_record *select_except (select_record *s); + bool is_slow () {return 1;} }; class fhandler_tty_slave: public fhandler_tty_common @@ -905,9 +893,8 @@ class fhandler_tty_slave: public fhandler_tty_common public: /* Constructor */ fhandler_tty_slave (); - fhandler_tty_slave (int); - int open (path_conv *, int flags, mode_t mode = 0); + int open (int flags, mode_t mode = 0); int write (const void *ptr, size_t len); void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3))); void init (HANDLE, DWORD, mode_t); @@ -923,21 +910,24 @@ class fhandler_tty_slave: public fhandler_tty_common _off64_t lseek (_off64_t, int) { return 0; } select_record *select_read (select_record *s); int cygserver_attach_tty (HANDLE*, HANDLE*); + int get_unit () __attribute__ ((regparm (1))); }; class fhandler_pty_master: public fhandler_tty_common { int pktmode; // non-zero if pty in a packet mode. - public: +protected: + device slave; // device type of slave +public: int need_nl; // Next read should start with \n /* Constructor */ - fhandler_pty_master (DWORD devtype = FH_PTYM, int unit = -1); + fhandler_pty_master (); int process_slave_output (char *buf, size_t len, int pktmode_on); void doecho (const void *str, DWORD len); int accept_input (); - int open (path_conv *, int flags, mode_t mode = 0); + int open (int flags, mode_t mode = 0); int write (const void *ptr, size_t len); void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3))); int close (); @@ -952,6 +942,7 @@ class fhandler_pty_master: public fhandler_tty_common void set_close_on_exec (int val); bool hit_eof (); + int get_unit () const { return slave.minor; } }; class fhandler_tty_master: public fhandler_pty_master @@ -960,12 +951,13 @@ class fhandler_tty_master: public fhandler_pty_master /* Constructor */ fhandler_console *console; // device handler to perform real i/o. - fhandler_tty_master (int unit); - int init (int); + fhandler_tty_master (); + int init (); int init_console (); void set_winsize (bool); void fixup_after_fork (HANDLE parent); void fixup_after_exec (HANDLE); + bool is_slow () {return 1;} }; class fhandler_dev_null: public fhandler_base @@ -983,7 +975,7 @@ class fhandler_dev_zero: public fhandler_base { public: fhandler_dev_zero (); - int open (path_conv *, int flags, mode_t mode = 0); + int open (int flags, mode_t mode = 0); int write (const void *ptr, size_t len); void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3))); _off64_t lseek (_off64_t offset, int whence); @@ -994,7 +986,6 @@ class fhandler_dev_zero: public fhandler_base class fhandler_dev_random: public fhandler_base { protected: - int unit; HCRYPTPROV crypt_prov; long pseudo; @@ -1003,9 +994,8 @@ class fhandler_dev_random: public fhandler_base int pseudo_read (void *ptr, size_t len); public: - fhandler_dev_random (int unit); - int get_unit () { return unit; } - int open (path_conv *, int flags, mode_t mode = 0); + fhandler_dev_random (); + int open (int flags, mode_t mode = 0); int write (const void *ptr, size_t len); void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3))); _off64_t lseek (_off64_t offset, int whence); @@ -1018,20 +1008,19 @@ class fhandler_dev_random: public fhandler_base class fhandler_dev_mem: public fhandler_base { protected: - int unit; DWORD mem_size; _off64_t pos; public: - fhandler_dev_mem (int unit); + fhandler_dev_mem (); ~fhandler_dev_mem (void); - int open (path_conv *, int flags, mode_t mode = 0); + int open (int flags, mode_t mode = 0); int write (const void *ptr, size_t ulen); void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3))); _off64_t lseek (_off64_t offset, int whence); int close (void); - int __stdcall fstat (struct __stat64 *buf, path_conv *) __attribute__ ((regparm (3))); + int __stdcall fstat (struct __stat64 *buf) __attribute__ ((regparm (2))); int dup (fhandler_base *child); HANDLE mmap (caddr_t *addr, size_t len, DWORD access, int flags, _off64_t off); @@ -1048,7 +1037,7 @@ class fhandler_dev_clipboard: public fhandler_base public: fhandler_dev_clipboard (); int is_windows (void) { return 1; } - int open (path_conv *, int flags, mode_t mode = 0); + int open (int flags, mode_t mode = 0); int write (const void *ptr, size_t len); void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3))); _off64_t lseek (_off64_t offset, int whence); @@ -1073,7 +1062,7 @@ class fhandler_windows: public fhandler_base public: fhandler_windows (); int is_windows (void) { return 1; } - int open (path_conv *, int flags, mode_t mode = 0); + int open (int flags, mode_t mode = 0); int write (const void *ptr, size_t len); void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3))); int ioctl (unsigned int cmd, void *); @@ -1085,6 +1074,7 @@ class fhandler_windows: public fhandler_base select_record *select_read (select_record *s); select_record *select_write (select_record *s); select_record *select_except (select_record *s); + bool is_slow () {return 1;} }; class fhandler_dev_dsp : public fhandler_base @@ -1099,13 +1089,13 @@ class fhandler_dev_dsp : public fhandler_base fhandler_dev_dsp (); ~fhandler_dev_dsp(); - int open (path_conv *, int flags, mode_t mode = 0); + int open (int flags, mode_t mode = 0); int write (const void *ptr, size_t len); void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3))); int ioctl (unsigned int cmd, void *); _off64_t lseek (_off64_t, int); int close (void); - int dup (fhandler_base * child); + int dup (fhandler_base *child); void dump (void); void fixup_after_exec (HANDLE); }; @@ -1120,11 +1110,11 @@ class fhandler_virtual : public fhandler_base int fileid; // unique within each class public: - fhandler_virtual (DWORD devtype); + fhandler_virtual (); virtual ~fhandler_virtual(); virtual int exists(); - DIR *opendir (path_conv& pc); + DIR *opendir (); _off64_t telldir (DIR *); void seekdir (DIR *, _off64_t); void rewinddir (DIR *); @@ -1132,9 +1122,10 @@ class fhandler_virtual : public fhandler_base int write (const void *ptr, size_t len); void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3))); _off64_t lseek (_off64_t, int); - int dup (fhandler_base * child); - int open (path_conv *, int flags, mode_t mode = 0); + int dup (fhandler_base *child); + int open (int flags, mode_t mode = 0); int close (void); + int __stdcall fstat (struct stat *buf) __attribute__ ((regparm (2))); virtual bool fill_filebuf (); void fixup_after_exec (HANDLE); }; @@ -1143,13 +1134,12 @@ class fhandler_proc: public fhandler_virtual { public: fhandler_proc (); - fhandler_proc (DWORD devtype); int exists(); struct dirent *readdir (DIR *); static DWORD get_proc_fhandler(const char *path); - int open (path_conv *real_path, int flags, mode_t mode = 0); - int __stdcall fstat (struct __stat64 *buf, path_conv *) __attribute__ ((regparm (3))); + int open (int flags, mode_t mode = 0); + int __stdcall fstat (struct __stat64 *buf) __attribute__ ((regparm (2))); bool fill_filebuf (); }; @@ -1166,8 +1156,8 @@ class fhandler_registry: public fhandler_proc void rewinddir (DIR *); int closedir (DIR *); - int open (path_conv *real_path, int flags, mode_t mode = 0); - int __stdcall fstat (struct __stat64 *buf, path_conv *) __attribute__ ((regparm (3))); + int open (int flags, mode_t mode = 0); + int __stdcall fstat (struct __stat64 *buf) __attribute__ ((regparm (2))); bool fill_filebuf (); int close (void); }; @@ -1180,11 +1170,18 @@ class fhandler_process: public fhandler_proc fhandler_process (); int exists(); struct dirent *readdir (DIR *); - int open (path_conv *real_path, int flags, mode_t mode = 0); - int __stdcall fstat (struct __stat64 *buf, path_conv *) __attribute__ ((regparm (3))); + int open (int flags, mode_t mode = 0); + int __stdcall fstat (struct __stat64 *buf) __attribute__ ((regparm (2))); bool fill_filebuf (); }; +struct fhandler_nodevice: public fhandler_base +{ + fhandler_nodevice (); + int open (int flags, mode_t mode = 0); + // int __stdcall fstat (struct __stat64 *buf, path_conv *); +}; + typedef union { char __base[sizeof (fhandler_base)]; @@ -1213,6 +1210,7 @@ typedef union char __tty_slave[sizeof (fhandler_tty_slave)]; char __virtual[sizeof (fhandler_virtual)]; char __windows[sizeof (fhandler_windows)]; + char __nodevice[sizeof (fhandler_nodevice)]; } fhandler_union; struct select_record @@ -1245,19 +1243,21 @@ class select_stuff { public: ~select_stuff (); - select_stuff (): always_ready (0), windows_used (0), start (0) - { - memset (device_specific, 0, sizeof (device_specific)); - } bool always_ready, windows_used; select_record start; - void *device_specific[FH_NDEV]; + void *device_specific_pipe; + void *device_specific_socket; + void *device_specific_serial; int test_and_set (int i, fd_set *readfds, fd_set *writefds, fd_set *exceptfds); int poll (fd_set *readfds, fd_set *writefds, fd_set *exceptfds); int wait (fd_set *readfds, fd_set *writefds, fd_set *exceptfds, DWORD ms); void cleanup (); + select_stuff (): always_ready (0), windows_used (0), start (0), + device_specific_pipe (0), + device_specific_socket (0), + device_specific_serial (0) {} }; int __stdcall set_console_state_for_spawn (); |