Add "error" member.
(cwdstuff::get_error): New inline method.
(cwdstuff::get_error_desc): Declare.
(cwdstuff::set): Change first parameter to pointer to path_conv.
* path.cc (chdir): Drop doit. Align call to cwdstuff::set to
new arguments.
(cwdstuff::init): Only call cwdstuff::set if it's not already
initialized. Add comment. Drop third parameter in call to
cwdstuff::set.
(cwdstuff::set): Partially rewrite. Add lots of comments to explain
everything. Drop "doit" since it's not used anymore. Always create
new handle to CWD if not in a virtual path. Drop PEB locking when
reading PEB values in init phase. Check for accessibility to set
correct error code. Drop Vista workaround. Never write back into PEB.
Set Win32 CWD to \\?\PIPE\ on init. Simplify creation of win32 path.
Set new error member to a meaningful value.
(cwdstuff::get_error_desc): New method to generate error message
from cwd error code.
* spawn.cc (spawn_guts): Call cwdstuff::get_error_desc to create
more meaningful error message when not being able to start native
Win32 app due to CWD restrictions. When starting native Win32 app,
lock cwd and use in calls to CreateProcessW/CreateProcessAsUserW.
relative DOS path conversion. Simplify fixing the path.
In CCP_POSIX_TO_WIN_W conversion, always drop long path prefix if path
fits into MAX_PATH. Explain why.
know that we have filled out the filesystem information.
* path.h (path_conv::path_conv): Use consistent initialization for
constructors.
* include/sys/cygwin.h: Define CW_STRERROR.
* include/cygwin/version.h: Bump CYGWIN_VERSION_API_MINOR to 228.
* include/external.h: Implement CW_STRERROR.
fhandler.
* fhandler.cc (fhandler_base::fstatvfs): Keep handle in created
path_conv.
* fhandler.h (fhandler_base::get_stat_access): New method.
(fhandler_base::get_stat_handle): New method.
* fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Use handle
returned by get_stat_handle. Only request inode from system if it
isn't already set in the fhandler, and only for filesystems supporting
them.
(fhandler_base::fstat_fs): Use handle returned by get_stat_handle.
Change the way open_fs is called. Explain why.
(fhandler_base::fstat_helper): Use handle returned by get_stat_handle.
Never use 0 inode number. Simplify executable recognition by re-using
get_stat_handle if file could be opened with sufficient rights.
(fhandler_disk_file::fstatvfs): Use handle returned by get_stat_handle.
(fhandler_disk_file::facl): Use handle returned by get_stat_handle in
GETACL and GETACLCNT cases.
(fhandler_disk_file::link): Use handle returned by get_stat_handle
instead of opening file here again. Add comment.
(readdir_get_ino): Keep handle in created path_conv and drop
opening file.
* ntdll.h (wait_pending): New helper function.
* path.cc (symlink_info::check): Drop unused 'opt' parameter from
declaration. Add path_conv_handle argument.
(path_conv::check): Make sure conv_handle is closed. Keep
PC_KEEP_HANDLE flag in pflags_or. Accommodate call to sym.check to
new args.
(path_conv::~path_conv): Close conv_handle.
(symlink_info::check_shortcut): Don't re-open file here, just use
incoming handle. Drop goto's and label out.
(symlink_info::check_sysfile): Don't re-open file here, just use
incoming handle. Keep track of file position to accommodate the fact
that file has been opened asynchronously in calling function.
(symlink_info::check_nfs_symlink): Don't re-open file here, just use
incoming handle.
(symlink_info::check): Drop unused 'opt' parameter. Add
path_conv_handle argument. Always try to open file with GENERIC_READ
rights first to allow reading file content w/o having to re-open the
file. Drop back to READ_CONTROL | FILE_READ_ATTRIBUTES otherwise.
Call symlink test functions (except for check_reparse_point) only if
file could be opened with GENERIC_READ. Keep file handle open if
PC_KEEP_HANDLE is set in pflags.
* path.h (enum pathconv_arg): Add PC_KEEP_HANDLE flag.
(class path_conv_handle): New class.
(class path_conv): Add conv_handle member.
(path_conv::operator =): Duplicate conv_handle.
(path_conv::handle): New method.
(path_conv::access): New method.
(path_conv::reset_conv_handle): New method.
(path_conv::close_conv_handle): New method.
local UNICODE_STRING object.
(symlink_info::check_sysfile): Ditto. Return immediately if NtOpenFile
failed to avoid closing random handle. Improve debug output in case
NtReadFile failed.
in udf check. Remove overagressive bracketing. Don't set h to NULL
without closing the handle. Fix using wrong handle in checking
file system when using parent directory handle.
(STATUS_BAD_NETWORK_NAME): Define.
* path.cc (symlink_info::check): Convert STATUS_BAD_NETWORK_PATH and
STATUS_BAD_NETWORK_NAME into an immediate ENOENT.
mount_info::conv_to_win32_path since the flag value is overwritten by
mount_info::conv_to_win32_path anyway.
Set flags for DOS paths before calling symlink_info::check so they can
be used in that function already.
(fillout_mntent): Ditto.
* path.cc (path_conv::get_nt_native_path): Use path_conv's
has_dos_filenames_only method.
(path_conv::check): Add PATH_IHASH flag if FS has unreliable inode
numbers.
(symlink_info::check_shortcut): Or symlink flags to pflags.
(symlink_info::check_sysfile): Ditto. Change test accordingly.
(symlink_info::check_reparse_point): Ditto.
(symlink_info::check_nfs_symlink): Ditto.
(symlink_info::check): Check PATH_DOS flag in call to get_nt_native_path
to utilize mount flag. Ditto in test for potential restarting. Set
PATH_DOS if FS only allows DOS filename rules.
* path.h (enum path_types): Add PATH_DOS and PATH_IHASH.
(path_conv::hasgood_inode): Check PATH_IHASH instead of
fs.hasgood_inode.
(path_conv::has_dos_filenames_only): New method.
* include/sys/mount.h (MOUNT_DOS): New mount flag.
(MOUNT_IHASH): Ditto.
* path.cc (path_conv::check): Clear filesystem info if following a
symlink. Use new fs_info::inited method to check if FS info is already
available.
(symlink_info::check): Drop fs_update_called. Use fs_info::inited
method instead. Streamline test for leading space and trailing dot or
space. Add comments.
declare with regparms.
* path.cc (get_nt_native_path): Add third parameter to allow conversion
of leading and trailing dots and spaces on filesystems only supporting
filenames following DOS rules.
(path_conv::get_nt_native_path): Call get_nt_native_path according to
fs.has_dos_filenames_only flag.
(getfileattr): Accommodate new parameter to get_nt_native_path.
(symlink_info::check): Revamp fs_update_called handling to call
fs.update only once per call. Call get_nt_native_path according to
fs.has_dos_filenames_only flag. Streamline filesystem dependent code
not to be called more than once unnecessarily. Drop code tweaking
incoming path for broken filesystems only allowing DOS pathnames.
Rely on changed get_nt_native_path instead.
* mount.cc (fillout_mntent): Accommodate new parameter to
get_nt_native_path.
* strfuncs.cc (tfx_rev_chars): New conversion table with comment.
(sys_cp_wcstombs): Use tfx_rev_chars rather than tfx_chars.
from mask. Expand the comment a bit.
(WIN_FAT_FLAGS): New define.
(FS_IS_WINDOWS_FAT): New macro.
(fs_info::update): Handle remote FS faking to be FAT. Subsume under
CIFS. Check for NWFS and has_buggy_basic_info only for remote
filesystems. Add check for has_dos_filenames_only.
* mount.h (class fs_info): Add has_dos_filenames_only status flag.
Implement accessors.
* path.cc (symlink_info::check): Rearrange variable definitions to
clear them up. Add a restart label to allow a clean restart within
the method. Add a check for broken filesystems only allowing DOS
pathnames in case we encounter a STATUS_OBJECT_NAME_NOT_FOUND status.
If all checks point to one of that, restart method with tweaked
incoming path. Add lengthy comments to explain what we do.
memory leak.
* path.h (path_conv::operator =): Just use cstrdup to allocate normalized_path,
avoiding attempt to free a pointer which is allocated in another pc.
FileDirectoryInformation info class to avoid problems with incomplete
filesystem implementations. Fix comments accordingly.
* fhandler_disk_file.cc (fhandler_disk_file::readdir_helper): Set
fname->Length to 0 in error case to avoid potential crash in debug
output.
(fhandler_disk_file::readdir): Try to speed up the working default case.
Check for STATUS_INVALID_NETWORK_RESPONSE as potential status value
returned by filesystems not implementing FileIdBothDirectoryInformation.
* ntdll.h (STATUS_INVALID_NETWORK_RESPONSE): Define.
(FILE_BOTH_DIRECTORY_INFORMATION): Rename to official name.
* path.cc (symlink_info::check): Don't request FILE_READ_EA access, it's
not required for NFS. Try to speed up the working default case. Check
for STATUS_INVALID_NETWORK_RESPONSE as potential status value returned
by filesystems not supporting non-NULL EA parameters. Fix the way
fs.update is called. Improve debug output.
SubstituteName for volume string to recognize volume mount points.
Reuse subst when calling sys_wcstombs.
* syscalls.cc (rename): Set errno to EBUSY when trying to rename
volume mount points. Explain why.
* mount.cc (mount_info::from_fstab): Remove extern declaration of
transform_chars.
* path.cc (tfx_chars): Move to strfuncs.cc.
(transform_chars): Ditto.
* strfunc.cc (tfx_chars): Moved here from path.cc.
(transform_chars): Ditto.
(sys_cp_wcstombs): Make UNICODE private use area conversion roundtrip
save for all characters.
(sys_cp_mbstowcs): Ditto, by removing special case for UTF-8 sequences
representing U+f0XX UNICODE chars. Fix typo in comment.
LocalFree instead of ::free.
* sec_acl.cc: Throughout replace old ACE flag definitions with current
definitions as used in MSDN man pages.
* security.cc: Ditto.
* fhandler.cc (fhandler_base::open): Make sure file has really been
just created before fixing file permissions. Add S_JUSTCREATED
attribute to set_file_attribute call.
* fhandler_disk_file.cc (fhandler_disk_file::mkdir): Always create dir
with default security descriptor and fix descriptor afterwards.
Add S_JUSTCREATED flag to set_file_attribute call.
* fhandler_socket.cc (fhandler_socket::bind): Ditto for AF_LOCAL
socket files.
* path.cc (symlink_worker): Ditto for symlinks.
* security.cc (get_file_sd): Call GetSecurityInfo rather than
NtQuerySecurityObject. Explain why. Change error handling accordingly.
(alloc_sd): Skip non-inherited, non-standard entries in ACL if
S_JUSTCREATED attribute is set. Explain why. Minor format fixes.
* security.h (S_JUSTCREATED): New define.
(security_descriptor::operator=): New operator.
returning pointer to posix path.
(cwdstuff::reset_posix): Convert to non-inline method taking a wchar_t
pointer.
* path.cc (cwdstuff::set): Revert change from 2009-05-13. Set posix
to valid incoming path again.
(cwdstuff::reset_posix): New implementation setting posix path from
incoming wchar_t path. Explain usage.
(cwdstuff::get_posix): Drop implementation.
(cwdstuff::get): Drop special case to handle empty posix path.
* syscalls.cc (internal_setlocale): Store old posix cwd as wide char
path. Restore posix cwd using new charset. Explain why.
* path.cc (symlink_info::check_reparse_point): Return -1 for volume
mount points. Explain why.
(symlink_info::check): Call fs.update again for volume mount points.
Explain why.
the length exceeds it.
* net.cc (fdsock): Use 65535 as window size, just like the comment says or we
run into problems with DuplicateHandle.
* path.cc (patch_conv::check): Use set_path to set invalid filename.
* path.h (path_conv::path_conv): Ditto.
* cygheap.h: Remove stuff now included in cygheap_malloc.h and include that
file. Make cygheap_init a standard c++ function. Remove unneeded child_info
declaration.
* path.h: Include cygheap_malloc.h. Remove extra cstrdup declaration.
(path_conv): Reorganize to group variables together.
(path_conv::path): Make const char *.
(path_conv::known_suffix): Ditto.
(path_conv::normalized_path): Ditto.
(path_conv::path_conv): Reorganize initializers to reflect new element
ordering.
(path_conv::get_win32): Change return value to const char *.
(path_conv::set_path): Move back here from spawn.cc.
(parh_conv::modifiable_path): New function.
* path.cc (path_conv::add_ext_from_sym): Accommodate const'ness of
known_suffixes.
(path_conv::set_normalized_path): Ditto for normalized_path.
(path_conv::check): Use modifiable_path whereever we need to modify the path
element. Use set_path to set the path.
(path_conv::~path_conv): Accommodate new const'ness.
* spawn.cc (perhaps_suffix): Declare ext as const since that's what is being
returned.
(path_conv::set_path): Move back to path.h.
* winf.f (linebuf): Perform minor cleanup.
(linebuf::fromargv): Change second parameter to const.
* winf.cc (linebuf::fromargv): Ditto.
Initialize to NULL in constructors. Drop normalized_path_size member.
(path_conv::size): Remove.
(path_conv::operator =): Always copy with sizeof path_conv. Always
duplicate path on cygheap.
(path_conv::set_path): Move implementation to spawn.cc.
* path.cc (path_conv::set_normalized_path): Always allocate
normalized_path on cygheap.
(path_conv::check): Don't work on path, rather allocate THIS_path in
TLS and use it throughout. When finished, allocate path on cygheap
and copy over. Defer tacking on extension after having copied path.
* spawn.cc (path_conv::set_path): Implement here.