2000-02-18 03:38:33 +08:00
|
|
|
/* path.h: path data structures
|
|
|
|
|
2013-01-21 12:34:52 +08:00
|
|
|
Copyright 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
|
2015-02-11 21:15:59 +08:00
|
|
|
2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Red Hat, Inc.
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
This file is part of Cygwin.
|
|
|
|
|
|
|
|
This software is a copyrighted work licensed under the terms of the
|
|
|
|
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
|
|
|
details. */
|
|
|
|
|
* devices.cc: New file.
* devices.gperf: New file.
* devices.shilka: New file.
* cygwin-gperf: New file.
* cygwin-shilka: New file.
* fhandler_fifo.cc: New file.
* fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes
fhandler.h throughout. Remove device argument and unit arguments from fhandler
constructors throughout. Remove pc arguments to fhandler functions and use
internal pc element instead, throughout. Use dev element in pc throughout.
Use major/minor elements rather than units and device numbers previously in
fhandler class. Use correct methods for fhandler file names rather than
directly accessing file name variables, throughout.
* Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o
* dcrt0.cc (dll_crt0_1): Call device::init.
* devices.h: Renumber devices based on more Linux-like major/minor numbers.
Add more devices. Declare standard device storage.
(device): Declare struct.
* dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type.
* dtable.cc (dtable::get_debugger_info): Ditto.
(cygwin_attach_handle_to_fd): Ditto.
(dtable::release): Remove special FH_SOCKET case in favor of generic
"need_fixup_before" test.
(dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name
to build standard fhandler.
(dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move
out of dtable class. Don't accept a path_conv argument. Just build it here
and pass it to:
(build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class.
Use intrinsic device type in path_conv to create new fhandler.
(build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class.
Simplify arguments to just take new 'device' type and a name. Just return
pointer to fhandler rather than trying to insert into dtable.
(dtable::dup_worker): Accommodate above build_fh name changes.
(dtable::find_fifo): New (currently broken) function.
(handle_to_fn): Use strechr for efficiency.
* dtable.h: Reflect above build_fh name changes and argument differences.
(fhandler_base *&operator []): Return self rather than copy of self.
* fhandler.cc (fhandler_base::operator =): Use pc element to set normalized
path.
(fhandler_base::set_name): Ditto.
(fhandler_base::raw_read): Use method to access name.
(fhandler_base::write): Correctly use get_output_handle rather than get_handle.
(handler_base::device_access_denied): New function.
(fhandler_base::open): Eliminate pc argument and use pc element of
fhandler_base throughout.
(fhandler_base::fstat): Detect if device is based in filesystem and use
fstat_fs to calculate stat, if so.
(fhandler_base::fhandler_base): Eliminate handling of file names and, instead,
just free appropriate component from pc.
(fhandler_base::opendir): Remove path_conv parameter.
* fhandler.h: Remove all device flags.
(fhandler_base::pc): New element.
(fhandler_base::set_name): Change argument to path_conv.
(fhandler_base::error): New function.
(fhandler_base::exists): New function.
(fhandler_base::pc_binmode): New function.
(fhandler_base::dev): New function.
(fhandler_base::open_fs): New function.
(fhandler_base::fstat_fs): New function.
(fhandler_base::fstat_by_name): New function.
(fhandler_base::fstat_by_handle): New function.
(fhandler_base::isfifo): New function.
(fhandler_base::is_slow): New function.
(fhandler_base::is_auto_device): New function.
(fhandler_base::is_fs_special): New function.
(fhandler_base::device_access_denied): New function.
(fhandler_base::operator DWORD&): New operator.
(fhandler_base::get_name): Return normalized path from pc.
(fhandler_base::get_win32_name): Return windows path from pc.
(fhandler_base::isdevice): Renamed from is_device.
(fhandler_base::get_native_name): Return device format.
(fhandler_fifo): New class.
(fhandler_nodevice): New class.
(select_stuff::device_specific): Remove array.
(select_stuff::device_specific_pipe): New class element.
(select_stuff::device_specific_socket): New class element.
(select_stuff::device_specific_serial): New class element.
(select_stuff::select_stuff): Initialize new elements.
* fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class
from fhandler_disk_file.
(fhandler_base::fstat_by_name): Ditto.
(fhandler_base::fstat_by_name): Ditto.
(fhandler_disk_file::open): Move most functionality into
fhandler_base::open_fs.
(fhandler_base::open_fs): New function.
(fhandler_disk_file::close): Move most functionality into
fhandler_base::close_fs.
(fhandler_base::close_fs): New function.
* fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging
output.
* fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard
urandom device into appropriate place.
(fhandler_socket::accept): Reflect change in fdsock return value.
* fhandler_tty.cc: See "throughouts" above.
* net.cc: Accommodate fdsock change throughout.
(fdsock): Return success or failure, accept fd argument and device argument.
* path.cc (symlink_info::major): New element.
(symlink_info::minor): New element.
(symlink_info::parse_device): Declare new function.
(fs_info::update): Accommodate changes in path_conv class.
(path_conv::fillin): Ditto.
(path_conv::return_and_clear_normalized_path): Eliminate.
(path_conv::set_normalized_path): New function.
(path_conv::path_conv): Set info in dev element. Use path_conv methods Check
for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff.
where appropriate rather than direct access. Use set_normalized_path to set
normalized path.
(windows_device_names): Eliminate.
(get_dev): Ditto.
(get_raw_device_number): Ditto.
(get_device_number): Ditto.
(win32_device_name): Call new device name parser to do most of the heavy
lifting.
(mount_info::conv_to_win32_path): Fill in dev field as appropriate.
(symlink_worker): Handle new device files.
(symlink_info::check): Ditto.
(symlink_info::parse_device): Define new function.
* path.h (executable_states): Move here from fhandler.h.
(fs_info): Rename variables to *_storage and create methods for accessing same.
(path_conv): Add dev element, remove devn and unit and adjust inline methods to
accommodate.
(set_normalized_path): Declare new function.
* pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos.
(_pinfo::commune_send): Ditto.
* pipe.cc (fhandler_pipe::close): check for existence of handle before closing
it.
(handler_pipe::create): Rename from make_pipe. Change arguments to accept
fhandler_pipe array. Accommodate fifos.
(pipe): Rework to deal with fhandler_pipe::create changes.
(_pipe): Ditto.
* select.cc: Use individual device_specific types throughout rather than
indexing with obsolete device number.
(set_bits): Use is_socket call rather than checking device number.
* shared_info.h (CURR_MOUNT_MAGIC): Update.
(conv_to_win32_path): Reflect addition of device argument.
* syscalls.cc (mknod_worker): New function.
(open): Use build_fh_name to build fhandler.
(chown_worker): Detect if this is an 'auto' device rather than an on-filesystem
device and handle appropriately.
(chmod_device): New function.
(chmod): Detect if this is an 'auto' device rather than an on-filesystem device
and handle appropriately. Use chmod_device to set mode of in-filesystem
devices.
(stat_worker): Eliminate path_conv argument. Call build_fh_name to construct
fhandler. Use fh->error() rather than pc->error to detect errors in fhandler
construction.
(access_worker): New function pulled from access. Accommodate in-filesystem
devices.
(access): Use access_worker.
(fpathconf): Detect if this is an 'auto' device rather than an on-filesystem
device and handle appropriately.
(mknod_worker): New function.
(mknod32): New function.
(chroot): Free normalized path -- assuming it was actually cmalloced.
* tty.cc (create_tty_master): Tweak for new device class.
(tty::common_init): Ditto.
* winsup.h (stat_worker): Remove.
(symlink_worker): Declare.
* exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't
worry about pending_signals since sig_dispatch_pending should always do the
right thing now.
(sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3.
* pinfo.h: Move __SIG enum to sigproc.h.
(PICOM_FIFO): New enum element.
(_pinfo): Remove 'thread2signal' stuff throughout class.
(_pinfo::commune_send): Make varargs.
(_pinfo::sigtodo): Eliminate.
(_pinfo::thread2signal): Ditto.
* signal.cc (kill_worker): Eliminate call to setthread2signal.
* sigproc.cc (local_sigtodo): Eliminate.
(getlocal_sigtodo): Ditto.
(sigelem): New class.
(pending_signals): New class.
(sigqueue): New variable, start of sigqueue linked list.
(sigcatch_nonmain): Eliminate.
(sigcatch_main): Eliminate.
(sigcatch_nosync): Eliminate.
(sigcomplete_nonmain): Eliminate.
(pending_signals): Eliminate.
(sig_clear): Call signal thread to clear pending signals, unless already in
signal thread.
(sigpending): Call signal thread to get pending signals.
(sig_dispatch_pending): Eliminate use of pending_signals and just check
sigqueue.
(sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close
signal pipe handle.
(sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send
signals.
(getevent): Eliminate.
(pending_signals::add): New function.
(pending_signals::del): New function.
(pending_signals::next): New function.
(wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to
communicate and maintain a linked list of signals.
* sigproc.h: Move __SIG defines here. Add __SIGPENDING.
(sig_dispatch_pending): Remove "C" specifier.
(sig_handle): Accept a mask argument.
* thread.cc: Remove signal handling considerations throughout.
2003-09-25 08:37:18 +08:00
|
|
|
#include "devices.h"
|
2008-12-25 23:55:31 +08:00
|
|
|
#include "mount.h"
|
2009-08-02 03:52:46 +08:00
|
|
|
#include "cygheap_malloc.h"
|
2010-09-30 21:52:34 +08:00
|
|
|
#include "nfs.h"
|
* devices.cc: New file.
* devices.gperf: New file.
* devices.shilka: New file.
* cygwin-gperf: New file.
* cygwin-shilka: New file.
* fhandler_fifo.cc: New file.
* fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes
fhandler.h throughout. Remove device argument and unit arguments from fhandler
constructors throughout. Remove pc arguments to fhandler functions and use
internal pc element instead, throughout. Use dev element in pc throughout.
Use major/minor elements rather than units and device numbers previously in
fhandler class. Use correct methods for fhandler file names rather than
directly accessing file name variables, throughout.
* Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o
* dcrt0.cc (dll_crt0_1): Call device::init.
* devices.h: Renumber devices based on more Linux-like major/minor numbers.
Add more devices. Declare standard device storage.
(device): Declare struct.
* dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type.
* dtable.cc (dtable::get_debugger_info): Ditto.
(cygwin_attach_handle_to_fd): Ditto.
(dtable::release): Remove special FH_SOCKET case in favor of generic
"need_fixup_before" test.
(dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name
to build standard fhandler.
(dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move
out of dtable class. Don't accept a path_conv argument. Just build it here
and pass it to:
(build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class.
Use intrinsic device type in path_conv to create new fhandler.
(build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class.
Simplify arguments to just take new 'device' type and a name. Just return
pointer to fhandler rather than trying to insert into dtable.
(dtable::dup_worker): Accommodate above build_fh name changes.
(dtable::find_fifo): New (currently broken) function.
(handle_to_fn): Use strechr for efficiency.
* dtable.h: Reflect above build_fh name changes and argument differences.
(fhandler_base *&operator []): Return self rather than copy of self.
* fhandler.cc (fhandler_base::operator =): Use pc element to set normalized
path.
(fhandler_base::set_name): Ditto.
(fhandler_base::raw_read): Use method to access name.
(fhandler_base::write): Correctly use get_output_handle rather than get_handle.
(handler_base::device_access_denied): New function.
(fhandler_base::open): Eliminate pc argument and use pc element of
fhandler_base throughout.
(fhandler_base::fstat): Detect if device is based in filesystem and use
fstat_fs to calculate stat, if so.
(fhandler_base::fhandler_base): Eliminate handling of file names and, instead,
just free appropriate component from pc.
(fhandler_base::opendir): Remove path_conv parameter.
* fhandler.h: Remove all device flags.
(fhandler_base::pc): New element.
(fhandler_base::set_name): Change argument to path_conv.
(fhandler_base::error): New function.
(fhandler_base::exists): New function.
(fhandler_base::pc_binmode): New function.
(fhandler_base::dev): New function.
(fhandler_base::open_fs): New function.
(fhandler_base::fstat_fs): New function.
(fhandler_base::fstat_by_name): New function.
(fhandler_base::fstat_by_handle): New function.
(fhandler_base::isfifo): New function.
(fhandler_base::is_slow): New function.
(fhandler_base::is_auto_device): New function.
(fhandler_base::is_fs_special): New function.
(fhandler_base::device_access_denied): New function.
(fhandler_base::operator DWORD&): New operator.
(fhandler_base::get_name): Return normalized path from pc.
(fhandler_base::get_win32_name): Return windows path from pc.
(fhandler_base::isdevice): Renamed from is_device.
(fhandler_base::get_native_name): Return device format.
(fhandler_fifo): New class.
(fhandler_nodevice): New class.
(select_stuff::device_specific): Remove array.
(select_stuff::device_specific_pipe): New class element.
(select_stuff::device_specific_socket): New class element.
(select_stuff::device_specific_serial): New class element.
(select_stuff::select_stuff): Initialize new elements.
* fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class
from fhandler_disk_file.
(fhandler_base::fstat_by_name): Ditto.
(fhandler_base::fstat_by_name): Ditto.
(fhandler_disk_file::open): Move most functionality into
fhandler_base::open_fs.
(fhandler_base::open_fs): New function.
(fhandler_disk_file::close): Move most functionality into
fhandler_base::close_fs.
(fhandler_base::close_fs): New function.
* fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging
output.
* fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard
urandom device into appropriate place.
(fhandler_socket::accept): Reflect change in fdsock return value.
* fhandler_tty.cc: See "throughouts" above.
* net.cc: Accommodate fdsock change throughout.
(fdsock): Return success or failure, accept fd argument and device argument.
* path.cc (symlink_info::major): New element.
(symlink_info::minor): New element.
(symlink_info::parse_device): Declare new function.
(fs_info::update): Accommodate changes in path_conv class.
(path_conv::fillin): Ditto.
(path_conv::return_and_clear_normalized_path): Eliminate.
(path_conv::set_normalized_path): New function.
(path_conv::path_conv): Set info in dev element. Use path_conv methods Check
for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff.
where appropriate rather than direct access. Use set_normalized_path to set
normalized path.
(windows_device_names): Eliminate.
(get_dev): Ditto.
(get_raw_device_number): Ditto.
(get_device_number): Ditto.
(win32_device_name): Call new device name parser to do most of the heavy
lifting.
(mount_info::conv_to_win32_path): Fill in dev field as appropriate.
(symlink_worker): Handle new device files.
(symlink_info::check): Ditto.
(symlink_info::parse_device): Define new function.
* path.h (executable_states): Move here from fhandler.h.
(fs_info): Rename variables to *_storage and create methods for accessing same.
(path_conv): Add dev element, remove devn and unit and adjust inline methods to
accommodate.
(set_normalized_path): Declare new function.
* pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos.
(_pinfo::commune_send): Ditto.
* pipe.cc (fhandler_pipe::close): check for existence of handle before closing
it.
(handler_pipe::create): Rename from make_pipe. Change arguments to accept
fhandler_pipe array. Accommodate fifos.
(pipe): Rework to deal with fhandler_pipe::create changes.
(_pipe): Ditto.
* select.cc: Use individual device_specific types throughout rather than
indexing with obsolete device number.
(set_bits): Use is_socket call rather than checking device number.
* shared_info.h (CURR_MOUNT_MAGIC): Update.
(conv_to_win32_path): Reflect addition of device argument.
* syscalls.cc (mknod_worker): New function.
(open): Use build_fh_name to build fhandler.
(chown_worker): Detect if this is an 'auto' device rather than an on-filesystem
device and handle appropriately.
(chmod_device): New function.
(chmod): Detect if this is an 'auto' device rather than an on-filesystem device
and handle appropriately. Use chmod_device to set mode of in-filesystem
devices.
(stat_worker): Eliminate path_conv argument. Call build_fh_name to construct
fhandler. Use fh->error() rather than pc->error to detect errors in fhandler
construction.
(access_worker): New function pulled from access. Accommodate in-filesystem
devices.
(access): Use access_worker.
(fpathconf): Detect if this is an 'auto' device rather than an on-filesystem
device and handle appropriately.
(mknod_worker): New function.
(mknod32): New function.
(chroot): Free normalized path -- assuming it was actually cmalloced.
* tty.cc (create_tty_master): Tweak for new device class.
(tty::common_init): Ditto.
* winsup.h (stat_worker): Remove.
(symlink_worker): Declare.
* exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't
worry about pending_signals since sig_dispatch_pending should always do the
right thing now.
(sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3.
* pinfo.h: Move __SIG enum to sigproc.h.
(PICOM_FIFO): New enum element.
(_pinfo): Remove 'thread2signal' stuff throughout class.
(_pinfo::commune_send): Make varargs.
(_pinfo::sigtodo): Eliminate.
(_pinfo::thread2signal): Ditto.
* signal.cc (kill_worker): Eliminate call to setthread2signal.
* sigproc.cc (local_sigtodo): Eliminate.
(getlocal_sigtodo): Ditto.
(sigelem): New class.
(pending_signals): New class.
(sigqueue): New variable, start of sigqueue linked list.
(sigcatch_nonmain): Eliminate.
(sigcatch_main): Eliminate.
(sigcatch_nosync): Eliminate.
(sigcomplete_nonmain): Eliminate.
(pending_signals): Eliminate.
(sig_clear): Call signal thread to clear pending signals, unless already in
signal thread.
(sigpending): Call signal thread to get pending signals.
(sig_dispatch_pending): Eliminate use of pending_signals and just check
sigqueue.
(sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close
signal pipe handle.
(sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send
signals.
(getevent): Eliminate.
(pending_signals::add): New function.
(pending_signals::del): New function.
(pending_signals::next): New function.
(wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to
communicate and maintain a linked list of signals.
* sigproc.h: Move __SIG defines here. Add __SIGPENDING.
(sig_dispatch_pending): Remove "C" specifier.
(sig_handle): Accept a mask argument.
* thread.cc: Remove signal handling considerations throughout.
2003-09-25 08:37:18 +08:00
|
|
|
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <fcntl.h>
|
2011-10-23 00:26:30 +08:00
|
|
|
#include <alloca.h>
|
* devices.cc: New file.
* devices.gperf: New file.
* devices.shilka: New file.
* cygwin-gperf: New file.
* cygwin-shilka: New file.
* fhandler_fifo.cc: New file.
* fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes
fhandler.h throughout. Remove device argument and unit arguments from fhandler
constructors throughout. Remove pc arguments to fhandler functions and use
internal pc element instead, throughout. Use dev element in pc throughout.
Use major/minor elements rather than units and device numbers previously in
fhandler class. Use correct methods for fhandler file names rather than
directly accessing file name variables, throughout.
* Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o
* dcrt0.cc (dll_crt0_1): Call device::init.
* devices.h: Renumber devices based on more Linux-like major/minor numbers.
Add more devices. Declare standard device storage.
(device): Declare struct.
* dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type.
* dtable.cc (dtable::get_debugger_info): Ditto.
(cygwin_attach_handle_to_fd): Ditto.
(dtable::release): Remove special FH_SOCKET case in favor of generic
"need_fixup_before" test.
(dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name
to build standard fhandler.
(dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move
out of dtable class. Don't accept a path_conv argument. Just build it here
and pass it to:
(build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class.
Use intrinsic device type in path_conv to create new fhandler.
(build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class.
Simplify arguments to just take new 'device' type and a name. Just return
pointer to fhandler rather than trying to insert into dtable.
(dtable::dup_worker): Accommodate above build_fh name changes.
(dtable::find_fifo): New (currently broken) function.
(handle_to_fn): Use strechr for efficiency.
* dtable.h: Reflect above build_fh name changes and argument differences.
(fhandler_base *&operator []): Return self rather than copy of self.
* fhandler.cc (fhandler_base::operator =): Use pc element to set normalized
path.
(fhandler_base::set_name): Ditto.
(fhandler_base::raw_read): Use method to access name.
(fhandler_base::write): Correctly use get_output_handle rather than get_handle.
(handler_base::device_access_denied): New function.
(fhandler_base::open): Eliminate pc argument and use pc element of
fhandler_base throughout.
(fhandler_base::fstat): Detect if device is based in filesystem and use
fstat_fs to calculate stat, if so.
(fhandler_base::fhandler_base): Eliminate handling of file names and, instead,
just free appropriate component from pc.
(fhandler_base::opendir): Remove path_conv parameter.
* fhandler.h: Remove all device flags.
(fhandler_base::pc): New element.
(fhandler_base::set_name): Change argument to path_conv.
(fhandler_base::error): New function.
(fhandler_base::exists): New function.
(fhandler_base::pc_binmode): New function.
(fhandler_base::dev): New function.
(fhandler_base::open_fs): New function.
(fhandler_base::fstat_fs): New function.
(fhandler_base::fstat_by_name): New function.
(fhandler_base::fstat_by_handle): New function.
(fhandler_base::isfifo): New function.
(fhandler_base::is_slow): New function.
(fhandler_base::is_auto_device): New function.
(fhandler_base::is_fs_special): New function.
(fhandler_base::device_access_denied): New function.
(fhandler_base::operator DWORD&): New operator.
(fhandler_base::get_name): Return normalized path from pc.
(fhandler_base::get_win32_name): Return windows path from pc.
(fhandler_base::isdevice): Renamed from is_device.
(fhandler_base::get_native_name): Return device format.
(fhandler_fifo): New class.
(fhandler_nodevice): New class.
(select_stuff::device_specific): Remove array.
(select_stuff::device_specific_pipe): New class element.
(select_stuff::device_specific_socket): New class element.
(select_stuff::device_specific_serial): New class element.
(select_stuff::select_stuff): Initialize new elements.
* fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class
from fhandler_disk_file.
(fhandler_base::fstat_by_name): Ditto.
(fhandler_base::fstat_by_name): Ditto.
(fhandler_disk_file::open): Move most functionality into
fhandler_base::open_fs.
(fhandler_base::open_fs): New function.
(fhandler_disk_file::close): Move most functionality into
fhandler_base::close_fs.
(fhandler_base::close_fs): New function.
* fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging
output.
* fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard
urandom device into appropriate place.
(fhandler_socket::accept): Reflect change in fdsock return value.
* fhandler_tty.cc: See "throughouts" above.
* net.cc: Accommodate fdsock change throughout.
(fdsock): Return success or failure, accept fd argument and device argument.
* path.cc (symlink_info::major): New element.
(symlink_info::minor): New element.
(symlink_info::parse_device): Declare new function.
(fs_info::update): Accommodate changes in path_conv class.
(path_conv::fillin): Ditto.
(path_conv::return_and_clear_normalized_path): Eliminate.
(path_conv::set_normalized_path): New function.
(path_conv::path_conv): Set info in dev element. Use path_conv methods Check
for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff.
where appropriate rather than direct access. Use set_normalized_path to set
normalized path.
(windows_device_names): Eliminate.
(get_dev): Ditto.
(get_raw_device_number): Ditto.
(get_device_number): Ditto.
(win32_device_name): Call new device name parser to do most of the heavy
lifting.
(mount_info::conv_to_win32_path): Fill in dev field as appropriate.
(symlink_worker): Handle new device files.
(symlink_info::check): Ditto.
(symlink_info::parse_device): Define new function.
* path.h (executable_states): Move here from fhandler.h.
(fs_info): Rename variables to *_storage and create methods for accessing same.
(path_conv): Add dev element, remove devn and unit and adjust inline methods to
accommodate.
(set_normalized_path): Declare new function.
* pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos.
(_pinfo::commune_send): Ditto.
* pipe.cc (fhandler_pipe::close): check for existence of handle before closing
it.
(handler_pipe::create): Rename from make_pipe. Change arguments to accept
fhandler_pipe array. Accommodate fifos.
(pipe): Rework to deal with fhandler_pipe::create changes.
(_pipe): Ditto.
* select.cc: Use individual device_specific types throughout rather than
indexing with obsolete device number.
(set_bits): Use is_socket call rather than checking device number.
* shared_info.h (CURR_MOUNT_MAGIC): Update.
(conv_to_win32_path): Reflect addition of device argument.
* syscalls.cc (mknod_worker): New function.
(open): Use build_fh_name to build fhandler.
(chown_worker): Detect if this is an 'auto' device rather than an on-filesystem
device and handle appropriately.
(chmod_device): New function.
(chmod): Detect if this is an 'auto' device rather than an on-filesystem device
and handle appropriately. Use chmod_device to set mode of in-filesystem
devices.
(stat_worker): Eliminate path_conv argument. Call build_fh_name to construct
fhandler. Use fh->error() rather than pc->error to detect errors in fhandler
construction.
(access_worker): New function pulled from access. Accommodate in-filesystem
devices.
(access): Use access_worker.
(fpathconf): Detect if this is an 'auto' device rather than an on-filesystem
device and handle appropriately.
(mknod_worker): New function.
(mknod32): New function.
(chroot): Free normalized path -- assuming it was actually cmalloced.
* tty.cc (create_tty_master): Tweak for new device class.
(tty::common_init): Ditto.
* winsup.h (stat_worker): Remove.
(symlink_worker): Declare.
* exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't
worry about pending_signals since sig_dispatch_pending should always do the
right thing now.
(sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3.
* pinfo.h: Move __SIG enum to sigproc.h.
(PICOM_FIFO): New enum element.
(_pinfo): Remove 'thread2signal' stuff throughout class.
(_pinfo::commune_send): Make varargs.
(_pinfo::sigtodo): Eliminate.
(_pinfo::thread2signal): Ditto.
* signal.cc (kill_worker): Eliminate call to setthread2signal.
* sigproc.cc (local_sigtodo): Eliminate.
(getlocal_sigtodo): Ditto.
(sigelem): New class.
(pending_signals): New class.
(sigqueue): New variable, start of sigqueue linked list.
(sigcatch_nonmain): Eliminate.
(sigcatch_main): Eliminate.
(sigcatch_nosync): Eliminate.
(sigcomplete_nonmain): Eliminate.
(pending_signals): Eliminate.
(sig_clear): Call signal thread to clear pending signals, unless already in
signal thread.
(sigpending): Call signal thread to get pending signals.
(sig_dispatch_pending): Eliminate use of pending_signals and just check
sigqueue.
(sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close
signal pipe handle.
(sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send
signals.
(getevent): Eliminate.
(pending_signals::add): New function.
(pending_signals::del): New function.
(pending_signals::next): New function.
(wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to
communicate and maintain a linked list of signals.
* sigproc.h: Move __SIG defines here. Add __SIGPENDING.
(sig_dispatch_pending): Remove "C" specifier.
(sig_handle): Accept a mask argument.
* thread.cc: Remove signal handling considerations throughout.
2003-09-25 08:37:18 +08:00
|
|
|
|
2012-12-22 05:30:56 +08:00
|
|
|
extern inline bool
|
2005-09-22 23:52:02 +08:00
|
|
|
has_attribute (DWORD attributes, DWORD attribs_to_test)
|
|
|
|
{
|
|
|
|
return attributes != INVALID_FILE_ATTRIBUTES
|
|
|
|
&& (attributes & attribs_to_test);
|
|
|
|
}
|
|
|
|
|
* devices.cc: New file.
* devices.gperf: New file.
* devices.shilka: New file.
* cygwin-gperf: New file.
* cygwin-shilka: New file.
* fhandler_fifo.cc: New file.
* fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes
fhandler.h throughout. Remove device argument and unit arguments from fhandler
constructors throughout. Remove pc arguments to fhandler functions and use
internal pc element instead, throughout. Use dev element in pc throughout.
Use major/minor elements rather than units and device numbers previously in
fhandler class. Use correct methods for fhandler file names rather than
directly accessing file name variables, throughout.
* Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o
* dcrt0.cc (dll_crt0_1): Call device::init.
* devices.h: Renumber devices based on more Linux-like major/minor numbers.
Add more devices. Declare standard device storage.
(device): Declare struct.
* dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type.
* dtable.cc (dtable::get_debugger_info): Ditto.
(cygwin_attach_handle_to_fd): Ditto.
(dtable::release): Remove special FH_SOCKET case in favor of generic
"need_fixup_before" test.
(dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name
to build standard fhandler.
(dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move
out of dtable class. Don't accept a path_conv argument. Just build it here
and pass it to:
(build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class.
Use intrinsic device type in path_conv to create new fhandler.
(build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class.
Simplify arguments to just take new 'device' type and a name. Just return
pointer to fhandler rather than trying to insert into dtable.
(dtable::dup_worker): Accommodate above build_fh name changes.
(dtable::find_fifo): New (currently broken) function.
(handle_to_fn): Use strechr for efficiency.
* dtable.h: Reflect above build_fh name changes and argument differences.
(fhandler_base *&operator []): Return self rather than copy of self.
* fhandler.cc (fhandler_base::operator =): Use pc element to set normalized
path.
(fhandler_base::set_name): Ditto.
(fhandler_base::raw_read): Use method to access name.
(fhandler_base::write): Correctly use get_output_handle rather than get_handle.
(handler_base::device_access_denied): New function.
(fhandler_base::open): Eliminate pc argument and use pc element of
fhandler_base throughout.
(fhandler_base::fstat): Detect if device is based in filesystem and use
fstat_fs to calculate stat, if so.
(fhandler_base::fhandler_base): Eliminate handling of file names and, instead,
just free appropriate component from pc.
(fhandler_base::opendir): Remove path_conv parameter.
* fhandler.h: Remove all device flags.
(fhandler_base::pc): New element.
(fhandler_base::set_name): Change argument to path_conv.
(fhandler_base::error): New function.
(fhandler_base::exists): New function.
(fhandler_base::pc_binmode): New function.
(fhandler_base::dev): New function.
(fhandler_base::open_fs): New function.
(fhandler_base::fstat_fs): New function.
(fhandler_base::fstat_by_name): New function.
(fhandler_base::fstat_by_handle): New function.
(fhandler_base::isfifo): New function.
(fhandler_base::is_slow): New function.
(fhandler_base::is_auto_device): New function.
(fhandler_base::is_fs_special): New function.
(fhandler_base::device_access_denied): New function.
(fhandler_base::operator DWORD&): New operator.
(fhandler_base::get_name): Return normalized path from pc.
(fhandler_base::get_win32_name): Return windows path from pc.
(fhandler_base::isdevice): Renamed from is_device.
(fhandler_base::get_native_name): Return device format.
(fhandler_fifo): New class.
(fhandler_nodevice): New class.
(select_stuff::device_specific): Remove array.
(select_stuff::device_specific_pipe): New class element.
(select_stuff::device_specific_socket): New class element.
(select_stuff::device_specific_serial): New class element.
(select_stuff::select_stuff): Initialize new elements.
* fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class
from fhandler_disk_file.
(fhandler_base::fstat_by_name): Ditto.
(fhandler_base::fstat_by_name): Ditto.
(fhandler_disk_file::open): Move most functionality into
fhandler_base::open_fs.
(fhandler_base::open_fs): New function.
(fhandler_disk_file::close): Move most functionality into
fhandler_base::close_fs.
(fhandler_base::close_fs): New function.
* fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging
output.
* fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard
urandom device into appropriate place.
(fhandler_socket::accept): Reflect change in fdsock return value.
* fhandler_tty.cc: See "throughouts" above.
* net.cc: Accommodate fdsock change throughout.
(fdsock): Return success or failure, accept fd argument and device argument.
* path.cc (symlink_info::major): New element.
(symlink_info::minor): New element.
(symlink_info::parse_device): Declare new function.
(fs_info::update): Accommodate changes in path_conv class.
(path_conv::fillin): Ditto.
(path_conv::return_and_clear_normalized_path): Eliminate.
(path_conv::set_normalized_path): New function.
(path_conv::path_conv): Set info in dev element. Use path_conv methods Check
for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff.
where appropriate rather than direct access. Use set_normalized_path to set
normalized path.
(windows_device_names): Eliminate.
(get_dev): Ditto.
(get_raw_device_number): Ditto.
(get_device_number): Ditto.
(win32_device_name): Call new device name parser to do most of the heavy
lifting.
(mount_info::conv_to_win32_path): Fill in dev field as appropriate.
(symlink_worker): Handle new device files.
(symlink_info::check): Ditto.
(symlink_info::parse_device): Define new function.
* path.h (executable_states): Move here from fhandler.h.
(fs_info): Rename variables to *_storage and create methods for accessing same.
(path_conv): Add dev element, remove devn and unit and adjust inline methods to
accommodate.
(set_normalized_path): Declare new function.
* pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos.
(_pinfo::commune_send): Ditto.
* pipe.cc (fhandler_pipe::close): check for existence of handle before closing
it.
(handler_pipe::create): Rename from make_pipe. Change arguments to accept
fhandler_pipe array. Accommodate fifos.
(pipe): Rework to deal with fhandler_pipe::create changes.
(_pipe): Ditto.
* select.cc: Use individual device_specific types throughout rather than
indexing with obsolete device number.
(set_bits): Use is_socket call rather than checking device number.
* shared_info.h (CURR_MOUNT_MAGIC): Update.
(conv_to_win32_path): Reflect addition of device argument.
* syscalls.cc (mknod_worker): New function.
(open): Use build_fh_name to build fhandler.
(chown_worker): Detect if this is an 'auto' device rather than an on-filesystem
device and handle appropriately.
(chmod_device): New function.
(chmod): Detect if this is an 'auto' device rather than an on-filesystem device
and handle appropriately. Use chmod_device to set mode of in-filesystem
devices.
(stat_worker): Eliminate path_conv argument. Call build_fh_name to construct
fhandler. Use fh->error() rather than pc->error to detect errors in fhandler
construction.
(access_worker): New function pulled from access. Accommodate in-filesystem
devices.
(access): Use access_worker.
(fpathconf): Detect if this is an 'auto' device rather than an on-filesystem
device and handle appropriately.
(mknod_worker): New function.
(mknod32): New function.
(chroot): Free normalized path -- assuming it was actually cmalloced.
* tty.cc (create_tty_master): Tweak for new device class.
(tty::common_init): Ditto.
* winsup.h (stat_worker): Remove.
(symlink_worker): Declare.
* exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't
worry about pending_signals since sig_dispatch_pending should always do the
right thing now.
(sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3.
* pinfo.h: Move __SIG enum to sigproc.h.
(PICOM_FIFO): New enum element.
(_pinfo): Remove 'thread2signal' stuff throughout class.
(_pinfo::commune_send): Make varargs.
(_pinfo::sigtodo): Eliminate.
(_pinfo::thread2signal): Ditto.
* signal.cc (kill_worker): Eliminate call to setthread2signal.
* sigproc.cc (local_sigtodo): Eliminate.
(getlocal_sigtodo): Ditto.
(sigelem): New class.
(pending_signals): New class.
(sigqueue): New variable, start of sigqueue linked list.
(sigcatch_nonmain): Eliminate.
(sigcatch_main): Eliminate.
(sigcatch_nosync): Eliminate.
(sigcomplete_nonmain): Eliminate.
(pending_signals): Eliminate.
(sig_clear): Call signal thread to clear pending signals, unless already in
signal thread.
(sigpending): Call signal thread to get pending signals.
(sig_dispatch_pending): Eliminate use of pending_signals and just check
sigqueue.
(sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close
signal pipe handle.
(sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send
signals.
(getevent): Eliminate.
(pending_signals::add): New function.
(pending_signals::del): New function.
(pending_signals::next): New function.
(wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to
communicate and maintain a linked list of signals.
* sigproc.h: Move __SIG defines here. Add __SIGPENDING.
(sig_dispatch_pending): Remove "C" specifier.
(sig_handle): Accept a mask argument.
* thread.cc: Remove signal handling considerations throughout.
2003-09-25 08:37:18 +08:00
|
|
|
enum executable_states
|
|
|
|
{
|
|
|
|
is_executable,
|
|
|
|
dont_care_if_executable,
|
|
|
|
not_executable = dont_care_if_executable,
|
|
|
|
dont_know_if_executable
|
|
|
|
};
|
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
struct suffix_info
|
|
|
|
{
|
|
|
|
const char *name;
|
|
|
|
int addon;
|
2000-10-15 09:37:07 +08:00
|
|
|
suffix_info (const char *s, int addit = 0): name (s), addon (addit) {}
|
2000-02-18 03:38:33 +08:00
|
|
|
};
|
|
|
|
|
2007-08-14 22:48:52 +08:00
|
|
|
extern suffix_info stat_suffixes[];
|
|
|
|
|
2000-07-18 03:18:21 +08:00
|
|
|
enum pathconv_arg
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2000-07-18 03:18:21 +08:00
|
|
|
PC_SYM_FOLLOW = 0x0001,
|
|
|
|
PC_SYM_NOFOLLOW = 0x0002,
|
2011-01-17 22:19:39 +08:00
|
|
|
PC_SYM_NOFOLLOW_REP = 0x0004,
|
2000-07-18 03:18:21 +08:00
|
|
|
PC_SYM_CONTENTS = 0x0008,
|
2005-05-13 23:46:07 +08:00
|
|
|
PC_NOFULL = 0x0010,
|
2001-06-05 18:45:52 +08:00
|
|
|
PC_NULLEMPTY = 0x0020,
|
2005-03-12 10:33:00 +08:00
|
|
|
PC_POSIX = 0x0080,
|
2006-08-02 02:00:44 +08:00
|
|
|
PC_NOWARN = 0x0100,
|
2011-10-16 06:37:30 +08:00
|
|
|
PC_OPEN = 0x0200, /* use open semantics */
|
|
|
|
PC_CTTY = 0x0400, /* could later be used as ctty */
|
2010-06-15 20:05:15 +08:00
|
|
|
PC_KEEP_HANDLE = 0x00400000,
|
2005-10-13 04:38:38 +08:00
|
|
|
PC_NO_ACCESS_CHECK = 0x00800000
|
2000-02-18 03:38:33 +08:00
|
|
|
};
|
|
|
|
|
2000-07-18 03:18:21 +08:00
|
|
|
#define PC_NONULLEMPTY -1
|
|
|
|
|
2005-05-13 11:21:39 +08:00
|
|
|
#include "sys/mount.h"
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2000-07-18 03:18:21 +08:00
|
|
|
enum path_types
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2005-03-12 10:33:00 +08:00
|
|
|
PATH_NOTHING = 0,
|
|
|
|
PATH_SYMLINK = MOUNT_SYMLINK,
|
|
|
|
PATH_BINARY = MOUNT_BINARY,
|
|
|
|
PATH_EXEC = MOUNT_EXEC,
|
|
|
|
PATH_NOTEXEC = MOUNT_NOTEXEC,
|
|
|
|
PATH_CYGWIN_EXEC = MOUNT_CYGWIN_EXEC,
|
2012-12-14 18:45:29 +08:00
|
|
|
PATH_SPARSE = MOUNT_SPARSE,
|
2005-05-13 11:21:39 +08:00
|
|
|
PATH_RO = MOUNT_RO,
|
2008-07-15 04:22:03 +08:00
|
|
|
PATH_NOACL = MOUNT_NOACL,
|
2008-07-17 04:20:45 +08:00
|
|
|
PATH_NOPOSIX = MOUNT_NOPOSIX,
|
2010-04-29 18:38:05 +08:00
|
|
|
PATH_DOS = MOUNT_DOS,
|
|
|
|
PATH_IHASH = MOUNT_IHASH,
|
2005-03-12 10:33:00 +08:00
|
|
|
PATH_ALL_EXEC = (PATH_CYGWIN_EXEC | PATH_EXEC),
|
|
|
|
PATH_NO_ACCESS_CHECK = PC_NO_ACCESS_CHECK,
|
2011-10-16 06:37:30 +08:00
|
|
|
PATH_CTTY = 0x00400000, /* could later be used as ctty */
|
|
|
|
PATH_OPEN = 0x00800000, /* use open semantics */
|
2013-04-23 17:44:36 +08:00
|
|
|
/* FIXME? PATH_OPEN collides with
|
|
|
|
PATH_NO_ACCESS_CHECK, but it looks
|
|
|
|
like they are never used together. */
|
2005-03-12 10:33:00 +08:00
|
|
|
PATH_LNK = 0x01000000,
|
|
|
|
PATH_TEXT = 0x02000000,
|
2006-10-31 19:40:47 +08:00
|
|
|
PATH_REP = 0x04000000,
|
2005-03-12 10:33:00 +08:00
|
|
|
PATH_HAS_SYMLINKS = 0x10000000,
|
2013-08-23 17:29:25 +08:00
|
|
|
PATH_SOCKET = 0x40000000
|
2000-02-18 03:38:33 +08:00
|
|
|
};
|
|
|
|
|
2010-09-13 19:17:36 +08:00
|
|
|
class symlink_info;
|
|
|
|
struct _FILE_NETWORK_OPEN_INFORMATION;
|
|
|
|
|
2010-06-15 20:05:15 +08:00
|
|
|
class path_conv_handle
|
|
|
|
{
|
|
|
|
HANDLE hdl;
|
2010-09-30 21:52:34 +08:00
|
|
|
union {
|
|
|
|
/* Identical to FILE_NETWORK_OPEN_INFORMATION. We don't want to pull in
|
|
|
|
ntdll.h here, though. */
|
|
|
|
struct {
|
|
|
|
LARGE_INTEGER CreationTime;
|
|
|
|
LARGE_INTEGER LastAccessTime;
|
|
|
|
LARGE_INTEGER LastWriteTime;
|
|
|
|
LARGE_INTEGER ChangeTime;
|
|
|
|
LARGE_INTEGER AllocationSize;
|
|
|
|
LARGE_INTEGER EndOfFile;
|
|
|
|
ULONG FileAttributes;
|
|
|
|
} _fnoi;
|
|
|
|
/* For NFS. */
|
|
|
|
fattr3 _fattr3;
|
|
|
|
} attribs;
|
2010-06-15 20:05:15 +08:00
|
|
|
public:
|
2010-10-07 22:03:26 +08:00
|
|
|
path_conv_handle () : hdl (NULL) {}
|
|
|
|
inline void set (HANDLE h) { hdl = h; }
|
2010-06-15 20:05:15 +08:00
|
|
|
inline void close ()
|
|
|
|
{
|
|
|
|
if (hdl)
|
|
|
|
CloseHandle (hdl);
|
2010-10-07 22:03:26 +08:00
|
|
|
set (NULL);
|
2010-06-15 20:05:15 +08:00
|
|
|
}
|
2011-10-16 06:37:30 +08:00
|
|
|
inline void dup (const path_conv_handle &pch)
|
2010-06-15 20:05:15 +08:00
|
|
|
{
|
|
|
|
if (!DuplicateHandle (GetCurrentProcess (), pch.handle (),
|
|
|
|
GetCurrentProcess (), &hdl,
|
|
|
|
0, TRUE, DUPLICATE_SAME_ACCESS))
|
2010-10-07 22:03:26 +08:00
|
|
|
hdl = NULL;
|
2010-06-15 20:05:15 +08:00
|
|
|
}
|
|
|
|
inline HANDLE handle () const { return hdl; }
|
2010-09-13 19:17:36 +08:00
|
|
|
inline struct _FILE_NETWORK_OPEN_INFORMATION *fnoi ()
|
2010-09-30 21:52:34 +08:00
|
|
|
{ return (struct _FILE_NETWORK_OPEN_INFORMATION *) &attribs._fnoi; }
|
|
|
|
inline struct fattr3 *nfsattr ()
|
|
|
|
{ return (struct fattr3 *) &attribs._fattr3; }
|
2010-06-15 20:05:15 +08:00
|
|
|
};
|
|
|
|
|
2002-05-12 11:08:59 +08:00
|
|
|
class path_conv
|
|
|
|
{
|
2002-07-24 13:37:47 +08:00
|
|
|
DWORD fileattr;
|
2008-07-17 04:20:45 +08:00
|
|
|
ULONG caseinsensitive;
|
2002-05-12 11:08:59 +08:00
|
|
|
fs_info fs;
|
2007-07-19 19:41:17 +08:00
|
|
|
PWCHAR wide_path;
|
|
|
|
UNICODE_STRING uni_path;
|
2002-05-12 11:08:59 +08:00
|
|
|
void add_ext_from_sym (symlink_info&);
|
2009-08-02 03:52:46 +08:00
|
|
|
DWORD symlink_length;
|
|
|
|
const char *path;
|
2015-02-15 16:59:55 +08:00
|
|
|
unsigned path_flags;
|
|
|
|
const char *suffix;
|
|
|
|
const char *posix_path;
|
2010-06-15 20:05:15 +08:00
|
|
|
path_conv_handle conv_handle;
|
2000-02-18 03:38:33 +08:00
|
|
|
public:
|
2001-10-01 12:10:07 +08:00
|
|
|
int error;
|
* devices.cc: New file.
* devices.gperf: New file.
* devices.shilka: New file.
* cygwin-gperf: New file.
* cygwin-shilka: New file.
* fhandler_fifo.cc: New file.
* fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes
fhandler.h throughout. Remove device argument and unit arguments from fhandler
constructors throughout. Remove pc arguments to fhandler functions and use
internal pc element instead, throughout. Use dev element in pc throughout.
Use major/minor elements rather than units and device numbers previously in
fhandler class. Use correct methods for fhandler file names rather than
directly accessing file name variables, throughout.
* Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o
* dcrt0.cc (dll_crt0_1): Call device::init.
* devices.h: Renumber devices based on more Linux-like major/minor numbers.
Add more devices. Declare standard device storage.
(device): Declare struct.
* dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type.
* dtable.cc (dtable::get_debugger_info): Ditto.
(cygwin_attach_handle_to_fd): Ditto.
(dtable::release): Remove special FH_SOCKET case in favor of generic
"need_fixup_before" test.
(dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name
to build standard fhandler.
(dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move
out of dtable class. Don't accept a path_conv argument. Just build it here
and pass it to:
(build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class.
Use intrinsic device type in path_conv to create new fhandler.
(build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class.
Simplify arguments to just take new 'device' type and a name. Just return
pointer to fhandler rather than trying to insert into dtable.
(dtable::dup_worker): Accommodate above build_fh name changes.
(dtable::find_fifo): New (currently broken) function.
(handle_to_fn): Use strechr for efficiency.
* dtable.h: Reflect above build_fh name changes and argument differences.
(fhandler_base *&operator []): Return self rather than copy of self.
* fhandler.cc (fhandler_base::operator =): Use pc element to set normalized
path.
(fhandler_base::set_name): Ditto.
(fhandler_base::raw_read): Use method to access name.
(fhandler_base::write): Correctly use get_output_handle rather than get_handle.
(handler_base::device_access_denied): New function.
(fhandler_base::open): Eliminate pc argument and use pc element of
fhandler_base throughout.
(fhandler_base::fstat): Detect if device is based in filesystem and use
fstat_fs to calculate stat, if so.
(fhandler_base::fhandler_base): Eliminate handling of file names and, instead,
just free appropriate component from pc.
(fhandler_base::opendir): Remove path_conv parameter.
* fhandler.h: Remove all device flags.
(fhandler_base::pc): New element.
(fhandler_base::set_name): Change argument to path_conv.
(fhandler_base::error): New function.
(fhandler_base::exists): New function.
(fhandler_base::pc_binmode): New function.
(fhandler_base::dev): New function.
(fhandler_base::open_fs): New function.
(fhandler_base::fstat_fs): New function.
(fhandler_base::fstat_by_name): New function.
(fhandler_base::fstat_by_handle): New function.
(fhandler_base::isfifo): New function.
(fhandler_base::is_slow): New function.
(fhandler_base::is_auto_device): New function.
(fhandler_base::is_fs_special): New function.
(fhandler_base::device_access_denied): New function.
(fhandler_base::operator DWORD&): New operator.
(fhandler_base::get_name): Return normalized path from pc.
(fhandler_base::get_win32_name): Return windows path from pc.
(fhandler_base::isdevice): Renamed from is_device.
(fhandler_base::get_native_name): Return device format.
(fhandler_fifo): New class.
(fhandler_nodevice): New class.
(select_stuff::device_specific): Remove array.
(select_stuff::device_specific_pipe): New class element.
(select_stuff::device_specific_socket): New class element.
(select_stuff::device_specific_serial): New class element.
(select_stuff::select_stuff): Initialize new elements.
* fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class
from fhandler_disk_file.
(fhandler_base::fstat_by_name): Ditto.
(fhandler_base::fstat_by_name): Ditto.
(fhandler_disk_file::open): Move most functionality into
fhandler_base::open_fs.
(fhandler_base::open_fs): New function.
(fhandler_disk_file::close): Move most functionality into
fhandler_base::close_fs.
(fhandler_base::close_fs): New function.
* fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging
output.
* fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard
urandom device into appropriate place.
(fhandler_socket::accept): Reflect change in fdsock return value.
* fhandler_tty.cc: See "throughouts" above.
* net.cc: Accommodate fdsock change throughout.
(fdsock): Return success or failure, accept fd argument and device argument.
* path.cc (symlink_info::major): New element.
(symlink_info::minor): New element.
(symlink_info::parse_device): Declare new function.
(fs_info::update): Accommodate changes in path_conv class.
(path_conv::fillin): Ditto.
(path_conv::return_and_clear_normalized_path): Eliminate.
(path_conv::set_normalized_path): New function.
(path_conv::path_conv): Set info in dev element. Use path_conv methods Check
for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff.
where appropriate rather than direct access. Use set_normalized_path to set
normalized path.
(windows_device_names): Eliminate.
(get_dev): Ditto.
(get_raw_device_number): Ditto.
(get_device_number): Ditto.
(win32_device_name): Call new device name parser to do most of the heavy
lifting.
(mount_info::conv_to_win32_path): Fill in dev field as appropriate.
(symlink_worker): Handle new device files.
(symlink_info::check): Ditto.
(symlink_info::parse_device): Define new function.
* path.h (executable_states): Move here from fhandler.h.
(fs_info): Rename variables to *_storage and create methods for accessing same.
(path_conv): Add dev element, remove devn and unit and adjust inline methods to
accommodate.
(set_normalized_path): Declare new function.
* pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos.
(_pinfo::commune_send): Ditto.
* pipe.cc (fhandler_pipe::close): check for existence of handle before closing
it.
(handler_pipe::create): Rename from make_pipe. Change arguments to accept
fhandler_pipe array. Accommodate fifos.
(pipe): Rework to deal with fhandler_pipe::create changes.
(_pipe): Ditto.
* select.cc: Use individual device_specific types throughout rather than
indexing with obsolete device number.
(set_bits): Use is_socket call rather than checking device number.
* shared_info.h (CURR_MOUNT_MAGIC): Update.
(conv_to_win32_path): Reflect addition of device argument.
* syscalls.cc (mknod_worker): New function.
(open): Use build_fh_name to build fhandler.
(chown_worker): Detect if this is an 'auto' device rather than an on-filesystem
device and handle appropriately.
(chmod_device): New function.
(chmod): Detect if this is an 'auto' device rather than an on-filesystem device
and handle appropriately. Use chmod_device to set mode of in-filesystem
devices.
(stat_worker): Eliminate path_conv argument. Call build_fh_name to construct
fhandler. Use fh->error() rather than pc->error to detect errors in fhandler
construction.
(access_worker): New function pulled from access. Accommodate in-filesystem
devices.
(access): Use access_worker.
(fpathconf): Detect if this is an 'auto' device rather than an on-filesystem
device and handle appropriately.
(mknod_worker): New function.
(mknod32): New function.
(chroot): Free normalized path -- assuming it was actually cmalloced.
* tty.cc (create_tty_master): Tweak for new device class.
(tty::common_init): Ditto.
* winsup.h (stat_worker): Remove.
(symlink_worker): Declare.
* exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't
worry about pending_signals since sig_dispatch_pending should always do the
right thing now.
(sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3.
* pinfo.h: Move __SIG enum to sigproc.h.
(PICOM_FIFO): New enum element.
(_pinfo): Remove 'thread2signal' stuff throughout class.
(_pinfo::commune_send): Make varargs.
(_pinfo::sigtodo): Eliminate.
(_pinfo::thread2signal): Ditto.
* signal.cc (kill_worker): Eliminate call to setthread2signal.
* sigproc.cc (local_sigtodo): Eliminate.
(getlocal_sigtodo): Ditto.
(sigelem): New class.
(pending_signals): New class.
(sigqueue): New variable, start of sigqueue linked list.
(sigcatch_nonmain): Eliminate.
(sigcatch_main): Eliminate.
(sigcatch_nosync): Eliminate.
(sigcomplete_nonmain): Eliminate.
(pending_signals): Eliminate.
(sig_clear): Call signal thread to clear pending signals, unless already in
signal thread.
(sigpending): Call signal thread to get pending signals.
(sig_dispatch_pending): Eliminate use of pending_signals and just check
sigqueue.
(sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close
signal pipe handle.
(sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send
signals.
(getevent): Eliminate.
(pending_signals::add): New function.
(pending_signals::del): New function.
(pending_signals::next): New function.
(wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to
communicate and maintain a linked list of signals.
* sigproc.h: Move __SIG defines here. Add __SIGPENDING.
(sig_dispatch_pending): Remove "C" specifier.
(sig_handle): Accept a mask argument.
* thread.cc: Remove signal handling considerations throughout.
2003-09-25 08:37:18 +08:00
|
|
|
device dev;
|
2001-05-31 13:25:46 +08:00
|
|
|
|
2015-02-15 16:59:55 +08:00
|
|
|
const char *known_suffix () { return suffix; }
|
2006-04-27 00:51:09 +08:00
|
|
|
bool isremote () const {return fs.is_remote_drive ();}
|
2008-07-17 04:20:45 +08:00
|
|
|
ULONG objcaseinsensitive () const {return caseinsensitive;}
|
2008-07-15 04:22:03 +08:00
|
|
|
bool has_acls () const {return !(path_flags & PATH_NOACL) && fs.has_acls (); }
|
2010-04-29 18:38:05 +08:00
|
|
|
bool hasgood_inode () const {return !(path_flags & PATH_IHASH); }
|
2013-04-23 17:44:36 +08:00
|
|
|
bool isgood_inode (ino_t ino) const;
|
2012-12-14 18:45:29 +08:00
|
|
|
bool support_sparse () const
|
|
|
|
{
|
|
|
|
return (path_flags & PATH_SPARSE)
|
|
|
|
&& (fs_flags () & FILE_SUPPORTS_SPARSE_FILES);
|
|
|
|
}
|
2001-05-31 13:25:46 +08:00
|
|
|
int has_symlinks () const {return path_flags & PATH_HAS_SYMLINKS;}
|
2010-04-29 18:38:05 +08:00
|
|
|
int has_dos_filenames_only () const {return path_flags & PATH_DOS;}
|
2004-04-10 21:45:10 +08:00
|
|
|
int has_buggy_open () const {return fs.has_buggy_open ();}
|
2010-09-22 00:32:22 +08:00
|
|
|
int has_buggy_reopen () const {return fs.has_buggy_reopen ();}
|
2008-07-30 22:41:59 +08:00
|
|
|
int has_buggy_fileid_dirinfo () const {return fs.has_buggy_fileid_dirinfo ();}
|
2010-01-12 22:47:46 +08:00
|
|
|
int has_buggy_basic_info () const {return fs.has_buggy_basic_info ();}
|
2015-11-02 19:08:25 +08:00
|
|
|
int has_broken_fnoi () const {return fs.has_broken_fnoi ();}
|
2002-06-05 09:42:28 +08:00
|
|
|
int binmode () const
|
|
|
|
{
|
|
|
|
if (path_flags & PATH_BINARY)
|
|
|
|
return O_BINARY;
|
|
|
|
if (path_flags & PATH_TEXT)
|
|
|
|
return O_TEXT;
|
|
|
|
return 0;
|
|
|
|
}
|
2001-05-31 13:25:46 +08:00
|
|
|
int issymlink () const {return path_flags & PATH_SYMLINK;}
|
2003-03-08 11:36:39 +08:00
|
|
|
int is_lnk_symlink () const {return path_flags & PATH_LNK;}
|
2006-10-31 19:40:47 +08:00
|
|
|
int is_rep_symlink () const {return path_flags & PATH_REP;}
|
2011-05-29 02:17:09 +08:00
|
|
|
int isdevice () const {return dev.not_device (FH_FS) && dev.not_device (FH_FIFO);}
|
|
|
|
int isfifo () const {return dev.is_device (FH_FIFO);}
|
|
|
|
int isspecial () const {return dev.not_device (FH_FS);}
|
|
|
|
int iscygdrive () const {return dev.is_device (FH_CYGDRIVE);}
|
2004-04-13 17:04:22 +08:00
|
|
|
int is_auto_device () const {return isdevice () && !is_fs_special ();}
|
2005-04-15 01:34:03 +08:00
|
|
|
int is_fs_device () const {return isdevice () && is_fs_special ();}
|
2005-12-02 01:33:59 +08:00
|
|
|
int is_fs_special () const {return dev.is_fs_special ();}
|
2005-04-15 01:34:03 +08:00
|
|
|
int is_lnk_special () const {return is_fs_device () || isfifo () || is_lnk_symlink ();}
|
2011-05-29 02:17:09 +08:00
|
|
|
int issocket () const {return dev.is_device (FH_UNIX);}
|
2001-05-31 13:25:46 +08:00
|
|
|
int iscygexec () const {return path_flags & PATH_CYGWIN_EXEC;}
|
2011-10-16 06:37:30 +08:00
|
|
|
int isopen () const {return path_flags & PATH_OPEN;}
|
|
|
|
int isctty_capable () const {return path_flags & PATH_CTTY;}
|
2005-09-08 08:57:12 +08:00
|
|
|
void set_cygexec (bool isset)
|
|
|
|
{
|
|
|
|
if (isset)
|
|
|
|
path_flags |= PATH_CYGWIN_EXEC;
|
|
|
|
else
|
|
|
|
path_flags &= ~PATH_CYGWIN_EXEC;
|
|
|
|
}
|
2013-04-23 17:44:36 +08:00
|
|
|
void set_cygexec (void *target)
|
|
|
|
{
|
|
|
|
if (target)
|
2013-08-23 17:29:25 +08:00
|
|
|
path_flags |= PATH_CYGWIN_EXEC;
|
2013-04-23 17:44:36 +08:00
|
|
|
else
|
|
|
|
path_flags &= ~PATH_CYGWIN_EXEC;
|
|
|
|
}
|
2005-05-13 11:21:39 +08:00
|
|
|
bool isro () const {return !!(path_flags & PATH_RO);}
|
2002-01-15 04:39:59 +08:00
|
|
|
bool exists () const {return fileattr != INVALID_FILE_ATTRIBUTES;}
|
2001-10-01 12:10:07 +08:00
|
|
|
bool has_attribute (DWORD x) const {return exists () && (fileattr & x);}
|
|
|
|
int isdir () const {return has_attribute (FILE_ATTRIBUTE_DIRECTORY);}
|
2001-03-05 14:28:25 +08:00
|
|
|
executable_states exec_state ()
|
|
|
|
{
|
|
|
|
extern int _check_for_executable;
|
|
|
|
if (path_flags & PATH_ALL_EXEC)
|
|
|
|
return is_executable;
|
|
|
|
if (path_flags & PATH_NOTEXEC)
|
|
|
|
return not_executable;
|
|
|
|
if (!_check_for_executable)
|
|
|
|
return dont_care_if_executable;
|
|
|
|
return dont_know_if_executable;
|
|
|
|
}
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2004-04-14 11:08:00 +08:00
|
|
|
void set_symlink (DWORD n) {path_flags |= PATH_SYMLINK; symlink_length = n;}
|
2001-01-23 04:29:24 +08:00
|
|
|
void set_has_symlinks () {path_flags |= PATH_HAS_SYMLINKS;}
|
2001-03-05 14:28:25 +08:00
|
|
|
void set_exec (int x = 1) {path_flags |= x ? PATH_EXEC : PATH_NOTEXEC;}
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2013-01-21 12:34:52 +08:00
|
|
|
void __reg3 check (const UNICODE_STRING *upath, unsigned opt = PC_SYM_FOLLOW,
|
|
|
|
const suffix_info *suffixes = NULL);
|
|
|
|
void __reg3 check (const char *src, unsigned opt = PC_SYM_FOLLOW,
|
|
|
|
const suffix_info *suffixes = NULL);
|
2000-07-18 03:18:21 +08:00
|
|
|
|
2008-05-20 18:18:12 +08:00
|
|
|
path_conv (const device& in_dev)
|
2009-08-05 11:18:48 +08:00
|
|
|
: fileattr (INVALID_FILE_ATTRIBUTES), wide_path (NULL), path (NULL),
|
2015-02-15 16:59:55 +08:00
|
|
|
path_flags (0), suffix (NULL), posix_path (NULL), error (0),
|
2009-08-05 11:18:48 +08:00
|
|
|
dev (in_dev)
|
2008-05-20 18:18:12 +08:00
|
|
|
{
|
2009-08-05 06:35:35 +08:00
|
|
|
set_path (in_dev.native);
|
2008-05-20 18:18:12 +08:00
|
|
|
}
|
* devices.cc: New file.
* devices.gperf: New file.
* devices.shilka: New file.
* cygwin-gperf: New file.
* cygwin-shilka: New file.
* fhandler_fifo.cc: New file.
* fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes
fhandler.h throughout. Remove device argument and unit arguments from fhandler
constructors throughout. Remove pc arguments to fhandler functions and use
internal pc element instead, throughout. Use dev element in pc throughout.
Use major/minor elements rather than units and device numbers previously in
fhandler class. Use correct methods for fhandler file names rather than
directly accessing file name variables, throughout.
* Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o
* dcrt0.cc (dll_crt0_1): Call device::init.
* devices.h: Renumber devices based on more Linux-like major/minor numbers.
Add more devices. Declare standard device storage.
(device): Declare struct.
* dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type.
* dtable.cc (dtable::get_debugger_info): Ditto.
(cygwin_attach_handle_to_fd): Ditto.
(dtable::release): Remove special FH_SOCKET case in favor of generic
"need_fixup_before" test.
(dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name
to build standard fhandler.
(dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move
out of dtable class. Don't accept a path_conv argument. Just build it here
and pass it to:
(build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class.
Use intrinsic device type in path_conv to create new fhandler.
(build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class.
Simplify arguments to just take new 'device' type and a name. Just return
pointer to fhandler rather than trying to insert into dtable.
(dtable::dup_worker): Accommodate above build_fh name changes.
(dtable::find_fifo): New (currently broken) function.
(handle_to_fn): Use strechr for efficiency.
* dtable.h: Reflect above build_fh name changes and argument differences.
(fhandler_base *&operator []): Return self rather than copy of self.
* fhandler.cc (fhandler_base::operator =): Use pc element to set normalized
path.
(fhandler_base::set_name): Ditto.
(fhandler_base::raw_read): Use method to access name.
(fhandler_base::write): Correctly use get_output_handle rather than get_handle.
(handler_base::device_access_denied): New function.
(fhandler_base::open): Eliminate pc argument and use pc element of
fhandler_base throughout.
(fhandler_base::fstat): Detect if device is based in filesystem and use
fstat_fs to calculate stat, if so.
(fhandler_base::fhandler_base): Eliminate handling of file names and, instead,
just free appropriate component from pc.
(fhandler_base::opendir): Remove path_conv parameter.
* fhandler.h: Remove all device flags.
(fhandler_base::pc): New element.
(fhandler_base::set_name): Change argument to path_conv.
(fhandler_base::error): New function.
(fhandler_base::exists): New function.
(fhandler_base::pc_binmode): New function.
(fhandler_base::dev): New function.
(fhandler_base::open_fs): New function.
(fhandler_base::fstat_fs): New function.
(fhandler_base::fstat_by_name): New function.
(fhandler_base::fstat_by_handle): New function.
(fhandler_base::isfifo): New function.
(fhandler_base::is_slow): New function.
(fhandler_base::is_auto_device): New function.
(fhandler_base::is_fs_special): New function.
(fhandler_base::device_access_denied): New function.
(fhandler_base::operator DWORD&): New operator.
(fhandler_base::get_name): Return normalized path from pc.
(fhandler_base::get_win32_name): Return windows path from pc.
(fhandler_base::isdevice): Renamed from is_device.
(fhandler_base::get_native_name): Return device format.
(fhandler_fifo): New class.
(fhandler_nodevice): New class.
(select_stuff::device_specific): Remove array.
(select_stuff::device_specific_pipe): New class element.
(select_stuff::device_specific_socket): New class element.
(select_stuff::device_specific_serial): New class element.
(select_stuff::select_stuff): Initialize new elements.
* fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class
from fhandler_disk_file.
(fhandler_base::fstat_by_name): Ditto.
(fhandler_base::fstat_by_name): Ditto.
(fhandler_disk_file::open): Move most functionality into
fhandler_base::open_fs.
(fhandler_base::open_fs): New function.
(fhandler_disk_file::close): Move most functionality into
fhandler_base::close_fs.
(fhandler_base::close_fs): New function.
* fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging
output.
* fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard
urandom device into appropriate place.
(fhandler_socket::accept): Reflect change in fdsock return value.
* fhandler_tty.cc: See "throughouts" above.
* net.cc: Accommodate fdsock change throughout.
(fdsock): Return success or failure, accept fd argument and device argument.
* path.cc (symlink_info::major): New element.
(symlink_info::minor): New element.
(symlink_info::parse_device): Declare new function.
(fs_info::update): Accommodate changes in path_conv class.
(path_conv::fillin): Ditto.
(path_conv::return_and_clear_normalized_path): Eliminate.
(path_conv::set_normalized_path): New function.
(path_conv::path_conv): Set info in dev element. Use path_conv methods Check
for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff.
where appropriate rather than direct access. Use set_normalized_path to set
normalized path.
(windows_device_names): Eliminate.
(get_dev): Ditto.
(get_raw_device_number): Ditto.
(get_device_number): Ditto.
(win32_device_name): Call new device name parser to do most of the heavy
lifting.
(mount_info::conv_to_win32_path): Fill in dev field as appropriate.
(symlink_worker): Handle new device files.
(symlink_info::check): Ditto.
(symlink_info::parse_device): Define new function.
* path.h (executable_states): Move here from fhandler.h.
(fs_info): Rename variables to *_storage and create methods for accessing same.
(path_conv): Add dev element, remove devn and unit and adjust inline methods to
accommodate.
(set_normalized_path): Declare new function.
* pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos.
(_pinfo::commune_send): Ditto.
* pipe.cc (fhandler_pipe::close): check for existence of handle before closing
it.
(handler_pipe::create): Rename from make_pipe. Change arguments to accept
fhandler_pipe array. Accommodate fifos.
(pipe): Rework to deal with fhandler_pipe::create changes.
(_pipe): Ditto.
* select.cc: Use individual device_specific types throughout rather than
indexing with obsolete device number.
(set_bits): Use is_socket call rather than checking device number.
* shared_info.h (CURR_MOUNT_MAGIC): Update.
(conv_to_win32_path): Reflect addition of device argument.
* syscalls.cc (mknod_worker): New function.
(open): Use build_fh_name to build fhandler.
(chown_worker): Detect if this is an 'auto' device rather than an on-filesystem
device and handle appropriately.
(chmod_device): New function.
(chmod): Detect if this is an 'auto' device rather than an on-filesystem device
and handle appropriately. Use chmod_device to set mode of in-filesystem
devices.
(stat_worker): Eliminate path_conv argument. Call build_fh_name to construct
fhandler. Use fh->error() rather than pc->error to detect errors in fhandler
construction.
(access_worker): New function pulled from access. Accommodate in-filesystem
devices.
(access): Use access_worker.
(fpathconf): Detect if this is an 'auto' device rather than an on-filesystem
device and handle appropriately.
(mknod_worker): New function.
(mknod32): New function.
(chroot): Free normalized path -- assuming it was actually cmalloced.
* tty.cc (create_tty_master): Tweak for new device class.
(tty::common_init): Ditto.
* winsup.h (stat_worker): Remove.
(symlink_worker): Declare.
* exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't
worry about pending_signals since sig_dispatch_pending should always do the
right thing now.
(sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3.
* pinfo.h: Move __SIG enum to sigproc.h.
(PICOM_FIFO): New enum element.
(_pinfo): Remove 'thread2signal' stuff throughout class.
(_pinfo::commune_send): Make varargs.
(_pinfo::sigtodo): Eliminate.
(_pinfo::thread2signal): Ditto.
* signal.cc (kill_worker): Eliminate call to setthread2signal.
* sigproc.cc (local_sigtodo): Eliminate.
(getlocal_sigtodo): Ditto.
(sigelem): New class.
(pending_signals): New class.
(sigqueue): New variable, start of sigqueue linked list.
(sigcatch_nonmain): Eliminate.
(sigcatch_main): Eliminate.
(sigcatch_nosync): Eliminate.
(sigcomplete_nonmain): Eliminate.
(pending_signals): Eliminate.
(sig_clear): Call signal thread to clear pending signals, unless already in
signal thread.
(sigpending): Call signal thread to get pending signals.
(sig_dispatch_pending): Eliminate use of pending_signals and just check
sigqueue.
(sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close
signal pipe handle.
(sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send
signals.
(getevent): Eliminate.
(pending_signals::add): New function.
(pending_signals::del): New function.
(pending_signals::next): New function.
(wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to
communicate and maintain a linked list of signals.
* sigproc.h: Move __SIG defines here. Add __SIGPENDING.
(sig_dispatch_pending): Remove "C" specifier.
(sig_handle): Accept a mask argument.
* thread.cc: Remove signal handling considerations throughout.
2003-09-25 08:37:18 +08:00
|
|
|
|
2000-07-18 03:18:21 +08:00
|
|
|
path_conv (int, const char *src, unsigned opt = PC_SYM_FOLLOW,
|
|
|
|
const suffix_info *suffixes = NULL)
|
2010-07-05 01:12:27 +08:00
|
|
|
: fileattr (INVALID_FILE_ATTRIBUTES), wide_path (NULL), path (NULL),
|
2015-02-15 16:59:55 +08:00
|
|
|
path_flags (0), suffix (NULL), posix_path (NULL), error (0)
|
2000-07-18 03:18:21 +08:00
|
|
|
{
|
|
|
|
check (src, opt, suffixes);
|
|
|
|
}
|
|
|
|
|
2008-03-23 05:04:16 +08:00
|
|
|
path_conv (const UNICODE_STRING *src, unsigned opt = PC_SYM_FOLLOW,
|
2007-07-27 01:30:54 +08:00
|
|
|
const suffix_info *suffixes = NULL)
|
2010-07-05 01:12:27 +08:00
|
|
|
: fileattr (INVALID_FILE_ATTRIBUTES), wide_path (NULL), path (NULL),
|
2015-02-15 16:59:55 +08:00
|
|
|
path_flags (0), suffix (NULL), posix_path (NULL), error (0)
|
2007-07-27 01:30:54 +08:00
|
|
|
{
|
|
|
|
check (src, opt | PC_NULLEMPTY, suffixes);
|
|
|
|
}
|
|
|
|
|
2000-07-18 03:18:21 +08:00
|
|
|
path_conv (const char *src, unsigned opt = PC_SYM_FOLLOW,
|
|
|
|
const suffix_info *suffixes = NULL)
|
2010-07-05 01:12:27 +08:00
|
|
|
: fileattr (INVALID_FILE_ATTRIBUTES), wide_path (NULL), path (NULL),
|
2015-02-15 16:59:55 +08:00
|
|
|
path_flags (0), suffix (NULL), posix_path (NULL), error (0)
|
2000-04-26 13:13:32 +08:00
|
|
|
{
|
2000-07-18 03:18:21 +08:00
|
|
|
check (src, opt | PC_NULLEMPTY, suffixes);
|
2000-04-26 13:13:32 +08:00
|
|
|
}
|
|
|
|
|
2008-05-20 18:18:12 +08:00
|
|
|
path_conv ()
|
2009-08-02 03:52:46 +08:00
|
|
|
: fileattr (INVALID_FILE_ATTRIBUTES), wide_path (NULL), path (NULL),
|
2015-02-15 16:59:55 +08:00
|
|
|
path_flags (0), suffix (NULL), posix_path (NULL), error (0)
|
2009-07-30 16:56:57 +08:00
|
|
|
{}
|
2000-04-26 13:13:32 +08:00
|
|
|
|
2004-02-18 04:03:01 +08:00
|
|
|
~path_conv ();
|
2015-02-15 16:59:55 +08:00
|
|
|
inline const char *get_win32 () const { return path; }
|
2015-04-23 21:02:32 +08:00
|
|
|
void set_nt_native_path (PUNICODE_STRING);
|
2007-07-19 19:41:17 +08:00
|
|
|
PUNICODE_STRING get_nt_native_path ();
|
2010-09-22 00:32:22 +08:00
|
|
|
inline POBJECT_ATTRIBUTES get_object_attr (OBJECT_ATTRIBUTES &attr,
|
|
|
|
SECURITY_ATTRIBUTES &sa)
|
|
|
|
{
|
|
|
|
if (!get_nt_native_path ())
|
|
|
|
return NULL;
|
|
|
|
InitializeObjectAttributes (&attr, &uni_path,
|
|
|
|
objcaseinsensitive ()
|
|
|
|
| (sa.bInheritHandle ? OBJ_INHERIT : 0),
|
|
|
|
NULL, sa.lpSecurityDescriptor);
|
|
|
|
return &attr;
|
|
|
|
}
|
2014-08-27 04:47:46 +08:00
|
|
|
inline POBJECT_ATTRIBUTES init_reopen_attr (OBJECT_ATTRIBUTES &attr, HANDLE h)
|
2010-09-22 00:32:22 +08:00
|
|
|
{
|
|
|
|
if (has_buggy_reopen ())
|
2014-08-27 04:47:46 +08:00
|
|
|
InitializeObjectAttributes (&attr, get_nt_native_path (),
|
2010-09-22 00:32:22 +08:00
|
|
|
objcaseinsensitive (), NULL, NULL)
|
|
|
|
else
|
2014-08-27 04:47:46 +08:00
|
|
|
InitializeObjectAttributes (&attr, &ro_u_empty, objcaseinsensitive (),
|
2010-09-22 00:32:22 +08:00
|
|
|
h, NULL);
|
2014-08-27 04:47:46 +08:00
|
|
|
return &attr;
|
2010-09-22 00:32:22 +08:00
|
|
|
}
|
2007-08-20 23:41:08 +08:00
|
|
|
inline size_t get_wide_win32_path_len ()
|
|
|
|
{
|
|
|
|
get_nt_native_path ();
|
|
|
|
return uni_path.Length / sizeof (WCHAR);
|
|
|
|
}
|
|
|
|
|
2007-07-19 19:41:17 +08:00
|
|
|
PWCHAR get_wide_win32_path (PWCHAR wc);
|
2002-05-02 12:13:48 +08:00
|
|
|
operator DWORD &() {return fileattr;}
|
2002-09-30 10:51:22 +08:00
|
|
|
operator int () {return fileattr; }
|
2011-10-21 05:35:59 +08:00
|
|
|
# define cfree_and_null(x) \
|
|
|
|
if (x) \
|
|
|
|
{ \
|
|
|
|
cfree ((void *) (x)); \
|
|
|
|
(x) = NULL; \
|
|
|
|
}
|
|
|
|
void free_strings ()
|
|
|
|
{
|
|
|
|
cfree_and_null (path);
|
2015-02-15 16:59:55 +08:00
|
|
|
cfree_and_null (posix_path);
|
2011-10-21 05:35:59 +08:00
|
|
|
cfree_and_null (wide_path);
|
|
|
|
}
|
2011-10-23 00:26:30 +08:00
|
|
|
path_conv& eq_worker (const path_conv& pc, const char *in_path,
|
2015-02-15 16:59:55 +08:00
|
|
|
const char *in_posix_path)
|
2007-08-13 23:08:25 +08:00
|
|
|
{
|
2011-10-21 05:35:59 +08:00
|
|
|
free_strings ();
|
2009-07-30 16:56:57 +08:00
|
|
|
memcpy (this, &pc, sizeof pc);
|
2011-10-23 00:26:30 +08:00
|
|
|
path = cstrdup (in_path);
|
2010-06-15 20:05:15 +08:00
|
|
|
conv_handle.dup (pc.conv_handle);
|
2015-02-15 16:59:55 +08:00
|
|
|
posix_path = cstrdup(pc.posix_path);
|
2011-07-26 21:30:41 +08:00
|
|
|
if (pc.wide_path)
|
|
|
|
{
|
|
|
|
wide_path = cwcsdup (uni_path.Buffer);
|
|
|
|
if (!wide_path)
|
|
|
|
api_fatal ("cwcsdup would have returned NULL");
|
|
|
|
uni_path.Buffer = wide_path;
|
|
|
|
}
|
2007-08-13 23:08:25 +08:00
|
|
|
return *this;
|
|
|
|
}
|
2011-10-23 00:26:30 +08:00
|
|
|
|
|
|
|
path_conv &operator << (const path_conv& pc)
|
|
|
|
{
|
|
|
|
const char *save_path;
|
2015-02-15 16:59:55 +08:00
|
|
|
const char *save_posix_path;
|
2011-10-23 00:26:30 +08:00
|
|
|
if (!path)
|
|
|
|
save_path = pc.path;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
save_path = (char *) alloca (strlen (path) + 1);
|
|
|
|
strcpy ((char *) save_path, path);
|
|
|
|
}
|
2015-02-15 16:59:55 +08:00
|
|
|
if (!posix_path)
|
|
|
|
save_posix_path = pc.posix_path;
|
2011-10-23 00:26:30 +08:00
|
|
|
else
|
|
|
|
{
|
2015-02-15 16:59:55 +08:00
|
|
|
save_posix_path = (char *) alloca (strlen (posix_path) + 1);
|
|
|
|
strcpy ((char *) save_posix_path, path);
|
2011-10-23 00:26:30 +08:00
|
|
|
}
|
2015-02-15 16:59:55 +08:00
|
|
|
return eq_worker (pc, save_path, save_posix_path);
|
2011-10-23 00:26:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
path_conv &operator =(const path_conv& pc)
|
|
|
|
{
|
2015-02-15 16:59:55 +08:00
|
|
|
return eq_worker (pc, pc.path, pc.posix_path);
|
2011-10-23 00:26:30 +08:00
|
|
|
}
|
2013-04-23 17:44:36 +08:00
|
|
|
dev_t get_device () {return dev.get_device ();}
|
2006-04-27 00:51:09 +08:00
|
|
|
DWORD file_attributes () const {return fileattr;}
|
2004-05-11 23:39:50 +08:00
|
|
|
void file_attributes (DWORD new_attr) {fileattr = new_attr;}
|
2012-12-14 18:45:29 +08:00
|
|
|
DWORD fs_flags () const {return fs.flags ();}
|
|
|
|
DWORD fs_name_len () const {return fs.name_len ();}
|
2012-04-02 19:08:07 +08:00
|
|
|
bool fs_got_fs () const { return fs.got_fs (); }
|
2006-04-27 00:51:09 +08:00
|
|
|
bool fs_is_fat () const {return fs.is_fat ();}
|
|
|
|
bool fs_is_ntfs () const {return fs.is_ntfs ();}
|
2012-06-04 00:46:53 +08:00
|
|
|
bool fs_is_refs () const {return fs.is_refs ();}
|
2006-04-27 00:51:09 +08:00
|
|
|
bool fs_is_samba () const {return fs.is_samba ();}
|
|
|
|
bool fs_is_nfs () const {return fs.is_nfs ();}
|
2007-05-15 09:27:30 +08:00
|
|
|
bool fs_is_netapp () const {return fs.is_netapp ();}
|
|
|
|
bool fs_is_cdrom () const {return fs.is_cdrom ();}
|
2009-07-17 17:00:19 +08:00
|
|
|
bool fs_is_mvfs () const {return fs.is_mvfs ();}
|
2010-02-04 00:05:33 +08:00
|
|
|
bool fs_is_cifs () const {return fs.is_cifs ();}
|
|
|
|
bool fs_is_nwfs () const {return fs.is_nwfs ();}
|
2011-10-21 16:29:19 +08:00
|
|
|
bool fs_is_ncfsd () const {return fs.is_ncfsd ();}
|
2013-04-24 18:16:13 +08:00
|
|
|
bool fs_is_afs () const {return fs.is_afs ();}
|
2015-11-04 21:47:25 +08:00
|
|
|
bool fs_is_prlfs () const {return fs.is_prlfs ();}
|
2013-01-10 23:08:22 +08:00
|
|
|
fs_info_type fs_type () const {return fs.what_fs ();}
|
2008-04-01 02:03:25 +08:00
|
|
|
ULONG fs_serial_number () const {return fs.serial_number ();}
|
2009-08-02 03:52:46 +08:00
|
|
|
inline const char *set_path (const char *p)
|
|
|
|
{
|
|
|
|
if (path)
|
|
|
|
cfree (modifiable_path ());
|
|
|
|
char *new_path = (char *) cmalloc_abort (HEAP_STR, strlen (p) + 7);
|
|
|
|
strcpy (new_path, p);
|
|
|
|
return path = new_path;
|
|
|
|
}
|
2007-07-31 23:20:00 +08:00
|
|
|
bool is_binary ();
|
* devices.cc: New file.
* devices.gperf: New file.
* devices.shilka: New file.
* cygwin-gperf: New file.
* cygwin-shilka: New file.
* fhandler_fifo.cc: New file.
* fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes
fhandler.h throughout. Remove device argument and unit arguments from fhandler
constructors throughout. Remove pc arguments to fhandler functions and use
internal pc element instead, throughout. Use dev element in pc throughout.
Use major/minor elements rather than units and device numbers previously in
fhandler class. Use correct methods for fhandler file names rather than
directly accessing file name variables, throughout.
* Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o
* dcrt0.cc (dll_crt0_1): Call device::init.
* devices.h: Renumber devices based on more Linux-like major/minor numbers.
Add more devices. Declare standard device storage.
(device): Declare struct.
* dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type.
* dtable.cc (dtable::get_debugger_info): Ditto.
(cygwin_attach_handle_to_fd): Ditto.
(dtable::release): Remove special FH_SOCKET case in favor of generic
"need_fixup_before" test.
(dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name
to build standard fhandler.
(dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move
out of dtable class. Don't accept a path_conv argument. Just build it here
and pass it to:
(build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class.
Use intrinsic device type in path_conv to create new fhandler.
(build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class.
Simplify arguments to just take new 'device' type and a name. Just return
pointer to fhandler rather than trying to insert into dtable.
(dtable::dup_worker): Accommodate above build_fh name changes.
(dtable::find_fifo): New (currently broken) function.
(handle_to_fn): Use strechr for efficiency.
* dtable.h: Reflect above build_fh name changes and argument differences.
(fhandler_base *&operator []): Return self rather than copy of self.
* fhandler.cc (fhandler_base::operator =): Use pc element to set normalized
path.
(fhandler_base::set_name): Ditto.
(fhandler_base::raw_read): Use method to access name.
(fhandler_base::write): Correctly use get_output_handle rather than get_handle.
(handler_base::device_access_denied): New function.
(fhandler_base::open): Eliminate pc argument and use pc element of
fhandler_base throughout.
(fhandler_base::fstat): Detect if device is based in filesystem and use
fstat_fs to calculate stat, if so.
(fhandler_base::fhandler_base): Eliminate handling of file names and, instead,
just free appropriate component from pc.
(fhandler_base::opendir): Remove path_conv parameter.
* fhandler.h: Remove all device flags.
(fhandler_base::pc): New element.
(fhandler_base::set_name): Change argument to path_conv.
(fhandler_base::error): New function.
(fhandler_base::exists): New function.
(fhandler_base::pc_binmode): New function.
(fhandler_base::dev): New function.
(fhandler_base::open_fs): New function.
(fhandler_base::fstat_fs): New function.
(fhandler_base::fstat_by_name): New function.
(fhandler_base::fstat_by_handle): New function.
(fhandler_base::isfifo): New function.
(fhandler_base::is_slow): New function.
(fhandler_base::is_auto_device): New function.
(fhandler_base::is_fs_special): New function.
(fhandler_base::device_access_denied): New function.
(fhandler_base::operator DWORD&): New operator.
(fhandler_base::get_name): Return normalized path from pc.
(fhandler_base::get_win32_name): Return windows path from pc.
(fhandler_base::isdevice): Renamed from is_device.
(fhandler_base::get_native_name): Return device format.
(fhandler_fifo): New class.
(fhandler_nodevice): New class.
(select_stuff::device_specific): Remove array.
(select_stuff::device_specific_pipe): New class element.
(select_stuff::device_specific_socket): New class element.
(select_stuff::device_specific_serial): New class element.
(select_stuff::select_stuff): Initialize new elements.
* fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class
from fhandler_disk_file.
(fhandler_base::fstat_by_name): Ditto.
(fhandler_base::fstat_by_name): Ditto.
(fhandler_disk_file::open): Move most functionality into
fhandler_base::open_fs.
(fhandler_base::open_fs): New function.
(fhandler_disk_file::close): Move most functionality into
fhandler_base::close_fs.
(fhandler_base::close_fs): New function.
* fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging
output.
* fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard
urandom device into appropriate place.
(fhandler_socket::accept): Reflect change in fdsock return value.
* fhandler_tty.cc: See "throughouts" above.
* net.cc: Accommodate fdsock change throughout.
(fdsock): Return success or failure, accept fd argument and device argument.
* path.cc (symlink_info::major): New element.
(symlink_info::minor): New element.
(symlink_info::parse_device): Declare new function.
(fs_info::update): Accommodate changes in path_conv class.
(path_conv::fillin): Ditto.
(path_conv::return_and_clear_normalized_path): Eliminate.
(path_conv::set_normalized_path): New function.
(path_conv::path_conv): Set info in dev element. Use path_conv methods Check
for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff.
where appropriate rather than direct access. Use set_normalized_path to set
normalized path.
(windows_device_names): Eliminate.
(get_dev): Ditto.
(get_raw_device_number): Ditto.
(get_device_number): Ditto.
(win32_device_name): Call new device name parser to do most of the heavy
lifting.
(mount_info::conv_to_win32_path): Fill in dev field as appropriate.
(symlink_worker): Handle new device files.
(symlink_info::check): Ditto.
(symlink_info::parse_device): Define new function.
* path.h (executable_states): Move here from fhandler.h.
(fs_info): Rename variables to *_storage and create methods for accessing same.
(path_conv): Add dev element, remove devn and unit and adjust inline methods to
accommodate.
(set_normalized_path): Declare new function.
* pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos.
(_pinfo::commune_send): Ditto.
* pipe.cc (fhandler_pipe::close): check for existence of handle before closing
it.
(handler_pipe::create): Rename from make_pipe. Change arguments to accept
fhandler_pipe array. Accommodate fifos.
(pipe): Rework to deal with fhandler_pipe::create changes.
(_pipe): Ditto.
* select.cc: Use individual device_specific types throughout rather than
indexing with obsolete device number.
(set_bits): Use is_socket call rather than checking device number.
* shared_info.h (CURR_MOUNT_MAGIC): Update.
(conv_to_win32_path): Reflect addition of device argument.
* syscalls.cc (mknod_worker): New function.
(open): Use build_fh_name to build fhandler.
(chown_worker): Detect if this is an 'auto' device rather than an on-filesystem
device and handle appropriately.
(chmod_device): New function.
(chmod): Detect if this is an 'auto' device rather than an on-filesystem device
and handle appropriately. Use chmod_device to set mode of in-filesystem
devices.
(stat_worker): Eliminate path_conv argument. Call build_fh_name to construct
fhandler. Use fh->error() rather than pc->error to detect errors in fhandler
construction.
(access_worker): New function pulled from access. Accommodate in-filesystem
devices.
(access): Use access_worker.
(fpathconf): Detect if this is an 'auto' device rather than an on-filesystem
device and handle appropriately.
(mknod_worker): New function.
(mknod32): New function.
(chroot): Free normalized path -- assuming it was actually cmalloced.
* tty.cc (create_tty_master): Tweak for new device class.
(tty::common_init): Ditto.
* winsup.h (stat_worker): Remove.
(symlink_worker): Declare.
* exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't
worry about pending_signals since sig_dispatch_pending should always do the
right thing now.
(sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3.
* pinfo.h: Move __SIG enum to sigproc.h.
(PICOM_FIFO): New enum element.
(_pinfo): Remove 'thread2signal' stuff throughout class.
(_pinfo::commune_send): Make varargs.
(_pinfo::sigtodo): Eliminate.
(_pinfo::thread2signal): Ditto.
* signal.cc (kill_worker): Eliminate call to setthread2signal.
* sigproc.cc (local_sigtodo): Eliminate.
(getlocal_sigtodo): Ditto.
(sigelem): New class.
(pending_signals): New class.
(sigqueue): New variable, start of sigqueue linked list.
(sigcatch_nonmain): Eliminate.
(sigcatch_main): Eliminate.
(sigcatch_nosync): Eliminate.
(sigcomplete_nonmain): Eliminate.
(pending_signals): Eliminate.
(sig_clear): Call signal thread to clear pending signals, unless already in
signal thread.
(sigpending): Call signal thread to get pending signals.
(sig_dispatch_pending): Eliminate use of pending_signals and just check
sigqueue.
(sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close
signal pipe handle.
(sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send
signals.
(getevent): Eliminate.
(pending_signals::add): New function.
(pending_signals::del): New function.
(pending_signals::next): New function.
(wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to
communicate and maintain a linked list of signals.
* sigproc.h: Move __SIG defines here. Add __SIGPENDING.
(sig_dispatch_pending): Remove "C" specifier.
(sig_handle): Accept a mask argument.
* thread.cc: Remove signal handling considerations throughout.
2003-09-25 08:37:18 +08:00
|
|
|
|
2010-06-15 20:05:15 +08:00
|
|
|
HANDLE handle () const { return conv_handle.handle (); }
|
2010-09-13 19:17:36 +08:00
|
|
|
struct _FILE_NETWORK_OPEN_INFORMATION *fnoi () { return conv_handle.fnoi (); }
|
2010-09-30 21:52:34 +08:00
|
|
|
struct fattr3 *nfsattr () { return conv_handle.nfsattr (); }
|
2010-10-07 22:03:26 +08:00
|
|
|
void reset_conv_handle () { conv_handle.set (NULL); }
|
2010-06-15 20:05:15 +08:00
|
|
|
void close_conv_handle () { conv_handle.close (); }
|
|
|
|
|
2013-04-23 17:44:36 +08:00
|
|
|
ino_t get_ino_by_handle (HANDLE h);
|
2015-02-15 16:59:55 +08:00
|
|
|
inline const char *get_posix () const { return posix_path; }
|
|
|
|
void __reg2 set_posix (const char *);
|
2004-04-14 11:08:00 +08:00
|
|
|
DWORD get_symlink_length () { return symlink_length; };
|
2003-02-13 11:13:37 +08:00
|
|
|
private:
|
2009-08-02 03:52:46 +08:00
|
|
|
char *modifiable_path () {return (char *) path;}
|
2000-02-18 03:38:33 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Symlink marker */
|
|
|
|
#define SYMLINK_COOKIE "!<symlink>"
|
|
|
|
|
|
|
|
/* Socket marker */
|
|
|
|
#define SOCKET_COOKIE "!<socket >"
|
|
|
|
|
2009-08-27 04:32:35 +08:00
|
|
|
/* Interix symlink marker */
|
|
|
|
#define INTERIX_SYMLINK_COOKIE "IntxLNK\1"
|
|
|
|
|
2001-10-31 08:55:32 +08:00
|
|
|
enum fe_types
|
|
|
|
{
|
|
|
|
FE_NADA = 0, /* Nothing special */
|
|
|
|
FE_NNF = 1, /* Return NULL if not found */
|
2006-02-01 05:49:39 +08:00
|
|
|
FE_CWD = 4, /* Search CWD for program */
|
|
|
|
FE_DLL = 8 /* Search for DLLs, not executables. */
|
2001-10-31 08:55:32 +08:00
|
|
|
};
|
2013-01-21 12:34:52 +08:00
|
|
|
const char *__reg3 find_exec (const char *name, path_conv& buf,
|
2015-02-11 21:15:59 +08:00
|
|
|
const char *search = "PATH",
|
2008-03-23 05:04:16 +08:00
|
|
|
unsigned opt = FE_NADA,
|
2013-01-21 12:34:52 +08:00
|
|
|
const char **known_suffix = NULL);
|
2000-08-22 13:10:20 +08:00
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
/* Common macros for checking for invalid path names */
|
2000-05-30 21:45:20 +08:00
|
|
|
#define isdrive(s) (isalpha (*(s)) && (s)[1] == ':')
|
2008-03-07 19:24:51 +08:00
|
|
|
#define iswdrive(s) (iswalpha (*(s)) && (s)[1] == L':')
|
2000-09-05 11:16:28 +08:00
|
|
|
|
2000-11-01 07:14:29 +08:00
|
|
|
static inline bool
|
|
|
|
has_exec_chars (const char *buf, int len)
|
|
|
|
{
|
|
|
|
return len >= 2 &&
|
|
|
|
((buf[0] == '#' && buf[1] == '!') ||
|
|
|
|
(buf[0] == ':' && buf[1] == '\n') ||
|
|
|
|
(buf[0] == 'M' && buf[1] == 'Z'));
|
|
|
|
}
|
|
|
|
|
2013-01-21 12:34:52 +08:00
|
|
|
int __reg3 pathmatch (const char *path1, const char *path2, bool caseinsensitive);
|
|
|
|
int __reg3 pathnmatch (const char *path1, const char *path2, int len, bool caseinsensitive);
|
|
|
|
bool __reg2 has_dot_last_component (const char *dir, bool test_dot_dot);
|
2002-05-02 12:13:48 +08:00
|
|
|
|
2013-01-21 12:34:52 +08:00
|
|
|
int __reg3 path_prefix_p (const char *path1, const char *path2, int len1,
|
|
|
|
bool caseinsensitive);
|
2003-01-20 10:57:54 +08:00
|
|
|
|
2011-12-13 19:54:28 +08:00
|
|
|
NTSTATUS file_get_fnoi (HANDLE, bool, struct _FILE_NETWORK_OPEN_INFORMATION *);
|
2008-04-08 00:15:45 +08:00
|
|
|
int normalize_win32_path (const char *, char *, char *&);
|
|
|
|
int normalize_posix_path (const char *, char *, char *&);
|
2013-01-21 12:34:52 +08:00
|
|
|
PUNICODE_STRING __reg3 get_nt_native_path (const char *, UNICODE_STRING&, bool);
|
2005-03-30 01:42:50 +08:00
|
|
|
|
2013-04-24 18:16:13 +08:00
|
|
|
int __reg3 symlink_worker (const char *, const char *, bool);
|