* 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.
This commit is contained in:
parent
2d9af27bf3
commit
7ac6173643
@ -1,3 +1,218 @@
|
|||||||
|
2003-09-24 Christopher Faylor <cgf@redhat.com>
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
|
2003-09-24 Christopher Faylor <cgf@redhat.com>
|
||||||
|
|
||||||
|
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-22 Christopher Faylor <cgf@redhat.com>
|
2003-09-22 Christopher Faylor <cgf@redhat.com>
|
||||||
|
|
||||||
* dcrt0.cc (do_exit): Eliminate "C" linkage. Call events_terminate
|
* dcrt0.cc (do_exit): Eliminate "C" linkage. Call events_terminate
|
||||||
@ -37,7 +252,7 @@
|
|||||||
|
|
||||||
2003-09-18 Corinna Vinschen <corinna@vinschen.de>
|
2003-09-18 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* fhandler_tty.cc (fhandler_pty_master::process_slave_output):
|
* fhandler_tty.cc (fhandler_pty_master::process_slave_output):
|
||||||
Handle buf == NULL as flushing the buffer.
|
Handle buf == NULL as flushing the buffer.
|
||||||
(fhandler_tty_slave::read): Handle ptr == NULL as flushing the buffer.
|
(fhandler_tty_slave::read): Handle ptr == NULL as flushing the buffer.
|
||||||
(fhandler_tty_slave::tcflush): Implement input queue flushing by
|
(fhandler_tty_slave::tcflush): Implement input queue flushing by
|
||||||
@ -97,18 +312,18 @@
|
|||||||
|
|
||||||
* security.h (__sec_user): Add "access2" argument.
|
* security.h (__sec_user): Add "access2" argument.
|
||||||
(sec_acl): Add "original" and "access2" arguments.
|
(sec_acl): Add "original" and "access2" arguments.
|
||||||
(sec_user): Add "sid2" and "access2" argument. Remove dependence on
|
(sec_user): Add "sid2" and "access2" argument. Remove dependence on
|
||||||
allow_ntsec.
|
allow_ntsec.
|
||||||
(sec_user_nih): Ditto.
|
(sec_user_nih): Ditto.
|
||||||
* sec_helper.cc (__sec_user): Add "has_security" test.
|
* sec_helper.cc (__sec_user): Add "has_security" test.
|
||||||
Call sec_acl with new arguments, letting it handle original_sid.
|
Call sec_acl with new arguments, letting it handle original_sid.
|
||||||
(sec_acl): Add "original" and "access2" arguments. Handle original_sid
|
(sec_acl): Add "original" and "access2" arguments. Handle original_sid
|
||||||
depending on flag but avoiding duplicates. Use "access2" for sid2.
|
depending on flag but avoiding duplicates. Use "access2" for sid2.
|
||||||
* pinfo.cc (pinfo::init): Use security attributes created by sec_user
|
* pinfo.cc (pinfo::init): Use security attributes created by sec_user
|
||||||
when creating the mapping.
|
when creating the mapping.
|
||||||
* security.cc (create_token): Adjust arguments in call to sec_acl.
|
* security.cc (create_token): Adjust arguments in call to sec_acl.
|
||||||
Call sec_user instead of __sec_user.
|
Call sec_user instead of __sec_user.
|
||||||
* syscall.cc (seteuid32): Adjust arguments in call to sec_acl. Remove
|
* syscall.cc (seteuid32): Adjust arguments in call to sec_acl. Remove
|
||||||
now unnecessary test. Remove useless conversions to psid.
|
now unnecessary test. Remove useless conversions to psid.
|
||||||
* dcrt0.cc (dll_crt0_1): Call cygsid::init before pinfo_init.
|
* dcrt0.cc (dll_crt0_1): Call cygsid::init before pinfo_init.
|
||||||
|
|
||||||
@ -290,11 +505,11 @@
|
|||||||
* security.h: Add _SECURITY_H guard.
|
* security.h: Add _SECURITY_H guard.
|
||||||
(sec_user): Use sec_none in the no ntsec case.
|
(sec_user): Use sec_none in the no ntsec case.
|
||||||
* spawn.cc (spawn_guts): Remove call to load_registry_hive.
|
* spawn.cc (spawn_guts): Remove call to load_registry_hive.
|
||||||
* syscalls (seteuid32): If warranted, call load_registry_hive,
|
* syscalls (seteuid32): If warranted, call load_registry_hive,
|
||||||
user_shared_initialize and RegCloseKey(HKEY_CURRENT_USER).
|
user_shared_initialize and RegCloseKey(HKEY_CURRENT_USER).
|
||||||
* shared.cc (user_shared_initialize): New.
|
* shared.cc (user_shared_initialize): New.
|
||||||
(open_shared): Add and use psa argument.
|
(open_shared): Add and use psa argument.
|
||||||
(memory_init): Move mount table initialization to
|
(memory_init): Move mount table initialization to
|
||||||
user_shared_initialize. Call it.
|
user_shared_initialize. Call it.
|
||||||
|
|
||||||
2003-09-09 Corinna Vinschen <corinna@vinschen.de>
|
2003-09-09 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
@ -48,37 +48,6 @@ override INSTALL_DATA:=@INSTALL_DATA@
|
|||||||
MT_SAFE:=@MT_SAFE@
|
MT_SAFE:=@MT_SAFE@
|
||||||
DEFS:=@DEFS@
|
DEFS:=@DEFS@
|
||||||
|
|
||||||
# cygheap_CFLAGS:=-fomit-frame-pointer
|
|
||||||
malloc_CFLAGS:=-fomit-frame-pointer
|
|
||||||
malloc_wrapper_CFLAGS:=-fomit-frame-pointer
|
|
||||||
shared_CFLAGS:=-fomit-frame-pointer
|
|
||||||
cygthread_CFLAGS:=-fomit-frame-pointer
|
|
||||||
miscfuncs_CFLAGS:=-fomit-frame-pointer
|
|
||||||
fhandler_CFLAGS:=-fomit-frame-pointer
|
|
||||||
fhandler_clipboard_CFLAGS:=-fomit-frame-pointer
|
|
||||||
fhandler_console_CFLAGS:=-fomit-frame-pointer
|
|
||||||
fhandler_disk_file_CFLAGS:=-fomit-frame-pointer
|
|
||||||
fhandler_dsp_CFLAGS:=-fomit-frame-pointer
|
|
||||||
fhandler_floppy_CFLAGS:=-fomit-frame-pointer
|
|
||||||
fhandler_mem_CFLAGS:=-fomit-frame-pointer
|
|
||||||
fhandler_proc_CFLAGS:=-fomit-frame-pointer
|
|
||||||
fhandler_process_CFLAGS:=-fomit-frame-pointer
|
|
||||||
fhandler_random_CFLAGS:=-fomit-frame-pointer
|
|
||||||
fhandler_raw_CFLAGS:=-fomit-frame-pointer
|
|
||||||
fhandler_registry_CFLAGS:=-fomit-frame-pointer
|
|
||||||
fhandler_serial_CFLAGS:=-fomit-frame-pointer
|
|
||||||
fhandler_socket_CFLAGS:=-fomit-frame-pointer
|
|
||||||
fhandler_tape_CFLAGS:=-fomit-frame-pointer
|
|
||||||
fhandler_termios_CFLAGS:=-fomit-frame-pointer
|
|
||||||
fhandler_tty_CFLAGS:=-fomit-frame-pointer
|
|
||||||
fhandler_virtual_CFLAGS:=-fomit-frame-pointer
|
|
||||||
fhandler_windows_CFLAGS:=-fomit-frame-pointer
|
|
||||||
fhandler_zero_CFLAGS:=-fomit-frame-pointer
|
|
||||||
regcomp_CFLAGS=-fomit-frame-pointer
|
|
||||||
regerror_CFLAGS=-fomit-frame-pointer
|
|
||||||
regexec_CFLAGS=-fomit-frame-pointer
|
|
||||||
regfree_CFLAGS=-fomit-frame-pointer
|
|
||||||
|
|
||||||
CC:=@CC@
|
CC:=@CC@
|
||||||
# FIXME: Which is it, CC or CC_FOR_TARGET?
|
# FIXME: Which is it, CC or CC_FOR_TARGET?
|
||||||
CC_FOR_TARGET:=$(CC)
|
CC_FOR_TARGET:=$(CC)
|
||||||
@ -146,14 +115,15 @@ MALLOC_OFILES=@MALLOC_OFILES@
|
|||||||
|
|
||||||
DLL_IMPORTS:=$(w32api_lib)/libkernel32.a
|
DLL_IMPORTS:=$(w32api_lib)/libkernel32.a
|
||||||
|
|
||||||
|
MT_SAFE_OBJECTS:=
|
||||||
# Please maintain this list in sorted order, with maximum files per 80 col line
|
# Please maintain this list in sorted order, with maximum files per 80 col line
|
||||||
DLL_OFILES:=assert.o autoload.o bsdlib.o cxx.o cygheap.o cygthread.o dcrt0.o \
|
DLL_OFILES:=assert.o autoload.o bsdlib.o cxx.o cygheap.o cygthread.o dcrt0.o \
|
||||||
debug.o delqueue.o dir.o dlfcn.o dll_init.o dtable.o environ.o \
|
debug.o delqueue.o devices.o dir.o dlfcn.o dll_init.o dtable.o environ.o \
|
||||||
errno.o exceptions.o exec.o external.o fcntl.o fhandler.o \
|
errno.o exceptions.o exec.o external.o fcntl.o fhandler.o \
|
||||||
fhandler_clipboard.o fhandler_console.o fhandler_disk_file.o \
|
fhandler_clipboard.o fhandler_console.o fhandler_disk_file.o \
|
||||||
fhandler_dsp.o fhandler_floppy.o fhandler_mem.o \
|
fhandler_dsp.o fhandler_fifo.o fhandler_floppy.o fhandler_mem.o \
|
||||||
fhandler_proc.o fhandler_process.o fhandler_random.o \
|
fhandler_nodevice.o fhandler_proc.o fhandler_process.o \
|
||||||
fhandler_raw.o fhandler_registry.o fhandler_serial.o \
|
fhandler_random.o fhandler_raw.o fhandler_registry.o fhandler_serial.o \
|
||||||
fhandler_socket.o fhandler_tape.o fhandler_termios.o \
|
fhandler_socket.o fhandler_tape.o fhandler_termios.o \
|
||||||
fhandler_tty.o fhandler_virtual.o fhandler_windows.o \
|
fhandler_tty.o fhandler_virtual.o fhandler_windows.o \
|
||||||
fhandler_zero.o fnmatch.o fork.o getopt.o glob.o grp.o heap.o init.o \
|
fhandler_zero.o fnmatch.o fork.o getopt.o glob.o grp.o heap.o init.o \
|
||||||
@ -243,6 +213,40 @@ SUBLIBS:=$(PWD)/libpthread.a $(PWD)/libm.a $(PWD)/libc.a
|
|||||||
EXTRALIBS:=libautomode.a libbinmode.a libtextmode.a
|
EXTRALIBS:=libautomode.a libbinmode.a libtextmode.a
|
||||||
INSTOBJS:=automode.o binmode.o textmode.o
|
INSTOBJS:=automode.o binmode.o textmode.o
|
||||||
TARGET_LIBS:=$(LIB_NAME) $(CYGWIN_START) $(GMON_START) $(LIBGMON_A) $(SUBLIBS) $(INSTOBJS) $(EXTRALIBS)
|
TARGET_LIBS:=$(LIB_NAME) $(CYGWIN_START) $(GMON_START) $(LIBGMON_A) $(SUBLIBS) $(INSTOBJS) $(EXTRALIBS)
|
||||||
|
|
||||||
|
ifneq "${filter -O%,$(CFLAGS)}" ""
|
||||||
|
cygheap_CFLAGS:=-fomit-frame-pointer
|
||||||
|
malloc_CFLAGS:=-fomit-frame-pointer
|
||||||
|
malloc_wrapper_CFLAGS:=-fomit-frame-pointer
|
||||||
|
shared_CFLAGS:=-fomit-frame-pointer
|
||||||
|
cygthread_CFLAGS:=-fomit-frame-pointer
|
||||||
|
miscfuncs_CFLAGS:=-fomit-frame-pointer
|
||||||
|
fhandler_CFLAGS:=-fomit-frame-pointer
|
||||||
|
fhandler_clipboard_CFLAGS:=-fomit-frame-pointer
|
||||||
|
fhandler_console_CFLAGS:=-fomit-frame-pointer
|
||||||
|
fhandler_disk_file_CFLAGS:=-fomit-frame-pointer
|
||||||
|
fhandler_dsp_CFLAGS:=-fomit-frame-pointer
|
||||||
|
fhandler_floppy_CFLAGS:=-fomit-frame-pointer
|
||||||
|
fhandler_mem_CFLAGS:=-fomit-frame-pointer
|
||||||
|
fhandler_proc_CFLAGS:=-fomit-frame-pointer
|
||||||
|
fhandler_process_CFLAGS:=-fomit-frame-pointer
|
||||||
|
fhandler_random_CFLAGS:=-fomit-frame-pointer
|
||||||
|
fhandler_raw_CFLAGS:=-fomit-frame-pointer
|
||||||
|
fhandler_registry_CFLAGS:=-fomit-frame-pointer
|
||||||
|
fhandler_serial_CFLAGS:=-fomit-frame-pointer
|
||||||
|
fhandler_socket_CFLAGS:=-fomit-frame-pointer
|
||||||
|
fhandler_tape_CFLAGS:=-fomit-frame-pointer
|
||||||
|
fhandler_termios_CFLAGS:=-fomit-frame-pointer
|
||||||
|
fhandler_tty_CFLAGS:=-fomit-frame-pointer
|
||||||
|
fhandler_virtual_CFLAGS:=-fomit-frame-pointer
|
||||||
|
fhandler_windows_CFLAGS:=-fomit-frame-pointer
|
||||||
|
fhandler_zero_CFLAGS:=-fomit-frame-pointer
|
||||||
|
regcomp_CFLAGS=-fomit-frame-pointer
|
||||||
|
regerror_CFLAGS=-fomit-frame-pointer
|
||||||
|
regexec_CFLAGS=-fomit-frame-pointer
|
||||||
|
regfree_CFLAGS=-fomit-frame-pointer
|
||||||
|
endif
|
||||||
|
|
||||||
.PHONY: all force dll_ofiles install all_target install_target all_host install_host \
|
.PHONY: all force dll_ofiles install all_target install_target all_host install_host \
|
||||||
install install-libs install-headers -lgcc
|
install install-libs install-headers -lgcc
|
||||||
|
|
||||||
@ -382,6 +386,12 @@ dcrt0.o sigproc.o: child_info_magic.h
|
|||||||
|
|
||||||
shared.o: shared_info_magic.h
|
shared.o: shared_info_magic.h
|
||||||
|
|
||||||
|
$(srcdir)/devices.cc: cygwin-gperf devices.gperf devices.h
|
||||||
|
$^ > $@
|
||||||
|
|
||||||
|
$(srcdir)/qevices.cc: cygwin-shilka devices.shilka devices.h
|
||||||
|
${wordlist 1,2,$^} $@
|
||||||
|
|
||||||
$(PWD)/libpthread.a: speclib $(LIB_NAME) pthread.o thread.o
|
$(PWD)/libpthread.a: speclib $(LIB_NAME) pthread.o thread.o
|
||||||
/bin/sh ${word 1, $^} $@ "${NM}" "$(AR)" ${wordlist 2, 99, $^}
|
/bin/sh ${word 1, $^} $@ "${NM}" "$(AR)" ${wordlist 2, 99, $^}
|
||||||
|
|
||||||
|
@ -13,8 +13,8 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include "fhandler.h"
|
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
|
@ -284,6 +284,7 @@ class cygheap_fdmanip
|
|||||||
}
|
}
|
||||||
operator int &() {return fd;}
|
operator int &() {return fd;}
|
||||||
operator fhandler_base* &() {return *fh;}
|
operator fhandler_base* &() {return *fh;}
|
||||||
|
operator fhandler_socket* () const {return reinterpret_cast<fhandler_socket *> (*fh);}
|
||||||
void operator = (fhandler_base *fh) {*this->fh = fh;}
|
void operator = (fhandler_base *fh) {*this->fh = fh;}
|
||||||
fhandler_base *operator -> () const {return *fh;}
|
fhandler_base *operator -> () const {return *fh;}
|
||||||
bool isopen () const
|
bool isopen () const
|
||||||
|
153
winsup/cygwin/cygwin-gperf
Executable file
153
winsup/cygwin/cygwin-gperf
Executable file
@ -0,0 +1,153 @@
|
|||||||
|
#!/usr/bin/perl
|
||||||
|
use strict;
|
||||||
|
sub read_devices($%);
|
||||||
|
my $infile = shift;
|
||||||
|
my $incfile = shift;
|
||||||
|
open(GPERF, "gperf -c --key-positions='5-8,1-2,9-10' -r -t -C -E " .
|
||||||
|
"-T -L 'ANSI-C' -Hdevhash -N'device::lookup' -Z devstring " .
|
||||||
|
"-7 -G $infile |");
|
||||||
|
my @lines = <GPERF>;
|
||||||
|
my $ix = 0;
|
||||||
|
my $i = 0;
|
||||||
|
my $n = -1;
|
||||||
|
my $findclose = 0;
|
||||||
|
my $add_device = '';
|
||||||
|
my %fh_static;
|
||||||
|
my %fh_declare = (
|
||||||
|
'cygdrive' => 'dev_cygdrive_storage',
|
||||||
|
'fs' => 'dev_fs_storage',
|
||||||
|
'proc' => 'dev_proc_storage',
|
||||||
|
'registry' => 'dev_registry_storage',
|
||||||
|
'process' => 'dev_process_storage',
|
||||||
|
'piper' => 'dev_piper_storage',
|
||||||
|
'pipew' => 'dev_pipew_storage',
|
||||||
|
'tcp' => 'dev_tcp_storage',
|
||||||
|
'udp' => 'dev_udp_storage',
|
||||||
|
'icmp' => 'dev_icmp_storage',
|
||||||
|
'unix' => 'dev_unix_storage',
|
||||||
|
'stream' => 'dev_stream_storage',
|
||||||
|
'dgram' => 'dev_dgram_storage'
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach (@lines) {
|
||||||
|
$i++;
|
||||||
|
s/\[(str\[[^\]]*\])\]/[(unsigned) cyg_tolower ($1)]/o and next;
|
||||||
|
s/static (.* )wordlist/static NO_COPY $1wordlist/o and do {
|
||||||
|
$findclose = 1;
|
||||||
|
};
|
||||||
|
s/([ ]*)if \(\*str.*$/$1if (strncasematch (str, s, len))/o and next;
|
||||||
|
$findclose and /};/o and do {
|
||||||
|
$_ .= "\n";
|
||||||
|
$_ .=<<'EOF';
|
||||||
|
const device dev_cygdrive_storage =
|
||||||
|
{"/cygdrive", FH_CYGDRIVE, "/cygdrive", 0, 0, 0, 0};
|
||||||
|
|
||||||
|
const device dev_fs_storage =
|
||||||
|
{"", FH_FS, "", 0, 0, 0, 0};
|
||||||
|
|
||||||
|
const device dev_proc_storage =
|
||||||
|
{"", FH_PROC, "", 0, 0, 0, 0};
|
||||||
|
|
||||||
|
const device dev_registry_storage =
|
||||||
|
{"", FH_REGISTRY, "", 0, 0, 0, 0};
|
||||||
|
|
||||||
|
const device dev_process_storage =
|
||||||
|
{"", FH_PROCESS, "", 0, 0, 0, 0};
|
||||||
|
|
||||||
|
const device dev_tcp_storage =
|
||||||
|
{"/dev/inet/tcp", FH_TCP, "", 0, 0, 0, 0};
|
||||||
|
|
||||||
|
const device dev_udp_storage =
|
||||||
|
{"/dev/inet/udp", FH_UCP, "", 0, 0, 0, 0};
|
||||||
|
|
||||||
|
const device dev_icmp_storage =
|
||||||
|
{"/dev/inet/icmp", FH_ICMP, "", 0, 0, 0, 0};
|
||||||
|
|
||||||
|
const device dev_unix_storage =
|
||||||
|
{"/dev/inet/unix", FH_UNIX, "", 0, 0, 0, 0};
|
||||||
|
|
||||||
|
const device dev_stream_storage =
|
||||||
|
{"/dev/inet/stream", FH_STREAM, "", 0, 0, 0, 0};
|
||||||
|
|
||||||
|
const device dev_dgram_storage =
|
||||||
|
{"/dev/inet/dgram", FH_DGRAM, "", 0, 0, 0, 0};
|
||||||
|
|
||||||
|
const device dev_piper_storage =
|
||||||
|
{"", FH_PIPER, "", 0, 0, 0, 0};
|
||||||
|
|
||||||
|
const device dev_pipew_storage =
|
||||||
|
{"", FH_PIPEW, "", 0, 0, 0, 0};
|
||||||
|
|
||||||
|
const device dev_fs =
|
||||||
|
{"", FH_FS, "", 0, 0, 0, 0};
|
||||||
|
EOF
|
||||||
|
for my $f (sort keys %fh_declare) {
|
||||||
|
$_ .= 'const device dev_' . $f . "_storage = $fh_declare{$f};\n"
|
||||||
|
if $fh_declare{$f} !~ /_storage/;
|
||||||
|
}
|
||||||
|
$_ .= "\n";
|
||||||
|
$_ .= read_devices($incfile, %fh_declare);
|
||||||
|
$findclose = 0;
|
||||||
|
};
|
||||||
|
/^(\s+)(\{".*)/ or next;
|
||||||
|
my $indent = $1;
|
||||||
|
my $rest = $2;
|
||||||
|
for my $f ($rest =~ /\{([^}]+)\}/g) {
|
||||||
|
$f eq '""' and do {
|
||||||
|
$ix++;
|
||||||
|
next;
|
||||||
|
};
|
||||||
|
my ($str, $fh) = (split(/, /, $f))[0..1];
|
||||||
|
if ($str !~ m!^"(?:/dev|:bad:)!) {
|
||||||
|
$ix++;
|
||||||
|
} else {
|
||||||
|
my $what = lc(($fh =~ /FH_(.+)/o)[0]);
|
||||||
|
my $addon = '';
|
||||||
|
while (defined $fh_static{$what . $addon} &&
|
||||||
|
$fh_static{$what . $addon} ne $f) {
|
||||||
|
$addon++;
|
||||||
|
}
|
||||||
|
$what .= $addon;
|
||||||
|
$fh_static{$what} = $f;
|
||||||
|
$fh_declare{$what} = "wordlist[$ix]";
|
||||||
|
$ix++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
print @lines;
|
||||||
|
|
||||||
|
sub read_devices($%) {
|
||||||
|
my $fn = shift;
|
||||||
|
my %fh_declare = @_;
|
||||||
|
open(F, "$fn") or die "$0: couldn't open $fn - $!\n";
|
||||||
|
my (%dev, %fh);
|
||||||
|
local $_;
|
||||||
|
while (<F>) {
|
||||||
|
/^\s*DEV_([A-Z_0-9]+)_MAJOR\s*=\s*(\d+)/ and do {
|
||||||
|
my $dev = lc($1);
|
||||||
|
next unless $fh_declare{$dev};
|
||||||
|
my $a = sprintf "%08d", $2;
|
||||||
|
$dev{$2} = '&' . $fh_declare{$dev} . " /* \L$1 */";
|
||||||
|
next;
|
||||||
|
};
|
||||||
|
/^\s*FH_([A-Z_0-9]+)\s*=\s*FHDEV\s*\((\d+),\s*(\d+)\)/ and do {
|
||||||
|
my $a = sprintf "%08d.%08d", $2, $3;
|
||||||
|
$fh{$a} = '&' . $fh_declare{lc($1)} . " /* \L$1 */";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
close F;
|
||||||
|
my $toprint = '';
|
||||||
|
$toprint = "const device *unit_devices[] =\n{";
|
||||||
|
for my $f (sort keys %dev) {
|
||||||
|
$toprint .= "\n $dev{$f}," if length($dev{$f});
|
||||||
|
}
|
||||||
|
chop $toprint;
|
||||||
|
$toprint .= "\n};\n\nconst device *uniq_devices[] = \n{";
|
||||||
|
for my $f (sort keys %fh) {
|
||||||
|
$toprint .= "\n $fh{$f},";
|
||||||
|
}
|
||||||
|
chop $toprint;
|
||||||
|
$toprint .= "\n};\n";
|
||||||
|
return $toprint;
|
||||||
|
}
|
6
winsup/cygwin/cygwin-shilka
Executable file
6
winsup/cygwin/cygwin-shilka
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/sh -x
|
||||||
|
c="$(basename $1 .shilka).c"
|
||||||
|
shilka -strip -no-definitions $1 && \
|
||||||
|
sed -e '1,4d' -e '/KR_reset.*;/d' -e '/KR_output_statistics.*;/d' \
|
||||||
|
-e '/KR_reset.*)/,/}/d' -e '/KR_output_statistics.*)/,/}/d' "$c" > $2 &&
|
||||||
|
rm -f "$c"
|
@ -23,8 +23,8 @@ details. */
|
|||||||
#define NEED_VFORK
|
#define NEED_VFORK
|
||||||
#include "perprocess.h"
|
#include "perprocess.h"
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include "fhandler.h"
|
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
#include "child_info_magic.h"
|
#include "child_info_magic.h"
|
||||||
@ -550,6 +550,7 @@ dll_crt0_1 ()
|
|||||||
|
|
||||||
/* Set the os_being_run global. */
|
/* Set the os_being_run global. */
|
||||||
wincap.init ();
|
wincap.init ();
|
||||||
|
device::init ();
|
||||||
check_sanity_and_sync (user_data);
|
check_sanity_and_sync (user_data);
|
||||||
|
|
||||||
do_global_ctors (&__CTOR_LIST__, 1);
|
do_global_ctors (&__CTOR_LIST__, 1);
|
||||||
|
@ -15,8 +15,8 @@ details. */
|
|||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#ifdef DEBUGGING
|
#ifdef DEBUGGING
|
||||||
#include "fhandler.h"
|
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -12,16 +12,18 @@
|
|||||||
#undef __GNUC__
|
#undef __GNUC__
|
||||||
static unsigned int devhash (const char *, unsigned)
|
static unsigned int devhash (const char *, unsigned)
|
||||||
__attribute__ ((regparm (2)));
|
__attribute__ ((regparm (2)));
|
||||||
|
#define bad_dev (&dev_bad_storage)
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
TOTAL_KEYWORDS = 54,
|
TOTAL_KEYWORDS = 54,
|
||||||
MIN_WORD_LENGTH = 5,
|
MIN_WORD_LENGTH = 5,
|
||||||
MAX_WORD_LENGTH = 14,
|
MAX_WORD_LENGTH = 14,
|
||||||
MIN_HASH_VALUE = 131,
|
MIN_HASH_VALUE = 106,
|
||||||
MAX_HASH_VALUE = 358
|
MAX_HASH_VALUE = 288
|
||||||
};
|
};
|
||||||
|
|
||||||
/* maximum key range = 228, duplicates = 0 */
|
/* maximum key range = 183, duplicates = 0 */
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
__inline
|
__inline
|
||||||
@ -35,19 +37,19 @@ devhash (register const char *str, register unsigned int len)
|
|||||||
{
|
{
|
||||||
static const unsigned short asso_values[] =
|
static const unsigned short asso_values[] =
|
||||||
{
|
{
|
||||||
359, 359, 359, 359, 359, 359, 359, 359, 359, 359,
|
289, 289, 289, 289, 289, 289, 289, 289, 289, 289,
|
||||||
359, 359, 359, 359, 359, 359, 359, 359, 359, 359,
|
289, 289, 289, 289, 289, 289, 289, 289, 289, 289,
|
||||||
359, 359, 359, 359, 359, 359, 359, 359, 359, 359,
|
289, 289, 289, 289, 289, 289, 289, 289, 289, 289,
|
||||||
359, 359, 359, 359, 359, 359, 359, 359, 359, 359,
|
289, 289, 289, 289, 289, 289, 289, 289, 289, 289,
|
||||||
359, 359, 359, 359, 359, 359, 359, 60, 359, 359,
|
289, 289, 289, 289, 289, 289, 289, 2, 289, 289,
|
||||||
359, 359, 359, 359, 359, 359, 359, 359, 62, 359,
|
289, 289, 289, 289, 289, 289, 289, 289, 62, 289,
|
||||||
359, 359, 359, 359, 359, 359, 359, 359, 359, 359,
|
289, 289, 289, 289, 289, 289, 289, 289, 289, 289,
|
||||||
359, 359, 359, 359, 359, 359, 359, 359, 359, 359,
|
289, 289, 289, 289, 289, 289, 289, 289, 289, 289,
|
||||||
359, 359, 359, 15, 359, 359, 359, 359, 359, 359,
|
289, 289, 289, 27, 289, 289, 289, 289, 289, 289,
|
||||||
359, 359, 359, 359, 359, 359, 359, 0, 2, 46,
|
289, 289, 289, 289, 289, 289, 289, 29, 28, 12,
|
||||||
42, 50, 3, 4, 36, 15, 10, 41, 61, 13,
|
45, 59, 32, 39, 24, 11, 19, 53, 55, 2,
|
||||||
26, 30, 52, 57, 45, 27, 59, 39, 51, 38,
|
57, 35, 21, 54, 62, 9, 52, 8, 37, 10,
|
||||||
32, 18, 14, 359, 359, 359, 359, 359
|
16, 33, 43, 289, 289, 289, 289, 289
|
||||||
};
|
};
|
||||||
register int hval = len;
|
register int hval = len;
|
||||||
|
|
||||||
@ -90,252 +92,237 @@ static NO_COPY const struct device wordlist[] =
|
|||||||
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
|
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
|
||||||
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
|
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
|
||||||
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
|
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
|
||||||
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
|
|
||||||
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
|
|
||||||
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
|
|
||||||
{""}, {""}, {""}, {""}, {""},
|
|
||||||
{":bad:", FH_BAD, ":bad:", 0, 0, 0, 0},
|
|
||||||
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
|
|
||||||
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
|
|
||||||
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
|
|
||||||
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
|
|
||||||
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
|
|
||||||
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
|
|
||||||
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
|
|
||||||
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
|
|
||||||
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
|
|
||||||
{""},
|
|
||||||
{"/dev/fd", FH_FLOPPY, "\\Device\\Floppy%d", 0, 15},
|
|
||||||
{""}, {""}, {""}, {""}, {""}, {""}, {""},
|
{""}, {""}, {""}, {""}, {""}, {""}, {""},
|
||||||
{"/dev/fifo", FH_FIFO, "\\dev\\fifo", 0, 0, 0, 0},
|
{"/dev/com", FH_SERIAL, "\\.\\com%d", 1, 99},
|
||||||
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
|
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
|
||||||
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
|
|
||||||
{"/dev/sr", FH_CDROM, "\\Device\\CdRom%d", 0, 15},
|
|
||||||
{""}, {""}, {""}, {""},
|
|
||||||
{"/dev/mem", FH_MEM, "\\dev\\mem", 0, 0, 0, 0},
|
|
||||||
{""},
|
{""},
|
||||||
{"/dev/hda", FH_SDA, "\\Device\\Harddisk%d\\Partition%d", 1, 16, -1},
|
|
||||||
{""},
|
|
||||||
{"/dev/hdb", FH_SDB, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 15},
|
|
||||||
{"/dev/hdf", FH_SDF, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 79},
|
|
||||||
{"/dev/hdg", FH_SDG, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 95},
|
|
||||||
{""}, {""},
|
|
||||||
{"/dev/st", FH_TAPE, "\\Device\\Tape%d", 0, 127},
|
{"/dev/st", FH_TAPE, "\\Device\\Tape%d", 0, 127},
|
||||||
{""}, {""},
|
{""}, {""},
|
||||||
{"/dev/hdj", FH_SDJ, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 143},
|
{"/dev/mem", FH_MEM, "\\dev\\mem", 0, 0, 0, 0},
|
||||||
{"/dev/com", FH_SERIAL, "\\.\\com%d", 1, 99},
|
|
||||||
{""},
|
|
||||||
{"/dev/hdm", FH_SDM, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 191},
|
|
||||||
{"/dev/hdz", FH_SDZ, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 399},
|
|
||||||
{"/dev/hdi", FH_SDI, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 127},
|
|
||||||
{""}, {""},
|
{""}, {""},
|
||||||
{"/dev/hdy", FH_SDY, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 383},
|
|
||||||
{""}, {""}, {""}, {""}, {""}, {""}, {""},
|
|
||||||
{"/dev/hdn", FH_SDN, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 207},
|
|
||||||
{"/dev/hds", FH_SDS, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 287},
|
|
||||||
{""}, {""},
|
|
||||||
{"/dev/hdo", FH_SDO, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 223},
|
|
||||||
{""},
|
|
||||||
{"/dev/hdx", FH_SDX, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 367},
|
|
||||||
{""},
|
|
||||||
{"/dev/nst", FH_NTAPE, "\\Device\\Tape%d", 0, 127},
|
|
||||||
{""},
|
|
||||||
{"/dev/hdh", FH_SDH, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 111},
|
|
||||||
{"/dev/scd", FH_CDROM, "\\Device\\CdRom%d", 0, 15},
|
{"/dev/scd", FH_CDROM, "\\Device\\CdRom%d", 0, 15},
|
||||||
{"/dev/hdw", FH_SDW, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 351},
|
{""}, {""}, {""},
|
||||||
{"/dev/hdu", FH_SDU, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 319},
|
{"/dev/sr", FH_CDROM, "\\Device\\CdRom%d", 0, 15},
|
||||||
{"/dev/kmem", FH_KMEM, "\\dev\\mem", 0, 0, 0, 0},
|
{"/dev/hdm", FH_SDM, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 191},
|
||||||
{"/dev/hdk", FH_SDK, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 159},
|
{""}, {""}, {""},
|
||||||
{"/dev/hdd", FH_SDD, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 47},
|
|
||||||
{"/dev/dsp", FH_OSS_DSP, "\\dev\\dsp", 0, 0, 0, 0},
|
{"/dev/dsp", FH_OSS_DSP, "\\dev\\dsp", 0, 0, 0, 0},
|
||||||
{""},
|
{"/dev/fd", FH_FLOPPY, "\\Device\\Floppy%d", 0, 15},
|
||||||
{"/dev/hdr", FH_SDR, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 271},
|
{"/dev/hdu", FH_SDU, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 319},
|
||||||
|
{"/dev/hds", FH_SDS, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 287},
|
||||||
|
{"/dev/hdw", FH_SDW, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 351},
|
||||||
|
{"/dev/hdi", FH_SDI, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 127},
|
||||||
{"/dev/hdc", FH_SDC, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 31},
|
{"/dev/hdc", FH_SDC, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 31},
|
||||||
{""}, {""}, {""},
|
{""}, {""}, {""},
|
||||||
{"/dev/hde", FH_SDE, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 63},
|
{"/dev/hdx", FH_SDX, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 367},
|
||||||
{"/dev/hdv", FH_SDV, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 335},
|
{""}, {""},
|
||||||
{"/dev/hdp", FH_SDP, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 239},
|
{"/dev/hdj", FH_SDJ, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 143},
|
||||||
{""}, {""}, {""}, {""},
|
|
||||||
{"/dev/hdq", FH_SDQ, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 255 /* FIXME 8 bit lunacy */},
|
|
||||||
{"/dev/tty", FH_TTY, "\\dev\\tty", 0, 0, 0, 0},
|
|
||||||
{"/dev/hdt", FH_SDT, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 303},
|
|
||||||
{""},
|
{""},
|
||||||
|
{"/dev/hdp", FH_SDP, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 239},
|
||||||
|
{""},
|
||||||
|
{"/dev/ptmx", FH_PTYM, "\\dev\\ptmx", 0, 0, 0, 0},
|
||||||
|
{"/dev/hdh", FH_SDH, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 111},
|
||||||
|
{""}, {""}, {""},
|
||||||
|
{"/dev/hdb", FH_SDB, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 15},
|
||||||
|
{"/dev/hda", FH_SDA, "\\Device\\Harddisk%d\\Partition%d", 1, 16, -1},
|
||||||
|
{""},
|
||||||
|
{":bad:", FH_BAD, ":bad:", 0, 0, 0, 0},
|
||||||
|
{"/dev/hdf", FH_SDF, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 79},
|
||||||
|
{"/dev/hdy", FH_SDY, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 383},
|
||||||
|
{""},
|
||||||
|
{"/dev/hdo", FH_SDO, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 223},
|
||||||
|
{""},
|
||||||
|
{"/dev/hdv", FH_SDV, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 335},
|
||||||
|
{""},
|
||||||
|
{"/dev/hdg", FH_SDG, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 95},
|
||||||
|
{""}, {""},
|
||||||
|
{"/dev/fifo", FH_FIFO, "\\dev\\fifo", 0, 0, 0, 0},
|
||||||
|
{"/dev/hdz", FH_SDZ, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 399},
|
||||||
|
{"/dev/pipe", FH_PIPE, "\\dev\\pipe", 0, 0, 0, 0},
|
||||||
|
{"/dev/hdd", FH_SDD, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 47},
|
||||||
|
{""}, {""},
|
||||||
|
{"/dev/kmem", FH_KMEM, "\\dev\\mem", 0, 0, 0, 0},
|
||||||
|
{"/dev/nst", FH_NTAPE, "\\Device\\Tape%d", 0, 127},
|
||||||
|
{""}, {""},
|
||||||
|
{"/dev/hdt", FH_SDT, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 303},
|
||||||
|
{"/dev/hdk", FH_SDK, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 159},
|
||||||
|
{"/dev/hdq", FH_SDQ, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 255 /* FIXME 8 bit lunacy */},
|
||||||
{"/dev/hdl", FH_SDL, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 175},
|
{"/dev/hdl", FH_SDL, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 175},
|
||||||
|
{""},
|
||||||
|
{"/dev/hdn", FH_SDN, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 207},
|
||||||
|
{""},
|
||||||
|
{"/dev/hde", FH_SDE, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 63},
|
||||||
|
{""}, {""},
|
||||||
|
{"/dev/hdr", FH_SDR, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 271},
|
||||||
|
{""},
|
||||||
|
{"/dev/clipboard", FH_CLIPBOARD, "\\dev\\clipboard", 0, 0, 0, 0},
|
||||||
|
{""}, {""}, {""},
|
||||||
|
{"/dev/tty", FH_TTY, "\\dev\\tty", 0, 0, 0, 0},
|
||||||
|
{""}, {""},
|
||||||
|
{"/dev/ttym", FH_TTYM, "\\dev\\ttym", 0, 255, 0, 0},
|
||||||
|
{""}, {""}, {""}, {""}, {""}, {""},
|
||||||
|
{"/dev/ttys", FH_TTYS, "\\dev\\tty%d", 0, 255, 0, 0},
|
||||||
|
{""}, {""},
|
||||||
|
{"/dev/conout", FH_CONOUT, "conout", 0, 0, 0, 0},
|
||||||
|
{""},
|
||||||
|
{"/dev/console", FH_CONSOLE, "\\dev\\console", 0, 0, 0, 0},
|
||||||
|
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
|
||||||
|
{"/dev/windows", FH_WINDOWS, "\\dev\\windows", 0, 0, 0, 0},
|
||||||
|
{""}, {""},
|
||||||
|
{"/dev/ttyS", FH_SERIAL, "\\.\\com%d", 0, 99, -1},
|
||||||
|
{""}, {""}, {""}, {""}, {""},
|
||||||
|
{"/dev/port", FH_PORT, "\\dev\\port", 0, 0, 0, 0},
|
||||||
|
{""}, {""},
|
||||||
|
{"/dev/conin", FH_CONIN, "conin", 0, 0, 0, 0},
|
||||||
|
{""},
|
||||||
|
{"/dev/null", FH_NULL, "nul", 0, 0, 0, 0},
|
||||||
|
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
|
||||||
|
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
|
||||||
|
{""}, {""}, {""}, {""}, {""},
|
||||||
{"/dev/zero", FH_ZERO, "\\dev\\zero", 0, 0, 0, 0},
|
{"/dev/zero", FH_ZERO, "\\dev\\zero", 0, 0, 0, 0},
|
||||||
{""}, {""}, {""}, {""},
|
{""}, {""}, {""}, {""},
|
||||||
{"/dev/conin", FH_CONIN, "conin", 0, 0, 0, 0},
|
|
||||||
{"/dev/random", FH_RANDOM, "\\dev\\random", 0, 0, 0, 0},
|
|
||||||
{""}, {""}, {""},
|
|
||||||
{"/dev/ttym", FH_TTYM, "\\dev\\ttym", 0, 255, 0, 0},
|
|
||||||
{""},
|
|
||||||
{"/dev/ttyS", FH_SERIAL, "\\.\\com%d", 0, 99, -1},
|
|
||||||
{""}, {""},
|
|
||||||
{"/dev/windows", FH_WINDOWS, "\\dev\\windows", 0, 0, 0, 0},
|
|
||||||
{"/dev/urandom", FH_URANDOM, "\\dev\\urandom", 0, 0, 0, 0},
|
{"/dev/urandom", FH_URANDOM, "\\dev\\urandom", 0, 0, 0, 0},
|
||||||
{"/dev/ptmx", FH_PTYM, "\\dev\\ptmx", 0, 0, 0, 0},
|
{""}, {""}, {""}, {""}, {""}, {""}, {""},
|
||||||
{""}, {""}, {""}, {""}, {""},
|
|
||||||
{"/dev/console", FH_CONSOLE, "\\dev\\console", 0, 0, 0, 0},
|
|
||||||
{"/dev/ttys", FH_TTYS, "\\dev\\tty%d", 0, 255, 0, 0},
|
|
||||||
{""}, {""}, {""}, {""}, {""},
|
|
||||||
{"/dev/pipe", FH_PIPE, "\\dev\\pipe", 0, 0, 0, 0},
|
|
||||||
{""}, {""}, {""},
|
|
||||||
{"/dev/conout", FH_CONOUT, "conout", 0, 0, 0, 0},
|
|
||||||
{"/dev/rawdrive", FH_RAWDRIVE, "\\DosDevices\\%c:", 0, 0, 0, 0},
|
{"/dev/rawdrive", FH_RAWDRIVE, "\\DosDevices\\%c:", 0, 0, 0, 0},
|
||||||
{""}, {""}, {""}, {""}, {""}, {""},
|
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
|
||||||
{"/dev/clipboard", FH_CLIPBOARD, "\\dev\\clipboard", 0, 0, 0, 0},
|
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
|
||||||
{""}, {""}, {""}, {""},
|
{"/dev/random", FH_RANDOM, "\\dev\\random", 0, 0, 0, 0}
|
||||||
{"/dev/port", FH_PORT, "\\dev\\port", 0, 0, 0, 0},
|
|
||||||
{"/dev/null", FH_NULL, "nul", 0, 0, 0, 0}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const device cygdrive_dev_storage =
|
const device dev_cygdrive_storage =
|
||||||
{"/cygdrive", FH_CYGDRIVE, "/cygdrive", 0, 0, 0, 0};
|
{"/cygdrive", FH_CYGDRIVE, "/cygdrive", 0, 0, 0, 0};
|
||||||
|
|
||||||
static const device fs_dev_storage =
|
const device dev_fs_storage =
|
||||||
{"", FH_FS, "", 0, 0, 0, 0};
|
{"", FH_FS, "", 0, 0, 0, 0};
|
||||||
|
|
||||||
static const device proc_dev_storage =
|
const device dev_proc_storage =
|
||||||
{"", FH_PROC, "", 0, 0, 0, 0};
|
{"", FH_PROC, "", 0, 0, 0, 0};
|
||||||
|
|
||||||
static const device registry_dev_storage =
|
const device dev_registry_storage =
|
||||||
{"", FH_REGISTRY, "", 0, 0, 0, 0};
|
{"", FH_REGISTRY, "", 0, 0, 0, 0};
|
||||||
|
|
||||||
static const device process_dev_storage =
|
const device dev_process_storage =
|
||||||
{"", FH_PROCESS, "", 0, 0, 0, 0};
|
{"", FH_PROCESS, "", 0, 0, 0, 0};
|
||||||
|
|
||||||
static const device tcp_dev_storage =
|
const device dev_tcp_storage =
|
||||||
{"/dev/inet/tcp", FH_TCP, "", 0, 0, 0, 0};
|
{"/dev/inet/tcp", FH_TCP, "", 0, 0, 0, 0};
|
||||||
|
|
||||||
static const device udp_dev_storage =
|
const device dev_udp_storage =
|
||||||
{"/dev/inet/udp", FH_UCP, "", 0, 0, 0, 0};
|
{"/dev/inet/udp", FH_UCP, "", 0, 0, 0, 0};
|
||||||
|
|
||||||
static const device icmp_dev_storage =
|
const device dev_icmp_storage =
|
||||||
{"/dev/inet/icmp", FH_ICMP, "", 0, 0, 0, 0};
|
{"/dev/inet/icmp", FH_ICMP, "", 0, 0, 0, 0};
|
||||||
|
|
||||||
static const device unix_dev_storage =
|
const device dev_unix_storage =
|
||||||
{"/dev/inet/unix", FH_UNIX, "", 0, 0, 0, 0};
|
{"/dev/inet/unix", FH_UNIX, "", 0, 0, 0, 0};
|
||||||
|
|
||||||
static const device stream_dev_storage =
|
const device dev_stream_storage =
|
||||||
{"/dev/inet/stream", FH_STREAM, "", 0, 0, 0, 0};
|
{"/dev/inet/stream", FH_STREAM, "", 0, 0, 0, 0};
|
||||||
|
|
||||||
static const device dgram_dev_storage =
|
const device dev_dgram_storage =
|
||||||
{"/dev/inet/dgram", FH_DGRAM, "", 0, 0, 0, 0};
|
{"/dev/inet/dgram", FH_DGRAM, "", 0, 0, 0, 0};
|
||||||
|
|
||||||
static const device piper_dev_storage =
|
const device dev_piper_storage =
|
||||||
{"", FH_PIPER, "", 0, 0, 0, 0};
|
{"", FH_PIPER, "", 0, 0, 0, 0};
|
||||||
|
|
||||||
static const device pipew_dev_storage =
|
const device dev_pipew_storage =
|
||||||
{"", FH_PIPEW, "", 0, 0, 0, 0};
|
{"", FH_PIPEW, "", 0, 0, 0, 0};
|
||||||
|
|
||||||
static const device dev_fs =
|
const device dev_fs =
|
||||||
{"", FH_FS, "", 0, 0, 0, 0};
|
{"", FH_FS, "", 0, 0, 0, 0};
|
||||||
const device *bad_dev = wordlist + 131;
|
const device dev_bad_storage = wordlist[157];
|
||||||
const device *cdrom_dev = wordlist + 241;
|
const device dev_cdrom_storage = wordlist[123];
|
||||||
const device *cdrom_dev1 = wordlist + 285;
|
const device dev_cdrom1_storage = wordlist[127];
|
||||||
const device *clipboard_dev = wordlist + 352;
|
const device dev_clipboard_storage = wordlist[190];
|
||||||
const device *conin_dev = wordlist + 315;
|
const device dev_conin_storage = wordlist[231];
|
||||||
const device *conout_dev = wordlist + 344;
|
const device dev_conout_storage = wordlist[207];
|
||||||
const device *console_dev = wordlist + 333;
|
const device dev_console_storage = wordlist[209];
|
||||||
const device *cygdrive_dev = &cygdrive_dev_storage;
|
const device dev_fifo_storage = wordlist[168];
|
||||||
const device *dgram_dev = &dgram_dev_storage;
|
const device dev_floppy_storage = wordlist[133];
|
||||||
const device *fifo_dev = wordlist + 222;
|
const device dev_kmem_storage = wordlist[174];
|
||||||
const device *floppy_dev = wordlist + 214;
|
const device dev_mem_storage = wordlist[120];
|
||||||
const device *fs_dev = &fs_dev_storage;
|
const device dev_ntape_storage = wordlist[175];
|
||||||
const device *icmp_dev = &icmp_dev_storage;
|
const device dev_null_storage = wordlist[233];
|
||||||
const device *kmem_dev = wordlist + 288;
|
const device dev_oss_dsp_storage = wordlist[132];
|
||||||
const device *mem_dev = wordlist + 246;
|
const device dev_pipe_storage = wordlist[170];
|
||||||
const device *ntape_dev = wordlist + 282;
|
const device dev_port_storage = wordlist[228];
|
||||||
const device *null_dev = wordlist + 358;
|
const device dev_ptym_storage = wordlist[149];
|
||||||
const device *oss_dsp_dev = wordlist + 291;
|
const device dev_random_storage = wordlist[288];
|
||||||
const device *pipe_dev = wordlist + 340;
|
const device dev_rawdrive_storage = wordlist[270];
|
||||||
const device *piper_dev = &piper_dev_storage;
|
const device dev_sda_storage = wordlist[155];
|
||||||
const device *pipew_dev = &pipew_dev_storage;
|
const device dev_sdb_storage = wordlist[154];
|
||||||
const device *port_dev = wordlist + 357;
|
const device dev_sdc_storage = wordlist[138];
|
||||||
const device *proc_dev = &proc_dev_storage;
|
const device dev_sdd_storage = wordlist[171];
|
||||||
const device *process_dev = &process_dev_storage;
|
const device dev_sde_storage = wordlist[185];
|
||||||
const device *ptym_dev = wordlist + 327;
|
const device dev_sdf_storage = wordlist[158];
|
||||||
const device *random_dev = wordlist + 316;
|
const device dev_sdg_storage = wordlist[165];
|
||||||
const device *rawdrive_dev = wordlist + 345;
|
const device dev_sdh_storage = wordlist[150];
|
||||||
const device *registry_dev = ®istry_dev_storage;
|
const device dev_sdi_storage = wordlist[137];
|
||||||
const device *sda_dev = wordlist + 248;
|
const device dev_sdj_storage = wordlist[145];
|
||||||
const device *sdb_dev = wordlist + 250;
|
const device dev_sdk_storage = wordlist[179];
|
||||||
const device *sdc_dev = wordlist + 294;
|
const device dev_sdl_storage = wordlist[181];
|
||||||
const device *sdd_dev = wordlist + 290;
|
const device dev_sdm_storage = wordlist[128];
|
||||||
const device *sde_dev = wordlist + 298;
|
const device dev_sdn_storage = wordlist[183];
|
||||||
const device *sdf_dev = wordlist + 251;
|
const device dev_sdo_storage = wordlist[161];
|
||||||
const device *sdg_dev = wordlist + 252;
|
const device dev_sdp_storage = wordlist[147];
|
||||||
const device *sdh_dev = wordlist + 284;
|
const device dev_sdq_storage = wordlist[180];
|
||||||
const device *sdi_dev = wordlist + 263;
|
const device dev_sdr_storage = wordlist[188];
|
||||||
const device *sdj_dev = wordlist + 258;
|
const device dev_sds_storage = wordlist[135];
|
||||||
const device *sdk_dev = wordlist + 289;
|
const device dev_sdt_storage = wordlist[178];
|
||||||
const device *sdl_dev = wordlist + 309;
|
const device dev_sdu_storage = wordlist[134];
|
||||||
const device *sdm_dev = wordlist + 261;
|
const device dev_sdv_storage = wordlist[163];
|
||||||
const device *sdn_dev = wordlist + 274;
|
const device dev_sdw_storage = wordlist[136];
|
||||||
const device *sdo_dev = wordlist + 278;
|
const device dev_sdx_storage = wordlist[142];
|
||||||
const device *sdp_dev = wordlist + 300;
|
const device dev_sdy_storage = wordlist[159];
|
||||||
const device *sdq_dev = wordlist + 305;
|
const device dev_sdz_storage = wordlist[169];
|
||||||
const device *sdr_dev = wordlist + 293;
|
const device dev_serial_storage = wordlist[106];
|
||||||
const device *sds_dev = wordlist + 275;
|
const device dev_serial1_storage = wordlist[222];
|
||||||
const device *sdt_dev = wordlist + 307;
|
const device dev_tape_storage = wordlist[117];
|
||||||
const device *sdu_dev = wordlist + 287;
|
const device dev_tty_storage = wordlist[194];
|
||||||
const device *sdv_dev = wordlist + 299;
|
const device dev_ttym_storage = wordlist[197];
|
||||||
const device *sdw_dev = wordlist + 286;
|
const device dev_ttys_storage = wordlist[204];
|
||||||
const device *sdx_dev = wordlist + 280;
|
const device dev_urandom_storage = wordlist[262];
|
||||||
const device *sdy_dev = wordlist + 266;
|
const device dev_windows_storage = wordlist[219];
|
||||||
const device *sdz_dev = wordlist + 262;
|
const device dev_zero_storage = wordlist[257];
|
||||||
const device *serial_dev = wordlist + 259;
|
|
||||||
const device *serial_dev1 = wordlist + 322;
|
|
||||||
const device *stream_dev = &stream_dev_storage;
|
|
||||||
const device *tape_dev = wordlist + 255;
|
|
||||||
const device *tcp_dev = &tcp_dev_storage;
|
|
||||||
const device *tty_dev = wordlist + 306;
|
|
||||||
const device *ttym_dev = wordlist + 320;
|
|
||||||
const device *ttys_dev = wordlist + 334;
|
|
||||||
const device *udp_dev = &udp_dev_storage;
|
|
||||||
const device *unix_dev = &unix_dev_storage;
|
|
||||||
const device *urandom_dev = wordlist + 326;
|
|
||||||
const device *windows_dev = wordlist + 325;
|
|
||||||
const device *zero_dev = wordlist + 310;
|
|
||||||
|
|
||||||
const device *unit_devices[] =
|
const device *unit_devices[] =
|
||||||
{
|
{
|
||||||
wordlist + 241 /* cdrom */,
|
&wordlist[123] /* cdrom */,
|
||||||
wordlist + 259 /* serial */,
|
&wordlist[106] /* serial */,
|
||||||
wordlist + 320 /* ttym */,
|
&wordlist[197] /* ttym */,
|
||||||
wordlist + 334 /* ttys */,
|
&wordlist[204] /* ttys */,
|
||||||
wordlist + 214 /* floppy */,
|
&wordlist[133] /* floppy */,
|
||||||
&tcp_dev_storage /* tcp */,
|
&dev_tcp_storage /* tcp */,
|
||||||
wordlist + 345 /* rawdrive */,
|
&wordlist[270] /* rawdrive */,
|
||||||
wordlist + 255 /* tape */
|
&wordlist[117] /* tape */
|
||||||
};
|
};
|
||||||
|
|
||||||
const device *uniq_devices[] =
|
const device *uniq_devices[] =
|
||||||
{
|
{
|
||||||
wordlist + 131 /* bad */,
|
&wordlist[157] /* bad */,
|
||||||
&fs_dev_storage /* fs */,
|
&dev_fs_storage /* fs */,
|
||||||
&process_dev_storage /* process */,
|
&dev_process_storage /* process */,
|
||||||
®istry_dev_storage /* registry */,
|
&dev_registry_storage /* registry */,
|
||||||
&proc_dev_storage /* proc */,
|
&dev_proc_storage /* proc */,
|
||||||
wordlist + 222 /* fifo */,
|
&wordlist[168] /* fifo */,
|
||||||
&pipew_dev_storage /* pipew */,
|
&dev_pipew_storage /* pipew */,
|
||||||
&piper_dev_storage /* piper */,
|
&dev_piper_storage /* piper */,
|
||||||
wordlist + 340 /* pipe */,
|
&wordlist[170] /* pipe */,
|
||||||
wordlist + 246 /* mem */,
|
&wordlist[120] /* mem */,
|
||||||
wordlist + 288 /* kmem */,
|
&wordlist[174] /* kmem */,
|
||||||
wordlist + 358 /* null */,
|
&wordlist[233] /* null */,
|
||||||
wordlist + 310 /* zero */,
|
&wordlist[257] /* zero */,
|
||||||
wordlist + 357 /* port */,
|
&wordlist[228] /* port */,
|
||||||
wordlist + 316 /* random */,
|
&wordlist[288] /* random */,
|
||||||
wordlist + 326 /* urandom */,
|
&wordlist[262] /* urandom */,
|
||||||
wordlist + 306 /* tty */,
|
&wordlist[194] /* tty */,
|
||||||
wordlist + 333 /* console */,
|
&wordlist[209] /* console */,
|
||||||
wordlist + 327 /* ptym */,
|
&wordlist[149] /* ptym */,
|
||||||
wordlist + 344 /* conout */,
|
&wordlist[207] /* conout */,
|
||||||
wordlist + 315 /* conin */,
|
&wordlist[231] /* conin */,
|
||||||
wordlist + 352 /* clipboard */,
|
&wordlist[190] /* clipboard */,
|
||||||
wordlist + 325 /* windows */,
|
&wordlist[219] /* windows */,
|
||||||
wordlist + 291 /* oss_dsp */,
|
&wordlist[132] /* oss_dsp */,
|
||||||
wordlist + 259 /* serial */
|
&wordlist[106] /* serial */
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
#undef __GNUC__
|
#undef __GNUC__
|
||||||
static unsigned int devhash (const char *, unsigned)
|
static unsigned int devhash (const char *, unsigned)
|
||||||
__attribute__ ((regparm (2)));
|
__attribute__ ((regparm (2)));
|
||||||
|
#define bad_dev (&dev_bad_storage)
|
||||||
|
|
||||||
%}
|
%}
|
||||||
struct device;
|
struct device;
|
||||||
%%
|
%%
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* devices.h
|
/* devices.h
|
||||||
|
|
||||||
Copyright 2002 Red Hat, Inc.
|
Copyright 2002, 2003 Red Hat, Inc.
|
||||||
|
|
||||||
This file is part of Cygwin.
|
This file is part of Cygwin.
|
||||||
|
|
||||||
@ -8,83 +8,184 @@ This software is a copyrighted work licensed under the terms of the
|
|||||||
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
||||||
details. */
|
details. */
|
||||||
|
|
||||||
#ifndef _DEVICES_H_
|
typedef unsigned short _major_t;
|
||||||
#define _DEVICES_H_
|
typedef unsigned short _minor_t;
|
||||||
|
typedef mode_t _mode_t;
|
||||||
|
typedef __dev32_t _dev_t;
|
||||||
|
|
||||||
#include <sys/ioctl.h>
|
#define FHDEV(maj, min) ((((unsigned) (maj)) << (sizeof (_major_t) * 8)) | (unsigned) (min))
|
||||||
#include <fcntl.h>
|
#define _minor(dev) ((dev) & ((1 << (sizeof (_minor_t) * 8)) - 1))
|
||||||
|
#define _major(dev) ((dev) >> (sizeof (_major_t) * 8))
|
||||||
|
|
||||||
enum
|
enum fh_devices
|
||||||
{
|
{
|
||||||
FH_RBINARY = 0x00001000, /* binary read mode */
|
FH_TTY = FHDEV (5, 0),
|
||||||
FH_WBINARY = 0x00002000, /* binary write mode */
|
FH_CONSOLE = FHDEV (5, 1),
|
||||||
FH_CLOEXEC = 0x00004000, /* close-on-exec */
|
FH_PTYM = FHDEV (5, 2), /* /dev/ptmx */
|
||||||
FH_RBINSET = 0x00008000, /* binary read mode has been explicitly set */
|
FH_CONIN = FHDEV (5, 255),
|
||||||
FH_WBINSET = 0x00010000, /* binary write mode has been explicitly set */
|
FH_CONOUT = FHDEV (5, 254),
|
||||||
FH_APPEND = 0x00020000, /* always append */
|
|
||||||
FH_ASYNC = 0x00040000, /* async I/O */
|
|
||||||
FH_SIGCLOSE = 0x00080000, /* signal handler should close fd on interrupt */
|
|
||||||
|
|
||||||
FH_SYMLINK = 0x00100000, /* is a symlink */
|
DEV_TTYM_MAJOR = 128,
|
||||||
FH_EXECABL = 0x00200000, /* file looked like it would run:
|
FH_TTYM = FHDEV (DEV_TTYM_MAJOR, 0),
|
||||||
* ends in .exe or .bat or begins with #! */
|
FH_TTYM_MAX= FHDEV (DEV_TTYM_MAJOR, 255),
|
||||||
FH_W95LSBUG = 0x00400000, /* set when lseek is called as a flag that
|
|
||||||
* _write should check if we've moved beyond
|
|
||||||
* EOF, zero filling if so. */
|
|
||||||
FH_NOHANDLE = 0x00800000, /* No handle associated with fhandler. */
|
|
||||||
FH_NOEINTR = 0x01000000, /* Set if I/O should be uninterruptible. */
|
|
||||||
FH_FFIXUP = 0x02000000, /* Set if need to fixup after fork. */
|
|
||||||
FH_LOCAL = 0x04000000, /* File is unix domain socket */
|
|
||||||
FH_SHUTRD = 0x08000000, /* Socket saw a SHUT_RD */
|
|
||||||
FH_SHUTWR = 0x10000000, /* Socket saw a SHUT_WR */
|
|
||||||
FH_ISREMOTE = 0x10000000, /* File is on a remote drive */
|
|
||||||
FH_DCEXEC = 0x20000000, /* Don't care if this is executable */
|
|
||||||
FH_HASACLS = 0x40000000, /* True if fs of file has ACLS */
|
|
||||||
FH_QUERYOPEN = 0x80000000, /* open file without requesting either read
|
|
||||||
or write access */
|
|
||||||
|
|
||||||
/* Device flags */
|
DEV_TTYS_MAJOR = 136,
|
||||||
|
FH_TTYS = FHDEV (DEV_TTYS_MAJOR, 0), /* FIXME: Should separate ttys and ptys */
|
||||||
|
FH_TTYS_MAX= FHDEV (DEV_TTYS_MAJOR, 255), /* FIXME: Should separate ttys and ptys */
|
||||||
|
|
||||||
/* Slow devices */
|
DEV_SERIAL_MAJOR = 117,
|
||||||
FH_CONSOLE = 0x00000001, /* is a console */
|
FH_SERIAL = FHDEV (117, 0), /* /dev/ttyS? */
|
||||||
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_WINDOWS = FHDEV (13, 255),
|
||||||
FH_DISK = 0x00000010, /* is a disk */
|
FH_CLIPBOARD=FHDEV (13, 254),
|
||||||
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_PIPE = FHDEV (0, 255),
|
||||||
FH_DEVMASK = 0x00000fff, /* devices live here */
|
FH_PIPER = FHDEV (0, 254),
|
||||||
FH_BAD = 0xffffffff
|
FH_PIPEW = FHDEV (0, 253),
|
||||||
|
FH_FIFO = FHDEV (0, 252),
|
||||||
|
FH_PROC = FHDEV (0, 250),
|
||||||
|
FH_REGISTRY= FHDEV (0, 249),
|
||||||
|
FH_PROCESS = FHDEV (0, 248),
|
||||||
|
|
||||||
|
FH_FS = FHDEV (0, 247), /* filesystem based device */
|
||||||
|
|
||||||
|
DEV_FLOPPY_MAJOR = 2,
|
||||||
|
FH_FLOPPY = FHDEV (DEV_FLOPPY_MAJOR, 0),
|
||||||
|
|
||||||
|
DEV_CDROM_MAJOR = 11,
|
||||||
|
FH_CDROM = FHDEV (DEV_CDROM_MAJOR, 0),
|
||||||
|
|
||||||
|
DEV_TAPE_MAJOR = 9,
|
||||||
|
FH_TAPE = FHDEV (DEV_TAPE_MAJOR, 0),
|
||||||
|
FH_NTAPE = FHDEV (DEV_TAPE_MAJOR, 128),
|
||||||
|
FH_MAXNTAPE= FHDEV (DEV_TAPE_MAJOR, 255),
|
||||||
|
|
||||||
|
DEV_SD_MAJOR = 3,
|
||||||
|
DEV_SD1_MAJOR = 90,
|
||||||
|
FH_SD = FHDEV (DEV_SD_MAJOR, 0),
|
||||||
|
FH_SD1 = FHDEV (DEV_SD1_MAJOR, 0),
|
||||||
|
FH_SDA = FHDEV (DEV_SD_MAJOR, 0),
|
||||||
|
FH_SDB = FHDEV (DEV_SD_MAJOR, 16),
|
||||||
|
FH_SDC = FHDEV (DEV_SD_MAJOR, 32),
|
||||||
|
FH_SDD = FHDEV (DEV_SD_MAJOR, 48),
|
||||||
|
FH_SDE = FHDEV (DEV_SD_MAJOR, 64),
|
||||||
|
FH_SDF = FHDEV (DEV_SD_MAJOR, 80),
|
||||||
|
FH_SDG = FHDEV (DEV_SD_MAJOR, 96),
|
||||||
|
FH_SDH = FHDEV (DEV_SD_MAJOR, 112),
|
||||||
|
FH_SDI = FHDEV (DEV_SD_MAJOR, 128),
|
||||||
|
FH_SDJ = FHDEV (DEV_SD_MAJOR, 144),
|
||||||
|
FH_SDK = FHDEV (DEV_SD_MAJOR, 160),
|
||||||
|
FH_SDL = FHDEV (DEV_SD_MAJOR, 176),
|
||||||
|
FH_SDM = FHDEV (DEV_SD_MAJOR, 192),
|
||||||
|
FH_SDN = FHDEV (DEV_SD_MAJOR, 208),
|
||||||
|
FH_SDO = FHDEV (DEV_SD_MAJOR, 224),
|
||||||
|
FH_SDP = FHDEV (DEV_SD_MAJOR, 240),
|
||||||
|
FH_SDQ = FHDEV (DEV_SD1_MAJOR, 0),
|
||||||
|
FH_SDR = FHDEV (DEV_SD1_MAJOR, 16),
|
||||||
|
FH_SDS = FHDEV (DEV_SD1_MAJOR, 32),
|
||||||
|
FH_SDT = FHDEV (DEV_SD1_MAJOR, 48),
|
||||||
|
FH_SDU = FHDEV (DEV_SD1_MAJOR, 64),
|
||||||
|
FH_SDV = FHDEV (DEV_SD1_MAJOR, 80),
|
||||||
|
FH_SDW = FHDEV (DEV_SD1_MAJOR, 96),
|
||||||
|
FH_SDX = FHDEV (DEV_SD1_MAJOR, 112),
|
||||||
|
FH_SDY = FHDEV (DEV_SD1_MAJOR, 128),
|
||||||
|
FH_SDZ = FHDEV (DEV_SD1_MAJOR, 144),
|
||||||
|
|
||||||
|
FH_MEM = FHDEV (1, 1),
|
||||||
|
FH_KMEM = FHDEV (1, 2), /* not implemented yet */
|
||||||
|
FH_NULL = FHDEV (1, 3),
|
||||||
|
FH_ZERO = FHDEV (1, 4),
|
||||||
|
FH_PORT = FHDEV (1, 5),
|
||||||
|
FH_RANDOM = FHDEV (1, 8),
|
||||||
|
FH_URANDOM = FHDEV (1, 9),
|
||||||
|
FH_OSS_DSP = FHDEV (14, 3),
|
||||||
|
|
||||||
|
DEV_CYGDRIVE_MAJOR = 30,
|
||||||
|
FH_CYGDRIVE= FHDEV (DEV_CYGDRIVE_MAJOR, 0),
|
||||||
|
FH_CYGDRIVE_A= FHDEV (DEV_CYGDRIVE_MAJOR, 'a'),
|
||||||
|
FH_CYGDRIVE_Z= FHDEV (DEV_CYGDRIVE_MAJOR, 'z'),
|
||||||
|
|
||||||
|
DEV_RAWDRIVE_MAJOR = 65,
|
||||||
|
FH_RAWDRIVE= FHDEV (DEV_RAWDRIVE_MAJOR, 0),
|
||||||
|
|
||||||
|
DEV_TCP_MAJOR = 30,
|
||||||
|
FH_TCP = FHDEV (DEV_TCP_MAJOR, 36),
|
||||||
|
FH_UCP = FHDEV (DEV_TCP_MAJOR, 39),
|
||||||
|
FH_ICMP = FHDEV (DEV_TCP_MAJOR, 33),
|
||||||
|
FH_UNIX = FHDEV (DEV_TCP_MAJOR, 120),
|
||||||
|
FH_STREAM = FHDEV (DEV_TCP_MAJOR, 121),
|
||||||
|
FH_DGRAM = FHDEV (DEV_TCP_MAJOR, 122),
|
||||||
|
|
||||||
|
FH_BAD = FHDEV (0, 0)
|
||||||
};
|
};
|
||||||
|
|
||||||
#define FHDEVN(n) ((n) & FH_DEVMASK)
|
struct device
|
||||||
#define FHISSETF(x) __ISSETF (this, x, FH)
|
{
|
||||||
#define FHSETF(x) __SETF (this, x, FH)
|
const char *name;
|
||||||
#define FHCLEARF(x) __CLEARF (this, x, FH)
|
union
|
||||||
#define FHCONDSETF(n, x) __CONDSETF(n, this, x, FH)
|
{
|
||||||
|
_dev_t devn;
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
_minor_t minor;
|
||||||
|
_major_t major;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
const char *fmt;
|
||||||
|
unsigned lower, upper;
|
||||||
|
int adjust;
|
||||||
|
unsigned mul;
|
||||||
|
_mode_t mode;
|
||||||
|
bool dev_on_fs;
|
||||||
|
static const device *lookup (const char *, unsigned int = 0xffffffff);
|
||||||
|
void parse (const char *);
|
||||||
|
void parse (_major_t major, _minor_t minor);
|
||||||
|
void parse (_dev_t dev);
|
||||||
|
inline bool setunit (unsigned n)
|
||||||
|
{
|
||||||
|
if (mul && n > mul)
|
||||||
|
return false;
|
||||||
|
minor += (n + adjust) * (mul ?: 1);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
static void init ();
|
||||||
|
void tty_to_real_device ();
|
||||||
|
inline operator int () const {return devn;}
|
||||||
|
inline void setfs (bool x) {dev_on_fs = x;}
|
||||||
|
inline bool isfs () const {return dev_on_fs;}
|
||||||
|
};
|
||||||
|
|
||||||
#define FHSTATOFF 0
|
extern const device dev_console_storage;
|
||||||
#endif
|
#define console_dev (&dev_console_storage)
|
||||||
|
extern const device dev_piper_storage;
|
||||||
|
#define piper_dev (&dev_piper_storage)
|
||||||
|
extern const device dev_pipew_storage;
|
||||||
|
#define pipew_dev (&dev_pipew_storage)
|
||||||
|
extern const device dev_socket_storage;
|
||||||
|
#define socket_dev (&dev_socket_storage)
|
||||||
|
extern const device dev_ttym_storage;
|
||||||
|
#define ttym_dev (&dev_ttym_storage)
|
||||||
|
extern const device dev_ttys_storage;
|
||||||
|
#define ttys_dev (&dev_ttys_storage)
|
||||||
|
extern const device dev_urandom_storage;
|
||||||
|
#define urandom_dev (&dev_urandom_storage)
|
||||||
|
extern const device dev_tcp_storage;
|
||||||
|
#define tcp_dev (&dev_tcp_storage)
|
||||||
|
extern const device dev_udp_storage;
|
||||||
|
#define udp_dev (&dev_udp_storage)
|
||||||
|
extern const device dev_icmp_storage;
|
||||||
|
#define icmp_dev (&dev_icmp_storage)
|
||||||
|
extern const device dev_unix_storage;
|
||||||
|
#define unix_dev (&dev_unix_storage)
|
||||||
|
extern const device dev_stream_storage;
|
||||||
|
#define stream_dev (&dev_stream_storage)
|
||||||
|
extern const device dev_dgram_storage;
|
||||||
|
#define dgram_dev (&dev_dgram_storage)
|
||||||
|
extern const device dev_proc_storage;
|
||||||
|
#define proc_dev (&dev_proc_storage)
|
||||||
|
extern const device dev_cygdrive_storage;
|
||||||
|
#define cygdrive_dev (&dev_cygdrive_storage)
|
||||||
|
extern const device dev_fh_storage;
|
||||||
|
#define fh_dev (&dev_fh_storage)
|
||||||
|
extern const device dev_fs_storage;
|
||||||
|
#define fs_dev (&dev_fs_storage)
|
||||||
|
406
winsup/cygwin/devices.shilka
Normal file
406
winsup/cygwin/devices.shilka
Normal file
@ -0,0 +1,406 @@
|
|||||||
|
%import {
|
||||||
|
#include "winsup.h"
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "devices.h"
|
||||||
|
#include "sys/cygwin.h"
|
||||||
|
#include "tty.h"
|
||||||
|
#include "pinfo.h"
|
||||||
|
typedef const device *KR_device_t;
|
||||||
|
}
|
||||||
|
%type KR_device_t
|
||||||
|
%local {
|
||||||
|
const device dev_cygdrive_storage =
|
||||||
|
{"/cygdrive", FH_CYGDRIVE, "/cygdrive", 0, 0, 0, 0};
|
||||||
|
|
||||||
|
const device dev_fs_storage =
|
||||||
|
{"", FH_FS, "", 0, 0, 0, 0};
|
||||||
|
|
||||||
|
const device dev_proc_storage =
|
||||||
|
{"", FH_PROC, "", 0, 0, 0, 0};
|
||||||
|
|
||||||
|
const device dev_registry_storage =
|
||||||
|
{"", FH_REGISTRY, "", 0, 0, 0, 0};
|
||||||
|
|
||||||
|
const device dev_process_storage =
|
||||||
|
{"", FH_PROCESS, "", 0, 0, 0, 0};
|
||||||
|
|
||||||
|
const device dev_tcp_storage =
|
||||||
|
{"/dev/inet/tcp", FH_TCP, "", 0, 0, 0, 0};
|
||||||
|
|
||||||
|
const device dev_udp_storage =
|
||||||
|
{"/dev/inet/udp", FH_UCP, "", 0, 0, 0, 0};
|
||||||
|
|
||||||
|
const device dev_icmp_storage =
|
||||||
|
{"/dev/inet/icmp", FH_ICMP, "", 0, 0, 0, 0};
|
||||||
|
|
||||||
|
const device dev_unix_storage =
|
||||||
|
{"/dev/inet/unix", FH_UNIX, "", 0, 0, 0, 0};
|
||||||
|
|
||||||
|
const device dev_stream_storage =
|
||||||
|
{"/dev/inet/stream", FH_STREAM, "", 0, 0, 0, 0};
|
||||||
|
|
||||||
|
const device dev_dgram_storage =
|
||||||
|
{"/dev/inet/dgram", FH_DGRAM, "", 0, 0, 0, 0};
|
||||||
|
|
||||||
|
const device dev_piper_storage =
|
||||||
|
{"", FH_PIPER, "", 0, 0, 0, 0};
|
||||||
|
|
||||||
|
const device dev_pipew_storage =
|
||||||
|
{"", FH_PIPEW, "", 0, 0, 0, 0};
|
||||||
|
|
||||||
|
const device dev_tty_storage =
|
||||||
|
{"/dev/tty", FH_TTY, "\\dev\\tty", 0, 0, 0, 0};
|
||||||
|
|
||||||
|
const device dev_ttys_storage =
|
||||||
|
{"/dev/ttys", FH_TTYS, "\\dev\\tty%d", 0, 255, 0, 0};
|
||||||
|
|
||||||
|
const device dev_console_storage =
|
||||||
|
{"/dev/console", FH_CONSOLE, "\\dev\\console", 0, 0, 0, 0};
|
||||||
|
|
||||||
|
const device dev_ttym_storage =
|
||||||
|
{"/dev/ttym", FH_TTYM, "\\dev\\ttym", 0, 255, 0, 0};
|
||||||
|
|
||||||
|
const device dev_ptym_storage =
|
||||||
|
{"/dev/ptmx", FH_PTYM, "\\dev\\ptmx", 0, 0, 0, 0};
|
||||||
|
|
||||||
|
const device dev_windows_storage =
|
||||||
|
{"/dev/windows", FH_WINDOWS, "\\dev\\windows", 0, 0, 0, 0};
|
||||||
|
|
||||||
|
const device dev_oss_dsp_storage =
|
||||||
|
{"/dev/dsp", FH_OSS_DSP, "\\dev\\dsp", 0, 0, 0, 0};
|
||||||
|
|
||||||
|
const device dev_conin_storage =
|
||||||
|
{"/dev/conin", FH_CONIN, "conin", 0, 0, 0, 0};
|
||||||
|
|
||||||
|
const device dev_conout_storage =
|
||||||
|
{"/dev/conout", FH_CONOUT, "conout", 0, 0, 0, 0};
|
||||||
|
|
||||||
|
const device dev_null_storage =
|
||||||
|
{"/dev/null", FH_NULL, "nul", 0, 0, 0, 0};
|
||||||
|
|
||||||
|
const device dev_zero_storage =
|
||||||
|
{"/dev/zero", FH_ZERO, "\\dev\\zero", 0, 0, 0, 0};
|
||||||
|
|
||||||
|
const device dev_random_storage =
|
||||||
|
{"/dev/random", FH_RANDOM, "\\dev\\random", 0, 0, 0, 0};
|
||||||
|
|
||||||
|
const device dev_urandom_storage =
|
||||||
|
{"/dev/urandom", FH_URANDOM, "\\dev\\urandom", 0, 0, 0, 0};
|
||||||
|
|
||||||
|
const device dev_mem_storage =
|
||||||
|
{"/dev/mem", FH_MEM, "\\dev\\mem", 0, 0, 0, 0};
|
||||||
|
|
||||||
|
const device dev_kmem_storage =
|
||||||
|
{"/dev/kmem", FH_KMEM, "\\dev\\mem", 0, 0, 0, 0};
|
||||||
|
|
||||||
|
const device dev_clipboard_storage =
|
||||||
|
{"/dev/clipboard", FH_CLIPBOARD, "\\dev\\clipboard", 0, 0, 0, 0};
|
||||||
|
|
||||||
|
const device dev_port_storage =
|
||||||
|
{"/dev/port", FH_PORT, "\\dev\\port", 0, 0, 0, 0};
|
||||||
|
|
||||||
|
const device dev_serial_storage =
|
||||||
|
{"/dev/com", FH_SERIAL, "\\.\\com%d", 1, 99};
|
||||||
|
|
||||||
|
const device dev_ttyS_storage =
|
||||||
|
{"/dev/ttyS", FH_SERIAL, "\\.\\com%d", 0, 99, -1};
|
||||||
|
|
||||||
|
const device dev_pipe_storage =
|
||||||
|
{"/dev/pipe", FH_PIPE, "\\dev\\pipe", 0, 0, 0, 0};
|
||||||
|
|
||||||
|
const device dev_fifo_storage =
|
||||||
|
{"/dev/fifo", FH_FIFO, "\\dev\\fifo", 0, 0, 0, 0};
|
||||||
|
|
||||||
|
const device dev_tape_storage =
|
||||||
|
{"/dev/st", FH_TAPE, "\\Device\\Tape%d", 0, 127};
|
||||||
|
|
||||||
|
const device dev_nst_storage =
|
||||||
|
{"/dev/nst", FH_NTAPE, "\\Device\\Tape%d", 0, 127};
|
||||||
|
|
||||||
|
const device dev_floppy_storage =
|
||||||
|
{"/dev/fd", FH_FLOPPY, "\\Device\\Floppy%d", 0, 15};
|
||||||
|
|
||||||
|
const device dev_cdrom_storage =
|
||||||
|
{"/dev/scd", FH_CDROM, "\\Device\\CdRom%d", 0, 15};
|
||||||
|
|
||||||
|
const device dev_sr_storage =
|
||||||
|
{"/dev/sr", FH_CDROM, "\\Device\\CdRom%d", 0, 15};
|
||||||
|
|
||||||
|
const device dev_hda_storage =
|
||||||
|
{"/dev/hda", FH_SDA, "\\Device\\Harddisk%d\\Partition%d", 1, 16, -1};
|
||||||
|
|
||||||
|
const device dev_hdb_storage =
|
||||||
|
{"/dev/hdb", FH_SDB, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 15};
|
||||||
|
|
||||||
|
const device dev_hdc_storage =
|
||||||
|
{"/dev/hdc", FH_SDC, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 31};
|
||||||
|
|
||||||
|
const device dev_hdd_storage =
|
||||||
|
{"/dev/hdd", FH_SDD, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 47};
|
||||||
|
|
||||||
|
const device dev_hde_storage =
|
||||||
|
{"/dev/hde", FH_SDE, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 63};
|
||||||
|
|
||||||
|
const device dev_hdf_storage =
|
||||||
|
{"/dev/hdf", FH_SDF, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 79};
|
||||||
|
|
||||||
|
const device dev_hdg_storage =
|
||||||
|
{"/dev/hdg", FH_SDG, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 95};
|
||||||
|
|
||||||
|
const device dev_hdh_storage =
|
||||||
|
{"/dev/hdh", FH_SDH, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 111};
|
||||||
|
|
||||||
|
const device dev_hdi_storage =
|
||||||
|
{"/dev/hdi", FH_SDI, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 127};
|
||||||
|
|
||||||
|
const device dev_hdj_storage =
|
||||||
|
{"/dev/hdj", FH_SDJ, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 143};
|
||||||
|
|
||||||
|
const device dev_hdk_storage =
|
||||||
|
{"/dev/hdk", FH_SDK, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 159};
|
||||||
|
|
||||||
|
const device dev_hdl_storage =
|
||||||
|
{"/dev/hdl", FH_SDL, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 175};
|
||||||
|
|
||||||
|
const device dev_hdm_storage =
|
||||||
|
{"/dev/hdm", FH_SDM, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 191};
|
||||||
|
|
||||||
|
const device dev_hdn_storage =
|
||||||
|
{"/dev/hdn", FH_SDN, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 207};
|
||||||
|
|
||||||
|
const device dev_hdo_storage =
|
||||||
|
{"/dev/hdo", FH_SDO, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 223};
|
||||||
|
|
||||||
|
const device dev_hdp_storage =
|
||||||
|
{"/dev/hdp", FH_SDP, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 239};
|
||||||
|
|
||||||
|
const device dev_hdq_storage =
|
||||||
|
{"/dev/hdq", FH_SDQ, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 255 /* FIXME 8 bit lunacy */};
|
||||||
|
|
||||||
|
const device dev_hdr_storage =
|
||||||
|
{"/dev/hdr", FH_SDR, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 271};
|
||||||
|
|
||||||
|
const device dev_hds_storage =
|
||||||
|
{"/dev/hds", FH_SDS, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 287};
|
||||||
|
|
||||||
|
const device dev_hdt_storage =
|
||||||
|
{"/dev/hdt", FH_SDT, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 303};
|
||||||
|
|
||||||
|
const device dev_hdu_storage =
|
||||||
|
{"/dev/hdu", FH_SDU, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 319};
|
||||||
|
|
||||||
|
const device dev_hdv_storage =
|
||||||
|
{"/dev/hdv", FH_SDV, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 335};
|
||||||
|
|
||||||
|
const device dev_hdw_storage =
|
||||||
|
{"/dev/hdw", FH_SDW, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 351};
|
||||||
|
|
||||||
|
const device dev_hdx_storage =
|
||||||
|
{"/dev/hdx", FH_SDX, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 367};
|
||||||
|
|
||||||
|
const device dev_hdy_storage =
|
||||||
|
{"/dev/hdy", FH_SDY, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 383};
|
||||||
|
|
||||||
|
const device dev_hdz_storage =
|
||||||
|
{"/dev/hdz", FH_SDZ, "\\Device\\Harddisk%d\\Partition%d", 1, 16, 399};
|
||||||
|
|
||||||
|
const device dev_rawdrive_storage =
|
||||||
|
{"/dev/rawdrive", FH_RAWDRIVE, "\\DosDevices\\%c:", 0, 0, 0, 0};
|
||||||
|
|
||||||
|
const device dev_bad_storage =
|
||||||
|
{":bad:", FH_BAD, ":bad:", 0, 0, 0, 0};
|
||||||
|
#define bad_dev (&dev_bad_storage)
|
||||||
|
|
||||||
|
const device *unit_devices[] =
|
||||||
|
{
|
||||||
|
&dev_cdrom_storage,
|
||||||
|
&dev_serial_storage,
|
||||||
|
&dev_ttym_storage,
|
||||||
|
&dev_ttys_storage,
|
||||||
|
&dev_floppy_storage,
|
||||||
|
&dev_tcp_storage,
|
||||||
|
&dev_rawdrive_storage,
|
||||||
|
&dev_tape_storage
|
||||||
|
};
|
||||||
|
|
||||||
|
const device *uniq_devices[] =
|
||||||
|
{
|
||||||
|
&dev_bad_storage,
|
||||||
|
&dev_fs_storage,
|
||||||
|
&dev_process_storage,
|
||||||
|
&dev_registry_storage,
|
||||||
|
&dev_proc_storage,
|
||||||
|
&dev_fifo_storage,
|
||||||
|
&dev_pipew_storage,
|
||||||
|
&dev_piper_storage,
|
||||||
|
&dev_pipe_storage,
|
||||||
|
&dev_mem_storage,
|
||||||
|
&dev_kmem_storage,
|
||||||
|
&dev_null_storage,
|
||||||
|
&dev_zero_storage,
|
||||||
|
&dev_port_storage,
|
||||||
|
&dev_random_storage,
|
||||||
|
&dev_urandom_storage,
|
||||||
|
&dev_tty_storage,
|
||||||
|
&dev_console_storage,
|
||||||
|
&dev_ptym_storage,
|
||||||
|
&dev_conout_storage,
|
||||||
|
&dev_conin_storage,
|
||||||
|
&dev_clipboard_storage,
|
||||||
|
&dev_windows_storage,
|
||||||
|
&dev_oss_dsp_storage,
|
||||||
|
&dev_serial_storage
|
||||||
|
};
|
||||||
|
}
|
||||||
|
%%
|
||||||
|
"/dev/tty" = tty {return &dev_tty_storage;}
|
||||||
|
"/dev/ttys" = ttys {return &dev_ttys_storage;}
|
||||||
|
"/dev/console" = console {return &dev_console_storage;}
|
||||||
|
"/dev/ttym" = ttym {return &dev_ttym_storage;}
|
||||||
|
"/dev/ptmx" = ptmx {return &dev_ptym_storage;}
|
||||||
|
"/dev/windows" = windows {return &dev_windows_storage;}
|
||||||
|
"/dev/dsp" = dsp {return &dev_oss_dsp_storage;}
|
||||||
|
"/dev/conin" = conin {return &dev_conin_storage;}
|
||||||
|
"/dev/conout" = conout {return &dev_conout_storage;}
|
||||||
|
"/dev/null" = null {return &dev_null_storage;}
|
||||||
|
"/dev/zero" = zero {return &dev_zero_storage;}
|
||||||
|
"/dev/random" = random {return &dev_random_storage;}
|
||||||
|
"/dev/urandom" = urandom {return &dev_urandom_storage;}
|
||||||
|
"/dev/mem" = mem {return &dev_mem_storage;}
|
||||||
|
"/dev/kmem" = kmem {return &dev_kmem_storage;}
|
||||||
|
"/dev/clipboard" = clipboard {return &dev_clipboard_storage;}
|
||||||
|
"/dev/port" = port {return &dev_port_storage;}
|
||||||
|
"/dev/com" = com {return &dev_serial_storage;}
|
||||||
|
"/dev/ttyS" = ttyS {return &dev_ttyS_storage;}
|
||||||
|
"/dev/pipe" = pipe {return &dev_pipe_storage;}
|
||||||
|
"/dev/fifo" = fifo {return &dev_fifo_storage;}
|
||||||
|
"/dev/st" = st {return &dev_tape_storage;}
|
||||||
|
"/dev/nst" = nst {return &dev_nst_storage;}
|
||||||
|
"/dev/fd" = fd {return &dev_floppy_storage;}
|
||||||
|
"/dev/scd" = scd {return &dev_cdrom_storage;}
|
||||||
|
"/dev/sr" = sr {return &dev_sr_storage;}
|
||||||
|
"/dev/hda" = hda {return &dev_hda_storage;}
|
||||||
|
"/dev/hdb" = hdb {return &dev_hdb_storage;}
|
||||||
|
"/dev/hdc" = hdc {return &dev_hdc_storage;}
|
||||||
|
"/dev/hdd" = hdd {return &dev_hdd_storage;}
|
||||||
|
"/dev/hde" = hde {return &dev_hde_storage;}
|
||||||
|
"/dev/hdf" = hdf {return &dev_hdf_storage;}
|
||||||
|
"/dev/hdg" = hdg {return &dev_hdg_storage;}
|
||||||
|
"/dev/hdh" = hdh {return &dev_hdh_storage;}
|
||||||
|
"/dev/hdi" = hdi {return &dev_hdi_storage;}
|
||||||
|
"/dev/hdj" = hdj {return &dev_hdj_storage;}
|
||||||
|
"/dev/hdk" = hdk {return &dev_hdk_storage;}
|
||||||
|
"/dev/hdl" = hdl {return &dev_hdl_storage;}
|
||||||
|
"/dev/hdm" = hdm {return &dev_hdm_storage;}
|
||||||
|
"/dev/hdn" = hdn {return &dev_hdn_storage;}
|
||||||
|
"/dev/hdo" = hdo {return &dev_hdo_storage;}
|
||||||
|
"/dev/hdp" = hdp {return &dev_hdp_storage;}
|
||||||
|
"/dev/hdq" = hdq {return &dev_hdq_storage;}
|
||||||
|
"/dev/hdr" = hdr {return &dev_hdr_storage;}
|
||||||
|
"/dev/hds" = hds {return &dev_hds_storage;}
|
||||||
|
"/dev/hdt" = hdt {return &dev_hdt_storage;}
|
||||||
|
"/dev/hdu" = hdu {return &dev_hdu_storage;}
|
||||||
|
"/dev/hdv" = hdv {return &dev_hdv_storage;}
|
||||||
|
"/dev/hdw" = hdw {return &dev_hdw_storage;}
|
||||||
|
"/dev/hdx" = hdx {return &dev_hdx_storage;}
|
||||||
|
"/dev/hdy" = hdy {return &dev_hdy_storage;}
|
||||||
|
"/dev/hdz" = hdz {return &dev_hdz_storage;}
|
||||||
|
"/dev/rawdrive" = rawdrive {return &dev_rawdrive_storage;}
|
||||||
|
%other {return NULL;}
|
||||||
|
%%
|
||||||
|
void
|
||||||
|
device::parse (const char *s)
|
||||||
|
{
|
||||||
|
size_t len = strlen (s);
|
||||||
|
const device *dev = KR_find_keyword (s, len);
|
||||||
|
unsigned unit = 0;
|
||||||
|
|
||||||
|
if (!dev || !*dev)
|
||||||
|
{
|
||||||
|
size_t prior_len = len;
|
||||||
|
while (len-- > 0 && isdigit (s[len]))
|
||||||
|
continue;
|
||||||
|
if (++len < prior_len)
|
||||||
|
{
|
||||||
|
dev = KR_find_keyword (s, len);
|
||||||
|
if (!dev || (!dev->upper && !dev->devn == FH_TTY))
|
||||||
|
dev = NULL;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
unsigned n = atoi (s + len);
|
||||||
|
if (dev->devn == FH_TTY)
|
||||||
|
dev = ttys_dev; // SIGH
|
||||||
|
if (n >= dev->lower && n <= dev->upper)
|
||||||
|
unit = n;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!dev || !*dev)
|
||||||
|
*this = *fs_dev;
|
||||||
|
else if (dev->devn == FH_TTY)
|
||||||
|
tty_to_real_device ();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*this = *dev;
|
||||||
|
if (!setunit (unit))
|
||||||
|
devn = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
device::init ()
|
||||||
|
{
|
||||||
|
/* nothing to do... yet */
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
device::parse (_major_t major, _minor_t minor)
|
||||||
|
{
|
||||||
|
_dev_t dev = FHDEV (major, 0);
|
||||||
|
|
||||||
|
devn = 0;
|
||||||
|
|
||||||
|
unsigned i;
|
||||||
|
for (i = 0; i < (sizeof (unit_devices) / sizeof (unit_devices[0])); i++)
|
||||||
|
if (unit_devices[i]->devn == dev)
|
||||||
|
{
|
||||||
|
*this = *unit_devices[i];
|
||||||
|
this->setunit (minor);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
dev = FHDEV (major, minor);
|
||||||
|
for (i = 0; i < (sizeof (uniq_devices) / sizeof (uniq_devices[0])); i++)
|
||||||
|
if (uniq_devices[i]->devn == dev)
|
||||||
|
{
|
||||||
|
*this = *uniq_devices[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
|
if (!*this)
|
||||||
|
devn = FHDEV (major, minor);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
device::parse (_dev_t dev)
|
||||||
|
{
|
||||||
|
parse (_major (dev), _minor (dev));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
device::tty_to_real_device ()
|
||||||
|
{
|
||||||
|
if (!real_tty_attached (myself))
|
||||||
|
*this = myself->ctty < 0 ? *bad_dev : *console_dev;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*this = *ttys_dev;
|
||||||
|
setunit (myself->ctty);
|
||||||
|
}
|
||||||
|
}
|
@ -19,8 +19,8 @@ details. */
|
|||||||
#include "pinfo.h"
|
#include "pinfo.h"
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include "fhandler.h"
|
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
|
|
||||||
@ -84,15 +84,13 @@ extern "C" DIR *
|
|||||||
opendir (const char *name)
|
opendir (const char *name)
|
||||||
{
|
{
|
||||||
fhandler_base *fh;
|
fhandler_base *fh;
|
||||||
path_conv pc;
|
|
||||||
DIR *res;
|
DIR *res;
|
||||||
|
|
||||||
fh = cygheap->fdtab.build_fhandler_from_name (-1, name, NULL, pc,
|
fh = build_fh_name (name, NULL, PC_SYM_FOLLOW | PC_FULL);
|
||||||
PC_SYM_FOLLOW | PC_FULL, NULL);
|
|
||||||
if (!fh)
|
if (!fh)
|
||||||
res = NULL;
|
res = NULL;
|
||||||
else if (pc.exists ())
|
else if (fh->exists ())
|
||||||
res = fh->opendir (pc);
|
res = fh->opendir ();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
set_errno (ENOENT);
|
set_errno (ENOENT);
|
||||||
|
@ -14,9 +14,9 @@ details. */
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
|
#include "path.h"
|
||||||
#include "fhandler.h"
|
#include "fhandler.h"
|
||||||
#include "perprocess.h"
|
#include "perprocess.h"
|
||||||
#include "path.h"
|
|
||||||
#include "thread.h"
|
#include "thread.h"
|
||||||
#include "dlfcn.h"
|
#include "dlfcn.h"
|
||||||
#include "dll_init.h"
|
#include "dll_init.h"
|
||||||
|
@ -13,8 +13,8 @@ details. */
|
|||||||
#include "dll_init.h"
|
#include "dll_init.h"
|
||||||
#include "environ.h"
|
#include "environ.h"
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include "fhandler.h"
|
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
#include "pinfo.h"
|
#include "pinfo.h"
|
||||||
|
@ -28,6 +28,210 @@
|
|||||||
* malloc_usable_size(P) is equivalent to realloc(P, malloc_usable_size(P))
|
* malloc_usable_size(P) is equivalent to realloc(P, malloc_usable_size(P))
|
||||||
*
|
*
|
||||||
* $Log$
|
* $Log$
|
||||||
|
* Revision 1.7 2003/09/25 00:37:16 cgf
|
||||||
|
* * 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.
|
||||||
|
*
|
||||||
|
* Revision 1.5.52.1 2003/09/02 02:31:08 cgf
|
||||||
|
* merge from trunk
|
||||||
|
*
|
||||||
* Revision 1.6 2003/08/31 18:26:58 cgf
|
* Revision 1.6 2003/08/31 18:26:58 cgf
|
||||||
* * Makefile.in (MALLOC_OFILES): Always fill in with correct malloc object.
|
* * Makefile.in (MALLOC_OFILES): Always fill in with correct malloc object.
|
||||||
* * configure.in: Fill in MALLOC_OFILES with either debugging or regular malloc.
|
* * configure.in: Fill in MALLOC_OFILES with either debugging or regular malloc.
|
||||||
|
@ -26,8 +26,8 @@ details. */
|
|||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "perprocess.h"
|
#include "perprocess.h"
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include "fhandler.h"
|
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
#include "ntdll.h"
|
#include "ntdll.h"
|
||||||
@ -105,12 +105,12 @@ dtable::get_debugger_info ()
|
|||||||
for (int i = 0; i < 3; i++)
|
for (int i = 0; i < 3; i++)
|
||||||
if (std[i][0])
|
if (std[i][0])
|
||||||
{
|
{
|
||||||
path_conv pc;
|
|
||||||
HANDLE h = GetStdHandle (std_consts[i]);
|
HANDLE h = GetStdHandle (std_consts[i]);
|
||||||
fhandler_base *fh = build_fhandler_from_name (i, std[i], NULL, pc);
|
fhandler_base *fh = build_fh_name (std[i]);
|
||||||
if (!fh)
|
if (!fh)
|
||||||
continue;
|
continue;
|
||||||
if (!fh->open (&pc, (i ? O_WRONLY : O_RDONLY) | O_BINARY, 0777))
|
fds[i] = fh;
|
||||||
|
if (!fh->open ((i ? O_WRONLY : O_RDONLY) | O_BINARY, 0777))
|
||||||
release (i);
|
release (i);
|
||||||
else
|
else
|
||||||
CloseHandle (h);
|
CloseHandle (h);
|
||||||
@ -183,12 +183,8 @@ dtable::release (int fd)
|
|||||||
{
|
{
|
||||||
if (!not_open (fd))
|
if (!not_open (fd))
|
||||||
{
|
{
|
||||||
switch (fds[fd]->get_device ())
|
if (fds[fd]->need_fixup_before ())
|
||||||
{
|
dec_need_fixup_before ();
|
||||||
case FH_SOCKET:
|
|
||||||
dec_need_fixup_before ();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
delete fds[fd];
|
delete fds[fd];
|
||||||
fds[fd] = NULL;
|
fds[fd] = NULL;
|
||||||
}
|
}
|
||||||
@ -200,23 +196,24 @@ cygwin_attach_handle_to_fd (char *name, int fd, HANDLE handle, mode_t bin,
|
|||||||
{
|
{
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
fd = cygheap->fdtab.find_unused_handle ();
|
fd = cygheap->fdtab.find_unused_handle ();
|
||||||
path_conv pc;
|
fhandler_base *fh = build_fh_name (name);
|
||||||
fhandler_base *res = cygheap->fdtab.build_fhandler_from_name (fd, name, handle,
|
cygheap->fdtab[fd] = fh;
|
||||||
pc);
|
fh->init (handle, myaccess, bin ?: fh->pc_binmode ());
|
||||||
res->init (handle, myaccess, bin ?: pc.binmode ());
|
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
dtable::init_std_file_from_handle (int fd, HANDLE handle)
|
dtable::init_std_file_from_handle (int fd, HANDLE handle)
|
||||||
{
|
{
|
||||||
const char *name;
|
const char *name = NULL;
|
||||||
CONSOLE_SCREEN_BUFFER_INFO buf;
|
CONSOLE_SCREEN_BUFFER_INFO buf;
|
||||||
struct sockaddr sa;
|
struct sockaddr sa;
|
||||||
int sal = sizeof (sa);
|
int sal = sizeof (sa);
|
||||||
DCB dcb;
|
DCB dcb;
|
||||||
unsigned bin = O_BINARY;
|
unsigned bin = O_BINARY;
|
||||||
|
device dev;
|
||||||
|
|
||||||
|
dev.devn = 0; /* FIXME: device */
|
||||||
first_fd_for_open = 0;
|
first_fd_for_open = 0;
|
||||||
|
|
||||||
if (!not_open (fd))
|
if (!not_open (fd))
|
||||||
@ -224,36 +221,34 @@ dtable::init_std_file_from_handle (int fd, HANDLE handle)
|
|||||||
|
|
||||||
SetLastError (0);
|
SetLastError (0);
|
||||||
DWORD ft = GetFileType (handle);
|
DWORD ft = GetFileType (handle);
|
||||||
if (ft == FILE_TYPE_UNKNOWN && GetLastError () == ERROR_INVALID_HANDLE)
|
if (ft != FILE_TYPE_UNKNOWN || GetLastError () != ERROR_INVALID_HANDLE)
|
||||||
name = NULL;
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
/* See if we can consoleify it */
|
/* See if we can consoleify it */
|
||||||
if (GetConsoleScreenBufferInfo (handle, &buf))
|
if (GetConsoleScreenBufferInfo (handle, &buf))
|
||||||
{
|
{
|
||||||
if (ISSTATE (myself, PID_USETTY))
|
if (ISSTATE (myself, PID_USETTY))
|
||||||
name = "/dev/tty";
|
dev.parse ("/dev/tty");
|
||||||
else
|
else
|
||||||
name = "/dev/conout";
|
dev = *console_dev;
|
||||||
}
|
}
|
||||||
else if (GetNumberOfConsoleInputEvents (handle, (DWORD *) &buf))
|
else if (GetNumberOfConsoleInputEvents (handle, (DWORD *) &buf))
|
||||||
{
|
{
|
||||||
if (ISSTATE (myself, PID_USETTY))
|
if (ISSTATE (myself, PID_USETTY))
|
||||||
name = "/dev/tty";
|
dev.parse ("/dev/tty");
|
||||||
else
|
else
|
||||||
name = "/dev/conin";
|
dev = *console_dev;
|
||||||
}
|
}
|
||||||
else if (ft == FILE_TYPE_PIPE)
|
else if (ft == FILE_TYPE_PIPE)
|
||||||
{
|
{
|
||||||
if (fd == 0)
|
if (fd == 0)
|
||||||
name = "/dev/piper";
|
dev = *piper_dev;
|
||||||
else
|
else
|
||||||
name = "/dev/pipew";
|
dev = *pipew_dev;
|
||||||
}
|
}
|
||||||
else if (wsock_started && getpeername ((SOCKET) handle, &sa, &sal) == 0)
|
else if (wsock_started && getpeername ((SOCKET) handle, &sa, &sal) == 0)
|
||||||
name = "/dev/socket";
|
dev = *tcp_dev;
|
||||||
else if (GetCommState (handle, &dcb))
|
else if (GetCommState (handle, &dcb))
|
||||||
name = "/dev/ttyS0"; // FIXME - determine correct device
|
dev.parse ("/dev/ttyS0");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
name = handle_to_fn (handle, (char *) alloca (MAX_PATH + 100));
|
name = handle_to_fn (handle, (char *) alloca (MAX_PATH + 100));
|
||||||
@ -261,17 +256,29 @@ dtable::init_std_file_from_handle (int fd, HANDLE handle)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!name)
|
if (!name && !dev)
|
||||||
fds[fd] = NULL;
|
fds[fd] = NULL;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
path_conv pc;
|
fhandler_base *fh;
|
||||||
fhandler_base *fh = build_fhandler_from_name (fd, name, handle, pc);
|
|
||||||
|
if (dev)
|
||||||
|
fh = build_fh_dev (dev);
|
||||||
|
else
|
||||||
|
fh = build_fh_name (name);
|
||||||
|
|
||||||
|
if (fh)
|
||||||
|
cygheap->fdtab[fd] = fh;
|
||||||
|
|
||||||
if (!bin)
|
if (!bin)
|
||||||
{
|
{
|
||||||
bin = fh->get_default_fmode (O_RDWR);
|
bin = fh->get_default_fmode (O_RDWR);
|
||||||
if (!bin && name != unknown_file)
|
if (bin)
|
||||||
bin = pc.binmode ();
|
/* nothing */;
|
||||||
|
else if (dev)
|
||||||
|
bin = O_BINARY;
|
||||||
|
else if (name != unknown_file)
|
||||||
|
bin = fh->pc_binmode ();
|
||||||
}
|
}
|
||||||
|
|
||||||
fh->init (handle, GENERIC_READ | GENERIC_WRITE, bin);
|
fh->init (handle, GENERIC_READ | GENERIC_WRITE, bin);
|
||||||
@ -281,92 +288,110 @@ dtable::init_std_file_from_handle (int fd, HANDLE handle)
|
|||||||
}
|
}
|
||||||
|
|
||||||
fhandler_base *
|
fhandler_base *
|
||||||
dtable::build_fhandler_from_name (int fd, const char *name, HANDLE handle,
|
build_fh_name (const char *name, HANDLE h, unsigned opt, suffix_info *si)
|
||||||
path_conv& pc, unsigned opt, suffix_info *si)
|
|
||||||
{
|
{
|
||||||
pc.check (name, opt | PC_NULLEMPTY | PC_FULL | PC_POSIX, si);
|
path_conv pc (name, opt | PC_NULLEMPTY | PC_FULL | PC_POSIX, si);
|
||||||
if (pc.error)
|
if (pc.error)
|
||||||
{
|
{
|
||||||
set_errno (pc.error);
|
set_errno (pc.error);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pc.exists () && handle)
|
if (!pc.exists () && h)
|
||||||
pc.fillin (handle);
|
pc.fillin (h);
|
||||||
|
|
||||||
char *posix_path = pc.return_and_clear_normalized_path ();
|
return build_fh_pc (pc);
|
||||||
fhandler_base *fh = build_fhandler (fd, pc.get_devn (), posix_path,
|
|
||||||
pc, pc.get_unitn ());
|
|
||||||
if (pc.issocket ()) /* Only true for files pretending an AF_LOCAL socket. */
|
|
||||||
{
|
|
||||||
fhandler_socket * fhs = (fhandler_socket *) fh;
|
|
||||||
fhs->set_addr_family (AF_LOCAL);
|
|
||||||
fhs->set_sun_path (posix_path);
|
|
||||||
}
|
|
||||||
return fh;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fhandler_base *
|
fhandler_base *
|
||||||
dtable::build_fhandler (int fd, DWORD dev, const char *unix_name,
|
build_fh_dev (const device& dev, const char *unix_name)
|
||||||
const char *win32_name, int unit)
|
|
||||||
{
|
{
|
||||||
return build_fhandler (fd, dev, cstrdup (unix_name), win32_name, unit);
|
path_conv pc (dev);
|
||||||
|
char *w32buf = const_cast<char *> (pc.get_win32 ());
|
||||||
|
|
||||||
|
__small_sprintf (w32buf, dev.fmt, dev.minor);
|
||||||
|
if (unix_name)
|
||||||
|
pc.set_normalized_path (unix_name);
|
||||||
|
else if (!dev.upper)
|
||||||
|
pc.set_normalized_path (dev.name);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pc.set_normalized_path (w32buf);
|
||||||
|
for (char *p = strchr (pc.normalized_path, '\\');
|
||||||
|
p;
|
||||||
|
p = strchr (p + 1, '\\'))
|
||||||
|
*p = '/';
|
||||||
|
}
|
||||||
|
return build_fh_pc (pc);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define cnew(name) new ((void *) ccalloc (HEAP_FHANDLER, 1, sizeof (name))) name
|
#define cnew(name) new ((void *) ccalloc (HEAP_FHANDLER, 1, sizeof (name))) name
|
||||||
fhandler_base *
|
fhandler_base *
|
||||||
dtable::build_fhandler (int fd, DWORD dev, char *unix_name,
|
build_fh_pc (path_conv& pc)
|
||||||
const char *win32_name, int unit)
|
|
||||||
{
|
{
|
||||||
fhandler_base *fh;
|
fhandler_base *fh = NULL;
|
||||||
|
|
||||||
dev &= FH_DEVMASK;
|
if (pc.dev.upper)
|
||||||
switch (dev)
|
switch (pc.dev.major)
|
||||||
{
|
{
|
||||||
case FH_TTYM:
|
case DEV_TTYS_MAJOR:
|
||||||
fh = cnew (fhandler_tty_master) (unit);
|
fh = cnew (fhandler_tty_slave) ();
|
||||||
break;
|
break;
|
||||||
|
case DEV_TTYM_MAJOR:
|
||||||
|
fh = cnew (fhandler_tty_master) ();
|
||||||
|
break;
|
||||||
|
case DEV_CYGDRIVE_MAJOR:
|
||||||
|
fh = cnew (fhandler_cygdrive) ();
|
||||||
|
break;
|
||||||
|
case DEV_FLOPPY_MAJOR:
|
||||||
|
case DEV_CDROM_MAJOR:
|
||||||
|
case DEV_SD_MAJOR:
|
||||||
|
case DEV_RAWDRIVE_MAJOR:
|
||||||
|
fh = cnew (fhandler_dev_floppy) ();
|
||||||
|
break;
|
||||||
|
case DEV_TAPE_MAJOR:
|
||||||
|
fh = cnew (fhandler_dev_tape) ();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
switch (pc.dev)
|
||||||
|
{
|
||||||
case FH_CONSOLE:
|
case FH_CONSOLE:
|
||||||
case FH_CONIN:
|
case FH_CONIN:
|
||||||
case FH_CONOUT:
|
case FH_CONOUT:
|
||||||
fh = cnew (fhandler_console) ();
|
fh = cnew (fhandler_console) ();
|
||||||
break;
|
break;
|
||||||
|
case FH_CYGDRIVE:
|
||||||
|
fh = cnew (fhandler_cygdrive) ();
|
||||||
|
break;
|
||||||
case FH_PTYM:
|
case FH_PTYM:
|
||||||
fh = cnew (fhandler_pty_master) ();
|
fh = cnew (fhandler_pty_master) ();
|
||||||
break;
|
break;
|
||||||
case FH_TTYS:
|
|
||||||
if (unit < 0)
|
|
||||||
fh = cnew (fhandler_tty_slave) ();
|
|
||||||
else
|
|
||||||
fh = cnew (fhandler_tty_slave) (unit);
|
|
||||||
break;
|
|
||||||
case FH_WINDOWS:
|
case FH_WINDOWS:
|
||||||
fh = cnew (fhandler_windows) ();
|
fh = cnew (fhandler_windows) ();
|
||||||
break;
|
break;
|
||||||
case FH_SERIAL:
|
case FH_SERIAL:
|
||||||
fh = cnew (fhandler_serial) (unit);
|
fh = cnew (fhandler_serial) ();
|
||||||
|
break;
|
||||||
|
case FH_FIFO:
|
||||||
|
fh = cnew (fhandler_fifo) ();
|
||||||
break;
|
break;
|
||||||
case FH_PIPE:
|
case FH_PIPE:
|
||||||
case FH_PIPER:
|
case FH_PIPER:
|
||||||
case FH_PIPEW:
|
case FH_PIPEW:
|
||||||
fh = cnew (fhandler_pipe) (dev);
|
fh = cnew (fhandler_pipe) ();
|
||||||
break;
|
break;
|
||||||
case FH_SOCKET:
|
case FH_TCP:
|
||||||
if ((fh = cnew (fhandler_socket) (unit)))
|
case FH_UCP:
|
||||||
inc_need_fixup_before ();
|
case FH_ICMP:
|
||||||
|
case FH_UNIX:
|
||||||
|
case FH_STREAM:
|
||||||
|
case FH_DGRAM:
|
||||||
|
fh = cnew (fhandler_socket) ();
|
||||||
break;
|
break;
|
||||||
case FH_DISK:
|
case FH_FS:
|
||||||
fh = cnew (fhandler_disk_file) ();
|
fh = cnew (fhandler_disk_file) ();
|
||||||
break;
|
break;
|
||||||
case FH_CYGDRIVE:
|
|
||||||
fh = cnew (fhandler_cygdrive) (unit);
|
|
||||||
break;
|
|
||||||
case FH_FLOPPY:
|
|
||||||
fh = cnew (fhandler_dev_floppy) (unit);
|
|
||||||
break;
|
|
||||||
case FH_TAPE:
|
|
||||||
fh = cnew (fhandler_dev_tape) (unit);
|
|
||||||
break;
|
|
||||||
case FH_NULL:
|
case FH_NULL:
|
||||||
fh = cnew (fhandler_dev_null) ();
|
fh = cnew (fhandler_dev_null) ();
|
||||||
break;
|
break;
|
||||||
@ -374,10 +399,12 @@ dtable::build_fhandler (int fd, DWORD dev, char *unix_name,
|
|||||||
fh = cnew (fhandler_dev_zero) ();
|
fh = cnew (fhandler_dev_zero) ();
|
||||||
break;
|
break;
|
||||||
case FH_RANDOM:
|
case FH_RANDOM:
|
||||||
fh = cnew (fhandler_dev_random) (unit);
|
case FH_URANDOM:
|
||||||
|
fh = cnew (fhandler_dev_random) ();
|
||||||
break;
|
break;
|
||||||
case FH_MEM:
|
case FH_MEM:
|
||||||
fh = cnew (fhandler_dev_mem) (unit);
|
case FH_PORT:
|
||||||
|
fh = cnew (fhandler_dev_mem) ();
|
||||||
break;
|
break;
|
||||||
case FH_CLIPBOARD:
|
case FH_CLIPBOARD:
|
||||||
fh = cnew (fhandler_dev_clipboard) ();
|
fh = cnew (fhandler_dev_clipboard) ();
|
||||||
@ -394,34 +421,35 @@ dtable::build_fhandler (int fd, DWORD dev, char *unix_name,
|
|||||||
case FH_PROCESS:
|
case FH_PROCESS:
|
||||||
fh = cnew (fhandler_process) ();
|
fh = cnew (fhandler_process) ();
|
||||||
break;
|
break;
|
||||||
default:
|
case FH_TTY:
|
||||||
system_printf ("internal error -- unknown device - %p", dev);
|
{
|
||||||
fh = NULL;
|
device newdev = pc.dev;
|
||||||
|
newdev.tty_to_real_device ();
|
||||||
|
switch (newdev)
|
||||||
|
{
|
||||||
|
case FH_CONSOLE:
|
||||||
|
fh = cnew (fhandler_console) ();
|
||||||
|
break;
|
||||||
|
case FH_TTYS:
|
||||||
|
fh = cnew (fhandler_tty_slave) ();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unix_name)
|
if (!fh)
|
||||||
{
|
fh = cnew (fhandler_nodevice) ();
|
||||||
char new_win32_name[strlen (unix_name) + 1];
|
|
||||||
if (!win32_name)
|
fh->set_name (pc);
|
||||||
{
|
|
||||||
char *p;
|
debug_printf ("fh %p", fh);
|
||||||
/* FIXME: ? Should we call win32_device_name here?
|
return fh;
|
||||||
It seems like overkill, but... */
|
|
||||||
win32_name = strcpy (new_win32_name, unix_name);
|
|
||||||
for (p = (char *) win32_name; (p = strchr (p, '/')); p++)
|
|
||||||
*p = '\\';
|
|
||||||
}
|
|
||||||
if (!fh->set_name (unix_name, win32_name, fh->get_unit ()))
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
debug_printf ("fd %d, fh %p", fd, fh);
|
|
||||||
return fd >= 0 ? (fds[fd] = fh) : fh;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fhandler_base *
|
fhandler_base *
|
||||||
dtable::dup_worker (fhandler_base *oldfh)
|
dtable::dup_worker (fhandler_base *oldfh)
|
||||||
{
|
{
|
||||||
fhandler_base *newfh = build_fhandler (-1, oldfh->get_device ());
|
fhandler_base *newfh = build_fh_pc (oldfh->pc);
|
||||||
*newfh = *oldfh;
|
*newfh = *oldfh;
|
||||||
newfh->set_io_handle (NULL);
|
newfh->set_io_handle (NULL);
|
||||||
if (oldfh->dup (newfh))
|
if (oldfh->dup (newfh))
|
||||||
@ -500,6 +528,19 @@ done:
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fhandler_fifo *
|
||||||
|
dtable::find_fifo (ATOM hill)
|
||||||
|
{
|
||||||
|
SetResourceLock (LOCK_FD_LIST, READ_LOCK, "dup");
|
||||||
|
for (unsigned i = 0; i < size; i++)
|
||||||
|
{
|
||||||
|
fhandler_base *fh = fds[i];
|
||||||
|
if (fh && fh->isfifo () && ((fhandler_fifo *) fh)->get_atom () == hill)
|
||||||
|
return (fhandler_fifo *) fh;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
select_record *
|
select_record *
|
||||||
dtable::select_read (int fd, select_record *s)
|
dtable::select_read (int fd, select_record *s)
|
||||||
{
|
{
|
||||||
@ -753,9 +794,7 @@ handle_to_fn (HANDLE h, char *posix_fn)
|
|||||||
|| !QueryDosDevice (NULL, fnbuf, sizeof (fnbuf)))
|
|| !QueryDosDevice (NULL, fnbuf, sizeof (fnbuf)))
|
||||||
return strcpy (posix_fn, win32_fn);
|
return strcpy (posix_fn, win32_fn);
|
||||||
|
|
||||||
char *p = strchr (win32_fn + DEVICE_PREFIX_LEN, '\\');
|
char *p = strechr (win32_fn + DEVICE_PREFIX_LEN, '\\');
|
||||||
if (!p)
|
|
||||||
p = strchr (win32_fn + DEVICE_PREFIX_LEN, '\0');
|
|
||||||
|
|
||||||
int n = p - win32_fn;
|
int n = p - win32_fn;
|
||||||
int maxmatchlen = 0;
|
int maxmatchlen = 0;
|
||||||
|
@ -14,6 +14,9 @@ details. */
|
|||||||
#include "thread.h"
|
#include "thread.h"
|
||||||
|
|
||||||
class suffix_info;
|
class suffix_info;
|
||||||
|
class fhandler_fifo;
|
||||||
|
|
||||||
|
#define BFH_OPTS (PC_NULLEMPTY | PC_FULL | PC_POSIX)
|
||||||
class dtable
|
class dtable
|
||||||
{
|
{
|
||||||
fhandler_base **fds;
|
fhandler_base **fds;
|
||||||
@ -41,14 +44,6 @@ public:
|
|||||||
void fixup_before_exec (DWORD win_proc_id);
|
void fixup_before_exec (DWORD win_proc_id);
|
||||||
void fixup_before_fork (DWORD win_proc_id);
|
void fixup_before_fork (DWORD win_proc_id);
|
||||||
void fixup_after_fork (HANDLE);
|
void fixup_after_fork (HANDLE);
|
||||||
fhandler_base *build_fhandler (int fd, DWORD dev, const char *unix_name,
|
|
||||||
const char *win32_name = NULL, int unit = -1);
|
|
||||||
fhandler_base *build_fhandler (int fd, DWORD dev, char *unix_name = NULL,
|
|
||||||
const char *win32_name = NULL, int unit = -1);
|
|
||||||
fhandler_base *build_fhandler_from_name (int fd, const char *name, HANDLE h,
|
|
||||||
path_conv& pc,
|
|
||||||
unsigned opts = PC_SYM_FOLLOW,
|
|
||||||
suffix_info *si = NULL);
|
|
||||||
inline int not_open (int fd)
|
inline int not_open (int fd)
|
||||||
{
|
{
|
||||||
SetResourceLock (LOCK_FD_LIST, READ_LOCK, "not_open");
|
SetResourceLock (LOCK_FD_LIST, READ_LOCK, "not_open");
|
||||||
@ -64,7 +59,7 @@ public:
|
|||||||
void init_std_file_from_handle (int fd, HANDLE handle);
|
void init_std_file_from_handle (int fd, HANDLE handle);
|
||||||
int dup2 (int oldfd, int newfd);
|
int dup2 (int oldfd, int newfd);
|
||||||
void fixup_after_exec (HANDLE);
|
void fixup_after_exec (HANDLE);
|
||||||
inline fhandler_base *operator [](int fd) const { return fds[fd]; }
|
inline fhandler_base *&operator [](int fd) const { return fds[fd]; }
|
||||||
select_record *select_read (int fd, select_record *s);
|
select_record *select_read (int fd, select_record *s);
|
||||||
select_record *select_write (int fd, select_record *s);
|
select_record *select_write (int fd, select_record *s);
|
||||||
select_record *select_except (int fd, select_record *s);
|
select_record *select_except (int fd, select_record *s);
|
||||||
@ -73,8 +68,13 @@ public:
|
|||||||
void get_debugger_info ();
|
void get_debugger_info ();
|
||||||
void set_file_pointers_for_exec ();
|
void set_file_pointers_for_exec ();
|
||||||
bool in_vfork_cleanup () {return fds_on_hold == fds;}
|
bool in_vfork_cleanup () {return fds_on_hold == fds;}
|
||||||
|
fhandler_fifo *find_fifo (ATOM);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
fhandler_base *build_fh_dev (const device&, const char * = NULL);
|
||||||
|
fhandler_base *build_fh_name (const char *unix_name, HANDLE = NULL, unsigned = 0, suffix_info * = NULL);
|
||||||
|
fhandler_base *build_fh_pc (path_conv& pc);
|
||||||
|
|
||||||
void dtable_init (void);
|
void dtable_init (void);
|
||||||
void stdio_init (void);
|
void stdio_init (void);
|
||||||
extern dtable fdtab;
|
extern dtable fdtab;
|
||||||
|
@ -17,8 +17,8 @@ details. */
|
|||||||
#include "pinfo.h"
|
#include "pinfo.h"
|
||||||
#include "perprocess.h"
|
#include "perprocess.h"
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include "fhandler.h"
|
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
#include "fhandler.h"
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
|
@ -11,12 +11,14 @@ details. */
|
|||||||
#include "winsup.h"
|
#include "winsup.h"
|
||||||
#include <imagehlp.h>
|
#include <imagehlp.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <setjmp.h>
|
||||||
|
|
||||||
#include "exceptions.h"
|
#include "exceptions.h"
|
||||||
#include "sync.h"
|
#include "sync.h"
|
||||||
#include "sigproc.h"
|
#include "sigproc.h"
|
||||||
#include "pinfo.h"
|
#include "pinfo.h"
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
|
#define NEED_VFORK
|
||||||
#include "perthread.h"
|
#include "perthread.h"
|
||||||
#include "shared_info.h"
|
#include "shared_info.h"
|
||||||
#include "perprocess.h"
|
#include "perprocess.h"
|
||||||
@ -966,25 +968,42 @@ set_process_mask (sigset_t newmask)
|
|||||||
sigproc_printf ("old mask = %x, new mask = %x", myself->getsigmask (), newmask);
|
sigproc_printf ("old mask = %x, new mask = %x", myself->getsigmask (), newmask);
|
||||||
myself->setsigmask (newmask); // Set a new mask
|
myself->setsigmask (newmask); // Set a new mask
|
||||||
mask_sync->release ();
|
mask_sync->release ();
|
||||||
if (!(oldmask & ~newmask))
|
if (oldmask & ~newmask)
|
||||||
|
sig_dispatch_pending ();
|
||||||
|
else
|
||||||
sigproc_printf ("not calling sig_dispatch_pending. sigtid %p current %p",
|
sigproc_printf ("not calling sig_dispatch_pending. sigtid %p current %p",
|
||||||
sigtid, GetCurrentThreadId ());
|
sigtid, GetCurrentThreadId ());
|
||||||
else
|
|
||||||
{
|
|
||||||
extern bool pending_signals;
|
|
||||||
pending_signals = true;
|
|
||||||
sig_dispatch_pending ();
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int __stdcall
|
int __stdcall
|
||||||
sig_handle (int sig)
|
sig_handle (int sig, sigset_t mask)
|
||||||
{
|
{
|
||||||
|
if (sig == SIGCONT)
|
||||||
|
{
|
||||||
|
DWORD stopped = myself->process_state & PID_STOPPED;
|
||||||
|
myself->stopsig = 0;
|
||||||
|
myself->process_state &= ~PID_STOPPED;
|
||||||
|
/* Clear pending stop signals */
|
||||||
|
sig_clear (SIGSTOP);
|
||||||
|
sig_clear (SIGTSTP);
|
||||||
|
sig_clear (SIGTTIN);
|
||||||
|
sig_clear (SIGTTOU);
|
||||||
|
if (stopped)
|
||||||
|
SetEvent (sigCONT);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sig != SIGKILL && sig != SIGSTOP
|
||||||
|
&& (sigismember (&mask, sig) || main_vfork->pid
|
||||||
|
|| ISSTATE (myself, PID_STOPPED)))
|
||||||
|
{
|
||||||
|
sigproc_printf ("signal %d blocked", sig);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
int rc = 1;
|
int rc = 1;
|
||||||
|
|
||||||
sigproc_printf ("signal %d", sig);
|
sigproc_printf ("signal %d processing", sig);
|
||||||
|
|
||||||
struct sigaction thissig = myself->getsig (sig);
|
struct sigaction thissig = myself->getsig (sig);
|
||||||
void *handler = (void *) thissig.sa_handler;
|
void *handler = (void *) thissig.sa_handler;
|
||||||
|
|
||||||
@ -1000,25 +1019,6 @@ sig_handle (int sig)
|
|||||||
if (sig == SIGSTOP)
|
if (sig == SIGSTOP)
|
||||||
goto stop;
|
goto stop;
|
||||||
|
|
||||||
/* FIXME: Should we still do this if SIGCONT has a handler? */
|
|
||||||
if (sig == SIGCONT)
|
|
||||||
{
|
|
||||||
DWORD stopped = myself->process_state & PID_STOPPED;
|
|
||||||
myself->stopsig = 0;
|
|
||||||
myself->process_state &= ~PID_STOPPED;
|
|
||||||
/* Clear pending stop signals */
|
|
||||||
sig_clear (SIGSTOP);
|
|
||||||
sig_clear (SIGTSTP);
|
|
||||||
sig_clear (SIGTTIN);
|
|
||||||
sig_clear (SIGTTOU);
|
|
||||||
if (stopped)
|
|
||||||
SetEvent (sigCONT);
|
|
||||||
/* process pending signals */
|
|
||||||
#if 0 // FIXME?
|
|
||||||
sig_dispatch_pending ();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
char sigmsg[24];
|
char sigmsg[24];
|
||||||
__small_sprintf (sigmsg, "cygwin: signal %d\n", sig);
|
__small_sprintf (sigmsg, "cygwin: signal %d\n", sig);
|
||||||
|
@ -15,8 +15,8 @@ details. */
|
|||||||
#include <process.h>
|
#include <process.h>
|
||||||
#include "perprocess.h"
|
#include "perprocess.h"
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include "fhandler.h"
|
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
#include "fhandler.h"
|
||||||
#include "pinfo.h"
|
#include "pinfo.h"
|
||||||
#include "environ.h"
|
#include "environ.h"
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
|
@ -12,7 +12,6 @@ details. */
|
|||||||
|
|
||||||
#include "winsup.h"
|
#include "winsup.h"
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include "fhandler.h"
|
|
||||||
#include "sigproc.h"
|
#include "sigproc.h"
|
||||||
#include "pinfo.h"
|
#include "pinfo.h"
|
||||||
#include <exceptions.h>
|
#include <exceptions.h>
|
||||||
@ -20,8 +19,8 @@ details. */
|
|||||||
#include "cygwin_version.h"
|
#include "cygwin_version.h"
|
||||||
#include "perprocess.h"
|
#include "perprocess.h"
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "fhandler.h"
|
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
#include "wincap.h"
|
#include "wincap.h"
|
||||||
|
@ -12,8 +12,8 @@ details. */
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include "fhandler.h"
|
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
|
@ -18,8 +18,8 @@ details. */
|
|||||||
#include "perprocess.h"
|
#include "perprocess.h"
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include "cygwin/version.h"
|
#include "cygwin/version.h"
|
||||||
#include "fhandler.h"
|
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
#include "shared_info.h"
|
#include "shared_info.h"
|
||||||
@ -35,11 +35,10 @@ struct __cygwin_perfile *perfile_table;
|
|||||||
DWORD binmode;
|
DWORD binmode;
|
||||||
|
|
||||||
inline fhandler_base&
|
inline fhandler_base&
|
||||||
fhandler_base::operator =(fhandler_base &x)
|
fhandler_base::operator =(fhandler_base& x)
|
||||||
{
|
{
|
||||||
memcpy (this, &x, sizeof *this);
|
memcpy (this, &x, sizeof *this);
|
||||||
unix_path_name = x.unix_path_name ? cstrdup (x.unix_path_name) : NULL;
|
pc.set_normalized_path (x.pc.normalized_path);
|
||||||
win32_path_name = x.win32_path_name ? cstrdup (x.win32_path_name) : NULL;
|
|
||||||
rabuf = NULL;
|
rabuf = NULL;
|
||||||
ralen = 0;
|
ralen = 0;
|
||||||
raixget = 0;
|
raixget = 0;
|
||||||
@ -144,63 +143,13 @@ fhandler_base::get_readahead_into_buffer (char *buf, size_t buflen)
|
|||||||
return copied_chars;
|
return copied_chars;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Record the file name.
|
/* Record the file name. and name hash */
|
||||||
Filenames are used mostly for debugging messages, and it's hoped that
|
void
|
||||||
in cases where the name is really required, the filename wouldn't ever
|
fhandler_base::set_name (path_conv &in_pc)
|
||||||
be too long (e.g. devices or some such).
|
|
||||||
The unix_path_name is also used by virtual fhandlers. */
|
|
||||||
bool
|
|
||||||
fhandler_base::set_name (const char *unix_path, const char *win32_path, int unit)
|
|
||||||
{
|
{
|
||||||
if (unix_path == NULL || !*unix_path)
|
memcpy (&pc, &in_pc, in_pc.size ());
|
||||||
return false;
|
pc.set_normalized_path (in_pc.normalized_path);
|
||||||
|
namehash = hash_path_name (0, get_win32_name ());
|
||||||
if (win32_path)
|
|
||||||
win32_path_name = cstrdup (win32_path);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
const char *fmt = get_native_name ();
|
|
||||||
char *w = (char *) cmalloc (HEAP_STR, strlen (fmt) + 16);
|
|
||||||
if (w)
|
|
||||||
__small_sprintf (w, fmt, unit);
|
|
||||||
win32_path_name = w;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (win32_path_name == NULL)
|
|
||||||
{
|
|
||||||
system_printf ("fatal error. strdup failed");
|
|
||||||
set_errno (ENOMEM);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
assert (unix_path_name == NULL);
|
|
||||||
/* FIXME: This isn't really right. It ignores the first argument if we're
|
|
||||||
building names for a device and just converts the device name from the
|
|
||||||
win32 name since it has theoretically been previously detected by
|
|
||||||
path_conv. Ideally, we should pass in a format string and build the
|
|
||||||
unix_path, too. */
|
|
||||||
if (!is_device () || *win32_path_name != '\\')
|
|
||||||
unix_path_name = unix_path;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
char *p = cstrdup (win32_path_name);
|
|
||||||
unix_path_name = p;
|
|
||||||
if (p)
|
|
||||||
while ((p = strchr (p, '\\')) != NULL)
|
|
||||||
*p++ = '/';
|
|
||||||
if (unix_path)
|
|
||||||
cfree ((void *) unix_path);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (unix_path_name == NULL)
|
|
||||||
{
|
|
||||||
system_printf ("fatal error. strdup failed");
|
|
||||||
free ((void *) win32_path_name);
|
|
||||||
set_errno (ENOMEM);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
namehash = hash_path_name (0, win32_path_name);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Detect if we are sitting at EOF for conditions where Windows
|
/* Detect if we are sitting at EOF for conditions where Windows
|
||||||
@ -308,7 +257,7 @@ fhandler_base::raw_read (void *ptr, size_t& ulen)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
syscall_printf ("ReadFile %s failed, %E", unix_path_name);
|
syscall_printf ("ReadFile %s failed, %E", get_name ());
|
||||||
__seterrno_from_win_error (errcode);
|
__seterrno_from_win_error (errcode);
|
||||||
bytes_read = (size_t) -1;
|
bytes_read = (size_t) -1;
|
||||||
break;
|
break;
|
||||||
@ -324,7 +273,7 @@ fhandler_base::raw_write (const void *ptr, size_t len)
|
|||||||
{
|
{
|
||||||
DWORD bytes_written;
|
DWORD bytes_written;
|
||||||
|
|
||||||
if (!WriteFile (get_handle (), ptr, len, &bytes_written, 0))
|
if (!WriteFile (get_output_handle (), ptr, len, &bytes_written, 0))
|
||||||
{
|
{
|
||||||
if (GetLastError () == ERROR_DISK_FULL && bytes_written > 0)
|
if (GetLastError () == ERROR_DISK_FULL && bytes_written > 0)
|
||||||
return bytes_written;
|
return bytes_written;
|
||||||
@ -367,9 +316,25 @@ fhandler_base::get_default_fmode (int flags)
|
|||||||
return fmode;
|
return fmode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
fhandler_base::device_access_denied (int flags)
|
||||||
|
{
|
||||||
|
int mode = 0;
|
||||||
|
int access_worker (path_conv&, int);
|
||||||
|
|
||||||
|
if (flags & O_RDWR)
|
||||||
|
mode |= R_OK | W_OK;
|
||||||
|
if (flags & (O_WRONLY | O_APPEND))
|
||||||
|
mode |= W_OK;
|
||||||
|
if (!mode)
|
||||||
|
mode |= R_OK;
|
||||||
|
|
||||||
|
return access_worker (pc, mode);
|
||||||
|
}
|
||||||
|
|
||||||
/* Open system call handler function. */
|
/* Open system call handler function. */
|
||||||
int
|
int
|
||||||
fhandler_base::open (path_conv *pc, int flags, mode_t mode)
|
fhandler_base::open (int flags, mode_t mode)
|
||||||
{
|
{
|
||||||
int res = 0;
|
int res = 0;
|
||||||
HANDLE x;
|
HANDLE x;
|
||||||
@ -431,7 +396,7 @@ fhandler_base::open (path_conv *pc, int flags, mode_t mode)
|
|||||||
file_attributes |= FILE_FLAG_OVERLAPPED;
|
file_attributes |= FILE_FLAG_OVERLAPPED;
|
||||||
|
|
||||||
#ifdef HIDDEN_DOT_FILES
|
#ifdef HIDDEN_DOT_FILES
|
||||||
if (flags & O_CREAT && get_device () == FH_DISK)
|
if (flags & O_CREAT && get_device () == FH_FS)
|
||||||
{
|
{
|
||||||
char *c = strrchr (get_win32_name (), '\\');
|
char *c = strrchr (get_win32_name (), '\\');
|
||||||
if ((c && c[1] == '.') || *get_win32_name () == '.')
|
if ((c && c[1] == '.') || *get_win32_name () == '.')
|
||||||
@ -443,7 +408,7 @@ fhandler_base::open (path_conv *pc, int flags, mode_t mode)
|
|||||||
share returns some handle, even if file doesn't exist. This code
|
share returns some handle, even if file doesn't exist. This code
|
||||||
works around this bug. */
|
works around this bug. */
|
||||||
if (get_query_open () && isremote () &&
|
if (get_query_open () && isremote () &&
|
||||||
creation_distribution == OPEN_EXISTING && pc && !pc->exists ())
|
creation_distribution == OPEN_EXISTING && !pc.exists ())
|
||||||
{
|
{
|
||||||
set_errno (ENOENT);
|
set_errno (ENOENT);
|
||||||
goto done;
|
goto done;
|
||||||
@ -455,7 +420,7 @@ fhandler_base::open (path_conv *pc, int flags, mode_t mode)
|
|||||||
|
|
||||||
/* If the file should actually be created and ntsec is on,
|
/* If the file should actually be created and ntsec is on,
|
||||||
set files attributes. */
|
set files attributes. */
|
||||||
if (flags & O_CREAT && get_device () == FH_DISK && allow_ntsec && has_acls ())
|
if (flags & O_CREAT && get_device () == FH_FS && allow_ntsec && has_acls ())
|
||||||
set_security_attribute (mode, &sa, alloca (4096), 4096);
|
set_security_attribute (mode, &sa, alloca (4096), 4096);
|
||||||
|
|
||||||
x = CreateFile (get_win32_name (), access, shared, &sa, creation_distribution,
|
x = CreateFile (get_win32_name (), access, shared, &sa, creation_distribution,
|
||||||
@ -463,15 +428,15 @@ fhandler_base::open (path_conv *pc, int flags, mode_t mode)
|
|||||||
|
|
||||||
if (x == INVALID_HANDLE_VALUE)
|
if (x == INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
if (!wincap.can_open_directories () && pc && pc->isdir ())
|
if (!wincap.can_open_directories () && pc.isdir ())
|
||||||
{
|
{
|
||||||
if (flags & (O_CREAT | O_EXCL) == (O_CREAT | O_EXCL))
|
if (flags & (O_CREAT | O_EXCL) == (O_CREAT | O_EXCL))
|
||||||
set_errno (EEXIST);
|
set_errno (EEXIST);
|
||||||
else if (flags & (O_WRONLY | O_RDWR))
|
else if (flags & (O_WRONLY | O_RDWR))
|
||||||
set_errno (EISDIR);
|
set_errno (EISDIR);
|
||||||
else
|
else
|
||||||
set_nohandle (true);
|
set_nohandle (true);
|
||||||
}
|
}
|
||||||
else if (GetLastError () == ERROR_INVALID_HANDLE)
|
else if (GetLastError () == ERROR_INVALID_HANDLE)
|
||||||
set_errno (ENOENT);
|
set_errno (ENOENT);
|
||||||
else
|
else
|
||||||
@ -485,7 +450,7 @@ fhandler_base::open (path_conv *pc, int flags, mode_t mode)
|
|||||||
creation_distribution, file_attributes);
|
creation_distribution, file_attributes);
|
||||||
|
|
||||||
set_io_handle (x);
|
set_io_handle (x);
|
||||||
set_flags (flags, pc ? pc->binmode () : 0);
|
set_flags (flags, pc.binmode ());
|
||||||
|
|
||||||
res = 1;
|
res = 1;
|
||||||
set_open_status ();
|
set_open_status ();
|
||||||
@ -994,9 +959,13 @@ rootdir (char *full_path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int __stdcall
|
int __stdcall
|
||||||
fhandler_base::fstat (struct __stat64 *buf, path_conv *)
|
fhandler_base::fstat (struct __stat64 *buf)
|
||||||
{
|
{
|
||||||
debug_printf ("here");
|
debug_printf ("here");
|
||||||
|
|
||||||
|
if (is_fs_special ())
|
||||||
|
return fstat_fs (buf);
|
||||||
|
|
||||||
switch (get_device ())
|
switch (get_device ())
|
||||||
{
|
{
|
||||||
case FH_PIPE:
|
case FH_PIPE:
|
||||||
@ -1186,8 +1155,8 @@ fhandler_base::operator delete (void *p)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Normal I/O constructor */
|
/* Normal I/O constructor */
|
||||||
fhandler_base::fhandler_base (DWORD devtype, int unit):
|
fhandler_base::fhandler_base ():
|
||||||
status (devtype),
|
status (0),
|
||||||
access (0),
|
access (0),
|
||||||
io_handle (NULL),
|
io_handle (NULL),
|
||||||
namehash (0),
|
namehash (0),
|
||||||
@ -1197,8 +1166,6 @@ fhandler_base::fhandler_base (DWORD devtype, int unit):
|
|||||||
raixget (0),
|
raixget (0),
|
||||||
raixput (0),
|
raixput (0),
|
||||||
rabuflen (0),
|
rabuflen (0),
|
||||||
unix_path_name (NULL),
|
|
||||||
win32_path_name (NULL),
|
|
||||||
open_status (0),
|
open_status (0),
|
||||||
fs_flags (0),
|
fs_flags (0),
|
||||||
read_state (NULL)
|
read_state (NULL)
|
||||||
@ -1208,20 +1175,17 @@ fhandler_base::fhandler_base (DWORD devtype, int unit):
|
|||||||
/* Normal I/O destructor */
|
/* Normal I/O destructor */
|
||||||
fhandler_base::~fhandler_base (void)
|
fhandler_base::~fhandler_base (void)
|
||||||
{
|
{
|
||||||
if (unix_path_name != NULL)
|
if (!pc.normalized_path_size && pc.normalized_path)
|
||||||
cfree ((void *) unix_path_name);
|
cfree (pc.normalized_path);
|
||||||
if (win32_path_name != NULL)
|
|
||||||
cfree ((void *) win32_path_name);
|
|
||||||
if (rabuf)
|
if (rabuf)
|
||||||
free (rabuf);
|
free (rabuf);
|
||||||
unix_path_name = win32_path_name = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
/* /dev/null */
|
/* /dev/null */
|
||||||
|
|
||||||
fhandler_dev_null::fhandler_dev_null () :
|
fhandler_dev_null::fhandler_dev_null () :
|
||||||
fhandler_base (FH_NULL)
|
fhandler_base ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1299,7 +1263,7 @@ fhandler_base::set_nonblocking (int yes)
|
|||||||
}
|
}
|
||||||
|
|
||||||
DIR *
|
DIR *
|
||||||
fhandler_base::opendir (path_conv&)
|
fhandler_base::opendir ()
|
||||||
{
|
{
|
||||||
set_errno (ENOTDIR);
|
set_errno (ENOTDIR);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -11,9 +11,6 @@ details. */
|
|||||||
#ifndef _FHANDLER_H_
|
#ifndef _FHANDLER_H_
|
||||||
#define _FHANDLER_H_
|
#define _FHANDLER_H_
|
||||||
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
FH_RBINARY = 0x00001000, /* binary read mode */
|
FH_RBINARY = 0x00001000, /* binary read mode */
|
||||||
@ -42,45 +39,9 @@ enum
|
|||||||
FH_HASACLS = 0x40000000, /* True if fs of file has ACLS */
|
FH_HASACLS = 0x40000000, /* True if fs of file has ACLS */
|
||||||
FH_QUERYOPEN = 0x80000000, /* open file without requesting either read
|
FH_QUERYOPEN = 0x80000000, /* open file without requesting either read
|
||||||
or write access */
|
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 FHISSETF(x) __ISSETF (this, x, FH)
|
||||||
#define FHSETF(x) __SETF (this, x, FH)
|
#define FHSETF(x) __SETF (this, x, FH)
|
||||||
#define FHCLEARF(x) __CLEARF (this, x, FH)
|
#define FHCLEARF(x) __CLEARF (this, x, FH)
|
||||||
@ -112,7 +73,6 @@ extern const char proc[];
|
|||||||
extern const int proc_len;
|
extern const int proc_len;
|
||||||
|
|
||||||
class select_record;
|
class select_record;
|
||||||
class path_conv;
|
|
||||||
class fhandler_disk_file;
|
class fhandler_disk_file;
|
||||||
typedef struct __DIR DIR;
|
typedef struct __DIR DIR;
|
||||||
struct dirent;
|
struct dirent;
|
||||||
@ -135,16 +95,9 @@ enum bg_check_types
|
|||||||
bg_signalled = 2
|
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
|
class fhandler_base
|
||||||
{
|
{
|
||||||
|
friend class dtable;
|
||||||
protected:
|
protected:
|
||||||
DWORD status;
|
DWORD status;
|
||||||
private:
|
private:
|
||||||
@ -164,27 +117,32 @@ class fhandler_base
|
|||||||
size_t raixput;
|
size_t raixput;
|
||||||
size_t rabuflen;
|
size_t rabuflen;
|
||||||
|
|
||||||
const char *unix_path_name;
|
|
||||||
const char *win32_path_name;
|
|
||||||
DWORD open_status;
|
DWORD open_status;
|
||||||
DWORD fs_flags;
|
DWORD fs_flags;
|
||||||
HANDLE read_state;
|
HANDLE read_state;
|
||||||
|
path_conv pc;
|
||||||
|
|
||||||
public:
|
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);
|
virtual fhandler_base& operator =(fhandler_base &x);
|
||||||
fhandler_base (DWORD dev, int unit = 0);
|
fhandler_base ();
|
||||||
virtual ~fhandler_base ();
|
virtual ~fhandler_base ();
|
||||||
|
|
||||||
/* Non-virtual simple accessor functions. */
|
/* Non-virtual simple accessor functions. */
|
||||||
void set_io_handle (HANDLE x) { io_handle = x; }
|
void set_io_handle (HANDLE x) { io_handle = x; }
|
||||||
|
|
||||||
DWORD get_device () { return status & FH_DEVMASK; }
|
DWORD get_device () { return dev ().devn; }
|
||||||
virtual int get_unit () { return 0; }
|
DWORD get_major () { return dev ().major; }
|
||||||
virtual BOOL is_slow () { return get_device () < FH_SLOW; }
|
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; }
|
void set_access (int x) { access = x; }
|
||||||
|
|
||||||
bool get_async () { return FHISSETF (ASYNC); }
|
bool get_async () { return FHISSETF (ASYNC); }
|
||||||
@ -298,8 +256,8 @@ class fhandler_base
|
|||||||
bool isremote () { return FHISSETF (ISREMOTE); }
|
bool isremote () { return FHISSETF (ISREMOTE); }
|
||||||
void set_isremote (int val) { FHCONDSETF (val, ISREMOTE); }
|
void set_isremote (int val) { FHCONDSETF (val, ISREMOTE); }
|
||||||
|
|
||||||
const char *get_name () { return unix_path_name; }
|
const char *get_name () const { return pc.normalized_path; }
|
||||||
const char *get_win32_name () { return win32_path_name; }
|
const char *get_win32_name () { return pc.get_win32 (); }
|
||||||
__ino64_t get_namehash () { return namehash; }
|
__ino64_t get_namehash () { return namehash; }
|
||||||
|
|
||||||
virtual void hclose (HANDLE h) {CloseHandle (h);}
|
virtual void hclose (HANDLE h) {CloseHandle (h);}
|
||||||
@ -307,13 +265,29 @@ class fhandler_base
|
|||||||
|
|
||||||
/* fixup fd possibly non-inherited handles after fork */
|
/* fixup fd possibly non-inherited handles after fork */
|
||||||
void fork_fixup (HANDLE parent, HANDLE &h, const char *name);
|
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 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 ioctl (unsigned int cmd, void *);
|
||||||
virtual int fcntl (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 void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3)));
|
||||||
virtual int write (const void *ptr, size_t len);
|
virtual int write (const void *ptr, size_t len);
|
||||||
virtual ssize_t readv (const struct iovec *, int iovcnt, ssize_t tot = -1);
|
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 tcsetpgrp (const pid_t pid);
|
||||||
virtual int tcgetpgrp ();
|
virtual int tcgetpgrp ();
|
||||||
virtual int is_tty () { return 0; }
|
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 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 class fhandler_console *is_console () { return 0; }
|
||||||
virtual int is_windows () {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_write (select_record *s);
|
||||||
virtual select_record *select_except (select_record *s);
|
virtual select_record *select_except (select_record *s);
|
||||||
virtual int ready_for_read (int fd, DWORD howlong);
|
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;}
|
virtual bg_check_types bg_check (int) {return bg_ok;}
|
||||||
void clear_readahead ()
|
void clear_readahead ()
|
||||||
@ -375,12 +350,16 @@ class fhandler_base
|
|||||||
void operator delete (void *);
|
void operator delete (void *);
|
||||||
virtual HANDLE get_guard () const {return NULL;}
|
virtual HANDLE get_guard () const {return NULL;}
|
||||||
virtual void set_eof () {}
|
virtual void set_eof () {}
|
||||||
virtual DIR *opendir (path_conv& pc);
|
virtual DIR *opendir ();
|
||||||
virtual dirent *readdir (DIR *);
|
virtual dirent *readdir (DIR *);
|
||||||
virtual _off64_t telldir (DIR *);
|
virtual _off64_t telldir (DIR *);
|
||||||
virtual void seekdir (DIR *, _off64_t);
|
virtual void seekdir (DIR *, _off64_t);
|
||||||
virtual void rewinddir (DIR *);
|
virtual void rewinddir (DIR *);
|
||||||
virtual int closedir (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
|
class fhandler_socket: public fhandler_base
|
||||||
@ -393,14 +372,12 @@ class fhandler_socket: public fhandler_base
|
|||||||
struct _WSAPROTOCOL_INFOA *prot_info_ptr;
|
struct _WSAPROTOCOL_INFOA *prot_info_ptr;
|
||||||
char *sun_path;
|
char *sun_path;
|
||||||
int had_connect_or_listen;
|
int had_connect_or_listen;
|
||||||
int unit;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
fhandler_socket (int unit);
|
fhandler_socket ();
|
||||||
~fhandler_socket ();
|
~fhandler_socket ();
|
||||||
int get_socket () { return (int) get_handle(); }
|
int get_socket () { return (int) get_handle(); }
|
||||||
fhandler_socket * is_socket () { return this; }
|
fhandler_socket *is_socket () { return this; }
|
||||||
int get_unit () { return unit; }
|
|
||||||
|
|
||||||
bool saw_shutdown_read () const {return FHISSETF (SHUTRD);}
|
bool saw_shutdown_read () const {return FHISSETF (SHUTRD);}
|
||||||
bool saw_shutdown_write () const {return FHISSETF (SHUTWR);}
|
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);
|
virtual void fixup_before_fork_exec (DWORD);
|
||||||
void fixup_after_fork (HANDLE);
|
void fixup_after_fork (HANDLE);
|
||||||
void fixup_after_exec (HANDLE);
|
void fixup_after_exec (HANDLE);
|
||||||
|
bool need_fixup_before () const {return true;}
|
||||||
|
|
||||||
select_record *select_read (select_record *s);
|
select_record *select_read (select_record *s);
|
||||||
select_record *select_write (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);
|
int check_peer_secret_event (struct sockaddr_in *peer, int *secret = NULL);
|
||||||
void signal_secret_event ();
|
void signal_secret_event ();
|
||||||
void close_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
|
class fhandler_pipe: public fhandler_base
|
||||||
{
|
{
|
||||||
|
protected:
|
||||||
HANDLE guard;
|
HANDLE guard;
|
||||||
bool broken_pipe;
|
bool broken_pipe;
|
||||||
HANDLE writepipe_exists;
|
HANDLE writepipe_exists;
|
||||||
DWORD orig_pid;
|
DWORD orig_pid;
|
||||||
unsigned id;
|
unsigned id;
|
||||||
public:
|
public:
|
||||||
fhandler_pipe (DWORD devtype);
|
fhandler_pipe ();
|
||||||
_off64_t lseek (_off64_t offset, int whence);
|
_off64_t lseek (_off64_t offset, int whence);
|
||||||
select_record *select_read (select_record *s);
|
select_record *select_read (select_record *s);
|
||||||
select_record *select_write (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);
|
void fixup_after_exec (HANDLE);
|
||||||
bool hit_eof ();
|
bool hit_eof ();
|
||||||
void set_eof () {broken_pipe = true;}
|
void set_eof () {broken_pipe = true;}
|
||||||
friend int make_pipe (int fildes[2], unsigned int psize, int mode);
|
|
||||||
HANDLE get_guard () const {return guard;}
|
HANDLE get_guard () const {return guard;}
|
||||||
int ready_for_read (int fd, DWORD howlong);
|
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
|
class fhandler_dev_raw: public fhandler_base
|
||||||
@ -503,7 +507,6 @@ class fhandler_dev_raw: public fhandler_base
|
|||||||
int is_writing : 1;
|
int is_writing : 1;
|
||||||
int has_written : 1;
|
int has_written : 1;
|
||||||
int varblkop : 1;
|
int varblkop : 1;
|
||||||
int unit;
|
|
||||||
|
|
||||||
virtual void clear (void);
|
virtual void clear (void);
|
||||||
virtual int writebuf (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 */
|
/* returns not null, if `win_error' determines an end of file condition */
|
||||||
virtual int is_eof(int win_error) = 0;
|
virtual int is_eof(int win_error) = 0;
|
||||||
|
|
||||||
fhandler_dev_raw (DWORD dev, int unit);
|
fhandler_dev_raw ();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~fhandler_dev_raw (void);
|
~fhandler_dev_raw (void);
|
||||||
|
|
||||||
int get_unit () { return unit; }
|
int open (int flags, mode_t mode = 0);
|
||||||
|
|
||||||
int open (path_conv *, int flags, mode_t mode = 0);
|
|
||||||
int close (void);
|
int close (void);
|
||||||
|
|
||||||
void raw_read (void *ptr, size_t& ulen);
|
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);
|
virtual int is_eof (int win_error);
|
||||||
|
|
||||||
public:
|
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 int close (void);
|
||||||
|
|
||||||
virtual _off64_t lseek (_off64_t offset, int whence);
|
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);
|
virtual int is_eof (int win_error);
|
||||||
|
|
||||||
public:
|
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 int close (void);
|
||||||
|
|
||||||
virtual _off64_t lseek (_off64_t offset, int whence);
|
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);
|
virtual int dup (fhandler_base *child);
|
||||||
|
|
||||||
@ -596,32 +597,19 @@ class fhandler_disk_file: public fhandler_base
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
fhandler_disk_file ();
|
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 close ();
|
||||||
int lock (int, struct flock *);
|
int lock (int, struct flock *);
|
||||||
BOOL is_device () { return FALSE; }
|
bool isdevice () { return false; }
|
||||||
int __stdcall fstat (struct __stat64 *buf, path_conv *pc) __attribute__ ((regparm (3)));
|
int __stdcall fstat (struct __stat64 *buf) __attribute__ ((regparm (2)));
|
||||||
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)));
|
|
||||||
|
|
||||||
HANDLE mmap (caddr_t *addr, size_t len, DWORD access, int flags, _off64_t off);
|
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 munmap (HANDLE h, caddr_t addr, size_t len);
|
||||||
int msync (HANDLE h, caddr_t addr, size_t len, int flags);
|
int msync (HANDLE h, caddr_t addr, size_t len, int flags);
|
||||||
BOOL fixup_mmap_after_fork (HANDLE h, DWORD access, DWORD offset,
|
BOOL fixup_mmap_after_fork (HANDLE h, DWORD access, DWORD offset,
|
||||||
DWORD size, void *address);
|
DWORD size, void *address);
|
||||||
DIR *opendir (path_conv& pc);
|
DIR *opendir ();
|
||||||
struct dirent *readdir (DIR *);
|
struct dirent *readdir (DIR *);
|
||||||
_off64_t telldir (DIR *);
|
_off64_t telldir (DIR *);
|
||||||
void seekdir (DIR *, _off64_t);
|
void seekdir (DIR *, _off64_t);
|
||||||
@ -631,20 +619,19 @@ class fhandler_disk_file: public fhandler_base
|
|||||||
|
|
||||||
class fhandler_cygdrive: public fhandler_disk_file
|
class fhandler_cygdrive: public fhandler_disk_file
|
||||||
{
|
{
|
||||||
int unit;
|
|
||||||
int ndrives;
|
int ndrives;
|
||||||
const char *pdrive;
|
const char *pdrive;
|
||||||
void set_drives ();
|
void set_drives ();
|
||||||
public:
|
public:
|
||||||
bool iscygdrive_root () const { return !unit; }
|
bool iscygdrive_root () { return !dev ().minor; }
|
||||||
fhandler_cygdrive (int unit);
|
fhandler_cygdrive ();
|
||||||
DIR *opendir (path_conv& pc);
|
DIR *opendir ();
|
||||||
struct dirent *readdir (DIR *);
|
struct dirent *readdir (DIR *);
|
||||||
_off64_t telldir (DIR *);
|
_off64_t telldir (DIR *);
|
||||||
void seekdir (DIR *, _off64_t);
|
void seekdir (DIR *, _off64_t);
|
||||||
void rewinddir (DIR *);
|
void rewinddir (DIR *);
|
||||||
int closedir (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
|
class fhandler_serial: public fhandler_base
|
||||||
@ -662,9 +649,9 @@ class fhandler_serial: public fhandler_base
|
|||||||
DWORD ev;
|
DWORD ev;
|
||||||
|
|
||||||
/* Constructor */
|
/* 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 ();
|
int close ();
|
||||||
void init (HANDLE h, DWORD a, mode_t flags);
|
void init (HANDLE h, DWORD a, mode_t flags);
|
||||||
void overlapped_setup ();
|
void overlapped_setup ();
|
||||||
@ -692,6 +679,7 @@ class fhandler_serial: public fhandler_base
|
|||||||
select_record *select_read (select_record *s);
|
select_record *select_read (select_record *s);
|
||||||
select_record *select_write (select_record *s);
|
select_record *select_write (select_record *s);
|
||||||
select_record *select_except (select_record *s);
|
select_record *select_except (select_record *s);
|
||||||
|
bool is_slow () {return 1;}
|
||||||
};
|
};
|
||||||
|
|
||||||
#define acquire_output_mutex(ms) \
|
#define acquire_output_mutex(ms) \
|
||||||
@ -710,8 +698,8 @@ class fhandler_termios: public fhandler_base
|
|||||||
virtual int accept_input () {return 1;};
|
virtual int accept_input () {return 1;};
|
||||||
public:
|
public:
|
||||||
tty_min *tc;
|
tty_min *tc;
|
||||||
fhandler_termios (DWORD dev, int unit = 0) :
|
fhandler_termios () :
|
||||||
fhandler_base (dev, unit)
|
fhandler_base ()
|
||||||
{
|
{
|
||||||
set_need_fork_fixup ();
|
set_need_fork_fixup ();
|
||||||
}
|
}
|
||||||
@ -817,7 +805,7 @@ class fhandler_console: public fhandler_termios
|
|||||||
void cursor_set (BOOL, int, int);
|
void cursor_set (BOOL, int, int);
|
||||||
void cursor_get (int *, int *);
|
void cursor_get (int *, int *);
|
||||||
void cursor_rel (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);
|
void char_command (char);
|
||||||
BOOL set_raw_win32_keyboard_mode (BOOL);
|
BOOL set_raw_win32_keyboard_mode (BOOL);
|
||||||
int output_tcsetattr (int a, const struct termios *t);
|
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; }
|
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);
|
int write (const void *ptr, size_t len);
|
||||||
void doecho (const void *str, DWORD len) { (void) write (str, 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 set_input_state ();
|
||||||
void send_winch_maybe ();
|
void send_winch_maybe ();
|
||||||
static tty_min *get_tty_stuff (int);
|
static tty_min *get_tty_stuff (int);
|
||||||
|
bool is_slow () {return 1;}
|
||||||
};
|
};
|
||||||
|
|
||||||
class fhandler_tty_common: public fhandler_termios
|
class fhandler_tty_common: public fhandler_termios
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
fhandler_tty_common (DWORD dev, int unit = 0)
|
fhandler_tty_common ()
|
||||||
: fhandler_termios (dev, unit), output_done_event (NULL),
|
: fhandler_termios (), output_done_event (NULL),
|
||||||
ioctl_request_event (NULL), ioctl_done_event (NULL), output_mutex (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
|
// nothing to do
|
||||||
}
|
}
|
||||||
@ -882,7 +871,6 @@ class fhandler_tty_common: public fhandler_termios
|
|||||||
HANDLE output_mutex, input_mutex;
|
HANDLE output_mutex, input_mutex;
|
||||||
HANDLE input_available_event;
|
HANDLE input_available_event;
|
||||||
HANDLE inuse; // used to indicate that a tty is in use
|
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);
|
DWORD __acquire_output_mutex (const char *fn, int ln, DWORD ms);
|
||||||
void __release_output_mutex (const char *fn, int ln);
|
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);
|
virtual int dup (fhandler_base *child);
|
||||||
|
|
||||||
tty *get_ttyp () { return (tty *)tc; }
|
tty *get_ttyp () { return (tty *)tc; }
|
||||||
int get_unit () { return ttynum; }
|
|
||||||
|
|
||||||
int close ();
|
int close ();
|
||||||
void set_close_on_exec (int val);
|
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_read (select_record *s);
|
||||||
select_record *select_write (select_record *s);
|
select_record *select_write (select_record *s);
|
||||||
select_record *select_except (select_record *s);
|
select_record *select_except (select_record *s);
|
||||||
|
bool is_slow () {return 1;}
|
||||||
};
|
};
|
||||||
|
|
||||||
class fhandler_tty_slave: public fhandler_tty_common
|
class fhandler_tty_slave: public fhandler_tty_common
|
||||||
@ -905,9 +893,8 @@ class fhandler_tty_slave: public fhandler_tty_common
|
|||||||
public:
|
public:
|
||||||
/* Constructor */
|
/* Constructor */
|
||||||
fhandler_tty_slave ();
|
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);
|
int write (const void *ptr, size_t len);
|
||||||
void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3)));
|
void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3)));
|
||||||
void init (HANDLE, DWORD, mode_t);
|
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; }
|
_off64_t lseek (_off64_t, int) { return 0; }
|
||||||
select_record *select_read (select_record *s);
|
select_record *select_read (select_record *s);
|
||||||
int cygserver_attach_tty (HANDLE*, HANDLE*);
|
int cygserver_attach_tty (HANDLE*, HANDLE*);
|
||||||
|
int get_unit () __attribute__ ((regparm (1)));
|
||||||
};
|
};
|
||||||
|
|
||||||
class fhandler_pty_master: public fhandler_tty_common
|
class fhandler_pty_master: public fhandler_tty_common
|
||||||
{
|
{
|
||||||
int pktmode; // non-zero if pty in a packet mode.
|
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
|
int need_nl; // Next read should start with \n
|
||||||
|
|
||||||
/* Constructor */
|
/* 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);
|
int process_slave_output (char *buf, size_t len, int pktmode_on);
|
||||||
void doecho (const void *str, DWORD len);
|
void doecho (const void *str, DWORD len);
|
||||||
int accept_input ();
|
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);
|
int write (const void *ptr, size_t len);
|
||||||
void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3)));
|
void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3)));
|
||||||
int close ();
|
int close ();
|
||||||
@ -952,6 +942,7 @@ class fhandler_pty_master: public fhandler_tty_common
|
|||||||
|
|
||||||
void set_close_on_exec (int val);
|
void set_close_on_exec (int val);
|
||||||
bool hit_eof ();
|
bool hit_eof ();
|
||||||
|
int get_unit () const { return slave.minor; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class fhandler_tty_master: public fhandler_pty_master
|
class fhandler_tty_master: public fhandler_pty_master
|
||||||
@ -960,12 +951,13 @@ class fhandler_tty_master: public fhandler_pty_master
|
|||||||
/* Constructor */
|
/* Constructor */
|
||||||
fhandler_console *console; // device handler to perform real i/o.
|
fhandler_console *console; // device handler to perform real i/o.
|
||||||
|
|
||||||
fhandler_tty_master (int unit);
|
fhandler_tty_master ();
|
||||||
int init (int);
|
int init ();
|
||||||
int init_console ();
|
int init_console ();
|
||||||
void set_winsize (bool);
|
void set_winsize (bool);
|
||||||
void fixup_after_fork (HANDLE parent);
|
void fixup_after_fork (HANDLE parent);
|
||||||
void fixup_after_exec (HANDLE);
|
void fixup_after_exec (HANDLE);
|
||||||
|
bool is_slow () {return 1;}
|
||||||
};
|
};
|
||||||
|
|
||||||
class fhandler_dev_null: public fhandler_base
|
class fhandler_dev_null: public fhandler_base
|
||||||
@ -983,7 +975,7 @@ class fhandler_dev_zero: public fhandler_base
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
fhandler_dev_zero ();
|
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);
|
int write (const void *ptr, size_t len);
|
||||||
void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3)));
|
void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3)));
|
||||||
_off64_t lseek (_off64_t offset, int whence);
|
_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
|
class fhandler_dev_random: public fhandler_base
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
int unit;
|
|
||||||
HCRYPTPROV crypt_prov;
|
HCRYPTPROV crypt_prov;
|
||||||
long pseudo;
|
long pseudo;
|
||||||
|
|
||||||
@ -1003,9 +994,8 @@ class fhandler_dev_random: public fhandler_base
|
|||||||
int pseudo_read (void *ptr, size_t len);
|
int pseudo_read (void *ptr, size_t len);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
fhandler_dev_random (int unit);
|
fhandler_dev_random ();
|
||||||
int get_unit () { return unit; }
|
int open (int flags, mode_t mode = 0);
|
||||||
int open (path_conv *, int flags, mode_t mode = 0);
|
|
||||||
int write (const void *ptr, size_t len);
|
int write (const void *ptr, size_t len);
|
||||||
void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3)));
|
void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3)));
|
||||||
_off64_t lseek (_off64_t offset, int whence);
|
_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
|
class fhandler_dev_mem: public fhandler_base
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
int unit;
|
|
||||||
DWORD mem_size;
|
DWORD mem_size;
|
||||||
_off64_t pos;
|
_off64_t pos;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
fhandler_dev_mem (int unit);
|
fhandler_dev_mem ();
|
||||||
~fhandler_dev_mem (void);
|
~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);
|
int write (const void *ptr, size_t ulen);
|
||||||
void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3)));
|
void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3)));
|
||||||
_off64_t lseek (_off64_t offset, int whence);
|
_off64_t lseek (_off64_t offset, int whence);
|
||||||
int close (void);
|
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);
|
int dup (fhandler_base *child);
|
||||||
|
|
||||||
HANDLE mmap (caddr_t *addr, size_t len, DWORD access, int flags, _off64_t off);
|
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:
|
public:
|
||||||
fhandler_dev_clipboard ();
|
fhandler_dev_clipboard ();
|
||||||
int is_windows (void) { return 1; }
|
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);
|
int write (const void *ptr, size_t len);
|
||||||
void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3)));
|
void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3)));
|
||||||
_off64_t lseek (_off64_t offset, int whence);
|
_off64_t lseek (_off64_t offset, int whence);
|
||||||
@ -1073,7 +1062,7 @@ class fhandler_windows: public fhandler_base
|
|||||||
public:
|
public:
|
||||||
fhandler_windows ();
|
fhandler_windows ();
|
||||||
int is_windows (void) { return 1; }
|
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);
|
int write (const void *ptr, size_t len);
|
||||||
void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3)));
|
void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3)));
|
||||||
int ioctl (unsigned int cmd, void *);
|
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_read (select_record *s);
|
||||||
select_record *select_write (select_record *s);
|
select_record *select_write (select_record *s);
|
||||||
select_record *select_except (select_record *s);
|
select_record *select_except (select_record *s);
|
||||||
|
bool is_slow () {return 1;}
|
||||||
};
|
};
|
||||||
|
|
||||||
class fhandler_dev_dsp : public fhandler_base
|
class fhandler_dev_dsp : public fhandler_base
|
||||||
@ -1099,13 +1089,13 @@ class fhandler_dev_dsp : public fhandler_base
|
|||||||
fhandler_dev_dsp ();
|
fhandler_dev_dsp ();
|
||||||
~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);
|
int write (const void *ptr, size_t len);
|
||||||
void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3)));
|
void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3)));
|
||||||
int ioctl (unsigned int cmd, void *);
|
int ioctl (unsigned int cmd, void *);
|
||||||
_off64_t lseek (_off64_t, int);
|
_off64_t lseek (_off64_t, int);
|
||||||
int close (void);
|
int close (void);
|
||||||
int dup (fhandler_base * child);
|
int dup (fhandler_base *child);
|
||||||
void dump (void);
|
void dump (void);
|
||||||
void fixup_after_exec (HANDLE);
|
void fixup_after_exec (HANDLE);
|
||||||
};
|
};
|
||||||
@ -1120,11 +1110,11 @@ class fhandler_virtual : public fhandler_base
|
|||||||
int fileid; // unique within each class
|
int fileid; // unique within each class
|
||||||
public:
|
public:
|
||||||
|
|
||||||
fhandler_virtual (DWORD devtype);
|
fhandler_virtual ();
|
||||||
virtual ~fhandler_virtual();
|
virtual ~fhandler_virtual();
|
||||||
|
|
||||||
virtual int exists();
|
virtual int exists();
|
||||||
DIR *opendir (path_conv& pc);
|
DIR *opendir ();
|
||||||
_off64_t telldir (DIR *);
|
_off64_t telldir (DIR *);
|
||||||
void seekdir (DIR *, _off64_t);
|
void seekdir (DIR *, _off64_t);
|
||||||
void rewinddir (DIR *);
|
void rewinddir (DIR *);
|
||||||
@ -1132,9 +1122,10 @@ class fhandler_virtual : public fhandler_base
|
|||||||
int write (const void *ptr, size_t len);
|
int write (const void *ptr, size_t len);
|
||||||
void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3)));
|
void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3)));
|
||||||
_off64_t lseek (_off64_t, int);
|
_off64_t lseek (_off64_t, int);
|
||||||
int dup (fhandler_base * child);
|
int dup (fhandler_base *child);
|
||||||
int open (path_conv *, int flags, mode_t mode = 0);
|
int open (int flags, mode_t mode = 0);
|
||||||
int close (void);
|
int close (void);
|
||||||
|
int __stdcall fstat (struct stat *buf) __attribute__ ((regparm (2)));
|
||||||
virtual bool fill_filebuf ();
|
virtual bool fill_filebuf ();
|
||||||
void fixup_after_exec (HANDLE);
|
void fixup_after_exec (HANDLE);
|
||||||
};
|
};
|
||||||
@ -1143,13 +1134,12 @@ class fhandler_proc: public fhandler_virtual
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
fhandler_proc ();
|
fhandler_proc ();
|
||||||
fhandler_proc (DWORD devtype);
|
|
||||||
int exists();
|
int exists();
|
||||||
struct dirent *readdir (DIR *);
|
struct dirent *readdir (DIR *);
|
||||||
static DWORD get_proc_fhandler(const char *path);
|
static DWORD get_proc_fhandler(const char *path);
|
||||||
|
|
||||||
int open (path_conv *real_path, int flags, mode_t mode = 0);
|
int open (int flags, mode_t mode = 0);
|
||||||
int __stdcall fstat (struct __stat64 *buf, path_conv *) __attribute__ ((regparm (3)));
|
int __stdcall fstat (struct __stat64 *buf) __attribute__ ((regparm (2)));
|
||||||
bool fill_filebuf ();
|
bool fill_filebuf ();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1166,8 +1156,8 @@ class fhandler_registry: public fhandler_proc
|
|||||||
void rewinddir (DIR *);
|
void rewinddir (DIR *);
|
||||||
int closedir (DIR *);
|
int closedir (DIR *);
|
||||||
|
|
||||||
int open (path_conv *real_path, int flags, mode_t mode = 0);
|
int open (int flags, mode_t mode = 0);
|
||||||
int __stdcall fstat (struct __stat64 *buf, path_conv *) __attribute__ ((regparm (3)));
|
int __stdcall fstat (struct __stat64 *buf) __attribute__ ((regparm (2)));
|
||||||
bool fill_filebuf ();
|
bool fill_filebuf ();
|
||||||
int close (void);
|
int close (void);
|
||||||
};
|
};
|
||||||
@ -1180,11 +1170,18 @@ class fhandler_process: public fhandler_proc
|
|||||||
fhandler_process ();
|
fhandler_process ();
|
||||||
int exists();
|
int exists();
|
||||||
struct dirent *readdir (DIR *);
|
struct dirent *readdir (DIR *);
|
||||||
int open (path_conv *real_path, int flags, mode_t mode = 0);
|
int open (int flags, mode_t mode = 0);
|
||||||
int __stdcall fstat (struct __stat64 *buf, path_conv *) __attribute__ ((regparm (3)));
|
int __stdcall fstat (struct __stat64 *buf) __attribute__ ((regparm (2)));
|
||||||
bool fill_filebuf ();
|
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
|
typedef union
|
||||||
{
|
{
|
||||||
char __base[sizeof (fhandler_base)];
|
char __base[sizeof (fhandler_base)];
|
||||||
@ -1213,6 +1210,7 @@ typedef union
|
|||||||
char __tty_slave[sizeof (fhandler_tty_slave)];
|
char __tty_slave[sizeof (fhandler_tty_slave)];
|
||||||
char __virtual[sizeof (fhandler_virtual)];
|
char __virtual[sizeof (fhandler_virtual)];
|
||||||
char __windows[sizeof (fhandler_windows)];
|
char __windows[sizeof (fhandler_windows)];
|
||||||
|
char __nodevice[sizeof (fhandler_nodevice)];
|
||||||
} fhandler_union;
|
} fhandler_union;
|
||||||
|
|
||||||
struct select_record
|
struct select_record
|
||||||
@ -1245,19 +1243,21 @@ class select_stuff
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
~select_stuff ();
|
~select_stuff ();
|
||||||
select_stuff (): always_ready (0), windows_used (0), start (0)
|
|
||||||
{
|
|
||||||
memset (device_specific, 0, sizeof (device_specific));
|
|
||||||
}
|
|
||||||
bool always_ready, windows_used;
|
bool always_ready, windows_used;
|
||||||
select_record start;
|
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,
|
int test_and_set (int i, fd_set *readfds, fd_set *writefds,
|
||||||
fd_set *exceptfds);
|
fd_set *exceptfds);
|
||||||
int poll (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);
|
int wait (fd_set *readfds, fd_set *writefds, fd_set *exceptfds, DWORD ms);
|
||||||
void cleanup ();
|
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 ();
|
int __stdcall set_console_state_for_spawn ();
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* fhandler_dev_clipboard: code to access /dev/clipboard
|
/* fhandler_dev_clipboard: code to access /dev/clipboard
|
||||||
|
|
||||||
Copyright 2000, 2001, 2002 Red Hat, Inc
|
Copyright 2000, 2001, 2002, 2003 Red Hat, Inc
|
||||||
|
|
||||||
Written by Charles Wilson (cwilson@ece.gatech.edu)
|
Written by Charles Wilson (cwilson@ece.gatech.edu)
|
||||||
|
|
||||||
@ -19,6 +19,7 @@ details. */
|
|||||||
#include <winuser.h>
|
#include <winuser.h>
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
|
#include "path.h"
|
||||||
#include "fhandler.h"
|
#include "fhandler.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -32,7 +33,7 @@ static const NO_COPY char *CYGWIN_NATIVE = "CYGWIN_NATIVE_CLIPBOARD";
|
|||||||
static UINT cygnativeformat;
|
static UINT cygnativeformat;
|
||||||
|
|
||||||
fhandler_dev_clipboard::fhandler_dev_clipboard ()
|
fhandler_dev_clipboard::fhandler_dev_clipboard ()
|
||||||
: fhandler_base (FH_CLIPBOARD), pos (0), membuffer (NULL), msize (0),
|
: fhandler_base (), pos (0), membuffer (NULL), msize (0),
|
||||||
eof (true)
|
eof (true)
|
||||||
{
|
{
|
||||||
/* FIXME: check for errors and loop until we can open the clipboard */
|
/* FIXME: check for errors and loop until we can open the clipboard */
|
||||||
@ -51,7 +52,7 @@ fhandler_dev_clipboard::dup (fhandler_base * child)
|
|||||||
{
|
{
|
||||||
fhandler_dev_clipboard *fhc = (fhandler_dev_clipboard *) child;
|
fhandler_dev_clipboard *fhc = (fhandler_dev_clipboard *) child;
|
||||||
|
|
||||||
if (!fhc->open (NULL, get_flags (), 0))
|
if (!fhc->open (get_flags (), 0))
|
||||||
system_printf ("error opening clipboard, %E");
|
system_printf ("error opening clipboard, %E");
|
||||||
|
|
||||||
fhc->membuffer = membuffer;
|
fhc->membuffer = membuffer;
|
||||||
@ -62,7 +63,7 @@ fhandler_dev_clipboard::dup (fhandler_base * child)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
fhandler_dev_clipboard::open (path_conv *, int flags, mode_t)
|
fhandler_dev_clipboard::open (int flags, mode_t)
|
||||||
{
|
{
|
||||||
set_flags (flags | O_TEXT);
|
set_flags (flags | O_TEXT);
|
||||||
eof = false;
|
eof = false;
|
||||||
|
@ -21,8 +21,8 @@ details. */
|
|||||||
#include <sys/cygwin.h>
|
#include <sys/cygwin.h>
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include "fhandler.h"
|
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
#include "sigproc.h"
|
#include "sigproc.h"
|
||||||
@ -594,7 +594,7 @@ fhandler_console::scroll_screen (int x1, int y1, int x2, int y2, int xn, int yn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
fhandler_console::open (path_conv *, int flags, mode_t)
|
fhandler_console::open (int flags, mode_t)
|
||||||
{
|
{
|
||||||
HANDLE h;
|
HANDLE h;
|
||||||
|
|
||||||
@ -679,7 +679,7 @@ fhandler_console::dup (fhandler_base *child)
|
|||||||
{
|
{
|
||||||
fhandler_console *fhc = (fhandler_console *) child;
|
fhandler_console *fhc = (fhandler_console *) child;
|
||||||
|
|
||||||
if (!fhc->open (NULL, get_flags () & ~O_NOCTTY, 0))
|
if (!fhc->open (get_flags () & ~O_NOCTTY, 0))
|
||||||
system_printf ("error opening console, %E");
|
system_printf ("error opening console, %E");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -867,7 +867,7 @@ fhandler_console::tcgetattr (struct termios *t)
|
|||||||
}
|
}
|
||||||
|
|
||||||
fhandler_console::fhandler_console () :
|
fhandler_console::fhandler_console () :
|
||||||
fhandler_termios (FH_CONSOLE, -1)
|
fhandler_termios ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1696,7 +1696,7 @@ fhandler_console::init (HANDLE f, DWORD a, mode_t bin)
|
|||||||
flags = O_WRONLY;
|
flags = O_WRONLY;
|
||||||
if (a == (GENERIC_READ | GENERIC_WRITE))
|
if (a == (GENERIC_READ | GENERIC_WRITE))
|
||||||
flags = O_RDWR;
|
flags = O_RDWR;
|
||||||
open ((path_conv *) NULL, flags | O_BINARY);
|
open (flags | O_BINARY);
|
||||||
if (f != INVALID_HANDLE_VALUE)
|
if (f != INVALID_HANDLE_VALUE)
|
||||||
CloseHandle (f); /* Reopened by open */
|
CloseHandle (f); /* Reopened by open */
|
||||||
|
|
||||||
@ -1725,7 +1725,7 @@ fhandler_console::fixup_after_fork (HANDLE)
|
|||||||
/* Windows does not allow duplication of console handles between processes
|
/* Windows does not allow duplication of console handles between processes
|
||||||
so open the console explicitly. */
|
so open the console explicitly. */
|
||||||
|
|
||||||
if (!open (NULL, O_NOCTTY | get_flags (), 0))
|
if (!open (O_NOCTTY | get_flags (), 0))
|
||||||
system_printf ("error opening console after fork, %E");
|
system_printf ("error opening console after fork, %E");
|
||||||
|
|
||||||
if (!get_close_on_exec ())
|
if (!get_close_on_exec ())
|
||||||
@ -1755,7 +1755,7 @@ fhandler_console::fixup_after_exec (HANDLE)
|
|||||||
HANDLE h = get_handle ();
|
HANDLE h = get_handle ();
|
||||||
HANDLE oh = get_output_handle ();
|
HANDLE oh = get_output_handle ();
|
||||||
|
|
||||||
if (!open (NULL, O_NOCTTY | get_flags (), 0))
|
if (!open (O_NOCTTY | get_flags (), 0))
|
||||||
{
|
{
|
||||||
int sawerr = 0;
|
int sawerr = 0;
|
||||||
if (!get_io_handle ())
|
if (!get_io_handle ())
|
||||||
|
@ -17,8 +17,8 @@ details. */
|
|||||||
#include "perprocess.h"
|
#include "perprocess.h"
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include "cygwin/version.h"
|
#include "cygwin/version.h"
|
||||||
#include "fhandler.h"
|
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
#include "shared_info.h"
|
#include "shared_info.h"
|
||||||
@ -92,7 +92,7 @@ path_conv::ndisk_links (DWORD nNumberOfLinks)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int __stdcall
|
int __stdcall
|
||||||
fhandler_disk_file::fstat_by_handle (struct __stat64 *buf, path_conv *pc)
|
fhandler_base::fstat_by_handle (struct __stat64 *buf)
|
||||||
{
|
{
|
||||||
int res = 0;
|
int res = 0;
|
||||||
BY_HANDLE_FILE_INFORMATION local;
|
BY_HANDLE_FILE_INFORMATION local;
|
||||||
@ -106,6 +106,7 @@ fhandler_disk_file::fstat_by_handle (struct __stat64 *buf, path_conv *pc)
|
|||||||
if (local.dwVolumeSerialNumber && (long) local.dwVolumeSerialNumber != -1)
|
if (local.dwVolumeSerialNumber && (long) local.dwVolumeSerialNumber != -1)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
debug_printf ("%d = GetFileInformationByHandle (%s, %d)",
|
debug_printf ("%d = GetFileInformationByHandle (%s, %d)",
|
||||||
res, get_win32_name (), get_handle ());
|
res, get_win32_name (), get_handle ());
|
||||||
if (res == 0)
|
if (res == 0)
|
||||||
@ -116,7 +117,7 @@ fhandler_disk_file::fstat_by_handle (struct __stat64 *buf, path_conv *pc)
|
|||||||
local.nFileSizeLow = GetFileSize (get_handle (), &local.nFileSizeHigh);
|
local.nFileSizeLow = GetFileSize (get_handle (), &local.nFileSizeHigh);
|
||||||
}
|
}
|
||||||
|
|
||||||
return fstat_helper (buf, pc,
|
return fstat_helper (buf,
|
||||||
local.ftCreationTime,
|
local.ftCreationTime,
|
||||||
local.ftLastAccessTime,
|
local.ftLastAccessTime,
|
||||||
local.ftLastWriteTime,
|
local.ftLastWriteTime,
|
||||||
@ -128,36 +129,36 @@ fhandler_disk_file::fstat_by_handle (struct __stat64 *buf, path_conv *pc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int __stdcall
|
int __stdcall
|
||||||
fhandler_disk_file::fstat_by_name (struct __stat64 *buf, path_conv *pc)
|
fhandler_base::fstat_by_name (struct __stat64 *buf)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
HANDLE handle;
|
HANDLE handle;
|
||||||
WIN32_FIND_DATA local;
|
WIN32_FIND_DATA local;
|
||||||
|
|
||||||
if (!pc->exists ())
|
if (!pc.exists ())
|
||||||
{
|
{
|
||||||
debug_printf ("already determined that pc does not exist");
|
debug_printf ("already determined that pc does not exist");
|
||||||
set_errno (ENOENT);
|
set_errno (ENOENT);
|
||||||
res = -1;
|
res = -1;
|
||||||
}
|
}
|
||||||
else if ((handle = FindFirstFile (*pc, &local)) != INVALID_HANDLE_VALUE)
|
else if ((handle = FindFirstFile (pc, &local)) != INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
FindClose (handle);
|
FindClose (handle);
|
||||||
res = fstat_helper (buf, pc,
|
res = fstat_helper (buf,
|
||||||
local.ftCreationTime,
|
local.ftCreationTime,
|
||||||
local.ftLastAccessTime,
|
local.ftLastAccessTime,
|
||||||
local.ftLastWriteTime,
|
local.ftLastWriteTime,
|
||||||
local.nFileSizeHigh,
|
local.nFileSizeHigh,
|
||||||
local.nFileSizeLow);
|
local.nFileSizeLow);
|
||||||
}
|
}
|
||||||
else if (pc->isdir ())
|
else if (pc.isdir ())
|
||||||
{
|
{
|
||||||
FILETIME ft = {};
|
FILETIME ft = {};
|
||||||
res = fstat_helper (buf, pc, ft, ft, ft, 0, 0);
|
res = fstat_helper (buf, ft, ft, ft, 0, 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
debug_printf ("FindFirstFile failed for '%s', %E", (char *) *pc);
|
debug_printf ("FindFirstFile failed for '%s', %E", (char *) pc);
|
||||||
__seterrno ();
|
__seterrno ();
|
||||||
res = -1;
|
res = -1;
|
||||||
}
|
}
|
||||||
@ -165,7 +166,7 @@ fhandler_disk_file::fstat_by_name (struct __stat64 *buf, path_conv *pc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int __stdcall
|
int __stdcall
|
||||||
fhandler_disk_file::fstat (struct __stat64 *buf, path_conv *pc)
|
fhandler_base::fstat_fs (struct __stat64 *buf)
|
||||||
{
|
{
|
||||||
int res = -1;
|
int res = -1;
|
||||||
int oret;
|
int oret;
|
||||||
@ -175,52 +176,52 @@ fhandler_disk_file::fstat (struct __stat64 *buf, path_conv *pc)
|
|||||||
if (get_io_handle ())
|
if (get_io_handle ())
|
||||||
{
|
{
|
||||||
if (get_nohandle ())
|
if (get_nohandle ())
|
||||||
return fstat_by_name (buf, pc);
|
return fstat_by_name (buf);
|
||||||
else
|
else
|
||||||
return fstat_by_handle (buf, pc);
|
return fstat_by_handle (buf);
|
||||||
}
|
}
|
||||||
/* If we don't care if the file is executable or we already know if it is,
|
/* If we don't care if the file is executable or we already know if it is,
|
||||||
then just do a "query open" as it is apparently much faster. */
|
then just do a "query open" as it is apparently much faster. */
|
||||||
if (pc->exec_state () != dont_know_if_executable)
|
if (pc.exec_state () != dont_know_if_executable)
|
||||||
set_query_open (query_open_already = true);
|
set_query_open (query_open_already = true);
|
||||||
else
|
else
|
||||||
query_open_already = false;
|
query_open_already = false;
|
||||||
|
|
||||||
if (query_open_already && strncasematch (pc->volname (), "FAT", 3)
|
if (query_open_already && strncasematch (pc.volname (), "FAT", 3)
|
||||||
&& !strpbrk (get_win32_name (), "?*|<>"))
|
&& !strpbrk (get_win32_name (), "?*|<>"))
|
||||||
oret = 0;
|
oret = 0;
|
||||||
else if (!(oret = open (pc, open_flags, 0))
|
else if (!(oret = open_fs (open_flags, 0))
|
||||||
&& !query_open_already
|
&& !query_open_already
|
||||||
&& get_errno () == EACCES)
|
&& get_errno () == EACCES)
|
||||||
{
|
{
|
||||||
/* If we couldn't open the file, try a "query open" with no permissions.
|
/* If we couldn't open the file, try a "query open" with no permissions.
|
||||||
This will allow us to determine *some* things about the file, at least. */
|
This will allow us to determine *some* things about the file, at least. */
|
||||||
pc->set_exec (0);
|
pc.set_exec (0);
|
||||||
set_query_open (true);
|
set_query_open (true);
|
||||||
oret = open (pc, open_flags, 0);
|
oret = open_fs (open_flags, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!oret || get_nohandle ())
|
if (!oret || get_nohandle ())
|
||||||
res = fstat_by_name (buf, pc);
|
res = fstat_by_name (buf);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
res = fstat_by_handle (buf, pc);
|
res = fstat_by_handle (buf);
|
||||||
close ();
|
close_fs ();
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
int __stdcall
|
int __stdcall
|
||||||
fhandler_disk_file::fstat_helper (struct __stat64 *buf, path_conv *pc,
|
fhandler_base::fstat_helper (struct __stat64 *buf,
|
||||||
FILETIME ftCreationTime,
|
FILETIME ftCreationTime,
|
||||||
FILETIME ftLastAccessTime,
|
FILETIME ftLastAccessTime,
|
||||||
FILETIME ftLastWriteTime,
|
FILETIME ftLastWriteTime,
|
||||||
DWORD nFileSizeHigh,
|
DWORD nFileSizeHigh,
|
||||||
DWORD nFileSizeLow,
|
DWORD nFileSizeLow,
|
||||||
DWORD nFileIndexHigh,
|
DWORD nFileIndexHigh,
|
||||||
DWORD nFileIndexLow,
|
DWORD nFileIndexLow,
|
||||||
DWORD nNumberOfLinks)
|
DWORD nNumberOfLinks)
|
||||||
{
|
{
|
||||||
/* This is for FAT filesystems, which don't support atime/ctime */
|
/* This is for FAT filesystems, which don't support atime/ctime */
|
||||||
if (ftLastAccessTime.dwLowDateTime == 0
|
if (ftLastAccessTime.dwLowDateTime == 0
|
||||||
@ -233,21 +234,21 @@ fhandler_disk_file::fstat_helper (struct __stat64 *buf, path_conv *pc,
|
|||||||
to_timestruc_t (&ftLastAccessTime, &buf->st_atim);
|
to_timestruc_t (&ftLastAccessTime, &buf->st_atim);
|
||||||
to_timestruc_t (&ftLastWriteTime, &buf->st_mtim);
|
to_timestruc_t (&ftLastWriteTime, &buf->st_mtim);
|
||||||
to_timestruc_t (&ftCreationTime, &buf->st_ctim);
|
to_timestruc_t (&ftCreationTime, &buf->st_ctim);
|
||||||
buf->st_dev = pc->volser ();
|
buf->st_dev = pc.volser ();
|
||||||
buf->st_size = ((_off64_t)nFileSizeHigh << 32) + nFileSizeLow;
|
buf->st_size = ((_off64_t) nFileSizeHigh << 32) + nFileSizeLow;
|
||||||
/* The number of links to a directory includes the
|
/* The number of links to a directory includes the
|
||||||
number of subdirectories in the directory, since all
|
number of subdirectories in the directory, since all
|
||||||
those subdirectories point to it.
|
those subdirectories point to it.
|
||||||
This is too slow on remote drives, so we do without it.
|
This is too slow on remote drives, so we do without it.
|
||||||
Setting the count to 2 confuses `find (1)' command. So
|
Setting the count to 2 confuses `find (1)' command. So
|
||||||
let's try it with `1' as link count. */
|
let's try it with `1' as link count. */
|
||||||
buf->st_nlink = pc->ndisk_links (nNumberOfLinks);
|
buf->st_nlink = pc.ndisk_links (nNumberOfLinks);
|
||||||
|
|
||||||
/* Assume that if a drive has ACL support it MAY have valid "inodes".
|
/* Assume that if a drive has ACL support it MAY have valid "inodes".
|
||||||
It definitely does not have valid inodes if it does not have ACL
|
It definitely does not have valid inodes if it does not have ACL
|
||||||
support. */
|
support. */
|
||||||
switch (pc->has_acls () && (nFileIndexHigh || nFileIndexLow)
|
switch (pc.has_acls () && (nFileIndexHigh || nFileIndexLow)
|
||||||
? pc->drive_type () : DRIVE_UNKNOWN)
|
? pc.drive_type () : DRIVE_UNKNOWN)
|
||||||
{
|
{
|
||||||
case DRIVE_FIXED:
|
case DRIVE_FIXED:
|
||||||
case DRIVE_REMOVABLE:
|
case DRIVE_REMOVABLE:
|
||||||
@ -270,7 +271,7 @@ fhandler_disk_file::fstat_helper (struct __stat64 *buf, path_conv *pc,
|
|||||||
/* GetCompressedFileSize() gets autoloaded. It returns INVALID_FILE_SIZE
|
/* GetCompressedFileSize() gets autoloaded. It returns INVALID_FILE_SIZE
|
||||||
if it doesn't exist. Since that's also a valid return value on 64bit
|
if it doesn't exist. Since that's also a valid return value on 64bit
|
||||||
capable file systems, we must additionally check for the win32 error. */
|
capable file systems, we must additionally check for the win32 error. */
|
||||||
nFileSizeLow = GetCompressedFileSizeA (pc->get_win32 (), &nFileSizeHigh);
|
nFileSizeLow = GetCompressedFileSizeA (pc, &nFileSizeHigh);
|
||||||
if (nFileSizeLow != INVALID_FILE_SIZE || GetLastError () == NO_ERROR)
|
if (nFileSizeLow != INVALID_FILE_SIZE || GetLastError () == NO_ERROR)
|
||||||
/* On systems supporting compressed (and sparsed) files,
|
/* On systems supporting compressed (and sparsed) files,
|
||||||
GetCompressedFileSize() returns the actual amount of
|
GetCompressedFileSize() returns the actual amount of
|
||||||
@ -284,24 +285,24 @@ fhandler_disk_file::fstat_helper (struct __stat64 *buf, path_conv *pc,
|
|||||||
buf->st_mode = 0;
|
buf->st_mode = 0;
|
||||||
/* Using a side effect: get_file_attibutes checks for
|
/* Using a side effect: get_file_attibutes checks for
|
||||||
directory. This is used, to set S_ISVTX, if needed. */
|
directory. This is used, to set S_ISVTX, if needed. */
|
||||||
if (pc->isdir ())
|
if (pc.isdir ())
|
||||||
buf->st_mode = S_IFDIR;
|
buf->st_mode = S_IFDIR;
|
||||||
else if (pc->issymlink ())
|
else if (pc.issymlink ())
|
||||||
{
|
{
|
||||||
/* symlinks are everything for everyone! */
|
/* symlinks are everything for everyone! */
|
||||||
buf->st_mode = S_IFLNK | S_IRWXU | S_IRWXG | S_IRWXO;
|
buf->st_mode = S_IFLNK | S_IRWXU | S_IRWXG | S_IRWXO;
|
||||||
get_file_attribute (pc->has_acls (), get_win32_name (), NULL,
|
get_file_attribute (pc.has_acls (), get_win32_name (), NULL,
|
||||||
&buf->st_uid, &buf->st_gid);
|
&buf->st_uid, &buf->st_gid);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
else if (pc->issocket ())
|
else if (pc.issocket ())
|
||||||
buf->st_mode = S_IFSOCK;
|
buf->st_mode = S_IFSOCK;
|
||||||
|
|
||||||
if (get_file_attribute (pc->has_acls (), get_win32_name (), &buf->st_mode,
|
if (get_file_attribute (pc.has_acls (), get_win32_name (), &buf->st_mode,
|
||||||
&buf->st_uid, &buf->st_gid) == 0)
|
&buf->st_uid, &buf->st_gid) == 0)
|
||||||
{
|
{
|
||||||
/* If read-only attribute is set, modify ntsec return value */
|
/* If read-only attribute is set, modify ntsec return value */
|
||||||
if (pc->has_attribute (FILE_ATTRIBUTE_READONLY) && !get_symlink_p ())
|
if (pc.has_attribute (FILE_ATTRIBUTE_READONLY) && !get_symlink_p ())
|
||||||
buf->st_mode &= ~(S_IWUSR | S_IWGRP | S_IWOTH);
|
buf->st_mode &= ~(S_IWUSR | S_IWGRP | S_IWOTH);
|
||||||
|
|
||||||
if (!(buf->st_mode & S_IFMT))
|
if (!(buf->st_mode & S_IFMT))
|
||||||
@ -311,7 +312,7 @@ fhandler_disk_file::fstat_helper (struct __stat64 *buf, path_conv *pc,
|
|||||||
{
|
{
|
||||||
buf->st_mode |= STD_RBITS;
|
buf->st_mode |= STD_RBITS;
|
||||||
|
|
||||||
if (!pc->has_attribute (FILE_ATTRIBUTE_READONLY))
|
if (!pc.has_attribute (FILE_ATTRIBUTE_READONLY))
|
||||||
buf->st_mode |= STD_WBITS;
|
buf->st_mode |= STD_WBITS;
|
||||||
/* | S_IWGRP | S_IWOTH; we don't give write to group etc */
|
/* | S_IWGRP | S_IWOTH; we don't give write to group etc */
|
||||||
|
|
||||||
@ -319,10 +320,15 @@ fhandler_disk_file::fstat_helper (struct __stat64 *buf, path_conv *pc,
|
|||||||
buf->st_mode |= S_IFDIR | STD_XBITS;
|
buf->st_mode |= S_IFDIR | STD_XBITS;
|
||||||
else if (buf->st_mode & S_IFMT)
|
else if (buf->st_mode & S_IFMT)
|
||||||
/* nothing */;
|
/* nothing */;
|
||||||
|
else if (is_fs_special ())
|
||||||
|
{
|
||||||
|
buf->st_dev = dev ();
|
||||||
|
buf->st_mode = dev ().mode;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
buf->st_mode |= S_IFREG;
|
buf->st_mode |= S_IFREG;
|
||||||
if (pc->exec_state () == dont_know_if_executable)
|
if (pc.exec_state () == dont_know_if_executable)
|
||||||
{
|
{
|
||||||
DWORD cur, done;
|
DWORD cur, done;
|
||||||
char magic[3];
|
char magic[3];
|
||||||
@ -340,7 +346,7 @@ fhandler_disk_file::fstat_helper (struct __stat64 *buf, path_conv *pc,
|
|||||||
&& has_exec_chars (magic, done))
|
&& has_exec_chars (magic, done))
|
||||||
{
|
{
|
||||||
set_execable_p ();
|
set_execable_p ();
|
||||||
pc->set_exec ();
|
pc.set_exec ();
|
||||||
buf->st_mode |= STD_XBITS;
|
buf->st_mode |= STD_XBITS;
|
||||||
}
|
}
|
||||||
(void) SetFilePointer (get_handle (), cur, NULL, FILE_BEGIN);
|
(void) SetFilePointer (get_handle (), cur, NULL, FILE_BEGIN);
|
||||||
@ -348,7 +354,7 @@ fhandler_disk_file::fstat_helper (struct __stat64 *buf, path_conv *pc,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pc->exec_state () == is_executable)
|
if (pc.exec_state () == is_executable)
|
||||||
buf->st_mode |= STD_XBITS;
|
buf->st_mode |= STD_XBITS;
|
||||||
|
|
||||||
/* This fakes the permissions of all files to match the current umask. */
|
/* This fakes the permissions of all files to match the current umask. */
|
||||||
@ -362,30 +368,37 @@ fhandler_disk_file::fstat_helper (struct __stat64 *buf, path_conv *pc,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
fhandler_disk_file::fhandler_disk_file (DWORD devtype) :
|
int __stdcall
|
||||||
fhandler_base (devtype)
|
fhandler_disk_file::fstat (struct __stat64 *buf)
|
||||||
{
|
{
|
||||||
|
return fstat_fs (buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
fhandler_disk_file::fhandler_disk_file () :
|
fhandler_disk_file::fhandler_disk_file () :
|
||||||
fhandler_base (FH_DISK)
|
fhandler_base ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
fhandler_disk_file::open (path_conv *real_path, int flags, mode_t mode)
|
fhandler_disk_file::open (int flags, mode_t mode)
|
||||||
{
|
{
|
||||||
if (real_path->case_clash && flags & O_CREAT)
|
return open_fs (flags, mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
fhandler_base::open_fs (int flags, mode_t mode)
|
||||||
|
{
|
||||||
|
if (pc.case_clash && flags & O_CREAT)
|
||||||
{
|
{
|
||||||
debug_printf ("case clash detected");
|
debug_printf ("case clash detected");
|
||||||
set_errno (ECASECLASH);
|
set_errno (ECASECLASH);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
set_has_acls (real_path->has_acls ());
|
set_has_acls (pc.has_acls ());
|
||||||
set_isremote (real_path->isremote ());
|
set_isremote (pc.isremote ());
|
||||||
|
|
||||||
int res = fhandler_base::open (real_path, flags | O_DIROPEN, mode);
|
int res = fhandler_base::open (flags | O_DIROPEN, mode);
|
||||||
if (!res)
|
if (!res)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
@ -395,10 +408,10 @@ fhandler_disk_file::open (path_conv *real_path, int flags, mode_t mode)
|
|||||||
The only known file system to date is the SUN NFS Solstice Client 3.1
|
The only known file system to date is the SUN NFS Solstice Client 3.1
|
||||||
which returns a valid handle when trying to open a file in a nonexistent
|
which returns a valid handle when trying to open a file in a nonexistent
|
||||||
directory. */
|
directory. */
|
||||||
if (real_path->has_buggy_open () && !real_path->exists ())
|
if (pc.has_buggy_open () && !pc.exists ())
|
||||||
{
|
{
|
||||||
debug_printf ("Buggy open detected.");
|
debug_printf ("Buggy open detected.");
|
||||||
close ();
|
close_fs ();
|
||||||
set_errno (ENOENT);
|
set_errno (ENOENT);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -411,10 +424,10 @@ fhandler_disk_file::open (path_conv *real_path, int flags, mode_t mode)
|
|||||||
&& !allow_ntsec && allow_ntea)
|
&& !allow_ntsec && allow_ntea)
|
||||||
set_file_attribute (has_acls (), get_win32_name (), mode);
|
set_file_attribute (has_acls (), get_win32_name (), mode);
|
||||||
|
|
||||||
set_fs_flags (real_path->fs_flags ());
|
set_fs_flags (pc.fs_flags ());
|
||||||
set_symlink_p (real_path->issymlink ());
|
set_symlink_p (pc.issymlink ());
|
||||||
set_execable_p (real_path->exec_state ());
|
set_execable_p (pc.exec_state ());
|
||||||
set_socket_p (real_path->issocket ());
|
set_socket_p (pc.issocket ());
|
||||||
|
|
||||||
out:
|
out:
|
||||||
syscall_printf ("%d = fhandler_disk_file::open (%s, %p)", res,
|
syscall_printf ("%d = fhandler_disk_file::open (%s, %p)", res,
|
||||||
@ -424,6 +437,12 @@ out:
|
|||||||
|
|
||||||
int
|
int
|
||||||
fhandler_disk_file::close ()
|
fhandler_disk_file::close ()
|
||||||
|
{
|
||||||
|
return close_fs ();
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
fhandler_base::close_fs ()
|
||||||
{
|
{
|
||||||
int res = fhandler_base::close ();
|
int res = fhandler_base::close ();
|
||||||
if (!res)
|
if (!res)
|
||||||
@ -431,19 +450,14 @@ fhandler_disk_file::close ()
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* FIXME: The correct way to do this to get POSIX locking semantics is to
|
||||||
* FIXME !!!
|
keep a linked list of posix lock requests and map them into Win32 locks.
|
||||||
* The correct way to do this to get POSIX locking
|
he problem is that Win32 does not deal correctly with overlapping lock
|
||||||
* semantics is to keep a linked list of posix lock
|
requests. Also another pain is that Win95 doesn't do non-blocking or
|
||||||
* requests and map them into Win32 locks. The problem
|
non-exclusive locks at all. For '95 just convert all lock requests into
|
||||||
* is that Win32 does not deal correctly with overlapping
|
blocking,exclusive locks. This shouldn't break many apps but denying all
|
||||||
* lock requests. Also another pain is that Win95 doesn't do
|
locking would. For now just convert to Win32 locks and hope for
|
||||||
* non-blocking or non exclusive locks at all. For '95 just
|
the best. */
|
||||||
* convert all lock requests into blocking,exclusive locks.
|
|
||||||
* This shouldn't break many apps but denying all locking
|
|
||||||
* would.
|
|
||||||
* For now just convert to Win32 locks and hope for the best.
|
|
||||||
*/
|
|
||||||
|
|
||||||
int
|
int
|
||||||
fhandler_disk_file::lock (int cmd, struct flock *fl)
|
fhandler_disk_file::lock (int cmd, struct flock *fl)
|
||||||
@ -589,15 +603,15 @@ fhandler_disk_file::lock (int cmd, struct flock *fl)
|
|||||||
}
|
}
|
||||||
|
|
||||||
DIR *
|
DIR *
|
||||||
fhandler_disk_file::opendir (path_conv& real_name)
|
fhandler_disk_file::opendir ()
|
||||||
{
|
{
|
||||||
DIR *dir;
|
DIR *dir;
|
||||||
DIR *res = NULL;
|
DIR *res = NULL;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
if (!real_name.isdir ())
|
if (!pc.isdir ())
|
||||||
set_errno (ENOTDIR);
|
set_errno (ENOTDIR);
|
||||||
else if ((len = strlen (real_name))> MAX_PATH - 3)
|
else if ((len = strlen (pc))> MAX_PATH - 3)
|
||||||
set_errno (ENAMETOOLONG);
|
set_errno (ENAMETOOLONG);
|
||||||
else if ((dir = (DIR *) malloc (sizeof (DIR))) == NULL)
|
else if ((dir = (DIR *) malloc (sizeof (DIR))) == NULL)
|
||||||
set_errno (ENOMEM);
|
set_errno (ENOMEM);
|
||||||
@ -615,7 +629,7 @@ fhandler_disk_file::opendir (path_conv& real_name)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strcpy (dir->__d_dirname, real_name.get_win32 ());
|
strcpy (dir->__d_dirname, get_win32_name ());
|
||||||
dir->__d_dirent->d_version = __DIRENT_VERSION;
|
dir->__d_dirent->d_version = __DIRENT_VERSION;
|
||||||
cygheap_fdnew fd;
|
cygheap_fdnew fd;
|
||||||
if (fd >= 0)
|
if (fd >= 0)
|
||||||
@ -637,7 +651,7 @@ fhandler_disk_file::opendir (path_conv& real_name)
|
|||||||
|
|
||||||
res = dir;
|
res = dir;
|
||||||
}
|
}
|
||||||
if (real_name.isencoded ())
|
if (pc.isencoded ())
|
||||||
set_encoded ();
|
set_encoded ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -697,7 +711,7 @@ fhandler_disk_file::readdir (DIR *dir)
|
|||||||
strcpy (fbuf, dir->__d_dirname);
|
strcpy (fbuf, dir->__d_dirname);
|
||||||
strcpy (fbuf + strlen (fbuf) - 1, dir->__d_dirent->d_name);
|
strcpy (fbuf + strlen (fbuf) - 1, dir->__d_dirent->d_name);
|
||||||
path_conv fpath (fbuf, PC_SYM_NOFOLLOW);
|
path_conv fpath (fbuf, PC_SYM_NOFOLLOW);
|
||||||
if (fpath.issymlink ())
|
if (fpath.issymlink () || fpath.isspecial ())
|
||||||
c[len - 4] = '\0';
|
c[len - 4] = '\0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -749,8 +763,8 @@ fhandler_disk_file::closedir (DIR *dir)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
fhandler_cygdrive::fhandler_cygdrive (int unit) :
|
fhandler_cygdrive::fhandler_cygdrive () :
|
||||||
fhandler_disk_file (FH_CYGDRIVE), unit (unit), ndrives (0), pdrive (NULL)
|
fhandler_disk_file (), ndrives (0), pdrive (NULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -759,17 +773,16 @@ void
|
|||||||
fhandler_cygdrive::set_drives ()
|
fhandler_cygdrive::set_drives ()
|
||||||
{
|
{
|
||||||
const int len = 2 + 26 * DRVSZ;
|
const int len = 2 + 26 * DRVSZ;
|
||||||
char *p = (char *) crealloc ((void *) win32_path_name, len);
|
char *p = const_cast<char *> (get_win32_name ());
|
||||||
|
pdrive = p;
|
||||||
win32_path_name = pdrive = p;
|
|
||||||
ndrives = GetLogicalDriveStrings (len, p) / DRVSZ;
|
ndrives = GetLogicalDriveStrings (len, p) / DRVSZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
fhandler_cygdrive::fstat (struct __stat64 *buf, path_conv *pc)
|
fhandler_cygdrive::fstat (struct __stat64 *buf)
|
||||||
{
|
{
|
||||||
if (!iscygdrive_root ())
|
if (!iscygdrive_root ())
|
||||||
return fhandler_disk_file::fstat (buf, pc);
|
return fhandler_disk_file::fstat (buf);
|
||||||
buf->st_mode = S_IFDIR | 0555;
|
buf->st_mode = S_IFDIR | 0555;
|
||||||
if (!ndrives)
|
if (!ndrives)
|
||||||
set_drives ();
|
set_drives ();
|
||||||
@ -778,11 +791,11 @@ fhandler_cygdrive::fstat (struct __stat64 *buf, path_conv *pc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
DIR *
|
DIR *
|
||||||
fhandler_cygdrive::opendir (path_conv& real_name)
|
fhandler_cygdrive::opendir ()
|
||||||
{
|
{
|
||||||
DIR *dir;
|
DIR *dir;
|
||||||
|
|
||||||
dir = fhandler_disk_file::opendir (real_name);
|
dir = fhandler_disk_file::opendir ();
|
||||||
if (dir && iscygdrive_root () && !ndrives)
|
if (dir && iscygdrive_root () && !ndrives)
|
||||||
set_drives ();
|
set_drives ();
|
||||||
|
|
||||||
@ -823,7 +836,7 @@ fhandler_cygdrive::seekdir (DIR *dir, _off64_t loc)
|
|||||||
if (!iscygdrive_root ())
|
if (!iscygdrive_root ())
|
||||||
return fhandler_disk_file::seekdir (dir, loc);
|
return fhandler_disk_file::seekdir (dir, loc);
|
||||||
|
|
||||||
for (pdrive = win32_path_name, dir->__d_position = -1; *pdrive;
|
for (pdrive = get_win32_name (), dir->__d_position = -1; *pdrive;
|
||||||
pdrive = strchr (pdrive, '\0') + 1)
|
pdrive = strchr (pdrive, '\0') + 1)
|
||||||
if (++dir->__d_position >= loc)
|
if (++dir->__d_position >= loc)
|
||||||
break;
|
break;
|
||||||
@ -836,7 +849,7 @@ fhandler_cygdrive::rewinddir (DIR *dir)
|
|||||||
{
|
{
|
||||||
if (!iscygdrive_root ())
|
if (!iscygdrive_root ())
|
||||||
return fhandler_disk_file::rewinddir (dir);
|
return fhandler_disk_file::rewinddir (dir);
|
||||||
pdrive = win32_path_name;
|
pdrive = get_win32_name ();
|
||||||
dir->__d_position = 0;
|
dir->__d_position = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -846,6 +859,6 @@ fhandler_cygdrive::closedir (DIR *dir)
|
|||||||
{
|
{
|
||||||
if (!iscygdrive_root ())
|
if (!iscygdrive_root ())
|
||||||
return fhandler_disk_file::closedir (dir);
|
return fhandler_disk_file::closedir (dir);
|
||||||
pdrive = win32_path_name;
|
pdrive = get_win32_name ();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ details. */
|
|||||||
#include <mmsystem.h>
|
#include <mmsystem.h>
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
|
#include "path.h"
|
||||||
#include "fhandler.h"
|
#include "fhandler.h"
|
||||||
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
@ -419,7 +420,7 @@ fhandler_dev_dsp::setupwav (const char *pData, int nBytes)
|
|||||||
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
fhandler_dev_dsp::fhandler_dev_dsp ():
|
fhandler_dev_dsp::fhandler_dev_dsp ():
|
||||||
fhandler_base (FH_OSS_DSP)
|
fhandler_base ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -428,7 +429,7 @@ fhandler_dev_dsp::~fhandler_dev_dsp ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
fhandler_dev_dsp::open (path_conv *, int flags, mode_t mode)
|
fhandler_dev_dsp::open (int flags, mode_t mode)
|
||||||
{
|
{
|
||||||
// currently we only support writing
|
// currently we only support writing
|
||||||
if ((flags & (O_WRONLY | O_RDONLY | O_RDWR)) != O_WRONLY)
|
if ((flags & (O_WRONLY | O_RDONLY | O_RDWR)) != O_WRONLY)
|
||||||
|
@ -17,6 +17,7 @@ details. */
|
|||||||
#include <cygwin/hdreg.h>
|
#include <cygwin/hdreg.h>
|
||||||
#include <cygwin/fs.h>
|
#include <cygwin/fs.h>
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
|
#include "path.h"
|
||||||
#include "fhandler.h"
|
#include "fhandler.h"
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
|
|
||||||
@ -41,12 +42,13 @@ fhandler_dev_floppy::is_eof (int)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
fhandler_dev_floppy::fhandler_dev_floppy (int unit) : fhandler_dev_raw (FH_FLOPPY, unit)
|
fhandler_dev_floppy::fhandler_dev_floppy ()
|
||||||
|
: fhandler_dev_raw ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
fhandler_dev_floppy::open (path_conv *real_path, int flags, mode_t)
|
fhandler_dev_floppy::open (int flags, mode_t)
|
||||||
{
|
{
|
||||||
/* The correct size of the buffer would be 512 bytes,
|
/* The correct size of the buffer would be 512 bytes,
|
||||||
* which is the atomic size, supported by WinNT.
|
* which is the atomic size, supported by WinNT.
|
||||||
@ -61,7 +63,7 @@ fhandler_dev_floppy::open (path_conv *real_path, int flags, mode_t)
|
|||||||
* and cpio buffer sizes by default!
|
* and cpio buffer sizes by default!
|
||||||
*/
|
*/
|
||||||
devbufsiz = 61440L; /* 512L; */
|
devbufsiz = 61440L; /* 512L; */
|
||||||
return fhandler_dev_raw::open (real_path, flags);
|
return fhandler_dev_raw::open (flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -15,14 +15,15 @@
|
|||||||
|
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
|
#include "path.h"
|
||||||
#include "fhandler.h"
|
#include "fhandler.h"
|
||||||
#include "ntdll.h"
|
#include "ntdll.h"
|
||||||
|
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
/* fhandler_dev_mem */
|
/* fhandler_dev_mem */
|
||||||
|
|
||||||
fhandler_dev_mem::fhandler_dev_mem (int nunit)
|
fhandler_dev_mem::fhandler_dev_mem ()
|
||||||
: fhandler_base (FH_MEM), unit (nunit)
|
: fhandler_base ()
|
||||||
{
|
{
|
||||||
/* Reading physical memory only supported on NT/W2K. */
|
/* Reading physical memory only supported on NT/W2K. */
|
||||||
if (!wincap.has_physical_mem_access ())
|
if (!wincap.has_physical_mem_access ())
|
||||||
@ -31,7 +32,7 @@ fhandler_dev_mem::fhandler_dev_mem (int nunit)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unit == 1) /* /dev/mem */
|
if (dev () == FH_MEM) /* /dev/mem */
|
||||||
{
|
{
|
||||||
NTSTATUS ret;
|
NTSTATUS ret;
|
||||||
SYSTEM_BASIC_INFORMATION sbi;
|
SYSTEM_BASIC_INFORMATION sbi;
|
||||||
@ -47,12 +48,12 @@ fhandler_dev_mem::fhandler_dev_mem (int nunit)
|
|||||||
mem_size = sbi.PhysicalPageSize * sbi.NumberOfPhysicalPages;
|
mem_size = sbi.PhysicalPageSize * sbi.NumberOfPhysicalPages;
|
||||||
debug_printf ("MemSize: %d MB", mem_size >> 20);
|
debug_printf ("MemSize: %d MB", mem_size >> 20);
|
||||||
}
|
}
|
||||||
else if (unit == 2) /* /dev/kmem - Not yet supported */
|
else if (dev () == FH_KMEM) /* /dev/kmem - Not yet supported */
|
||||||
{
|
{
|
||||||
mem_size = 0;
|
mem_size = 0;
|
||||||
debug_printf ("KMemSize: %d MB", mem_size >> 20);
|
debug_printf ("KMemSize: %d MB", mem_size >> 20);
|
||||||
}
|
}
|
||||||
else if (unit == 4) /* /dev/port == First 64K of /dev/mem */
|
else if (dev () == FH_ZERO) /* /dev/port == First 64K of /dev/mem */
|
||||||
{
|
{
|
||||||
mem_size = 65536;
|
mem_size = 65536;
|
||||||
debug_printf ("PortSize: 64 KB");
|
debug_printf ("PortSize: 64 KB");
|
||||||
@ -69,15 +70,12 @@ fhandler_dev_mem::~fhandler_dev_mem (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
fhandler_dev_mem::open (path_conv *, int flags, mode_t)
|
fhandler_dev_mem::open (int flags, mode_t)
|
||||||
{
|
{
|
||||||
if (!wincap.has_physical_mem_access ())
|
if (!wincap.has_physical_mem_access ())
|
||||||
{
|
{
|
||||||
set_errno (ENOENT);
|
set_errno (ENOENT);
|
||||||
debug_printf ("%s is accessible under NT/W2K only",
|
debug_printf ("%s is accessible under NT/W2K only", dev ().name);
|
||||||
unit == 1 ? "/dev/mem" :
|
|
||||||
unit == 2 ? "/dev/kmem" :
|
|
||||||
"/dev/port");
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -406,9 +404,9 @@ fhandler_dev_mem::fixup_mmap_after_fork (HANDLE h, DWORD access, DWORD offset,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
fhandler_dev_mem::fstat (struct __stat64 *buf, path_conv *pc)
|
fhandler_dev_mem::fstat (struct __stat64 *buf)
|
||||||
{
|
{
|
||||||
fhandler_base::fstat (buf, pc);
|
fhandler_base::fstat (buf);
|
||||||
buf->st_mode = S_IFCHR;
|
buf->st_mode = S_IFCHR;
|
||||||
if (wincap.has_physical_mem_access ())
|
if (wincap.has_physical_mem_access ())
|
||||||
buf->st_mode |= S_IRUSR | S_IWUSR |
|
buf->st_mode |= S_IRUSR | S_IWUSR |
|
||||||
|
@ -17,8 +17,8 @@ details. */
|
|||||||
#include <ntdef.h>
|
#include <ntdef.h>
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include "fhandler.h"
|
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
#include "fhandler.h"
|
||||||
#include "pinfo.h"
|
#include "pinfo.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
@ -146,23 +146,18 @@ fhandler_proc::exists ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
fhandler_proc::fhandler_proc ():
|
fhandler_proc::fhandler_proc ():
|
||||||
fhandler_virtual (FH_PROC)
|
fhandler_virtual ()
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
fhandler_proc::fhandler_proc (DWORD devtype):
|
|
||||||
fhandler_virtual (devtype)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
fhandler_proc::fstat (struct __stat64 *buf, path_conv *pc)
|
fhandler_proc::fstat (struct __stat64 *buf)
|
||||||
{
|
{
|
||||||
const char *path = get_name ();
|
const char *path = get_name ();
|
||||||
debug_printf ("fstat (%s)", path);
|
debug_printf ("fstat (%s)", path);
|
||||||
|
|
||||||
path += proc_len;
|
path += proc_len;
|
||||||
(void) fhandler_base::fstat (buf, pc);
|
(void) fhandler_base::fstat (buf);
|
||||||
|
|
||||||
buf->st_mode &= ~_IFMT & NO_W;
|
buf->st_mode &= ~_IFMT & NO_W;
|
||||||
|
|
||||||
@ -216,11 +211,11 @@ fhandler_proc::readdir (DIR * dir)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
fhandler_proc::open (path_conv *pc, int flags, mode_t mode)
|
fhandler_proc::open (int flags, mode_t mode)
|
||||||
{
|
{
|
||||||
int proc_file_no = -1;
|
int proc_file_no = -1;
|
||||||
|
|
||||||
int res = fhandler_virtual::open (pc, flags, mode);
|
int res = fhandler_virtual::open (flags, mode);
|
||||||
if (!res)
|
if (!res)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
@ -15,9 +15,9 @@ details. */
|
|||||||
#include <ntdef.h>
|
#include <ntdef.h>
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
|
#include "path.h"
|
||||||
#include "fhandler.h"
|
#include "fhandler.h"
|
||||||
#include "pinfo.h"
|
#include "pinfo.h"
|
||||||
#include "path.h"
|
|
||||||
#include "shared_info.h"
|
#include "shared_info.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
@ -96,16 +96,16 @@ fhandler_process::exists ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
fhandler_process::fhandler_process ():
|
fhandler_process::fhandler_process ():
|
||||||
fhandler_proc (FH_PROCESS)
|
fhandler_proc ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
fhandler_process::fstat (struct __stat64 *buf, path_conv *pc)
|
fhandler_process::fstat (struct __stat64 *buf)
|
||||||
{
|
{
|
||||||
const char *path = get_name ();
|
const char *path = get_name ();
|
||||||
int file_type = exists ();
|
int file_type = exists ();
|
||||||
(void) fhandler_base::fstat (buf, pc);
|
(void) fhandler_base::fstat (buf);
|
||||||
path += proc_len + 1;
|
path += proc_len + 1;
|
||||||
pid = atoi (path);
|
pid = atoi (path);
|
||||||
pinfo p (pid);
|
pinfo p (pid);
|
||||||
@ -155,11 +155,11 @@ fhandler_process::readdir (DIR * dir)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
fhandler_process::open (path_conv *pc, int flags, mode_t mode)
|
fhandler_process::open (int flags, mode_t mode)
|
||||||
{
|
{
|
||||||
int process_file_no = -1;
|
int process_file_no = -1;
|
||||||
|
|
||||||
int res = fhandler_virtual::open (pc, flags, mode);
|
int res = fhandler_virtual::open (flags, mode);
|
||||||
if (!res)
|
if (!res)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ details. */
|
|||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
|
#include "path.h"
|
||||||
#include "fhandler.h"
|
#include "fhandler.h"
|
||||||
|
|
||||||
#define RANDOM 8
|
#define RANDOM 8
|
||||||
@ -22,13 +23,13 @@ details. */
|
|||||||
#define PSEUDO_MULTIPLIER (6364136223846793005LL)
|
#define PSEUDO_MULTIPLIER (6364136223846793005LL)
|
||||||
#define PSEUDO_SHIFTVAL (21)
|
#define PSEUDO_SHIFTVAL (21)
|
||||||
|
|
||||||
fhandler_dev_random::fhandler_dev_random (int nunit)
|
fhandler_dev_random::fhandler_dev_random ()
|
||||||
: fhandler_base (FH_RANDOM), unit (nunit), crypt_prov ((HCRYPTPROV) NULL)
|
: fhandler_base (), crypt_prov ((HCRYPTPROV) NULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
fhandler_dev_random::open (path_conv *, int flags, mode_t)
|
fhandler_dev_random::open (int flags, mode_t)
|
||||||
{
|
{
|
||||||
set_flags ((flags & ~O_TEXT) | O_BINARY);
|
set_flags ((flags & ~O_TEXT) | O_BINARY);
|
||||||
set_nohandle (true);
|
set_nohandle (true);
|
||||||
@ -84,7 +85,7 @@ fhandler_dev_random::write (const void *ptr, size_t len)
|
|||||||
memcpy (buf, ptr, limited_len);
|
memcpy (buf, ptr, limited_len);
|
||||||
|
|
||||||
/* Mess up system entropy source. Return error if device is /dev/random. */
|
/* Mess up system entropy source. Return error if device is /dev/random. */
|
||||||
if (!crypt_gen_random (buf, limited_len) && unit == RANDOM)
|
if (!crypt_gen_random (buf, limited_len) && dev () == FH_RANDOM)
|
||||||
{
|
{
|
||||||
__seterrno ();
|
__seterrno ();
|
||||||
return -1;
|
return -1;
|
||||||
@ -128,7 +129,7 @@ fhandler_dev_random::read (void *ptr, size_t& len)
|
|||||||
/* If device is /dev/urandom, use pseudo number generator as fallback.
|
/* If device is /dev/urandom, use pseudo number generator as fallback.
|
||||||
Don't do this for /dev/random since it's intended for uses that need
|
Don't do this for /dev/random since it's intended for uses that need
|
||||||
very high quality randomness. */
|
very high quality randomness. */
|
||||||
if (unit == URANDOM)
|
if (dev () == FH_URANDOM)
|
||||||
{
|
{
|
||||||
len = pseudo_read (ptr, len);
|
len = pseudo_read (ptr, len);
|
||||||
return;
|
return;
|
||||||
@ -158,7 +159,6 @@ int
|
|||||||
fhandler_dev_random::dup (fhandler_base *child)
|
fhandler_dev_random::dup (fhandler_base *child)
|
||||||
{
|
{
|
||||||
fhandler_dev_random *fhr = (fhandler_dev_random *) child;
|
fhandler_dev_random *fhr = (fhandler_dev_random *) child;
|
||||||
fhr->unit = unit;
|
|
||||||
fhr->crypt_prov = (HCRYPTPROV)NULL;
|
fhr->crypt_prov = (HCRYPTPROV)NULL;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,8 @@
|
|||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "perprocess.h"
|
#include "perprocess.h"
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include "fhandler.h"
|
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
#include "ntdll.h"
|
#include "ntdll.h"
|
||||||
@ -115,8 +115,8 @@ fhandler_dev_raw::writebuf (void)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
fhandler_dev_raw::fhandler_dev_raw (DWORD devtype, int nunit)
|
fhandler_dev_raw::fhandler_dev_raw ()
|
||||||
: fhandler_base (devtype), unit (nunit)
|
: fhandler_base ()
|
||||||
{
|
{
|
||||||
clear ();
|
clear ();
|
||||||
set_need_fork_fixup ();
|
set_need_fork_fixup ();
|
||||||
@ -130,12 +130,12 @@ fhandler_dev_raw::~fhandler_dev_raw (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
fhandler_dev_raw::open (path_conv *real_path, int flags, mode_t)
|
fhandler_dev_raw::open (int flags, mode_t)
|
||||||
{
|
{
|
||||||
if (!wincap.has_raw_devices ())
|
if (!wincap.has_raw_devices ())
|
||||||
{
|
{
|
||||||
set_errno (ENOENT);
|
set_errno (ENOENT);
|
||||||
debug_printf ("%s is accessible under NT/W2K only",real_path->get_win32());
|
debug_printf ("%s is accessible under NT/W2K only", get_win32_name ());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,7 +159,7 @@ fhandler_dev_raw::open (path_conv *real_path, int flags, mode_t)
|
|||||||
extern void str2buf2uni (UNICODE_STRING &, WCHAR *, const char *);
|
extern void str2buf2uni (UNICODE_STRING &, WCHAR *, const char *);
|
||||||
UNICODE_STRING dev;
|
UNICODE_STRING dev;
|
||||||
WCHAR devname[MAX_PATH + 1];
|
WCHAR devname[MAX_PATH + 1];
|
||||||
str2buf2uni (dev, devname, real_path->get_win32 ());
|
str2buf2uni (dev, devname, get_win32_name ());
|
||||||
OBJECT_ATTRIBUTES attr;
|
OBJECT_ATTRIBUTES attr;
|
||||||
InitializeObjectAttributes (&attr, &dev, OBJ_CASE_INSENSITIVE, NULL, NULL);
|
InitializeObjectAttributes (&attr, &dev, OBJ_CASE_INSENSITIVE, NULL, NULL);
|
||||||
|
|
||||||
@ -476,7 +476,6 @@ fhandler_dev_raw::dup (fhandler_base *child)
|
|||||||
fhc->eof_detected = eof_detected;
|
fhc->eof_detected = eof_detected;
|
||||||
fhc->lastblk_to_read = 0;
|
fhc->lastblk_to_read = 0;
|
||||||
fhc->varblkop = varblkop;
|
fhc->varblkop = varblkop;
|
||||||
fhc->unit = unit;
|
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -16,8 +16,8 @@ details. */
|
|||||||
#include <sys/cygwin.h>
|
#include <sys/cygwin.h>
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include "fhandler.h"
|
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@ -187,14 +187,14 @@ out:
|
|||||||
}
|
}
|
||||||
|
|
||||||
fhandler_registry::fhandler_registry ():
|
fhandler_registry::fhandler_registry ():
|
||||||
fhandler_proc (FH_REGISTRY)
|
fhandler_proc ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
fhandler_registry::fstat (struct __stat64 *buf, path_conv *pc)
|
fhandler_registry::fstat (struct __stat64 *buf)
|
||||||
{
|
{
|
||||||
fhandler_base::fstat (buf, pc);
|
fhandler_base::fstat (buf);
|
||||||
buf->st_mode &= ~_IFMT & NO_W;
|
buf->st_mode &= ~_IFMT & NO_W;
|
||||||
int file_type = exists ();
|
int file_type = exists ();
|
||||||
switch (file_type)
|
switch (file_type)
|
||||||
@ -396,13 +396,13 @@ fhandler_registry::closedir (DIR * dir)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
fhandler_registry::open (path_conv * pc, int flags, mode_t mode)
|
fhandler_registry::open (int flags, mode_t mode)
|
||||||
{
|
{
|
||||||
int pathlen;
|
int pathlen;
|
||||||
const char *file;
|
const char *file;
|
||||||
HKEY handle;
|
HKEY handle;
|
||||||
|
|
||||||
int res = fhandler_virtual::open (pc, flags, mode);
|
int res = fhandler_virtual::open (flags, mode);
|
||||||
if (!res)
|
if (!res)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ details. */
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
|
#include "path.h"
|
||||||
#include "fhandler.h"
|
#include "fhandler.h"
|
||||||
#include "sigproc.h"
|
#include "sigproc.h"
|
||||||
#include "pinfo.h"
|
#include "pinfo.h"
|
||||||
@ -22,8 +23,8 @@ details. */
|
|||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
/* fhandler_serial */
|
/* fhandler_serial */
|
||||||
|
|
||||||
fhandler_serial::fhandler_serial (int unit)
|
fhandler_serial::fhandler_serial ()
|
||||||
: fhandler_base (FH_SERIAL, unit), vmin_ (0), vtime_ (0), pgrp_ (myself->pgid)
|
: fhandler_base (), vmin_ (0), vtime_ (0), pgrp_ (myself->pgid)
|
||||||
{
|
{
|
||||||
set_need_fork_fixup ();
|
set_need_fork_fixup ();
|
||||||
}
|
}
|
||||||
@ -200,11 +201,11 @@ fhandler_serial::dump (void)
|
|||||||
void
|
void
|
||||||
fhandler_serial::init (HANDLE f, DWORD flags, mode_t bin)
|
fhandler_serial::init (HANDLE f, DWORD flags, mode_t bin)
|
||||||
{
|
{
|
||||||
(void) open (NULL, flags, bin & (O_BINARY | O_TEXT));
|
(void) open (flags, bin & (O_BINARY | O_TEXT));
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
fhandler_serial::open (path_conv *, int flags, mode_t mode)
|
fhandler_serial::open (int flags, mode_t mode)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
COMMTIMEOUTS to;
|
COMMTIMEOUTS to;
|
||||||
@ -213,7 +214,7 @@ fhandler_serial::open (path_conv *, int flags, mode_t mode)
|
|||||||
syscall_printf ("fhandler_serial::open (%s, %p, %p)",
|
syscall_printf ("fhandler_serial::open (%s, %p, %p)",
|
||||||
get_name (), flags, mode);
|
get_name (), flags, mode);
|
||||||
|
|
||||||
if (!fhandler_base::open (NULL, flags, mode))
|
if (!fhandler_base::open (flags, mode))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
res = 1;
|
res = 1;
|
||||||
|
@ -25,8 +25,8 @@
|
|||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include "cygwin/version.h"
|
#include "cygwin/version.h"
|
||||||
#include "perprocess.h"
|
#include "perprocess.h"
|
||||||
#include "fhandler.h"
|
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
#include "sigproc.h"
|
#include "sigproc.h"
|
||||||
@ -35,9 +35,7 @@
|
|||||||
#include "select.h"
|
#include "select.h"
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#define ENTROPY_SOURCE_DEV_UNIT 9
|
extern bool fdsock (cygheap_fdmanip& fd, const device *, SOCKET soc);
|
||||||
|
|
||||||
extern fhandler_socket *fdsock (int& fd, const char *name, SOCKET soc);
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
int sscanf (const char *, const char *, ...);
|
int sscanf (const char *, const char *, ...);
|
||||||
} /* End of "C" section */
|
} /* End of "C" section */
|
||||||
@ -123,12 +121,20 @@ get_inet_addr (const struct sockaddr *in, int inlen,
|
|||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
/* fhandler_socket */
|
/* fhandler_socket */
|
||||||
|
|
||||||
fhandler_socket::fhandler_socket (int nunit)
|
fhandler_socket::fhandler_socket ()
|
||||||
: fhandler_base (FH_SOCKET), sun_path (NULL), unit (nunit)
|
: fhandler_base (), sun_path (NULL)
|
||||||
{
|
{
|
||||||
set_need_fork_fixup ();
|
set_need_fork_fixup ();
|
||||||
prot_info_ptr = (LPWSAPROTOCOL_INFOA) cmalloc (HEAP_BUF,
|
prot_info_ptr = (LPWSAPROTOCOL_INFOA) cmalloc (HEAP_BUF,
|
||||||
sizeof (WSAPROTOCOL_INFOA));
|
sizeof (WSAPROTOCOL_INFOA));
|
||||||
|
#if 0
|
||||||
|
if (pc.is_fs_special ())
|
||||||
|
{
|
||||||
|
fhandler_socket * fhs = (fhandler_socket *) fh;
|
||||||
|
fhs->set_addr_family (AF_LOCAL);
|
||||||
|
fhs->set_sun_path (posix_path);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
fhandler_socket::~fhandler_socket ()
|
fhandler_socket::~fhandler_socket ()
|
||||||
@ -145,10 +151,11 @@ fhandler_socket::set_connect_secret ()
|
|||||||
if (!entropy_source)
|
if (!entropy_source)
|
||||||
{
|
{
|
||||||
void *buf = malloc (sizeof (fhandler_dev_random));
|
void *buf = malloc (sizeof (fhandler_dev_random));
|
||||||
entropy_source = new (buf) fhandler_dev_random (ENTROPY_SOURCE_DEV_UNIT);
|
entropy_source = new (buf) fhandler_dev_random ();
|
||||||
|
entropy_source->dev () = *urandom_dev;
|
||||||
}
|
}
|
||||||
if (entropy_source &&
|
if (entropy_source &&
|
||||||
!entropy_source->open (NULL, O_RDONLY))
|
!entropy_source->open (O_RDONLY))
|
||||||
{
|
{
|
||||||
delete entropy_source;
|
delete entropy_source;
|
||||||
entropy_source = NULL;
|
entropy_source = NULL;
|
||||||
@ -361,25 +368,9 @@ fhandler_socket::dup (fhandler_base *child)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int __stdcall
|
int __stdcall
|
||||||
fhandler_socket::fstat (struct __stat64 *buf, path_conv *pc)
|
fhandler_socket::fstat (struct __stat64 *buf)
|
||||||
{
|
{
|
||||||
int res;
|
int res = fhandler_base::fstat (buf);
|
||||||
if (get_addr_family () == AF_LOCAL && get_sun_path () && !get_socket_type ())
|
|
||||||
{
|
|
||||||
path_conv spc (get_sun_path (), PC_SYM_NOFOLLOW | PC_NULLEMPTY | PC_FULL,
|
|
||||||
NULL);
|
|
||||||
fhandler_base *fh = cygheap->fdtab.build_fhandler (-1, FH_DISK,
|
|
||||||
get_sun_path (),
|
|
||||||
spc, 0);
|
|
||||||
if (fh)
|
|
||||||
{
|
|
||||||
res = fh->fstat (buf, &spc);
|
|
||||||
buf->st_rdev = buf->st_size = buf->st_blocks = 0;
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
res = fhandler_base::fstat (buf, pc);
|
|
||||||
if (!res)
|
if (!res)
|
||||||
{
|
{
|
||||||
if (get_socket_type ()) /* fstat */
|
if (get_socket_type ()) /* fstat */
|
||||||
@ -639,16 +630,13 @@ fhandler_socket::accept (struct sockaddr *peer, int *len)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
cygheap_fdnew res_fd;
|
cygheap_fdnew res_fd;
|
||||||
fhandler_socket* res_fh = NULL;
|
if (res_fd >= 0 && fdsock (res_fd, &dev (), res))
|
||||||
if (res_fd >= 0)
|
{
|
||||||
res_fh = fdsock (res_fd, get_name (), res);
|
|
||||||
if (res_fh)
|
|
||||||
{
|
|
||||||
if (get_addr_family () == AF_LOCAL)
|
if (get_addr_family () == AF_LOCAL)
|
||||||
res_fh->set_sun_path (get_sun_path ());
|
((fhandler_socket *) res_fd)->set_sun_path (get_sun_path ());
|
||||||
res_fh->set_addr_family (get_addr_family ());
|
((fhandler_socket *) res_fd)->set_addr_family (get_addr_family ());
|
||||||
res_fh->set_socket_type (get_socket_type ());
|
((fhandler_socket *) res_fd)->set_socket_type (get_socket_type ());
|
||||||
res_fh->set_connect_state (CONNECTED);
|
((fhandler_socket *) res_fd)->set_connect_state (CONNECTED);
|
||||||
res = res_fd;
|
res = res_fd;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -658,6 +646,7 @@ fhandler_socket::accept (struct sockaddr *peer, int *len)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
debug_printf ("res %d", res);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,8 +16,8 @@ details. */
|
|||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "perprocess.h"
|
#include "perprocess.h"
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include "fhandler.h"
|
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
|
|
||||||
@ -52,20 +52,20 @@ fhandler_dev_tape::is_eof (int win_error)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
fhandler_dev_tape::fhandler_dev_tape (int unit)
|
fhandler_dev_tape::fhandler_dev_tape ()
|
||||||
: fhandler_dev_raw (FH_TAPE, unit)
|
: fhandler_dev_raw ()
|
||||||
{
|
{
|
||||||
debug_printf ("unit: %d", unit);
|
debug_printf ("unit: %d", dev ().minor);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
fhandler_dev_tape::open (path_conv *real_path, int flags, mode_t)
|
fhandler_dev_tape::open (int flags, mode_t)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
devbufsiz = 1L;
|
devbufsiz = 1L;
|
||||||
|
|
||||||
ret = fhandler_dev_raw::open (real_path, flags);
|
ret = fhandler_dev_raw::open (flags);
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
struct mtget get;
|
struct mtget get;
|
||||||
@ -88,7 +88,7 @@ fhandler_dev_tape::open (path_conv *real_path, int flags, mode_t)
|
|||||||
* returns ERROR_NO_DATA_DETECTED. After media change, all subsequent
|
* returns ERROR_NO_DATA_DETECTED. After media change, all subsequent
|
||||||
* ReadFile calls return ERROR_NO_DATA_DETECTED, too.
|
* ReadFile calls return ERROR_NO_DATA_DETECTED, too.
|
||||||
* The call to tape_set_pos seems to reset some internal flags. */
|
* The call to tape_set_pos seems to reset some internal flags. */
|
||||||
if ((! ioctl (MTIOCPOS, &pos)) && (! pos.mt_blkno))
|
if ((!ioctl (MTIOCPOS, &pos)) && (!pos.mt_blkno))
|
||||||
{
|
{
|
||||||
op.mt_op = MTREW;
|
op.mt_op = MTREW;
|
||||||
ioctl (MTIOCTOP, &op);
|
ioctl (MTIOCTOP, &op);
|
||||||
@ -145,11 +145,11 @@ fhandler_dev_tape::close (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
fhandler_dev_tape::fstat (struct __stat64 *buf, path_conv *pc)
|
fhandler_dev_tape::fstat (struct __stat64 *buf)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!(ret = fhandler_base::fstat (buf, pc)))
|
if (!(ret = fhandler_base::fstat (buf)))
|
||||||
{
|
{
|
||||||
struct mtget get;
|
struct mtget get;
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ details. */
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
|
#include "path.h"
|
||||||
#include "fhandler.h"
|
#include "fhandler.h"
|
||||||
#include "sigproc.h"
|
#include "sigproc.h"
|
||||||
#include "pinfo.h"
|
#include "pinfo.h"
|
||||||
|
@ -18,8 +18,8 @@ details. */
|
|||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include "fhandler.h"
|
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
#include "sigproc.h"
|
#include "sigproc.h"
|
||||||
#include "pinfo.h"
|
#include "pinfo.h"
|
||||||
@ -36,11 +36,17 @@ static DWORD WINAPI process_input (void *); // Input queue thread
|
|||||||
static DWORD WINAPI process_output (void *); // Output queue thread
|
static DWORD WINAPI process_output (void *); // Output queue thread
|
||||||
static DWORD WINAPI process_ioctl (void *); // Ioctl requests thread
|
static DWORD WINAPI process_ioctl (void *); // Ioctl requests thread
|
||||||
|
|
||||||
fhandler_tty_master::fhandler_tty_master (int unit)
|
fhandler_tty_master::fhandler_tty_master ()
|
||||||
: fhandler_pty_master (FH_TTYM, unit), console (NULL)
|
: fhandler_pty_master (), console (NULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
fhandler_tty_slave::get_unit ()
|
||||||
|
{
|
||||||
|
return dev () == FH_TTY ? myself->ctty : dev ().minor;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
fhandler_tty_master::set_winsize (bool sendSIGWINCH)
|
fhandler_tty_master::set_winsize (bool sendSIGWINCH)
|
||||||
{
|
{
|
||||||
@ -52,9 +58,11 @@ fhandler_tty_master::set_winsize (bool sendSIGWINCH)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
fhandler_tty_master::init (int ntty)
|
fhandler_tty_master::init ()
|
||||||
{
|
{
|
||||||
termios_printf ("Creating master for tty%d", ntty);
|
termios_printf ("Creating master for tty%d", get_unit ());
|
||||||
|
|
||||||
|
slave = dev ();
|
||||||
|
|
||||||
if (init_console ())
|
if (init_console ())
|
||||||
{
|
{
|
||||||
@ -66,9 +74,7 @@ fhandler_tty_master::init (int ntty)
|
|||||||
memset (&ti, 0, sizeof (ti));
|
memset (&ti, 0, sizeof (ti));
|
||||||
console->tcsetattr (0, &ti);
|
console->tcsetattr (0, &ti);
|
||||||
|
|
||||||
ttynum = ntty;
|
cygwin_shared->tty[get_unit ()]->common_init (this);
|
||||||
|
|
||||||
cygwin_shared->tty[ttynum]->common_init (this);
|
|
||||||
|
|
||||||
set_winsize (false);
|
set_winsize (false);
|
||||||
|
|
||||||
@ -431,14 +437,8 @@ process_ioctl (void *)
|
|||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
/* Tty slave stuff */
|
/* Tty slave stuff */
|
||||||
|
|
||||||
fhandler_tty_slave::fhandler_tty_slave (int num)
|
|
||||||
: fhandler_tty_common (FH_TTYS, num)
|
|
||||||
{
|
|
||||||
set_r_no_interrupt (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
fhandler_tty_slave::fhandler_tty_slave ()
|
fhandler_tty_slave::fhandler_tty_slave ()
|
||||||
: fhandler_tty_common (FH_TTYS, 0)
|
: fhandler_tty_common ()
|
||||||
{
|
{
|
||||||
set_r_no_interrupt (1);
|
set_r_no_interrupt (1);
|
||||||
}
|
}
|
||||||
@ -446,12 +446,12 @@ fhandler_tty_slave::fhandler_tty_slave ()
|
|||||||
/* FIXME: This function needs to close handles when it has
|
/* FIXME: This function needs to close handles when it has
|
||||||
a failing condition. */
|
a failing condition. */
|
||||||
int
|
int
|
||||||
fhandler_tty_slave::open (path_conv *, int flags, mode_t)
|
fhandler_tty_slave::open (int flags, mode_t)
|
||||||
{
|
{
|
||||||
tcinit (cygwin_shared->tty[ttynum]);
|
tcinit (cygwin_shared->tty[get_unit ()]);
|
||||||
|
|
||||||
attach_tty (ttynum);
|
attach_tty (get_unit ());
|
||||||
tc->set_ctty (ttynum, flags);
|
tc->set_ctty (get_unit (), flags);
|
||||||
|
|
||||||
set_flags ((flags & ~O_TEXT) | O_BINARY);
|
set_flags ((flags & ~O_TEXT) | O_BINARY);
|
||||||
/* Create synchronisation events */
|
/* Create synchronisation events */
|
||||||
@ -462,7 +462,7 @@ fhandler_tty_slave::open (path_conv *, int flags, mode_t)
|
|||||||
startup if use_tty is non-zero. It will not exist if this is a
|
startup if use_tty is non-zero. It will not exist if this is a
|
||||||
pty opened by fhandler_pty_master::open. In the former case, tty
|
pty opened by fhandler_pty_master::open. In the former case, tty
|
||||||
output is handled by a separate thread which controls output. */
|
output is handled by a separate thread which controls output. */
|
||||||
__small_sprintf (buf, OUTPUT_DONE_EVENT, ttynum);
|
__small_sprintf (buf, OUTPUT_DONE_EVENT, get_unit ());
|
||||||
output_done_event = OpenEvent (EVENT_ALL_ACCESS, TRUE, buf);
|
output_done_event = OpenEvent (EVENT_ALL_ACCESS, TRUE, buf);
|
||||||
|
|
||||||
if (!(output_mutex = get_ttyp ()->open_output_mutex ()))
|
if (!(output_mutex = get_ttyp ()->open_output_mutex ()))
|
||||||
@ -477,7 +477,7 @@ fhandler_tty_slave::open (path_conv *, int flags, mode_t)
|
|||||||
__seterrno ();
|
__seterrno ();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
__small_sprintf (buf, INPUT_AVAILABLE_EVENT, ttynum);
|
__small_sprintf (buf, INPUT_AVAILABLE_EVENT, get_unit ());
|
||||||
if (!(input_available_event = OpenEvent (EVENT_ALL_ACCESS, TRUE, buf)))
|
if (!(input_available_event = OpenEvent (EVENT_ALL_ACCESS, TRUE, buf)))
|
||||||
{
|
{
|
||||||
termios_printf ("open input event failed, %E");
|
termios_printf ("open input event failed, %E");
|
||||||
@ -487,9 +487,9 @@ fhandler_tty_slave::open (path_conv *, int flags, mode_t)
|
|||||||
|
|
||||||
/* The ioctl events may or may not exist. See output_done_event,
|
/* The ioctl events may or may not exist. See output_done_event,
|
||||||
above. */
|
above. */
|
||||||
__small_sprintf (buf, IOCTL_REQUEST_EVENT, ttynum);
|
__small_sprintf (buf, IOCTL_REQUEST_EVENT, get_unit ());
|
||||||
ioctl_request_event = OpenEvent (EVENT_ALL_ACCESS, TRUE, buf);
|
ioctl_request_event = OpenEvent (EVENT_ALL_ACCESS, TRUE, buf);
|
||||||
__small_sprintf (buf, IOCTL_DONE_EVENT, ttynum);
|
__small_sprintf (buf, IOCTL_DONE_EVENT, get_unit ());
|
||||||
ioctl_done_event = OpenEvent (EVENT_ALL_ACCESS, TRUE, buf);
|
ioctl_done_event = OpenEvent (EVENT_ALL_ACCESS, TRUE, buf);
|
||||||
|
|
||||||
/* FIXME: Needs a method to eliminate tty races */
|
/* FIXME: Needs a method to eliminate tty races */
|
||||||
@ -525,7 +525,7 @@ fhandler_tty_slave::open (path_conv *, int flags, mode_t)
|
|||||||
if (tty_owner == NULL)
|
if (tty_owner == NULL)
|
||||||
{
|
{
|
||||||
termios_printf ("can't open tty (%d) handle process %d",
|
termios_printf ("can't open tty (%d) handle process %d",
|
||||||
ttynum, get_ttyp ()->master_pid);
|
get_unit (), get_ttyp ()->master_pid);
|
||||||
__seterrno ();
|
__seterrno ();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -577,7 +577,7 @@ fhandler_tty_slave::open (path_conv *, int flags, mode_t)
|
|||||||
init_console_handler ();
|
init_console_handler ();
|
||||||
}
|
}
|
||||||
termios_printf ("incremented open_fhs %d", fhandler_console::open_fhs);
|
termios_printf ("incremented open_fhs %d", fhandler_console::open_fhs);
|
||||||
termios_printf ("tty%d opened", ttynum);
|
termios_printf ("tty%d opened", get_unit ());
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -618,17 +618,17 @@ fhandler_tty_slave::cygserver_attach_tty (LPHANDLE from_master_ptr,
|
|||||||
void
|
void
|
||||||
fhandler_tty_slave::init (HANDLE, DWORD a, mode_t)
|
fhandler_tty_slave::init (HANDLE, DWORD a, mode_t)
|
||||||
{
|
{
|
||||||
int mode = 0;
|
int flags = 0;
|
||||||
|
|
||||||
a &= GENERIC_READ | GENERIC_WRITE;
|
a &= GENERIC_READ | GENERIC_WRITE;
|
||||||
if (a == GENERIC_READ)
|
if (a == GENERIC_READ)
|
||||||
mode = O_RDONLY;
|
flags = O_RDONLY;
|
||||||
if (a == GENERIC_WRITE)
|
if (a == GENERIC_WRITE)
|
||||||
mode = O_WRONLY;
|
flags = O_WRONLY;
|
||||||
if (a == (GENERIC_READ | GENERIC_WRITE))
|
if (a == (GENERIC_READ | GENERIC_WRITE))
|
||||||
mode = O_RDWR;
|
flags = O_RDWR;
|
||||||
|
|
||||||
open (0, mode);
|
open (flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -636,7 +636,7 @@ fhandler_tty_slave::write (const void *ptr, size_t len)
|
|||||||
{
|
{
|
||||||
DWORD n, towrite = len;
|
DWORD n, towrite = len;
|
||||||
|
|
||||||
termios_printf ("tty%d, write(%x, %d)", ttynum, ptr, len);
|
termios_printf ("tty%d, write(%x, %d)", get_unit (), ptr, len);
|
||||||
|
|
||||||
acquire_output_mutex (INFINITE);
|
acquire_output_mutex (INFINITE);
|
||||||
|
|
||||||
@ -882,11 +882,10 @@ fhandler_tty_common::dup (fhandler_base *child)
|
|||||||
fhandler_tty_slave *fts = (fhandler_tty_slave *) child;
|
fhandler_tty_slave *fts = (fhandler_tty_slave *) child;
|
||||||
int errind;
|
int errind;
|
||||||
|
|
||||||
fts->ttynum = ttynum;
|
|
||||||
fts->tcinit (get_ttyp ());
|
fts->tcinit (get_ttyp ());
|
||||||
|
|
||||||
attach_tty (ttynum);
|
attach_tty (get_unit ());
|
||||||
tc->set_ctty (ttynum, openflags);
|
tc->set_ctty (get_unit (), openflags);
|
||||||
|
|
||||||
HANDLE nh;
|
HANDLE nh;
|
||||||
|
|
||||||
@ -1017,7 +1016,7 @@ fhandler_tty_slave::ioctl (unsigned int cmd, void *arg)
|
|||||||
termios_printf ("ioctl (%x)", cmd);
|
termios_printf ("ioctl (%x)", cmd);
|
||||||
|
|
||||||
if (myself->pgid && get_ttyp ()->getpgid () != myself->pgid
|
if (myself->pgid && get_ttyp ()->getpgid () != myself->pgid
|
||||||
&& myself->ctty == ttynum && (get_ttyp ()->ti.c_lflag & TOSTOP))
|
&& myself->ctty == get_unit () && (get_ttyp ()->ti.c_lflag & TOSTOP))
|
||||||
{
|
{
|
||||||
/* background process */
|
/* background process */
|
||||||
termios_printf ("bg ioctl pgid %d, tpgid %d, ctty %d",
|
termios_printf ("bg ioctl pgid %d, tpgid %d, ctty %d",
|
||||||
@ -1084,24 +1083,26 @@ out:
|
|||||||
/*******************************************************
|
/*******************************************************
|
||||||
fhandler_pty_master
|
fhandler_pty_master
|
||||||
*/
|
*/
|
||||||
fhandler_pty_master::fhandler_pty_master (DWORD devtype, int unit)
|
fhandler_pty_master::fhandler_pty_master ()
|
||||||
: fhandler_tty_common (devtype, unit)
|
: fhandler_tty_common ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
fhandler_pty_master::open (path_conv *, int flags, mode_t)
|
fhandler_pty_master::open (int flags, mode_t)
|
||||||
{
|
{
|
||||||
ttynum = cygwin_shared->tty.allocate_tty (0);
|
int ntty = cygwin_shared->tty.allocate_tty (0);
|
||||||
if (ttynum < 0)
|
if (ntty < 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
cygwin_shared->tty[ttynum]->common_init (this);
|
slave = *ttys_dev;
|
||||||
|
slave.setunit (ntty);
|
||||||
|
cygwin_shared->tty[ntty]->common_init (this);
|
||||||
inuse = get_ttyp ()->create_inuse (TTY_MASTER_ALIVE);
|
inuse = get_ttyp ()->create_inuse (TTY_MASTER_ALIVE);
|
||||||
set_flags ((flags & ~O_TEXT) | O_BINARY);
|
set_flags ((flags & ~O_TEXT) | O_BINARY);
|
||||||
set_open_status ();
|
set_open_status ();
|
||||||
|
|
||||||
termios_printf ("opened pty master tty%d<%p>", ttynum, this);
|
termios_printf ("opened pty master tty%d", get_unit ());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1136,7 +1137,7 @@ fhandler_tty_common::close ()
|
|||||||
termios_printf ("CloseHandle (get_output_handle ()<%p>), %E", get_output_handle ());
|
termios_printf ("CloseHandle (get_output_handle ()<%p>), %E", get_output_handle ());
|
||||||
|
|
||||||
inuse = NULL;
|
inuse = NULL;
|
||||||
termios_printf ("tty%d <%p,%p> closed", ttynum, get_handle (), get_output_handle ());
|
termios_printf ("tty%d <%p,%p> closed", get_unit (), get_handle (), get_output_handle ());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1151,7 +1152,7 @@ fhandler_pty_master::close ()
|
|||||||
|
|
||||||
if (!get_ttyp ()->master_alive ())
|
if (!get_ttyp ()->master_alive ())
|
||||||
{
|
{
|
||||||
termios_printf ("freeing tty%d (%d)", ttynum, get_ttyp ()->ntty);
|
termios_printf ("freeing tty%d (%d)", get_unit (), get_ttyp ()->ntty);
|
||||||
#if 0
|
#if 0
|
||||||
if (get_ttyp ()->to_slave)
|
if (get_ttyp ()->to_slave)
|
||||||
ForceCloseHandle1 (get_ttyp ()->to_slave, to_slave);
|
ForceCloseHandle1 (get_ttyp ()->to_slave, to_slave);
|
||||||
@ -1198,14 +1199,14 @@ fhandler_pty_master::read (void *ptr, size_t& len)
|
|||||||
int
|
int
|
||||||
fhandler_pty_master::tcgetattr (struct termios *t)
|
fhandler_pty_master::tcgetattr (struct termios *t)
|
||||||
{
|
{
|
||||||
*t = cygwin_shared->tty[ttynum]->ti;
|
*t = cygwin_shared->tty[get_unit ()]->ti;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
fhandler_pty_master::tcsetattr (int, const struct termios *t)
|
fhandler_pty_master::tcsetattr (int, const struct termios *t)
|
||||||
{
|
{
|
||||||
cygwin_shared->tty[ttynum]->ti = *t;
|
cygwin_shared->tty[get_unit ()]->ti = *t;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1257,11 +1258,11 @@ fhandler_pty_master::ioctl (unsigned int cmd, void *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
fhandler_pty_master::ptsname (void)
|
fhandler_pty_master::ptsname ()
|
||||||
{
|
{
|
||||||
static char buf[32];
|
static char buf[32];
|
||||||
|
|
||||||
__small_sprintf (buf, "/dev/tty%d", ttynum);
|
__small_sprintf (buf, "/dev/tty%d", get_unit ());
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1350,7 +1351,7 @@ fhandler_tty_master::fixup_after_exec (HANDLE)
|
|||||||
int
|
int
|
||||||
fhandler_tty_master::init_console ()
|
fhandler_tty_master::init_console ()
|
||||||
{
|
{
|
||||||
console = (fhandler_console *) cygheap->fdtab.build_fhandler (-1, FH_CONSOLE, "/dev/ttym");
|
console = (fhandler_console *) build_fh_dev (*console_dev, "/dev/ttym");
|
||||||
if (console == NULL)
|
if (console == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
@ -14,8 +14,8 @@ details. */
|
|||||||
#include <sys/cygwin.h>
|
#include <sys/cygwin.h>
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include "fhandler.h"
|
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
#include "shared_info.h"
|
#include "shared_info.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
@ -23,8 +23,8 @@ details. */
|
|||||||
|
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
|
||||||
fhandler_virtual::fhandler_virtual (DWORD devtype):
|
fhandler_virtual::fhandler_virtual ():
|
||||||
fhandler_base (devtype), filebuf (NULL), bufalloc ((size_t) -1),
|
fhandler_base (), filebuf (NULL), bufalloc ((size_t) -1),
|
||||||
fileid (-1)
|
fileid (-1)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -44,7 +44,7 @@ fhandler_virtual::fixup_after_exec (HANDLE)
|
|||||||
}
|
}
|
||||||
|
|
||||||
DIR *
|
DIR *
|
||||||
fhandler_virtual::opendir (path_conv& pc)
|
fhandler_virtual::opendir ()
|
||||||
{
|
{
|
||||||
DIR *dir;
|
DIR *dir;
|
||||||
DIR *res = NULL;
|
DIR *res = NULL;
|
||||||
@ -205,7 +205,7 @@ fhandler_virtual::write (const void *ptr, size_t len)
|
|||||||
|
|
||||||
/* low-level open for all proc files */
|
/* low-level open for all proc files */
|
||||||
int
|
int
|
||||||
fhandler_virtual::open (path_conv *, int flags, mode_t mode)
|
fhandler_virtual::open (int flags, mode_t mode)
|
||||||
{
|
{
|
||||||
set_r_binary (1);
|
set_r_binary (1);
|
||||||
set_w_binary (1);
|
set_w_binary (1);
|
||||||
|
@ -16,6 +16,7 @@ details. */
|
|||||||
#include <winuser.h>
|
#include <winuser.h>
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
|
#include "path.h"
|
||||||
#include "fhandler.h"
|
#include "fhandler.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -46,12 +47,12 @@ The following unix-style calls are supported:
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
fhandler_windows::fhandler_windows ()
|
fhandler_windows::fhandler_windows ()
|
||||||
: fhandler_base (FH_WINDOWS), hWnd_ (NULL), method_ (WINDOWS_POST)
|
: fhandler_base (), hWnd_ (NULL), method_ (WINDOWS_POST)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
fhandler_windows::open (path_conv *, int flags, mode_t)
|
fhandler_windows::open (int flags, mode_t)
|
||||||
{
|
{
|
||||||
set_flags ((flags & ~O_TEXT) | O_BINARY);
|
set_flags ((flags & ~O_TEXT) | O_BINARY);
|
||||||
set_close_on_exec_flag (1);
|
set_close_on_exec_flag (1);
|
||||||
|
@ -13,15 +13,16 @@ details. */
|
|||||||
#include "winsup.h"
|
#include "winsup.h"
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
|
#include "path.h"
|
||||||
#include "fhandler.h"
|
#include "fhandler.h"
|
||||||
|
|
||||||
fhandler_dev_zero::fhandler_dev_zero ()
|
fhandler_dev_zero::fhandler_dev_zero ()
|
||||||
: fhandler_base (FH_ZERO)
|
: fhandler_base ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
fhandler_dev_zero::open (path_conv *, int flags, mode_t)
|
fhandler_dev_zero::open (int flags, mode_t)
|
||||||
{
|
{
|
||||||
set_flags ((flags & ~O_TEXT) | O_BINARY);
|
set_flags ((flags & ~O_TEXT) | O_BINARY);
|
||||||
set_nohandle (true);
|
set_nohandle (true);
|
||||||
|
@ -14,8 +14,8 @@ details. */
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include "fhandler.h"
|
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "sigproc.h"
|
#include "sigproc.h"
|
||||||
|
@ -18,8 +18,8 @@ details. */
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "pinfo.h"
|
#include "pinfo.h"
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include "fhandler.h"
|
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
|
@ -15,8 +15,8 @@ details. */
|
|||||||
#include "heap.h"
|
#include "heap.h"
|
||||||
#include "shared_info.h"
|
#include "shared_info.h"
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include "fhandler.h"
|
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
#include "registry.h"
|
#include "registry.h"
|
||||||
|
@ -101,7 +101,7 @@ typedef __ino32_t ino_t;
|
|||||||
|
|
||||||
#ifndef __key_t_defined
|
#ifndef __key_t_defined
|
||||||
#define __key_t_defined
|
#define __key_t_defined
|
||||||
typedef long long key_t;
|
typedef long key_t;
|
||||||
#endif /* __key_t_defined */
|
#endif /* __key_t_defined */
|
||||||
|
|
||||||
#ifndef __BIT_TYPES_DEFINED
|
#ifndef __BIT_TYPES_DEFINED
|
||||||
|
@ -15,8 +15,8 @@ details. */
|
|||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include "fhandler.h"
|
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
#include "sigproc.h"
|
#include "sigproc.h"
|
||||||
|
@ -15,8 +15,8 @@ details. */
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include "fhandler.h"
|
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
|
@ -14,8 +14,8 @@ details. */
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include "fhandler.h"
|
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
@ -56,31 +56,31 @@ class mmap_record
|
|||||||
private:
|
private:
|
||||||
int fdesc_;
|
int fdesc_;
|
||||||
HANDLE mapping_handle_;
|
HANDLE mapping_handle_;
|
||||||
int devtype_;
|
|
||||||
DWORD access_mode_;
|
DWORD access_mode_;
|
||||||
_off64_t offset_;
|
_off64_t offset_;
|
||||||
DWORD size_to_map_;
|
DWORD size_to_map_;
|
||||||
caddr_t base_address_;
|
caddr_t base_address_;
|
||||||
DWORD *page_map_;
|
DWORD *page_map_;
|
||||||
|
device dev;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
mmap_record (int fd, HANDLE h, DWORD ac, _off64_t o, DWORD s, caddr_t b) :
|
mmap_record (int fd, HANDLE h, DWORD ac, _off64_t o, DWORD s, caddr_t b) :
|
||||||
fdesc_ (fd),
|
fdesc_ (fd),
|
||||||
mapping_handle_ (h),
|
mapping_handle_ (h),
|
||||||
devtype_ (0),
|
|
||||||
access_mode_ (ac),
|
access_mode_ (ac),
|
||||||
offset_ (o),
|
offset_ (o),
|
||||||
size_to_map_ (s),
|
size_to_map_ (s),
|
||||||
base_address_ (b),
|
base_address_ (b),
|
||||||
page_map_ (NULL)
|
page_map_ (NULL)
|
||||||
{
|
{
|
||||||
|
dev.devn = 0;
|
||||||
if (fd >= 0 && !cygheap->fdtab.not_open (fd))
|
if (fd >= 0 && !cygheap->fdtab.not_open (fd))
|
||||||
devtype_ = cygheap->fdtab[fd]->get_device ();
|
dev = cygheap->fdtab[fd]->dev ();
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_fd () const { return fdesc_; }
|
int get_fd () const { return fdesc_; }
|
||||||
HANDLE get_handle () const { return mapping_handle_; }
|
HANDLE get_handle () const { return mapping_handle_; }
|
||||||
DWORD get_device () const { return devtype_; }
|
device& get_device () { return dev; }
|
||||||
DWORD get_access () const { return access_mode_; }
|
DWORD get_access () const { return access_mode_; }
|
||||||
DWORD get_offset () const { return offset_; }
|
DWORD get_offset () const { return offset_; }
|
||||||
DWORD get_size () const { return size_to_map_; }
|
DWORD get_size () const { return size_to_map_; }
|
||||||
@ -295,12 +295,13 @@ mmap_record::alloc_fh ()
|
|||||||
return &fh_paging_file;
|
return &fh_paging_file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static path_conv pc; // should be thread safe - CGF
|
||||||
/* The file descriptor could have been closed or, even
|
/* The file descriptor could have been closed or, even
|
||||||
worse, could have been reused for another file before
|
worse, could have been reused for another file before
|
||||||
the call to fork(). This requires creating a fhandler
|
the call to fork(). This requires creating a fhandler
|
||||||
of the correct type to be sure to call the method of the
|
of the correct type to be sure to call the method of the
|
||||||
correct class. */
|
correct class. */
|
||||||
return cygheap->fdtab.build_fhandler (-1, get_device ());
|
return build_fh_dev (get_device ());
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -509,7 +510,7 @@ mmap64 (void *addr, size_t len, int prot, int flags, int fd, _off64_t off)
|
|||||||
return MAP_FAILED;
|
return MAP_FAILED;
|
||||||
}
|
}
|
||||||
fh = cfd;
|
fh = cfd;
|
||||||
if (fh->get_device () == FH_DISK)
|
if (fh->get_device () == FH_FS)
|
||||||
{
|
{
|
||||||
DWORD high;
|
DWORD high;
|
||||||
DWORD low = GetFileSize (fh->get_handle (), &high);
|
DWORD low = GetFileSize (fh->get_handle (), &high);
|
||||||
|
@ -28,8 +28,8 @@ details. */
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include "fhandler.h"
|
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
#include "sigproc.h"
|
#include "sigproc.h"
|
||||||
@ -617,8 +617,8 @@ cygwin_getprotobynumber (int number)
|
|||||||
return protoent_buf;
|
return protoent_buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
fhandler_socket *
|
bool
|
||||||
fdsock (int &fd, const char *name, SOCKET soc)
|
fdsock (cygheap_fdmanip& fd, const device *dev, SOCKET soc)
|
||||||
{
|
{
|
||||||
if (!winsock2_active)
|
if (!winsock2_active)
|
||||||
soc = set_socket_inheritance (soc);
|
soc = set_socket_inheritance (soc);
|
||||||
@ -632,16 +632,15 @@ fdsock (int &fd, const char *name, SOCKET soc)
|
|||||||
else
|
else
|
||||||
debug_printf ("not setting socket inheritance since winsock2_active %d",
|
debug_printf ("not setting socket inheritance since winsock2_active %d",
|
||||||
winsock2_active);
|
winsock2_active);
|
||||||
fhandler_socket *fh = (fhandler_socket *)
|
fd = build_fh_dev (*dev);
|
||||||
cygheap->fdtab.build_fhandler (fd, FH_SOCKET, name, NULL,
|
if (!fd.isopen ())
|
||||||
tolower (name[5]) - 'a');
|
return false;
|
||||||
if (!fh)
|
fd->set_io_handle ((HANDLE) soc);
|
||||||
return NULL;
|
fd->set_flags (O_RDWR | O_BINARY);
|
||||||
fh->set_io_handle ((HANDLE) soc);
|
fd->set_r_no_interrupt (winsock2_active);
|
||||||
fh->set_flags (O_RDWR | O_BINARY);
|
cygheap->fdtab.inc_need_fixup_before ();
|
||||||
fh->set_r_no_interrupt (winsock2_active);
|
debug_printf ("fd %d, name '%s', soc %p", (int) fd, dev->name, soc);
|
||||||
debug_printf ("fd %d, name '%s', soc %p", fd, name, soc);
|
return true;
|
||||||
return fh;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* exported as socket: standards? */
|
/* exported as socket: standards? */
|
||||||
@ -650,7 +649,6 @@ cygwin_socket (int af, int type, int protocol)
|
|||||||
{
|
{
|
||||||
int res = -1;
|
int res = -1;
|
||||||
SOCKET soc = 0;
|
SOCKET soc = 0;
|
||||||
fhandler_socket *fh = NULL;
|
|
||||||
|
|
||||||
debug_printf ("socket (%d, %d, %d)", af, type, protocol);
|
debug_printf ("socket (%d, %d, %d)", af, type, protocol);
|
||||||
|
|
||||||
@ -662,25 +660,23 @@ cygwin_socket (int af, int type, int protocol)
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *name;
|
const device *dev;
|
||||||
|
|
||||||
if (af == AF_INET)
|
if (af == AF_INET)
|
||||||
name = (type == SOCK_STREAM ? "/dev/tcp" : "/dev/udp");
|
dev = type == SOCK_STREAM ? tcp_dev : udp_dev;
|
||||||
else
|
else
|
||||||
name = (type == SOCK_STREAM ? "/dev/streamsocket" : "/dev/dgsocket");
|
dev = type == SOCK_STREAM ? stream_dev : dgram_dev;
|
||||||
|
|
||||||
{
|
{
|
||||||
cygheap_fdnew fd;
|
cygheap_fdnew fd;
|
||||||
if (fd >= 0)
|
if (fd < 0 || !fdsock (fd, dev, soc))
|
||||||
fh = fdsock (fd, name, soc);
|
closesocket (soc);
|
||||||
if (fh)
|
else
|
||||||
{
|
{
|
||||||
fh->set_addr_family (af);
|
((fhandler_socket *) fd)->set_addr_family (af);
|
||||||
fh->set_socket_type (type);
|
((fhandler_socket *) fd)->set_socket_type (type);
|
||||||
res = fd;
|
res = fd;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
closesocket (soc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
@ -1990,14 +1986,11 @@ cygwin_rcmd (char **ahost, unsigned short inport, char *locuser,
|
|||||||
res = rcmd (ahost, inport, locuser, remuser, cmd, fd2p ? &fd2s : NULL);
|
res = rcmd (ahost, inport, locuser, remuser, cmd, fd2p ? &fd2s : NULL);
|
||||||
if (res != (int) INVALID_SOCKET)
|
if (res != (int) INVALID_SOCKET)
|
||||||
{
|
{
|
||||||
fhandler_socket *fh = NULL;
|
|
||||||
cygheap_fdnew res_fd;
|
cygheap_fdnew res_fd;
|
||||||
|
|
||||||
if (res_fd >= 0)
|
if (res_fd >= 0 && fdsock (res_fd, tcp_dev, res))
|
||||||
fh = fdsock (res_fd, "/dev/tcp", res);
|
|
||||||
if (fh)
|
|
||||||
{
|
{
|
||||||
fh->set_connect_state (CONNECTED);
|
((fhandler_socket *) res_fd)->set_connect_state (CONNECTED);
|
||||||
res = res_fd;
|
res = res_fd;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -2009,14 +2002,12 @@ cygwin_rcmd (char **ahost, unsigned short inport, char *locuser,
|
|||||||
if (res >= 0 && fd2p)
|
if (res >= 0 && fd2p)
|
||||||
{
|
{
|
||||||
cygheap_fdnew newfd (res_fd, false);
|
cygheap_fdnew newfd (res_fd, false);
|
||||||
|
cygheap_fdget fd (*fd2p);
|
||||||
|
|
||||||
fh = NULL;
|
if (newfd >= 0 && fdsock (newfd, tcp_dev, fd2s))
|
||||||
if (newfd >= 0)
|
|
||||||
fh = fdsock (newfd, "/dev/tcp", fd2s);
|
|
||||||
if (fh)
|
|
||||||
{
|
{
|
||||||
*fd2p = newfd;
|
*fd2p = newfd;
|
||||||
fh->set_connect_state (CONNECTED);
|
((fhandler_socket *) fd2p)->set_connect_state (CONNECTED);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -2046,13 +2037,10 @@ cygwin_rresvport (int *port)
|
|||||||
|
|
||||||
if (res != (int) INVALID_SOCKET)
|
if (res != (int) INVALID_SOCKET)
|
||||||
{
|
{
|
||||||
fhandler_socket *fh = NULL;
|
|
||||||
cygheap_fdnew res_fd;
|
cygheap_fdnew res_fd;
|
||||||
|
|
||||||
if (res_fd >= 0)
|
if (res_fd >= 0 && fdsock (res_fd, tcp_dev, res))
|
||||||
fh = fdsock (res_fd, "/dev/tcp", res);
|
res = res_fd;
|
||||||
if (fh)
|
|
||||||
res = res_fd;
|
|
||||||
else
|
else
|
||||||
res = -1;
|
res = -1;
|
||||||
}
|
}
|
||||||
@ -2080,14 +2068,11 @@ cygwin_rexec (char **ahost, unsigned short inport, char *locuser,
|
|||||||
res = rexec (ahost, inport, locuser, password, cmd, fd2p ? &fd2s : NULL);
|
res = rexec (ahost, inport, locuser, password, cmd, fd2p ? &fd2s : NULL);
|
||||||
if (res != (int) INVALID_SOCKET)
|
if (res != (int) INVALID_SOCKET)
|
||||||
{
|
{
|
||||||
fhandler_socket *fh = NULL;
|
|
||||||
cygheap_fdnew res_fd;
|
cygheap_fdnew res_fd;
|
||||||
|
|
||||||
if (res_fd >= 0)
|
if (res_fd >= 0 && fdsock (res_fd, tcp_dev, res))
|
||||||
fh = fdsock (res_fd, "/dev/tcp", res);
|
|
||||||
if (fh)
|
|
||||||
{
|
{
|
||||||
fh->set_connect_state (CONNECTED);
|
((fhandler_socket *) res_fd)->set_connect_state (CONNECTED);
|
||||||
res = res_fd;
|
res = res_fd;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -2099,13 +2084,11 @@ cygwin_rexec (char **ahost, unsigned short inport, char *locuser,
|
|||||||
if (res >= 0 && fd2p)
|
if (res >= 0 && fd2p)
|
||||||
{
|
{
|
||||||
cygheap_fdnew newfd (res_fd, false);
|
cygheap_fdnew newfd (res_fd, false);
|
||||||
|
cygheap_fdget fd (*fd2p);
|
||||||
|
|
||||||
fh = NULL;
|
if (newfd >= 0 && fdsock (newfd, tcp_dev, fd2s))
|
||||||
if (newfd >= 0)
|
|
||||||
fh = fdsock (newfd, "/dev/tcp", fd2s);
|
|
||||||
if (fh)
|
|
||||||
{
|
{
|
||||||
fh->set_connect_state (CONNECTED);
|
((fhandler_socket *) fd2p)->set_connect_state (CONNECTED);
|
||||||
*fd2p = newfd;
|
*fd2p = newfd;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -2267,35 +2250,29 @@ socketpair (int family, int type, int protocol, int *sb)
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
fhandler_socket *fh = NULL;
|
|
||||||
cygheap_fdnew sb0;
|
cygheap_fdnew sb0;
|
||||||
const char *name;
|
const device *dev;
|
||||||
|
|
||||||
if (family == AF_INET)
|
if (family == AF_INET)
|
||||||
name = (type == SOCK_STREAM ? "/dev/tcp" : "/dev/udp");
|
dev = (type == SOCK_STREAM ? tcp_dev : udp_dev);
|
||||||
else
|
else
|
||||||
name = (type == SOCK_STREAM ? "/dev/streamsocket" : "/dev/dgsocket");
|
dev = (type == SOCK_STREAM ? stream_dev : dgram_dev);
|
||||||
|
|
||||||
if (sb0 >= 0)
|
if (sb0 >= 0 && fdsock (sb0, dev, insock))
|
||||||
fh = fdsock (sb0, name, insock);
|
|
||||||
if (fh)
|
|
||||||
{
|
{
|
||||||
fh->set_sun_path ("");
|
((fhandler_socket *) sb0)->set_sun_path ("");
|
||||||
fh->set_addr_family (family);
|
((fhandler_socket *) sb0)->set_addr_family (family);
|
||||||
fh->set_socket_type (type);
|
((fhandler_socket *) sb0)->set_socket_type (type);
|
||||||
fh->set_connect_state (CONNECTED);
|
((fhandler_socket *) sb0)->set_connect_state (CONNECTED);
|
||||||
|
|
||||||
cygheap_fdnew sb1 (sb0, false);
|
cygheap_fdnew sb1 (sb0, false);
|
||||||
|
|
||||||
fh = NULL;
|
if (sb1 >= 0 && fdsock (sb1, dev, outsock))
|
||||||
if (sb1 >= 0)
|
|
||||||
fh = fdsock (sb1, name, outsock);
|
|
||||||
if (fh)
|
|
||||||
{
|
{
|
||||||
fh->set_sun_path ("");
|
((fhandler_socket *) sb1)->set_sun_path ("");
|
||||||
fh->set_addr_family (family);
|
((fhandler_socket *) sb1)->set_addr_family (family);
|
||||||
fh->set_socket_type (type);
|
((fhandler_socket *) sb1)->set_socket_type (type);
|
||||||
fh->set_connect_state (CONNECTED);
|
((fhandler_socket *) sb1)->set_connect_state (CONNECTED);
|
||||||
|
|
||||||
sb[0] = sb0;
|
sb[0] = sb0;
|
||||||
sb[1] = sb1;
|
sb[1] = sb1;
|
||||||
|
@ -14,8 +14,8 @@ details. */
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include "fhandler.h"
|
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
#include "pinfo.h"
|
#include "pinfo.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
|
@ -63,8 +63,8 @@ details. */
|
|||||||
#include <cygwin/version.h>
|
#include <cygwin/version.h>
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include "fhandler.h"
|
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
#include "fhandler.h"
|
||||||
#include "sync.h"
|
#include "sync.h"
|
||||||
#include "sigproc.h"
|
#include "sigproc.h"
|
||||||
#include "pinfo.h"
|
#include "pinfo.h"
|
||||||
@ -97,7 +97,11 @@ struct symlink_info
|
|||||||
bool ext_tacked_on;
|
bool ext_tacked_on;
|
||||||
int error;
|
int error;
|
||||||
bool case_clash;
|
bool case_clash;
|
||||||
|
_major_t major;
|
||||||
|
_minor_t minor;
|
||||||
|
_mode_t mode;
|
||||||
int check (char *path, const suffix_info *suffixes, unsigned opt);
|
int check (char *path, const suffix_info *suffixes, unsigned opt);
|
||||||
|
bool parse_device (const char *);
|
||||||
BOOL case_check (char *path);
|
BOOL case_check (char *path);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -354,27 +358,27 @@ fs_info::update (const char *win32_path)
|
|||||||
if (!rootdir (tmp_buf))
|
if (!rootdir (tmp_buf))
|
||||||
{
|
{
|
||||||
debug_printf ("Cannot get root component of path %s", win32_path);
|
debug_printf ("Cannot get root component of path %s", win32_path);
|
||||||
name [0] = '\0';
|
name_storage [0] = '\0';
|
||||||
sym_opt = flags = serial = 0;
|
sym_opt_storage = flags_storage = serial_storage = 0;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp (tmp_buf, root_dir) == 0)
|
if (strcmp (tmp_buf, root_dir_storage) == 0)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
strncpy (root_dir, tmp_buf, MAX_PATH);
|
strncpy (root_dir_storage, tmp_buf, MAX_PATH);
|
||||||
drive_type = GetDriveType (root_dir);
|
drive_type_storage = GetDriveType (root_dir_storage);
|
||||||
if (drive_type == DRIVE_REMOTE || (drive_type == DRIVE_UNKNOWN && (root_dir[0] == '\\' && root_dir[1] == '\\')))
|
if (drive_type_storage == DRIVE_REMOTE || (drive_type_storage == DRIVE_UNKNOWN && (root_dir_storage[0] == '\\' && root_dir_storage[1] == '\\')))
|
||||||
is_remote_drive = 1;
|
is_remote_drive_storage = 1;
|
||||||
else
|
else
|
||||||
is_remote_drive = 0;
|
is_remote_drive_storage = 0;
|
||||||
|
|
||||||
if (!GetVolumeInformation (root_dir, NULL, 0, &serial, NULL, &flags,
|
if (!GetVolumeInformation (root_dir_storage, NULL, 0, &serial_storage, NULL, &flags_storage,
|
||||||
name, sizeof (name)))
|
name_storage, sizeof (name_storage)))
|
||||||
{
|
{
|
||||||
debug_printf ("Cannot get volume information (%s), %E", root_dir);
|
debug_printf ("Cannot get volume information (%s), %E", root_dir_storage);
|
||||||
name [0] = '\0';
|
name_storage[0] = '\0';
|
||||||
sym_opt = flags = serial = 0;
|
sym_opt_storage = flags_storage = serial_storage = 0;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
/* FIXME: Samba by default returns "NTFS" in file system name, but
|
/* FIXME: Samba by default returns "NTFS" in file system name, but
|
||||||
@ -382,19 +386,11 @@ fs_info::update (const char *win32_path)
|
|||||||
* distinguish between samba and real ntfs, it should be implemented
|
* distinguish between samba and real ntfs, it should be implemented
|
||||||
* here.
|
* here.
|
||||||
*/
|
*/
|
||||||
sym_opt = (!is_remote_drive && strcmp (name, "NTFS") == 0) ? PC_CHECK_EA : 0;
|
sym_opt_storage = (!is_remote_drive_storage && strcmp (name_storage, "NTFS") == 0) ? PC_CHECK_EA : 0;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
|
||||||
path_conv::return_and_clear_normalized_path ()
|
|
||||||
{
|
|
||||||
char *s = normalized_path;
|
|
||||||
normalized_path = NULL;
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
path_conv::fillin (HANDLE h)
|
path_conv::fillin (HANDLE h)
|
||||||
{
|
{
|
||||||
@ -402,14 +398,31 @@ path_conv::fillin (HANDLE h)
|
|||||||
if (!GetFileInformationByHandle (h, &local))
|
if (!GetFileInformationByHandle (h, &local))
|
||||||
{
|
{
|
||||||
fileattr = INVALID_FILE_ATTRIBUTES;
|
fileattr = INVALID_FILE_ATTRIBUTES;
|
||||||
fs.serial = 0;
|
fs.serial () = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fileattr = local.dwFileAttributes;
|
fileattr = local.dwFileAttributes;
|
||||||
fs.serial = local.dwVolumeSerialNumber;
|
fs.serial () = local.dwVolumeSerialNumber;
|
||||||
}
|
}
|
||||||
fs.drive_type = DRIVE_UNKNOWN;
|
fs.drive_type () = DRIVE_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
path_conv::set_normalized_path (const char *path_copy)
|
||||||
|
{
|
||||||
|
char *eopath = strchr (path, '\0');
|
||||||
|
size_t n = strlen (path_copy) + 1;
|
||||||
|
|
||||||
|
normalized_path = path + sizeof (path) - n;
|
||||||
|
if (normalized_path > eopath)
|
||||||
|
normalized_path_size = n;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
normalized_path = (char *) cmalloc (HEAP_STR, n);
|
||||||
|
normalized_path_size = 0;
|
||||||
|
}
|
||||||
|
memcpy (normalized_path, path_copy, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert an arbitrary path SRC to a pure Win32 path, suitable for
|
/* Convert an arbitrary path SRC to a pure Win32 path, suitable for
|
||||||
@ -457,13 +470,13 @@ path_conv::check (const char *src, unsigned opt,
|
|||||||
known_suffix = NULL;
|
known_suffix = NULL;
|
||||||
fileattr = INVALID_FILE_ATTRIBUTES;
|
fileattr = INVALID_FILE_ATTRIBUTES;
|
||||||
case_clash = false;
|
case_clash = false;
|
||||||
devn = unit = 0;
|
memset (&dev, 0, sizeof (dev));
|
||||||
fs.root_dir[0] = '\0';
|
fs.root_dir ()[0] = '\0';
|
||||||
fs.name[0] = '\0';
|
fs.name ()[0] = '\0';
|
||||||
fs.flags = fs.serial = 0;
|
fs.flags () = fs.serial () = 0;
|
||||||
fs.sym_opt = 0;
|
fs.sym_opt () = 0;
|
||||||
fs.drive_type = 0;
|
fs.drive_type () = 0;
|
||||||
fs.is_remote_drive = 0;
|
fs.is_remote_drive () = 0;
|
||||||
normalized_path = NULL;
|
normalized_path = NULL;
|
||||||
|
|
||||||
if (!(opt & PC_NULLEMPTY))
|
if (!(opt & PC_NULLEMPTY))
|
||||||
@ -528,29 +541,29 @@ path_conv::check (const char *src, unsigned opt,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Convert to native path spec sans symbolic link info. */
|
/* Convert to native path spec sans symbolic link info. */
|
||||||
error = mount_table->conv_to_win32_path (path_copy, full_path, devn,
|
error = mount_table->conv_to_win32_path (path_copy, full_path, dev,
|
||||||
unit, &sym.pflags, 1);
|
&sym.pflags, 1);
|
||||||
|
|
||||||
if (error)
|
if (error)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (devn == FH_CYGDRIVE)
|
if (dev.major == DEV_CYGDRIVE_MAJOR)
|
||||||
{
|
{
|
||||||
if (!component)
|
if (!component)
|
||||||
fileattr = FILE_ATTRIBUTE_DIRECTORY;
|
fileattr = FILE_ATTRIBUTE_DIRECTORY;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
devn = FH_BAD;
|
dev.devn = FH_FS;
|
||||||
fileattr = GetFileAttributes (this->path);
|
fileattr = GetFileAttributes (this->path);
|
||||||
}
|
}
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
else if (isvirtual_dev (devn))
|
else if (isvirtual_dev (dev.devn))
|
||||||
{
|
{
|
||||||
/* FIXME: Calling build_fhandler here is not the right way to handle this. */
|
/* FIXME: Calling build_fhandler here is not the right way to handle this. */
|
||||||
fhandler_virtual *fh =
|
fhandler_virtual *fh = (fhandler_virtual *) build_fh_dev (dev, path_copy);
|
||||||
(fhandler_virtual *) cygheap->fdtab.build_fhandler (-1, devn, (const char *) path_copy, NULL, unit);
|
|
||||||
int file_type = fh->exists ();
|
int file_type = fh->exists ();
|
||||||
|
delete fh;
|
||||||
switch (file_type)
|
switch (file_type)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
@ -564,11 +577,10 @@ path_conv::check (const char *src, unsigned opt,
|
|||||||
fileattr = INVALID_FILE_ATTRIBUTES;
|
fileattr = INVALID_FILE_ATTRIBUTES;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
delete fh;
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
/* devn should not be a device. If it is, then stop parsing now. */
|
/* devn should not be a device. If it is, then stop parsing now. */
|
||||||
else if (devn != FH_BAD)
|
else if (dev.devn != FH_FS)
|
||||||
{
|
{
|
||||||
fileattr = 0;
|
fileattr = 0;
|
||||||
path_flags = sym.pflags;
|
path_flags = sym.pflags;
|
||||||
@ -581,7 +593,7 @@ path_conv::check (const char *src, unsigned opt,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!fs.update (full_path))
|
if (!fs.update (full_path))
|
||||||
fs.root_dir[0] = '\0';
|
fs.root_dir ()[0] = '\0';
|
||||||
|
|
||||||
/* Eat trailing slashes */
|
/* Eat trailing slashes */
|
||||||
char *dostail = strchr (full_path, '\0');
|
char *dostail = strchr (full_path, '\0');
|
||||||
@ -605,7 +617,19 @@ path_conv::check (const char *src, unsigned opt,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
int len = sym.check (full_path, suff, opt | fs.sym_opt);
|
int len = sym.check (full_path, suff, opt | fs.sym_opt ());
|
||||||
|
|
||||||
|
if (sym.minor || sym.major)
|
||||||
|
{
|
||||||
|
dev.parse (sym.major, sym.minor);
|
||||||
|
dev.setfs (1);
|
||||||
|
dev.mode = sym.mode;
|
||||||
|
fileattr = sym.fileattr;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sym.pflags & PATH_SOCKET)
|
||||||
|
dev.setfs (1);
|
||||||
|
|
||||||
if (sym.case_clash)
|
if (sym.case_clash)
|
||||||
{
|
{
|
||||||
@ -757,12 +781,6 @@ path_conv::check (const char *src, unsigned opt,
|
|||||||
add_ext_from_sym (sym);
|
add_ext_from_sym (sym);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (opt & PC_POSIX)
|
|
||||||
{
|
|
||||||
if (tail[1] != '\0')
|
|
||||||
*tail = '/';
|
|
||||||
normalized_path = cstrdup (path_copy);
|
|
||||||
}
|
|
||||||
/* Deal with Windows stupidity which considers filename\. to be valid
|
/* Deal with Windows stupidity which considers filename\. to be valid
|
||||||
even when "filename" is not a directory. */
|
even when "filename" is not a directory. */
|
||||||
if (!need_directory || error)
|
if (!need_directory || error)
|
||||||
@ -776,11 +794,11 @@ out:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (devn == FH_BAD)
|
if (dev.devn == FH_FS)
|
||||||
{
|
{
|
||||||
if (!fs.update (path))
|
if (!fs.update (path))
|
||||||
{
|
{
|
||||||
fs.root_dir[0] = '\0';
|
fs.root_dir ()[0] = '\0';
|
||||||
set_has_acls (false); // already implied but...
|
set_has_acls (false); // already implied but...
|
||||||
set_has_buggy_open (false); // ditto
|
set_has_buggy_open (false); // ditto
|
||||||
}
|
}
|
||||||
@ -788,8 +806,8 @@ out:
|
|||||||
{
|
{
|
||||||
set_isdisk ();
|
set_isdisk ();
|
||||||
debug_printf ("root_dir(%s), this->path(%s), set_has_acls(%d)",
|
debug_printf ("root_dir(%s), this->path(%s), set_has_acls(%d)",
|
||||||
fs.root_dir, this->path, fs.flags & FS_PERSISTENT_ACLS);
|
fs.root_dir (), this->path, fs.flags () & FS_PERSISTENT_ACLS);
|
||||||
if (!(fs.flags & FS_PERSISTENT_ACLS) || (!allow_smbntsec && fs.is_remote_drive))
|
if (!(fs.flags () & FS_PERSISTENT_ACLS) || (!allow_smbntsec && fs.is_remote_drive ()))
|
||||||
set_has_acls (false);
|
set_has_acls (false);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -801,7 +819,7 @@ out:
|
|||||||
}
|
}
|
||||||
/* Known file systems with buggy open calls. Further explanation
|
/* Known file systems with buggy open calls. Further explanation
|
||||||
in fhandler.cc (fhandler_disk_file::open). */
|
in fhandler.cc (fhandler_disk_file::open). */
|
||||||
set_has_buggy_open (strcmp (fs.name, "SUNWNFS") == 0);
|
set_has_buggy_open (strcmp (fs.name (), "SUNWNFS") == 0);
|
||||||
}
|
}
|
||||||
if (exec_state () != dont_know_if_executable)
|
if (exec_state () != dont_know_if_executable)
|
||||||
/* ok */;
|
/* ok */;
|
||||||
@ -810,8 +828,11 @@ out:
|
|||||||
else if (issymlink () || issocket ())
|
else if (issymlink () || issocket ())
|
||||||
set_exec (0);
|
set_exec (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
if (issocket ())
|
if (issocket ())
|
||||||
devn = FH_SOCKET;
|
devn = FH_SOCKET;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!(opt & PC_FULL))
|
if (!(opt & PC_FULL))
|
||||||
{
|
{
|
||||||
@ -844,6 +865,15 @@ out:
|
|||||||
path_flags |= PATH_EXEC;
|
path_flags |= PATH_EXEC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!(opt & PC_POSIX))
|
||||||
|
normalized_path_size = 0;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (tail[1] != '\0')
|
||||||
|
*tail = '/';
|
||||||
|
set_normalized_path (path_copy);
|
||||||
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if (!error)
|
if (!error)
|
||||||
{
|
{
|
||||||
@ -862,293 +892,30 @@ digits (const char *name)
|
|||||||
return p > name && !*p ? n : -1;
|
return p > name && !*p ? n : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *windows_device_names[] NO_COPY =
|
|
||||||
{
|
|
||||||
NULL,
|
|
||||||
"\\dev\\console",
|
|
||||||
"conin",
|
|
||||||
"conout",
|
|
||||||
"\\dev\\ttym",
|
|
||||||
"\\dev\\tty%d",
|
|
||||||
"\\dev\\ptym",
|
|
||||||
"\\\\.\\com%d",
|
|
||||||
"\\dev\\pipe",
|
|
||||||
"\\dev\\piper",
|
|
||||||
"\\dev\\pipew",
|
|
||||||
"\\dev\\socket",
|
|
||||||
"\\dev\\windows",
|
|
||||||
|
|
||||||
NULL, NULL, NULL,
|
|
||||||
|
|
||||||
"\\dev\\disk",
|
|
||||||
"\\dev\\fd%d",
|
|
||||||
"\\dev\\st%d",
|
|
||||||
"nul",
|
|
||||||
"\\dev\\zero",
|
|
||||||
"\\dev\\%srandom",
|
|
||||||
"\\dev\\mem",
|
|
||||||
"\\dev\\clipboard",
|
|
||||||
"\\dev\\dsp"
|
|
||||||
};
|
|
||||||
|
|
||||||
#define deveq(s) (strcasematch (name, (s)))
|
|
||||||
#define deveqn(s, n) (strncasematch (name, (s), (n)))
|
|
||||||
#define wdeveq(s) (strcasematch (w32_path, (s)))
|
|
||||||
#define wdeveqn(s, n) (strncasematch (w32_path, (s), (n)))
|
|
||||||
#define udeveq(s) (strcasematch (unix_path, (s)))
|
|
||||||
#define udeveqn(s, n) (strncasematch (unix_path, (s), (n)))
|
|
||||||
|
|
||||||
static int __stdcall
|
|
||||||
get_devn (const char *name, int &unit)
|
|
||||||
{
|
|
||||||
int devn = FH_BAD;
|
|
||||||
name += 5;
|
|
||||||
if (deveq ("tty"))
|
|
||||||
{
|
|
||||||
if (real_tty_attached (myself))
|
|
||||||
{
|
|
||||||
unit = myself->ctty;
|
|
||||||
devn = FH_TTYS;
|
|
||||||
}
|
|
||||||
else if (myself->ctty > 0)
|
|
||||||
devn = FH_CONSOLE;
|
|
||||||
}
|
|
||||||
else if (deveqn ("tty", 3) && (unit = digits (name + 3)) >= 0)
|
|
||||||
devn = FH_TTYS;
|
|
||||||
else if (deveq ("ttym"))
|
|
||||||
devn = FH_TTYM;
|
|
||||||
else if (deveq ("ptmx"))
|
|
||||||
devn = FH_PTYM;
|
|
||||||
else if (deveq ("windows"))
|
|
||||||
devn = FH_WINDOWS;
|
|
||||||
else if (deveq ("dsp"))
|
|
||||||
devn = FH_OSS_DSP;
|
|
||||||
else if (deveq ("conin"))
|
|
||||||
devn = FH_CONIN;
|
|
||||||
else if (deveq ("conout"))
|
|
||||||
devn = FH_CONOUT;
|
|
||||||
else if (deveq ("null"))
|
|
||||||
devn = FH_NULL;
|
|
||||||
else if (deveq ("zero"))
|
|
||||||
devn = FH_ZERO;
|
|
||||||
else if (deveq ("random") || deveq ("urandom"))
|
|
||||||
{
|
|
||||||
devn = FH_RANDOM;
|
|
||||||
unit = 8 + (deveqn ("u", 1) ? 1 : 0); /* Keep unit Linux conformant */
|
|
||||||
}
|
|
||||||
else if (deveq ("mem"))
|
|
||||||
{
|
|
||||||
devn = FH_MEM;
|
|
||||||
unit = 1;
|
|
||||||
}
|
|
||||||
else if (deveq ("clipboard"))
|
|
||||||
devn = FH_CLIPBOARD;
|
|
||||||
else if (deveq ("port"))
|
|
||||||
{
|
|
||||||
devn = FH_MEM;
|
|
||||||
unit = 4;
|
|
||||||
}
|
|
||||||
else if (deveqn ("com", 3) && (unit = digits (name + 3)) >= 0 && unit < 100)
|
|
||||||
devn = FH_SERIAL;
|
|
||||||
else if (deveqn ("ttyS", 4) && (unit = digits (name + 4)) >= 0)
|
|
||||||
{
|
|
||||||
devn = FH_SERIAL;
|
|
||||||
unit++;
|
|
||||||
}
|
|
||||||
else if (deveq ("pipe"))
|
|
||||||
devn = FH_PIPE;
|
|
||||||
else if (deveq ("piper"))
|
|
||||||
devn = FH_PIPER;
|
|
||||||
else if (deveq ("pipew"))
|
|
||||||
devn = FH_PIPEW;
|
|
||||||
else if (deveq ("tcp") || deveq ("udp") || deveq ("streamsocket")
|
|
||||||
|| deveq ("dgsocket"))
|
|
||||||
{
|
|
||||||
devn = FH_SOCKET;
|
|
||||||
unit = tolower (*name) - 'a';
|
|
||||||
}
|
|
||||||
|
|
||||||
return devn;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
major minor POSIX filename NT filename
|
|
||||||
----- ----- -------------- -------------------------
|
|
||||||
FH_TAPE 0 /dev/st0 \device\tape0
|
|
||||||
FH_TAPE 1 /dev/st1 \device\tape1
|
|
||||||
...
|
|
||||||
FH_TAPE 128 /dev/nst0 \device\tape0
|
|
||||||
FH_TAPE 129 /dev/nst1 \device\tape1
|
|
||||||
...
|
|
||||||
|
|
||||||
FH_FLOPPY 0 /dev/fd0 \device\floppy0
|
|
||||||
FH_FLOPPY 1 /dev/fd1 \device\floppy1
|
|
||||||
...
|
|
||||||
|
|
||||||
FH_FLOPPY 16 /dev/scd0 \device\cdrom0
|
|
||||||
FH_FLOPPY 17 /dev/scd0 \device\cdrom1
|
|
||||||
...
|
|
||||||
|
|
||||||
FH_FLOPPY 32 /dev/sda \device\harddisk0\partition0
|
|
||||||
FH_FLOPPY 33 /dev/sda1 \device\harddisk0\partition1
|
|
||||||
...
|
|
||||||
FH_FLOPPY 47 /dev/sda15 \device\harddisk0\partition15
|
|
||||||
|
|
||||||
FH_FLOPPY 48 /dev/sdb \device\harddisk1\partition0
|
|
||||||
FH_FLOPPY 33 /dev/sdb1 \device\harddisk1\partition1
|
|
||||||
...
|
|
||||||
FH_FLOPPY 208 /dev/sdl \device\harddisk11\partition0
|
|
||||||
...
|
|
||||||
FH_FLOPPY 223 /dev/sdl15 \device\harddisk11\partition15
|
|
||||||
|
|
||||||
The following are needed to maintain backward compatibility with
|
|
||||||
the old Win32 partitioning scheme on W2K/XP.
|
|
||||||
|
|
||||||
FH_FLOPPY 224 from mount tab \\.\A:
|
|
||||||
...
|
|
||||||
FH_FLOPPY 250 from mount tab \\.\Z:
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
get_raw_device_number (const char *name, const char *w32_path, int &unit)
|
|
||||||
{
|
|
||||||
DWORD devn = FH_BAD;
|
|
||||||
|
|
||||||
if (!w32_path) /* New approach using fixed device names. */
|
|
||||||
{
|
|
||||||
if (deveqn ("st", 2))
|
|
||||||
{
|
|
||||||
unit = digits (name + 2);
|
|
||||||
if (unit >= 0 && unit < 128)
|
|
||||||
devn = FH_TAPE;
|
|
||||||
}
|
|
||||||
else if (deveqn ("nst", 3))
|
|
||||||
{
|
|
||||||
unit = digits (name + 3) + 128;
|
|
||||||
if (unit >= 128 && unit < 256)
|
|
||||||
devn = FH_TAPE;
|
|
||||||
}
|
|
||||||
else if (deveqn ("fd", 2))
|
|
||||||
{
|
|
||||||
unit = digits (name + 2);
|
|
||||||
if (unit >= 0 && unit < 16)
|
|
||||||
devn = FH_FLOPPY;
|
|
||||||
}
|
|
||||||
else if (deveqn ("scd", 3))
|
|
||||||
{
|
|
||||||
unit = digits (name + 3) + 16;
|
|
||||||
if (unit >= 16 && unit < 32)
|
|
||||||
devn = FH_FLOPPY;
|
|
||||||
}
|
|
||||||
else if (deveqn ("sd", 2) && isalpha (name[2]))
|
|
||||||
{
|
|
||||||
unit = (cyg_tolower (name[2]) - 'a') * 16 + 32;
|
|
||||||
if (unit >= 32 && unit < 224)
|
|
||||||
if (!name[3])
|
|
||||||
devn = FH_FLOPPY;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int d = digits (name + 3);
|
|
||||||
if (d >= 1 && d < 16)
|
|
||||||
{
|
|
||||||
unit += d;
|
|
||||||
devn = FH_FLOPPY;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else /* Backward compatible checking of mount table device mapping. */
|
|
||||||
{
|
|
||||||
if (wdeveqn ("tape", 4))
|
|
||||||
{
|
|
||||||
unit = digits (w32_path + 4);
|
|
||||||
/* Norewind tape devices have leading n in name. */
|
|
||||||
if (deveqn ("n", 1))
|
|
||||||
unit += 128;
|
|
||||||
devn = FH_TAPE;
|
|
||||||
}
|
|
||||||
else if (wdeveqn ("physicaldrive", 13))
|
|
||||||
{
|
|
||||||
unit = digits (w32_path + 13) * 16 + 32;
|
|
||||||
devn = FH_FLOPPY;
|
|
||||||
}
|
|
||||||
else if (isdrive (w32_path))
|
|
||||||
{
|
|
||||||
unit = cyg_tolower (w32_path[0]) - 'a' + 224;
|
|
||||||
devn = FH_FLOPPY;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return devn;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int __stdcall get_device_number (const char *unix_path,
|
|
||||||
const char *w32_path, int &unit)
|
|
||||||
__attribute__ ((regparm(3)));
|
|
||||||
static int __stdcall
|
|
||||||
get_device_number (const char *unix_path, const char *w32_path, int &unit)
|
|
||||||
{
|
|
||||||
DWORD devn = FH_BAD;
|
|
||||||
unit = 0;
|
|
||||||
|
|
||||||
if (*unix_path == '/' && udeveqn ("/dev/", 5))
|
|
||||||
{
|
|
||||||
devn = get_devn (unix_path, unit);
|
|
||||||
if (devn == FH_BAD && *w32_path == '\\' && wdeveqn ("\\dev\\", 5))
|
|
||||||
devn = get_devn (w32_path, unit);
|
|
||||||
if (devn == FH_BAD && wdeveqn ("\\\\.\\", 4))
|
|
||||||
devn = get_raw_device_number (unix_path + 5, w32_path + 4, unit);
|
|
||||||
if (devn == FH_BAD)
|
|
||||||
devn = get_raw_device_number (unix_path + 5, NULL, unit);
|
|
||||||
}
|
|
||||||
|
|
||||||
return devn;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Return TRUE if src_path is a Win32 device name, filling out the device
|
/* Return TRUE if src_path is a Win32 device name, filling out the device
|
||||||
name in win32_path */
|
name in win32_path */
|
||||||
|
|
||||||
static BOOL
|
static BOOL
|
||||||
win32_device_name (const char *src_path, char *win32_path,
|
win32_device_name (const char *src_path, char *win32_path, device& dev)
|
||||||
DWORD &devn, int &unit)
|
|
||||||
{
|
{
|
||||||
const char *devfmt;
|
dev.parse (src_path);
|
||||||
|
|
||||||
devn = get_device_number (src_path, win32_path, unit);
|
if (dev.devn == FH_FS)
|
||||||
|
|
||||||
if (devn == FH_BAD)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ((devfmt = windows_device_names[FHDEVN (devn)]) == NULL)
|
switch (dev.devn)
|
||||||
return false;
|
|
||||||
switch (devn)
|
|
||||||
{
|
{
|
||||||
case FH_SOCKET:
|
|
||||||
char *c;
|
|
||||||
strcpy (win32_path, src_path);
|
|
||||||
while ((c = strchr (win32_path, '/')))
|
|
||||||
*c = '\\';
|
|
||||||
break;
|
|
||||||
case FH_RANDOM:
|
|
||||||
__small_sprintf (win32_path, devfmt, unit == 8 ? "" : "u");
|
|
||||||
break;
|
|
||||||
case FH_TAPE:
|
case FH_TAPE:
|
||||||
__small_sprintf (win32_path, "\\Device\\Tape%d", unit % 128);
|
__small_sprintf (win32_path, dev.fmt, dev.minor % 128);
|
||||||
break;
|
break;
|
||||||
case FH_FLOPPY:
|
case FH_RAWDRIVE:
|
||||||
if (unit < 16)
|
__small_sprintf (win32_path, dev.fmt, dev.minor - 224 + 'A');
|
||||||
__small_sprintf (win32_path, "\\Device\\Floppy%d", unit);
|
|
||||||
else if (unit < 32)
|
|
||||||
__small_sprintf (win32_path, "\\Device\\CdRom%d", unit - 16);
|
|
||||||
else if (unit < 224)
|
|
||||||
__small_sprintf (win32_path, "\\Device\\Harddisk%d\\Partition%d",
|
|
||||||
(unit - 32) / 16, unit % 16);
|
|
||||||
else
|
|
||||||
__small_sprintf (win32_path, "\\DosDevices\\%c:", unit - 224 + 'A');
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
__small_sprintf (win32_path, devfmt, unit);
|
__small_sprintf (win32_path, dev.fmt, dev.minor);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Normalize a Win32 path.
|
/* Normalize a Win32 path.
|
||||||
@ -1529,9 +1296,8 @@ mount_item::build_win32 (char *dst, const char *src, unsigned *outflags, unsigne
|
|||||||
{,full_}win32_path must have sufficient space (i.e. MAX_PATH bytes). */
|
{,full_}win32_path must have sufficient space (i.e. MAX_PATH bytes). */
|
||||||
|
|
||||||
int
|
int
|
||||||
mount_info::conv_to_win32_path (const char *src_path, char *dst,
|
mount_info::conv_to_win32_path (const char *src_path, char *dst, device& dev,
|
||||||
DWORD &devn, int &unit, unsigned *flags,
|
unsigned *flags, bool no_normalize)
|
||||||
bool no_normalize)
|
|
||||||
{
|
{
|
||||||
bool chroot_ok = !cygheap->root.exists ();
|
bool chroot_ok = !cygheap->root.exists ();
|
||||||
while (sys_mount_table_counter < cygwin_shared->sys_mount_table_counter)
|
while (sys_mount_table_counter < cygwin_shared->sys_mount_table_counter)
|
||||||
@ -1543,8 +1309,7 @@ mount_info::conv_to_win32_path (const char *src_path, char *dst,
|
|||||||
MALLOC_CHECK;
|
MALLOC_CHECK;
|
||||||
unsigned dummy_flags;
|
unsigned dummy_flags;
|
||||||
|
|
||||||
devn = FH_BAD;
|
dev.devn = FH_FS;
|
||||||
unit = 0;
|
|
||||||
|
|
||||||
if (!flags)
|
if (!flags)
|
||||||
flags = &dummy_flags;
|
flags = &dummy_flags;
|
||||||
@ -1595,7 +1360,7 @@ mount_info::conv_to_win32_path (const char *src_path, char *dst,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* See if this is a cygwin "device" */
|
/* See if this is a cygwin "device" */
|
||||||
if (win32_device_name (pathbuf, dst, devn, unit))
|
if (win32_device_name (pathbuf, dst, dev))
|
||||||
{
|
{
|
||||||
*flags = MOUNT_BINARY; /* FIXME: Is this a sensible default for devices? */
|
*flags = MOUNT_BINARY; /* FIXME: Is this a sensible default for devices? */
|
||||||
rc = 0;
|
rc = 0;
|
||||||
@ -1607,20 +1372,23 @@ mount_info::conv_to_win32_path (const char *src_path, char *dst,
|
|||||||
MALLOC_CHECK;
|
MALLOC_CHECK;
|
||||||
if (isproc (pathbuf))
|
if (isproc (pathbuf))
|
||||||
{
|
{
|
||||||
devn = fhandler_proc::get_proc_fhandler (pathbuf);
|
dev = *proc_dev;
|
||||||
if (devn == FH_BAD)
|
dev.devn = fhandler_proc::get_proc_fhandler (pathbuf);
|
||||||
|
if (dev.devn == FH_BAD)
|
||||||
return ENOENT;
|
return ENOENT;
|
||||||
}
|
}
|
||||||
else if (iscygdrive (pathbuf))
|
else if (iscygdrive (pathbuf))
|
||||||
{
|
{
|
||||||
int n = mount_table->cygdrive_len - 1;
|
int n = mount_table->cygdrive_len - 1;
|
||||||
|
int unit;
|
||||||
|
|
||||||
if (!pathbuf[n] ||
|
if (!pathbuf[n] ||
|
||||||
(pathbuf[n] == '/' && pathbuf[n + 1] == '.' && !pathbuf[n + 2]))
|
(pathbuf[n] == '/' && pathbuf[n + 1] == '.' && !pathbuf[n + 2]))
|
||||||
{
|
{
|
||||||
unit = 0;
|
unit = 0;
|
||||||
dst[0] = '\0';
|
dst[0] = '\0';
|
||||||
if (mount_table->cygdrive_len > 1)
|
if (mount_table->cygdrive_len > 1)
|
||||||
devn = FH_CYGDRIVE;
|
dev = *cygdrive_dev;
|
||||||
}
|
}
|
||||||
else if (cygdrive_win32_path (pathbuf, dst, unit))
|
else if (cygdrive_win32_path (pathbuf, dst, unit))
|
||||||
{
|
{
|
||||||
@ -1678,8 +1446,8 @@ mount_info::conv_to_win32_path (const char *src_path, char *dst,
|
|||||||
chroot_ok = !cygheap->root.exists ();
|
chroot_ok = !cygheap->root.exists ();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isvirtual_dev (devn))
|
if (!isvirtual_dev (dev.devn))
|
||||||
win32_device_name (src_path, dst, devn, unit);
|
win32_device_name (src_path, dst, dev);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
MALLOC_CHECK;
|
MALLOC_CHECK;
|
||||||
@ -1734,7 +1502,7 @@ mount_info::cygdrive_win32_path (const char *src, char *dst, int& unit)
|
|||||||
const char *p = src + cygdrive_len;
|
const char *p = src + cygdrive_len;
|
||||||
if (!isalpha (*p) || (!isdirsep (p[1]) && p[1]))
|
if (!isalpha (*p) || (!isdirsep (p[1]) && p[1]))
|
||||||
{
|
{
|
||||||
unit = -1;
|
unit = -1; /* FIXME: should be zero, maybe? */
|
||||||
dst[0] = '\0';
|
dst[0] = '\0';
|
||||||
res = 0;
|
res = 0;
|
||||||
}
|
}
|
||||||
@ -2699,6 +2467,13 @@ int allow_winsymlinks = TRUE;
|
|||||||
|
|
||||||
extern "C" int
|
extern "C" int
|
||||||
symlink (const char *topath, const char *frompath)
|
symlink (const char *topath, const char *frompath)
|
||||||
|
{
|
||||||
|
return symlink_worker (topath, frompath, allow_winsymlinks, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
symlink_worker (const char *topath, const char *frompath, bool use_winsym,
|
||||||
|
bool isdevice)
|
||||||
{
|
{
|
||||||
HANDLE h;
|
HANDLE h;
|
||||||
int res = -1;
|
int res = -1;
|
||||||
@ -2723,7 +2498,7 @@ symlink (const char *topath, const char *frompath)
|
|||||||
}
|
}
|
||||||
|
|
||||||
win32_path.check (frompath, PC_SYM_NOFOLLOW);
|
win32_path.check (frompath, PC_SYM_NOFOLLOW);
|
||||||
if (allow_winsymlinks && !win32_path.exists ())
|
if (use_winsym && !win32_path.exists ())
|
||||||
{
|
{
|
||||||
strcpy (from, frompath);
|
strcpy (from, frompath);
|
||||||
strcat (from, ".lnk");
|
strcat (from, ".lnk");
|
||||||
@ -2738,13 +2513,22 @@ symlink (const char *topath, const char *frompath)
|
|||||||
|
|
||||||
syscall_printf ("symlink (%s, %s)", topath, win32_path.get_win32 ());
|
syscall_printf ("symlink (%s, %s)", topath, win32_path.get_win32 ());
|
||||||
|
|
||||||
if (win32_path.is_device () || win32_path.exists ())
|
if (win32_path.is_auto_device ())
|
||||||
{
|
{
|
||||||
set_errno (EEXIST);
|
set_errno (EEXIST);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (allow_winsymlinks)
|
DWORD create_how;
|
||||||
|
if (!use_winsym)
|
||||||
|
create_how = CREATE_NEW;
|
||||||
|
else if (isdevice)
|
||||||
|
{
|
||||||
|
strcpy (w32topath, topath);
|
||||||
|
create_how = CREATE_ALWAYS;
|
||||||
|
(void) SetFileAttributes (win32_path, FILE_ATTRIBUTE_NORMAL);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
if (!isabspath (topath))
|
if (!isabspath (topath))
|
||||||
{
|
{
|
||||||
@ -2768,21 +2552,22 @@ symlink (const char *topath, const char *frompath)
|
|||||||
*cp = c;
|
*cp = c;
|
||||||
chdir (cwd);
|
chdir (cwd);
|
||||||
}
|
}
|
||||||
|
create_how = CREATE_NEW;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (allow_ntsec && win32_path.has_acls ())
|
if (allow_ntsec && win32_path.has_acls ())
|
||||||
set_security_attribute (S_IFLNK | STD_RBITS | STD_WBITS,
|
set_security_attribute (S_IFLNK | STD_RBITS | STD_WBITS,
|
||||||
&sa, alloca (4096), 4096);
|
&sa, alloca (4096), 4096);
|
||||||
|
|
||||||
h = CreateFile (win32_path, GENERIC_WRITE, 0, &sa,
|
h = CreateFile (win32_path, GENERIC_WRITE, 0, &sa, create_how,
|
||||||
CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0);
|
FILE_ATTRIBUTE_NORMAL, 0);
|
||||||
if (h == INVALID_HANDLE_VALUE)
|
if (h == INVALID_HANDLE_VALUE)
|
||||||
__seterrno ();
|
__seterrno ();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BOOL success;
|
BOOL success;
|
||||||
|
|
||||||
if (allow_winsymlinks)
|
if (use_winsym)
|
||||||
{
|
{
|
||||||
create_shortcut_header ();
|
create_shortcut_header ();
|
||||||
/* Don't change the datatypes of `len' and `win_len' since
|
/* Don't change the datatypes of `len' and `win_len' since
|
||||||
@ -2822,16 +2607,16 @@ symlink (const char *topath, const char *frompath)
|
|||||||
win32_path.get_win32 (),
|
win32_path.get_win32 (),
|
||||||
S_IFLNK | S_IRWXU | S_IRWXG | S_IRWXO);
|
S_IFLNK | S_IRWXU | S_IRWXG | S_IRWXO);
|
||||||
|
|
||||||
DWORD attr = allow_winsymlinks ? FILE_ATTRIBUTE_READONLY
|
DWORD attr = use_winsym ? FILE_ATTRIBUTE_READONLY
|
||||||
: FILE_ATTRIBUTE_SYSTEM;
|
: FILE_ATTRIBUTE_SYSTEM;
|
||||||
#ifdef HIDDEN_DOT_FILES
|
#ifdef HIDDEN_DOT_FILES
|
||||||
cp = strrchr (win32_path, '\\');
|
cp = strrchr (win32_path, '\\');
|
||||||
if ((cp && cp[1] == '.') || *win32_path == '.')
|
if ((cp && cp[1] == '.') || *win32_path == '.')
|
||||||
attr |= FILE_ATTRIBUTE_HIDDEN;
|
attr |= FILE_ATTRIBUTE_HIDDEN;
|
||||||
#endif
|
#endif
|
||||||
SetFileAttributes (win32_path.get_win32 (), attr);
|
SetFileAttributes (win32_path, attr);
|
||||||
|
|
||||||
if (win32_path.fs_fast_ea ())
|
if (!isdevice && win32_path.fs_fast_ea ())
|
||||||
set_symlink_ea (win32_path, topath);
|
set_symlink_ea (win32_path, topath);
|
||||||
res = 0;
|
res = 0;
|
||||||
}
|
}
|
||||||
@ -2844,7 +2629,8 @@ symlink (const char *topath, const char *frompath)
|
|||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
syscall_printf ("%d = symlink (%s, %s)", res, topath, frompath);
|
syscall_printf ("%d = symlink_worker (%s, %s, %d, %d)", res, topath,
|
||||||
|
frompath, use_winsym, isdevice);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3086,6 +2872,48 @@ suffix_scan::next ()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
symlink_info::parse_device (const char *contents)
|
||||||
|
{
|
||||||
|
char *endptr;
|
||||||
|
_major_t mymajor;
|
||||||
|
_major_t myminor;
|
||||||
|
_mode_t mymode;
|
||||||
|
|
||||||
|
mymajor = strtol (++contents, &endptr, 16);
|
||||||
|
if (endptr == contents)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
contents = endptr;
|
||||||
|
myminor = strtol (++contents, &endptr, 16);
|
||||||
|
if (endptr == contents)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
contents = endptr;
|
||||||
|
mymode = strtol (++contents, &endptr, 16);
|
||||||
|
if (endptr == contents)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
switch (mymode & S_IFMT)
|
||||||
|
{
|
||||||
|
case S_IFIFO:
|
||||||
|
mymajor = _major (FH_FIFO);
|
||||||
|
myminor = _minor (FH_FIFO);
|
||||||
|
break;
|
||||||
|
case S_IFBLK:
|
||||||
|
case S_IFCHR:
|
||||||
|
if (mymajor || myminor)
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
major = mymajor;
|
||||||
|
minor = myminor;
|
||||||
|
mode = mymode;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/* Check if PATH is a symlink. PATH must be a valid Win32 path name.
|
/* Check if PATH is a symlink. PATH must be a valid Win32 path name.
|
||||||
|
|
||||||
If PATH is a symlink, put the value of the symlink--the file to
|
If PATH is a symlink, put the value of the symlink--the file to
|
||||||
@ -3114,6 +2942,8 @@ symlink_info::check (char *path, const suffix_info *suffixes, unsigned opt)
|
|||||||
is_symlink = true;
|
is_symlink = true;
|
||||||
ext_here = suffix.has (path, suffixes);
|
ext_here = suffix.has (path, suffixes);
|
||||||
extn = ext_here - path;
|
extn = ext_here - path;
|
||||||
|
major = 0;
|
||||||
|
minor = 0;
|
||||||
|
|
||||||
pflags &= ~(PATH_SYMLINK | PATH_LNK);
|
pflags &= ~(PATH_SYMLINK | PATH_LNK);
|
||||||
|
|
||||||
@ -3179,13 +3009,16 @@ symlink_info::check (char *path, const suffix_info *suffixes, unsigned opt)
|
|||||||
goto file_not_symlink;
|
goto file_not_symlink;
|
||||||
|
|
||||||
/* FIXME: if symlink isn't present in EA, but EAs are supported,
|
/* FIXME: if symlink isn't present in EA, but EAs are supported,
|
||||||
* should we write it there?
|
should we write it there? */
|
||||||
*/
|
|
||||||
switch (sym_check)
|
switch (sym_check)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
res = check_shortcut (suffix.path, fileattr, h, contents, &error, &pflags);
|
res = check_shortcut (suffix.path, fileattr, h, contents, &error, &pflags);
|
||||||
if (res)
|
if (!res)
|
||||||
|
/* check more below */;
|
||||||
|
else if (*contents == ':' && parse_device (contents))
|
||||||
|
goto file_not_symlink;
|
||||||
|
else
|
||||||
break;
|
break;
|
||||||
/* If searching for `foo' and then finding a `foo.lnk' which is
|
/* If searching for `foo' and then finding a `foo.lnk' which is
|
||||||
no shortcut, return the same as if file not found. */
|
no shortcut, return the same as if file not found. */
|
||||||
@ -3204,7 +3037,7 @@ symlink_info::check (char *path, const suffix_info *suffixes, unsigned opt)
|
|||||||
|
|
||||||
file_not_symlink:
|
file_not_symlink:
|
||||||
is_symlink = false;
|
is_symlink = false;
|
||||||
syscall_printf ("not a symlink");
|
syscall_printf ("%s", (major || minor) ? "is a device" : "not a symlink");
|
||||||
res = 0;
|
res = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -3652,7 +3485,8 @@ conv_path_list_buf_size (const char *path_list, bool to_posix)
|
|||||||
+ (nrel * strlen (to_posix ? pc.normalized_path : pc.get_win32 ()))
|
+ (nrel * strlen (to_posix ? pc.normalized_path : pc.get_win32 ()))
|
||||||
+ 100;
|
+ 100;
|
||||||
|
|
||||||
cfree (pc.normalized_path); // FIXME - probably should be in a destructor but
|
if (!pc.normalized_path_size && pc.normalized_path)
|
||||||
|
cfree (pc.normalized_path); // FIXME - probably should be in a destructor but
|
||||||
// it's hard to justify a destructor for the few
|
// it's hard to justify a destructor for the few
|
||||||
// places where this is needed
|
// places where this is needed
|
||||||
return size;
|
return size;
|
||||||
|
@ -8,6 +8,19 @@ This software is a copyrighted work licensed under the terms of the
|
|||||||
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
||||||
details. */
|
details. */
|
||||||
|
|
||||||
|
#include "devices.h"
|
||||||
|
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
enum executable_states
|
||||||
|
{
|
||||||
|
is_executable,
|
||||||
|
dont_care_if_executable,
|
||||||
|
not_executable = dont_care_if_executable,
|
||||||
|
dont_know_if_executable
|
||||||
|
};
|
||||||
|
|
||||||
struct suffix_info
|
struct suffix_info
|
||||||
{
|
{
|
||||||
const char *name;
|
const char *name;
|
||||||
@ -60,13 +73,20 @@ enum path_types
|
|||||||
class symlink_info;
|
class symlink_info;
|
||||||
struct fs_info
|
struct fs_info
|
||||||
{
|
{
|
||||||
char name[MAX_PATH];
|
char name_storage[MAX_PATH];
|
||||||
char root_dir[MAX_PATH];
|
char root_dir_storage[MAX_PATH];
|
||||||
DWORD flags;
|
DWORD flags_storage;
|
||||||
DWORD serial;
|
DWORD serial_storage;
|
||||||
DWORD sym_opt; /* additional options to pass to symlink_info resolver */
|
DWORD sym_opt_storage; /* additional options to pass to symlink_info resolver */
|
||||||
DWORD is_remote_drive;
|
bool is_remote_drive_storage;
|
||||||
DWORD drive_type;
|
DWORD drive_type_storage;
|
||||||
|
inline char* name () const {return (char *) name_storage;}
|
||||||
|
inline char* root_dir () const {return (char *) root_dir_storage;}
|
||||||
|
inline DWORD& flags () {return flags_storage;};
|
||||||
|
inline DWORD& serial () {return serial_storage;};
|
||||||
|
inline DWORD& sym_opt () {return sym_opt_storage;};
|
||||||
|
inline bool& is_remote_drive () {return is_remote_drive_storage;};
|
||||||
|
inline DWORD& drive_type () {return drive_type_storage;};
|
||||||
bool update (const char *);
|
bool update (const char *);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -80,12 +100,11 @@ class path_conv
|
|||||||
unsigned path_flags;
|
unsigned path_flags;
|
||||||
char *known_suffix;
|
char *known_suffix;
|
||||||
int error;
|
int error;
|
||||||
DWORD devn;
|
device dev;
|
||||||
int unit;
|
|
||||||
BOOL case_clash;
|
BOOL case_clash;
|
||||||
|
|
||||||
int isdisk () const { return path_flags & PATH_ISDISK;}
|
int isdisk () const { return path_flags & PATH_ISDISK;}
|
||||||
int isremote () const {return fs.is_remote_drive;}
|
bool& isremote () {return fs.is_remote_drive ();}
|
||||||
int has_acls () const {return path_flags & PATH_HASACLS;}
|
int has_acls () const {return path_flags & PATH_HASACLS;}
|
||||||
int has_symlinks () const {return path_flags & PATH_HAS_SYMLINKS;}
|
int has_symlinks () const {return path_flags & PATH_HAS_SYMLINKS;}
|
||||||
int hasgood_inode () const {return path_flags & PATH_HASACLS;} // Not strictly correct
|
int hasgood_inode () const {return path_flags & PATH_HASACLS;} // Not strictly correct
|
||||||
@ -101,6 +120,11 @@ class path_conv
|
|||||||
}
|
}
|
||||||
int issymlink () const {return path_flags & PATH_SYMLINK;}
|
int issymlink () const {return path_flags & PATH_SYMLINK;}
|
||||||
int is_lnk_symlink () const {return path_flags & PATH_LNK;}
|
int is_lnk_symlink () const {return path_flags & PATH_LNK;}
|
||||||
|
int isdevice () const {return dev.devn && dev.devn != FH_FS && dev.devn != FH_FIFO;}
|
||||||
|
int isfifo () const {return dev == FH_FIFO;}
|
||||||
|
int isspecial () const {return dev.devn && dev.devn != FH_FS;}
|
||||||
|
int is_auto_device () const {return isdevice () && !is_fs_special ();}
|
||||||
|
int is_fs_special () const {return isspecial () && dev.isfs ();}
|
||||||
int issocket () const {return path_flags & PATH_SOCKET;}
|
int issocket () const {return path_flags & PATH_SOCKET;}
|
||||||
int iscygexec () const {return path_flags & PATH_CYGWIN_EXEC;}
|
int iscygexec () const {return path_flags & PATH_CYGWIN_EXEC;}
|
||||||
bool exists () const {return fileattr != INVALID_FILE_ATTRIBUTES;}
|
bool exists () const {return fileattr != INVALID_FILE_ATTRIBUTES;}
|
||||||
@ -121,7 +145,7 @@ class path_conv
|
|||||||
void set_binary () {path_flags |= PATH_BINARY;}
|
void set_binary () {path_flags |= PATH_BINARY;}
|
||||||
void set_symlink () {path_flags |= PATH_SYMLINK;}
|
void set_symlink () {path_flags |= PATH_SYMLINK;}
|
||||||
void set_has_symlinks () {path_flags |= PATH_HAS_SYMLINKS;}
|
void set_has_symlinks () {path_flags |= PATH_HAS_SYMLINKS;}
|
||||||
void set_isdisk () {path_flags |= PATH_ISDISK; devn = FH_DISK;}
|
void set_isdisk () {path_flags |= PATH_ISDISK; dev.devn = FH_FS;}
|
||||||
void set_exec (int x = 1) {path_flags |= x ? PATH_EXEC : PATH_NOTEXEC;}
|
void set_exec (int x = 1) {path_flags |= x ? PATH_EXEC : PATH_NOTEXEC;}
|
||||||
void set_has_acls (int x = 1) {path_flags |= x ? PATH_HASACLS : PATH_NOTHING;}
|
void set_has_acls (int x = 1) {path_flags |= x ? PATH_HASACLS : PATH_NOTHING;}
|
||||||
void set_has_buggy_open (int x = 1) {path_flags |= x ? PATH_HASBUGGYOPEN : PATH_NOTHING;}
|
void set_has_buggy_open (int x = 1) {path_flags |= x ? PATH_HASBUGGYOPEN : PATH_NOTHING;}
|
||||||
@ -129,6 +153,9 @@ class path_conv
|
|||||||
void check (const char *src, unsigned opt = PC_SYM_FOLLOW,
|
void check (const char *src, unsigned opt = PC_SYM_FOLLOW,
|
||||||
const suffix_info *suffixes = NULL) __attribute__ ((regparm(3)));
|
const suffix_info *suffixes = NULL) __attribute__ ((regparm(3)));
|
||||||
|
|
||||||
|
path_conv (const device& in_dev): fileattr (INVALID_FILE_ATTRIBUTES),
|
||||||
|
path_flags (0), known_suffix (NULL), error (0), dev (in_dev) {}
|
||||||
|
|
||||||
path_conv (int, const char *src, unsigned opt = PC_SYM_FOLLOW,
|
path_conv (int, const char *src, unsigned opt = PC_SYM_FOLLOW,
|
||||||
const suffix_info *suffixes = NULL)
|
const suffix_info *suffixes = NULL)
|
||||||
{
|
{
|
||||||
@ -142,8 +169,8 @@ class path_conv
|
|||||||
}
|
}
|
||||||
|
|
||||||
path_conv (): fileattr (INVALID_FILE_ATTRIBUTES), path_flags (0),
|
path_conv (): fileattr (INVALID_FILE_ATTRIBUTES), path_flags (0),
|
||||||
known_suffix (NULL), error (0), devn (0), unit (0),
|
known_suffix (NULL), error (0), normalized_path (NULL)
|
||||||
normalized_path (NULL) {path[0] = '\0';}
|
{path[0] = '\0';}
|
||||||
|
|
||||||
inline char *get_win32 () { return path; }
|
inline char *get_win32 () { return path; }
|
||||||
operator char *() {return path;}
|
operator char *() {return path;}
|
||||||
@ -151,21 +178,26 @@ class path_conv
|
|||||||
operator DWORD &() {return fileattr;}
|
operator DWORD &() {return fileattr;}
|
||||||
operator int () {return fileattr; }
|
operator int () {return fileattr; }
|
||||||
char operator [](int i) const {return path[i];}
|
char operator [](int i) const {return path[i];}
|
||||||
BOOL is_device () {return devn != FH_BAD && devn != FH_DISK;}
|
DWORD get_devn () {return dev.devn;}
|
||||||
DWORD get_devn () {return devn == FH_BAD ? (DWORD) FH_DISK : devn;}
|
short get_unitn () {return dev.minor;}
|
||||||
short get_unitn () {return devn == FH_BAD ? 0 : unit;}
|
|
||||||
DWORD file_attributes () {return fileattr;}
|
DWORD file_attributes () {return fileattr;}
|
||||||
DWORD drive_type () {return fs.drive_type;}
|
DWORD drive_type () {return fs.drive_type ();}
|
||||||
DWORD fs_flags () {return fs.flags;}
|
DWORD fs_flags () {return fs.flags ();}
|
||||||
BOOL fs_fast_ea () {return fs.sym_opt & PC_CHECK_EA;}
|
BOOL fs_fast_ea () {return fs.sym_opt () & PC_CHECK_EA;}
|
||||||
void set_path (const char *p) {strcpy (path, p);}
|
void set_path (const char *p) {strcpy (path, p);}
|
||||||
char *return_and_clear_normalized_path ();
|
const char * root_dir () const { return fs.root_dir (); }
|
||||||
const char * root_dir () { return fs.root_dir; }
|
DWORD volser () { return fs.serial (); }
|
||||||
DWORD volser () { return fs.serial; }
|
const char *volname () {return fs.name (); }
|
||||||
const char *volname () {return fs.name; }
|
|
||||||
void fillin (HANDLE h);
|
void fillin (HANDLE h);
|
||||||
|
inline size_t size ()
|
||||||
|
{
|
||||||
|
return (sizeof (*this) - sizeof (path)) + strlen (path) + 1 + normalized_path_size;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned __stdcall ndisk_links (DWORD);
|
unsigned __stdcall ndisk_links (DWORD);
|
||||||
char *normalized_path;
|
char *normalized_path;
|
||||||
|
size_t normalized_path_size;
|
||||||
|
void set_normalized_path (const char *) __attribute__ ((regparm (2)));
|
||||||
private:
|
private:
|
||||||
char path[MAX_PATH];
|
char path[MAX_PATH];
|
||||||
};
|
};
|
||||||
@ -222,6 +254,7 @@ int path_prefix_p (const char *path1, const char *path2, int len1) __attribute__
|
|||||||
#define MAX_ETC_FILES 2
|
#define MAX_ETC_FILES 2
|
||||||
class etc
|
class etc
|
||||||
{
|
{
|
||||||
|
friend class dtable;
|
||||||
static int curr_ix;
|
static int curr_ix;
|
||||||
static bool change_possible[MAX_ETC_FILES + 1];
|
static bool change_possible[MAX_ETC_FILES + 1];
|
||||||
static const char *fn[MAX_ETC_FILES + 1];
|
static const char *fn[MAX_ETC_FILES + 1];
|
||||||
|
@ -12,9 +12,10 @@ details. */
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
#include <stdarg.h>
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include "fhandler.h"
|
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "sigproc.h"
|
#include "sigproc.h"
|
||||||
@ -28,6 +29,7 @@ details. */
|
|||||||
#include "cygthread.h"
|
#include "cygthread.h"
|
||||||
#include "shared_info.h"
|
#include "shared_info.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
|
#include "fhandler.h"
|
||||||
|
|
||||||
static char NO_COPY pinfo_dummy[sizeof (_pinfo)] = {0};
|
static char NO_COPY pinfo_dummy[sizeof (_pinfo)] = {0};
|
||||||
|
|
||||||
@ -318,11 +320,34 @@ _pinfo::commune_recv ()
|
|||||||
sigproc_printf ("WriteFile arg %d failed, %E", a - argv);
|
sigproc_printf ("WriteFile arg %d failed, %E", a - argv);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!WriteFile (__tothem, "", 1, &nr, NULL))
|
if (!WriteFile (__tothem, "", 1, &nr, NULL))
|
||||||
{
|
{
|
||||||
sigproc_printf ("WriteFile null failed, %E");
|
sigproc_printf ("WriteFile null failed, %E");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case PICOM_FIFO:
|
||||||
|
{
|
||||||
|
int formic;
|
||||||
|
if (!ReadFile (__fromthem, &formic, sizeof formic, &nr, NULL)
|
||||||
|
|| nr != sizeof formic)
|
||||||
|
{
|
||||||
|
/* __seterrno ();*/ // this is run from the signal thread, so don't set errno
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
fhandler_fifo *fh = cygheap->fdtab.find_fifo ((ATOM) formic);
|
||||||
|
HANDLE it[] = {(fh->get_handle ()), (fh->get_output_handle ())};
|
||||||
|
|
||||||
|
if (!WriteFile (__tothem, it, sizeof (it), &nr, NULL))
|
||||||
|
{
|
||||||
|
/*__seterrno ();*/ // this is run from the signal thread, so don't set errno
|
||||||
|
sigproc_printf ("WriteFile read handle failed, %E");
|
||||||
|
}
|
||||||
|
|
||||||
|
(void) ReadFile (__fromthem, &nr, sizeof (nr), &nr, NULL);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,12 +361,15 @@ out:
|
|||||||
#define PIPEBUFSIZE (16 * sizeof (DWORD))
|
#define PIPEBUFSIZE (16 * sizeof (DWORD))
|
||||||
|
|
||||||
commune_result
|
commune_result
|
||||||
_pinfo::commune_send (DWORD code)
|
_pinfo::commune_send (DWORD code, ...)
|
||||||
{
|
{
|
||||||
HANDLE fromthem = NULL, tome = NULL;
|
HANDLE fromthem = NULL, tome = NULL;
|
||||||
HANDLE fromme = NULL, tothem = NULL;
|
HANDLE fromme = NULL, tothem = NULL;
|
||||||
DWORD nr;
|
DWORD nr;
|
||||||
commune_result res;
|
commune_result res;
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
va_start (args, code);
|
||||||
|
|
||||||
res.s = NULL;
|
res.s = NULL;
|
||||||
res.n = 0;
|
res.n = 0;
|
||||||
@ -373,6 +401,20 @@ _pinfo::commune_send (DWORD code)
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch (code)
|
||||||
|
{
|
||||||
|
case PICOM_FIFO:
|
||||||
|
{
|
||||||
|
int formic = va_arg (args, int);
|
||||||
|
if (!WriteFile (tothem, &formic, sizeof formic, &nr, NULL) || nr != sizeof formic)
|
||||||
|
{
|
||||||
|
__seterrno ();
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (sig_send (this, __SIGCOMMUNE))
|
if (sig_send (this, __SIGCOMMUNE))
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
@ -402,14 +444,14 @@ _pinfo::commune_send (DWORD code)
|
|||||||
}
|
}
|
||||||
|
|
||||||
size_t n;
|
size_t n;
|
||||||
if (!ReadFile (fromthem, &n, sizeof n, &nr, NULL) || nr != sizeof n)
|
|
||||||
{
|
|
||||||
__seterrno ();
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
switch (code)
|
switch (code)
|
||||||
{
|
{
|
||||||
case PICOM_CMDLINE:
|
case PICOM_CMDLINE:
|
||||||
|
if (!ReadFile (fromthem, &n, sizeof n, &nr, NULL) || nr != sizeof n)
|
||||||
|
{
|
||||||
|
__seterrno ();
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
res.s = (char *) malloc (n);
|
res.s = (char *) malloc (n);
|
||||||
char *p;
|
char *p;
|
||||||
for (p = res.s; ReadFile (fromthem, p, n, &nr, NULL); p += nr)
|
for (p = res.s; ReadFile (fromthem, p, n, &nr, NULL); p += nr)
|
||||||
@ -421,6 +463,19 @@ _pinfo::commune_send (DWORD code)
|
|||||||
}
|
}
|
||||||
res.n = n;
|
res.n = n;
|
||||||
break;
|
break;
|
||||||
|
case PICOM_FIFO:
|
||||||
|
{
|
||||||
|
DWORD x = ReadFile (fromthem, res.handles, sizeof (res.handles), &nr, NULL);
|
||||||
|
WriteFile (tothem, &x, sizeof (x), &x, NULL);
|
||||||
|
if (!x)
|
||||||
|
goto err;
|
||||||
|
if (nr != sizeof (res.handles))
|
||||||
|
{
|
||||||
|
set_errno (EPIPE);
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
CloseHandle (tothem);
|
CloseHandle (tothem);
|
||||||
CloseHandle (fromthem);
|
CloseHandle (fromthem);
|
||||||
@ -435,7 +490,8 @@ err:
|
|||||||
CloseHandle (tothem);
|
CloseHandle (tothem);
|
||||||
if (fromme)
|
if (fromme)
|
||||||
CloseHandle (fromme);
|
CloseHandle (fromme);
|
||||||
res.n = 0;
|
memset (&res, 0, sizeof (res));
|
||||||
|
|
||||||
out:
|
out:
|
||||||
myself->hello_pid = 0;
|
myself->hello_pid = 0;
|
||||||
LeaveCriticalSection (&myself->lock);
|
LeaveCriticalSection (&myself->lock);
|
||||||
@ -477,7 +533,8 @@ pinfo::release ()
|
|||||||
if (h)
|
if (h)
|
||||||
{
|
{
|
||||||
#ifdef DEBUGGING
|
#ifdef DEBUGGING
|
||||||
if (((DWORD) procinfo & 0x77000000) == 0x61000000) try_to_debug ();
|
if (((DWORD) procinfo & 0x77000000) == 0x61000000)
|
||||||
|
try_to_debug ();
|
||||||
#endif
|
#endif
|
||||||
UnmapViewOfFile (procinfo);
|
UnmapViewOfFile (procinfo);
|
||||||
procinfo = NULL;
|
procinfo = NULL;
|
||||||
|
@ -12,14 +12,6 @@ details. */
|
|||||||
#define _PINFO_H
|
#define _PINFO_H
|
||||||
/* Signal constants (have to define them here, unfortunately) */
|
/* Signal constants (have to define them here, unfortunately) */
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
__SIGFLUSH = -2,
|
|
||||||
__SIGSTRACE = -1,
|
|
||||||
__SIGCOMMUNE = 0,
|
|
||||||
__SIGOFFSET = 2
|
|
||||||
};
|
|
||||||
|
|
||||||
#define PSIZE 63
|
#define PSIZE 63
|
||||||
|
|
||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
@ -29,11 +21,13 @@ struct commune_result
|
|||||||
{
|
{
|
||||||
char *s;
|
char *s;
|
||||||
int n;
|
int n;
|
||||||
|
HANDLE handles[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
enum picom
|
enum picom
|
||||||
{
|
{
|
||||||
PICOM_CMDLINE = 1
|
PICOM_CMDLINE = 1,
|
||||||
|
PICOM_FIFO = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct sigaction *global_sigs;
|
extern struct sigaction *global_sigs;
|
||||||
@ -117,35 +111,30 @@ public:
|
|||||||
|
|
||||||
inline sigset_t& getsigmask ()
|
inline sigset_t& getsigmask ()
|
||||||
{
|
{
|
||||||
return thread2signal ? *thread2signal->sigmask : sig_mask;
|
return sig_mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void setsigmask (sigset_t mask)
|
inline void setsigmask (sigset_t mask)
|
||||||
{
|
{
|
||||||
if (thread2signal)
|
|
||||||
*(thread2signal->sigmask) = mask;
|
|
||||||
sig_mask = mask;
|
sig_mask = mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline LONG* getsigtodo (int sig) {return _sigtodo + __SIGOFFSET + sig;}
|
|
||||||
|
|
||||||
inline HANDLE getthread2signal ()
|
inline HANDLE getthread2signal ()
|
||||||
{
|
{
|
||||||
return thread2signal ? thread2signal->win32_obj_id : hMainThread;
|
return hMainThread;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void setthread2signal (void *thr) {thread2signal = (pthread *) thr;}
|
|
||||||
void commune_recv ();
|
void commune_recv ();
|
||||||
commune_result commune_send (DWORD);
|
commune_result commune_send (DWORD, ...);
|
||||||
bool alive ();
|
bool alive ();
|
||||||
char *cmdline (size_t &);
|
char *cmdline (size_t &);
|
||||||
|
|
||||||
friend void __stdcall set_myself (pid_t, HANDLE);
|
friend void __stdcall set_myself (pid_t, HANDLE);
|
||||||
|
|
||||||
|
/* signals */
|
||||||
|
HANDLE sendsig;
|
||||||
private:
|
private:
|
||||||
sigset_t sig_mask; /* one set for everything to ignore. */
|
sigset_t sig_mask;
|
||||||
LONG _sigtodo[NSIG + __SIGOFFSET];
|
|
||||||
pthread *thread2signal; // NULL means thread any other means a pthread
|
|
||||||
CRITICAL_SECTION lock;
|
CRITICAL_SECTION lock;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -15,8 +15,8 @@ details. */
|
|||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include "fhandler.h"
|
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
#include "thread.h"
|
#include "thread.h"
|
||||||
@ -26,8 +26,8 @@ details. */
|
|||||||
static unsigned pipecount;
|
static unsigned pipecount;
|
||||||
static const NO_COPY char pipeid_fmt[] = "stupid_pipe.%u.%u";
|
static const NO_COPY char pipeid_fmt[] = "stupid_pipe.%u.%u";
|
||||||
|
|
||||||
fhandler_pipe::fhandler_pipe (DWORD devtype)
|
fhandler_pipe::fhandler_pipe ()
|
||||||
: fhandler_base (devtype), guard (NULL), broken_pipe (false), writepipe_exists(0),
|
: fhandler_base (), guard (NULL), broken_pipe (false), writepipe_exists(0),
|
||||||
orig_pid (0), id (0)
|
orig_pid (0), id (0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -72,7 +72,7 @@ fhandler_pipe::read (void *in_ptr, size_t& in_len)
|
|||||||
in_len = 0;
|
in_len = 0;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pipeargs pi = {this, in_ptr, &in_len};
|
pipeargs pi = {dynamic_cast<fhandler_base *>(this), in_ptr, &in_len};
|
||||||
ResetEvent (read_state);
|
ResetEvent (read_state);
|
||||||
cygthread *th = new cygthread (read_pipe, &pi, "read_pipe");
|
cygthread *th = new cygthread (read_pipe, &pi, "read_pipe");
|
||||||
if (th->detach (read_state) && !in_len)
|
if (th->detach (read_state) && !in_len)
|
||||||
@ -82,17 +82,21 @@ fhandler_pipe::read (void *in_ptr, size_t& in_len)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int fhandler_pipe::close ()
|
int
|
||||||
|
fhandler_pipe::close ()
|
||||||
{
|
{
|
||||||
int res = fhandler_base::close ();
|
|
||||||
#undef guard
|
|
||||||
if (guard)
|
if (guard)
|
||||||
CloseHandle (guard);
|
CloseHandle (guard);
|
||||||
if (writepipe_exists)
|
if (writepipe_exists)
|
||||||
CloseHandle (writepipe_exists);
|
CloseHandle (writepipe_exists);
|
||||||
if (read_state && !cygheap->fdtab.in_vfork_cleanup ())
|
if (read_state && !cygheap->fdtab.in_vfork_cleanup ())
|
||||||
CloseHandle (read_state);
|
CloseHandle (read_state);
|
||||||
return res;
|
if (get_handle ())
|
||||||
|
{
|
||||||
|
CloseHandle (get_handle ());
|
||||||
|
set_io_handle (NULL);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@ -177,55 +181,45 @@ fhandler_pipe::dup (fhandler_base *child)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
make_pipe (int fildes[2], unsigned int psize, int mode)
|
fhandler_pipe::create (fhandler_pipe *fhs[2], unsigned psize, int mode, bool fifo)
|
||||||
{
|
{
|
||||||
HANDLE r, w;
|
HANDLE r, w;
|
||||||
SECURITY_ATTRIBUTES *sa = (mode & O_NOINHERIT) ? &sec_none_nih : &sec_none;
|
SECURITY_ATTRIBUTES *sa = (mode & O_NOINHERIT) ? &sec_none_nih : &sec_none;
|
||||||
int res = -1;
|
int res = -1;
|
||||||
|
|
||||||
cygheap_fdnew fdr;
|
if (!CreatePipe (&r, &w, sa, psize))
|
||||||
if (fdr >= 0)
|
__seterrno ();
|
||||||
|
else
|
||||||
{
|
{
|
||||||
cygheap_fdnew fdw (fdr, false);
|
fhs[0] = (fhandler_pipe *) build_fh_dev (*piper_dev);
|
||||||
if (fdw < 0)
|
fhs[1] = (fhandler_pipe *) build_fh_dev (*pipew_dev);
|
||||||
/* out of fds? */;
|
|
||||||
else if (!CreatePipe (&r, &w, sa, psize))
|
int binmode = mode & O_TEXT ?: O_BINARY;
|
||||||
__seterrno ();
|
fhs[0]->init (r, GENERIC_READ, binmode);
|
||||||
else
|
fhs[1]->init (w, GENERIC_WRITE, binmode);
|
||||||
|
if (mode & O_NOINHERIT)
|
||||||
|
{
|
||||||
|
fhs[0]->set_close_on_exec_flag (1);
|
||||||
|
fhs[1]->set_close_on_exec_flag (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
fhs[0]->read_state = CreateEvent (&sec_none_nih, FALSE, FALSE, NULL);
|
||||||
|
fhs[0]->set_need_fork_fixup ();
|
||||||
|
|
||||||
|
res = 0;
|
||||||
|
fhs[0]->create_guard (sa);
|
||||||
|
if (wincap.has_unreliable_pipes ())
|
||||||
{
|
{
|
||||||
fhandler_pipe *fhr = (fhandler_pipe *) cygheap->fdtab.build_fhandler (fdr, FH_PIPER, "/dev/piper");
|
char buf[80];
|
||||||
fhandler_pipe *fhw = (fhandler_pipe *) cygheap->fdtab.build_fhandler (fdw, FH_PIPEW, "/dev/pipew");
|
int count = pipecount++; /* FIXME: Should this be InterlockedIncrement? */
|
||||||
|
__small_sprintf (buf, pipeid_fmt, myself->pid, count);
|
||||||
int binmode = mode & O_TEXT ?: O_BINARY;
|
fhs[1]->writepipe_exists = CreateEvent (sa, TRUE, FALSE, buf);
|
||||||
fhr->init (r, GENERIC_READ, binmode);
|
fhs[0]->orig_pid = myself->pid;
|
||||||
fhw->init (w, GENERIC_WRITE, binmode);
|
fhs[0]->id = count;
|
||||||
if (mode & O_NOINHERIT)
|
|
||||||
{
|
|
||||||
fhr->set_close_on_exec_flag (1);
|
|
||||||
fhw->set_close_on_exec_flag (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
fildes[0] = fdr;
|
|
||||||
fildes[1] = fdw;
|
|
||||||
fhr->read_state = CreateEvent (&sec_none_nih, FALSE, FALSE, NULL);
|
|
||||||
fhr->set_need_fork_fixup ();
|
|
||||||
|
|
||||||
res = 0;
|
|
||||||
fhr->create_guard (sa);
|
|
||||||
if (wincap.has_unreliable_pipes ())
|
|
||||||
{
|
|
||||||
char buf[80];
|
|
||||||
int count = pipecount++; /* FIXME: Should this be InterlockedIncrement? */
|
|
||||||
__small_sprintf (buf, pipeid_fmt, myself->pid, count);
|
|
||||||
fhw->writepipe_exists = CreateEvent (sa, TRUE, FALSE, buf);
|
|
||||||
fhr->orig_pid = myself->pid;
|
|
||||||
fhr->id = count;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
syscall_printf ("%d = make_pipe ([%d, %d], %d, %p)", res, fildes[0],
|
syscall_printf ("%d = ([%p, %p], %d, %p)", res, fhs[0], fhs[1], psize, mode);
|
||||||
fildes[1], psize, mode);
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -260,15 +254,38 @@ extern "C" int
|
|||||||
pipe (int filedes[2])
|
pipe (int filedes[2])
|
||||||
{
|
{
|
||||||
extern DWORD binmode;
|
extern DWORD binmode;
|
||||||
return make_pipe (filedes, 16384, (!binmode || binmode == O_BINARY) ? O_BINARY : O_TEXT);
|
fhandler_pipe *fhs[2];
|
||||||
|
int res = fhandler_pipe::create (fhs, 16384, (!binmode || binmode == O_BINARY)
|
||||||
|
? O_BINARY : O_TEXT);
|
||||||
|
if (res == 0)
|
||||||
|
{
|
||||||
|
cygheap_fdnew fdin;
|
||||||
|
cygheap_fdnew fdout (fdin, false);
|
||||||
|
fdin = fhs[0];
|
||||||
|
fdout = fhs[1];
|
||||||
|
filedes[0] = fdin;
|
||||||
|
filedes[1] = fdout;
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" int
|
extern "C" int
|
||||||
_pipe (int filedes[2], unsigned int psize, int mode)
|
_pipe (int filedes[2], unsigned int psize, int mode)
|
||||||
{
|
{
|
||||||
int res = make_pipe (filedes, psize, mode);
|
fhandler_pipe *fhs[2];
|
||||||
|
int res = fhandler_pipe::create (fhs, psize, mode);
|
||||||
/* This type of pipe is not interruptible so set the appropriate flag. */
|
/* This type of pipe is not interruptible so set the appropriate flag. */
|
||||||
if (!res)
|
if (!res)
|
||||||
cygheap->fdtab[filedes[0]]->set_r_no_interrupt (1);
|
{
|
||||||
|
cygheap_fdnew fdin;
|
||||||
|
cygheap_fdnew fdout (fdin, false);
|
||||||
|
fhs[0]->set_r_no_interrupt (1);
|
||||||
|
fdin = fhs[0];
|
||||||
|
fdout = fhs[1];
|
||||||
|
filedes[0] = fdin;
|
||||||
|
filedes[1] = fdout;
|
||||||
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,8 @@
|
|||||||
#define USE_SYS_TYPES_FD_SET
|
#define USE_SYS_TYPES_FD_SET
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include "fhandler.h"
|
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
|
@ -24,8 +24,8 @@ details. */
|
|||||||
#include <winuser.h>
|
#include <winuser.h>
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include "fhandler.h"
|
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
#include "pinfo.h"
|
#include "pinfo.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
|
@ -25,8 +25,8 @@ details. */
|
|||||||
#include <wininet.h>
|
#include <wininet.h>
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include "fhandler.h"
|
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
#include "pinfo.h"
|
#include "pinfo.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
|
@ -30,8 +30,8 @@ details. */
|
|||||||
#include <aclapi.h>
|
#include <aclapi.h>
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include "fhandler.h"
|
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
#include "pinfo.h"
|
#include "pinfo.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
|
@ -34,8 +34,8 @@ details. */
|
|||||||
#include "select.h"
|
#include "select.h"
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include "fhandler.h"
|
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
#include "sigproc.h"
|
#include "sigproc.h"
|
||||||
@ -335,7 +335,7 @@ set_bits (select_record *me, fd_set *readfds, fd_set *writefds,
|
|||||||
if (me->write_selected && me->write_ready)
|
if (me->write_selected && me->write_ready)
|
||||||
{
|
{
|
||||||
UNIX_FD_SET (me->fd, writefds);
|
UNIX_FD_SET (me->fd, writefds);
|
||||||
if (me->except_on_write && me->fh->get_device () == FH_SOCKET)
|
if (me->except_on_write && me->fh->is_socket ())
|
||||||
((fhandler_socket *) me->fh)->set_connect_state (CONNECTED);
|
((fhandler_socket *) me->fh)->set_connect_state (CONNECTED);
|
||||||
ready++;
|
ready++;
|
||||||
}
|
}
|
||||||
@ -344,7 +344,7 @@ set_bits (select_record *me, fd_set *readfds, fd_set *writefds,
|
|||||||
if (me->except_on_write) /* Only on sockets */
|
if (me->except_on_write) /* Only on sockets */
|
||||||
{
|
{
|
||||||
UNIX_FD_SET (me->fd, writefds);
|
UNIX_FD_SET (me->fd, writefds);
|
||||||
if (me->fh->get_device () == FH_SOCKET)
|
if (me->fh->is_socket ())
|
||||||
((fhandler_socket *) me->fh)->set_connect_state (CONNECTED);
|
((fhandler_socket *) me->fh)->set_connect_state (CONNECTED);
|
||||||
}
|
}
|
||||||
if (me->except_selected)
|
if (me->except_selected)
|
||||||
@ -553,9 +553,9 @@ out:
|
|||||||
static int
|
static int
|
||||||
start_thread_pipe (select_record *me, select_stuff *stuff)
|
start_thread_pipe (select_record *me, select_stuff *stuff)
|
||||||
{
|
{
|
||||||
if (stuff->device_specific[FHDEVN (FH_PIPE)])
|
if (stuff->device_specific_pipe)
|
||||||
{
|
{
|
||||||
me->h = *((pipeinf *) stuff->device_specific[FHDEVN (FH_PIPE)])->thread;
|
me->h = *((pipeinf *) stuff->device_specific_pipe)->thread;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
pipeinf *pi = new pipeinf;
|
pipeinf *pi = new pipeinf;
|
||||||
@ -565,20 +565,20 @@ start_thread_pipe (select_record *me, select_stuff *stuff)
|
|||||||
me->h = *pi->thread;
|
me->h = *pi->thread;
|
||||||
if (!me->h)
|
if (!me->h)
|
||||||
return 0;
|
return 0;
|
||||||
stuff->device_specific[FHDEVN (FH_PIPE)] = (void *) pi;
|
stuff->device_specific_pipe = (void *) pi;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
pipe_cleanup (select_record *, select_stuff *stuff)
|
pipe_cleanup (select_record *, select_stuff *stuff)
|
||||||
{
|
{
|
||||||
pipeinf *pi = (pipeinf *) stuff->device_specific[FHDEVN (FH_PIPE)];
|
pipeinf *pi = (pipeinf *) stuff->device_specific_pipe;
|
||||||
if (pi && pi->thread)
|
if (pi && pi->thread)
|
||||||
{
|
{
|
||||||
pi->stop_thread_pipe = true;
|
pi->stop_thread_pipe = true;
|
||||||
pi->thread->detach ();
|
pi->thread->detach ();
|
||||||
delete pi;
|
delete pi;
|
||||||
stuff->device_specific[FHDEVN (FH_PIPE)] = NULL;
|
stuff->device_specific_pipe = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -984,9 +984,9 @@ thread_serial (void *arg)
|
|||||||
static int
|
static int
|
||||||
start_thread_serial (select_record *me, select_stuff *stuff)
|
start_thread_serial (select_record *me, select_stuff *stuff)
|
||||||
{
|
{
|
||||||
if (stuff->device_specific[FHDEVN (FH_SERIAL)])
|
if (stuff->device_specific_serial)
|
||||||
{
|
{
|
||||||
me->h = *((serialinf *) stuff->device_specific[FHDEVN (FH_SERIAL)])->thread;
|
me->h = *((serialinf *) stuff->device_specific_serial)->thread;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
serialinf *si = new serialinf;
|
serialinf *si = new serialinf;
|
||||||
@ -994,20 +994,20 @@ start_thread_serial (select_record *me, select_stuff *stuff)
|
|||||||
si->stop_thread_serial = FALSE;
|
si->stop_thread_serial = FALSE;
|
||||||
si->thread = new cygthread (thread_serial, (LPVOID) si, "select_serial");
|
si->thread = new cygthread (thread_serial, (LPVOID) si, "select_serial");
|
||||||
me->h = *si->thread;
|
me->h = *si->thread;
|
||||||
stuff->device_specific[FHDEVN (FH_SERIAL)] = (void *) si;
|
stuff->device_specific_serial = (void *) si;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
serial_cleanup (select_record *, select_stuff *stuff)
|
serial_cleanup (select_record *, select_stuff *stuff)
|
||||||
{
|
{
|
||||||
serialinf *si = (serialinf *) stuff->device_specific[FHDEVN (FH_SERIAL)];
|
serialinf *si = (serialinf *) stuff->device_specific_serial;
|
||||||
if (si && si->thread)
|
if (si && si->thread)
|
||||||
{
|
{
|
||||||
si->stop_thread_serial = true;
|
si->stop_thread_serial = true;
|
||||||
si->thread->detach ();
|
si->thread->detach ();
|
||||||
delete si;
|
delete si;
|
||||||
stuff->device_specific[FHDEVN (FH_SERIAL)] = NULL;
|
stuff->device_specific_serial = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1255,7 +1255,7 @@ start_thread_socket (select_record *me, select_stuff *stuff)
|
|||||||
{
|
{
|
||||||
socketinf *si;
|
socketinf *si;
|
||||||
|
|
||||||
if ((si = (socketinf *) stuff->device_specific[FHDEVN (FH_SOCKET)]))
|
if ((si = (socketinf *) stuff->device_specific_socket))
|
||||||
{
|
{
|
||||||
me->h = *si->thread;
|
me->h = *si->thread;
|
||||||
return 1;
|
return 1;
|
||||||
@ -1323,7 +1323,7 @@ start_thread_socket (select_record *me, select_stuff *stuff)
|
|||||||
select_printf ("exitsock %p", si->exitsock);
|
select_printf ("exitsock %p", si->exitsock);
|
||||||
WINSOCK_FD_SET ((HANDLE) si->exitsock, &si->readfds);
|
WINSOCK_FD_SET ((HANDLE) si->exitsock, &si->readfds);
|
||||||
WINSOCK_FD_SET ((HANDLE) si->exitsock, &si->exceptfds);
|
WINSOCK_FD_SET ((HANDLE) si->exitsock, &si->exceptfds);
|
||||||
stuff->device_specific[FHDEVN (FH_SOCKET)] = (void *) si;
|
stuff->device_specific_socket = (void *) si;
|
||||||
si->start = &stuff->start;
|
si->start = &stuff->start;
|
||||||
select_printf ("stuff_start %p", &stuff->start);
|
select_printf ("stuff_start %p", &stuff->start);
|
||||||
si->thread = new cygthread (thread_socket, (LPVOID) si, "select_socket");
|
si->thread = new cygthread (thread_socket, (LPVOID) si, "select_socket");
|
||||||
@ -1339,7 +1339,7 @@ err:
|
|||||||
void
|
void
|
||||||
socket_cleanup (select_record *, select_stuff *stuff)
|
socket_cleanup (select_record *, select_stuff *stuff)
|
||||||
{
|
{
|
||||||
socketinf *si = (socketinf *) stuff->device_specific[FHDEVN (FH_SOCKET)];
|
socketinf *si = (socketinf *) stuff->device_specific_socket;
|
||||||
select_printf ("si %p si->thread %p", si, si ? si->thread : NULL);
|
select_printf ("si %p si->thread %p", si, si ? si->thread : NULL);
|
||||||
if (si && si->thread)
|
if (si && si->thread)
|
||||||
{
|
{
|
||||||
@ -1367,7 +1367,7 @@ socket_cleanup (select_record *, select_stuff *stuff)
|
|||||||
si->thread->detach ();
|
si->thread->detach ();
|
||||||
shutdown (si->exitsock, SD_BOTH);
|
shutdown (si->exitsock, SD_BOTH);
|
||||||
closesocket (si->exitsock);
|
closesocket (si->exitsock);
|
||||||
stuff->device_specific[FHDEVN (FH_SOCKET)] = NULL;
|
stuff->device_specific_socket = NULL;
|
||||||
delete si;
|
delete si;
|
||||||
}
|
}
|
||||||
select_printf ("returning");
|
select_printf ("returning");
|
||||||
|
@ -16,8 +16,8 @@ details. */
|
|||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include "pinfo.h"
|
#include "pinfo.h"
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include "fhandler.h"
|
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
|
@ -44,10 +44,11 @@ class mount_item
|
|||||||
|
|
||||||
#define MOUNT_VERSION 27 // increment when mount table changes and
|
#define MOUNT_VERSION 27 // increment when mount table changes and
|
||||||
#define MOUNT_VERSION_MAGIC CYGWIN_VERSION_MAGIC (MOUNT_MAGIC, MOUNT_VERSION)
|
#define MOUNT_VERSION_MAGIC CYGWIN_VERSION_MAGIC (MOUNT_MAGIC, MOUNT_VERSION)
|
||||||
#define CURR_MOUNT_MAGIC 0x4fe431cdU
|
#define CURR_MOUNT_MAGIC 0x6dd73a3fU
|
||||||
#define MOUNT_INFO_CB 16488
|
#define MOUNT_INFO_CB 16488
|
||||||
|
|
||||||
class reg_key;
|
class reg_key;
|
||||||
|
struct device;
|
||||||
|
|
||||||
/* NOTE: Do not make gratuitous changes to the names or organization of the
|
/* NOTE: Do not make gratuitous changes to the names or organization of the
|
||||||
below class. The layout is checksummed to determine compatibility between
|
below class. The layout is checksummed to determine compatibility between
|
||||||
@ -86,8 +87,8 @@ class mount_info
|
|||||||
int del_reg_mount (const char * posix_path, unsigned mountflags);
|
int del_reg_mount (const char * posix_path, unsigned mountflags);
|
||||||
|
|
||||||
unsigned set_flags_from_win32_path (const char *path);
|
unsigned set_flags_from_win32_path (const char *path);
|
||||||
int conv_to_win32_path (const char *src_path, char *dst, DWORD &devn,
|
int conv_to_win32_path (const char *src_path, char *dst, device&,
|
||||||
int &unit, unsigned *flags = NULL, bool no_normalize = 0);
|
unsigned *flags = NULL, bool no_normalize = 0);
|
||||||
int conv_to_posix_path (const char *src_path, char *posix_path,
|
int conv_to_posix_path (const char *src_path, char *posix_path,
|
||||||
int keep_rel_p);
|
int keep_rel_p);
|
||||||
struct mntent *getmntent (int x);
|
struct mntent *getmntent (int x);
|
||||||
|
@ -182,8 +182,6 @@ kill_worker (pid_t pid, int sig)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
dest->setthread2signal (NULL);
|
|
||||||
|
|
||||||
if ((sendSIGCONT = (sig < 0)))
|
if ((sendSIGCONT = (sig < 0)))
|
||||||
sig = -sig;
|
sig = -sig;
|
||||||
|
|
||||||
|
@ -23,12 +23,11 @@ details. */
|
|||||||
#include "sigproc.h"
|
#include "sigproc.h"
|
||||||
#include "pinfo.h"
|
#include "pinfo.h"
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include "fhandler.h"
|
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
#include "child_info_magic.h"
|
#include "child_info_magic.h"
|
||||||
#define NEED_VFORK
|
|
||||||
#include "perthread.h"
|
#include "perthread.h"
|
||||||
#include "shared_info.h"
|
#include "shared_info.h"
|
||||||
#include "cygthread.h"
|
#include "cygthread.h"
|
||||||
@ -49,14 +48,33 @@ details. */
|
|||||||
|
|
||||||
#define NZOMBIES 256
|
#define NZOMBIES 256
|
||||||
|
|
||||||
static LONG local_sigtodo[TOTSIGS];
|
class sigelem
|
||||||
struct sigaction *global_sigs;
|
|
||||||
|
|
||||||
inline LONG *
|
|
||||||
getlocal_sigtodo (int sig)
|
|
||||||
{
|
{
|
||||||
return local_sigtodo + __SIGOFFSET + sig;
|
int sig;
|
||||||
}
|
class sigelem *next;
|
||||||
|
friend class pending_signals;
|
||||||
|
friend int __stdcall sig_dispatch_pending ();
|
||||||
|
};
|
||||||
|
|
||||||
|
class pending_signals
|
||||||
|
{
|
||||||
|
sigelem sigs[NSIG + 1];
|
||||||
|
sigelem start;
|
||||||
|
sigelem *end;
|
||||||
|
sigelem *prev;
|
||||||
|
sigelem *curr;
|
||||||
|
int empty;
|
||||||
|
public:
|
||||||
|
void reset () {curr = &start; prev = &start;}
|
||||||
|
void add (int sig);
|
||||||
|
void del ();
|
||||||
|
int next ();
|
||||||
|
friend int __stdcall sig_dispatch_pending ();
|
||||||
|
};
|
||||||
|
|
||||||
|
static pending_signals sigqueue;
|
||||||
|
|
||||||
|
struct sigaction *global_sigs;
|
||||||
|
|
||||||
void __stdcall
|
void __stdcall
|
||||||
sigalloc ()
|
sigalloc ()
|
||||||
@ -88,7 +106,7 @@ char NO_COPY myself_nowait_dummy[1] = {'0'};// Flag to sig_send that signal goes
|
|||||||
// current process but no wait is required
|
// current process but no wait is required
|
||||||
char NO_COPY myself_nowait_nonmain_dummy[1] = {'1'};// Flag to sig_send that signal goes to
|
char NO_COPY myself_nowait_nonmain_dummy[1] = {'1'};// Flag to sig_send that signal goes to
|
||||||
// current process but no wait is required
|
// current process but no wait is required
|
||||||
// if this is not the main thread.
|
// if this is the main thread.
|
||||||
|
|
||||||
HANDLE NO_COPY signal_arrived; // Event signaled when a signal has
|
HANDLE NO_COPY signal_arrived; // Event signaled when a signal has
|
||||||
// resulted in a user-specified
|
// resulted in a user-specified
|
||||||
@ -107,20 +125,9 @@ HANDLE NO_COPY signal_arrived; // Event signaled when a signal has
|
|||||||
Static DWORD proc_loop_wait = 1000; // Wait for subprocesses to exit
|
Static DWORD proc_loop_wait = 1000; // Wait for subprocesses to exit
|
||||||
Static DWORD sig_loop_wait = INFINITE; // Wait for signals to arrive
|
Static DWORD sig_loop_wait = INFINITE; // Wait for signals to arrive
|
||||||
|
|
||||||
Static HANDLE sigcatch_nonmain; // The semaphore signaled when
|
|
||||||
// signals are available for
|
|
||||||
// processing from non-main thread
|
|
||||||
Static HANDLE sigcatch_main; // Signalled when main thread sends a
|
|
||||||
// signal
|
|
||||||
Static HANDLE sigcatch_nosync; // Signal wait_sig to scan sigtodo
|
|
||||||
// but not to bother with any
|
|
||||||
// synchronization
|
|
||||||
Static HANDLE sigcomplete_main; // Event signaled when a signal has
|
Static HANDLE sigcomplete_main; // Event signaled when a signal has
|
||||||
// finished processing for the main
|
// finished processing for the main
|
||||||
// thread
|
// thread
|
||||||
Static HANDLE sigcomplete_nonmain; // Semaphore raised for non-main
|
|
||||||
// threads when a signal has finished
|
|
||||||
// processing
|
|
||||||
HANDLE NO_COPY sigCONT; // Used to "STOP" a process
|
HANDLE NO_COPY sigCONT; // Used to "STOP" a process
|
||||||
Static cygthread *hwait_sig; // Handle of wait_sig thread
|
Static cygthread *hwait_sig; // Handle of wait_sig thread
|
||||||
Static cygthread *hwait_subproc; // Handle of sig_subproc thread
|
Static cygthread *hwait_subproc; // Handle of sig_subproc thread
|
||||||
@ -147,13 +154,10 @@ muto NO_COPY *sync_proc_subproc = NULL; // Control access to subproc stuff
|
|||||||
|
|
||||||
DWORD NO_COPY sigtid = 0; // ID of the signal thread
|
DWORD NO_COPY sigtid = 0; // ID of the signal thread
|
||||||
|
|
||||||
bool NO_COPY pending_signals = false; // true if signals pending
|
|
||||||
|
|
||||||
/* Functions
|
/* Functions
|
||||||
*/
|
*/
|
||||||
static int __stdcall checkstate (waitq *) __attribute__ ((regparm (1)));
|
static int __stdcall checkstate (waitq *) __attribute__ ((regparm (1)));
|
||||||
static __inline__ BOOL get_proc_lock (DWORD, DWORD);
|
static __inline__ BOOL get_proc_lock (DWORD, DWORD);
|
||||||
static HANDLE __stdcall getevent (_pinfo *, const char *) __attribute__ ((regparm (2)));
|
|
||||||
static void __stdcall remove_zombie (int);
|
static void __stdcall remove_zombie (int);
|
||||||
static DWORD WINAPI wait_sig (VOID *arg);
|
static DWORD WINAPI wait_sig (VOID *arg);
|
||||||
static int __stdcall stopped_or_terminated (waitq *, _pinfo *);
|
static int __stdcall stopped_or_terminated (waitq *, _pinfo *);
|
||||||
@ -530,56 +534,45 @@ proc_terminate (void)
|
|||||||
sigproc_printf ("leaving");
|
sigproc_printf ("leaving");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clear pending signal from the sigtodo array
|
/* Clear pending signal */
|
||||||
*/
|
|
||||||
void __stdcall
|
void __stdcall
|
||||||
sig_clear (int sig)
|
sig_clear (int target_sig)
|
||||||
{
|
{
|
||||||
(void) InterlockedExchange (myself->getsigtodo (sig), 0L);
|
if (GetCurrentThreadId () != sigtid)
|
||||||
(void) InterlockedExchange (getlocal_sigtodo (sig), 0L);
|
sig_send (myself, -target_sig);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int sig;
|
||||||
|
sigqueue.reset ();
|
||||||
|
while ((sig = sigqueue.next ()))
|
||||||
|
if (sig == target_sig)
|
||||||
|
{
|
||||||
|
sigqueue.del ();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" int
|
extern "C" int
|
||||||
sigpending (sigset_t *set)
|
sigpending (sigset_t *mask)
|
||||||
{
|
{
|
||||||
unsigned bit;
|
sigset_t outset = (sigset_t) sig_send (myself, __SIGPENDING);
|
||||||
*set = 0;
|
if (outset == SIG_BAD_MASK)
|
||||||
for (int sig = 1; sig < NSIG; sig++)
|
return -1;
|
||||||
if ((*getlocal_sigtodo (sig) || *myself->getsigtodo (sig))
|
*mask = outset;
|
||||||
&& (myself->getsigmask () & (bit = SIGTOMASK (sig))))
|
|
||||||
*set |= bit;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Force the wait_sig thread to wake up and scan the sigtodo array.
|
/* Force the wait_sig thread to wake up and scan for pending signals */
|
||||||
*/
|
int __stdcall
|
||||||
extern "C" int __stdcall
|
|
||||||
sig_dispatch_pending ()
|
sig_dispatch_pending ()
|
||||||
{
|
{
|
||||||
if (exit_state || !hwait_sig || GetCurrentThreadId () == sigtid)
|
if (exit_state || GetCurrentThreadId () == sigtid || !sigqueue.start.next)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
sigframe thisframe (mainthread);
|
sigframe thisframe (mainthread);
|
||||||
|
(void) sig_send (myself, __SIGFLUSH);
|
||||||
#ifdef DEBUGGING
|
|
||||||
sigproc_printf ("pending_signals %d", pending_signals);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!pending_signals)
|
|
||||||
#ifdef DEBUGGING
|
|
||||||
sigproc_printf ("no need to wake anything up");
|
|
||||||
#else
|
|
||||||
;
|
|
||||||
#endif
|
|
||||||
else
|
|
||||||
{
|
|
||||||
(void) sig_send (myself, __SIGFLUSH);
|
|
||||||
#ifdef DEBUGGING
|
|
||||||
sigproc_printf ("woke up wait_sig");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
return thisframe.call_signal_handler ();
|
return thisframe.call_signal_handler ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -641,12 +634,7 @@ sigproc_terminate (void)
|
|||||||
sig_loop_wait = 0; // Tell wait_sig to exit when it is
|
sig_loop_wait = 0; // Tell wait_sig to exit when it is
|
||||||
// finished with anything it is doing
|
// finished with anything it is doing
|
||||||
ForceCloseHandle (sigcomplete_main);
|
ForceCloseHandle (sigcomplete_main);
|
||||||
for (int i = 0; i < 20; i++)
|
CloseHandle (myself->sendsig);
|
||||||
(void) ReleaseSemaphore (sigcomplete_nonmain, 1, NULL);
|
|
||||||
// ForceCloseHandle (sigcomplete_nonmain);
|
|
||||||
// ForceCloseHandle (sigcatch_main);
|
|
||||||
// ForceCloseHandle (sigcatch_nonmain);
|
|
||||||
// ForceCloseHandle (sigcatch_nosync);
|
|
||||||
}
|
}
|
||||||
proc_terminate (); // Terminate process handling thread
|
proc_terminate (); // Terminate process handling thread
|
||||||
|
|
||||||
@ -664,15 +652,15 @@ sig_send (_pinfo *p, int sig, DWORD ebp, bool exception)
|
|||||||
int rc = 1;
|
int rc = 1;
|
||||||
DWORD tid = GetCurrentThreadId ();
|
DWORD tid = GetCurrentThreadId ();
|
||||||
BOOL its_me;
|
BOOL its_me;
|
||||||
HANDLE thiscatch = NULL;
|
HANDLE thiscomplete;
|
||||||
HANDLE thiscomplete = NULL;
|
HANDLE sendsig;
|
||||||
BOOL wait_for_completion;
|
bool wait_for_completion;
|
||||||
sigframe thisframe;
|
sigframe thisframe;
|
||||||
|
|
||||||
if (p == myself_nowait_nonmain)
|
if (p == myself_nowait_nonmain)
|
||||||
p = (tid == mainthread.id) ? (_pinfo *) myself : myself_nowait;
|
p = (tid == mainthread.id) ? (_pinfo *) myself : myself_nowait;
|
||||||
if (!(its_me = (p == NULL || p == myself || p == myself_nowait)))
|
if (!(its_me = (p == NULL || p == myself || p == myself_nowait)))
|
||||||
wait_for_completion = FALSE;
|
wait_for_completion = false;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (no_signals_available ())
|
if (no_signals_available ())
|
||||||
@ -696,79 +684,78 @@ sig_send (_pinfo *p, int sig, DWORD ebp, bool exception)
|
|||||||
|
|
||||||
sigproc_printf ("pid %d, signal %d, its_me %d", p->pid, sig, its_me);
|
sigproc_printf ("pid %d, signal %d, its_me %d", p->pid, sig, its_me);
|
||||||
|
|
||||||
LONG *todo;
|
|
||||||
bool issem;
|
|
||||||
if (its_me)
|
if (its_me)
|
||||||
{
|
{
|
||||||
if (!wait_for_completion)
|
sendsig = myself->sendsig;
|
||||||
|
if (wait_for_completion)
|
||||||
{
|
{
|
||||||
thiscatch = sigcatch_nosync;
|
if (tid == mainthread.id)
|
||||||
todo = myself->getsigtodo (sig);
|
thisframe.init (mainthread, ebp, exception);
|
||||||
issem = false;
|
|
||||||
}
|
|
||||||
else if (tid != mainthread.id)
|
|
||||||
{
|
|
||||||
thiscatch = sigcatch_nonmain;
|
|
||||||
thiscomplete = sigcomplete_nonmain;
|
|
||||||
todo = getlocal_sigtodo (sig);
|
|
||||||
issem = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
thiscatch = sigcatch_main;
|
|
||||||
thiscomplete = sigcomplete_main;
|
thiscomplete = sigcomplete_main;
|
||||||
thisframe.init (mainthread, ebp, exception);
|
|
||||||
todo = getlocal_sigtodo (sig);
|
|
||||||
issem = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((thiscatch = getevent (p, "sigcatch")))
|
|
||||||
{
|
|
||||||
todo = p->getsigtodo (sig);
|
|
||||||
if (IsBadWritePtr (todo, sizeof (*todo)))
|
|
||||||
{
|
|
||||||
set_errno (EACCES);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
issem = false;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
goto out; // Couldn't get the semaphore. getevent issued
|
{
|
||||||
// an error, if appropriate.
|
HANDLE hp = OpenProcess (PROCESS_DUP_HANDLE, false, p->dwProcessId);
|
||||||
|
if (!hp)
|
||||||
|
{
|
||||||
|
__seterrno ();
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
if (!DuplicateHandle (hp, p->sendsig, hMainProc, &sendsig, false, 0,
|
||||||
|
DUPLICATE_SAME_ACCESS) || !sendsig)
|
||||||
|
{
|
||||||
|
__seterrno ();
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
thiscomplete = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
#if WHEN_MULTI_THREAD_SIGNALS_WORK
|
DWORD nb;
|
||||||
signal_dispatch *sd;
|
if (!WriteFile (sendsig, &sig, sizeof (sig), &nb, NULL) || nb != sizeof (sig))
|
||||||
sd = signal_dispatch_storage.get ();
|
|
||||||
if (sd == NULL)
|
|
||||||
sd = signal_dispatch_storage.create ();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Increment the sigtodo array to signify which signal to assert.
|
|
||||||
*/
|
|
||||||
(void) InterlockedIncrement (todo);
|
|
||||||
|
|
||||||
/* Notify the process that a signal has arrived.
|
|
||||||
*/
|
|
||||||
if (issem ? !ReleaseSemaphore (thiscatch, 1, NULL) : !SetEvent (thiscatch))
|
|
||||||
{
|
{
|
||||||
/* Couldn't signal the semaphore. This probably means that the
|
/* Couldn't signal the semaphore. This probably means that the
|
||||||
* process is exiting.
|
* process is exiting.
|
||||||
*/
|
*/
|
||||||
if (!its_me)
|
if (!its_me)
|
||||||
ForceCloseHandle (thiscatch);
|
{
|
||||||
|
__seterrno ();
|
||||||
|
ForceCloseHandle (sendsig);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (no_signals_available ())
|
if (no_signals_available ())
|
||||||
sigproc_printf ("I'm going away now");
|
sigproc_printf ("I'm going away now");
|
||||||
else if ((int) GetLastError () == -1)
|
|
||||||
rc = WaitForSingleObject (thiscomplete, 500);
|
|
||||||
else
|
else
|
||||||
system_printf ("error sending signal %d to pid %d, semaphore %p, %E",
|
system_printf ("error sending signal %d to pid %d, pipe handle %p, %E",
|
||||||
sig, p->pid, thiscatch);
|
sig, p->pid, sendsig);
|
||||||
}
|
}
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Write completion handle or NULL */
|
||||||
|
if (!WriteFile (sendsig, &thiscomplete, sizeof (thiscomplete), &nb, NULL)
|
||||||
|
|| nb != sizeof (thiscomplete))
|
||||||
|
{
|
||||||
|
__seterrno ();
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
sigset_t pending;
|
||||||
|
sigset_t *mask;
|
||||||
|
if (sig == __SIGPENDING)
|
||||||
|
mask = &pending;
|
||||||
|
else if (sig == __SIGFLUSH || sig > 0)
|
||||||
|
mask = &myself->getsigmask ();
|
||||||
|
else
|
||||||
|
mask = NULL;
|
||||||
|
if (mask && !WriteFile (sendsig, &mask, sizeof (mask), &nb, NULL)
|
||||||
|
|| nb != sizeof (pending))
|
||||||
|
{
|
||||||
|
__seterrno ();
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
/* No need to wait for signal completion unless this was a signal to
|
/* No need to wait for signal completion unless this was a signal to
|
||||||
* this process.
|
* this process.
|
||||||
*
|
*
|
||||||
@ -781,7 +768,7 @@ sig_send (_pinfo *p, int sig, DWORD ebp, bool exception)
|
|||||||
rc = WAIT_OBJECT_0;
|
rc = WAIT_OBJECT_0;
|
||||||
sigproc_printf ("Not waiting for sigcomplete. its_me %d signal %d", its_me, sig);
|
sigproc_printf ("Not waiting for sigcomplete. its_me %d signal %d", its_me, sig);
|
||||||
if (!its_me)
|
if (!its_me)
|
||||||
ForceCloseHandle (thiscatch);
|
ForceCloseHandle (sendsig);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -802,19 +789,16 @@ sig_send (_pinfo *p, int sig, DWORD ebp, bool exception)
|
|||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
sigproc_printf ("returning %d from sending signal %d", rc, sig);
|
if (sig != __SIGPENDING)
|
||||||
|
/* nothing */;
|
||||||
|
else if (!rc)
|
||||||
|
rc = (int) pending;
|
||||||
|
else
|
||||||
|
rc = SIG_BAD_MASK;
|
||||||
|
sigproc_printf ("returning %p from sending signal %d", rc, sig);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set pending signal from the sigtodo array
|
|
||||||
*/
|
|
||||||
void __stdcall
|
|
||||||
sig_set_pending (int sig)
|
|
||||||
{
|
|
||||||
(void) InterlockedIncrement (getlocal_sigtodo (sig));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Initialize the wait_subproc thread.
|
/* Initialize the wait_subproc thread.
|
||||||
* Called from fork() or spawn() to initialize the handling of subprocesses.
|
* Called from fork() or spawn() to initialize the handling of subprocesses.
|
||||||
*/
|
*/
|
||||||
@ -896,71 +880,6 @@ out:
|
|||||||
return potential_match;
|
return potential_match;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get or create a process specific semaphore used in message passing.
|
|
||||||
*/
|
|
||||||
static HANDLE __stdcall
|
|
||||||
getevent (_pinfo *p, const char *str)
|
|
||||||
{
|
|
||||||
HANDLE h;
|
|
||||||
char sem_name[MAX_PATH];
|
|
||||||
|
|
||||||
if (p != NULL)
|
|
||||||
{
|
|
||||||
if (!proc_can_be_signalled (p))
|
|
||||||
{
|
|
||||||
set_errno (ESRCH);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
int wait = 1000;
|
|
||||||
/* Wait for new process to generate its semaphores. */
|
|
||||||
sigproc_printf ("pid %d, ppid %d, wait %d, initializing %x", p->pid, p->ppid, wait,
|
|
||||||
ISSTATE (p, PID_INITIALIZING));
|
|
||||||
for (int i = 0; ISSTATE (p, PID_INITIALIZING) && i < wait; i++)
|
|
||||||
low_priority_sleep (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (p == NULL)
|
|
||||||
{
|
|
||||||
char sa_buf[1024];
|
|
||||||
|
|
||||||
DWORD winpid = GetCurrentProcessId ();
|
|
||||||
#if 0
|
|
||||||
h = CreateSemaphore (sec_user_nih (sa_buf), init, max,
|
|
||||||
str = shared_name (sem_name, str, winpid));
|
|
||||||
#else
|
|
||||||
h = CreateEvent (sec_user_nih (sa_buf), FALSE, FALSE,
|
|
||||||
str = shared_name (sem_name, str, winpid));
|
|
||||||
#endif
|
|
||||||
p = myself;
|
|
||||||
if (!h)
|
|
||||||
{
|
|
||||||
system_printf ("can't create semaphore %s, %E", str);
|
|
||||||
__seterrno ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
#if 0
|
|
||||||
h = OpenSemaphore (SEMAPHORE_ALL_ACCESS, FALSE,
|
|
||||||
shared_name (sem_name, str, p->dwProcessId));
|
|
||||||
#else
|
|
||||||
h = OpenEvent (EVENT_ALL_ACCESS, FALSE,
|
|
||||||
shared_name (sem_name, str, p->dwProcessId));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!h)
|
|
||||||
{
|
|
||||||
if (GetLastError () == ERROR_FILE_NOT_FOUND && !proc_exists (p))
|
|
||||||
set_errno (ESRCH); /* No such process */
|
|
||||||
else
|
|
||||||
set_errno (EPERM); /* Couldn't access the semaphore --
|
|
||||||
different cygwin DLL maybe? */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return h;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Remove a zombie from zombies by swapping it with the last child in the list.
|
/* Remove a zombie from zombies by swapping it with the last child in the list.
|
||||||
*/
|
*/
|
||||||
static void __stdcall
|
static void __stdcall
|
||||||
@ -1063,62 +982,94 @@ talktome ()
|
|||||||
pids[i]->commune_recv ();
|
pids[i]->commune_recv ();
|
||||||
}
|
}
|
||||||
|
|
||||||
#define RC_MAIN 0
|
|
||||||
#define RC_NONMAIN 1
|
|
||||||
#define RC_NOSYNC 2
|
|
||||||
/* Process signals by waiting for a semaphore to become signaled.
|
/* Process signals by waiting for a semaphore to become signaled.
|
||||||
* Then scan an in-memory array representing queued signals.
|
Then scan an in-memory array representing queued signals.
|
||||||
* Executes in a separate thread.
|
Executes in a separate thread.
|
||||||
*
|
|
||||||
* Signals sent from this process are sent a completion signal so
|
Signals sent from this process are sent a completion signal so
|
||||||
* that returns from kill/raise do not occur until the signal has
|
that returns from kill/raise do not occur until the signal has
|
||||||
* has been handled, as per POSIX.
|
has been handled, as per POSIX. */
|
||||||
*/
|
|
||||||
|
void
|
||||||
|
pending_signals::add (int sig)
|
||||||
|
{
|
||||||
|
sigelem *se;
|
||||||
|
for (se = start.next; se; se = se->next)
|
||||||
|
if (se->sig == sig)
|
||||||
|
return;
|
||||||
|
while (sigs[empty].sig)
|
||||||
|
if (++empty == NSIG)
|
||||||
|
empty = 0;
|
||||||
|
se = sigs + empty;
|
||||||
|
se->sig = sig;
|
||||||
|
se->next = NULL;
|
||||||
|
if (end)
|
||||||
|
end->next = se;
|
||||||
|
end = se;
|
||||||
|
if (!start.next)
|
||||||
|
start.next = se;
|
||||||
|
empty++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
pending_signals::del ()
|
||||||
|
{
|
||||||
|
sigelem *next = curr->next;
|
||||||
|
prev->next = next;
|
||||||
|
curr->sig = 0;
|
||||||
|
#ifdef DEBUGGING
|
||||||
|
curr->next = NULL;
|
||||||
|
#endif
|
||||||
|
if (end == curr)
|
||||||
|
end = prev;
|
||||||
|
empty = curr - sigs;
|
||||||
|
curr = next;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
pending_signals::next ()
|
||||||
|
{
|
||||||
|
int sig;
|
||||||
|
prev = curr;
|
||||||
|
if (!curr || !(curr = curr->next))
|
||||||
|
sig = 0;
|
||||||
|
else
|
||||||
|
sig = curr->sig;
|
||||||
|
return sig;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Process signals by waiting for signal data to arrive in a pipe.
|
||||||
|
Set a completion event if one was specified. */
|
||||||
static DWORD WINAPI
|
static DWORD WINAPI
|
||||||
wait_sig (VOID *self)
|
wait_sig (VOID *self)
|
||||||
{
|
{
|
||||||
LONG *todos[] = {getlocal_sigtodo (0), myself->getsigtodo (0)};
|
HANDLE readsig;
|
||||||
|
char sa_buf[1024];
|
||||||
|
|
||||||
/* Initialization */
|
/* Initialization */
|
||||||
(void) SetThreadPriority (GetCurrentThread (), WAIT_SIG_PRIORITY);
|
(void) SetThreadPriority (GetCurrentThread (), WAIT_SIG_PRIORITY);
|
||||||
|
|
||||||
/* sigcatch_nosync - semaphore incremented by sig_dispatch_pending and
|
/* sigcomplete_main - event used to signal main thread on signal
|
||||||
* by foreign processes to force an examination of
|
completion */
|
||||||
* the sigtodo array.
|
if (!CreatePipe (&readsig, &myself->sendsig, sec_user_nih (sa_buf), 0))
|
||||||
* sigcatch_main - ditto for local main thread.
|
api_fatal ("couldn't create signal pipe, %E");
|
||||||
* sigcatch_nonmain - ditto for local non-main threads.
|
|
||||||
*
|
|
||||||
* sigcomplete_main - event used to signal main thread on signal
|
|
||||||
* completion
|
|
||||||
* sigcomplete_nonmain - semaphore signaled for non-main thread on signal
|
|
||||||
* completion
|
|
||||||
*/
|
|
||||||
sigcatch_nosync = getevent (NULL, "sigcatch");
|
|
||||||
sigcatch_nonmain = CreateSemaphore (&sec_none_nih, 0, MAXLONG, NULL);
|
|
||||||
sigcatch_main = CreateSemaphore (&sec_none_nih, 0, MAXLONG, NULL);
|
|
||||||
sigcomplete_nonmain = CreateSemaphore (&sec_none_nih, 0, MAXLONG, NULL);
|
|
||||||
sigcomplete_main = CreateEvent (&sec_none_nih, FALSE, FALSE, NULL);
|
sigcomplete_main = CreateEvent (&sec_none_nih, FALSE, FALSE, NULL);
|
||||||
sigproc_printf ("sigcatch_nonmain %p, sigcatch_main %p", sigcatch_nonmain, sigcatch_main);
|
sigproc_printf ("sigcomplete_main %p", sigcomplete_main);
|
||||||
sigCONT = CreateEvent (&sec_none_nih, FALSE, FALSE, NULL);
|
sigCONT = CreateEvent (&sec_none_nih, FALSE, FALSE, NULL);
|
||||||
|
|
||||||
/* Setting dwProcessId flags that this process is now capable of receiving
|
/* Setting dwProcessId flags that this process is now capable of receiving
|
||||||
* signals. Prior to this, dwProcessId was set to the windows pid of
|
signals. Prior to this, dwProcessId was set to the windows pid of
|
||||||
* of the original windows process which spawned us unless this was a
|
of the original windows process which spawned us unless this was a
|
||||||
* "toplevel" process.
|
"toplevel" process. */
|
||||||
*/
|
|
||||||
myself->dwProcessId = GetCurrentProcessId ();
|
myself->dwProcessId = GetCurrentProcessId ();
|
||||||
myself->process_state |= PID_ACTIVE;
|
myself->process_state |= PID_ACTIVE;
|
||||||
myself->process_state &= ~PID_INITIALIZING;
|
myself->process_state &= ~PID_INITIALIZING;
|
||||||
|
|
||||||
ProtectHandle (sigcatch_nosync);
|
|
||||||
ProtectHandle (sigcatch_nonmain);
|
|
||||||
ProtectHandle (sigcatch_main);
|
|
||||||
ProtectHandle (sigcomplete_nonmain);
|
|
||||||
ProtectHandle (sigcomplete_main);
|
ProtectHandle (sigcomplete_main);
|
||||||
|
|
||||||
/* If we've been execed, then there is still a stub left in the previous
|
/* If we've been execed, then there is still a stub left in the previous
|
||||||
* windows process waiting to see if it's started a cygwin process or not.
|
windows process waiting to see if it's started a cygwin process or not.
|
||||||
* Signalling subproc_ready indicates that we are a cygwin process.
|
Signalling subproc_ready indicates that we are a cygwin process. */
|
||||||
*/
|
|
||||||
if (child_proc_info && child_proc_info->type == PROC_EXEC)
|
if (child_proc_info && child_proc_info->type == PROC_EXEC)
|
||||||
{
|
{
|
||||||
debug_printf ("subproc_ready %p", child_proc_info->subproc_ready);
|
debug_printf ("subproc_ready %p", child_proc_info->subproc_ready);
|
||||||
@ -1135,149 +1086,71 @@ wait_sig (VOID *self)
|
|||||||
SetEvent (wait_sig_inited);
|
SetEvent (wait_sig_inited);
|
||||||
sigtid = GetCurrentThreadId ();
|
sigtid = GetCurrentThreadId ();
|
||||||
|
|
||||||
HANDLE catchem[] = {sigcatch_main, sigcatch_nonmain, sigcatch_nosync};
|
|
||||||
sigproc_printf ("Ready. dwProcessid %d", myself->dwProcessId);
|
|
||||||
DWORD rc = RC_NOSYNC;
|
|
||||||
bool flush = false;
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
DWORD i;
|
int sig;
|
||||||
if (rc == RC_MAIN || rc == RC_NONMAIN)
|
DWORD nb;
|
||||||
i = RC_NOSYNC;
|
if (!ReadFile (readsig, &sig, sizeof (sig), &nb, NULL))
|
||||||
else
|
break;
|
||||||
i = RC_MAIN;
|
|
||||||
rc = WaitForSingleObject (catchem[i], 0);
|
|
||||||
if (rc != WAIT_OBJECT_0)
|
|
||||||
rc = WaitForMultipleObjects (3, catchem, FALSE, sig_loop_wait);
|
|
||||||
else
|
|
||||||
rc = i + WAIT_OBJECT_0;
|
|
||||||
(void) SetThreadPriority (GetCurrentThread (), WAIT_SIG_PRIORITY);
|
|
||||||
|
|
||||||
/* sigproc_terminate sets sig_loop_wait to zero to indicate that
|
HANDLE wakeup;
|
||||||
this thread should terminate. */
|
if (!ReadFile (readsig, &wakeup, sizeof (wakeup), &nb, NULL)
|
||||||
if (rc == WAIT_TIMEOUT)
|
|| nb != sizeof (wakeup))
|
||||||
{
|
{
|
||||||
if (!sig_loop_wait)
|
system_printf ("signal notification handle read failure, %E");
|
||||||
break; // Exiting
|
continue;
|
||||||
else
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rc == WAIT_FAILED)
|
if (!sig)
|
||||||
|
continue; /* Just checking to see if we exist */
|
||||||
|
|
||||||
|
sigset_t *mask;
|
||||||
|
if ((sig == __SIGFLUSH || sig == __SIGPENDING || sig > 0)
|
||||||
|
&& (!ReadFile (readsig, &mask, sizeof (mask), &nb, NULL)
|
||||||
|
|| nb != sizeof (mask)))
|
||||||
{
|
{
|
||||||
if (sig_loop_wait != 0)
|
system_printf ("signal mask handle read failure, %E");
|
||||||
system_printf ("WFMO failed, %E");
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (sig)
|
||||||
|
{
|
||||||
|
case __SIGCOMMUNE:
|
||||||
|
talktome ();
|
||||||
|
continue;
|
||||||
|
case __SIGSTRACE:
|
||||||
|
strace.hello ();
|
||||||
|
continue;
|
||||||
|
case __SIGPENDING:
|
||||||
|
*mask = 0;
|
||||||
|
unsigned bit;
|
||||||
|
sigqueue.reset ();
|
||||||
|
while ((sig = sigqueue.next ()))
|
||||||
|
if (myself->getsigmask () & (bit = SIGTOMASK (sig)))
|
||||||
|
*mask |= bit;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (sig < 0)
|
||||||
|
sig_clear (-sig);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int sh;
|
||||||
|
for (int i = 0; !(sh = sig_handle (sig, *mask)) && i < 100 ; i++)
|
||||||
|
low_priority_sleep (0); // hopefully a temporary condition
|
||||||
|
if (sh <= 0)
|
||||||
|
sigqueue.add (sig); // FIXME: Shouldn't add this in !sh condition
|
||||||
|
if (sig == SIGCHLD)
|
||||||
|
proc_subproc (PROC_CLEARWAIT, 0);
|
||||||
|
}
|
||||||
|
case __SIGFLUSH:
|
||||||
|
sigqueue.reset ();
|
||||||
|
while ((sig = sigqueue.next ()))
|
||||||
|
if (sig_handle (sig, *mask) > 0)
|
||||||
|
sigqueue.del ();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (wakeup)
|
||||||
rc -= WAIT_OBJECT_0;
|
SetEvent (wakeup);
|
||||||
sigproc_printf ("awake, rc %d", rc);
|
|
||||||
LONG *todo;
|
|
||||||
if (rc != RC_NOSYNC)
|
|
||||||
todo = todos[0];
|
|
||||||
else
|
|
||||||
todo = todos[1];
|
|
||||||
|
|
||||||
/* A sigcatch semaphore has been signaled. Scan the sigtodo
|
|
||||||
array looking for any unprocessed signals. */
|
|
||||||
pending_signals = false;
|
|
||||||
unsigned more_signals = 0;
|
|
||||||
bool saw_failed_interrupt = false;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
more_signals = 0;
|
|
||||||
for (int sig = -__SIGOFFSET; sig < NSIG; sig++)
|
|
||||||
{
|
|
||||||
LONG x = InterlockedDecrement (todo + sig);
|
|
||||||
if (x < 0)
|
|
||||||
InterlockedIncrement (todo + sig);
|
|
||||||
else if (x >= 0)
|
|
||||||
{
|
|
||||||
/* If x > 0, we have to deal with a signal at some later point */
|
|
||||||
if (rc != RC_NOSYNC && x > 0)
|
|
||||||
/*pending_signals = true*/; // There should be an armed semaphore, in this case
|
|
||||||
|
|
||||||
if (sig > 0 && sig != SIGKILL && sig != SIGSTOP &&
|
|
||||||
(sigismember (&myself->getsigmask (), sig) ||
|
|
||||||
main_vfork->pid ||
|
|
||||||
(sig != SIGCONT && ISSTATE (myself, PID_STOPPED))))
|
|
||||||
{
|
|
||||||
sigproc_printf ("signal %d blocked", sig);
|
|
||||||
x = InterlockedIncrement (myself->getsigtodo (sig));
|
|
||||||
/* pending_signals = true;*/ // will be set by set_process_mask
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sigproc_printf ("processing signal %d", sig);
|
|
||||||
switch (sig)
|
|
||||||
{
|
|
||||||
case __SIGFLUSH:
|
|
||||||
if (rc == RC_MAIN)
|
|
||||||
{
|
|
||||||
flush = true;
|
|
||||||
SetEvent (sigcatch_nosync);
|
|
||||||
goto out1;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
/* Internal signal to turn on stracing. */
|
|
||||||
case __SIGSTRACE:
|
|
||||||
strace.hello ();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case __SIGCOMMUNE:
|
|
||||||
talktome ();
|
|
||||||
break;
|
|
||||||
|
|
||||||
/* A normal UNIX signal */
|
|
||||||
default:
|
|
||||||
sigproc_printf ("Got signal %d", sig);
|
|
||||||
if (!sig_handle (sig))
|
|
||||||
{
|
|
||||||
pending_signals = true;
|
|
||||||
saw_failed_interrupt = true;
|
|
||||||
x = InterlockedIncrement (myself->getsigtodo (sig));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (rc == RC_NOSYNC && x > 0)
|
|
||||||
more_signals++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sig == SIGCHLD)
|
|
||||||
proc_subproc (PROC_CLEARWAIT, 0);
|
|
||||||
|
|
||||||
/* Need to take special action if an interrupt failed due to main thread not
|
|
||||||
getting around to calling handler yet. */
|
|
||||||
if (saw_failed_interrupt || rc != RC_NOSYNC)
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#ifdef DEBUGGING
|
|
||||||
if (more_signals > 100)
|
|
||||||
system_printf ("hmm. infinite loop? more_signals %u\n", more_signals);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
while (more_signals && sig_loop_wait);
|
|
||||||
|
|
||||||
out:
|
|
||||||
/* Signal completion of signal handling depending on which semaphore
|
|
||||||
woke up the WaitForMultipleObjects above. */
|
|
||||||
if (rc == RC_NONMAIN) // FIXME: This is broken
|
|
||||||
ReleaseSemaphore (sigcomplete_nonmain, 1, NULL);
|
|
||||||
else if (rc == RC_MAIN || flush)
|
|
||||||
{
|
|
||||||
SetEvent (sigcomplete_main);
|
|
||||||
sigproc_printf ("set main thread completion event");
|
|
||||||
flush = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
out1:
|
|
||||||
if (saw_failed_interrupt)
|
|
||||||
{
|
|
||||||
SetEvent (sigcatch_nosync);
|
|
||||||
low_priority_sleep (0); /* Hopefully, other thread will be waking up soon. */
|
|
||||||
}
|
|
||||||
sigproc_printf ("looping");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sigproc_printf ("done");
|
sigproc_printf ("done");
|
||||||
|
@ -16,6 +16,18 @@ details. */
|
|||||||
#define EXIT_REPARENTING 0x020000
|
#define EXIT_REPARENTING 0x020000
|
||||||
#define EXIT_NOCLOSEALL 0x040000
|
#define EXIT_NOCLOSEALL 0x040000
|
||||||
|
|
||||||
|
#ifdef NSIG
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
__SIGFLUSH = -(NSIG + 1),
|
||||||
|
__SIGSTRACE = -(NSIG + 2),
|
||||||
|
__SIGCOMMUNE = -(NSIG + 3),
|
||||||
|
__SIGPENDING = -(NSIG + 4)
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define SIG_BAD_MASK (1 << (SIGKILL - 1))
|
||||||
|
|
||||||
enum procstuff
|
enum procstuff
|
||||||
{
|
{
|
||||||
PROC_ADDCHILD = 1, // add a new subprocess to list
|
PROC_ADDCHILD = 1, // add a new subprocess to list
|
||||||
@ -98,10 +110,10 @@ extern HANDLE signal_arrived;
|
|||||||
extern HANDLE sigCONT;
|
extern HANDLE sigCONT;
|
||||||
|
|
||||||
BOOL __stdcall my_parent_is_alive ();
|
BOOL __stdcall my_parent_is_alive ();
|
||||||
extern "C" int __stdcall sig_dispatch_pending ();
|
int __stdcall sig_dispatch_pending ();
|
||||||
extern "C" void __stdcall set_process_mask (sigset_t newmask);
|
extern "C" void __stdcall set_process_mask (sigset_t newmask);
|
||||||
extern "C" void __stdcall reset_signal_arrived ();
|
extern "C" void __stdcall reset_signal_arrived ();
|
||||||
int __stdcall sig_handle (int) __attribute__ ((regparm (1)));
|
int __stdcall sig_handle (int, sigset_t) __attribute__ ((regparm (2)));
|
||||||
void __stdcall sig_clear (int) __attribute__ ((regparm (1)));
|
void __stdcall sig_clear (int) __attribute__ ((regparm (1)));
|
||||||
void __stdcall sig_set_pending (int) __attribute__ ((regparm (1)));
|
void __stdcall sig_set_pending (int) __attribute__ ((regparm (1)));
|
||||||
int __stdcall handle_sigsuspend (sigset_t);
|
int __stdcall handle_sigsuspend (sigset_t);
|
||||||
|
@ -15,7 +15,7 @@ details. */
|
|||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
int __small_sprintf (char *dst, const char *fmt,...);
|
int __small_sprintf (char *dst, const char *fmt, ...);
|
||||||
int __small_vsprintf (char *dst, const char *fmt, va_list ap);
|
int __small_vsprintf (char *dst, const char *fmt, va_list ap);
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
@ -108,7 +108,7 @@ __small_vsprintf (char *dst, const char *fmt, va_list ap)
|
|||||||
continue;
|
continue;
|
||||||
case 'c':
|
case 'c':
|
||||||
{
|
{
|
||||||
int c = va_arg (ap,int);
|
int c = va_arg (ap, int);
|
||||||
if (c > ' ' && c <= 127)
|
if (c > ' ' && c <= 127)
|
||||||
*dst++ = c;
|
*dst++ = c;
|
||||||
else
|
else
|
||||||
@ -180,7 +180,7 @@ __small_vsprintf (char *dst, const char *fmt, va_list ap)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
__small_sprintf (char *dst, const char *fmt,...)
|
__small_sprintf (char *dst, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
@ -191,7 +191,7 @@ __small_sprintf (char *dst, const char *fmt,...)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
small_printf (const char *fmt,...)
|
small_printf (const char *fmt, ...)
|
||||||
{
|
{
|
||||||
char buf[16384];
|
char buf[16384];
|
||||||
va_list ap;
|
va_list ap;
|
||||||
@ -218,7 +218,7 @@ small_printf (const char *fmt,...)
|
|||||||
#ifdef DEBUGGING
|
#ifdef DEBUGGING
|
||||||
static HANDLE NO_COPY console_handle = NULL;
|
static HANDLE NO_COPY console_handle = NULL;
|
||||||
void
|
void
|
||||||
console_printf (const char *fmt,...)
|
console_printf (const char *fmt, ...)
|
||||||
{
|
{
|
||||||
char buf[16384];
|
char buf[16384];
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
@ -21,8 +21,8 @@ details. */
|
|||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include <sys/cygwin.h>
|
#include <sys/cygwin.h>
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include "fhandler.h"
|
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
#include "sigproc.h"
|
#include "sigproc.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
|
@ -20,8 +20,8 @@ details. */
|
|||||||
#include "hires.h"
|
#include "hires.h"
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include "cygthread.h"
|
#include "cygthread.h"
|
||||||
#include "fhandler.h"
|
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
|
@ -49,8 +49,8 @@ details. */
|
|||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "perprocess.h"
|
#include "perprocess.h"
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include "fhandler.h"
|
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
#include "sigproc.h"
|
#include "sigproc.h"
|
||||||
#include "pinfo.h"
|
#include "pinfo.h"
|
||||||
@ -73,6 +73,12 @@ details. */
|
|||||||
|
|
||||||
SYSTEM_INFO system_info;
|
SYSTEM_INFO system_info;
|
||||||
|
|
||||||
|
static int __stdcall mknod_worker (const char *, mode_t, mode_t, _major_t,
|
||||||
|
_minor_t);
|
||||||
|
|
||||||
|
static int __stdcall stat_worker (const char *name, struct __stat64 *buf,
|
||||||
|
int nofollow) __attribute__ ((regparm (3)));
|
||||||
|
|
||||||
/* Close all files and process any queued deletions.
|
/* Close all files and process any queued deletions.
|
||||||
Lots of unix style applications will open a tmp file, unlink it,
|
Lots of unix style applications will open a tmp file, unlink it,
|
||||||
but never call close. This function is called by _exit to
|
but never call close. This function is called by _exit to
|
||||||
@ -486,7 +492,7 @@ writev (const int fd, const struct iovec *const iov, const int iovcnt)
|
|||||||
|
|
||||||
res = cfd->bg_check (SIGTTOU);
|
res = cfd->bg_check (SIGTTOU);
|
||||||
|
|
||||||
if (res > bg_eof)
|
if (res > (int) bg_eof)
|
||||||
{
|
{
|
||||||
myself->process_state |= PID_TTYOU;
|
myself->process_state |= PID_TTYOU;
|
||||||
res = cfd->writev (iov, iovcnt, tot);
|
res = cfd->writev (iov, iovcnt, tot);
|
||||||
@ -530,17 +536,24 @@ open (const char *unix_path, int flags, ...)
|
|||||||
|
|
||||||
if (fd >= 0)
|
if (fd >= 0)
|
||||||
{
|
{
|
||||||
path_conv pc;
|
if (!(fh = build_fh_name (unix_path, NULL, PC_SYM_FOLLOW)))
|
||||||
if (!(fh = cygheap->fdtab.build_fhandler_from_name (fd, unix_path,
|
|
||||||
NULL, pc)))
|
|
||||||
res = -1; // errno already set
|
res = -1; // errno already set
|
||||||
else if (!fh->open (&pc, flags, (mode & 07777) & ~cygheap->umask))
|
else if (fh->is_fs_special () && fh->device_access_denied (flags))
|
||||||
{
|
{
|
||||||
fd.release ();
|
delete fh;
|
||||||
res = -1;
|
res = -1;
|
||||||
}
|
}
|
||||||
else if ((res = fd) <= 2)
|
else if (!fh->open (flags, (mode & 07777) & ~cygheap->umask))
|
||||||
set_std_handle (res);
|
{
|
||||||
|
delete fh;
|
||||||
|
res = -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cygheap->fdtab[fd] = fh;
|
||||||
|
if ((res = fd) <= 2)
|
||||||
|
set_std_handle (res);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -817,7 +830,7 @@ chown_worker (const char *name, unsigned fmode, __uid32_t uid, __gid32_t gid)
|
|||||||
|
|
||||||
/* FIXME: This makes chown on a device succeed always. Someday we'll want
|
/* FIXME: This makes chown on a device succeed always. Someday we'll want
|
||||||
to actually allow chown to work properly on devices. */
|
to actually allow chown to work properly on devices. */
|
||||||
if (win32_path.is_device () && !win32_path.issocket ())
|
if (win32_path.is_auto_device () && !win32_path.issocket ())
|
||||||
{
|
{
|
||||||
res = 0;
|
res = 0;
|
||||||
goto done;
|
goto done;
|
||||||
@ -918,6 +931,12 @@ umask (mode_t mask)
|
|||||||
return oldmask;
|
return oldmask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
chmod_device (path_conv& pc, mode_t mode)
|
||||||
|
{
|
||||||
|
return mknod_worker (pc, pc.dev.mode & S_IFMT, mode, pc.dev.major, pc.dev.minor);
|
||||||
|
}
|
||||||
|
|
||||||
/* chmod: POSIX 5.6.4.1 */
|
/* chmod: POSIX 5.6.4.1 */
|
||||||
extern "C" int
|
extern "C" int
|
||||||
chmod (const char *path, mode_t mode)
|
chmod (const char *path, mode_t mode)
|
||||||
@ -935,11 +954,16 @@ chmod (const char *path, mode_t mode)
|
|||||||
|
|
||||||
/* FIXME: This makes chmod on a device succeed always. Someday we'll want
|
/* FIXME: This makes chmod on a device succeed always. Someday we'll want
|
||||||
to actually allow chmod to work properly on devices. */
|
to actually allow chmod to work properly on devices. */
|
||||||
if (win32_path.is_device () && !win32_path.issocket ())
|
if (win32_path.is_auto_device ())
|
||||||
{
|
{
|
||||||
res = 0;
|
res = 0;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
if (win32_path.is_fs_special ())
|
||||||
|
{
|
||||||
|
res = chmod_device (win32_path, mode);
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
if (!win32_path.exists ())
|
if (!win32_path.exists ())
|
||||||
__seterrno ();
|
__seterrno ();
|
||||||
@ -1033,15 +1057,14 @@ fstat64 (int fd, struct __stat64 *buf)
|
|||||||
res = -1;
|
res = -1;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
path_conv pc (cfd->get_name (), PC_SYM_NOFOLLOW);
|
|
||||||
memset (buf, 0, sizeof (struct __stat64));
|
memset (buf, 0, sizeof (struct __stat64));
|
||||||
res = cfd->fstat (buf, &pc);
|
res = cfd->fstat (buf);
|
||||||
if (!res && cfd->get_device () != FH_SOCKET)
|
if (!res)
|
||||||
{
|
{
|
||||||
if (!buf->st_ino)
|
if (!buf->st_ino)
|
||||||
buf->st_ino = hash_path_name (0, cfd->get_win32_name ());
|
buf->st_ino = hash_path_name (0, cfd->get_win32_name ());
|
||||||
if (!buf->st_dev)
|
if (!buf->st_dev)
|
||||||
buf->st_dev = (cfd->get_device () << 16) | cfd->get_unit ();
|
buf->st_dev = cfd->get_device ();
|
||||||
if (!buf->st_rdev)
|
if (!buf->st_rdev)
|
||||||
buf->st_rdev = buf->st_dev;
|
buf->st_rdev = buf->st_dev;
|
||||||
}
|
}
|
||||||
@ -1118,42 +1141,35 @@ suffix_info stat_suffixes[] =
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* Cygwin internal */
|
/* Cygwin internal */
|
||||||
int __stdcall
|
static int __stdcall
|
||||||
stat_worker (const char *name, struct __stat64 *buf, int nofollow,
|
stat_worker (const char *name, struct __stat64 *buf, int nofollow)
|
||||||
path_conv *pc)
|
|
||||||
{
|
{
|
||||||
int res = -1;
|
int res = -1;
|
||||||
path_conv real_path;
|
|
||||||
fhandler_base *fh = NULL;
|
fhandler_base *fh = NULL;
|
||||||
|
|
||||||
if (check_null_invalid_struct_errno (buf))
|
if (check_null_invalid_struct_errno (buf))
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
if (!pc)
|
fh = build_fh_name (name, NULL, (nofollow ? PC_SYM_NOFOLLOW : PC_SYM_FOLLOW)
|
||||||
pc = &real_path;
|
| PC_FULL, stat_suffixes);
|
||||||
|
|
||||||
fh = cygheap->fdtab.build_fhandler_from_name (-1, name, NULL, *pc,
|
if (fh->error ())
|
||||||
(nofollow ? PC_SYM_NOFOLLOW
|
|
||||||
: PC_SYM_FOLLOW)
|
|
||||||
| PC_FULL, stat_suffixes);
|
|
||||||
|
|
||||||
if (pc->error)
|
|
||||||
{
|
{
|
||||||
debug_printf ("got %d error from build_fhandler_from_name", pc->error);
|
debug_printf ("got %d error from build_fh_name", fh->error ());
|
||||||
set_errno (pc->error);
|
set_errno (fh->error ());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
debug_printf ("(%s, %p, %d, %p), file_attributes %d", name, buf, nofollow,
|
debug_printf ("(%s, %p, %d, %p), file_attributes %d", name, buf, nofollow,
|
||||||
pc, (DWORD) real_path);
|
fh, (DWORD) *fh);
|
||||||
memset (buf, 0, sizeof (*buf));
|
memset (buf, 0, sizeof (*buf));
|
||||||
res = fh->fstat (buf, pc);
|
res = fh->fstat (buf);
|
||||||
if (!res && fh->get_device () != FH_SOCKET)
|
if (!res)
|
||||||
{
|
{
|
||||||
if (!buf->st_ino)
|
if (!buf->st_ino)
|
||||||
buf->st_ino = hash_path_name (0, fh->get_win32_name ());
|
buf->st_ino = hash_path_name (0, fh->get_win32_name ());
|
||||||
if (!buf->st_dev)
|
if (!buf->st_dev)
|
||||||
buf->st_dev = (fh->get_device () << 16) | fh->get_unit ();
|
buf->st_dev = fh->get_device ();
|
||||||
if (!buf->st_rdev)
|
if (!buf->st_rdev)
|
||||||
buf->st_rdev = buf->st_dev;
|
buf->st_rdev = buf->st_dev;
|
||||||
}
|
}
|
||||||
@ -1227,18 +1243,9 @@ lstat (const char *name, struct __stat32 *buf)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" int
|
int
|
||||||
access (const char *fn, int flags)
|
access_worker (path_conv& real_path, int flags)
|
||||||
{
|
{
|
||||||
sigframe thisframe (mainthread);
|
|
||||||
// flags were incorrectly specified
|
|
||||||
if (flags & ~(F_OK|R_OK|W_OK|X_OK))
|
|
||||||
{
|
|
||||||
set_errno (EINVAL);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
path_conv real_path (fn, PC_SYM_FOLLOW | PC_FULL, stat_suffixes);
|
|
||||||
if (real_path.error)
|
if (real_path.error)
|
||||||
{
|
{
|
||||||
set_errno (real_path.error);
|
set_errno (real_path.error);
|
||||||
@ -1254,17 +1261,18 @@ access (const char *fn, int flags)
|
|||||||
if (!(flags & (R_OK | W_OK | X_OK)))
|
if (!(flags & (R_OK | W_OK | X_OK)))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (real_path.has_attribute (FILE_ATTRIBUTE_READONLY) && (flags & W_OK))
|
if (real_path.is_fs_special ())
|
||||||
|
/* short circuit */;
|
||||||
|
else if (real_path.has_attribute (FILE_ATTRIBUTE_READONLY) && (flags & W_OK))
|
||||||
{
|
{
|
||||||
set_errno (EACCES);
|
set_errno (EACCES);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
else if (real_path.has_acls () && allow_ntsec)
|
||||||
if (real_path.has_acls () && allow_ntsec)
|
|
||||||
return check_file_access (real_path, flags);
|
return check_file_access (real_path, flags);
|
||||||
|
|
||||||
struct __stat64 st;
|
struct __stat64 st;
|
||||||
int r = stat_worker (fn, &st, 0);
|
int r = stat_worker (real_path, &st, 0);
|
||||||
if (r)
|
if (r)
|
||||||
return -1;
|
return -1;
|
||||||
r = -1;
|
r = -1;
|
||||||
@ -1320,6 +1328,21 @@ done:
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" int
|
||||||
|
access (const char *fn, int flags)
|
||||||
|
{
|
||||||
|
sigframe thisframe (mainthread);
|
||||||
|
// flags were incorrectly specified
|
||||||
|
if (flags & ~(F_OK|R_OK|W_OK|X_OK))
|
||||||
|
{
|
||||||
|
set_errno (EINVAL);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
path_conv pc (fn, PC_SYM_FOLLOW | PC_FULL, stat_suffixes);
|
||||||
|
return access_worker (pc, flags);
|
||||||
|
}
|
||||||
|
|
||||||
extern "C" int
|
extern "C" int
|
||||||
rename (const char *oldpath, const char *newpath)
|
rename (const char *oldpath, const char *newpath)
|
||||||
{
|
{
|
||||||
@ -1573,7 +1596,7 @@ fpathconf (int fd, int v)
|
|||||||
}
|
}
|
||||||
case _PC_POSIX_PERMISSIONS:
|
case _PC_POSIX_PERMISSIONS:
|
||||||
case _PC_POSIX_SECURITY:
|
case _PC_POSIX_SECURITY:
|
||||||
if (cfd->get_device () == FH_DISK)
|
if (cfd->get_device () == FH_FS)
|
||||||
return check_posix_perm (cfd->get_win32_name (), v);
|
return check_posix_perm (cfd->get_win32_name (), v);
|
||||||
set_errno (EINVAL);
|
set_errno (EINVAL);
|
||||||
return -1;
|
return -1;
|
||||||
@ -1615,7 +1638,7 @@ pathconf (const char *file, int v)
|
|||||||
set_errno (full_path.error);
|
set_errno (full_path.error);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (full_path.is_device ())
|
if (full_path.is_auto_device ())
|
||||||
{
|
{
|
||||||
set_errno (EINVAL);
|
set_errno (EINVAL);
|
||||||
return -1;
|
return -1;
|
||||||
@ -1633,9 +1656,7 @@ ttyname (int fd)
|
|||||||
{
|
{
|
||||||
cygheap_fdget cfd (fd);
|
cygheap_fdget cfd (fd);
|
||||||
if (cfd < 0 || !cfd->is_tty ())
|
if (cfd < 0 || !cfd->is_tty ())
|
||||||
{
|
return 0;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return (char *) (cfd->ttyname ());
|
return (char *) (cfd->ttyname ());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1670,7 +1691,7 @@ _cygwin_istext_for_stdio (int fd)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cfd->get_device () != FH_DISK)
|
if (cfd->get_device () != FH_FS)
|
||||||
{
|
{
|
||||||
syscall_printf (" _cifs: fd not disk file");
|
syscall_printf (" _cifs: fd not disk file");
|
||||||
return 0;
|
return 0;
|
||||||
@ -1860,8 +1881,7 @@ statfs (const char *fname, struct statfs *sfs)
|
|||||||
}
|
}
|
||||||
|
|
||||||
path_conv full_path (fname, PC_SYM_FOLLOW | PC_FULL);
|
path_conv full_path (fname, PC_SYM_FOLLOW | PC_FULL);
|
||||||
|
const char *root = full_path.root_dir ();
|
||||||
const char *root = full_path.root_dir();
|
|
||||||
|
|
||||||
syscall_printf ("statfs %s", root);
|
syscall_printf ("statfs %s", root);
|
||||||
|
|
||||||
@ -2006,17 +2026,62 @@ regfree ()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* mknod was the call to create directories before the introduction
|
static int __stdcall
|
||||||
of mkdir in 4.2BSD and SVR3. Use of mknod required superuser privs
|
mknod_worker (const char *path, mode_t type, mode_t mode, _major_t major,
|
||||||
so the mkdir command had to be setuid root.
|
_minor_t minor)
|
||||||
Although mknod hasn't been implemented yet, some GNU tools (e.g. the
|
|
||||||
fileutils) assume its existence so we must provide a stub that always
|
|
||||||
fails. */
|
|
||||||
extern "C" int
|
|
||||||
mknod32 (const char *_path, mode_t mode, __dev32_t dev)
|
|
||||||
{
|
{
|
||||||
set_errno (ENOSYS);
|
char buf[sizeof (":00000000:00000000:00000000") + MAX_PATH];
|
||||||
return -1;
|
sprintf (buf, ":%x:%x:%x", major, minor,
|
||||||
|
type | (mode & (S_IRWXU | S_IRWXG | S_IRWXO)));
|
||||||
|
return symlink_worker (buf, path, true, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" int
|
||||||
|
mknod32 (const char *path, mode_t mode, __dev32_t dev)
|
||||||
|
{
|
||||||
|
if (check_null_empty_str_errno (path))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (strlen (path) >= MAX_PATH)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
path_conv w32path (path, PC_SYM_NOFOLLOW | PC_FULL);
|
||||||
|
if (w32path.exists ())
|
||||||
|
{
|
||||||
|
set_errno (EEXIST);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
mode_t type = mode & S_IFMT;
|
||||||
|
_major_t major = _major (dev);
|
||||||
|
_minor_t minor = _minor (dev);
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case S_IFCHR:
|
||||||
|
case S_IFBLK:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case S_IFIFO:
|
||||||
|
major = _major (FH_FIFO);
|
||||||
|
minor = _minor (FH_FIFO);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0:
|
||||||
|
case S_IFREG:
|
||||||
|
{
|
||||||
|
int fd = open (path, O_CREAT, mode);
|
||||||
|
if (fd < 0)
|
||||||
|
return -1;
|
||||||
|
close (fd);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
set_errno (EINVAL);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return mknod_worker (w32path, type, mode, major, minor);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" int
|
extern "C" int
|
||||||
@ -2028,7 +2093,7 @@ mknod (const char *_path, mode_t mode, __dev16_t dev)
|
|||||||
extern "C" int
|
extern "C" int
|
||||||
mkfifo (const char *_path, mode_t mode)
|
mkfifo (const char *_path, mode_t mode)
|
||||||
{
|
{
|
||||||
set_errno (ENOSYS);
|
set_errno (ENOSYS); // FIXME
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2343,7 +2408,7 @@ chroot (const char *newroot)
|
|||||||
|
|
||||||
syscall_printf ("%d = chroot (%s)", ret ? get_errno () : 0,
|
syscall_printf ("%d = chroot (%s)", ret ? get_errno () : 0,
|
||||||
newroot ? newroot : "NULL");
|
newroot ? newroot : "NULL");
|
||||||
if (path.normalized_path)
|
if (!path.normalized_path_size && path.normalized_path)
|
||||||
cfree (path.normalized_path);
|
cfree (path.normalized_path);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,8 @@ details. */
|
|||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <ntdef.h>
|
#include <ntdef.h>
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include "fhandler.h"
|
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
|
@ -15,8 +15,8 @@ details. */
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include "fhandler.h"
|
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
|
@ -16,8 +16,8 @@ details. */
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include "fhandler.h"
|
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
#include "cygwin/version.h"
|
#include "cygwin/version.h"
|
||||||
|
@ -1792,12 +1792,11 @@ pthread::thread_init_wrapper (void *_arg)
|
|||||||
|
|
||||||
struct sigaction _sigs[NSIG];
|
struct sigaction _sigs[NSIG];
|
||||||
sigset_t _sig_mask; /* one set for everything to ignore. */
|
sigset_t _sig_mask; /* one set for everything to ignore. */
|
||||||
LONG _sigtodo[NSIG + __SIGOFFSET];
|
|
||||||
|
|
||||||
// setup signal structures
|
// setup signal structures
|
||||||
thread->sigs = _sigs;
|
thread->sigs = _sigs;
|
||||||
thread->sigmask = &_sig_mask;
|
thread->sigmask = &_sig_mask;
|
||||||
thread->sigtodo = _sigtodo;
|
thread->sigtodo = NULL;
|
||||||
|
|
||||||
memset (&local_winsup, 0, sizeof (struct _winsup_t));
|
memset (&local_winsup, 0, sizeof (struct _winsup_t));
|
||||||
|
|
||||||
@ -2790,8 +2789,10 @@ pthread_kill (pthread_t thread, int sig)
|
|||||||
if (!pthread::is_good_object (&thread))
|
if (!pthread::is_good_object (&thread))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
||||||
|
#if 0
|
||||||
if (thread->sigs)
|
if (thread->sigs)
|
||||||
myself->setthread2signal (thread);
|
myself->setthread2signal (thread);
|
||||||
|
#endif
|
||||||
|
|
||||||
int rval = raise (sig);
|
int rval = raise (sig);
|
||||||
|
|
||||||
@ -2802,6 +2803,7 @@ pthread_kill (pthread_t thread, int sig)
|
|||||||
extern "C" int
|
extern "C" int
|
||||||
pthread_sigmask (int operation, const sigset_t *set, sigset_t *old_set)
|
pthread_sigmask (int operation, const sigset_t *set, sigset_t *old_set)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
pthread *thread = pthread::self ();
|
pthread *thread = pthread::self ();
|
||||||
|
|
||||||
// lock this myself, for the use of thread2signal
|
// lock this myself, for the use of thread2signal
|
||||||
@ -2809,6 +2811,7 @@ pthread_sigmask (int operation, const sigset_t *set, sigset_t *old_set)
|
|||||||
|
|
||||||
if (thread->sigs)
|
if (thread->sigs)
|
||||||
myself->setthread2signal (thread);
|
myself->setthread2signal (thread);
|
||||||
|
#endif
|
||||||
|
|
||||||
int rval = sigprocmask (operation, set, old_set);
|
int rval = sigprocmask (operation, set, old_set);
|
||||||
|
|
||||||
|
@ -17,8 +17,8 @@ details. */
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include "fhandler.h"
|
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
#include "fhandler.h"
|
||||||
#include "pinfo.h"
|
#include "pinfo.h"
|
||||||
#include "hires.h"
|
#include "hires.h"
|
||||||
|
|
||||||
|
@ -16,8 +16,8 @@ details. */
|
|||||||
#include <sys/cygwin.h>
|
#include <sys/cygwin.h>
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include "fhandler.h"
|
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
#include "pinfo.h"
|
#include "pinfo.h"
|
||||||
@ -76,9 +76,10 @@ tty_init (void)
|
|||||||
void __stdcall
|
void __stdcall
|
||||||
create_tty_master (int ttynum)
|
create_tty_master (int ttynum)
|
||||||
{
|
{
|
||||||
tty_master = (fhandler_tty_master *)
|
device ttym = *ttym_dev;
|
||||||
cygheap->fdtab.build_fhandler (-1, FH_TTYM, "/dev/ttym", NULL, ttynum);
|
ttym.setunit (ttynum); /* CGF FIXME device */
|
||||||
if (tty_master->init (ttynum))
|
tty_master = (fhandler_tty_master *) build_fh_dev (ttym);
|
||||||
|
if (tty_master->init ())
|
||||||
api_fatal ("Can't create master tty");
|
api_fatal ("Can't create master tty");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -431,7 +432,7 @@ tty::common_init (fhandler_pty_master *ptym)
|
|||||||
|
|
||||||
/* Create synchronisation events */
|
/* Create synchronisation events */
|
||||||
|
|
||||||
if (ptym->get_device () != FH_TTYM)
|
if (ptym->get_major () != DEV_TTYM_MAJOR)
|
||||||
{
|
{
|
||||||
ptym->output_done_event = ptym->ioctl_done_event =
|
ptym->output_done_event = ptym->ioctl_done_event =
|
||||||
ptym->ioctl_request_event = NULL;
|
ptym->ioctl_request_event = NULL;
|
||||||
|
@ -20,8 +20,8 @@ details. */
|
|||||||
#include <sys/cygwin.h>
|
#include <sys/cygwin.h>
|
||||||
#include "pinfo.h"
|
#include "pinfo.h"
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include "fhandler.h"
|
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "cygheap.h"
|
#include "cygheap.h"
|
||||||
|
@ -270,9 +270,9 @@ extern "C" int __small_sprintf (char *dst, const char *fmt, ...) /*__attribute__
|
|||||||
extern "C" int __small_vsprintf (char *dst, const char *fmt, va_list ap) /*__attribute__ ((regparm (3)))*/;
|
extern "C" int __small_vsprintf (char *dst, const char *fmt, va_list ap) /*__attribute__ ((regparm (3)))*/;
|
||||||
extern void multiple_cygwin_problem (const char *, unsigned, unsigned);
|
extern void multiple_cygwin_problem (const char *, unsigned, unsigned);
|
||||||
|
|
||||||
class path_conv;
|
int symlink_worker (const char *, const char *, bool, bool)
|
||||||
int __stdcall stat_worker (const char *name, struct __stat64 *buf, int nofollow,
|
__attribute__ ((regparm (3)));
|
||||||
path_conv *pc = NULL) __attribute__ ((regparm (3)));
|
|
||||||
int __stdcall low_priority_sleep (DWORD) __attribute__ ((regparm (1)));
|
int __stdcall low_priority_sleep (DWORD) __attribute__ ((regparm (1)));
|
||||||
#define SLEEP_0_STAY_LOW INFINITE
|
#define SLEEP_0_STAY_LOW INFINITE
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user