use FileIdBothDirectoryInformation on NFS shares. Fix comment to
explain why.
* path.cc (symlink_info::check): Reinstantiate no_ea. Use in
erroneously changed condition.
(fhandler_base::fstat_by_handle): Drop fai_size and pfai in favor of
static struct fai_buf. Restructure.
(fhandler_base::fstat_by_name): Drop fvi_size and pfvi. Drop fdi_size
and pfdi in favor of static struct fdi_buf. Drop redundant test for
existance. Use FileDirectoryInformation class instead of
FileBothDirectoryInformation. Drop call to NtQueryVolumeInformationFile
in favor of using pc.fs_serial_number (). Fix FileId information given
to fstat_helper.
(fhandler_disk_file::fstatvfs): Drop fvi_size, pfvi, fai_size and pfai.
Drop getting FileFsVolumeInformation and FileFsAttributeInformation in
favor of using the related path_conv info.
(fhandler_disk_file::opendir): Fix comment.
(fhandler_disk_file::readdir): Ditto. Use FileDirectoryInformation
class instead of FileBothDirectoryInformation.
* path.cc (fs_info::update): Store MaximumComponentNameLength in new
member name_len.
* path.h (struct fs_info): Use ULONG rather than DWORD. Add member
name_len to store MaximumComponentNameLength. Add accessor methods.
(path_conv::fs_name_len): New method.
dirent_info_mask.
* fhandler_disk_file.cc (fhandler_disk_file::opendir): Set
dirent_nfs_d_ino flag for NFS shares. Explain why.
(fhandler_disk_file::readdir): Use FileNamesInformation instead of
FileBothDirectoryInformation info class on NFS clients not supporting
the FileIdBothDirectoryInformation info class. Use local pointers to
accommodate different offsets.
* path.cc (symlink_info::check): Don't test directories for symlinks
on NFS shares. Enhance comment.
* fhandler.cc (fhandler_base::open): Open files on NFS shares with
correct access flags and EAs.
* fhandler.h (fhandler_base::fstat_by_nfs_ea): Declare.
* fhandler_disk_file.cc (fhandler_base::fstat_by_nfs_ea): New method.
(fhandler_base::fstat_by_handle): Call fstat_by_nfs_ea for files on
NFS shares.
(fhandler_disk_file::fchmod): Use NFS specific method to set mode for
files on NFS shares. Don't overrule errno from call to
set_file_attribute with errno from NtSetInformationFile call.
(fhandler_disk_file::fchown): Add comment.
* mount.cc (fillout_mntent): Accommodate change in second parameter
to fs_info::update.
* nfs.cc: New file.
* nfs.h: New file.
* path.cc (fs_info::update): Take handle instead of bool as second
parameter. Use that handle if it's not NULL. Only close handle if
it has been opened here. Use static defined buffers instead of
alloca'd buffers.
(path_conv::check): Call symlink_info::check with reference to fs.
Don't call fs.update here if file exists.
(conv_path_list): Prefer tmp_pathbuf buffer over using alloca.
(symlink_worker): Use NFS specific method to create symlinks on NFS
shares. Prefer tmp_pathbuf buffer over using alloca.
(symlink_info::check_shortcut): Reopen file from incoming handle
with necessary FILE_GENERIC_READ flag. Prefer tmp_pathbuf buffer over
using alloca.
(symlink_info::check_sysfile): Ditto.
(symlink_info::check_reparse_point): Use tmp_pathbuf buffer to
allocate REPARSE_DATA_BUFFER.
(symlink_info::check_nfs_symlink): New method.
(enum symlink_t): Remove.
(symlink_info::check): Don't use NtQueryAttributesFile. Rather, open
file with necessary access flags and call NtQueryInformationFile. Fix
error handling in case file can't be opened. For existing files, call
fs_info::update here. Restructure symlink checking to accommodate the
fact that the file is already open. Add case for NFS symlinks.
* path.h (fs_info::update): Take handle instead of bool as second
parameter.
Revamp advisory file locking to avoid cross reference pointers as well
as to allow BSD flock semantics. More agressively delete unused nodes
and sync objects.
* fhandler.h (fhandler_base::ino): Rename from namehash. Fix comment.
(fhandler_base::node): Remove.
(fhandler_base::unique_id): Add.
(fhandler_base::del_my_locks): New method.
(get_ino): Rename from get_namehash. Change usage throughout Cygwin.
(get_unique_id): New method.
* fhandler.cc (fhandler_base::close): Call own del_my_locks method.
Fix comment.
(fhandler_base::fhandler_base): Accommodate new and changed members.
(fhandler_base::fixup_after_fork): Call del_my_locks.
(fhandler_base::fixup_after_exec): Ditto for files with close-on-exec
flag set.
* fhandler_disk_file.cc (get_ino_by_handle): Rename from
readdir_get_ino_by_handle. Accommodate throughout.
(fhandler_base::open_fs): Fill ino with inode number if FS has good
inodes. Allocate a LUID and store in unique_id to recognize file
descriptors referencing the same file object.
* flock.cc: Drop flock TODO comments. Use explicit types __dev32_t
and __ino64_t instead of dev_t and ino_t.
(LOCK_OBJ_NAME_LEN): Change to reflect longer lf_id length.
(get_obj_handle_count): New method.
(lockf_t::lf_id): Change type to long long.
(inode_t::get_lock_obj_handle_count): Drop in favor of static function
get_obj_handle_count.
(inode_t::del_locks): Remove.
(inode_t::get): Add create_if_missing flag argument.
(inode_t::del_my_locks): Reimplement to handle POSIX and BSD flock
locks. Return if node can be deleted or not.
(inode_t::~inode_t): Ditto. Close handles to i_dir and i_mtx.
(fixup_lockf_after_fork): Remove.
(fhandler_base::del_my_locks): New method.
(fixup_lockf_after_exec): Check if node can be deleted.
(inode_t::get): Only create node if create_if_missing is set. Lock
the returned node here before unlocking the node list.
(inode_t::get_all_locks_list): Accommodate new lf_id length.
(inode_t::create_lock_obj): Ditto.
(lockf_t::open_lock_obj): Ditto. Change return type to bool. De-const.
Set lf_obj instead of returning a handle.
(lockf_t::del_lock_obj): Call SetEvent only if new incoming parameters
allow it. Explain how it's supposed to work.
(fhandler_disk_file::lock): Only fetch file length in SEEK_END case.
Use NtQueryInformationFile(FileStandardInformation) instead of
calling fstat_by_handle. Always unlock node before returning.
Use fhandler's unique id to create lf_id for BSD flock locks.
Rely on node lock from inode_t::get. Call del_lock_obj on removed
locks here to allow explicit unlocking. Delete node if no lock exists
on the file anymore.
(lf_setlock): Get file handle as additional parameter. Handle the fact
that lf_getblock now always opens the attached event object. Reactivate
erroneously applied patch which deactivates setting thread priority.
Additionally handle blocking on BSD flock locks.
(lf_clearlock): Get file handle as additional parameter.
(lf_getlock): Close event handle opened by lf_getblock.
(lf_getblock): Open potentially blocking event object here and check
its signal state if it's a BSD flock lock.
(lf_wakelock): Get file handle as additional parameter.
* fork.cc (frok::child): Drop call to fixup_lockf_after_fork.
* ntdll.h (struct _EVENT_BASIC_INFORMATION): Define.
(enum _EVENT_INFORMATION_CLASS): Define.
(NtQueryEvent): Declare.
* fhandler.h (fhandler_base::fs_flags): Remove.
(fhandler_base::set_fs_flags): Remove.
(fhandler_base::get_fs_flags): Remove.
* fhandler.cc (fhandler_base::write): Check for sparse file using
pc.fs_flags().
* fhandler_disk_file.cc (fhandler_disk_file::ftruncate): Ditto.
The return of the volume serial number in fs_info.
* fhandler.h (get_dev): New method.
* fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Drop call to
NtQueryVolumeInformationFile(FileFsVolumeInformation). Just use
get_dev() method.
* fhandler_fifo.cc (fhandler_fifo::open) Use device ID and inode number
to generate fifo name.
* path.h (fs_info::sernum): New member.
(fs_info::serial_number): New method.
(path_conv::fs_serial_number): New method.
* path.cc (fs_info::update): Fetch volume serial number and store in
sernum.
munging. Convert all chars in the 0xf0xx area to it's ascii equivalent.
* path.cc (normalize_posix_path): Don't treat "X:foo" as windows path,
only "a:\foo".
(tfx_chars): New transformation table for special DOS chars.
(tfx_chars_managed): Ditto, plus transformation of uppercase ASCII
chars.
(transform_chars): New function.
(get_nt_native_path): Make static. Call transform_chars for all valid
FS paths. Get additional flag if file is managed or not. Accommodate
throughout.
(getfileattr): Get additional flag if file is managed or not.
Accommodate throughout.
(path_conv::check): Disable special handling for trailing dots and
spaces.
(mount_item::build_win32): Disable code for managed paths.
(mount_info::conv_to_posix_path): Ditto.
* path.h (get_nt_native_path): Remove declaration.
name in terms of sizeof(WCHAR).
(fhandler_disk_file::readdir_helper): Convert *all* of fname.
* path.cc (fillout_mntent): Use tmp_pathbuf for path buffer.
(symlink_worker): Ditto.
(SCAN_JUSTCHECKTHIS): New state for suffix_scan to define
that only the actual name gets cheked and a suffix is never attached.
(suffix_scan::has): If filename + suffix would be > NAME_MAX, start
in SCAN_JUSTCHECKTHIS state.
(suffix_scan::next): Add case for SCAN_JUSTCHECKTHIS.
(symlink_info::check): Use tmp_pathbuf for path buffer. Goto
file_not_symlink in case of invalid file name.
(realpath): Use tmp_pathbuf for path buffer.
instead of close to avoid calling close from wrong class when changing
a file system based device node.
(fhandler_disk_file::fchown): Ditto.
(fhandler_disk_file::facl): Ditto.
* cygwin.din (getxattr, listxattr, removexattr, setxattr, lgetxattr,
llistxattr, lremovexattr, lsetxattr, fgetxattr, flistxattr,
fremovexattr, fsetxattr): Export Linux extended attribute functions.
Sort.
* errno.cc (errmap): Add mappings for ERROR_EAS_DIDNT_FIT,
ERROR_EAS_NOT_SUPPORTED, ERROR_EA_LIST_INCONSISTENT,
ERROR_EA_TABLE_FULL, ERROR_FILE_CORRUPT, ERROR_INVALID_EA_NAME.
* fhandler.h (class fhandler_base): Declare new fgetxattr and
fsetxattr methods.
(class fhandler_disk_file): Ditto.
* fhandler.cc (fhandler_base::fgetxattr): New method.
(fhandler_base::fsetxattr): New method.
* fhandler_disk_file.cc (fhandler_disk_file::fgetxattr): New method.
(fhandler_disk_file::fsetxattr): New method.
* ntdll.h (STATUS_EA_TOO_LARGE): Define.
(STATUS_NONEXISTENT_EA_ENTRY): Define.
(STATUS_NO_EAS_ON_FILE): Define.
* ntea.cc (read_ea): Rewrite for long pathnames and for using with
Linux extended attribute functions.
(write_ea): Ditto.
(getxattr_worker): New static function.
(getxattr): New function.
(lgetxattr): New function.
(fgetxattr): New function.
(listxattr): New function.
(llistxattr): New function.
(flistxattr): New function.
(setxattr_worker): New static function.
(setxattr): New function.
(lsetxattr): New function.
(fsetxattr): New function.
(removexattr): New function.
(lsetxattr): New function.
(fsetxattr): New function.
* security.h (read_ea): Change declaration according to above changes.
(write_ea): Ditto.
* include/cygwin/version.h: Bump API minor version.
(off_current): New static variable.
(off_append): Ditto.
(fhandler_base::raw_write): Use NtWriteFile. Accommodate O_APPEND here.
(fhandler_base::write): Drop O_APPEND hack. Use NT functions.
(fhandler_base::lseek): Rewrite using NT functions.
* fhandler_disk_file.cc (fhandler_disk_file::fstatvfs): Add space in
debug output.
(fhandler_disk_file::ftruncate): Ditto.
* ntdll.h (STATUS_DISK_FULL): Define.
(FILE_USE_FILE_POINTER_POSITION): Define.
(FILE_WRITE_TO_END_OF_FILE): Define.
mode bit by setting the SYSTEM attribute.
* fhandler_socket.cc (fhandler_socket::fchmod): Add S_IFSOCK mode bit
when calling fhandler_disk_file::fchmod. Don't set attributes here.
* fhandler_disk_file.cc (fhandler_disk_file::link): Drop extern
declaration of stat_suffixes. Use NT native path in debug output.
(fhandler_base::utimes_fs): Simplify closeit case. Use close_fs
to close newly opened file handle.
(fhandler_base::open_fs): Use NT native path in debug output.
* path.cc: Throughout drop extern declaration of stat_suffixes.
* path.h (stat_suffixes): Declare.
* sec_acl.cc (acl_worker): Drop extern declaration of stat_suffixes.
* times.cc (utimes_worker): Take path_conv as parameter instead of
single-byte pathnam, drop nofollow argument, accommodate throughout.
Compare UNICODE paths when enumerating file descriptors. Fix
formatting. Use NT native path in debug output.
* delqueue.cc: Delete.
* fhandler.h (fhandler_base::close_fs): Drop declaration.
(fhandler_disk_file::close): Drop declaration.
* fhandler_disk_file.cc (fhandler_base::fstat_fs): Call close instead of
close_fs.
(fhandler_base::fstat_helper): Use open FH_UNIX handle in call to
get_file_attribute.
(fhandler_base::open_fs): Call close instead of get_file_attribute.
(fhandler_disk_file::close): Remove.
(fhandler_base::close_fs): Remove.
* fhandler_socket.cc (fhandler_socket::close): Just call
fhandler_base::close for FH_UNIX sockets.
* shared.cc (user_shared_initialize): Drop call to
user_shared->delqueue.init.
* shared_info.h (CURR_USER_MAGIC): Change according to below change.
(MAX_DELQUEUES_PENDING): Remove.
(class delqueue_list): Remove.
(class user_info): Remove delqueue.
* syscalls.cc (close_all_files): Drop call to
user_shared->delqueue.process_queue.
(unlink): Drop delqueue handling.
for binary in case of .exe files.
* ntdll.h (RtlPrefixUnicodeString): Declare.
* path.cc (path_conv::is_binary): New method.
* path.h (path_conv::is_binary): Declare.
* syscalls.cc (rename_append_suffix): New static helper function for
rename.
(rename): Rewrite. New suffix tests. Use native NT functions.
opened for reading the ACLs, fall back to faking them.
* sec_acl.cc (acl_worker): Handle non-existing files.
* security.cc (get_file_attribute): Return ILLEGAL_UID/ILLEGAL_GID
as owner/group for non-readable ACLs on file systems supporting them.
FileAttributes set to 0 when calling NtSetInformationFile since it has
a special meaning.
(fhandler_disk_file::facl): Ditto.
(fhandler_disk_file::link): Only set attributes after copying files.
Use SetFileAttributesW.
* syscalls.cc (unlink_nt): Only care for actual FILE_ATTRIBUTE_READONLY.
Don't allow FileAttributes set to 0 when calling NtSetInformationFile.
After marking for deletion, restore R/O attribute on files to
accommodate hardlinks.
(fhandler_base::utimes_fs): Fix white space.
(fhandler_disk_file::lock): Remove 9x blurb from comment.
(fhandler_disk_file::mkdir): Use NtCreateFile/NtClose instead of
CreateDirectoryA.
(fhandler_disk_file::rmdir): Accommodate changes to unlink_nt.
Simplify post-delete SMB-related tests. Use NtQueryAttributesFile
instead of GetFileAttributes.
* ntdll.h (STATUS_DIRECTORY_NOT_EMPTY): Define.
(NtQueryAttributesFile): Declare.
* syscalls.cc (unlink_nt): Return NTSTATUS. Drop setattrs parameter.
Never use FILE_DELETE_ON_CLOSE, always use
NtSetInformationFile(FileDispositionInformation) instead.
Check for R/O attributes and open file with FILE_WRITE_ATTRIBUTES
access if any of them are set. Remove R/O attributes before
marking for delete if necessary. Revert them afterwards if necessary.
(unlink): Accommodate changes to unlink_nt.
(fhandler_disk_file::fchmod): Always try to open file with required
access rights. Use NtSetInformationFile instead of SetFileAttributes.
(fhandler_disk_file::facl): Use NtSetInformationFile instead of
SetFileAttributes.
(fhandler_base::utimes_fs): Change lastaccess and lastwrite to
LARGE_INTEGER. Drop 9x directory case. Use NtSetInformationFile
instead of SetFileAttributes. Drop temporarily changing R/O attribute
since NtSetInformationFile(FileBasicInformation) also works on R/O
files.
* ntdll.h (STATUS_NOT_SUPPORTED): Define.
parameters to be the same as for RtlInitEmptyUnicodeString.
(RtlEqualPathPrefix): New inline function.
(RtlEqualPathSuffix): New inline function.
* fhandler_disk_file.cc: Accommodate parameter order change of
RtlInitEmptyUnicodeString throughout.
(fhandler_disk_file::link): Do path checking in unicode. Call
CopyFileW instead of CopyFileA.