summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <cgf@redhat.com>2003-08-06 03:58:56 +0000
committerChristopher Faylor <cgf@redhat.com>2003-08-06 03:58:56 +0000
commit1934f8f2ce4b110f614dc131de763fe0821fd9f8 (patch)
treecb76b702e6869bbecd26ce3f47f0e1bf47cae868
parente520a18bb98a6616238f54a5c62cf0e1d0b90026 (diff)
downloadgdb-1934f8f2ce4b110f614dc131de763fe0821fd9f8.tar.gz
merge from trunk
-rw-r--r--winsup/cygwin/ChangeLog159
-rw-r--r--winsup/cygwin/Makefile.in28
-rwxr-xr-xwinsup/cygwin/configure104
-rw-r--r--winsup/cygwin/configure.in2
-rw-r--r--winsup/cygwin/crt0.c2
-rw-r--r--winsup/cygwin/cygheap.h47
-rw-r--r--winsup/cygwin/cygwin.din2
-rw-r--r--winsup/cygwin/dcrt0.cc7
-rw-r--r--winsup/cygwin/environ.cc2
-rw-r--r--winsup/cygwin/exceptions.cc12
-rw-r--r--winsup/cygwin/fhandler.cc19
-rw-r--r--winsup/cygwin/fhandler_disk_file.cc9
-rw-r--r--winsup/cygwin/fhandler_proc.cc85
-rw-r--r--winsup/cygwin/fhandler_process.cc5
-rw-r--r--winsup/cygwin/fhandler_registry.cc3
-rw-r--r--winsup/cygwin/fhandler_socket.cc6
-rw-r--r--winsup/cygwin/fhandler_tty.cc51
-rw-r--r--winsup/cygwin/include/cygwin/socket.h4
-rw-r--r--winsup/cygwin/include/cygwin/version.h6
-rw-r--r--winsup/cygwin/ipc.cc22
-rw-r--r--winsup/cygwin/mmap.cc22
-rw-r--r--winsup/cygwin/net.cc16
-rw-r--r--winsup/cygwin/ntdll.h1
-rw-r--r--winsup/cygwin/path.cc101
-rw-r--r--winsup/cygwin/pinfo.cc2
-rw-r--r--winsup/cygwin/security.cc80
-rwxr-xr-xwinsup/cygwin/speclib39
-rw-r--r--winsup/cygwin/syscalls.cc304
-rw-r--r--winsup/cygwin/sysconf.cc4
-rw-r--r--winsup/cygwin/thread.cc100
-rw-r--r--winsup/cygwin/times.cc2
-rw-r--r--winsup/cygwin/uinfo.cc4
-rw-r--r--winsup/cygwin/wincap.cc2
33 files changed, 716 insertions, 536 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 3e664b88aa8..f796140386d 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,9 +1,167 @@
+2003-08-05 Christopher Faylor <cgf@redhat.com>
+
+ * Makefile.in: Rework to accommodate new speclib arguments.
+ * speclib: Rework to extract everything from libcygwin.a rather than
+ building things from existing object files.
+
+2003-08-05 Pavel Tsekov <ptsekov@gmx.net>
+
+ * path.cc (cygdrive_getmntent): Do not skip over drives of type
+ DRIVE_REMOVABLE.
+
+2003-08-05 Christopher Faylor <cgf@redhat.com>
+
+ * fhandler.cc (fhandler_base::lseek): Be more paranoid when
+ constructing offsets from 64 bit value.
+ * syscalls.cc (logout): Avoid temp buffer memcpy since new scheme does
+ not require it.
+ (utmp_data): Rework as a macro which returns a pointer into a buffer.
+ (getutent): Use new buffer allocation mechanism to grab a utmp buffer.
+ (getutid): Ditto.
+ (pututline): Ditto.
+
+2003-08-05 Pavel Tsekov <ptsekov@gmx.net>
+
+ * fhandler_disk_file.cc (fhandler_cygdrive::readdir): Do not change
+ 'errno' if end of directory condition is encountered as per SUSv2.
+ * fhandler_proc.cc (fhandler_proc::readdir): Ditto.
+ * fhandler_process (fhandler_process::readdir): Ditto.
+ * fhandler_registry (fhandler_registry::readdir): Ditto.
+
+2003-07-30 Christopher Faylor <cgf@redhat.com>
+
+ * dcrt0.cc (_dll_crt0): Move strace.microseconds initialization to
+ after pthread initialization.
+ (dll_crt0_1): i.e., here.
+
+2003-07-28 Christopher Faylor <cgf@redhat.com>
+
+ * fhandler_base.cc (fhandler_base::readv): Rework to properly return
+ number of bytes from read.
+
+2003-07-28 Christopher Faylor <cgf@redhat.com>
+
+ * include/cygwin/version.h: Bump DLL minor number to 2.
+
+2003-07-26 Christopher Faylor <cgf@redhat.com>
+
+ * exceptions.cc (ctrl_c_handler): Send SIGHUP when events occur only if
+ there is a tty associated with the process. Send SIGHUP on
+ CTRL_LOGOFF_EVENT.
+
+ * fhandler_tty.cc (fhandler_tty_slave::open): Adjust console open
+ handle counter regardless of whether this is a pty or tty.
+ (fhandler_tty_slave::open): Ditto.
+ (fhandler_tty_slave::dup): Ditto.
+ (fhandler_tty_common::set_close_on_exec): Ditto.
+ (fhandler_tty_master::init_console): Decrement console open handle
+ counter after init since it will now be handled by all tty open.
+ * syscalls.cc (setsid): Rework debugging output slightly.
+
+2003-07-25 Christopher Faylor <cgf@redhat.com>
+
+ * configure.in: Use 'install-sh -c'.
+ * configure: Regenerate.
+
+2003-07-25 Christopher Faylor <cgf@redhat.com>
+
+ * configure.in: Always use install-sh.
+ * configure: Regenerate.
+
+2003-07-25 Christopher Faylor <cgf@redhat.com>
+
+ * include/cygwin/socket.h: Conditionalize [AP]F_INET6 define.
+
+2003-07-25 Christopher Faylor <cgf@redhat.com>
+
+ * Makefile.in (OBSOLETE_FUNCTION): Add fdopen.
+
+2003-07-25 Christopher Faylor <cgf@redhat.com>
+
+ * cygwin.din: Export _fdopen64
+ * Makefile.in (NEW_FUNCTIONS): Add _fdopen64 -> fdopen translation.
+ * include/cygwin/version.h: Bump api minor number.
+
+ * ntdll.h: Remove (now) duplicate FILE_SYNCHRONOUS_IO_NONALERT
+ definition.
+
+2003-07-24 Christopher Faylor <cgf@redhat.com>
+
+ * environ.cc (check_case_init): Use strncasematch.
+
+ * cygwin.din: Export __mempcpy.
+ * cygwin/version.h: Bump api minor number.
+
+2003-07-21 Pavel Tsekov <ptsekov@gmx.net>
+
+ * mmap.cc: Use proper format specifiers for _off64_t and size_t in
+ format strings passed to syscall_printf () and debug_printf ()
+ throughout.
+
+2003-07-18 Pierre Humblet <pierre.humblet@ieee.org>
+
+ * security.cc (verify_token): Fix white space and style.
+ Use type bool instead of BOOL and char. Use alloca
+ instead of malloc and free for my_grps.
+
+2003-07-17 Corinna Vinschen <corinna@vinschen.de>
+
+ * sysconf.cc (sysconf): Fix OPEN_MAX patch. Return page size on
+ _SC_PAGESIZE again.
+
+2003-07-14 Corinna Vinschen <corinna@vinschen.de>
+
+ * cygheap.h (class cygheap_user): Use INVALID_HANDLE_VALUE as invalid
+ value for tokens.
+ * syscalls.cc (seteuid32): Ditto. Set new_token to process token if
+ process token is suitable.
+ * uinfo.cc (uinfo_init): Initialize tokens in cygheap user info
+ to INVALID_HANDLE_VALUE.
+
+2003-07-14 Pierre Humblet <pierre.humblet@ieee.org>
+
+ * cygheap.h (enum impersonation): Delete.
+ (cygheap_user::impersonation_state): Delete.
+ (cygheap_user::current_token): New.
+ (cygheap_user::issetuid): Modify to use current_token.
+ (cygheap_user::token): Ditto.
+ (cygheap_user::deimpersonate): Ditto.
+ (cygheap_user::reimpersonate): Ditto.
+ (cygheap_user::has_impersonation_tokens): Ditto.
+ (cygheap_user::close_impersonation_tokens): Ditto.
+ * security.cc (cygwin_set_impersonation_token): Always set the token.
+ (verify_token): Change type of gsid to cygpsid.
+ (get_file_attribute): Use the effective ids.
+ * syscalls.cc (seteuid32): Modify to use cygheap_user::current_token.
+ * uinfo.cc (uinfo_init) Do not set cygheap->user.impersonation_state.
+
+2003-07-12 Christopher Faylor <cgf@redhat.com>
+
+ * pinfo.cc (_pinfo::commune_send): Fix bounds test so that poll of
+ communicating pid actually stops eventually.
+
+2003-07-10 Christopher Faylor <cgf@redhat.com>
+
+ * path.cc (get_device_number): Remove special com? consideration.
+ (special_chars): Make static.
+ (special_introducers): New.
+ (special_char): Allow specified valid_chars args.
+ (fnunmunge): Handle aux-like filenames correctly.
+ (special_name): Add con, conin$, conout$.
+ (mount_item::fnmunge): Use __small_sprintf return value to calculate
+ increments.
+
2003-07-09 Christopher Faylor <cgf@redhat.com>
* include/cygwin/version.h: Bump DLL minor number to 1.
2003-07-09 Christopher Faylor <cgf@redhat.com>
+ * fhandler_proc.cc (format_proc_stat): Use correctly sized constants
+ for filling in zeros on 98.
+
+2003-07-09 Christopher Faylor <cgf@redhat.com>
+
* fhandler_proc.cc (fhandler_proc::fill_filebuf): Allocate more space
for stat buffer.
(format_proc_stat): Reorganize to accumulate and report on all cpus.
@@ -2804,4 +2962,3 @@
* passwd.cc (getpwuid_r32): Add uid/gid fields to size check
calculation.
-
diff --git a/winsup/cygwin/Makefile.in b/winsup/cygwin/Makefile.in
index 4346027546f..11c1d40f222 100644
--- a/winsup/cygwin/Makefile.in
+++ b/winsup/cygwin/Makefile.in
@@ -38,8 +38,9 @@ datadir:=@datadir@
infodir:=@infodir@
includedir:=@includedir@
-INSTALL:=@INSTALL@
-INSTALL_PROGRAM:=@INSTALL_PROGRAM@
+override INSTALL:=@INSTALL@
+override INSTALL_PROGRAM:=@INSTALL_PROGRAM@
+override INSTALL_DATA:=@INSTALL_DATA@
#
# --enable options from configure
@@ -97,8 +98,6 @@ LDSCRIPT:=cygwin.sc
#
include $(srcdir)/../Makefile.common
-INSTALL_DATA:=$(SHELL) $(updir1)/install-sh -c
-
@SET_MAKE@
# Setup the testing framework, if you have one
@@ -118,7 +117,6 @@ RUNTESTFLAGS =
DLL_NAME:=cygwin1.dll
TEST_DLL_NAME:=cygwin0.dll
-LIB_NAME:=libcygwin.a
TEST_LIB_NAME:=libcygwin0.a
DEF_FILE:=cygwin.def
DLL_ENTRY:=@DLL_ENTRY@
@@ -171,7 +169,7 @@ GMON_OFILES:=gmon.o mcount.o profil.o
OBSOLETE_FUNCTIONS:=regcomp regerror regexec regfree regsub \
open acl aclcheck aclfrommode aclfrompbits \
aclfromtext aclsort acltomode acltopbits \
- acltotext chown facl fchown fgetpos fopen \
+ acltotext chown facl fchown fdopen fgetpos fopen \
freopen fseeko fsetpos fstat ftello ftruncate \
getegid geteuid getgid getgrent getgrgid getgrnam \
getgroups getpwuid getpwuid_r getuid initgroups \
@@ -196,6 +194,7 @@ NEW_FUNCTIONS:=regcomp posix_regcomp \
chown _chown32 \
facl _facl32 \
fchown _fchown32 \
+ fdopen _fdopen64 \
fgetpos _fgetpos64 \
fopen _fopen64 \
freopen _freopen64 \
@@ -235,10 +234,11 @@ NEW_FUNCTIONS:=regcomp posix_regcomp \
API_VER:=$(srcdir)/include/cygwin/version.h
PWD:=${shell pwd}
-SUBLIBS:=libpthread.a $(PWD)/libm.a libc.a
+LIB_NAME:=$(PWD)/libcygwin.a
+SUBLIBS:=$(PWD)/libpthread.a $(PWD)/libm.a $(PWD)/libc.a
EXTRALIBS:=libautomode.a libbinmode.a libtextmode.a
INSTOBJS:=automode.o binmode.o textmode.o
-TARGET_LIBS:=$(LIB_NAME) $(SUBLIBS) $(CYGWIN_START) $(GMON_START) $(LIBGMON_A) $(SUBLIBS) $(INSTOBJS) $(EXTRALIBS)
+TARGET_LIBS:=$(LIB_NAME) $(CYGWIN_START) $(GMON_START) $(LIBGMON_A) $(SUBLIBS) $(INSTOBJS) $(EXTRALIBS)
.PHONY: all force dll_ofiles install all_target install_target all_host install_host \
install install-libs install-headers -lgcc
@@ -378,14 +378,14 @@ dcrt0.o sigproc.o: child_info_magic.h
shared.o: shared_info_magic.h
-libpthread.a: speclib cygwin.def pthread.o thread.o
- /bin/sh ${word 1, $^} $@ "${NM}" "${DLLTOOL}" "${AS}" ${wordlist 2, 99, $^}
+$(PWD)/libpthread.a: speclib $(LIB_NAME) pthread.o thread.o
+ /bin/sh ${word 1, $^} $@ "${NM}" "$(AR)" ${wordlist 2, 99, $^}
-$(PWD)/libm.a: speclib cygwin.def $(LIBM)
- /bin/sh ${word 1, $^} $@ "${NM}" "${DLLTOOL}" "${AS}" ${wordlist 2, 99, $^}
+$(PWD)/libm.a: speclib $(LIB_NAME) $(LIBM)
+ /bin/sh ${word 1, $^} $@ "${NM}" "$(AR)" ${wordlist 2, 99, $^}
-$(PWD)/libc.a: speclib cygwin.def $(PWD)/libm.a libpthread.a
- /bin/sh ${word 1, $^} -v $@ "${NM}" "${DLLTOOL}" "${AS}" ${wordlist 2, 99, $^}
+$(PWD)/libc.a: speclib $(LIB_NAME) $(PWD)/libm.a libpthread.a
+ /bin/sh ${word 1, $^} -v $@ "${NM}" "$(AR)" ${wordlist 2, 99, $^}
lib%.a: %.o
$(AR) cru $@ $?
diff --git a/winsup/cygwin/configure b/winsup/cygwin/configure
index af5f3cab0fe..e2f22306cd3 100755
--- a/winsup/cygwin/configure
+++ b/winsup/cygwin/configure
@@ -533,6 +533,8 @@ fi
+INSTALL="/bin/sh "`cd $srcdir/../..; echo $(pwd)/install-sh -c`
+
ac_aux_dir=
for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
if test -f $ac_dir/install-sh; then
@@ -564,7 +566,7 @@ ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
# ./install, which can be erroneously created by make from ./install.sh.
echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
-echo "configure:568: checking for a BSD compatible install" >&5
+echo "configure:570: checking for a BSD compatible install" >&5
if test -z "$INSTALL"; then
if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -650,7 +652,7 @@ else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
fi
echo $ac_n "checking host system type""... $ac_c" 1>&6
-echo "configure:654: checking host system type" >&5
+echo "configure:656: checking host system type" >&5
host_alias=$host
case "$host_alias" in
@@ -671,7 +673,7 @@ host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
echo "$ac_t""$host" 1>&6
echo $ac_n "checking target system type""... $ac_c" 1>&6
-echo "configure:675: checking target system type" >&5
+echo "configure:677: checking target system type" >&5
target_alias=$target
case "$target_alias" in
@@ -689,7 +691,7 @@ target_os=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
echo "$ac_t""$target" 1>&6
echo $ac_n "checking build system type""... $ac_c" 1>&6
-echo "configure:693: checking build system type" >&5
+echo "configure:695: checking build system type" >&5
build_alias=$build
case "$build_alias" in
@@ -721,7 +723,7 @@ fi
# Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
set dummy ${ac_tool_prefix}gcc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:725: checking for $ac_word" >&5
+echo "configure:727: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -753,7 +755,7 @@ if test -n "$ac_tool_prefix"; then
# Extract the first word of "gcc", so it can be a program name with args.
set dummy gcc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:757: checking for $ac_word" >&5
+echo "configure:759: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -789,7 +791,7 @@ if test -z "$CC"; then
# Extract the first word of "cc", so it can be a program name with args.
set dummy cc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:793: checking for $ac_word" >&5
+echo "configure:795: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -838,7 +840,7 @@ fi
fi
echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
-echo "configure:842: checking whether we are using GNU C" >&5
+echo "configure:844: checking whether we are using GNU C" >&5
if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -847,7 +849,7 @@ else
yes;
#endif
EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:851: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:853: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
ac_cv_prog_gcc=yes
else
ac_cv_prog_gcc=no
@@ -862,7 +864,7 @@ if test $ac_cv_prog_gcc = yes; then
ac_save_CFLAGS="$CFLAGS"
CFLAGS=
echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-echo "configure:866: checking whether ${CC-cc} accepts -g" >&5
+echo "configure:868: checking whether ${CC-cc} accepts -g" >&5
if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -892,7 +894,7 @@ fi
# Extract the first word of "${ac_tool_prefix}g++", so it can be a program name with args.
set dummy ${ac_tool_prefix}g++; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:896: checking for $ac_word" >&5
+echo "configure:898: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CXX'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -924,7 +926,7 @@ if test -n "$ac_tool_prefix"; then
# Extract the first word of "g++", so it can be a program name with args.
set dummy g++; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:928: checking for $ac_word" >&5
+echo "configure:930: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CXX'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -960,7 +962,7 @@ if test -z "$CXX"; then
# Extract the first word of "c++", so it can be a program name with args.
set dummy c++; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:964: checking for $ac_word" >&5
+echo "configure:966: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CXX'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1009,7 +1011,7 @@ esac
# Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
set dummy ${ac_tool_prefix}ar; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1013: checking for $ac_word" >&5
+echo "configure:1015: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1041,7 +1043,7 @@ if test -n "$ac_tool_prefix"; then
# Extract the first word of "ar", so it can be a program name with args.
set dummy ar; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1045: checking for $ac_word" >&5
+echo "configure:1047: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1076,7 +1078,7 @@ fi
# Extract the first word of "${ac_tool_prefix}as", so it can be a program name with args.
set dummy ${ac_tool_prefix}as; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1080: checking for $ac_word" >&5
+echo "configure:1082: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_AS'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1108,7 +1110,7 @@ if test -n "$ac_tool_prefix"; then
# Extract the first word of "as", so it can be a program name with args.
set dummy as; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1112: checking for $ac_word" >&5
+echo "configure:1114: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_AS'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1143,7 +1145,7 @@ fi
# Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
set dummy ${ac_tool_prefix}ranlib; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1147: checking for $ac_word" >&5
+echo "configure:1149: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1175,7 +1177,7 @@ if test -n "$ac_tool_prefix"; then
# Extract the first word of "ranlib", so it can be a program name with args.
set dummy ranlib; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1179: checking for $ac_word" >&5
+echo "configure:1181: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1210,7 +1212,7 @@ fi
# Extract the first word of "${ac_tool_prefix}ld", so it can be a program name with args.
set dummy ${ac_tool_prefix}ld; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1214: checking for $ac_word" >&5
+echo "configure:1216: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_LD'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1242,7 +1244,7 @@ if test -n "$ac_tool_prefix"; then
# Extract the first word of "ld", so it can be a program name with args.
set dummy ld; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1246: checking for $ac_word" >&5
+echo "configure:1248: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_LD'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1277,7 +1279,7 @@ fi
# Extract the first word of "${ac_tool_prefix}nm", so it can be a program name with args.
set dummy ${ac_tool_prefix}nm; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1281: checking for $ac_word" >&5
+echo "configure:1283: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_NM'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1309,7 +1311,7 @@ if test -n "$ac_tool_prefix"; then
# Extract the first word of "nm", so it can be a program name with args.
set dummy nm; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1313: checking for $ac_word" >&5
+echo "configure:1315: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_NM'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1344,7 +1346,7 @@ fi
# Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args.
set dummy ${ac_tool_prefix}dlltool; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1348: checking for $ac_word" >&5
+echo "configure:1350: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_DLLTOOL'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1376,7 +1378,7 @@ if test -n "$ac_tool_prefix"; then
# Extract the first word of "dlltool", so it can be a program name with args.
set dummy dlltool; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1380: checking for $ac_word" >&5
+echo "configure:1382: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_DLLTOOL'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1411,7 +1413,7 @@ fi
# Extract the first word of "${ac_tool_prefix}windres", so it can be a program name with args.
set dummy ${ac_tool_prefix}windres; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1415: checking for $ac_word" >&5
+echo "configure:1417: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_WINDRES'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1443,7 +1445,7 @@ if test -n "$ac_tool_prefix"; then
# Extract the first word of "windres", so it can be a program name with args.
set dummy windres; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1447: checking for $ac_word" >&5
+echo "configure:1449: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_WINDRES'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1477,7 +1479,7 @@ fi
echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:1481: checking how to run the C preprocessor" >&5
+echo "configure:1483: checking how to run the C preprocessor" >&5
# On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then
CPP=
@@ -1492,13 +1494,13 @@ else
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp.
cat > conftest.$ac_ext <<EOF
-#line 1496 "configure"
+#line 1498 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1502: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1504: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
@@ -1509,13 +1511,13 @@ else
rm -rf conftest*
CPP="${CC-cc} -E -traditional-cpp"
cat > conftest.$ac_ext <<EOF
-#line 1513 "configure"
+#line 1515 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1519: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1521: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
@@ -1526,13 +1528,13 @@ else
rm -rf conftest*
CPP="${CC-cc} -nologo -E"
cat > conftest.$ac_ext <<EOF
-#line 1530 "configure"
+#line 1532 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1536: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1538: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
@@ -1559,19 +1561,19 @@ echo "$ac_t""$CPP" 1>&6
# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
# for constant arguments. Useless!
echo $ac_n "checking for working alloca.h""... $ac_c" 1>&6
-echo "configure:1563: checking for working alloca.h" >&5
+echo "configure:1565: checking for working alloca.h" >&5
if eval "test \"`echo '$''{'ac_cv_header_alloca_h'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1568 "configure"
+#line 1570 "configure"
#include "confdefs.h"
#include <alloca.h>
int main() {
char *p = alloca(2 * sizeof(int));
; return 0; }
EOF
-if { (eval echo configure:1575: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1577: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
ac_cv_header_alloca_h=yes
else
@@ -1592,12 +1594,12 @@ EOF
fi
echo $ac_n "checking for alloca""... $ac_c" 1>&6
-echo "configure:1596: checking for alloca" >&5
+echo "configure:1598: checking for alloca" >&5
if eval "test \"`echo '$''{'ac_cv_func_alloca_works'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1601 "configure"
+#line 1603 "configure"
#include "confdefs.h"
#ifdef __GNUC__
@@ -1625,7 +1627,7 @@ int main() {
char *p = (char *) alloca(1);
; return 0; }
EOF
-if { (eval echo configure:1629: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1631: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
ac_cv_func_alloca_works=yes
else
@@ -1657,12 +1659,12 @@ EOF
echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6
-echo "configure:1661: checking whether alloca needs Cray hooks" >&5
+echo "configure:1663: checking whether alloca needs Cray hooks" >&5
if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1666 "configure"
+#line 1668 "configure"
#include "confdefs.h"
#if defined(CRAY) && ! defined(CRAY2)
webecray
@@ -1687,12 +1689,12 @@ echo "$ac_t""$ac_cv_os_cray" 1>&6
if test $ac_cv_os_cray = yes; then
for ac_func in _getb67 GETB67 getb67; do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1691: checking for $ac_func" >&5
+echo "configure:1693: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1696 "configure"
+#line 1698 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -1715,7 +1717,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:1719: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1721: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -1742,7 +1744,7 @@ done
fi
echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6
-echo "configure:1746: checking stack direction for C alloca" >&5
+echo "configure:1748: checking stack direction for C alloca" >&5
if eval "test \"`echo '$''{'ac_cv_c_stack_direction'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1750,7 +1752,7 @@ else
ac_cv_c_stack_direction=0
else
cat > conftest.$ac_ext <<EOF
-#line 1754 "configure"
+#line 1756 "configure"
#include "confdefs.h"
find_stack_direction ()
{
@@ -1769,7 +1771,7 @@ main ()
exit (find_stack_direction() < 0);
}
EOF
-if { (eval echo configure:1773: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1775: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_c_stack_direction=1
else
@@ -1791,7 +1793,7 @@ EOF
fi
echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
-echo "configure:1795: checking whether ${MAKE-make} sets \${MAKE}" >&5
+echo "configure:1797: checking whether ${MAKE-make} sets \${MAKE}" >&5
set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -1828,7 +1830,7 @@ ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftes
cross_compiling=$ac_cv_prog_cxx_cross
cat > conftest.$ac_ext <<EOF
-#line 1832 "configure"
+#line 1834 "configure"
#include "confdefs.h"
#include <string.h>
@@ -1841,7 +1843,7 @@ int main() {
; return 0; }
EOF
-if { (eval echo configure:1845: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1847: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
use_builtin_memset=yes
else
diff --git a/winsup/cygwin/configure.in b/winsup/cygwin/configure.in
index c192221ab99..2c26d4d3b33 100644
--- a/winsup/cygwin/configure.in
+++ b/winsup/cygwin/configure.in
@@ -13,6 +13,8 @@ AC_PREREQ(2.12)dnl
AC_INIT(init.cc)
AC_CONFIG_HEADER(config.h)
+INSTALL="/bin/sh "`cd $srcdir/../..; echo $(pwd)/install-sh -c`
+
AC_PROG_INSTALL
dnl FIXME: We temporarily define our own version of AC_PROG_CC. This is
diff --git a/winsup/cygwin/crt0.c b/winsup/cygwin/crt0.c
index 2837a54d13f..52ba7bd349e 100644
--- a/winsup/cygwin/crt0.c
+++ b/winsup/cygwin/crt0.c
@@ -30,6 +30,8 @@ int __cygwin_crt0_bp = 0;
extern int main (int argc, char **argv);
+void cygwin_crt0 (int (*main) (int, char **));
+
void
mainCRTStartup ()
{
diff --git a/winsup/cygwin/cygheap.h b/winsup/cygwin/cygheap.h
index 215d202b51b..6ff20d569fa 100644
--- a/winsup/cygwin/cygheap.h
+++ b/winsup/cygwin/cygheap.h
@@ -92,14 +92,6 @@ enum homebodies
CH_HOME
};
-enum impersonation
-{
- IMP_BAD = -1,
- IMP_NONE = 0,
- IMP_EXTERNAL,
- IMP_INTERNAL
-};
-
class cygheap_user
{
/* Extendend user information.
@@ -125,7 +117,7 @@ public:
to `set_impersonation_token()'. */
HANDLE external_token;
HANDLE internal_token;
- enum impersonation impersonation_state;
+ HANDLE current_token;
/* CGF 2002-06-27. I removed the initializaton from this constructor
since this class is always allocated statically. That means that everything
@@ -170,41 +162,40 @@ public:
PSID sid () const { return psid; }
PSID orig_sid () const { return orig_psid; }
const char *ontherange (homebodies what, struct passwd * = NULL);
- bool issetuid () const
- {
- return impersonation_state > IMP_NONE;
- }
- HANDLE token ()
- {
- if (impersonation_state == IMP_EXTERNAL)
- return external_token;
- if (impersonation_state == IMP_INTERNAL)
- return internal_token;
- return INVALID_HANDLE_VALUE;
- }
+ bool issetuid () const { return current_token != INVALID_HANDLE_VALUE; }
+ HANDLE token () { return current_token; }
void deimpersonate ()
{
- if (impersonation_state > IMP_NONE)
+ if (issetuid ())
RevertToSelf ();
}
void reimpersonate ()
{
- if (impersonation_state > IMP_NONE
+ if (issetuid ()
&& !ImpersonateLoggedOnUser (token ()))
system_printf ("ImpersonateLoggedOnUser: %E");
}
- bool has_impersonation_tokens () { return external_token || internal_token; }
+ bool has_impersonation_tokens ()
+ { return external_token != INVALID_HANDLE_VALUE
+ || internal_token != INVALID_HANDLE_VALUE
+ || current_token != INVALID_HANDLE_VALUE; }
void close_impersonation_tokens ()
{
- if (external_token)
+ if (current_token != INVALID_HANDLE_VALUE)
+ {
+ if( current_token != external_token && current_token != internal_token)
+ CloseHandle (current_token);
+ current_token = INVALID_HANDLE_VALUE;
+ }
+ if (external_token != INVALID_HANDLE_VALUE)
{
CloseHandle (external_token);
- external_token = 0;
+ external_token = INVALID_HANDLE_VALUE;
}
- if (internal_token)
+ if (internal_token != INVALID_HANDLE_VALUE)
{
CloseHandle (internal_token);
- internal_token = 0;
+ internal_token = INVALID_HANDLE_VALUE;
}
}
const char *cygheap_user::test_uid (char *&, const char *, size_t)
diff --git a/winsup/cygwin/cygwin.din b/winsup/cygwin/cygwin.din
index 107dc00f3e2..ab8786d7955 100644
--- a/winsup/cygwin/cygwin.din
+++ b/winsup/cygwin/cygwin.din
@@ -425,6 +425,7 @@ fdim
fdimf
fdopen
_fdopen = fdopen
+_fdopen64 = fdopen64
feof
_feof = feof
ferror
@@ -820,6 +821,7 @@ _memcpy = memcpy
memmove
_memmove = memmove
mempcpy
+__mempcpy = mempcpy
memset
_memset = memset
mkdir
diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc
index 04449b2f6ff..afaeff08805 100644
--- a/winsup/cygwin/dcrt0.cc
+++ b/winsup/cygwin/dcrt0.cc
@@ -634,6 +634,10 @@ dll_crt0_1 ()
if (!user_data->forkee)
pthread::init_mainthread ();
+#ifdef DEBUGGING
+ strace.microseconds ();
+#endif
+
/* Initialize debug muto, if DLL is built with --enable-debugging.
Need to do this before any helper threads start. */
debug_init ();
@@ -848,9 +852,6 @@ _dll_crt0 ()
initial_env ();
char zeros[sizeof (fork_info->zero)] = {0};
static NO_COPY STARTUPINFO si;
-#ifdef DEBUGGING
- strace.microseconds ();
-#endif
main_environ = user_data->envptr;
*main_environ = NULL;
diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc
index 6c75f987dac..de50770be56 100644
--- a/winsup/cygwin/environ.cc
+++ b/winsup/cygwin/environ.cc
@@ -405,7 +405,7 @@ check_case_init (const char *buf)
if (!buf || !*buf)
return;
- if (strncmp (buf, "relax", 5)== 0)
+ if (strncasematch (buf, "relax", 5))
{
pcheck_case = PCHECK_RELAXED;
debug_printf ("File case checking set to RELAXED");
diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc
index 3c8bf39c99f..e7c3041853c 100644
--- a/winsup/cygwin/exceptions.cc
+++ b/winsup/cygwin/exceptions.cc
@@ -923,25 +923,29 @@ setup_handler (int sig, void *handler, struct sigaction& siga)
static BOOL WINAPI
ctrl_c_handler (DWORD type)
{
- if (type == CTRL_LOGOFF_EVENT)
- return TRUE;
+ static bool saw_close;
/* Return FALSE to prevent an "End task" dialog box from appearing
for each Cygwin process window that's open when the computer
is shut down or console window is closed. */
+
if (type == CTRL_SHUTDOWN_EVENT)
{
#if 0
/* Don't send a signal. Only NT service applications and their child
- processes will receive this event and the services typically already
+ processes will receive this event and the services typically already
handle the shutdown action when getting the SERVICE_CONTROL_SHUTDOWN
control message. */
sig_send (NULL, SIGTERM);
#endif
return FALSE;
}
- if (type == CTRL_CLOSE_EVENT)
+
+ if (myself->ctty != -1
+ && (type == CTRL_CLOSE_EVENT || (!saw_close && type == CTRL_LOGOFF_EVENT)))
{
+ if (type == CTRL_CLOSE_EVENT)
+ saw_close = true;
sig_send (NULL, SIGHUP);
return FALSE;
}
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index 253fca6fc47..f9b822522b9 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -723,28 +723,29 @@ fhandler_base::readv (const struct iovec *const iov, const int iovcnt,
assert (iov);
assert (iovcnt >= 1);
+ size_t len = tot;
if (iovcnt == 1)
{
- size_t len = iov->iov_len;
+ len = iov->iov_len;
read (iov->iov_base, len);
return len;
}
if (tot == -1) // i.e. if not pre-calculated by the caller.
{
- tot = 0;
+ len = 0;
const struct iovec *iovptr = iov + iovcnt;
do
{
iovptr -= 1;
- tot += iovptr->iov_len;
+ len += iovptr->iov_len;
}
while (iovptr != iov);
}
assert (tot >= 0);
- if (tot == 0)
+ if (!len)
return 0;
char *buf = (char *) alloca (tot);
@@ -755,10 +756,10 @@ fhandler_base::readv (const struct iovec *const iov, const int iovcnt,
return -1;
}
- read (buf, (size_t) tot);
+ read (buf, len);
+ ssize_t nbytes = (ssize_t) len;
const struct iovec *iovptr = iov;
- int nbytes = tot;
while (nbytes > 0)
{
@@ -769,7 +770,7 @@ fhandler_base::readv (const struct iovec *const iov, const int iovcnt,
nbytes -= frag;
}
- return tot;
+ return len;
}
ssize_t
@@ -855,13 +856,13 @@ fhandler_base::lseek (_off64_t offset, int whence)
DWORD win32_whence = whence == SEEK_SET ? FILE_BEGIN
: (whence == SEEK_CUR ? FILE_CURRENT : FILE_END);
- LONG off_low = offset & 0xffffffff;
+ LONG off_low = ((__uint64_t) offset) & 0xffffffffLL;
LONG *poff_high, off_high;
if (!wincap.has_64bit_file_access ())
poff_high = NULL;
else
{
- off_high = offset >> 32;
+ off_high = ((__uint64_t) offset) >> 32LL;
poff_high = &off_high;
}
diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc
index 49aae6c55f2..5495e889a7b 100644
--- a/winsup/cygwin/fhandler_disk_file.cc
+++ b/winsup/cygwin/fhandler_disk_file.cc
@@ -128,7 +128,7 @@ fhandler_base::fstat_by_name (struct __stat64 *buf)
FILETIME ft = {};
res = fstat_helper (buf, ft, ft, ft, 0, 0);
}
- else
+ else
{
debug_printf ("FindFirstFile failed for '%s', %E", (char *) pc);
__seterrno ();
@@ -232,7 +232,7 @@ fhandler_base::fstat_helper (struct __stat64 *buf,
/* Although the documentation indicates otherwise, it seems like
"inodes" on these devices are persistent, at least across reboots. */
buf->st_ino = (((__ino64_t) nFileIndexHigh) << 32)
- | (__ino64_t) nFileIndexLow;
+ | (__ino64_t) nFileIndexLow;
break;
default:
/* Either the nFileIndex* fields are unreliable or unavailable. Use the
@@ -786,10 +786,7 @@ fhandler_cygdrive::readdir (DIR *dir)
if (!iscygdrive_root ())
return fhandler_disk_file::readdir (dir);
if (!pdrive || !*pdrive)
- {
- set_errno (ENMFILE);
- return NULL;
- }
+ return NULL;
else if (dir->__d_position > 1
&& GetFileAttributes (pdrive) == INVALID_FILE_ATTRIBUTES)
{
diff --git a/winsup/cygwin/fhandler_proc.cc b/winsup/cygwin/fhandler_proc.cc
index 668731748f6..42bd8e16ebd 100644
--- a/winsup/cygwin/fhandler_proc.cc
+++ b/winsup/cygwin/fhandler_proc.cc
@@ -201,7 +201,6 @@ fhandler_proc::readdir (DIR * dir)
dir->__d_position++;
return dir->__d_dirent;
}
- set_errno (ENMFILE);
return NULL;
}
@@ -457,7 +456,7 @@ format_proc_stat (char *destbuf, size_t maxsize)
char *eobuf = destbuf;
if (!wincap.is_winnt ())
- eobuf += __small_sprintf (destbuf, "cpu %U %U %U %U\n", 0, 0, 0, 0);
+ eobuf += __small_sprintf (destbuf, "cpu %U %U %U %U\n", 0ULL, 0ULL, 0ULL, 0ULL);
else
{
NTSTATUS ret;
@@ -634,30 +633,30 @@ format_proc_cpuinfo (char *destbuf, size_t maxsize)
bufptr += __small_sprintf (bufptr, "vendor_id : %s\n", szBuffer);
read_value ("Identifier", REG_SZ);
bufptr += __small_sprintf (bufptr, "identifier : %s\n", szBuffer);
- if (wincap.is_winnt ())
- {
+ if (wincap.is_winnt ())
+ {
read_value ("~Mhz", REG_DWORD);
bufptr += __small_sprintf (bufptr, "cpu MHz : %u\n", *(DWORD *) szBuffer);
print ("flags :");
if (IsProcessorFeaturePresent (PF_3DNOW_INSTRUCTIONS_AVAILABLE))
- print (" 3dnow");
+ print (" 3dnow");
if (IsProcessorFeaturePresent (PF_COMPARE_EXCHANGE_DOUBLE))
- print (" cx8");
+ print (" cx8");
if (!IsProcessorFeaturePresent (PF_FLOATING_POINT_EMULATED))
- print (" fpu");
+ print (" fpu");
if (IsProcessorFeaturePresent (PF_MMX_INSTRUCTIONS_AVAILABLE))
- print (" mmx");
+ print (" mmx");
if (IsProcessorFeaturePresent (PF_PAE_ENABLED))
- print (" pae");
+ print (" pae");
if (IsProcessorFeaturePresent (PF_RDTSC_INSTRUCTION_AVAILABLE))
- print (" tsc");
+ print (" tsc");
if (IsProcessorFeaturePresent (PF_XMMI_INSTRUCTIONS_AVAILABLE))
- print (" sse");
+ print (" sse");
if (IsProcessorFeaturePresent (PF_XMMI64_INSTRUCTIONS_AVAILABLE))
- print (" sse2");
+ print (" sse2");
}
- }
+ }
else
{
bufptr += __small_sprintf (bufptr, "processor : %d\n", cpu_number);
@@ -666,12 +665,12 @@ format_proc_cpuinfo (char *destbuf, size_t maxsize)
maxf &= 0xffff;
vendor_id[3] = 0;
bufptr += __small_sprintf (bufptr, "vendor_id : %s\n", (char *)vendor_id);
- unsigned cpu_mhz = 0;
- if (wincap.is_winnt ())
- {
+ unsigned cpu_mhz = 0;
+ if (wincap.is_winnt ())
+ {
read_value ("~Mhz", REG_DWORD);
cpu_mhz = *(DWORD *)szBuffer;
- }
+ }
if (maxf >= 1)
{
unsigned features2, features1, extra_info, cpuid_sig;
@@ -717,10 +716,10 @@ format_proc_cpuinfo (char *destbuf, size_t maxsize)
// could implement a lookup table here if someone needs it
strcpy (szBuffer, "unknown");
}
- if (wincap.is_winnt ())
- {
- bufptr += __small_sprintf (bufptr, "type : %s\n"
- "cpu family : %d\n"
+ if (wincap.is_winnt ())
+ {
+ bufptr += __small_sprintf (bufptr, "type : %s\n"
+ "cpu family : %d\n"
"model : %d\n"
"model name : %s\n"
"stepping : %d\n"
@@ -739,28 +738,28 @@ format_proc_cpuinfo (char *destbuf, size_t maxsize)
apic_id,
cpu_mhz,
(features1 & (1 << 0)) ? "yes" : "no");
- }
- else
- {
- bufptr += __small_sprintf (bufptr, "type : %s\n"
- "cpu family : %d\n"
- "model : %d\n"
- "model name : %s\n"
- "stepping : %d\n"
- "brand id : %d\n"
- "cpu count : %d\n"
- "apic id : %d\n"
- "fpu : %s\n",
- type_str,
- family,
- model,
- szBuffer,
- stepping,
- brand_id,
- cpu_count,
- apic_id,
- (features1 & (1 << 0)) ? "yes" : "no");
- }
+ }
+ else
+ {
+ bufptr += __small_sprintf (bufptr, "type : %s\n"
+ "cpu family : %d\n"
+ "model : %d\n"
+ "model name : %s\n"
+ "stepping : %d\n"
+ "brand id : %d\n"
+ "cpu count : %d\n"
+ "apic id : %d\n"
+ "fpu : %s\n",
+ type_str,
+ family,
+ model,
+ szBuffer,
+ stepping,
+ brand_id,
+ cpu_count,
+ apic_id,
+ (features1 & (1 << 0)) ? "yes" : "no");
+ }
print ("flags :");
if (features1 & (1 << 0))
print (" fpu");
diff --git a/winsup/cygwin/fhandler_process.cc b/winsup/cygwin/fhandler_process.cc
index 92eb22ab3d9..3b61cd91874 100644
--- a/winsup/cygwin/fhandler_process.cc
+++ b/winsup/cygwin/fhandler_process.cc
@@ -147,10 +147,7 @@ struct dirent *
fhandler_process::readdir (DIR * dir)
{
if (dir->__d_position >= PROCESS_LINK_COUNT)
- {
- set_errno (ENMFILE);
- return NULL;
- }
+ return NULL;
strcpy (dir->__d_dirent->d_name, process_listing[dir->__d_position++]);
syscall_printf ("%p = readdir (%p) (%s)", &dir->__d_dirent, dir,
dir->__d_dirent->d_name);
diff --git a/winsup/cygwin/fhandler_registry.cc b/winsup/cygwin/fhandler_registry.cc
index 91370147670..42c87e3540b 100644
--- a/winsup/cygwin/fhandler_registry.cc
+++ b/winsup/cygwin/fhandler_registry.cc
@@ -331,7 +331,8 @@ retry:
{
RegCloseKey ((HKEY) dir->__d_u.__d_data.__handle);
dir->__d_u.__d_data.__handle = INVALID_HANDLE_VALUE;
- seterrno_from_win_error (__FILE__, __LINE__, error);
+ if (error != ERROR_NO_MORE_ITEMS)
+ seterrno_from_win_error (__FILE__, __LINE__, error);
goto out;
}
diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc
index 3dc16902598..338ce278233 100644
--- a/winsup/cygwin/fhandler_socket.cc
+++ b/winsup/cygwin/fhandler_socket.cc
@@ -47,7 +47,7 @@ secret_event_name (char *buf, short port, int *secret_ptr)
{
__small_sprintf (buf, "%scygwin.local_socket.secret.%d.%08x-%08x-%08x-%08x",
wincap.has_terminal_services () ? "Global\\" : "",
- port,
+ port,
secret_ptr [0], secret_ptr [1],
secret_ptr [2], secret_ptr [3]);
}
@@ -231,7 +231,7 @@ fhandler_socket::check_peer_secret_event (struct sockaddr_in* peer, int* secret)
{
char event_name[MAX_PATH];
-
+
secret_event_name (event_name, peer->sin_port, secret ?: connect_secret);
HANDLE ev = CreateEvent (&sec_all_nih, FALSE, FALSE, event_name);
if (!ev && GetLastError () == ERROR_ALREADY_EXISTS)
@@ -943,7 +943,7 @@ fhandler_socket::sendto (const void *ptr, size_t len, int flags,
res = ret;
/* Special handling for EPIPE and SIGPIPE.
-
+
EPIPE is generated if the local end has been shut down on a connection
oriented socket. In this case the process will also receive a SIGPIPE
unless MSG_NOSIGNAL is set. */
diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index 3c88fcc97b5..de5bae127fe 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -555,25 +555,22 @@ fhandler_tty_slave::open (int flags, mode_t)
set_output_handle (to_master_local);
set_open_status ();
- if (!output_done_event)
+ if (fhandler_console::open_fhs++ == 0 && !output_done_event
+ && wincap.pty_needs_alloc_console ())
{
- if (fhandler_console::open_fhs++ == 0
- && wincap.pty_needs_alloc_console ())
+ BOOL b;
+ HWINSTA h = CreateWindowStation (NULL, 0, GENERIC_READ | GENERIC_WRITE, &sec_none_nih);
+ termios_printf ("CreateWindowStation %p, %E", h);
+ if (h)
{
- BOOL b;
- HWINSTA h = CreateWindowStation (NULL, 0, GENERIC_READ | GENERIC_WRITE, &sec_none_nih);
- termios_printf ("CreateWindowStation %p, %E", h);
- if (h)
- {
- b = SetProcessWindowStation (h);
- termios_printf ("SetProcessWindowStation %d, %E", b);
- }
- b = AllocConsole (); // will cause flashing if workstation
- // stuff fails
- termios_printf ("%d = AllocConsole ()", b);
+ b = SetProcessWindowStation (h);
+ termios_printf ("SetProcessWindowStation %d, %E", b);
}
- termios_printf ("incremented open_fhs %d", fhandler_console::open_fhs);
+ b = AllocConsole (); // will cause flashing if workstation
+ // stuff fails
+ termios_printf ("%d = AllocConsole ()", b);
}
+ termios_printf ("incremented open_fhs %d", fhandler_console::open_fhs);
termios_printf ("tty%d opened", get_unit ());
return 1;
@@ -582,12 +579,9 @@ fhandler_tty_slave::open (int flags, mode_t)
int
fhandler_tty_slave::close ()
{
- if (!output_done_event)
- {
- if (!--fhandler_console::open_fhs && myself->ctty == -1)
- FreeConsole ();
- termios_printf ("decremented open_fhs %d", fhandler_console::open_fhs);
- }
+ if (!--fhandler_console::open_fhs && myself->ctty == -1)
+ FreeConsole ();
+ termios_printf ("decremented open_fhs %d", fhandler_console::open_fhs);
return fhandler_tty_common::close ();
}
@@ -855,11 +849,8 @@ fhandler_tty_slave::read (void *ptr, size_t& len)
int
fhandler_tty_slave::dup (fhandler_base *child)
{
- if (!output_done_event)
- {
- fhandler_console::open_fhs++;
- termios_printf ("incremented open_fhs %d", fhandler_console::open_fhs);
- }
+ fhandler_console::open_fhs++;
+ termios_printf ("incremented open_fhs %d", fhandler_console::open_fhs);
return fhandler_tty_common::dup (child);
}
@@ -1254,11 +1245,8 @@ fhandler_tty_common::set_close_on_exec (int val)
void
fhandler_tty_slave::fixup_after_fork (HANDLE parent)
{
- if (!output_done_event)
- {
- fhandler_console::open_fhs++;
- termios_printf ("incremented open_fhs %d", fhandler_console::open_fhs);
- }
+ fhandler_console::open_fhs++;
+ termios_printf ("incremented open_fhs %d", fhandler_console::open_fhs);
fhandler_tty_common::fixup_after_fork (parent);
}
@@ -1318,6 +1306,7 @@ fhandler_tty_master::init_console ()
return -1;
console->init (INVALID_HANDLE_VALUE, GENERIC_READ | GENERIC_WRITE, O_BINARY);
+ fhandler_console::open_fhs--; /* handled when individual fds are opened */
console->set_r_no_interrupt (1);
return 0;
}
diff --git a/winsup/cygwin/include/cygwin/socket.h b/winsup/cygwin/include/cygwin/socket.h
index f89a8ed8726..67e1345f293 100644
--- a/winsup/cygwin/include/cygwin/socket.h
+++ b/winsup/cygwin/include/cygwin/socket.h
@@ -75,7 +75,9 @@ struct msghdr
#define AF_HYLINK 15 /* NSC Hyperchannel */
#define AF_APPLETALK 16 /* AppleTalk */
#define AF_NETBIOS 17 /* NetBios-style addresses */
+#if 0 /* Not yet */
#define AF_INET6 23 /* IP version 6 */
+#endif
#define AF_MAX 32
/*
@@ -101,7 +103,9 @@ struct msghdr
#define PF_HYLINK AF_HYLINK
#define PF_APPLETALK AF_APPLETALK
#define PF_NETBIOS AF_NETBIOS
+#if 0
#define PF_INET6 AF_INET6
+#endif
#define PF_MAX AF_MAX
diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h
index 6954d09693c..05be44f6ef1 100644
--- a/winsup/cygwin/include/cygwin/version.h
+++ b/winsup/cygwin/include/cygwin/version.h
@@ -42,7 +42,7 @@ details. */
changes to the DLL and is mainly informative in nature. */
#define CYGWIN_VERSION_DLL_MAJOR 1005
-#define CYGWIN_VERSION_DLL_MINOR 1
+#define CYGWIN_VERSION_DLL_MINOR 2
/* Major numbers before CYGWIN_VERSION_DLL_EPOCH are
incompatible. */
@@ -208,12 +208,14 @@ details. */
86: Export ftok
87: Export vsyslog
88: Export _getreent
+ 89: Export __mempcpy
+ 90: Export _fopen64
*/
/* Note that we forgot to bump the api for ualarm, strtoll, strtoull */
#define CYGWIN_VERSION_API_MAJOR 0
-#define CYGWIN_VERSION_API_MINOR 88
+#define CYGWIN_VERSION_API_MINOR 90
/* There is also a compatibity version number associated with the
shared memory regions. It is incremented when incompatible
diff --git a/winsup/cygwin/ipc.cc b/winsup/cygwin/ipc.cc
index d37f45947ef..c89b23e213d 100644
--- a/winsup/cygwin/ipc.cc
+++ b/winsup/cygwin/ipc.cc
@@ -35,45 +35,45 @@ ftok (const char *path, int id)
We will have to alias; leaving open the possibility that the same
key will be returned for multiple files. This possibility exists
also on Linux; the question is, how to minimize this possibility.
-
+
How to solve? Well, based on C. Vinschen's research, the nFileIndex*
words vary as follows, on a partition with > 110,000 files
nFileIndexHigh: 564 values between 0x00010000 -- 0xffff0000
nFileIndexLow : 103812 values between 0x00000000 -- 0x0003ffff
- R. Collins suggests that these may represent a tree path,
+ R. Collins suggests that these may represent a tree path,
and that it would require ~2.9M files to force the tree depth
to increase and reveal more bit usage.
-
+
Implementation details: dev_t is 32bits, but is formed by
- device(32bits) << 16 | unit(32bits)
+ device(32bits) << 16 | unit(32bits)
But device is ACTUALLY == status & FH_DEVMASK, where FH_DEVMASK
is 0x00000fff --> 12 bits
-
- As it happens, the maximum number of devices is actually
+
+ As it happens, the maximum number of devices is actually
FH_NDEV, not FH_DEVMASK, where FH_NDEV is currently 0x0000001d.
However, FH_NDEV grows as new device types are added. So
currently the device number needs 5 bits, but later? Let's
take a cue from Linux, and use the lower 8 bits (instead of the
lower 12 or 16) for the device (major?) number.
-
+
Similarly, while 'units' is an int (32bits), it is unclear
how many of these are significant. For most devices, it seems that
'units' is equivalent to 'minor'. For FH_TAPE, it's obvious that
only 8 bits are important. However, for FH_SOCKET...it might be
as high as 16 significant bits.
-
+
Let's assume that we only need 8 bits from device (major) and
only 8 bits from unit (minor). (On linux, only 8 bits of minor
are used, and none from major).
---> so, we only need 0x00ff00ff (16 bits) of dev_t
-
+
---> we MUST have all 8 bits of id.
-
+
---> So, we only have 64 - 8 - 16 = 40 bits for ino_t. But, we
need 0xffff0000 for nFileIndexHigh and 0x0003ffff for nFileIndexLow
minimum, or 16 + 18 = 34 bits. Lucky us - we have 6 more bits
to distribute.
-
+
For lack of a better idea, we'll allocate 2 of the extra bits to
nFileIndexHigh and 4 to nFileIndexLow. */
diff --git a/winsup/cygwin/mmap.cc b/winsup/cygwin/mmap.cc
index 08f89c84f4c..d4f953290b7 100644
--- a/winsup/cygwin/mmap.cc
+++ b/winsup/cygwin/mmap.cc
@@ -123,12 +123,12 @@ mmap_record::alloc_map (_off64_t off, DWORD len)
len = PAGE_CNT (len) * getpagesize ();
if (off > 0 &&
!VirtualProtect (base_address_, off, PAGE_NOACCESS, &old_prot))
- syscall_printf ("VirtualProtect(%x,%d) failed: %E", base_address_, off);
+ syscall_printf ("VirtualProtect(%x,%D) failed: %E", base_address_, off);
if (off + len < size_to_map_
&& !VirtualProtect (base_address_ + off + len,
size_to_map_ - len - off,
PAGE_NOACCESS, &old_prot))
- syscall_printf ("VirtualProtect(%x,%d) failed: %E",
+ syscall_printf ("VirtualProtect(%x,%D) failed: %E",
base_address_ + off + len, size_to_map_ - len - off);
off /= getpagesize ();
len /= getpagesize ();
@@ -158,7 +158,7 @@ mmap_record::map_map (_off64_t off, DWORD len)
break;
}
- debug_printf ("map_map (fd=%d, off=%D, len=%d)", fdesc_, off, len);
+ debug_printf ("map_map (fd=%d, off=%D, len=%u)", fdesc_, off, len);
len = PAGE_CNT (len);
if ((off = find_empty (len)) == (DWORD)-1)
@@ -333,7 +333,7 @@ list::match (caddr_t addr, DWORD len, caddr_t &m_addr, DWORD &m_len,
for (int i = start + 1; i < nrecs; ++i)
{
low = (addr >= recs[i].get_address ()) ? addr : recs[i].get_address ();
- high = recs[i].get_address ()
+ high = recs[i].get_address ()
+ (PAGE_CNT (recs[i].get_size ()) * getpagesize ());
high = (addr + len < high) ? addr + len : high;
if (low < high)
@@ -436,7 +436,7 @@ static map *mmapped_areas;
extern "C" caddr_t
mmap64 (caddr_t addr, size_t len, int prot, int flags, int fd, _off64_t off)
{
- syscall_printf ("addr %x, len %d, prot %x, flags %x, fd %d, off %D",
+ syscall_printf ("addr %x, len %u, prot %x, flags %x, fd %d, off %D",
addr, len, prot, flags, fd, off);
static DWORD granularity;
@@ -566,7 +566,7 @@ mmap64 (caddr_t addr, size_t len, int prot, int flags, int fd, _off64_t off)
The offset is re-added when evaluating the return value. */
if (base)
base -= off - gran_off;
-
+
HANDLE h = fh->mmap (&base, gran_len, access, flags, gran_off);
if (h == INVALID_HANDLE_VALUE)
@@ -619,7 +619,7 @@ mmap (caddr_t addr, size_t len, int prot, int flags, int fd, _off_t off)
extern "C" int
munmap (caddr_t addr, size_t len)
{
- syscall_printf ("munmap (addr %x, len %d)", addr, len);
+ syscall_printf ("munmap (addr %x, len %u)", addr, len);
/* Error conditions according to SUSv3 */
if (!addr || ((DWORD)addr % getpagesize ()) || !len
@@ -676,7 +676,7 @@ munmap (caddr_t addr, size_t len)
extern "C" int
msync (caddr_t addr, size_t len, int flags)
{
- syscall_printf ("addr = %x, len = %d, flags = %x",
+ syscall_printf ("addr = %x, len = %u, flags = %x",
addr, len, flags);
/* However, check flags for validity. */
@@ -844,7 +844,7 @@ fhandler_disk_file::mmap (caddr_t *addr, size_t len, DWORD access,
if (!base && !(flags & MAP_FIXED))
base = MapViewOfFileEx (h, access, high, low, len, NULL);
debug_printf ("%x = MapViewOfFileEx (h:%x, access:%x, 0, off:%D, "
- "len:%d, addr:%x)", base, h, access, off, len, *addr);
+ "len:%u, addr:%x)", base, h, access, off, len, *addr);
if (!base || ((flags & MAP_FIXED) && base != *addr))
{
if (!base)
@@ -908,7 +908,7 @@ mprotect (caddr_t addr, size_t len, int prot)
DWORD old_prot;
DWORD new_prot = 0;
- syscall_printf ("mprotect (addr %x, len %d, prot %x)", addr, len, prot);
+ syscall_printf ("mprotect (addr %x, len %u, prot %x)", addr, len, prot);
if (!wincap.virtual_protect_works_on_shared_pages ()
&& addr >= (caddr_t)0x80000000 && addr <= (caddr_t)0xBFFFFFFF)
@@ -986,7 +986,7 @@ fixup_mmaps_after_fork (HANDLE parent)
{
mmap_record *rec = map_list->recs + li;
- debug_printf ("fd %d, h %x, access %x, offset %d, size %d, address %p",
+ debug_printf ("fd %d, h %x, access %x, offset %D, size %u, address %p",
rec->get_fd (), rec->get_handle (), rec->get_access (),
rec->get_offset (), rec->get_size (), rec->get_address ());
diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc
index 1d1abab7659..c66232508c5 100644
--- a/winsup/cygwin/net.cc
+++ b/winsup/cygwin/net.cc
@@ -527,7 +527,7 @@ fdsock (cygheap_fdmanip& fd, const device *dev, SOCKET soc)
fd->set_io_handle ((HANDLE) soc);
fd->set_flags (O_RDWR | O_BINARY);
fd->set_r_no_interrupt (winsock2_active);
- cygheap->fdtab.inc_need_fixup_before ();
+ // CORINNA - needed? // cygheap->fdtab.inc_need_fixup_before ();
debug_printf ("fd %d, name '%s', soc %p", (int) fd, dev->name, soc);
return true;
}
@@ -771,14 +771,14 @@ cygwin_connect (int fd, const struct sockaddr *name, int namelen)
{
bool was_blocking = false;
if (!fh->is_nonblocking ())
- {
+ {
int nonblocking = 1;
fh->ioctl (FIONBIO, &nonblocking);
was_blocking = true;
}
res = fh->connect (name, namelen);
if (was_blocking)
- {
+ {
if (res == -1 && get_errno () == EINPROGRESS)
{
size_t fds_size = howmany (fd + 1, NFDBITS) * sizeof (fd_mask);
@@ -790,7 +790,7 @@ cygwin_connect (int fd, const struct sockaddr *name, int namelen)
FD_SET (fd, except_fds);
res = cygwin_select (fd + 1, NULL, write_fds, except_fds, NULL);
if (res > 0 && FD_ISSET (fd, except_fds))
- {
+ {
res = -1;
for (;;)
{
@@ -799,7 +799,7 @@ cygwin_connect (int fd, const struct sockaddr *name, int namelen)
cygwin_getsockopt (fd, SOL_SOCKET, SO_ERROR,
(void *) &err, &len);
if (err)
- {
+ {
set_errno (err);
break;
}
@@ -807,9 +807,9 @@ cygwin_connect (int fd, const struct sockaddr *name, int namelen)
}
}
else if (res > 0)
- res = 0;
+ res = 0;
else
- {
+ {
WSASetLastError (WSAEINPROGRESS);
set_winsock_errno ();
}
@@ -1300,7 +1300,7 @@ getdomainname (char *domain, size_t len)
/* This is only used by Win95 and NT <= 4.0.
The registry names are language independent.
- FIXME: Handle DHCP on Win95. The DhcpDomain(s) may be available
+ FIXME: Handle DHCP on Win95. The DhcpDomain(s) may be available
in ..VxD\DHCP\DhcpInfoXX\OptionInfo, RFC 1533 format */
reg_key r (HKEY_LOCAL_MACHINE, KEY_READ,
diff --git a/winsup/cygwin/ntdll.h b/winsup/cygwin/ntdll.h
index 220cf3e821d..45739bf385a 100644
--- a/winsup/cygwin/ntdll.h
+++ b/winsup/cygwin/ntdll.h
@@ -9,7 +9,6 @@
details. */
#define STATUS_INFO_LENGTH_MISMATCH ((NTSTATUS) 0xc0000004)
-#define FILE_SYNCHRONOUS_IO_NONALERT 32
#define PDI_MODULES 0x01
#define PDI_HEAPS 0x04
#define LDRP_IMAGE_DLL 0x00000004
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index 8947be723f1..440023d796e 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -892,8 +892,6 @@ digits (const char *name)
return p > name && !*p ? n : -1;
}
-
-
/* Return TRUE if src_path is a Win32 device name, filling out the device
name in win32_path */
@@ -1150,7 +1148,7 @@ set_flags (unsigned *flags, unsigned val)
}
}
-char special_chars[] =
+static char special_chars[] =
"\001" "\002" "\003" "\004" "\005" "\006" "\007" "\010"
"\011" "\012" "\013" "\014" "\015" "\016" "\017" "\020"
"\021" "\022" "\023" "\024" "\025" "\026" "\027" "\030"
@@ -1160,62 +1158,78 @@ char special_chars[] =
"I" "J" "K" "L" "M" "N" "O" "P"
"Q" "R" "S" "T" "U" "V" "W" "X"
"Y" "Z";
+static char special_introducers[] =
+ "anpcl";
-static inline char
-special_char (const char *s)
+static char
+special_char (const char *s, const char *valid_chars = special_chars)
{
- char *p = strechr (special_chars, *s);
- if (*p == '%' && strlen (p) >= 3)
- {
- char hex[] = {s[1], s[2], '\0'};
- unsigned char c = strtoul (hex, &p, 16);
- p = strechr (special_chars, c);
- }
- return *p;
-}
-
-bool
-fnunmunge (char *dst, const char *src)
-{
- bool converted = false;
- char c;
-
- while (*src)
- if (*src != '%' || !(c = special_char (src)))
- *dst++ = *src++;
- else
- {
- converted = true;
- *dst++ = c;
- src += 3;
- }
+ if (*s != '%' || strlen (s) < 3)
+ return 0;
- *dst = *src;
- return converted;
+ char *p;
+ char hex[] = {s[1], s[2], '\0'};
+ unsigned char c = strtoul (hex, &p, 16);
+ p = strechr (valid_chars, c);
+ return *p;
}
/* Determines if name is "special". Assumes that name is empty or "absolute" */
static int
-special_name (const char *s)
+special_name (const char *s, int inc = 1)
{
if (!*s)
return false;
- if (strpbrk (++s, special_chars))
+ s += inc;
+ if (strpbrk (s, special_chars))
return !strncasematch (s, "%2f", 3);
if (strcasematch (s, "nul")
|| strcasematch (s, "aux")
- || strcasematch (s, "prn"))
+ || strcasematch (s, "prn")
+ || strcasematch (s, "con")
+ || strcasematch (s, "conin$")
+ || strcasematch (s, "conout$"))
return -1;
if (!strncasematch (s, "com", 3)
&& !strncasematch (s, "lpt", 3))
return false;
char *p;
- (void) strtol (s, &p, 10);
+ (void) strtoul (s + 3, &p, 10);
return -(*p == '\0');
}
+bool
+fnunmunge (char *dst, const char *src)
+{
+ bool converted = false;
+ char c;
+
+ if ((c = special_char (src, special_introducers)))
+ {
+ __small_sprintf (dst, "%c%s", c, src + 3);
+ if (special_name (dst, 0))
+ {
+ *dst++ = c;
+ src += 3;
+ }
+ }
+
+ while (*src)
+ if (!(c = special_char (src)))
+ *dst++ = *src++;
+ else
+ {
+ converted = true;
+ *dst++ = c;
+ src += 3;
+ }
+
+ *dst = *src;
+ return converted;
+}
+
void
mount_item::fnmunge (char *dst, const char *src)
{
@@ -1227,19 +1241,13 @@ mount_item::fnmunge (char *dst, const char *src)
char *d = dst;
*d++ = *src++;
if (name_type < 0)
- {
- __small_sprintf (d, "%%%02x", (unsigned char) *src++);
- d += 3;
- }
+ d += __small_sprintf (d, "%%%02x", (unsigned char) *src++);
while (*src)
- if (!special_char (src))
+ if (!strchr (special_chars, *src) || (*src == '%' && !special_char (src)))
*d++ = *src++;
else
- {
- __small_sprintf (d, "%%%02x", (unsigned char) *src++);
- d += 3;
- }
+ d += __small_sprintf (d, "%%%02x", (unsigned char) *src++);
*d = *src;
}
@@ -2299,8 +2307,7 @@ cygdrive_getmntent ()
break;
__small_sprintf (native_path, "%c:\\", drive);
- if (GetDriveType (native_path) == DRIVE_REMOVABLE ||
- GetFileAttributes (native_path) == INVALID_FILE_ATTRIBUTES)
+ if (GetFileAttributes (native_path) == INVALID_FILE_ATTRIBUTES)
{
available_drives &= ~mask;
continue;
diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc
index 489a91e0642..9cb06c48cd6 100644
--- a/winsup/cygwin/pinfo.cc
+++ b/winsup/cygwin/pinfo.cc
@@ -406,7 +406,7 @@ _pinfo::commune_send (DWORD code, ...)
/* FIXME: Need something better than an busy loop here */
bool isalive;
- for (int i = 0; (isalive = alive ()) || (i < 65536); i++)
+ for (int i = 0; (isalive = alive ()) && (i < 10000); i++)
if (myself->hello_pid <= 0)
break;
else
diff --git a/winsup/cygwin/security.cc b/winsup/cygwin/security.cc
index 47f7c335469..8ceebdbc722 100644
--- a/winsup/cygwin/security.cc
+++ b/winsup/cygwin/security.cc
@@ -69,17 +69,8 @@ extern "C" void
cygwin_set_impersonation_token (const HANDLE hToken)
{
debug_printf ("set_impersonation_token (%d)", hToken);
- if (cygheap->user.impersonation_state == IMP_EXTERNAL
- && cygheap->user.external_token != hToken)
- {
- set_errno (EPERM);
- return;
- }
- else
- {
- cygheap->user.external_token = hToken;
- return;
- }
+ cygheap->user.external_token = hToken;
+ return;
}
void
@@ -741,42 +732,38 @@ verify_token (HANDLE token, cygsid &usersid, user_groups &groups, BOOL *pintern)
if (intern && !groups.issetgroups ())
{
char sd_buf[MAX_SID_LEN + sizeof (SECURITY_DESCRIPTOR)];
- PSID gsid = NO_SID;
+ cygpsid gsid (NO_SID);
if (!GetKernelObjectSecurity (token, GROUP_SECURITY_INFORMATION,
(PSECURITY_DESCRIPTOR) sd_buf,
sizeof sd_buf, &size))
debug_printf ("GetKernelObjectSecurity(): %E");
else if (!GetSecurityDescriptorGroup ((PSECURITY_DESCRIPTOR) sd_buf,
- &gsid, (BOOL *) &size))
+ (PSID *) &gsid, (BOOL *) &size))
debug_printf ("GetSecurityDescriptorGroup(): %E");
if (well_known_null_sid != gsid)
return gsid == groups.pgsid;
}
- PTOKEN_GROUPS my_grps = NULL;
- BOOL ret = FALSE;
- char saw_buf[NGROUPS_MAX] = {};
- char *saw = saw_buf, sawpg = FALSE;
+ PTOKEN_GROUPS my_grps;
+ bool saw_buf[NGROUPS_MAX] = {};
+ bool *saw = saw_buf, sawpg = false, ret = false;
if (!GetTokenInformation (token, TokenGroups, NULL, 0, &size) &&
GetLastError () != ERROR_INSUFFICIENT_BUFFER)
debug_printf ("GetTokenInformation(token, TokenGroups): %E");
- else if (!(my_grps = (PTOKEN_GROUPS) malloc (size)))
- debug_printf ("malloc (my_grps) failed.");
+ else if (!(my_grps = (PTOKEN_GROUPS) alloca (size)))
+ debug_printf ("alloca (my_grps) failed.");
else if (!GetTokenInformation (token, TokenGroups, my_grps, size, &size))
debug_printf ("GetTokenInformation(my_token, TokenGroups): %E");
else if (!groups.issetgroups ()) /* setgroups was never called */
- {
- ret = sid_in_token_groups (my_grps, groups.pgsid);
- if (ret == FALSE)
- ret = (groups.pgsid == tok_usersid);
- }
+ ret = sid_in_token_groups (my_grps, groups.pgsid)
+ || groups.pgsid == usersid;
else /* setgroups was called */
{
struct __group32 *gr;
cygsid gsid;
- if (groups.sgsids.count > (int) sizeof (saw_buf) &&
- !(saw = (char *) calloc (groups.sgsids.count, sizeof (char))))
+ if (groups.sgsids.count > (int) (sizeof (saw_buf) / sizeof (*saw_buf))
+ && !(saw = (bool *) calloc (groups.sgsids.count, sizeof (bool))))
goto done;
/* token groups found in /etc/group match the user.gsids ? */
@@ -785,24 +772,21 @@ verify_token (HANDLE token, cygsid &usersid, user_groups &groups, BOOL *pintern)
{
int pos = groups.sgsids.position (gsid);
if (pos >= 0)
- saw[pos] = TRUE;
+ saw[pos] = true;
else if (groups.pgsid == gsid)
- sawpg = TRUE;
- else if (gsid != well_known_world_sid &&
- gsid != usersid)
+ sawpg = true;
+ else if (gsid != well_known_world_sid
+ && gsid != usersid)
goto done;
}
for (int gidx = 0; gidx < groups.sgsids.count; gidx++)
if (!saw[gidx])
goto done;
- if (sawpg ||
- groups.sgsids.contains (groups.pgsid) ||
- groups.pgsid == usersid)
- ret = TRUE;
+ ret = sawpg
+ || groups.sgsids.contains (groups.pgsid)
+ || groups.pgsid == usersid;
}
done:
- if (my_grps)
- free (my_grps);
if (saw != saw_buf)
free (saw);
return ret;
@@ -1414,9 +1398,9 @@ get_file_attribute (int use_ntsec, const char *file,
}
if (uidret)
- *uidret = getuid32 ();
+ *uidret = myself->uid;
if (gidret)
- *gidret = getgid32 ();
+ *gidret = myself->gid;
if (!attribute)
return 0;
@@ -1446,15 +1430,15 @@ get_nt_object_attribute (HANDLE handle, SE_OBJECT_TYPE object_type,
psd = (PSECURITY_DESCRIPTOR) & sd_buf[0];
DWORD len = sizeof (sd_buf);
if (ERROR_SUCCESS != RegGetKeySecurity ((HKEY) handle,
- DACL_SECURITY_INFORMATION |
- GROUP_SECURITY_INFORMATION |
- OWNER_SECURITY_INFORMATION,
- psd, &len))
- {
- __seterrno ();
- debug_printf ("RegGetKeySecurity %E");
- psd = NULL;
- }
+ DACL_SECURITY_INFORMATION |
+ GROUP_SECURITY_INFORMATION |
+ OWNER_SECURITY_INFORMATION,
+ psd, &len))
+ {
+ __seterrno ();
+ debug_printf ("RegGetKeySecurity %E");
+ psd = NULL;
+ }
}
else
{
@@ -1463,7 +1447,7 @@ get_nt_object_attribute (HANDLE handle, SE_OBJECT_TYPE object_type,
GROUP_SECURITY_INFORMATION |
OWNER_SECURITY_INFORMATION,
NULL, NULL, NULL, NULL, &psd))
- {
+ {
__seterrno ();
debug_printf ("GetSecurityInfo %E");
psd = NULL;
diff --git a/winsup/cygwin/speclib b/winsup/cygwin/speclib
new file mode 100755
index 00000000000..69074096c6e
--- /dev/null
+++ b/winsup/cygwin/speclib
@@ -0,0 +1,39 @@
+#!/bin/sh -x
+# speclib - Make a special version of the cygwin import library.
+#
+# Copyright 2001, 2002 Red Hat, Inc.
+#
+# 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.
+
+case "$1" in
+ -v) shift; v() { :; } ;;
+ *) v() { /bin/false; } ;;
+esac
+lib=$1; shift
+nm=$1; shift
+ar=$1; shift
+libdll=$1; shift
+cp /dev/null /tmp/$$.objs
+trap "/bin/rm -rf /tmp/$$.dir /tmp/$$.syms /tmp/$$.objs /tmp/$$.raw" 0 1 2 15
+$nm --extern-only --defined-only $* | sed -e '/^[ ]*$/d' -e '/:$/d' -e 's%^.* _\(.*\)%/ __imp__\1$/p%' | grep -v ' __imp___imp__' > /tmp/$$.syms
+v || $nm -Ap --extern-only --defined-only $libdll | egrep ' I __head| I _.*_iname' | awk -F: '{print $2}' > /tmp/$$.objs
+$nm -Ap --extern-only --defined-only $libdll | sed -n -f /tmp/$$.syms | awk -F: '{print $2}' >> /tmp/$$.objs
+sort -o /tmp/$$.objs -u /tmp/$$.objs
+
+[ -s /tmp/$$.objs ] || { echo "speclib: couldn't find symbols for $lib" 1>&2; exit 1; }
+
+/bin/rm -f /tmp/$$>dir
+mkdir /tmp/$$.dir
+cd /tmp/$$.dir
+if v; then
+ $ar x $libdll
+ /bin/rm -f `cat /tmp/$$.objs`
+else
+ $ar x $libdll `cat /tmp/$$.objs`
+fi
+/bin/rm -f $lib
+$ar crus $lib *.o
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 229c1f5ec14..752c8abffd0 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -290,14 +290,14 @@ setsid (void)
{
if (myself->ctty >= 0 && fhandler_console::open_fhs <= 0)
{
- syscall_printf ("open_fhs %d, freeing console",
- fhandler_console::open_fhs);
+ syscall_printf ("freeing console");
FreeConsole ();
}
myself->ctty = -1;
myself->sid = getpid ();
myself->pgid = getpid ();
- syscall_printf ("sid %d, pgid %d, ctty %d", myself->sid, myself->pgid, myself->ctty);
+ syscall_printf ("sid %d, pgid %d, ctty %d, open_fhs %d", myself->sid,
+ myself->pgid, myself->ctty, fhandler_console::open_fhs);
return myself->sid;
}
@@ -2123,7 +2123,6 @@ seteuid32 (__uid32_t uid)
HANDLE ptok, new_token = INVALID_HANDLE_VALUE;
struct passwd * pw_new;
PSID origpsid, psid2 = NO_SID;
- enum impersonation new_state = IMP_BAD;
BOOL token_is_internal;
pw_new = internal_getpwuid (uid);
@@ -2144,48 +2143,47 @@ seteuid32 (__uid32_t uid)
/* Verify if the process token is suitable. */
if (verify_token (ptok, usersid, groups))
- new_state = IMP_NONE;
- /* Verify if a current token is suitable */
- else if (cygheap->user.external_token
+ new_token = ptok;
+ /* Verify if the external token is suitable */
+ else if (cygheap->user.external_token != INVALID_HANDLE_VALUE
&& verify_token (cygheap->user.external_token, usersid, groups))
- {
- new_token = cygheap->user.external_token;
- new_state = IMP_EXTERNAL;
- }
- else if (cygheap->user.internal_token
+ new_token = cygheap->user.external_token;
+ /* Verify if the current token (internal or former external) is suitable */
+ else if (cygheap->user.current_token != INVALID_HANDLE_VALUE
+ && cygheap->user.current_token != cygheap->user.external_token
+ && verify_token (cygheap->user.current_token, usersid, groups,
+ &token_is_internal))
+ new_token = cygheap->user.current_token;
+ /* Verify if the internal token is suitable */
+ else if (cygheap->user.internal_token != INVALID_HANDLE_VALUE
+ && cygheap->user.internal_token != cygheap->user.current_token
&& verify_token (cygheap->user.internal_token, usersid, groups,
&token_is_internal))
- {
- new_token = cygheap->user.internal_token;
- new_state = IMP_INTERNAL;
- }
+ new_token = cygheap->user.internal_token;
- debug_printf ("New token %d, state %d", new_token, new_state);
- /* Return if current token is valid */
- if (cygheap->user.impersonation_state == new_state)
- {
- cygheap->user.reimpersonate ();
- goto success; /* No change */
- }
+ debug_printf ("Found token %d", new_token);
/* Set process def dacl to allow access to impersonated token */
- char dacl_buf[MAX_DACL_LEN (5)];
- if (usersid != (origpsid = cygheap->user.orig_sid ()))
- psid2 = usersid;
- if (sec_acl ((PACL) dacl_buf, FALSE, origpsid, psid2))
+ if (cygheap->user.current_token != new_token)
{
- TOKEN_DEFAULT_DACL tdacl;
- tdacl.DefaultDacl = (PACL) dacl_buf;
- if (!SetTokenInformation (ptok, TokenDefaultDacl,
- &tdacl, sizeof dacl_buf))
- debug_printf ("SetTokenInformation"
- "(TokenDefaultDacl): %E");
+ char dacl_buf[MAX_DACL_LEN (5)];
+ if (usersid != (origpsid = cygheap->user.orig_sid ()))
+ psid2 = usersid;
+ if (sec_acl ((PACL) dacl_buf, FALSE, origpsid, psid2))
+ {
+ TOKEN_DEFAULT_DACL tdacl;
+ tdacl.DefaultDacl = (PACL) dacl_buf;
+ if (!SetTokenInformation (ptok, TokenDefaultDacl,
+ &tdacl, sizeof dacl_buf))
+ debug_printf ("SetTokenInformation"
+ "(TokenDefaultDacl): %E");
+ }
}
- if (new_state == IMP_BAD)
+ /* If no impersonation token is available, try to
+ authenticate using NtCreateToken () or subauthentication. */
+ if (new_token == INVALID_HANDLE_VALUE)
{
- /* If no impersonation token is available, try to
- authenticate using NtCreateToken () or subauthentication. */
new_token = create_token (usersid, groups, pw_new);
if (new_token == INVALID_HANDLE_VALUE)
{
@@ -2195,48 +2193,31 @@ seteuid32 (__uid32_t uid)
if (new_token == INVALID_HANDLE_VALUE)
goto failed;
}
- new_state = IMP_INTERNAL;
- }
-
- /* If using the token, set info and impersonate */
- if (new_state != IMP_NONE)
- {
- /* If the token was explicitly created, all information has
- already been set correctly. */
- if (new_state == IMP_EXTERNAL)
- {
- /* Try setting owner to same value as user. */
- if (!SetTokenInformation (new_token, TokenOwner,
- &usersid, sizeof usersid))
- debug_printf ("SetTokenInformation(user.token, "
- "TokenOwner): %E");
- /* Try setting primary group in token to current group */
- if (!SetTokenInformation (new_token,
- TokenPrimaryGroup,
- &groups.pgsid, sizeof (cygsid)))
- debug_printf ("SetTokenInformation(user.token, "
- "TokenPrimaryGroup): %E");
- }
- /* Try to impersonate. */
- if (!ImpersonateLoggedOnUser (new_token))
- {
- debug_printf ("ImpersonateLoggedOnUser %E");
- __seterrno ();
- goto failed;
- }
/* Keep at most one internal token */
- if (new_state == IMP_INTERNAL)
- {
- if (cygheap->user.internal_token)
- CloseHandle (cygheap->user.internal_token);
- cygheap->user.internal_token = new_token;
- }
+ if (cygheap->user.internal_token != INVALID_HANDLE_VALUE)
+ CloseHandle (cygheap->user.internal_token);
+ cygheap->user.internal_token = new_token;
+ }
+ else if (new_token != ptok)
+ {
+ /* Try setting owner to same value as user. */
+ if (!SetTokenInformation (new_token, TokenOwner,
+ &usersid, sizeof usersid))
+ debug_printf ("SetTokenInformation(user.token, "
+ "TokenOwner): %E");
+ /* Try setting primary group in token to current group */
+ if (!SetTokenInformation (new_token,
+ TokenPrimaryGroup,
+ &groups.pgsid, sizeof (cygsid)))
+ debug_printf ("SetTokenInformation(user.token, "
+ "TokenPrimaryGroup): %E");
}
- cygheap->user.set_sid (usersid);
-success:
CloseHandle (ptok);
- cygheap->user.impersonation_state = new_state;
+ cygheap->user.set_sid (usersid);
+ cygheap->user.current_token = new_token == ptok ? INVALID_HANDLE_VALUE
+ : new_token;
+ cygheap->user.reimpersonate ();
success_9x:
cygheap->user.set_name (pw_new->pw_name);
myself->uid = uid;
@@ -2632,27 +2613,25 @@ logout (char *line)
strncpy (ut_buf.ut_line, line, sizeof ut_buf.ut_line);
setutent ();
ut = getutline (&ut_buf);
+
if (ut)
{
int fd;
- /* We can't use ut further since it's a pointer to the static utmp_data
- area (see below) and would get overwritten in pututline(). So we
- copy it back to the local ut_buf. */
- memcpy (&ut_buf, ut, sizeof ut_buf);
- ut_buf.ut_type = DEAD_PROCESS;
- memset (ut_buf.ut_user, 0, sizeof ut_buf.ut_user);
- time (&ut_buf.ut_time);
+ ut->ut_type = DEAD_PROCESS;
+ memset (ut->ut_user, 0, sizeof ut->ut_user);
+ time (&ut->ut_time);
/* Writing to wtmp must be atomic to prevent mixed up data. */
char mutex_name[MAX_PATH];
HANDLE mutex = CreateMutex (NULL, FALSE,
- shared_name (mutex_name, "wtmp_mutex", 0));
+ shared_name (mutex_name, "wtmp_mutex", 0));
if (mutex)
while (WaitForSingleObject (mutex, INFINITE) == WAIT_ABANDONED)
;
if ((fd = open (_PATH_WTMP, O_WRONLY | O_APPEND | O_BINARY, 0)) >= 0)
{
write (fd, &ut_buf, sizeof ut_buf);
+ debug_printf ("set logout time for %s", line);
close (fd);
}
if (mutex)
@@ -2660,9 +2639,9 @@ logout (char *line)
ReleaseMutex (mutex);
CloseHandle (mutex);
}
- memset (ut_buf.ut_line, 0, sizeof ut_buf.ut_line);
- ut_buf.ut_time = 0;
- pututline (&ut_buf);
+ memset (ut->ut_line, 0, sizeof ut_buf.ut_line);
+ ut->ut_time = 0;
+ pututline (ut);
endutent ();
}
return 1;
@@ -2672,8 +2651,6 @@ static int utmp_fd = -1;
static bool utmp_readonly = false;
static char *utmp_file = (char *) _PATH_UTMP;
-static struct utmp utmp_data;
-
static void
internal_setutent (bool force_readwrite)
{
@@ -2687,11 +2664,11 @@ internal_setutent (bool force_readwrite)
case we try again for reading only unless the process calls
pututline() (==force_readwrite) in which case opening just fails. */
if (utmp_fd < 0 && !force_readwrite)
- {
+ {
utmp_fd = open (utmp_file, O_RDONLY | O_BINARY);
if (utmp_fd >= 0)
utmp_readonly = true;
- }
+ }
}
else
lseek (utmp_fd, 0, SEEK_SET);
@@ -2729,6 +2706,16 @@ utmpname (_CONST char *file)
debug_printf ("New UTMP file: %s", utmp_file);
}
+/* Note: do not make NO_COPY */
+static struct utmp utmp_data_buf[16];
+static unsigned utix = 0;
+#define nutdbuf (sizeof (utmp_data_buf) / sizeof (utmp_data_buf[0]))
+#define utmp_data ({ \
+ if (utix > nutdbuf) \
+ utix = 0; \
+ utmp_data_buf + utix++; \
+})
+
extern "C" struct utmp *
getutent ()
{
@@ -2737,11 +2724,13 @@ getutent ()
{
internal_setutent (false);
if (utmp_fd < 0)
- return NULL;
+ return NULL;
}
- if (read (utmp_fd, &utmp_data, sizeof utmp_data) != sizeof utmp_data)
+
+ utmp *ut = utmp_data;
+ if (read (utmp_fd, ut, sizeof *ut) != sizeof *ut)
return NULL;
- return &utmp_data;
+ return ut;
}
extern "C" struct utmp *
@@ -2754,9 +2743,11 @@ getutid (struct utmp *id)
{
internal_setutent (false);
if (utmp_fd < 0)
- return NULL;
+ return NULL;
}
- while (read (utmp_fd, &utmp_data, sizeof utmp_data) == sizeof utmp_data)
+
+ utmp *ut = utmp_data;
+ while (read (utmp_fd, ut, sizeof *ut) == sizeof *ut)
{
switch (id->ut_type)
{
@@ -2764,15 +2755,15 @@ getutid (struct utmp *id)
case BOOT_TIME:
case OLD_TIME:
case NEW_TIME:
- if (id->ut_type == utmp_data.ut_type)
- return &utmp_data;
+ if (id->ut_type == ut->ut_type)
+ return ut;
break;
case INIT_PROCESS:
case LOGIN_PROCESS:
case USER_PROCESS:
case DEAD_PROCESS:
- if (strncmp (id->ut_id, utmp_data.ut_id, UT_IDLEN) == 0)
- return &utmp_data;
+ if (strncmp (id->ut_id, ut->ut_id, UT_IDLEN) == 0)
+ return ut;
break;
default:
return NULL;
@@ -2791,16 +2782,16 @@ getutline (struct utmp *line)
{
internal_setutent (false);
if (utmp_fd < 0)
- return NULL;
- }
- while (read (utmp_fd, &utmp_data, sizeof utmp_data) == sizeof utmp_data)
- {
- if ((utmp_data.ut_type == LOGIN_PROCESS ||
- utmp_data.ut_type == USER_PROCESS) &&
- !strncmp (utmp_data.ut_line, line->ut_line,
- sizeof utmp_data.ut_line))
- return &utmp_data;
+ return NULL;
}
+
+ utmp *ut = utmp_data;
+ while (read (utmp_fd, ut, sizeof *ut) == sizeof *ut)
+ if ((ut->ut_type == LOGIN_PROCESS ||
+ ut->ut_type == USER_PROCESS) &&
+ !strncmp (ut->ut_line, line->ut_line, sizeof (ut->ut_line)))
+ return ut;
+
return NULL;
}
@@ -2812,7 +2803,14 @@ pututline (struct utmp *ut)
return;
internal_setutent (true);
if (utmp_fd < 0)
- return;
+ {
+ debug_printf ("error: utmp_fd %d", utmp_fd);
+ return;
+ }
+ debug_printf ("ut->ut_type %d, ut->ut_pid %d, ut->ut_line '%s', ut->ut_id '%s'\n",
+ ut->ut_type, ut->ut_pid, ut->ut_line, ut->ut_id);
+ debug_printf ("ut->ut_user '%s', ut->ut_host '%s'\n",
+ ut->ut_user, ut->ut_host);
/* Read/write to utmp must be atomic to prevent overriding data
by concurrent processes. */
char mutex_name[MAX_PATH];
@@ -2838,18 +2836,18 @@ extern "C"
long gethostid(void)
{
unsigned data[13] = {0x92895012,
- 0x10293412,
- 0x29602018,
- 0x81928167,
- 0x34601329,
- 0x75630198,
- 0x89860395,
- 0x62897564,
- 0x00194362,
- 0x20548593,
- 0x96839102,
- 0x12219854,
- 0x00290012};
+ 0x10293412,
+ 0x29602018,
+ 0x81928167,
+ 0x34601329,
+ 0x75630198,
+ 0x89860395,
+ 0x62897564,
+ 0x00194362,
+ 0x20548593,
+ 0x96839102,
+ 0x12219854,
+ 0x00290012};
bool has_cpuid = false;
sigframe thisframe (mainthread);
@@ -2864,12 +2862,12 @@ long gethostid(void)
{
debug_printf ("486 processor");
if (can_set_flag (0x00200000))
- {
- debug_printf ("processor supports CPUID instruction");
- has_cpuid = true;
- }
+ {
+ debug_printf ("processor supports CPUID instruction");
+ has_cpuid = true;
+ }
else
- debug_printf ("processor does not support CPUID instruction");
+ debug_printf ("processor does not support CPUID instruction");
}
if (has_cpuid)
{
@@ -2877,22 +2875,22 @@ long gethostid(void)
cpuid (&maxf, &unused[0], &unused[1], &unused[2], 0);
maxf &= 0xffff;
if (maxf >= 1)
- {
- unsigned features;
- cpuid (&data[0], &unused[0], &unused[1], &features, 1);
- if (features & (1 << 18))
- {
- debug_printf ("processor has psn");
- if (maxf >= 3)
- {
- cpuid (&unused[0], &unused[1], &data[1], &data[2], 3);
- debug_printf ("Processor PSN: %04x-%04x-%04x-%04x-%04x-%04x",
- data[0] >> 16, data[0] & 0xffff, data[2] >> 16, data[2] & 0xffff, data[1] >> 16, data[1] & 0xffff);
- }
- }
- else
- debug_printf ("processor does not have psn");
- }
+ {
+ unsigned features;
+ cpuid (&data[0], &unused[0], &unused[1], &features, 1);
+ if (features & (1 << 18))
+ {
+ debug_printf ("processor has psn");
+ if (maxf >= 3)
+ {
+ cpuid (&unused[0], &unused[1], &data[1], &data[2], 3);
+ debug_printf ("Processor PSN: %04x-%04x-%04x-%04x-%04x-%04x",
+ data[0] >> 16, data[0] & 0xffff, data[2] >> 16, data[2] & 0xffff, data[1] >> 16, data[1] & 0xffff);
+ }
+ }
+ else
+ debug_printf ("processor does not have psn");
+ }
}
UUID Uuid;
@@ -2906,8 +2904,8 @@ long gethostid(void)
// Unfortunately Windows will sometimes pick a virtual Ethernet card
// e.g. VMWare Virtual Ethernet Adaptor
debug_printf ("MAC address of first Ethernet card: %02x:%02x:%02x:%02x:%02x:%02x",
- Uuid.Data4[2], Uuid.Data4[3], Uuid.Data4[4],
- Uuid.Data4[5], Uuid.Data4[6], Uuid.Data4[7]);
+ Uuid.Data4[2], Uuid.Data4[3], Uuid.Data4[4],
+ Uuid.Data4[5], Uuid.Data4[6], Uuid.Data4[7]);
}
else
{
@@ -2923,16 +2921,16 @@ long gethostid(void)
GetDiskFreeSpace ("C:\\", NULL, NULL, NULL, (DWORD *)&data[11]);
debug_printf ("hostid entropy: %08x %08x %08x %08x "
- "%08x %08x %08x %08x "
- "%08x %08x %08x %08x "
- "%08x",
- data[0], data[1],
- data[2], data[3],
- data[4], data[5],
- data[6], data[7],
- data[8], data[9],
- data[10], data[11],
- data[12]);
+ "%08x %08x %08x %08x "
+ "%08x %08x %08x %08x "
+ "%08x",
+ data[0], data[1],
+ data[2], data[3],
+ data[4], data[5],
+ data[6], data[7],
+ data[8], data[9],
+ data[10], data[11],
+ data[12]);
long hostid = 0x40291372;
// a random hashing algorithm
diff --git a/winsup/cygwin/sysconf.cc b/winsup/cygwin/sysconf.cc
index ac5b3500464..4c253a1c2e3 100644
--- a/winsup/cygwin/sysconf.cc
+++ b/winsup/cygwin/sysconf.cc
@@ -33,14 +33,14 @@ sysconf (int in)
/* FIXME: what's the right value? _POSIX_ARG_MAX is only 4K */
return 1048576;
case _SC_OPEN_MAX:
- return getdtablesize ();
- case _SC_PAGESIZE:
{
long max = getdtablesize ();
if (max < OPEN_MAX)
max = OPEN_MAX;
return max;
}
+ case _SC_PAGESIZE:
+ return getpagesize ();
case _SC_CLK_TCK:
return CLOCKS_PER_SEC;
case _SC_JOB_CONTROL:
diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc
index b42bb140bdc..516cb8d2b81 100644
--- a/winsup/cygwin/thread.cc
+++ b/winsup/cygwin/thread.cc
@@ -288,7 +288,7 @@ List<pthread> pthread::threads;
/* member methods */
pthread::pthread ():verifyable_object (PTHREAD_MAGIC), win32_obj_id (0),
- running (false), suspended (false),
+ running (false), suspended (false),
cancelstate (0), canceltype (0), cancel_event (0),
joiner (NULL), next (NULL), cleanup_stack (NULL)
{
@@ -856,8 +856,8 @@ pthread_cond::pthread_cond (pthread_condattr *attr) :
if (attr)
if (attr->shared != PTHREAD_PROCESS_PRIVATE)
{
- magic = 0;
- return;
+ magic = 0;
+ return;
}
verifyable_mutex_obj = &mtx_in;
@@ -907,7 +907,7 @@ pthread_cond::unblock (const bool all)
{
unsigned long releaseable;
- /*
+ /*
* Block outgoing threads (and avoid simultanous unblocks)
*/
mtx_out.lock ();
@@ -918,19 +918,19 @@ pthread_cond::unblock (const bool all)
unsigned long released;
if (!pending)
- {
- /*
- * Block incoming threads until all waiting threads are released.
- */
- mtx_in.lock ();
-
- /*
- * Calculate releaseable again because threads can enter until
- * the semaphore has been taken, but they can not leave, therefore pending
- * is unchanged and releaseable can only get higher
- */
- releaseable = waiting - pending;
- }
+ {
+ /*
+ * Block incoming threads until all waiting threads are released.
+ */
+ mtx_in.lock ();
+
+ /*
+ * Calculate releaseable again because threads can enter until
+ * the semaphore has been taken, but they can not leave, therefore pending
+ * is unchanged and releaseable can only get higher
+ */
+ releaseable = waiting - pending;
+ }
released = all ? releaseable : 1;
pending += released;
@@ -971,20 +971,20 @@ pthread_cond::wait (pthread_mutex_t mutex, DWORD dwMilliseconds)
rv = pthread::cancelable_wait (sem_wait, dwMilliseconds, false);
mtx_out.lock ();
-
+
if (rv != WAIT_OBJECT_0)
{
/*
* It might happen that a signal is sent while the thread got canceled
* or timed out. Try to take one.
* If the thread gets one than a signal|broadcast is in progress.
- */
+ */
if (WaitForSingleObject (sem_wait, 0) == WAIT_OBJECT_0)
- /*
- * thread got cancelled ot timed out while a signalling is in progress.
- * Set wait result back to signaled
- */
- rv = WAIT_OBJECT_0;
+ /*
+ * thread got cancelled ot timed out while a signalling is in progress.
+ * Set wait result back to signaled
+ */
+ rv = WAIT_OBJECT_0;
}
InterlockedDecrement ((long *)&waiting);
@@ -997,7 +997,7 @@ pthread_cond::wait (pthread_mutex_t mutex, DWORD dwMilliseconds)
mtx_in.unlock ();
mtx_out.unlock ();
-
+
mutex->lock ();
--mutex->condwaits;
@@ -1068,8 +1068,8 @@ pthread_rwlock::pthread_rwlock (pthread_rwlockattr *attr) :
if (attr)
if (attr->shared != PTHREAD_PROCESS_PRIVATE)
{
- magic = 0;
- return;
+ magic = 0;
+ return;
}
if (!pthread_mutex::is_good_object (&verifyable_mutex_obj))
@@ -1129,7 +1129,7 @@ pthread_rwlock::rdlock ()
}
while (writer || waiting_writers)
- {
+ {
pthread_cleanup_push (pthread_rwlock::rdlock_cleanup, this);
++waiting_readers;
@@ -1162,14 +1162,14 @@ pthread_rwlock::tryrdlock ()
{
struct RWLOCK_READER *reader = new struct RWLOCK_READER;
if (reader)
- {
- reader->thread = self;
- add_reader (reader);
- }
+ {
+ reader->thread = self;
+ add_reader (reader);
+ }
else
- result = EAGAIN;
+ result = EAGAIN;
}
-
+
mtx.unlock ();
return result;
@@ -1190,7 +1190,7 @@ pthread_rwlock::wrlock ()
}
while (writer || readers)
- {
+ {
pthread_cleanup_push (pthread_rwlock::wrlock_cleanup, this);
++waiting_writers;
@@ -1220,7 +1220,7 @@ pthread_rwlock::trywrlock ()
result = EBUSY;
else
writer = self;
-
+
mtx.unlock ();
return result;
@@ -1237,10 +1237,10 @@ pthread_rwlock::unlock ()
if (writer)
{
if (writer != self)
- {
- result = EPERM;
- goto DONE;
- }
+ {
+ result = EPERM;
+ goto DONE;
+ }
writer = NULL;
}
@@ -1249,10 +1249,10 @@ pthread_rwlock::unlock ()
struct RWLOCK_READER *reader = lookup_reader (self);
if (!reader)
- {
- result = EPERM;
- goto DONE;
- }
+ {
+ result = EPERM;
+ goto DONE;
+ }
remove_reader (reader);
delete reader;
@@ -1336,13 +1336,13 @@ pthread_rwlock::_fixup_after_fork ()
while (*temp)
{
if ((*temp)->thread == self)
- temp = &((*temp)->next);
+ temp = &((*temp)->next);
else
- {
- struct RWLOCK_READER *cur = *temp;
- *temp = (*temp)->next;
- delete cur;
- }
+ {
+ struct RWLOCK_READER *cur = *temp;
+ *temp = (*temp)->next;
+ delete cur;
+ }
}
}
diff --git a/winsup/cygwin/times.cc b/winsup/cygwin/times.cc
index 44a08831a9a..86e9f634356 100644
--- a/winsup/cygwin/times.cc
+++ b/winsup/cygwin/times.cc
@@ -1,6 +1,6 @@
/* times.cc
- Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+ Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc.
This file is part of Cygwin.
diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc
index 8c16ac64952..1c2a149b8f2 100644
--- a/winsup/cygwin/uinfo.cc
+++ b/winsup/cygwin/uinfo.cc
@@ -122,7 +122,9 @@ uinfo_init ()
cygheap->user.orig_uid = cygheap->user.real_uid = myself->uid;
cygheap->user.orig_gid = cygheap->user.real_gid = myself->gid;
- cygheap->user.impersonation_state = IMP_NONE;
+ cygheap->user.external_token = INVALID_HANDLE_VALUE;
+ cygheap->user.internal_token = INVALID_HANDLE_VALUE;
+ cygheap->user.current_token = INVALID_HANDLE_VALUE;
cygheap->user.set_orig_sid (); /* Update the original sid */
}
diff --git a/winsup/cygwin/wincap.cc b/winsup/cygwin/wincap.cc
index 37ec6ef570f..dbc39132d59 100644
--- a/winsup/cygwin/wincap.cc
+++ b/winsup/cygwin/wincap.cc
@@ -540,7 +540,7 @@ wincapc::init ()
case 0:
caps = &wincap_2000;
break;
-
+
case 1:
caps = &wincap_xp;
break;