__d_internal.
* fhandler_disk_file.cc (struct __DIR_cache): Remove useless "typedef".
(d_dirname): Remove useless "struct".
(d_cachepos): Ditto.
(d_cache): Ditto.
(class __DIR_mounts): New class, implementing mount point tracking
for readdir.
(d_mounts): New macro for easy access to __DIR_mounts structure.
(fhandler_disk_file::opendir): Allocate __DIR_mounts structure and
let __d_internal element of dir point to it.
(fhandler_disk_file::readdir_helper): Add mount points in the current
directory, which don't have a real directory backing them.
Don't generate an inode number for /dev. Add comment, why.
(fhandler_disk_file::readdir): Move filling fname to an earlier point.
Check if current entry is a mount point and evaluate correct inode
number for it.
(fhandler_disk_file::readdir_9x): Ditto.
(fhandler_disk_file::rewinddir): Set all mount points in this directory
to "not found" so that they are listed again after calling rewinddir().
(fhandler_disk_file::closedir): Deallocate __DIR_mounts structure.
* path.cc (mount_info::get_mounts_here): New method to evaluate a list
of mount points in a given parent directory.
* shared_info.h (class mount_info): Declare get_mounts_here.
spawn to determine environment variables which should be converted back to
windows form.
(cygwin_internal): Reflect setup_winenv -> sync_winenv name change.
* include/sys/cygwin.h: Ditto.
* 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.
* dir.cc (__opendir_with_d_ino): New function.
(opendir): Set flag if we should be calculating inodes.
(readdir_worker): Calculate d_ino by calling stat if the user has asked for it.
(seekdir64): Maintain all persistent flag settings.
* fhandler.h (dirent_states): Add dirent_set_d_ino.
* fhandler_disk_file.cc (fhandler_disk_file::opendir): Reflect changes to
dirent structure.
* fhandler_virtual.cc (fhandler_virtual::opendir): Ditto.
* include/sys/dirent.h (struct dirent): Coalesce two similar structures.
Remove all threads of the apparently highly confusing references to inodes.
Add support for calculating a real inode if __USE_EXPENSIVE_CYGWIN_D_INO is
defined.
of in_port_t and in_addr_t to top of file and use throughout. Use
sa_family_t type where appropriate.
(struct in6_addr): Change `unsigned char' to `uint8_t'.
(struct sockaddr_in6): Add sin6_scope_id member. Add comments.
* include/cygwin/socket.h: Include stdint.h. Move definition of
socklen_t to top of file. Define sa_family_t. Define struct
sockaddr_storage as per SUSv3.
* include/sys/un.h: Include cygwin/socket.h. Use sa_family_t type.
* child_info.h (CURR_CHILD_INFO_MAGIC): Reset.
(child_info::dwProcessId): Delete.
(child_info::straced): New variable.
(child_info::handle_fork): New member function.
* dcrt0.cc (in_forkee): New global variable.
(__cygwin_user_data::forkee): Mark as obsolete.
(do_global_ctors): Use in_forkee rather than user_data->forkee.
(get_cygwin_startup_info): Ditto. Deal with new straced field to allow strace
to deal with children of attached processes.
(initial_env): Accommodate changes to strace::hello.
(child_info_fork::handle_fork): Rename from plain old 'handle_fork'. Move
alloc_stack() call elsewhere.
(dll_crt0_0): Fill out more of user_data. Reference handle_fork via fork_info.
Add some debugging output.
(_dll_crt0): Don't wait for sync thread if sync_startup is invalid. Zero
sync_startup here. Call alloc_stack() here, if appropriate.
(dll_crt0_1): Use in_forkee rather than user_data->forkee.
(dll_crt0): Ditto.
* malloc_wrapper.cc (malloc_init): Ditto.
* dll_init.cc (in_forkee): Remove local static version of this variable.
(dll_list::load_after_fork): Don't set in_forkee here.
* external.cc (cygwin_internal): Use strace method rather than accessing field
directly.
* fhandler.cc (fhandler_base::read): Ditto.
* fhandler_tty.cc (fhandler_tty_common::__acquire_output_mutex): Ditto.
* fork.cc (frok::parent): Invoke strace write_childpid to communicate with
potential strace.
(child_copy): Add more detail to debugging output.
* init.cc (calibration_id): New static variable.
(prime_threads): Set sync_startup to invalid handle if we already know about
thread_func_ix. Use static calibration_id to hold calibration thread id.
* munge_threadfunc (munge_threadfunc): Don't try to debug if we don't find
threadfunc_ix.
(dll_entry): Avoid calling munge_threadfunc and _cygtls::remove on non-cygwin
threads invoked during process startup.
* pinfo.cc (set_myself): Always call strace.hello here regardless of DEBUGGING.
* sigproc.cc (child_info::child_info): Remove spurious handling of dwProcessId.
Set straced as appropriate.
* spawn.cc (spawn_guts): Rename ciresrv to ch. Invoke strace write_childpid to
communicate with potential strace.
* strace.cc: Include child_info.h.
(strace::hello): Remove inited test. Use active() method to test if strace has
been activated. Handle case where we are started before
(mypid): New function.
(strace::vsprntf): Try to deal more intelligently with case where progname may
not be filled out. Put pid in parentheses if it is a windows pid rather than a
cygwin pid. myself has been filled out.
(strace::write_childpid): New function for notifying strace about the creation
of children.
(strace::vprntf): Use strace method rather than accessing field directly.
(strace_printf): Ditto.
(strace::wm): Ditto.
* winsup.h (in_forkee): Declare.
* include/sys/strace.h (strace::write_childpid): Declare new function.
(strace::attached): Define new function.
(strace::active): Ditto.
(strace::active_val): Ditto.
(_STRACE_ON): Delete.
(_STRACE_OFF): Ditto.
(define_strace0): Use strace method rather than accessing field directly.
(strace_printf_wrap): Ditto.
(strace_printf_wrap1): Ditto.
*** cygwin utils changes:
* strace.cc (nprocesses): Make static global.
(quiet): New variable.
(strace_active): Ditto.
(add_child): Increment nprocesses here. Don't add a child if it is already
added (windows bug?). Report on child if not quiet.
(get_child): Just return NULL if child not found.
(remove_child): Report on child if not quiet.
(attach_process): Don't complain if given a windows process. Use windows pid
in error.
(handle_output_debug_string): Issue error if trying to manipulate a process
that we don't know about. Handle _STRACE_CHILD_PID - attach to reported child
when we get this.
(proc_child): Move nprocesses to file scope. Report on exceptions.
(longopts): Implement "--quiet".
(opts): Implement "-q".
(main): Manipulate quiet flag.
* utils.sgml (strace): Add words describing '-q'.
* include/cygwin/version.h: Bump api minor number to 147, reflecting
obsolescence of d_ino.
(CYGWIN_VERSION_USER_API_VERSION_COMBINED): New convenience macro.
(CYGWIN_VERSION_CHECK_FOR_NEEDS_D_INO): New convenience macro.
(fhandler_dev_zero::munmap): Ditto.
(fhandler_dev_zero::msync): Ditto.
(fhandler_dev_zero::fixup_mmap_after_fork): Ditto.
* mmap.cc: Implement anonymous mapping using fhandler_dev_zero class.
Implement private anonymous maps using VirtualAlloc/VirtualFree. Fix
or add some more comments.
(fh_paging_file): Change to type fhandler_dev_zero.
(priv): New static inline function to avoid having lots of flag bit
tests in the code. Use throughout were appropriate.
(fixed): Ditto.
(anonymous): Ditto.
(noreserve): Ditto.
(autogrow): Ditto.
(gen_protect): Never generate PAGE_WRITECOPY protection for
private anonymous maps.
(gen_access): Drop FILE_MAP_EXECUTE handling since it's not supported
correctly on 9x.
(VirtualProt9x): Move comment from mmap64 here.
(mmap_record::mmap_record): Gegerate correct device entry for
anonymous maps, though unused right now.
(mmap_record::priv): Call global priv function.
(mmap_record::fixed): Call global fixed function.
(mmap_record::anonymous): Call global anonymous function.
(mmap_record::noreserve): Call global noreserve function.
(mmap_record::autogrow): Call global autogrow function.
(list::anonymous): New method. Use throughout were appropriate.
(mmap_record::compatible_flags): Drop now useless ifdef.
(mmap_record::alloc_page_map): Accomodate private anonymous maps.
(mmap_record::map_pages): Accomodate MAP_NORESERVE mappings.
(mmap_record::unmap_pages): Accomodate private anonymous maps.
(mmap64): Simplify argument check. Don't remove the MAP_PRIVATE flag
for anonymous mappings on 9x anymore since that's now handled
gracefully.
(mprotect): Accomodate MAP_NORESERVE mappings. Fix case when
non-mmap areas are just MEM_RESERVEd.
(fhandler_dev_zero::mmap): Implement anonymous mapping here.
(fhandler_dev_zero::munmap): Ditto.
(fhandler_dev_zero::msyn): Ditto.
(fhandler_dev_zero::fixup_mmap_after_fork): Ditto.
(fixup_mmaps_after_fork): Accomodate private anonymous maps. Enhance
debug output in case VirtualProtect fails.
* include/sys/mman.h: Really define MAP_NORESERVE now.
* 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.
linux.
* include/cygwin/types.h: Include endian.h.
* include/sys/dirent.h: Define DT_* types and conversion macros.
* pinfo.cc (pinfo::init): Remove special handling for PID_ALLPIDS and execed
code, even though it probably still isn't quite right.
* fhandler.h (class fhandler_serial): Declare switch_modem_lines.
* fhandler_serial.cc (fhandler_serial::switch_modem_lines): New
static function to set or clear DTR and/or RTS.
(fhandler_serial::ioctl): Use switch_modem_lines for TIOCMSET
and new TIOCMBIS and TIOCMBIC.
* include/cygwin/version.h: Bump API minor number.
(getdelim): Export.
* include/sys/stdio.h (getline): Replace macro with function prototype.
(getdelim): Likewise.
* include/cygwin/version.h: Bump API minor number.
(__getdelim): Export.
* include/sys/stdio.h (getline): Define as __getline.
(getdelim): Define as __getdelim.
* include/cygwin/version.h: Bump API minor number.
* dir.cc (mkdir): Check path for writability.
(rmdir): Ditto. Remove check for special directories.
* path.cc (path_conv::check): Set PATH_RO for virtual devices. Set error if
read-only and asked for writability.
* path.h (pathconv_arg): Add PC_WRITABLE.
(path_types): Add PATH_RO.
(path_conv::isro): Add (currently unused) check for read-only filesystem.
Return "ENOSHARE" when we know a share doesn't exist.
* include/sys/mount.h: Add MOUNT_RO flag.
* autoload.cc (WNetGetResourceInformationA): Import.
* fhandler_netdrive.cc (fhandler_netdrive::exists): Detect actual existence of
remote system rather than always assuming that it exists.
(try_connect_guard): New static variable.
(syslogd_inited): Ditto.
(syslogd_sock): Ditto.
(try_connect_syslogd): New function to connect and write syslog to
local syslogd.
(vsyslog): Log to stderr if LOG_PERROR flag has been given to openlog.
Try logging to syslogd. Use Event Log resp. log file as fallback.
(closelog): Close socket to syslogd.
* include/sys/syslog.h (_PATH_LOG): Define.
(INTERNAL_NOPRI): Define if SYSLOG_NAMES is defined.
(INTERNAL_MARK): Ditto.
(struct _code): Ditto.
(prioritynames): Ditto.
(facilitynames): Ditto.
* syscalls.cc (utmpxname): Create export alias to utmpname.
* include/utmpx.h: Define ut_name and ut_xtime if not already defined.
(utmpxname): Add prototype.
* include/sys/utmp.h: Only define ut_name if not already defined.
* include/cygwin/version.h: Bump API minor version.
* fork.cc (fork_parent): Copy parent's nice value into child.
* spawn.cc (spawn_guts): Ditto.
* miscfuncs.cc (winprio_to_nice): New function.
(nice_to_winprio): Ditto.
* pinfo.cc (pinfo_init): If parent is not a Cygwin process, set
default nice value according to current Win32 priority class.
* pinfo.h (class _pinfo): Add nice member.
* syscalls.cc (setpriority): New function, only implementing
PRIO_PROCESS for now.
(getpriority): Ditto.
(nice): Just call setpriority.
* wincap.h (wincaps::has_extended_priority_class): New element.
* wincap.cc: Implement above element throughout.
* winsup.h: Add prototypes for winprio_to_nice and nice_to_winprio.
* include/limits.h (NZERO): New define.
* include/cygwin/types.h (id_t): New datatype.
* include/cygwin/version.h: Bump API minor version.
* include/sys/resource.h: Add PRIO_XXX defines and prototypes for
getpriority and setpriority.
* include/sys/cygwin.h: Remove PID_ZOMBIE.
* pinfo.h: Rename EXITCODE_* defines.
(pinfo::set_exit_state): Remove parameter.
* pinfo.cc (set_exit_state): Remove parameter. Reverse sense of test so that
exitcode is checked for having been set rather than not having been set. Set
flag when exitcode has been established. Don't set PID_STATE here.
(pinfo::init): Remove exitcode initialization.
(pinfo::exit): Reflect change in EXITCODE_* naming. Set flag when exitcode has
been established. Reflect change in arguments to set_process_state.
(proc_waiter): Reflect change in arguments to set_process_state. Set
process_state here and only here.
* fhandler_process.cc (fhandler_process::fill_filebuf): Reflect removal of
PID_ZOMBIE define.
(format_process_stat): Ditto.
(format_process_status): Ditto.
* sigproc.cc (pid_exists): Ditto.
(stopped_or_terminated): Ditto. Make sure that only low-order 16 bits of
exitcode are used.
* spawn.cc (spawn_guts): Reflect change in EXITCODE_* naming.
* syscalls.cc: Include utmpx.h. Implement utmpx functions as stubs
to utmp functions.
(copy_ut_to_utx): New static function.
(pututline): Change from void to struct utmp * as on Linux.
(setutxent): New function.
(endutxent): New function.
(getutxent): New function.
(getutxid): New function.
(getutxline): New function.
(pututxline): New function.
* include/utmpx.h: New file.
* include/cygwin/utmp.h: New file.
* include/cygwin/version.h: Bump API minor number.
* include/sys/utmp.h: Include cygwin/utmp.h. Move stuff common with
utmpx functionality there.
(pututline): Declare struct utmp *.