* ntdll.h (struct _FILE_RENAME_INFORMATION): Define.
* path.cc (fs_info::update): Note length of rootdir prefix in
root_len.
(get_nt_native_path): New function, taking over functionality of
path_conv::get_nt_native_path.
(path_conv::get_nt_native_path): Just call get_nt_native_path.
* path.h (get_nt_native_path): Declare.
(struct fs_info): New member root_len.
(fs_info::length): New inline method returning root_len.
(path_conv::rootdir): New inline method returning rootdir prefix.
* syscalls.cc (try_to_bin): Rewrite using only system calls.
(unlink_nt): Call try_to_bin with additional handle to open file
parameter.
(statvfs): Use path_conv::rootdir method.
* wincap.h: Define has_recycle_dot_bin throughout.
* wincap.cc: Ditto.
(struct _FILE_DISPOSITION_INFORMATION): Define.
* syscalls.cc (unlink_9x): new function to delete file on 9x.
* syscalls.cc (unlink_nt): new function to delete file on NT.
(unlink): Simplify. Move OS dependent stuff into aforementioned
functions. Also handle FILE_ATTRIBUTE_HIDDEN as R/O-like flag.
(NtSetEaFile): Define.
* fhandler.cc (fhandler_base::open): Use appropriate open flags
in query case when allow_ntea is set.
* ntdll.h (struct _FILE_GET_EA_INFORMATION): Define.
(struct _FILE_FULL_EA_INFORMATION): Define.
(NtQueryEaFile): Declare.
(NtSetEaFile): Declare.
* ntea.cc (read_ea): Rename from NTReadEA and rewrite using
NtQueryEaFile.
(write_ea): Rename from NTWriteEA and rewrite using NtSetEaFile.
* path.cc (get_symlink_ea): Make static. Add handle parameter to
accomodate new read_ea call.
(set_symlink_ea): Make static. Add handle parameter to accomodate new
write_ea call.
(symlink_worker): Call set_symlink_ea while file is still open.
(symlink_info::check): Call get_symlink_ea after file has been opened.
* security.cc (get_file_attribute): Accomodate new read_ea call.
(set_file_attribute): Accomodate new write_ea call.
* security.h (read_ea): Change declaration accordingly.
(write_ea): Ditto.
to take file size and inode number as 64 bit values.
* fhandler_disk_file.cc (FS_IS_SAMBA): Move to path.cc
(FS_IS_SAMBA_WITH_QUOTA): Ditto.
(path_conv::hasgood_inode): Delete.
(path_conv::is_samba): Delete.
(path_conv::isgood_inode): Centralized function to recognize
a good inode number.
(fhandler_base::fstat_by_handle): Constify fvi_size and fai_size.
Accomodate argument change in fstat_helper.
(fhandler_base::fstat_by_name): Ditto.
(fhandler_base::fstat_helper): Accomodate argument change. Call
path_conv::isgood_inode to recognize good inodes.
(fhandler_disk_file::opendir): Explain Samba weirdness here.
Call path_conv::fs_is_samba instead of path_conv::is_samba.
(fhandler_disk_file::readdir): Add STATUS_INVALID_INFO_CLASS
as valid return code from NtQueryDirectoryFile to indicate that
FileIdBothDirectoryInformation is not supported.
Call path_conv::isgood_inode to recognize good inodes.
* ntdll.h (STATUS_INVALID_INFO_CLASS): Define.
* path.cc (fs_info::update): Rework file system recognition
and set appropriate flags.
* path.h (struct fs_info): Add is_ntfs, is_samba and is_nfs flags.
Constify pure read accessors.
(fhandler_dev_floppy::get_drive_info): Rearrange so that now
NtQueryVolumeInformationFile is called on drives which don't support
IOCTL_DISK_GET_DRIVE_GEOMETRY.
* ntdll.h (struct _FILE_FS_SIZE_INFORMATION): Add.
(enum _FSINFOCLASS): Add missing values.
(NtOpenDirectoryObject): Define.
(NtQueryDirectoryObject): Define.
* fhandler_proc.cc: Include ctype.h and wchar.h.
(format_proc_partitions): Revamp loop over existing harddisks by
scanning the NT native \Device object directory and looking for
Harddisk entries.
* ntdll.h: Rearrange system call declarations alphabetically.
(DIRECTORY_QUERY): Define.
(struct _DIRECTORY_BASIC_INFORMATION): Define.
(NtOpenDirectoryObject): Declare.
(NtQueryDirectoryObject): Declare.
* dir.cc (__opendir_with_d_ino): Just call opendir.
(opendir): Remove CYGWIN_VERSION_CHECK_FOR_NEEDS_D_INO handling.
(readdir_worker): Only try generating d_ino if it's 0.
Utilize namehash of directories fhandler. Call readdir_get_ino to
generate d_ino for "..".
(seekdir64): Keep dirent_set_d_ino flag.
* fhandler.h (enum dirent_states): Add dirent_get_d_ino.
(class fhandler_disk_file): Declare new private methods readdir_helper
and readdir_9x.
* fhandler_disk_file.cc (path_conv::hasgood_inode): New method to
evaluate if a filesystem has reliable inode numbers.
(fhandler_base::fstat_by_handle): Accomodate structure member name
change from IndexNumber to FileId.
(fhandler_base::fstat_helper): Call hasgood_inode here.
(fhandler_disk_file::opendir): Call fhaccess only for real files.
Don't append '*' to __d_dirname here, move to readdir_9x. On NT,
open directory handle here. Set dirent_get_d_ino and dirent_set_d_ino
flags according to wincap and filesystem.
(fhandler_disk_file::readdir_helper): New method to implement readdir
postprocessing only once.
(readdir_get_ino_by_handle): New static function.
(readdir_get_ino): New function to centralize inode number evaluation
in case inode number hasn't been returned by NtQueryDirectoryFile.
(fhandler_disk_file::readdir): Move old functionality to readdir_9x.
Call readdir_9x when on 9x/Me. Implement NT specific readdir here.
(fhandler_disk_file::readdir_9x): Move 9x specific readdir here.
(fhandler_disk_file::seekdir): Accomodate new NT readdir method.
(fhandler_disk_file::closedir): Ditto.
(fhandler_cygdrive::fstat): Set d_ino to namehash. Add comment.
(fhandler_cygdrive::opendir): Call get_namehash to prepare later
correct evaluation of d_ino.
(fhandler_cygdrive::readdir): Replace recursion with loop. Evaluate
drive's d_ino by calling readdir_get_ino.
* fhandler_proc.cc (fhandler_proc::readdir): Set dirent_saw_dot and
dirent_saw_dot_dot to avoid seeing . and .. entries twice.
* fhandler_process.cc (fhandler_process::readdir): Ditto.
* fhandler_registry.cc (fhandler_registry::readdir): Ditto.
* ntdll.h (STATUS_INVALID_PARAMETER): New define.
(STATUS_INVALID_LEVEL): New define.
(struct _FILE_INTERNAL_INFORMATION): Rename member IndexNumber to
FileId (as in Nebbitt).
* path.h (path_conv::hasgood_inode): Now implemented in
fhandler_disk_file.cc.
* wincap.h (wincaps::has_fileid_dirinfo): New element.
* wincap.cc: Implement above element throughout.
* winsup.h (readdir_get_ino): Add declaration.
* include/sys/dirent.h (struct dirent): Slightly rename structure
members to accomodate changes.
Remove __USE_EXPENSIVE_CYGWIN_D_INO handling and declaration of
__opendir_with_d_ino.
STATUS_ACCESS_VIOLATION, check if the page is a mmaped page beyond
a file's EOF. Generate SIGBUS instead of SIGSEGV then.
* mmap.cc (__PROT_ATTACH): New define.
(__PROT_FILLER): Ditto.
(fh_anonymous): Rename from fh_paging_file;
(fh_disk_file): New global static variable.
(attached): New inline function.
(filler): Ditto.
(gen_create_protect): Split off from gen_protect to use the file's
access mode to create mapping always with maximum allowed protections.
(gen_protect): Accomodate pages attached beyond EOF. Use symbolic
values instead of numerics when possible. Drop create parameter.
(gen_access): Use file's access mode instead of protection.
(CreateMapping9x): Create named mapping names so that different
creation access modes result in different mappings.
(CreateMappingNT): Only reserve attached pages, don't commit them.
(MapViewNT): Ditto. Set AT_ROUND_TO_PAGE for all non-NULL base
addresses.
(mmap_func_t): Define CreateMapping and MapView function pointers
with additional openflags parameter.
(class mmap_record): Add openflags member.
(mmap_record::mmap_record): Add openflags parameter.
(mmap_record::get_openflags): New accessor.
(mmap_record::attached): Call global attached function.
(mmap_record::filler): Call global filler function.
(mmap_record::gen_create_protect): Call global gen_create_protect
function.
(mmap_record::gen_protect): Drop create parameter.
(mmap_record::alloc_fh): Set fhandler's access flags.
(list::search_record): Accomodate filler pages.
(list::set): Use inode number as hash value.
(map::get_list_by_fd): Check hash value against file's inode number.
(mmap_is_attached_page): New function to evaluate if a given address
is on a attached page. Called from _cygtls::handle_exceptions.
(mmap_worker): New function to do mapping and bookkeeping in a
single call.
(mmap64): Use roundup2 to round length to pagesize alignment.
Initialize global fhandlers. Simplify anonymous initialization.
Add SUSv3 compatible check of file open mode vs. requested protection.
Try creating new file handles to allow maximum page protection.
Allow creating attached pages in case of mapping beyond EOF.
Close new file handle if one has been created.
(munmap): Align len to pagesize.
(msync): Rework argument checks. Align len to pagesize.
(mprotect): Ditto. Accomodate attached pages.
(mlock): Use roundup/rounddown macros instead of homemade expressions.
(munlock): Add page alignment as in mlock.
(fhandler_dev_zero::munmap): Fix unmapping of non-private mappings.
(fhandler_dev_zero::fixup_mmap_after_fork): Accomodate filler pages.
(fixup_mmaps_after_fork): Don't fail if attached pages couldn't be
created in child. Avoid superfluous call to VirtualFree. Check for
original allocation protection to fix PAGE_WRITECOPY protection.
* ntdll.h: Revert deletion of AT_ROUND_TO_PAGE define.
* winsup.h (mmap_is_attached_page): Declare.
* cygheap.cc (_csbrk): Call getpagesize instead of getshmlba.
* dcrt0.cc (dll_crt0_0): Call mmap_init.
* external.cc (cygwin_internal): Call getpagesize instead of getshmlba.
* fhandler.h (fhandler_base::mmap): Change access to prot parameter.
(fhandler_base::fixup_mmap_after_fork): Ditto.
(fhandler_disk_file::mmap): Ditto.
(fhandler_disk_file::fixup_mmap_after_fork): Ditto.
(fhandler_dev_mem::mmap): Ditto.
(fhandler_dev_mem::fixup_mmap_after_fork): Ditto.
* fhandler_mem.cc (fhandler_dev_mem::write): Call getsystempagesize
instead of getpagesize.
(fhandler_dev_mem::read): Ditto.
(fhandler_dev_mem::fstat): Ditto.
(fhandler_dev_mem::mmap): Move to mmap.cc.
(fhandler_dev_mem::munmap): Ditto.
(fhandler_dev_mem::msync): Ditto.
(fhandler_dev_mem::fixup_mmap_after_fork): Ditto.
* fhandler_proc.cc (format_proc_meminfo): Call getsystempagesize
instead of getpagesize.
* fhandler_process.cc (format_process_stat): Ditto.
(format_process_status): Ditto.
(get_mem_values): Ditto.
* mmap.cc: Fix formatting. Try to make more readable and modular.
Take advantage of pagesize==granularity.
(gen_protect): New static function to evaluate Windows
protection bits from POSIX protection and flags.
(gen_access): Ditto for Windows access mode.
(VirtualProt9x): Wrapper function to call VirtualProtect on 9x.
(VirtualProtNT): Ditto for NT.
(VirtualProtEx9x): Ditto for VirtualProtectEx on 9x.
(VirtualProtExNT): Ditto for NT.
(CreateMapping9x): Wrapper function for creating a mapping handle on 9x.
(CreateMappingNT): Ditto for NT.
(MapView9x): Wrapper function to map a view on 9x.
(MapViewNT): Ditto for NT.
(mmap_funcs_9x): Structure containing function pointers to wrapper
functions for 9x.
(mmap_funcs_nt): Ditto for NT.
(mmap_func): Pointer to wrapper functions used in subsequent code.
(mmap_init): Initialize mmap_func depending on OS.
(class mmap_record): Use sensible member names. Add POSIX protection
member. Drop Windows access flags member. Constify more methods.
Use accessors instead of direct member access inside of own methods.
(mmap_record::gen_protect): Class wrapper to evaluate matching
Windows protection bits.
(mmap_record::gen_access): Ditto for Windows access flags.
(mmap_record::compatible_flags): New function to check if flags are
compatible with flags of existing map.
(list::add_record): Drop offset and length arguments.
(class map): Change counters to unsigned. Match usage throughout.
(mmapped_areas): Convert from pointer to global struct.
(mmap_record::alloc_page_map): Simplify.
(mmap_record::map_pages): Ditto.
(mmap_record::fixup_page_map): Delete.
(mmap64): Simplify. Add workaround for Windows 98 bug. Fix bug on
NT that existing anonymous mappings weren't searched for a match.
(munmap): Add workaround for Windows 98 bug.
(msync): Simplify.
(mprotect): Handle existing maps correctly.
(mlock): Add local pagesize variable and enlightening comment.
(fhandler_disk_file::mmap): Main functionality now in CreateMapping/
MapView wrapper functions.
(fhandler_disk_file::fixup_mmap_after_fork): Call MapView wrapper.
(fhandler_dev_mem::mmap): Moved from fhandler_mem.cc. Simplify by
calling MapViewNT.
(fhandler_dev_mem::munmap): Moved from fhandler_mem.cc.
(fhandler_dev_mem::msync): Ditto.
(fhandler_dev_mem::fixup_mmap_after_fork): Ditto. Call MapViewNT.
(fixup_mmaps_after_fork): Restructure and hopefully speed up loop for
setting protection and memory content on MAP_PRIVATE maps.
* ntdll.h (AT_ROUND_TO_PAGE): Remove define.
(AT_EXTENDABLE_FILE): Add define.
(NtCreateSection): Add prototype.
* syscalls.cc (getpagesize): Return granularity as pagesize now.
(getsystempagesize): New function to retrieve "real" pagesize.
(getshmlba): Delete since it's replaced by getpagesize now.
* wincap.h (wincaps::has_mmap_alignment_bug): New element.
* wincap.cc: Implement above element throughout.
* winsup.h (getshmlba): Drop prototype.
(getsystempagesize): Add prototype.
(mmap_init): Ditto.
* include/sys/mman.h: (Not yet) define MAP_NORESERVE.
eof_detected status flag. Delete is_eom and is_eof methods.
Move drive_size, bytes_per_sector, eom_detected status flag, as well
as the methods read_file, write_file, raw_read and raw_write to ...
(class fhandler_dev_floppy): ... here. Remove is_eom and is_eof
methods. Add dup method.
* fhandler_floppy.cc (IS_EOM): New macro.
(fhandler_dev_floppy::is_eom): Remove.
(fhandler_dev_floppy::is_eof): Remove.
(fhandler_dev_floppy::fhandler_dev_floppy): Initialize status flags.
(fhandler_dev_floppy::get_drive_info): Only call EX functions on
systems supporting them and stop suffering strange delays.
(fhandler_dev_floppy::read_file): Move here, drop setting
current_position.
(fhandler_dev_floppy::write_file): Move here, drop setting
current_position.
(fhandler_dev_floppy::open): Rearrange comment.
(fhandler_dev_floppy::dup): New method.
(fhandler_dev_floppy::get_current_position): New inline method. Use
instead of former current_position were appropriate.
(fhandler_dev_floppy::raw_read): Move here. Drop EOF handling.
(fhandler_dev_floppy::raw_write): Move here. Drop EOF handling.
(fhandler_dev_floppy::lseek): Remove useless conditions. Convert
sector_aligned_offset to LARGE_INTEGER to improve SetFilePointer call.
(fhandler_dev_floppy::ioctl): Move blocksize check in RDSETBLK case
to here.
* fhandler_raw.cc (fhandler_dev_raw::is_eom): Remove.
(fhandler_dev_raw::is_eof): Remove.
(fhandler_dev_raw::write_file): Remove.
(fhandler_dev_raw::read_file): Remove.
(fhandler_dev_raw::raw_read): Remove.
(fhandler_dev_raw::raw_write): Remove.
(fhandler_dev_raw::dup): Drop copying removed members.
(fhandler_dev_raw::ioctl): Drop blocksize testing.
* wincap.h: Implement has_disk_ex_ioctls throughout.
* wincap.cc: Ditto.
(wincap_vista): Preliminary wincaps for Windows Vista/Longhorn.
(wincapc::init): Add Vista/Longhorn handling.
* fhandler.cc (fhandler_base::raw_write): Don't touch has_changed flag.
* fhandler.h (enum change_state): Remove.
(fhandler_base::status): Revert has_changed to a simple bit.
(fhandler_base::fstat_helper): Add nAllocSize parameter. Rename
ftCreationTime to ftChangeTime.
* fhandler_disk_file.cc:
Call fstat_helper with additional
allocation size throughout.
(fhandler_base::fstat_by_handle): Use NT native functions to get
full file information on NT. Call fstat_helper with LastWriteTime
as ctime, if ChangeTime is not available.
(fhandler_base::fstat_by_name): Call fstat_helper with LastWriteTime
as ctime.
(fhandler_base::fstat_helper): Add comment. Drop special FAT
handling since it's useless. Use nAllocSize for st_blocks if available.
(fhandler_disk_file::touch_ctime): Only touch LastWriteTime.
(fhandler_disk_file::fchmod): Set has_changed on 9x only.
(fhandler_disk_file::fchown): Don't set has_changed.
(fhandler_disk_file::facl): Ditto.
(fhandler_disk_file::ftruncate): Ditto.
(fhandler_disk_file::link): Set has_changed on 9x only and on original
file only.
(fhandler_base::open_fs): Don't set has_changed in O_TRUNC case.
* ntdll.h (FILE_BASIC_INFORMATION): Define.
(FILE_STANDARD_INFORMATION): Define.
(FILE_INTERNAL_INFORMATION): Define.
(FILE_EA_INFORMATION): Define.
(FILE_ACCESS_INFORMATION): Define.
(FILE_POSITION_INFORMATION): Define.
(FILE_MODE_INFORMATION): Define.
(FILE_ALIGNMENT_INFORMATION): Define.
(FILE_NAME_INFORMATION): Don't define with arbitrary FileName size.
(FILE_ALL_INFORMATION): Define.
(FILE_INFORMATION_CLASS): Add FileAllInformation.
(FILE_FS_VOLUME_INFORMATION): Define.
(FS_INFORMATION_CLASS): Define.
(NtQueryVolumeInformationFile): Define.
with additional flags parameter. Change offset parameter to _off64_t.
(class fhandler_disk_file): Ditto.
(class fhandler_dev_mem): Ditto.
* fhandler_mem.cc (fhandler_dev_mem::fixup_mmap_after_fork):
Accomodate new parameters.
* mmap.cc: Include ntdll.h.
(class mmap_record): Add flags member.
(mmap_record::mmap_record): Add flags parameter.
(mmap_record::get_flags): New method.
(class map): Add next_anon_addr member to store next anonymous mapping
address suggestion.
(map::get_next_anon_addr): New method.
(map::set_next_anon_addr): New method.
(mmap64): Don't align offset and length to granularity in case of
MAP_ANONYMOUS on NT. Check for already existing mapping only on 9x.
Call mmap_record::mmap_record with additional flags argument.
(fhandler_base::fixup_mmap_after_fork): Accomodate new parameters.
(fhandler_disk_file::mmap): Use NtMapViewOfSection with
AT_ROUND_TO_PAGE flag for anonymous mappings on NT. If addr is NULL,
try to map adjacent to previous mapping.
(fhandler_disk_file::fixup_mmap_after_fork): Add flags argument.
Change offset parameter to _off64_t. Use NtMapViewOfSection to
re-create anonymous mappings on NT.
(fixup_mmaps_after_fork): Accomodate new parameters when calling
fhandler's fixup_mmaps_after_fork function.
* ntdll.h (AT_ROUND_TO_PAGE): New define.
* autoload.cc (NtQueryInformationFile): Return nonzero on error.
* ntdll.h (FILE_PIPE_LOCAL_INFORMATION): Add.
(NtQueryInformationFile): Fix types for last two arguments.
* pipe.cc: Include stdlib.h, limits.h, and ntdll.h.
(create_selectable_pipe): New function to create a pipe that can be used with
NtQueryInformationFile for select.
(fhandler_pipe::create): Call create_selectable_pipe instead of CreatePipe.
(pipe): Use DEFAULT_PIPEBUFSIZE as argument to create_pipe.
* select.cc: Include limits.h and ntdll.h.
(peek_pipe): Add select_printf output. Call NtQueryInformationFile to
implement select for write on pipes.
(fhandler_pipe::select_read): Reorder field assignments to be consistent with
fhandler_pipe::select_write.
(fhandler_pipe::select_write): Initialize startup, verify, cleanup, and
write_ready fields for select_record.
(fhandler_pipe::select_except): Tweak indentation to be consistent with
fhandler_pipe::select_write.
* dir.cc (mkdir): Change set_file_attribute call to indicate that
NT security isn't used.
* fhandler.cc (fhandler_base::open_9x): New method, created from
fhandler_base::open.
(fhandler_base::open): Rearrange to use NtCreateFile instead of
CreateFile.
* fhandler.h (enum query_state): Redefine query_null_access to
query_stat_control. query_null_access isn't allowed in NtCreateFile.
(fhandler_base::open_9x): Declare.
* fhandler_disk_file.cc (fhandler_base::fstat_fs): Use
query_stat_control first, query_read_control if that fails.
(fhandler_disk_file::fchmod): Call enable_restore_privilege before
trying to open for query_write_control. Don't fall back to
opening for query_read_control.
(fhandler_disk_file::fchown): Ditto.
(fhandler_disk_file::facl): Only request restore privilege and query
access necessary for given cmd.
* fhandler_raw.cc (fhandler_dev_raw::open): Call fhandler_base::open
instead of opening device here.
* ntdll.h (NtCreateFile): Declare.
* path.cc (symlink_worker): Change set_file_attribute call to indicate
that NT security isn't used.
* sec_acl.cc (getacl): Fix bracketing.
* sec_helper.cc (enable_restore_privilege): New function.
* security.cc (str2buf2uni_cat): New function.
(write_sd): Don't request restore permission here.
* security.h (set_process_privileges): Drop stale declaration.
(str2buf2uni): Declare.
(str2buf2uni_cat): Declare.
(enable_restore_privilege): Declare.
* syscalls.cc (fchown32): Return immediate success on 9x.
compressed size only if the matching attributes are set. Use
NtQueryInformationFile instead of GetCompressedFileSize.
(fhandler_base::fstat_by_handle): Remove NT 3.5 cruft since
local.dwVolumeSerialNumber isn't used subsequently.
* ntdll.h: Add typedefs for FILE_COMPRESSION_INFORMATION and
FILE_INFORMATION_CLASS.
real swap file usage by requesting SystemPagefileInformation. Use
GlobalMemoryStatus as fallback.
* ntdll.h (_SYSTEM_INFORMATION_CLASS): Add SystemPagefileInformation.
(struct _SYSTEM_PAGEFILE_INFORMATION): Define.
Drop ZwQuerySystemInformation since NtQuerySystemInformation was
already available.
* fhandler_proc.cc (format_proc_uptime): Replace call to
ZwQuerySystemInformation by call to NtQuerySystemInformation.
(format_proc_stat): Ditto.
* fhandler_process.cc (format_process_stat): Replace call to
ZwQueryInformationProcess by call to NtQueryInformationProcess.
(get_process_state): Ditto.
(get_mem_values): Ditto. Replace call to ZwQueryVirtualMemory by
call to NtQueryVirtualMemory.
* ntdll.h: Cleanup. Drop ZwQuerySystemInformation since
NtQuerySystemInformation was already available. Replace declarations
of ZwXXX functions by declarations of NtXXX.
* pinfo.cc (winpids::enumNT): Replace call to ZwQuerySystemInformation
by call to NtQuerySystemInformation.
(LoadFuncEx2): Adapted from LoadFuncEx. Provides control of return value for
nonexistent function.
(NtQueryObject): Declare.
(IsDebuggerPresent): Declare via LoadFuncEx2 and always return true if not
available.
* debug.h (being_debugged): Just rely on IsDebuggerPresent return value.
* dtable.cc (handle_to_fn): New function.
(dtable::init_std_file_from_handle): Attempt to derive std handle's name via
handle_to_fn.
(dtable::build_fhandler_from_name): Fill in what we can in path_conv structure
when given a handle and path doesn't exist.
* fhandler.cc (fhandler_base::open): Don't set the file pointer here. Use
pc->exists () to determine if file exists rather than calling GetFileAttributes
again.
* fhandler.h (fhandler_base::exec_state_isknown): New method.
(fhandler_base::fstat_helper): Add extra arguments to declaration.
(fhandler_base::fstat_by_handle): Declare new method.
(fhandler_base::fstat_by_name): Declare new method.
* fhandler_disk_file (num_entries): Make __stdcall.
(fhandler_base::fstat_by_handle): Define new method.
(fhandler_base::fstat_by_name): Define new method.
(fhandler_base:fstat): Call fstat_by_{handle,name} as appropriate.
(fhandler_disk_file::fstat_helper): Accept extra arguments for filling out stat
structure. Move handle or name specific stuff to new methods above.
(fhandler_disk_file::open): Use real_path->exists rather than calling
GetFileAttributes again.
* ntdll.h (FILE_NAME_INFORMATION): Define new structure.
(OBJECT_INFORMATION_CLASS): Partially define new enum.
(OBJECT_NAME_INFORMATION): Define new structure.
(NtQueryInformationFile): New declaration.
(NtQueryObject): New declaration.
* path.cc (path_conv::fillin): Define new method.
* path.h (path_conv::fillin): Declare new method.
(path_conv::drive_thpe): Rename from 'get_drive_type'.
(path_conv::volser): Declare new method.
(path_conv::volname): Declare new method.
(path_conv::root_dir): Declare new method.
* syscalls.cc (fstat64): Send real path_conv to fstat as second argument.
'ZwQueryVirtualMemory'.
* fhandler.h: Change type of bufalloc and filesize members of fhandler_virtual
from int to size_t. Change type of position member from __off32_t to
__off64_t. Add new fileid member to fhandler_virtual class. Make seekdir take
an __off64_t argument. Make lseek take an __off64_t argument. Add
fill_filebuf method to fhandler_virtual. Add fill_filebuf method to
fhandler_proc. Add fill_filebuf method to fhandler_registry. Add fill_filebuf
method to fhandler_process. Add saved_pid and saved_p members to
fhandler_process.
* fhandler_proc.cc (proc_listing_array): Add 'loadavg', 'meminfo', and 'stat'.
(proc_fhandlers array): Ditto.
(fhandler_proc::open): Use fill_filebuf to flesh out the file contents.
(fhandler_proc::fill_filebuf): New method.
(fhandler_proc::format_proc_meminfo): Ditto.
(fhandler_proc::format_proc_stat): Ditto.
(fhandler_proc::format_proc_uptime): Ditto.
* fhandler_process.cc (process_listing): Add 'stat' and 'statm'.
(fhandler_process::fstat): Find the _pinfo structure for the process named in
the filename. Return ENOENT if the process is no longer around. Set the gid
and uid fields of the stat structure.
(fhandler_process::open): Store pid and pointer to _pinfo structure in
saved_pid and saved_p respectively. Use fill_filebuf to flesh out file
contents.
(fhandler_proc::fill_filebuf): New method.
(format_process_stat): New function.
(format_process_status): Ditto.
(format_process_statm): Ditto.
(get_process_state): Ditto.
(get_mem_values): Ditto.
* fhandler_registry.cc (fhandler_registry::seekdir): Change argument type from
__off32_t to __off64_t.
(fhandler_registry::fill_filebuf): New method.
* fhandler_virtual.cc (fhandler_virtual::seekdir): Change argument type from
__off32_t to __off64_t.
(fhandler_virtual::lseek): Ditto.
(fhandler_virtual::fill_filebuf): New method.
(fhandler_virtual::fhandler_virtual): Initialise fileid to -1.
* wincap.cc: Set flag has_process_io_counters appropriately.
* wincap.h: Add flag has_process_io_counters.
* fhandler.h (fhandler_dev_raw::get_unit): New method.
(fhandler_dev_tape::norewind): Eliminate.
(fhandler_dev_tape::is_rewind_device): New method.
* fhandler_raw.cc (fhandler_dev_raw::open): Open new
fixed device name devices using NT internal method.
Keep calling fhandler_base::open() for old mount table
device mapping compatibility devices.
(fhandler_dev_raw::fstat): Eliminate. Settings are done
by fhandler_base::fstat() already.
* fhandler_tape.cc: Remove `norewind' usage throughout.
* ntdll.h: Define FILE_SYNCHRONOUS_IO_NONALERT.
Define struct _IO_STATUS_BLOCK.
Declare NtOpenFile().
* path.cc (get_raw_device_number): Add new approach for
using fixed device names.
(win32_device_name): Ditto.
(get_device_number): Ditto. Require POSIX path to begin
with "/dev/".
(mount_info::conv_to_win32_path): Call win32_device_name()
instead of get_device_number() after evaluating mount points
to allow changing the win32 destination path again.
* security.cc (str2buf2uni): Remove `static' to be able to
call function from fhandler_dev_raw::open().
* wincap.cc: Set flag has_raw_devices appropriately.
* wincap.h: Add flag has_raw_devices.
`LsaClose', `LsaEnumerateAccountRights', `LsaFreeMemory',
`LsaOpenPolicy', `LsaQueryInformationPolicy', `NetLocalGroupEnum',
`NetLocalGroupGetMembers', `NetServerEnum', `NetUserGetGroups' and
`NtCreateToken'.
* ntdll.h: Add declaration for `NtCreateToken'.
* sec_helper.cc: Add `well_known_local_sid', `well_known_dialup_sid',
`well_known_network_sid', `well_known_batch_sid',
`well_known_interactive_sid', `well_known_service_sid' and
`well_known_authenticated_users_sid'.
(cygsid::string): Define as const method.
(cygsid::get_sid): Set psid to NO_SID on error.
(cygsid::getfromstr): Ditto.
(cygsid::getfrompw): Simplify.
(cygsid::getfromgr): Check for gr == NULL.
(legal_sid_type): Move to security.h.
(set_process_privilege): Return -1 on error, otherwise 0 or 1 related
to previous privilege setting.
* security.cc (extract_nt_dom_user): Remove `static'.
(lsa2wchar): New function.
(open_local_policy): Ditto.
(close_local_policy): Ditto.
(get_lsa_srv_inf): Ditto.
(get_logon_server): Ditto.
(get_logon_server_and_user_domain): Ditto.
(get_user_groups): Ditto.
(is_group_member): Ditto.
(get_user_local_groups): Ditto.
(sid_in_token_groups): Ditto.
(get_user_primary_group): Ditto.
(get_group_sidlist): Ditto.
(get_system_priv_list): Ditto.
(get_priv_list): Ditto.
(get_dacl): Ditto.
(create_token): Ditto.
(subauth): Return immediately if SE_TCB_NAME can't be assigned.
Change all return statements in case of error to jumps to `out'
label. Add `out' label to support cleanup.
* security.h: Add extern declarations for `well_known_local_sid',
`well_known_dialup_sid', `well_known_network_sid',
`well_known_batch_sid', `well_known_interactive_sid',
`well_known_service_sid' and `well_known_authenticated_users_sid'.
Add extern declarations for functions `create_token',
`extract_nt_dom_user' and `get_logon_server_and_user_domain'.
(class cygsid): Add method `assign'. Change operator= to call new
`assign' method. Add `debug_print' method.
(class cygsidlist): New class.
(legal_sid_type): Moved from sec_helper.cc to here.
* spawn.cc (spawn_guts) Revert reversion of previous patch.
Call `RevertToSelf' and `ImpersonateLoggedOnUser' instead of `seteuid'
again.
* syscalls.cc (seteuid): Rearranged. Call `create_token' now when
needed. Call `subauth' if `create_token' fails. Try setting token
owner and primary group only if token was not explicitely created
by `create_token'.
* uinfo.cc (internal_getlogin): Try harder to generate correct user
information. Especially don't trust return value of `GetUserName'.
(EnumProcesses9x): Rename from EnumProcessesW95. Change arguments to be more
useful for cygwin.
(winpids::init): Accomodate argument changes.
(enum_init): Ditto.
* pinfo.h (winpids): Make pidlist dynamically extendable by storing it as a
pointer and remembering the size.
* ntdll.h: Add extra definitions needed for EnumProcessesNT. Reformat via
'indent'.
* fhandler_mem.cc: Move ntdll.dll specific definitions and
declarations to ntdll.h.
* sysconf.cc (sysconf): Add support for _SC_NPROCESSORS_CONF,
_SC_NPROCESSORS_ONLN, _SC_PHYS_PAGES and _SC_AVPHYS_PAGES.