Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Collins <rbtcollins@hotmail.com>2002-01-04 06:56:17 +0300
committerRobert Collins <rbtcollins@hotmail.com>2002-01-04 06:56:17 +0300
commitb59c74abba6d2238c4dc58fa7d61b2519f2d0ea8 (patch)
tree5aa3c386ebe83a1646a3494862e6a01437e3c401 /winsup/cygwin
parent9783ce28caf426c5ab39d1d6aefa31cfdb1b8234 (diff)
Merged changes from HEAD
Diffstat (limited to 'winsup/cygwin')
-rw-r--r--winsup/cygwin/CYGWIN_LICENSE18
-rw-r--r--winsup/cygwin/ChangeLog4092
-rw-r--r--winsup/cygwin/ChangeLog-199812
-rw-r--r--winsup/cygwin/ChangeLog-199942
-rw-r--r--winsup/cygwin/ChangeLog-200048
-rw-r--r--winsup/cygwin/Makefile.in140
-rw-r--r--winsup/cygwin/autoload.cc18
-rw-r--r--winsup/cygwin/child_info.h32
-rwxr-xr-xwinsup/cygwin/configure132
-rw-r--r--winsup/cygwin/configure.in2
-rw-r--r--winsup/cygwin/cygerrno.h5
-rw-r--r--winsup/cygwin/cygheap.cc13
-rw-r--r--winsup/cygwin/cygheap.h83
-rw-r--r--winsup/cygwin/cygwin.din33
-rw-r--r--winsup/cygwin/cygwin.sc2
-rw-r--r--winsup/cygwin/dcrt0.cc136
-rw-r--r--winsup/cygwin/debug.cc22
-rw-r--r--winsup/cygwin/debug.h4
-rw-r--r--winsup/cygwin/dir.cc237
-rw-r--r--winsup/cygwin/dlfcn.cc14
-rw-r--r--winsup/cygwin/dll_init.cc3
-rw-r--r--winsup/cygwin/dll_init.h12
-rw-r--r--winsup/cygwin/dlmalloc.c27
-rw-r--r--winsup/cygwin/dtable.cc160
-rw-r--r--winsup/cygwin/dtable.h7
-rw-r--r--winsup/cygwin/environ.cc40
-rw-r--r--winsup/cygwin/environ.h3
-rw-r--r--winsup/cygwin/errno.cc11
-rw-r--r--winsup/cygwin/exceptions.cc23
-rw-r--r--winsup/cygwin/exec.cc47
-rw-r--r--winsup/cygwin/external.cc26
-rw-r--r--winsup/cygwin/fcntl.cc14
-rw-r--r--winsup/cygwin/fhandler.cc535
-rw-r--r--winsup/cygwin/fhandler.h417
-rw-r--r--winsup/cygwin/fhandler_clipboard.cc16
-rw-r--r--winsup/cygwin/fhandler_console.cc46
-rw-r--r--winsup/cygwin/fhandler_dsp.cc22
-rw-r--r--winsup/cygwin/fhandler_floppy.cc7
-rw-r--r--winsup/cygwin/fhandler_mem.cc23
-rw-r--r--winsup/cygwin/fhandler_random.cc11
-rw-r--r--winsup/cygwin/fhandler_raw.cc84
-rw-r--r--winsup/cygwin/fhandler_serial.cc18
-rw-r--r--winsup/cygwin/fhandler_socket.cc118
-rw-r--r--winsup/cygwin/fhandler_tape.cc30
-rw-r--r--winsup/cygwin/fhandler_tty.cc48
-rw-r--r--winsup/cygwin/fhandler_windows.cc11
-rw-r--r--winsup/cygwin/fhandler_zero.cc9
-rw-r--r--winsup/cygwin/fork.cc10
-rw-r--r--winsup/cygwin/glob.c6
-rw-r--r--winsup/cygwin/grp.cc4
-rw-r--r--winsup/cygwin/heap.cc4
-rw-r--r--winsup/cygwin/heap.h2
-rw-r--r--winsup/cygwin/how-cygheap-works.txt2
-rw-r--r--winsup/cygwin/how-to-debug-cygwin.txt45
-rw-r--r--winsup/cygwin/include/cygwin/if.h40
-rw-r--r--winsup/cygwin/include/cygwin/mtio.h8
-rw-r--r--winsup/cygwin/include/cygwin/types.h2
-rw-r--r--winsup/cygwin/include/cygwin/version.h35
-rw-r--r--winsup/cygwin/include/getopt.h34
-rw-r--r--winsup/cygwin/include/glob.h4
-rw-r--r--winsup/cygwin/include/limits.h15
-rw-r--r--winsup/cygwin/include/pthread.h7
-rw-r--r--winsup/cygwin/include/sys/cygwin.h4
-rw-r--r--winsup/cygwin/include/sys/resource.h20
-rw-r--r--winsup/cygwin/include/sys/soundcard.h82
-rw-r--r--winsup/cygwin/include/sys/un.h2
-rw-r--r--winsup/cygwin/init.cc2
-rw-r--r--winsup/cygwin/ioctl.cc13
-rw-r--r--winsup/cygwin/lib/cygwin_crt0.c3
-rw-r--r--winsup/cygwin/lib/dll_main.cc2
-rw-r--r--winsup/cygwin/lib/getopt.c14
-rw-r--r--winsup/cygwin/localtime.cc5
-rw-r--r--winsup/cygwin/malloc_wrapper.cc2
-rw-r--r--winsup/cygwin/miscfuncs.cc51
-rw-r--r--winsup/cygwin/mmap.cc14
-rw-r--r--winsup/cygwin/net.cc719
-rw-r--r--winsup/cygwin/ntdll.h9
-rw-r--r--winsup/cygwin/passwd.cc12
-rw-r--r--winsup/cygwin/path.cc692
-rw-r--r--winsup/cygwin/path.h17
-rw-r--r--winsup/cygwin/perthread.h21
-rw-r--r--winsup/cygwin/pinfo.cc31
-rw-r--r--winsup/cygwin/pipe.cc87
-rw-r--r--winsup/cygwin/poll.cc18
-rw-r--r--winsup/cygwin/pwdgrp.h24
-rw-r--r--winsup/cygwin/regexp/regerror.c28
-rw-r--r--winsup/cygwin/regexp/regexp.3321
-rw-r--r--winsup/cygwin/regexp/regexp.c1321
-rw-r--r--winsup/cygwin/regexp/regsub.c87
-rw-r--r--winsup/cygwin/resource.cc16
-rw-r--r--winsup/cygwin/sec_acl.cc6
-rw-r--r--winsup/cygwin/security.cc49
-rw-r--r--winsup/cygwin/security.h18
-rw-r--r--winsup/cygwin/select.cc442
-rw-r--r--winsup/cygwin/shared.cc43
-rw-r--r--winsup/cygwin/shared_info.h29
-rw-r--r--winsup/cygwin/shortcut.c2
-rw-r--r--winsup/cygwin/signal.cc3
-rw-r--r--winsup/cygwin/sigproc.cc57
-rw-r--r--winsup/cygwin/sigproc.h12
-rw-r--r--winsup/cygwin/spawn.cc69
-rw-r--r--winsup/cygwin/strace.cc2
-rw-r--r--winsup/cygwin/sync.h10
-rw-r--r--winsup/cygwin/syscalls.cc642
-rw-r--r--winsup/cygwin/sysconf.cc4
-rw-r--r--winsup/cygwin/syslog.cc21
-rw-r--r--winsup/cygwin/termios.cc133
-rw-r--r--winsup/cygwin/test.c165
-rw-r--r--winsup/cygwin/thread.cc148
-rw-r--r--winsup/cygwin/thread.h3
-rw-r--r--winsup/cygwin/uinfo.cc99
-rw-r--r--winsup/cygwin/uname.cc24
-rw-r--r--winsup/cygwin/wincap.cc36
-rw-r--r--winsup/cygwin/wincap.h8
-rw-r--r--winsup/cygwin/window.cc37
-rw-r--r--winsup/cygwin/winsup.h31
116 files changed, 3565 insertions, 9216 deletions
diff --git a/winsup/cygwin/CYGWIN_LICENSE b/winsup/cygwin/CYGWIN_LICENSE
index f10b01f56..53369a297 100644
--- a/winsup/cygwin/CYGWIN_LICENSE
+++ b/winsup/cygwin/CYGWIN_LICENSE
@@ -16,7 +16,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*** NOTE ***
-In accordance with section 10 of the GPL, Cygnus permits programs whose
+In accordance with section 10 of the GPL, Red Hat permits programs whose
sources are distributed under a license that complies with the Open
Source definition to be linked with libcygwin.a without libcygwin.a
itself causing the resulting program to be covered by the GNU GPL.
@@ -31,16 +31,8 @@ for the cygwin DLL.
See http://www.opensource.org/osd.html for the precise Open Source
Definition referenced above.
-If you have questions about any of the above or would like to arrange
-for other licensing terms, please contact Cygnus using the information
-given below:
+Red Hat sells a special Cygwin License for customers who are unable to
+provide their application in open source code form. For more
+information, please see: http://www.redhat.com/software/tools/cygwin/,
+or call 866-2REDHAT ext. 3007
- Cygnus Solutions
- 1325 Chesapeake Terrace
- Sunnyvale, CA 94089
- USA
-
- +1 408 542 9600
- hotline: +1 408 542 9601
- email: info@cygnus.com
- fax: +1 408 542 9699
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 59a42075d..65f120d0e 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -26,7 +26,6 @@ Mon Oct 8 7:41:00 2001 Robert Collins <rbtcollins@hotmail.com>
terminates.
Thu Oct 4 14:12:00 2001 Robert Collins <rbtcollins@hotmail.com>
-
* cygserver.cc (request_loop): Make static.
(main): Use new cache constructor syntax.
Start cache worker threads.
@@ -250,4079 +249,18 @@ Tue Sep 25 16:22:00 2001 Robert Collins <rbtcollins@hotmail.com>
* include/sys/ipc.h: New file.
* include/sys/shm.h: New file.
-Mon Oct 1 16:52:23 2001 Christopher Faylor <cgf@cygnus.com>
-
- * dtable.h (dtable::build_fhandler): Make path_conv parameter
- non-optional.
- (dtable::init_std_file_from_handle): Eliminate name parameter.
- * dtable.cc (stdio_init): Don't pass bogus name to
- init_std_file_from_handle. The function will figure out the name
- itself.
- (dtable::init_std_file_from_handle): Eliminate name parameter. Assume
- that we're always called with an appropriate fd. Pass name as NULL if
- we can't simply figure it out from context.
- (cygwin_attach_handle_to_fd): Pass path_conv argument to
- build_fhandler.
- (dtable::build_fhandler): Make path_conv argument mandatory. Eliminate
- specific call to get_device_number. With unknown device names, set
- name from handle context for parsing by path_conv.
- (dtable::build_fhandler): Pass path_conv argument to build_fhandler.
- * path.h (path_conv::set_isdisk): Set disk device type.
- (path_conv::is_device): Don't consider FH_DISK a "device".
- * syscalls.cc (_open): Pass path_conv argument by reference.
- (stat_worker): Ditto.
- (_rename): Use path_conv operators. Add bounds to DeleteFile/MoveFile
- for loop.
-
-Mon Oct 1 14:25:00 2001 Charles Wilson <cwilson@ece.gatech.edu>
-
- * cygwin.din: export strtoll and strtoull
-
-Sun Sep 30 22:51:41 2001 Christopher Faylor <cgf@cygnus.com>
-
- Add "path.h" include throughout, where needed. Use new path_conv
- methods and operators to simplify testing for directory and attributes,
- throughout.
- * path.h (path_conv::exists): New method.
- (path_conv::has_attribute): Ditto.
- (path_conv::isdir): Ditto.
- (path_conv::DWORD &): New operator.
- (path_conv::int &): Ditto.
- * dir.cc (rmdir): Eliminate a goto.
- * dtable.cc (dtable::build_fhandler): Accept opt and suffix info for
- path_conv.check. Return fh == NULL on path_conv error. Pass unit to
- set_name as appropriate.
- (dtable::reset_unix_path_name): New method.
- * dtable.h (dtable): Declare new method. Reflect arg changes to
- build_fhandler.
- * fhandler.cc (fhandler_disk_dummy_name): Eliminate.
- (fhandler_base::set_name): Expect paths to be NULL. Build
- unix_path_name from win32_path_name when it is a device.
- (fhandler_base::reset_unix_path_name): New method.
- (fhandler_base::raw_read): Report EISDIR when ERROR_INVALID_FUNCTION
- or ERROR_INVALID_PARAMETER and reading a directory.
- (fhandler_disk_file::fstat): Don't call stat_dev since we should now
- never be calling fhandler_disk_file methods with devices.
- (fhandler_base::fhandler_base): Clear {unix,win32}_path_name.
- (fhandler_base::~fhandler_base): Always free {unix,win32}_path_name.
- (fhandler_disk_file::fhandler_disk_file): Remove set_no_free_names
- kludge.
- (fhandler_disk_file::open): Ditto.
- * fhandler.h (fhandler_base::no_free_names): Eliminate.
- (fhandler_base::set_no_free_names): Ditto.
- * fhandler_tty.cc (fhandler_tty_slave::fhandler_tty_slave): Don't set
- unix_path_name here.
- * path.cc (fchdir): Lock fd table throughout. Use new
- dtable::reset_unix_path_name method to reset path.
- * syscalls.cc (stat_worker): Reorganize to always call fstat method.
- Pass path_conv method to fhandler_*::open.
- (chroot): Elminate a goto.
-
-Sun Sep 30 17:37:43 2001 Christopher Faylor <cgf@cygnus.com>
-
- * environ.cc (winenv): Allocate exact amount of space needed for forced
- windows environment variable rather than just using MAX_PATH.
-
-Sun Sep 30 17:10:18 2001 Christopher Faylor <cgf@cygnus.com>
-
- * Makefile.in: Depend on stamp to ensure rebuilding. Remove stamp file
- when we've just built the DLL.
-
-Mon Oct 1 00:34:00 2001 Robert Collins <rbtcollins@hotmail.com>
-
- * thread.cc (pthread_cond_dowait): Hopefully eliminate a race on multiple thread
- wakeups.
-
-Sat Sep 29 18:26:00 2001 Robert Collins <rbtcollins@hotmail.com>
-
- * pthread.cc (pthread_cond_timedwait): Deleted - exported from thread.cc.
- (pthread_cond_wait): Deleted - exported from thread.cc.
- * thread.cc (pthread_cond::BroadCast): Update to use the new syntax for
- verifyable_object_isvalid ().
- (pthread_cond::Signal): Ditto. Also attempt to fix the lost signal race
- with pthread_cond::TimedWait().
- (check_valid_pointer): Change definiton to void const *.
- (verifyable_object_isvalid): Add new parameter to allow identification of
- static initializers, and return a enum rather than magic numbers.
- (__pthread_create): Ditto.
- (__pthread_cleanup): Ditto.
- (__pthread_attr_init): Ditto.
- (__pthread_attr_getinheritsched): Ditto.
- (__pthread_attr_getschedparam): Ditto.
- (__pthread_attr_getschedpolicy): Ditto.
- (__pthread_attr_getscope): Ditto.
- (__pthread_attr_setdetachstate): Ditto.
- (__pthread_attr_getdetachstate): Ditto.
- (__pthread_attr_setinheritsched): Ditto.
- (__pthread_attr_setschedparam): Ditto.
- (__pthread_attr_setschedpolicy): Ditto.
- (__pthread_attr_setscope): Ditto.
- (__pthread_attr_setstacksize): Ditto.
- (__pthread_attr_getstacksize): Ditto.
- (__pthread_attr_destroy): Ditto.
- (__pthread_join): Ditto.
- (__pthread_detach): Ditto.
- (__pthread_suspend): Ditto.
- (__pthread_continue): Ditto.
- (__pthread_getschedparam): Ditto.
- (__pthread_getsequence_np): Ditto.
- (__pthread_key_create): Ditto.
- (__pthread_key_delete): Ditto.
- (__pthread_setschedparam): Ditto.
- (__pthread_setspecific): Ditto.
- (__pthread_getspecific): Ditto.
- (__pthread_cond_destroy): Ditto.
- (__pthread_cond_init): Ditto.
- (__pthread_cond_broadcast): Ditto.
- (__pthread_cond_signal): Ditto.
- (__pthread_condattr_init): Ditto.
- (__pthread_condattr_getpshared): Ditto.
- (__pthread_condattr_setpshared): Ditto.
- (__pthread_condattr_destroy): Ditto.
- (__pthread_kill): Ditto.
- (__pthread_mutex_init): Ditto.
- (__pthread_mutex_getprioceiling): Ditto.
- (__pthread_mutex_lock): Ditto.
- (__pthread_mutex_trylock): Ditto.
- (__pthread_mutex_unlock): Ditto.
- (__pthread_mutex_destroy): Ditto.
- (__pthread_mutex_setprioceiling): Ditto.
- (__pthread_mutexattr_getprotocol): Ditto.
- (__pthread_mutexattr_getpshared): Ditto.
- (__pthread_mutexattr_gettype): Ditto.
- (__pthread_mutexattr_init): Ditto.
- (__pthread_mutexattr_destroy): Ditto.
- (__pthread_mutexattr_setprotocol): Ditto.
- (__pthread_mutexattr_setprioceiling): Ditto.
- (__pthread_mutexattr_getprioceiling): Ditto.
- (__pthread_mutexattr_setpshared): Ditto.
- (__pthread_mutexattr_settype): Ditto.
- (__sem_init): Ditto.
- (__sem_destroy): Ditto.
- (__sem_wait): Ditto.
- (__sem_trywait): Ditto.
- (__sem_post): Ditto.
- (__pthread_cond_dowait): New function, contains core logic from
- __pthread_cond_wait and __pthread_cond_timedwait. Decrement (*cond)->waiting
- before reentering the cond access mutex to allow detection of lost signals.
- (__pthread_cond_timedwait): Rename to pthread_cond_timedwait, and call
- __pthread_cond_dowait after calculating the wait length.
- (__pthread_cond_wait): Rename to pthread_cond_wait, and call
- __pthread_cond_dowait.
- * thread.h: New enum for use with verifyable_object_isvalid.
- Remove the extern exporting of __pthread_cond_timedwait and __pthread_cond_wait.
-
-Fri Sep 28 21:18:50 2001 Christopher Faylor <cgf@cygnus.com>
-
- * pipe.cc (fhandler_pipe::fixup_after_fork): New method.
- * fhandler.h (fhandler_pipe::fixup_after_fork): Declare new method.
-
-Fri Sep 28 03:23:04 2001 Christopher Faylor <cgf@cygnus.com>
-
- * passwd.cc (read_etc_passwd): Bother with unlocking when not
- in cygwin initialization.
- * grp.cc (read_etc_group): Ditto.
-
-Fri Sep 28 02:57:03 2001 Christopher Faylor <cgf@cygnus.com>
-
- * passwd.cc (read_etc_passwd): Don't bother with locking when
- in cygwin initialization since there is only one thread.
- * grp.cc (read_etc_group): Ditto.
-
-Fri Sep 28 01:50:09 2001 Christopher Faylor <cgf@cygnus.com>
-
- * pipe.cc (fhandler_pipe::hit_eof): Return correct value when there is
- no EOF event available.
-
-Sat Sep 28 00:34:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * mmap.cc (mmap): Move setting the access after evaluating fd.
- Remove useless comment. Explain copy-on-write problem of 9x
- more detailed. Don't set access to FILE_MAP_COPY on 9x only
- when anonymous mapping is requested.
- (fhandler_disk_file::mmap): Remove useless device check.
- Add debug output.
-
-Fri Sep 27 07:35:00 2001 Robert Collins <rbtcollins@hotmail.com>
-
- * Makefile.in: Only stamp winver_stamp on success.
-
-Wed Sep 26 16:02:35 2001 Christopher Faylor <cgf@cygnus.com>
-
- * select.cc (peek_pipe): REALLY only grab mutex when we actually got
- something from the pipe.
-
-Tue Sep 25 21:25:00 2001 Robert Collins <rbtcollins@hotmail.com>
-
- * thread.cc (pthread_cond::BroadCast): Use address with verifyable_object_isvalid().
- (pthread_cond::Signal): Ditto.
- (__pthread_create): Ditto.
- (__pthread_cleanup): Ditto.
- (__pthread_attr_init): Ditto.
- (__pthread_attr_getinheritsched): Ditto.
- (__pthread_attr_getschedparam): Ditto.
- (__pthread_attr_getschedpolicy): Ditto.
- (__pthread_attr_getscope): Ditto.
- (__pthread_attr_setdetachstate): Ditto.
- (__pthread_attr_getdetachstate): Ditto.
- (__pthread_attr_setinheritsched): Ditto.
- (__pthread_attr_setschedparam): Ditto.
- (__pthread_attr_setschedpolicy): Ditto.
- (__pthread_attr_setscope): Ditto.
- (__pthread_attr_setstacksize): Ditto.
- (__pthread_attr_getstacksize): Ditto.
- (__pthread_attr_destroy): Ditto.
- (__pthread_join): Ditto.
- (__pthread_detach): Ditto.
- (__pthread_suspend): Ditto.
- (__pthread_continue): Ditto.
- (__pthread_getschedparam): Ditto.
- (__pthread_getsequence_np): Ditto.
- (__pthread_key_create): Ditto.
- (__pthread_key_delete): Ditto.
- (__pthread_setschedparam): Ditto.
- (__pthread_setspecific): Ditto.
- (__pthread_getspecific): Ditto.
- (__pthread_cond_destroy): Ditto.
- (__pthread_cond_init): Ditto.
- (__pthread_cond_broadcast): Ditto.
- (__pthread_cond_signal): Ditto.
- (__pthread_cond_timedwait): Ditto.
- (__pthread_cond_wait): Ditto.
- (__pthread_condattr_init): Ditto.
- (__pthread_condattr_getpshared): Ditto.
- (__pthread_condattr_setpshared): Ditto.
- (__pthread_condattr_destroy): Ditto.
- (__pthread_kill): Ditto.
- (__pthread_mutex_init): Ditto.
- (__pthread_mutex_getprioceiling): Ditto.
- (__pthread_mutex_lock): Ditto.
- (__pthread_mutex_trylock): Ditto.
- (__pthread_mutex_unlock): Ditto.
- (__pthread_mutex_destroy): Ditto.
- (__pthread_mutex_setprioceiling): Ditto.
- (__pthread_mutexattr_getprotocol): Ditto.
- (__pthread_mutexattr_getpshared): Ditto.
- (__pthread_mutexattr_gettype): Ditto.
- (__pthread_mutexattr_init): Ditto.
- (__pthread_mutexattr_destroy): Ditto.
- (__pthread_mutexattr_setprotocol): Ditto.
- (__pthread_mutexattr_setprioceiling): Ditto.
- (__pthread_mutexattr_getprioceiling): Ditto.
- (__pthread_mutexattr_setpshared): Ditto.
- (__pthread_mutexattr_settype): Ditto.
- (__sem_init): Ditto.
- (__sem_destroy): Ditto.
- (__sem_wait): Ditto.
- (__sem_trywait): Ditto.
- (__sem_post): Ditto.
- (verifyable_object_isvalid): Recieve a pointer to a pointer for verification.
- (__pthread_mutexattr_getprotocol): Fix typo in magic number.
- (__pthread_mutexattr_getpshared): Ditto.
- (__pthread_mutexattr_gettype): Ditto.
- * thread.h (verifyable_object_isvalid): Change prototype to recieve a pointer to a
- pointer for verification.
- * include/pthread.h: Fix typo for __cleanup_routine_type typedef. (Contrib from Net).
-
-Tue Sep 25 02:09:42 2001 Christopher Faylor <cgf@redhat.com>
-
- * select.cc (fhandler_tty_common::ready_for_read): Rewrite to correctly
- call peek_pipe.
-
-Mon Sep 24 18:46:39 2001 Christopher Faylor <cgf@cygnus.com>
-
- * select.cc (peek_pipe): Only grab mutex when we actually got something
- from the pipe.
-
-Mon Sep 24 17:41:03 2001 Christopher Faylor <cgf@redhat.com>
-
- * fhandler.h (fhandler_pipe::hit_eof): New method.
- (writepipe_exists): New class element.
- (orig_pid): Ditto.
- (id): Ditto.
- (is_slow): Eliminate.
- * pipe.cc (fhandler_pipe::set_close_on_exec): Set inheritance on
- writepipe_exists, if it exists.
- (fhandler_pipe::hit_eof): New method, modelled after tty.
- (fhandler_pipe::dup): Duplicate writepipe_exists, if it exists.
- (make_pipe): Set up a dummy event for pipes on windows 9x. The
- nonexistence of this event means that the write side of the
- pipe has closed.
- (_dup): Move to syscalls.cc
- (_dup2): Ditto.
-
- * dtable.cc (dtable::build_fhandler): Fill out set_names here, if
- appropriate.
- * syscalls.cc (_open): Call set_names in build_fhandler.
-
-
-Sun Sep 23 16:55:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * syscalls.cc (_open): Set name in fhandler object after successful
- creation.
- (stat_dev): Set device type to block device in FH_FLOPPY case.
-
-Sun Sep 23 11:15:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * dtable.cc (dtable::build_fhandler): Initialize unit when using
- optional path_conv argument.
-
-Sat Sep 22 17:33:45 2001 Christopher Faylor <cgf@cygnus.com>
- Corinna Vinschen <corinna@vinschen.de>
-
- * dtable.cc (dtable::build_fhandler): Accept an optional path_conv
- argument. If available, use this to calculate path name and device
- number.
- * dtable.h (dtable): Reflect above change.
- * fhandler.h (fhandler_base): Declare virtual method which accepts
- path_conv rather than path string as first argument.
- * fhandler.cc (fhandler_base::open): Define above new method.
- * syscalls.cc (_open): Set aside a path_conv variable for use in
- build_fhandler and subsequent call to open.
-
-Sat Sep 22 12:44:57 2001 Christopher Faylor <cgf@cygnus.com>
-
- * exceptions.cc (setup_handler): Always relinquish lock after we've
- interrupted.
- * fhandler.cc: Move pipe methods to pipe.cc.
- * fhandler.h (fhandler_pipe): Add new methods.
- * fork.cc (sync_with_parent): Make error messages more informative.
- * pipe.cc (fhandler_pipe::fhandler_pipe): Move here from fhandler.cc.
- (fhandler_pipe::lseek): Ditto.
- (fhandler_pipe::set_close_on_exec): New method.
- (fhandler_pipe::read): Ditto.
- (fhandler_pipe::close): Ditto.
- (fhandler_pipe::dup): Ditto.
- (make_pipe): Create the guard mutex on the read side of the pipe.
- * select.cc (peek_pipe): Use guard_mutex to discover if we have the
- right to read on this pipe.
- (fhandler_pipe::readh_for_read): Pass the read pipe guard mutex to
- peek_pipe.
- * syscalls.cc (_read): Always detect signal catchers, for now.
-
- * debug.cc (makethread): Eliminate hack to make thread inheritable.
- * sigproc.cc (subproc_init): Don't use hack to make thread inheritable.
-
-Thu Sep 20 16:48:44 2001 Christopher Faylor <cgf@cygnus.com>
-
- * fhandler.cc (fhandler_base::set_inheritance): Just use
- DUPLICATE_CLOSE_SOURCE to change inheritance. Eliminate all other
- logic dealing with closed handles.
- * fhandler.h (fhandler_base::set_inheritance): Reflect above change.
- * fhandler_tty.cc (fhandler_tty_common::set_close_on_exec): Ditto.
-
-Thu Sep 20 13:34:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * fhandler_socket.cc (fhandler_socket::fixup_after_exec): Close
- socket only when not using Winsock2.
-
-Thu Sep 20 13:20:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * fhandler.h (fhandler_socket::fixup_after_exec): Remove inline
- implementation.
- (fhandler_dev_raw::fixup_after_exec): Ditto.
- * fhandler_raw.cc (fhandler_dev_raw::fixup_after_fork): Don't
- duplicate buffer on fork to avoid memory leak.
- (fhandler_dev_raw::fixup_after_exec): New implementation equal to
- former fixup_after_fork() implementation.
- * fhandler_socket.cc (fhandler_socket::fixup_after_fork): Do
- nothing when not using Winsock2.
- (fhandler_socket::fixup_after_exec): New implementation.
- (fhandler_socket::set_close_on_exec): Never call set_inheritance().
-
-Thu Sep 20 9:55:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * fhandler.cc (fhandler_base::set_inheritance): If available,
- use SetHandleInformation() to set inheritance.
- * wincap.cc: Set flag has_set_handle_information_on_console_handles
- appropriately.
- * wincap.h: Add flag has_set_handle_information_on_console_handles.
-
-Wed Sep 19 12:24:09 2001 Christopher Faylor <cgf@cygnus.com>
-
- * lib/getopt.c (__progname): Don't declare if not compiling for cygwin.
-
-Wed Sep 19 18:07:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * lib/getopt.c (getopt_long): Avoid compiler warning.
-
-Wed Sep 19 11:52:42 2001 Christopher Faylor <cgf@cygnus.com>
-
- * lib/getopt.c: Use __progname==__argv[0] when not compiling for cygwin.
-
- * scandir.cc (scandir): Use correct default when compar == NULL.
-
-Wed Sep 19 17:49:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * fhandler_socket.cc (fhandler_socket::fhandler_socket): Revert
- memory allocation to use cmalloc again.
-
-Tue Sep 18 21:04:26 2001 Christopher Faylor <cgf@cygnus.com>
-
- * cygwin.din (__argv): Export.
- (__argc): Ditto.
- (__progname): Ditto.
- * include/getopt.h (getopt_long): constify arguments.
- * lib/getopt.c: Import new file from NetBSD.
-
-Tue Sep 18 18:21:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * mmap.cc (mmap): Don't reuse anonymous memory in MAP_FIXED case.
-
-Mon Sep 17 17:29:25 2001 Christopher Faylor <cgf@cygnus.com>
-
- * include/io.h: Add access declaration.
-
-Mon Sep 17 14:04:27 2001 Christopher Faylor <cgf@cygnus.com>
-
- * syscalls.cc (rmdir): Set cwd to some other location if attempting to
- rmdir current working directory.
-
-Sun Sep 16 23:04:31 2001 Christopher Faylor <cgf@cygnus.com>
-
- * dtable.h (not_open): Assure inline.
- * fhandler.h (operator []): Make const.
-
-Sun Sep 16 23:02:57 2001 Robert Collins <rbtcollins@hotmail.com>
-
- * sync.cc (muto::~muto): Fix typo which stopped muto event handle from
- ever being closed.
-
-2001-09-16 Egor Duda <deo@logos-m.ru>
-
- * path.cc (symlink): Check arguments for validity.
- (getcwd): Ditto.
- * syscalls.cc (ftruncate): Ditto.
- * times.cc (times): Ditto.
- * uname.cc (uname): Ditto.
-
-Sat Sep 15 22:54:49 2001 Christopher Faylor <cgf@cygnus.com>
-
- * net.cc (dup_servent_ptr): Detect old Windows 95 misaligned structure
- and realign appropriately.
-
-Sat Sep 15 00:28:40 2001 Christopher Faylor <cgf@cygnus.com>
-
- * Makefile.in: Generate libcygwin.a during the link pass rather than as
- a separate dlltool step.
- * dcrt0.cc (_dll_crt0): pppid_handle could be NULL. Don't close it if
- so.
-
-Fri Sep 14 20:48:18 2001 Christopher Faylor <cgf@cygnus.com>
-
- * dcrt0.cc (dll_crt0_1): Create vfork main storage here so that it can
- be queried in waitsig later.
- * sigproc.cc (wait_sig): Don't deliver a signal if in a vfork.
- * sigproc.h (sigframe::init): New method.
- (sigframe): Use init.
- * perthread.h: Declare main_vfork.
- * fork.cc (vfork): Deliver all signals on parent return from vfork.
-
-Fri Sep 14 10:21:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * dcrt0.cc (_dll_crt0()): Don't call wincap.init() here.
-
-Fri Sep 14 00:37:54 2001 Christopher Faylor <cgf@cygnus.com>
-
- * fork.cc (vfork): Avoid recursive vforks.
-
-Fri Sep 14 00:18:52 2001 Christopher Faylor <cgf@cygnus.com>
-
- * fhandler.h (fhandler_pipe::is_slow): Return true only if pipes are
- reliable (i.e., not Win9x).
- * wincap.cc: Make statics NO_COPY to avoid fork overhead.
-
-Thu Sep 13 23:01:00 2001 Christopher Faylor <cgf@cygnus.com>
-
- * grp.cc (read_etc_group): Just reuse group_buf storage for subsequent
- reread of /etc/group.
- * passwd.cc (read_etc_passwd): Just reuse passwd_buf storage for
- subsequent reread of /etc/passwd.
-
-Thu Sep 13 20:46:05 2001 Christopher Faylor <cgf@cygnus.com>
-
- * cygheap.cc (dup_now): New function.
- (cygheap_setup_for_child): Accept new argument controlling whether to
- delay copying of cygheap to shared memory region.
- (cygheap_setup_for_child_cleanup): Accept new arguments controlling
- whether to copy cygheap at this point.
- * cygheap.h: Reflect above changes.
- * fork.cc (fork_parent): Break copying of cygheap into two parts when
- fork_fixup is required so that the child can see the parent's changes.
- (vfork): Do stack cleanup prior to forcing a fork error.
- * spawn.cc (spawn_guts): Ditto.
-
-Thu Sep 13 17:14:59 2001 Christopher Faylor <cgf@cygnus.com>
-
- * cygheap.cc (ccalloc): Pass correct length to creturn so that
- cygheap_max is correctly calculated.
-
-Wed Sep 12 21:06:38 2001 Christopher Faylor <cgf@cygnus.com>
-
- * sync.cc (muto::acquire): Fix while/if typo.
-
-Wed Sep 12 23:06:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * wincap.cc (wincapc::init): Simplify W2K/XP case.
-
-Wed Sep 12 23:02:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * wincap.cc (wincapc::init): Set os name to "NT" on XP, too.
-
-Wed Sep 12 19:00:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * Makefile.in: Build wincap.o.
- * wincap.cc: New file.
- * wincap.h: Ditto.
- * autoload.cc: Add dynamic load statement for `CreateHardLinkA'.
- * dcrt0.cc (os_being_run): Eliminated.
- (osname): Ditto.
- (iswinnt): Ditto.
- (set_os_type): Ditto.
- (dll_crt0_1): Call wincap.init() instead of set_os_type().
- (_dll_crt0): Ditto.
- * environ.cc (set_chunksize): New function.
- (parse_thing): `forkchunk' setting now invokes function `set_chunksize'.
- * fork.cc (chunksize): Eliminated. Moved to be member of wincap.
- * host_dependent.h: Removed.
- * syscalls.cc (_link): Try using `CreateHardLinkA' first, if available.
- * cygheap.cc, dcrt0.cc, delqueue.cc, dir.cc,
- environ.cc, fhandler.cc, fhandler.h, fhandler_console.cc,
- fhandler_mem.cc, fork.cc, mmap.cc, net.cc, pinfo.cc, pinfo.h,
- security.cc, syscalls.cc, sysconf.cc, syslog.cc, thread.cc,
- times.cc, tty.cc, uinfo.cc, uname.cc, winsup.h: Use new wincap
- capability check throughout.
- * winsup.h: Include wincap.h. Eliminate extern declarations of
- `os_being_run' and `iswinnt'. Eliminate `os_type" definition.
- * include/cygwin/version.h: Bump version to 1.3.4.
-
-Wed Sep 12 01:03:36 2001 Christopher Faylor <cgf@cygnus.com>
-
- * exceptions.cc (call_signal_handler_now): Add additional guard against
- inappropriately calling signal handler.
- * syscalls.cc (_read): Reset errno if not exiting due to signal.
-
-Wed Sep 12 13:03:00 2001 Robert Collins <rbtcollins@hotmail.com>
-
- * autoload.cc (LoadDLLfuncEx): Auto load TryEnterCriticalSection - it's
- an NT only call.
- * thread.cc (pthread_cond::TimedWait): Use critical sections for NT.
- (pthread_cond::fixup_after_fork): Don't detect bad apps.
- (pthread_mutex::pthread_mutex): Use critical sections for NT.
- (pthread_mutex::~pthread_mutex): Ditto.
- (pthread_mutex::Lock): Ditto.
- (pthread_mutex::TryLock): Ditto.
- (pthread_mutex::UnLock): Ditto.
- (pthread_mutex::fixup_after_fork): Ditto. Also do not detect bad apps.
- (__pthread_mutex_trylock): Move WIN32 specific test into the class
- method.
- (__pthread_mutex_destroy): Prevent dereferencing passed pointer without
- valid address.
- * thread.h (pthread_mutex): Use critical sections for NT.
-
-Tue Sep 11 21:55:37 2001 Christopher Faylor <cgf@cygnus.com>
-
- * sigproc.h (sigframe::unregister): Return true/false whether this
- frame is capable of responding to signals.
- * exceptions.cc (sigframe::call_signal_handler): Don't call signal
- handler if it is not armed for this thread.
-
-Tue Sep 11 11:23:10 2001 Christopher Faylor <cgf@cygnus.com>
-
- * cygwin.din: Remove cygwin_getshared.
- * shared.cc: Ditto.
- * include/cygwin/version.h: Bump API minor number.
-
-Tue Sep 11 11:14:11 2001 Dmitry Timoshkov <dmitry@baikal.ru>
-
- * dtable.cc (dtable::build_fhandler): Fix incorrect test for socket.
-
-Tue Sep 11 21:22:00 2001 Robert Collins <rbtcollins@hotmail.com>
-
- * thread.cc (pthread_cond::~pthread_cond): Fix incorrect use of
- InterlockExchangePointer.
- (pthread_mutex::~pthread_mutex): Ditto.
- (semaphore::~semaphore): Ditto.
-
-Tue Sep 11 18:15:00 2001 Robert Collins <rbtcollins@hotmail.com>
-
- * dcrt0.cc (cygwin_finished_initializing): Copy _mtinterf on fork.
- * fork.cc (fork_child): Fixup thread-related structures after fork.
- * thread.cc (MTinterface::Init): Initialise the new mutex, condition
- and semaphore lists.
- (MTinterface::fixup_after_fork): Iterate through each list and fixup
- the objects.
- (pthread_cond::pthread_cond): Add this to the condition list.
- (pthread_cond::~pthread_cond): Remove this from the condition list.
- (pthread_cond::fixup_after_fork): Recreate as best we can the pre-fork
- state.
- (pthread_mutex::pthread_mutex): Add this to the mutex list.
- (pthread_mutex::~pthread_mutex): Remove this from the mutex list.
- (pthread_mutex::fixup_after_fork): Recreate as best we can the pre-fork
- state.
- (semaphore::semaphore): Store the initial value, and add this to the
- semaphore list.
- (semaphore::~semaphore): Remove this from the semaphore list.
- (semaphore::Post): Increment the current semaphore value.
- (semaphore::TryWait): Decrement the current semaphore value.
- (semaphore::Wait): Ditto.
- (semaphore::fixup_after_fork): Recreate the pre-fork state as best we
- can.
- * thread.h (pthread_mutex): New members to allow fixup_after_fork.
- (pthread_cond): Ditto.
- (semaphore): Ditto.
- (MTinterface): New list heads for tracking conds and semaphores.
-
-Sun Sep 9 22:11:27 2001 Christopher Faylor <cgf@cygnus.com>
-
- * dtable.cc (dtable::fixup_after_fork): Use SetStdHandle appropriately
- on inherited fds.
-
-Sun Sep 9 20:09:11 2001 Christopher Faylor <cgf@cygnus.com>
-
- * sigproc.cc (NZOMBIES): Reduce substantially to minimize memory use.
-
-Mon Sep 10 08:28:00 2001 Robert Collins <rbtcollins@hotmail.com>
-
- * thread.h (MT_Interface): Remove pshared mutex array. Add a
- threadsafe list for mutex tracking (for fixup after fork).
- * thread.cc (MTInterface::Init): Remove pshared mutex array.
- (pthread_mutex::pthread_mutex): Remove pshared mutex functionality.
- Fail with EINVAL on attempts to use pshared functionality.
- (__pthread_mutex_getpshared): Remove.
- (__pthread_cond_timedwait): Remove pshared mutex functionality.
- (__pthread_cond_wait): Ditto.
- (__pthread_mutex_init): Ditto.
- (__pthread_mutex_getprioceiling): Ditto.
- (__pthread_mutex_lock): Ditto.
- (__pthread_mutex_trylock): Ditto.
- (__pthread_mutex_unlock): Ditto.
- (__pthread_mutex_destroy): Ditto.
- (__pthread_mutex_setprioceiling): Ditto.
- (__pthread_mutexattr_setpshared): Ditto.
-
-Sun Sep 9 23:09:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * pwdgrp.h (pwdgrp_check::set_last_modified): Call GetFileTime()
- instead of GetFileInformationByHandle().
-
-Sun Sep 9 15:59:53 2001 Christopher Faylor <cgf@cygnus.com>
-
- * heap.h (inheap): Rewrite macro to accomodate removal of brk macros
- below.
-
-Sun Sep 9 15:02:44 2001 Christopher Faylor <cgf@cygnus.com>
-
- * cygheap.cc (cygheap_fixup_in_child): Clear cygheap->base so that heap
- is not forced to start at the same place in execed process.
- * heap.cc: Remove brk* macros for clarity throughout.
- * heap.h: Ditto.
- * shared.cc (shared_info::initialize): Move heap_chunk test into
- heap_chunk_size().
- (heap_chunk_size): Check for chunk size here. Don't go to registry if
- heap_chunk_in_mb is already set.
-
- * smallprint.c (console_printf): Add Windows 95 concessions.
-
-Sun Sep 9 13:01:06 2001 Christopher Faylor <cgf@cygnus.com>
-
- * child_info.h (PROC_MAGIC): Bump magic number.
-
-Sun Sep 9 18:36:00 2001 Corinna Vinschen <corinna@vinschen.de>
- Christopher Faylor <cgf@cygnus.com>
-
- * cygheap.cc (init_cygheap::etc_changed): New method to signal
- a change in /etc.
- * cygheap.h (struct init_cygheap): Add member `etc_changed_h'
- and method `etc_changed'.
- * grp.cc (enum grp_state): Eliminate.
- (class grp_check): Ditto.
- (group_state): Define as `class pwdgrp_check'.
- (parse_grp): Remeber path and modification time of /etc/group file.
- * passwd.cc (enum_pwd_state): Eliminate.
- (class pwd_check): Ditto.
- (passwd_state): Define as `class pwdgrp_check'.
- (read_etc_passwd): Remember path and modification time of /etc/passwd
- file.
- * pwdgrp.h: New file.
- (enum pwdgrp_state): Substitutes `pwd_state' and `grp_state'.
- (class pwdgrp_check): Substitutes `pwd_check' and `grp_check'.
-
-Sun Sep 9 14:31:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * include/cygwin/version.h: Bump API minor version to 45 according
- to adding the gamm*_r functions.
-
-Sat Sep 8 23:32:18 2001 Christopher Faylor <cgf@cygnus.com>
-
- * fork.cc (fork_parent): Stop malloc activity while fork is in control
- of the heap.
- * sigproc.cc (NZOMBIES): Rename from ZOMBIEMAX for clarity.
- (zombies): Revert to original behavior. Allocating zombie array
- resulted in performance hit.
- * winsup.h: Declare malloc lock routines.
-
-Fri Sep 7 21:35:35 2001 Christopher Faylor <cgf@cygnus.com>
-
- * cygwin.din: Add gamm*_r function exports.
-
-Fri Sep 7 17:11:11 2001 Christopher Faylor <cgf@cygnus.com>
-
- * cygheap.h (init_cygheap): Move heap pointers here.
- * include/sys/cygwin.h (perprocess): Remove heap pointers.
- * dcrt0.cc (__cygwin_user_data): Reflect obsolete perprocess stuff.
- (_dll_crt0): Don't initialize heap pointers.
- (cygwin_dll_init): Ditto.
- (release_upto): Use heap pointers from cygheap.
- * heap.h: Ditto.
- * fork.cc (fork_parent): Ditto. Don't set heap pointers in ch.
- (fork_child): Remove obsolete sigproc_fixup_after_fork.
- * shared.cc (memory_init): Reorganize so that cygheap initialization is
- called prior to regular heap since regular heap uses cygheap now.
- * sigproc.cc (proc_subproc): Eliminate zombies allocation.
- (sigproc_init): Move zombies alloation here. Don't free up array on
- fork, just reuse it.
- (sigproc_fixup_after_fork): Eliminate.
- * sigproc.h: Ditto.
- * include/cygwin/version.h: Reflect change to perprocess structure.
-
-Fri Sep 7 10:53:34 2001 Jason Tishler <jason@tishler.net>
-
- * poll.cc (poll): Change implementation to only call select() when no
- invalid file descriptors are specified.
-
-Fri Sep 7 10:27:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * include/limits.h: Define PIPE_BUF.
- * syscalls.cc (fpathconf): Use PIPE_BUF instead of numerical constant.
- (pathconf): Ditto.
-
-Thu Sep 6 20:04:05 2001 Christopher Faylor <cgf@cygnus.com>
-
- * fhandler_socket.cc (fhandler_socket::fhandler_socket): Ensure that
- prot_info_ptr is zeroed for later use.
-
-Thu Sep 6 14:03:49 2001 Christopher Faylor <cgf@cygnus.com>
-
- * cygheap.cc (cygheap_fixup_in_child): Don't consider a NULL bucket as
- a candidate for deletion. It is actually the end of a linked list
- chain.
-
- * exceptions.cc (open_stackdumpfile): Default to "unknown" program name
- if myself->progname hasn't been filled out yet.
-
-Thu Sep 6 01:16:44 2001 Christopher Faylor <cgf@cygnus.com>
-
- Move appropriate variables to NO_COPY segment, throughout.
-
-Thu Sep 6 00:40:35 2001 Christopher Faylor <cgf@cygnus.com>
-
- Remove initialization of static or global values to zero, throughout.
- This just needlessly grows the size of the DLL.
- * tty.cc (tty::alive): Make inuse handle non-inheriting on open, just
- for thread safety.
-
-Wed Sep 5 23:36:03 2001 Christopher Faylor <cgf@cygnus.com>
-
- * cygheap.h (init_cygheap): Move bucket array here from cygheap.cc.
- * cygheap.cc: Throughout use bucket array from cygheap.
-
- * sigproc.cc (proc_subproc): Dynamically allocate zombie buffer to save
- DLL space.
- (sigproc_fixup_after_fork): Free zombie array after a fork.
- * sigproc.h (sigproc_fixup_after_fork): Declare.
-
-2001-09-06 Egor Duda <deo@logos-m.ru>
-
- * dir.cc (mkdir): Expand buffer for security descriptor to 4K to avoid
- stack corruption.
- * fhandler.cc (fhandler_base::open): Ditto.
- * path.cc (symlink): Ditto.
-
-Wed Sep 5 21:35:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * winver.rc: Change copyright to include 2001.
-
-Wed Sep 5 12:12:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * fhandler_floppy.cc (fhandler_floppy::lseek): Remove iswinnt check.
-
-Wed Sep 5 11:34:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * fhandler_socket.cc (fhandler_socket::close): Change 2MSL value
- according to MSDN.
-
-Wed Sep 5 10:14:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * net.cc (cygwin_connect): Add WSAEALREADY and WSAEINVAL handling
- for non-blocking sockets.
-
-Tue Sep 4 22:42:13 2001 Christopher Faylor <cgf@cygnus.com>
-
- * exceptions.cc (ctrl_c_handler): Only send SIGINT when we have a
- controlling terminal and we are the head of the process group.
-
-Tue Sep 4 16:48:14 2001 Christopher Faylor <cgf@cygnus.com>
-
- * thread.cc (InterlockedExchangePointer): Don't define if it already
- exists.
-
-Tue Sep 4 22:14:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * uname.cc (uname): Eliminate os specific retrieving of x86
- processor type.
-
-2001-09-04 Kazuhiro Fujieda <fujieda@jaist.ac.jp>
-
- * fhandler_console.cc (fhandler_console::char_command): Save the cursor
- position relative to the top of the window.
- * fhandler_cc (fhandler_console::write): Ditto.
-
-Mon Sep 3 21:06:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * dir.cc (opendir): Write version information to __d_dirent->d_version.
-
-Mon Sep 3 18:34:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * cygwin.din: Add `dirfd'.
- * dir.cc (dirfd): New function.
- (opendir): Open a directory file descriptor and save it in
- __d_dirent->d_fd.
- (closedir): Close directory file descriptor.
- * include/cygwin/version.h: Bump API minor version to 44.
-
-Sun Sep 2 22:09:31 2001 Christopher Faylor <cgf@cygnus.com>
-
- * child_info.h: Modify magic number.
- * dcrt0.cc (_cygwin_testing): Define.
- (_dll_crt0): Set _cygwin_testing if CYGWIN_TESTING environment variable
- exists. Don't issue "conflicting versions" error if _cygwin_testing is
- true.
- * shared.cc (shared_name): Use _cygwin_testing global rather than
- testing the environment.
- * syscalls.cc (_write): Remove debugging info.
-
-Sat Sep 1 01:37:13 2001 Christopher Faylor <cgf@cygnus.com>
-
- * tty.cc (tty::create_inuse): Eliminate unneeded argument.
- * tty.h: Reflect above change.
- * fhandler_tty.cc: Reflect argument reduction in tty::create_inuse,
- throughout. Always make inuse inheritable.
-
-Sat Sep 1 01:10:07 2001 Christopher Faylor <cgf@cygnus.com>
-
- * debug.cc (mark_closed): Rename from debug_mark_closed and make
- static.
- (setclexec_pid): New function for marking saved handle as
- close-on-exec.
- (delete_handle): New function.
- (debug_fixup_after_fork): New function.
- * debug.h: Declare new functions, remove obsolete ones.
- * fork.cc (debug_fixup_after_fork): Call to cleanup close-on-exec
- handles.
-
- * fhandler.cc (fhandler_disk_file::close): Minor reorg.
- (fhandler_base::set_inheritance): Set flag appropriately for debugging
- when close-on-exec so forked process can delete closed handles.
- * tty.h (open_output_mutex): Eliminate unneeded argument.
- (open_input_mutex): Ditto.
- * fhandler_tty.cc (fhandler_tty_slave::open): reflect open_*_mutex
- argument changes.
- * fhandler.h (fhandler_socket): Make saw_shutdown_* functions type
- bool.
- * tty.cc (tty::get_event): Eliminate unneeded argument.
- (tty::common_init): Reflect change to get_event. Events should always
- be inherited.
-
-Fri Aug 31 21:39:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * security.cc (create_token): Change initialization of `exp' to comply
- with new LARGE_INTEGER definition in winnt.h.
-
-Fri Aug 31 13:58:51 2001 Christopher Faylor <cgf@cygnus.com>
-
- * cygwin.sc: Revert to previous NO_COPY behavior.
- * winsup.h: Ditto.
- * sigproc.cc: Ditto.
- * autoload.cc: Ditto.
-
-Fri Aug 31 00:56:26 2001 Christopher Faylor <cgf@cygnus.com>
-
- * cygwin.sc: New file -- linker script for building cygwin DLL.
- * Makefile.in: Use linker script to control location of cygheap.
- * cygheap.cc (buckets): Make static.
- (init_cheap): Remove special iswinnt handling. Allocate cygheap at a
- fixed location. Display more info when allocation fails.
- (cygheap_fixup_in_child): Try harder to move cygheap to correct
- location. Display more info when allocation fails.
- * fhandler.h (fhandler_socket): Add macros for tracking socket shutdown
- state.
- * net.cc (cygwin_shutdown): Set appropriate shutdown value for future
- use.
- * select.cc (select_stuff::cleanup): New method.
- (cygwin_select): Call cleanup explicitly to avoid a race.
- (select_stuff:~select_stuff): Call cleanup chain via cleanup method.
- (fhandler_socket::select_read): Set *_ready when shutdown has been
- called on the socket.
- (fhandler_socket::select_write): Ditto.
- (fhandler_socket::select_except): Ditto.
-
- * winsup.h: Move NO_COPY to "COMMON" section.
- * autoload.cc (wsock_started): Avoid initializing NO_COPY value.
- * sigproc.cc: Remove initialization from NO_COPY variables.
- (sigproc_init): Initialize sig_loop_wait here, rather than via
- initialization.
- (subproc_init): Initialize proc_loop_wait here, rather than via
- initialization.
-
-Thu Aug 30 10:19:00 2001 Christopher Faylor <cgf@cygnus.com>
-
- * select.cc (select_read): Add setting read_ready flag.
- (select_write): Add setting write_ready flag.
-
-Wed Aug 29 00:40:42 2001 Christopher Faylor <cgf@cygnus.com>
-
- * path.cc (path_conv::check): Avoid splitting off leading '/' in path
- component when building a symlink.
-
-Wed Aug 29 0:45:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * resource.cc (getrlimit): Return actual values on RLIMIT_STACK.
-
-Tue Aug 28 16:37:17 2001 Christopher Faylor <cgf@cygnus.com>
-
- * dir.cc (rmdir): Report ENOENT when file doesn't exist rather than
- ENOTDIR.
-
-Mon Aug 27 11:58:19 2001 Christopher Faylor <cgf@cygnus.com>
-
- * select.cc (cygwin_select): Ensure that arguments are zeroed on
- timeout.
- (select_stuff::wait): Ditto.
-
-2001-08-24 Kazuhiro Fujieda <fujieda@jaist.ac.jp>
-
- * syscalls.cc (check_tty_fds): New function. Check whether there is a
- fd referring to pty slave.
- (setsid): Don't detach console if the process has a pty slave.
-
-Fri Aug 24 8:54:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * net.cc (free_addr_list): Add define for symmetry.
- (free_hostent_ptr): Use free_addr_list to free h_addr_list element.
-
-Thu Aug 23 16:00:09 2001 Jason Tishler <jason@tishler.net>
-
- * net.cc (dup_addr_list): New static function.
- (dup_hostent_ptr): Use dup_addr_list instead of dup_char_list in order
- to handle embedded null characters.
-
-Wed Aug 22 22:23:14 2001 Christopher Faylor <cgf@cygnus.com>
-
- * dtable.cc (dtable::dup2): Allow extension of fd table by dup2.
- * syscalls.cc: Minor code cleanup.
- (fpathconf): Check for bad fd before doing anything else.
- * termios.cc (tcsetattr): Don't convert to new termios if bad fd.
- (tcgetattr): Minor debugging tweak.
-
-Wed Aug 22 23:41:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * net.cc (cygwin_inet_ntoa): Rearrange previous patch to use
- thread local buffer space when compiled thread safe.
- (cygwin_getprotobyname): Ditto.
- (cygwin_getprotobynumber): Ditto.
- (cygwin_getservbyname): Ditto.
- (cygwin_getservbyport): Ditto.
- (cygwin_gethostbyname): Ditto.
- (cygwin_gethostbyaddr): Ditto. Move near to cygwin_gethostbyname.
- * thread.h (struct _winsup_t): Add pointers for above used buffer space.
- * passwd.cc (getpwduid): Remove initializing passwd.
- (setpwent): Ditto.
- (endpwent): Ditto.
- (setpassent): Ditto.
-
-Wed Aug 22 13:41:09 2001 Christopher Faylor <cgf@cygnus.com>
-
- * smallprint.c (console_printf): New function.
- * dcrt0.cc (dll_crt0_1): Use console_printf for debugging output.
- * debug.cc (debug_mark_closed): New function.
- (close_handle): Use debug_mark_closed.
- * debug.h: Declare new functions.
- * dtable.cc (dtable::build_fhandler): Remove unneeded extern.
- * spawn.cc: Cosmetic changes.
- * winsup.h: Define NO_COPY for C files, too. Declare a global.
-
-Wed Aug 22 17:31:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * net.cc (free_char_list): New static function.
- (dup_char_list): Ditto.
- (free_protoent_ptr): Ditto.
- (dup_protoent_ptr): Ditto.
- (free_servent_ptr): Ditto.
- (dup_servent_ptr): Ditto.
- (free_hostent_ptr): Ditto.
- (dup_hostent_ptr): Ditto.
- (cygwin_inet_ntoa): Use local static buffer to allow propagating of
- the result to child processes.
- (cygwin_getprotobyname): Ditto.
- (cygwin_getprotobynumber): Ditto.
- (cygwin_getservbyname): Ditto.
- (cygwin_getservbyport): Ditto.
- (cygwin_gethostbyname): Ditto.
- (cygwin_gethostbyaddr): Ditto.
-
-Mon Aug 20 11:56:19 2001 Christopher Faylor <cgf@cygnus.com>
-
- * cygheap.cc (init_cheap): Allocate cygheap in shared memory for Windows NT.
-
-Thu Aug 16 09:38:59 2001 Jason Tishler <jason@tishler.net>
-
- * fhandler_socket.cc (fhandler_socket::create_secret_event): Relax
- security of secret_event so AF_UNIX socket clients can connect to
- servers even if running under a different user account.
- (fhandler_socket::check_peer_secret_event): Ditto.
-
-Thu Aug 16 16:26:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * resource.cc (getrlimit): Return getdtablesize () as current limit
- on RLIMIT_NOFILE.
- * syscalls.cc (getdtablesize): Return OPEN_MAX if current dtable size
- is less than OPEN_MAX, the current dtable size otherwise.
- * sysconf.cc (sysconf): Return getdtablesize () on _SC_OPEN_MAX.
-
-Thu Aug 16 16:17:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * resource.cc (getrlimit): Return OPEN_MAX as current limit
- on RLIMIT_NOFILE.
- * syscalls.cc (getdtablesize): Return OPEN_MAX.
- * sysconf.cc (sysconf): Return OPEN_MAX on _SC_OPEN_MAX.
- * include/limits.h (OPEN_MAX): Define as 256.
-
-Wed Aug 15 12:43:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * times.cc (utimes): Revert previous change. Just open the
- file using FILE_WRITE_ATTRIBUTES instead of GENERIC_WRITE
- on NT/W2K.
-
-Wed Aug 15 12:18:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * security.cc (set_nt_attribute): Return always -1 in case of
- a failure.
- * times.cc (utimes): On NTFS with ntsec ON, change the file's
- security descriptor temporarily to acquire write access if
- opening the file failed.
-
-Wed Aug 15 9:42:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * fhandler.cc (fhandler_base::is_nonblocking): New method.
- (fhandler_base::set_nonblocking): Ditto.
- * fhandler.h (fhandler_base): Declare new methods `is_nonblocking' and
- `set_nonblocking'.
- * fhandler_socket.cc (fhandler_socket::ioctl): Use `set_nonblocking'.
- * fhandler_tty.cc (fhandler_pty_master::process_slave_output):
- Use `is_nonblocking'.
- (fhandler_tty_slave::read): Ditto.
- (fhandler_tty_slave::ioctl): Use `set_nonblocking'.
- (fhandler_pty_master::ioctl): Ditto.
- * net.cc (cygwin_sendto): Fallback to winsock 1 functionality
- in case of nonblocking IO.
- (cygwin_recvfrom): Ditto.
- (cygwin_recv): Ditto.
- (cygwin_send): Ditto.
- * syscalls.cc (_read): Use `is_nonblocking'.
-
-Tue Aug 14 11:05:26 2001 Christopher Faylor <cgf@cygnus.com>
-
- * include/cygwin/version.h: Bump API version.
-
-2001-08-14 Egor Duda <deo@logos-m.ru>
-
- * spawn.cc (spawn_guts): Enable appropriate privilege before
- loading user's registry hive.
-
-Mon Aug 13 22:34:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * fhandler.cc (fhandler_base::fcntl): Use new O_NONBLOCK_MASK define.
- * fhandler.h: Move definitions of O_NOSYMLINK, O_DIROPEN and
- OLD_O_NDELAY from winsup.h to here. Add O_NONBLOCK_MASK define.
- * fhandler_socket.cc (fhandler_socket::close): Add hack to allow
- a graceful shutdown even if shutdown() hasn't been called by the
- application. Add debug output.
- (fhandler_socket::ioctl): Set fhandler's NONBLOCK flag according
- to FIONBIO setting.
- (fhandler_socket::fcntl): Use new O_NONBLOCK_MASK define. Actually
- set `request' before using it.
- * fhandler_tty.cc: Use new O_NONBLOCK_MASK define throughout.
- (fhandler_tty_slave::ioctl): Set fhandler's NONBLOCK flag according
- to FIONBIO setting.
- (fhandler_pty_master::ioctl): Ditto.
- * net.cc (wsock_event::prepare): Compare WSACreateEvent return code
- with `WSA_INVALID_EVENT' according to MSDN.
- * syscalls.cc (_read): Use new O_NONBLOCK_MASK define.
-
-Wed Aug 8 15:24:59 2001 Christopher Faylor <cgf@cygnus.com>
-
- * include/wchar.h: Define __need_wint_t.
-
-Wed Aug 8 11:46:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * security.cc (alloc_sd): Revert to setting inheritance attribute for
- permissions given to directories. Never set inheritance on NULL ACE.
-
-Tue Aug 7 18:11:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * security.cc (alloc_sd): Don't set FILE_DELETE_CHILD for group
- if S_ISVTX attribute is given.
- * dir.cc (mkdir): Allow immediate setting of S_ISUID, S_ISGID and
- S_ISVTX attribute.
- * syscalls.cc (_open): Ditto.
-
-Tue Aug 7 16:24:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * dir.cc (mkdir): Set security attributes correctly for
- CreateDirectoryA () call if ntsec is on. Don't call
- set_file_attributes () then.
- * fhandler.cc (fhandler_base::open): Ditto for CreateFileA () call.
- * path.cc (symlink): Ditto.
- * security.cc (set_security_attribute): New function.
- * security.h: Add declaration for `allow_ntea' and
- `set_security_attribute'.
-
-Tue Aug 7 10:54:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * grp.cc (class grp_check): New class. Make `group_state'
- a member of class grp_check.
- (read_etc_group): Free former allocated memory on reread.
- * passwd.cc (class pwd_check): New class Make `passwd_state'
- a member of class pwd_check.
- (read_etc_passwd): Free former allocated memory on reread.
-
-Tue Aug 7 01:13:58 2001 Christopher Faylor <cgf@cygnus.com>
-
- * fhandler_console.cc (get_tty_stuff): Don't initialize shared memory
- console area if it is already initialized.
-
- * fhandler_termios.cc (fhandler_termios::tcsetpgrp): Augment debugging
- info.
-
-Mon Aug 6 19:58:43 2001 Christopher Faylor <cgf@cygnus.com>
-
- * cygheap.cc (cygheap_root::set): Avoid treating '/' specially.
-
- * fhandler.cc (fhandler_base::fcntl): Only set specific O_NDELAY style
- flag passed in from application.
- * fhandler_socket.cc (fhandler_socket::fcntl): Ditto.
- * fhandler.h: Set constant for future use.
- * winsup.h: Define OLD_O_NDELAY only for old programs.
- * include/cygwin/version.h: Define
- CYGWIN_VERSION_CHECK_FOR_OLD_O_NONBLOCK.
-
-Sat Aug 4 16:52:03 2001 Christopher Faylor <cgf@cygnus.com>
-
- Throughout, change check for running under Windows NT to 'iswinnt'.
- * dcrt0.cc (set_os_type): Set 'iswinnt' appropriately.
- * cygheap.cc (init_cheap): Revert to using VirtualAlloc for allocating
- cygheap.
- (cygheap_setup_for_child_cleanup): New function. Standard function to
- call after calling CreateProcess to cleanup cygheap info passed to
- child.
- (cygheap_fixup_in_child): Copy cygheap from shared memory into
- allocated space under Windows 9x or if can't relocate shared space
- under NT.
- * cygheap.h: Declare new function.
- * spawn.cc (spawn_guts): Use cygheap_fixup_in_child.
- * fork.cc (fork_parent): Ditto.
- * winsup.h: Declare iswinnt.
-
-2001-08-04 Egor Duda <deo@logos-m.ru>
-
- * dtable.cc (dtable::release): Avoid messing with console when
- closing socket.
-
-Fri Aug 3 14:02:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * net.cc (cygwin_accept): Allow NULL peer and len parameters.
- * include/cygwin/socket.h: Define socklen_t as int.
-
-Fri Aug 3 13:04:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * path.cc (fchdir): Set the fhandler's path to absolute value to ensure
- changing to the correct directory even if the fhandler originally
- points to a relative path.
-
-Thu Aug 2 17:59:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * security.cc (set_file_attribute): Clean up. Don't call
- `set_nt_attribute' when ntsec isn't set.
-
-Sat Jul 28 22:30:55 2001 Christopher Faylor <cgf@cygnus.com>
-
- * dcrt0.cc (alloc_stack_hard_way): Make half-hearted attempt to deal
- with growing stack under Windows 95.
-
-Fri Jul 27 12:36:07 2001 Christopher Faylor <cgf@cygnus.com>
-
- * Makefile.in: Add install-lib and install-headers.
-
-Fri Jul 27 12:28:12 2001 Christopher Faylor <cgf@cygnus.com>
-
- * cygwin.din: Export sys_errlist, sys_nerr.
- * include/cygwin/version.h: Bump minor version number.
-
-Fri 27 Jul 2001 10:29:00 Corinna Vinschen <corinna@vinschen.de>
-
- * security.cc (get_user_primary_group): Fix compiler warning.
- (alloc_sd): Add DELETE permission for user when S_IWUSR is given.
-
-Thu Jul 26 16:43:39 2001 Pieter de Visser <pieterdv@knoware.nl>
-
- * thread.cc (__pthread_equal): Invert return value so that true is
- returned when threads are equal.
-
-Thu Jul 26 15:50:38 2001 Charles Wilson <cwilson@ece.gatech.edu>
- Christopher Faylor <cgf@cygnus.com>
-
- * cygwin.din: Export __signgam.
- * include/cygwin/version.h: Bump minor version number.
-
-Thu Jul 26 15:19:50 2001 Christopher Faylor <cgf@cygnus.com>
-
- Throughout, reorganize header file inclusion to put security.h prior to
- fhandler.h.
- * fhandler.h (fhandler_base::get_inheritance): New method.
- * fhandler_socket.cc (fhandler_socket::create_secret_event): Use proper
- close-on-exec inheritance when creating.
- (fhandler_socket::check_peer_secret_event): Create handle as
- non-inheritable.
-
-2001-07-25 Kazuhiro Fujieda <fujieda@jaist.ac.jp>
-
- * syscalls.cc (setsid): Detach process from its console if the current
- controlling tty is the console and already closed.
- * dtable.h (class dtable): Add members to count descriptors referring
- to the console.
- * dtable.cc (dtable::dec_console_fds): New function to detach process
- from its console.
- (dtable::release): Decrement the counter of console descriptors.
- (dtable::build_fhandler): Increment it.
- * exception.cc (ctrl_c_handler): Send SIGTERM to myself when catch
- CTRL_SHUTDOWN_EVENT.
-
-Tue 24 Jul 2001 02:28:00 PM Trevor Forbes <t4bs@hotmail.com>
-
- * thread.cc (verifyable_object_isvalid): Don't validate
- PTHREAD_MUTEX_INITIALIZER pointer as it will cause an exception
- in IsBadWritePtr() when running GDB.
-
-Wed 25 Jul 2001 23:46:00 Corinna Vinschen <corinna@vinschen.de>
-
- * localtime.c: Changed whole file to become C++ clean. Rename to
- localtime.cc.
- * localtime.cc (tzload): Preserve errno.
-
-Fri 20 Jul 2001 11:15:50 PM EDT Christopher Faylor <cgf@cygnus.com>
-
- * cygheap.cc (cygheap_fixup_in_child): Attempt Win95 workaround.
- * dtable.cc (dtable::dup_worker): Add debugging output.
- (dtable::vfork_child_dup): Correctly set close_on_exec.
- * fhandler.cc (fhandler_base::fork_fixup): Don't mess with handle if
- there is no need to get it from the parent.
- * fhandler_tty.cc (fhandler_tty_common::close): Add debugging output.
-
-Fri 20 Jul 2001 09:15:00 Mark Bradshaw <bradshaw@staff.crosswalk.com>
-
- * dir.cc (readdir): Protect FindNextFileA against INVALID_HANDLE_VALUE.
-
-Wed 18 Jul 2001 01:00:47 PM EDT Christopher Faylor <cgf@cygnus.com>
-
- * cygheap.cc (_cmalloc): Use correct constants for size calculation.
- * dcrt0.cc (dll_crt0_1): Move uid initialization earlier.
- * fork.cc (fork_parent): Move cygheap_setup_in_child to just prior to
- CreateProcess so that all contents of cygheap are copied.
- * spawn.cc (spawn_guts): Ditto.
-
-Wed 18 Jul 2001 12:54:17 Corinna Vinschen <corinna@vinschen.de>
-
- * security.cc (get_user_groups): Call Net function with NULL server
- name under specific error conditions.
- (is_group_member): Ditto.
- (get_user_local_groups): Ditto.
- (get_user_primary_group): Ditto.
-
-Wed 18 Jul 2001 11:56:00 Corinna Vinschen <corinna@vinschen.de>
-
- * syscalls.cc (_unlink): Explicitly check for non-existant file.
-
-Tue 17 Jul 2001 10:19:00 Corinna Vinschen <corinna@vinschen.de>
-
- * delqueue.h: Remove obsolete file.
-
-Mon 16 Jul 2001 10:47:17 PM EDT Christopher Faylor <cgf@cygnus.com>
-
- * child_info.h: Bump magic number.
- (class child_info): Add an element.
- * cygheap.cc (init_cheap): Allocate cygwin heap in shared memory area.
- (cygheap_fixup_in_child): Map cygwin heap, passed from parent via
- shared memory into correct address.
- (cygheap_setup_for_child): New function.
- * cygheap.h: Declare new functions.
- * dcrt0.cc (dll_crt0_1): Accomodate new cygheap_fixup_in_child
- arguments. Avoid protecting subproc_ready unless it is spawn/nowait.
- * fork.cc (fork_parent): Use new cygheap_setup_for_child function to
- setup cygwin heap info. Close passed cygheap shared memory handle.
- * spawn.cc (spawn_guts): Ditto. Also, reorganize to avoid
- synchronization between parent and child in non-P_OVERLAY case.
- * sigproc.cc (wait_sig): Only signal subproc_ready when execing.
-
-Mon 16 Jul 2001 15:21:00 Corinna Vinschen <corinna@vinschen.de>
-
- * grp.cc: Add missing Copyright date 2001.
-
-Mon 16 Jul 2001 00:11:00 Corinna Vinschen <corinna@vinschen.de>
-
- Change well_known_admin_sid to well_known_admins_sid throughout.
- * sec_acl.cc (setacl): Never set DELETE permission. Set
- FILE_DELETE_CHILD only on readable and executable directories.
- * sec_helper.cc: Add constructor for `well_known_null_sid'.
- * security.cc (get_nt_attribute): Set S_ISVTX for directories if
- FILE_WRITE_DATA and FILE_EXECUTE but not FILE_DELETE_CHILD is set.
- Add evaluation of S_ISVTX, S_ISGID and S_ISUID from NULL ACE.
- (alloc_sd): Never set DELETE permission. Set FILE_DELETE_CHILD
- only on readable and executable directories.
- Add creation of NULL ACE for S_ISVTX, S_ISGID and S_ISUID permissions.
- * security.h: Add extern declaration for `well_known_null_sid'.
-
-Fri 13 Jul 2001 08:08:49 PM EDT Christopher Faylor <cgf@cygnus.com>
-
- * syscalls.cc (stat_worker): Simplify previous change.
-
-Fri Jul 13 13:13:09 2001 Christopher Faylor <cgf@cygnus.com>
-
- * syscalls.cc (_unlink): Correct (?) logic which determines when
- to report an access violation and when to queue file for eventual
- deletion.
- (stat_worker): Check for invalid buf argument.
-
-Tue Jul 10 23:01:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * mmap.cc (fhandler_disk_file::mmap): Try to open file mappings
- by a unified name when running under 9x/ME. If that failes, create
- the file mapping using the unified name.
-
-Mon Jul 9 10:43:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * uinfo.cc (internal_getlogin): Add pointer check.
-
-Mon Jul 9 10:05:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * security.cc (alloc_sd): Don't set inheritance attribute for
- permissions given to directories.
-
-Thu Jun 28 22:19:08 2001 Christopher Faylor <cgf@cygnus.com>
-
- * fhandler_dsp.cc (fhandler_dev_dsp::ioctl): Return 0 for success.
-
-Wed Jun 27 22:19:07 2001 Christopher Faylor <cgf@cygnus.com>
-
- * path.cc (path_conv::check): Add signal protection here since
- retrieving info about remote shares can take some time.
-
-Wed Jun 27 23:30:00 2001 Robert Collins <rbtcollins@hotmail.com>
- Christopher Faylor <cgf@cygnus.com>
-
- Change check_null_empty_path* to check_null_empty_str* throughout.
- * path.h (check_null_empty_str_errno): Convert to a function prototype.
- * path.cc (check_null_empty_str): Move to miscfuncs.cc.
- * miscfuncs.cc (check_null_empty_str_errno): New function.
- (__check_null_invalid_struct): Ditto.
- (__check_null_invalid_struct_errno): Ditto.
- (check_null_empty_str): Change from VirtualQuery to IsBadWritePtr.
- * thread.cc (check_valid_pointer): Ditto.
- * resource.cc (getrlimit): Use check_null_invalid_struct macro for
- checking validity of pointer.
- (setrlimit): Ditto.
-
-Tue Jun 26 16:59:16 2001 Christopher Faylor <cgf@cygnus.com>
-
- * fhandler.cc (fhandler_disk_file::fstat): Don't rely on exactly 3
- characters being read for executable test since we could be checking
- for less than that.
- * syscalls.cc (stat_worker): Try opening the file the "correct" way
- first so that #! processing can potentially happen. If that fails,
- then use "query open" method.
-
- * spawn.cc (spawn_guts): Delay processing of signal until after we've
- notified parent about reparenting.
-
-Tue Jun 26 10:47:24 2001 Christopher Faylor <cgf@cygnus.com>
-
- * mmap.cc: Clean up *ResourceLock calls throughout.
-
-Tue Jun 26 22:10:00 2001 Robert Collins rbtcollins@hotmail.com
-
- * thread.cc (pthread_cond::TimedWait): Check for WAIT_TIMEOUT as well
- as WAIT_ABANDONED.
- (__pthread_cond_timedwait): Calculate a relative wait from the abstime
- parameter.
-
-Sun Jun 24 17:38:19 2001 Christopher Faylor <cgf@cygnus.com>
-
- * exceptions.cc (interrupt_setup): Move actions from setup_handler to
- here.
- (setup_handler): Move actions after a successful interrupt to
- interrupt_setup.
- * fork.cc (vfork): Augment debugging output.
- * sigproc.cc (proc_subproc): Ditto.
- * spawn.cc (spawn_guts): Ditto. Correctly fill out progname when spawn
- NO_WAIT. Call signal handler when a signal arrives.
- * sigproc.h: Declare a function.
-
-Fri Jun 22 16:50:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * fhandler.h class fhandler_socket): Declare new method
- `set_close_on_exec'.
- * fhandler_socket.cc (fhandler_socket::set_close_on_exec):
- New method.
-
-Fri Jun 22 16:12:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * fhandler_tape.cc (fhandler_dev_tape::tape_erase): Set size
- parameter to value expected by GetTapeParameters().
-
-Thu Jun 21 22:01:39 2001 Marius Gedminas <mgedmin@delfi.lt>
-
- * fhandler_console.cc (fhandler_console::read): Detect AltGr more
- robustly on WinNT.
-
-2001-06-22 Robert Collins <rbbtcollins@hotmail.com>
-
- * thread.cc (__pthread_cond_timedwait): Lock the waiting mutex before
- the condition protect mutex to avoid deadlocking. (Found by Greg Smith).
- (__pthread_cond_wait): Ditto.
-
-2001-06-30 Egor Duda <deo@logos-m.ru>
-
- * fhandler.cc (fhandler_base::open): Work around windows bug when
- CreateFile() with dwDesiredAccess == 0 called on remote share returns
- valid handle even if file doesn't exist.
-
-2001-06-20 Egor Duda <deo@logos-m.ru>
-
- * fhandler_socket.cc (fhandler_socket::signal_secret_event): New
- function.
- * fhandler.h: Declare it.
- * fhandler_socket.cc (fhandler_socket::create_secret_event): Don't
- signal secret event immediately.
- (fhandler_socket::check_peer_secret_event): Do it after peer event
- was opened.
- * net.cc (cygwin_connect): Or if socket is non-blocking.
- (cygwin_accept): Ditto.
-
-Mon Jun 18 17:09:25 2001 Christopher Faylor <cgf@cygnus.com>
-
- * fhandler_tty.cc (fhandler_tty_slave::init): Revert 2001-06-16 change.
-
- * fork.cc (fork_copy): Print more debugging info.
- (fork_parent): Change order of arguments to accomdate buggy gcc.
- (fork): Ditto.
-
-Sun Jun 17 18:54:46 2001 Christopher Faylor <cgf@cygnus.com>
-
- * syscalls.cc (_unlink): Reorganize to try harder to delete file with
- DeleteFile and to recover more gracefully if FILE_FLAG_DELETE_ON_CLOSE
- doesn't work properly.
-
-Sat Jun 16 13:06:49 2001 Christopher Faylor <cgf@cygnus.com>
-
- * exceptions.cc (sig_handle_tty_stop): Reset PID_STOPPED if not
- actually stopping.
- * fhandler_console.cc (fhandler_console::fixup_after_fork): Don't set
- controlling terminal if just inheriting a handle.
- (fhandler_console::fixup_after_exec): Ditto.
- * fhandler_tty.cc (fhandler_tty_slave::init): Ditto.
- * signal.cc (kill_worker): Set appropriate errno if proc_exists
- determines that process does not really exist.
-
-Fri Jun 15 14:34:19 2001 Christopher Faylor <cgf@cygnus.com>
-
- * path.cc (path_conv::check): Deal more robustly with foo/ behavior.
-
-Fri Jun 15 11:15:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * fhandler_tape.cc (fhandler_dev_tape::tape_status): Set size
- parameter to value expected by GetTapeParameters().
-
-Thu Jun 14 20:19:46 2001 Christopher Faylor <cgf@cygnus.com>
-
- * fhandler.cc (fhandler_disk_file::fstat): Properly set executable bits
- for directory when !ntsec && !ntea. Also move common code prior to
- call to get_attributes.
-
-Fri June 15 09:25:00 Robert Collins <rbtcollins@hotmail.com>
-
- * thread.cc (pthread_cond::Signal): Release the condition access
- variable correctly.
-
-2001-06-14 Egor Duda <deo@logos-m.ru>
-
- * fhandler.cc (fhandler_base::open): Set win32 access flags to 0, when
- requested.
- * fhandler.h: New status flag FH_QUERYOPEN.
- (fhandler::get_query_open): New function.
- (fhandler::set_query_open): Ditto.
- * syscalls.cc (stat_worker): Request query-only open mode.
-
-2001-06-12 Egor Duda <deo@logos-m.ru>
-
- * environ.cc (set_file_api_mode): New function. Move setting
- of file APIs mode (OEM/ANSI) here.
- (codepage_init): From here.
- * winsup.h (set_file_api_mode): Declare it.
- * fork.cc (fork_child): Set file APIs mode in forkee.
-
-Mon Jun 11 14:19:49 2001 Christopher Faylor <cgf@cygnus.com>
-
- * pinfo.cc: Use autoloaded ToolHelp functions throughout for Win9x.
- * autoload.cc: Autoload ToolHelp functions.
-
- * sigproc.cc (proc_subproc): Incorporate SIGCHLD == SIG_IGN special
- handling of zombie processes. Ensure that zombie processes which are
- at the end of the zombie array are properly cleaned up.
-
-Mon Jun 11 11:18:56 2001 Christopher Faylor <cgf@cygnus.com>
-
- * path.cc (chdir): Fix call to path_conv constructor so that it REALLY
- doesn't check for the null/non-empty path.
-
-Sun Jun 10 23:34:09 2001 Christopher Faylor <cgf@cygnus.com>
-
- * path.cc (path_conv::update_fs_info): Don't consider remote drives to
- be NTFS. Set root_dir before invoking GetDriveType (from Kazuhiro
- Fujieda <fujieda@jaist.ac.jp>). Eliminate extra checks for rootdir.
-
-Sun Jun 10 20:19:47 2001 Christopher Faylor <cgf@cygnus.com>
-
- * path.cc (chdir): Pre-check path for validity before eating trailing
- space. Then, ensure that path_conv doesn't check the path for validity
- again.
-
-Sun Jun 10 12:56:00 2001 Christopher Faylor <cgf@redhat.com>
-
- * exceptions.cc (sigdelayed): Ensure that signal is cleared as
- the last operation or suffer races.
- * sigproc.cc (proc_subproc): Deal with zombie array overflow.
-
-Sun Jun 10 11:56:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * cygwin.din: Add fchdir symbols.
- * path.cc (chdir): Guard against invalid parameter.
- (fchdir): New function.
- * include/cygwin/version.h: Bump API minor version to 40.
- * uinfo.cc (internal_getlogin): Remove unused variable.
-
-Sat Jun 9 23:20:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * syscalls.cc (seteuid): Set environment variables USERNAME and
- USERDOMAIN before impersonation to workaround a LookupAccountSid()
- misbehaviour.
- * uinfo.cc (internal_getlogin): Revert most of the previous change.
- Don't set environment variables USERNAME and USERDOMAIN. That's
- the job of seteuid() now. Try to get logon server from Lsa
- only if logon server isn't already known.
-
-Thu Jun 7 15:54:32 2001 Robert Collins <rbtcollins@hotmail.com>
-
- * thread.cc (pthread_cond::Broadcast): Don't print error messages on
- invalid mutexs - user programs are allowed to call
- pthread_cond_broadcast like that.
- (__pthread_cond_timedwait): Initialise themutex properly.
- (__pthread_cond_wait): Initialise themutex properly.
-
-Tue Jun 5 19:56:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * fhandler_console.cc (fhandler_console::dup): Allocate space for
- savebuf on Cygwin heap.
- (fhandler_console::char_command): Ditto. Use correct values for size.
-
-2001-06-05 Egor Duda <deo@logos-m.ru>
-
- * security.h (NTWriteEA): Change prototype.
- * ntea.cc (NTReadEA): Don't check for global ntea setting, now
- it's caller responsibility.
- (NTWriteEA): Ditto.
- * security.cc (get_file_attribute): Read attribute from EA only
- if 'ntea' is enabled.
- (set_file_attribute): Ditto.
- * path.h: (class path_conv): Add members to store file system
- information.
- (path_conv::get_drive_type): New function.
- * syscalls.cc (stat_worker): Use it.
- * path.cc (path_conv::update_fs_info): New functions.
- (path_conv::check): Get file system information from device where
- file resides. On NTFS, try to read symlink contents from EA.
- (get_symlink_ea): New function.
- (set_symlink_ea): Ditto.
- (symlink): Store symlink in extended attribute, if possible.
-
-Tue Jun 5 11:18:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * fhandler.cc (fhandler_disk_file::fstat): Always reset file position
- to original value after checking for executable magic.
-
-Mon Jun 4 16:21:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * cygheap.h (cygheap_user::cygheap_user): Initialize token to
- INVALID_HANDLE_VALUE.
- * uinfo.cc (uinfo_init): Close token handle if needed.
-
-Sun Jun 3 20:52:13 2001 Christopher Faylor <cgf@cygnus.com>
-
- * path.cc (normalize_posix_path): Revert .. check removed by previous
- changes.
- * cygheap.h: Temporarily declare path_prefix_p here.
-
-Mon Jun 4 0:14:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * net.cc (wsock_event): Add destructor.
-
-Sun Jun 3 09:49:55 2001 Robert Collins <rbtcollins@hotmail.com>
-
- * dlfcn.cc (dlclose): Do not call FreeLibrary if the symbol to close
- was obtained by dlopen(NULL,...).
-
-Sat Jun 2 23:11:52 2001 Christopher Faylor <cgf@cygnus.com>
-
- * syscalls.cc (sleep): Try to be a little more accomodating of signal
- arrival. Ensure that the signal handler is called.
-
-Sat Jun 2 14:07:28 2001 Christopher Faylor <cgf@cygnus.com>
-
- * cygheap.cc (cygheap_root::cygheap_root): Remove constructor.
- (cygheap_root::~cygheap_root): Remove destructor.
- (cygheap_root::operator =): Remove.
- (cygheap_root::set): New method.
- * cygheap.h (cygheap_root): Reflect above changes. Store root info in
- mount-like structure.
- (cygheap_root:posix_ok): New method.
- (cygheap_root::ischroot_native): Ditto.
- (cygheap_root::unchroot): Ditto.
- (cygheap_root::exists): Ditto.
- (cygheap_root::posix_length): Ditto.
- (cygheap_root::posix_path): Ditto.
- (cygheap_root::native_length): Ditto.
- (cygheap_root::native_path): Ditto.
- * dir.cc (opendir): Remove special chroot test.
- * path.cc (path_prefix_p): Remove front end.
- (normalize_posix_path): Reorganize chroot tests to accomodate new
- convention of allowing paths using posix chroot prefix.
- (path_conv::check): Pass a "already ran normalize" option to
- conv_to_win32_path. Return if there is an error from this function.
- (mount_info::conv_to_win32_path): Add extra argument. Don't call
- normalize_posix_path if caller has already done so. Substitute chroot
- setting, if any, for root translation. Add chroot checking to final
- output step.
- * shared_info (mount_info): Accomodate additional argument to
- conv_to_win32_path.
- * syscalls.cc (chroot): Store both normalized posix path and native
- path in chroot.
-
-Fri Jun 1 10:57:19 2001 Christopher Faylor <cgf@cygnus.com>
-
- * path.cc (chdir): Really make sure that isspace gets only an unsigned
- char.
-
-Fri Jun 1 13:45:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * syscalls.cc (_rename): Handle the case that `foo' is renamed to
- `bar' while `bar.lnk' is an existing shortcut-symlink.
-
-Thu May 31 15:57:57 2001 Christopher Faylor <cgf@cygnus.com>
-
- * fhandler.cc (fhandler_disk_file::fstat): Avoid clearing S_IFMT bits
- since we've already pre-cleared everything anyway.
-
-Wed May 30 23:51:32 2001 Earnie Boyd <earnie_boyd@yahoo.com>
-
- * path.cc (chdir): Always send unsigned chars to isspace since newlib's
- isspace doesn't deal well with "negative" chars.
-
-Wed May 30 23:51:32 2001 Christopher Faylor <cgf@cygnus.com>
-
- * fhandler.cc (fhandler_disk_file::open): Propagate remote status of
- file garnered from path_conv. Move #! checking to fstat.
- (fhandler_disk_file::fstat): Reorganize st_mode setting to eliminate
- duplication. Move check for #! here from fhandler::open.
-
- * fhandler.h (fhandler_base::isremote): New method.
- (fhandler_base::set_isremote): Ditto.
- (fhandler_base::set_execable_p): Also record "don't care if executable
- state".
- (fhandler_base::dont_care_if_execable): New method.
- * path.cc (path_conv::check): Clear new flags. Appropriately set
- vol_flags, drive_type, and is_remote_drive.
- * path.h: Add new flags and methods for manipulating them.
- * syscalls.cc (_unlink): Use isremote() to determine if a path is
- remote rather than calling GetDriveType.
- (stat_worker): Ditto.
- * security.cc (get_file_attribute): Or attribute with result of
- NTReadEA to be consistent with get_nt_attribute.
-
-Tue May 29 19:02:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * sec_helper.cc (cygsid::getfrompw): Change parameter to `const'.
- (cygsid::getfromgr): Ditto.
- * security.cc: Use `sys_mbstowcs' and `sys_wcstombs' throughout.
- (extract_nt_dom_user): Try to get user and domain from SID in
- pw->pw_gecos first.
- * security.h (class cygsid): Change parameter of getfrompw() and
- getfromgr() to `const'.
- * uinfo.cc (internal_getlogin): Change order for evaluating user
- information in winNT case. Drop usage of NetWkstaUserGetInfo().
-
-Mon May 28 21:34:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * shortcut.c (check_shortcut): Treat only Cygwin shortcuts as symlinks.
-
-Fri May 25 11:07:07 2001 Christopher Faylor <cgf@cygnus.com>
-
- * path.cc (symlink_info::check): Correctly set 'ext_tacked_on'. Use
- this to determine if user specified 'foo.lnk' explicitly. Reorganize
- slightly to get rid of one goto.
-
-Fri May 25 10:15:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * path.cc (symlink_info::check): Add a check to return correctly
- if incoming `*.lnk' file is not a symlink.
-
-Thu May 24 15:46:50 2001 Christopher Faylor <cgf@cygnus.com>
-
- * path.cc (slash_drive_prefix_p): Remove.
- (mount_info::slash_drive_to_win32_path): Ditto.
- (mount_info::conv_to_win32_path): Remove slash drive prefix check.
- (mount_info::add_item): Ditto.
- (mount_info::del_item): Ditto.
- * shared_info.h (mount_info): Remove slash_drive_to_win32_path
- declaration.
-
-Thu May 24 01:17:33 2001 Christopher Faylor <cgf@cygnus.com>
-
- * exceptions.cc (handle_exceptions): Bump repeat count for debugging
- kick out.
-
- * fhandler.h (fhandler_dev_dsp): Add a fixup_after_exec.
- * fhandler_dsp.cc (class Audio): Add TOT_BLOCK_SIZE to enum.
- (operator new): New.
- (bigwavebuffer): Declare using TOT_BLOCK_SIZE to avoid buffer overruns.
- (Audio::Audio): Optimize slightly.
- (fhandler_dev_dsp::open): Allocate s_audio using static buffer.
- (fhandler_dev_dsp::fixup_after_exec): New function. Ditto.
-
-Wed May 23 17:45:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * syscalls.cc (seteuid): Restrict overriding external provided
- user tokens to ntsec. Don't test external tokens for primary
- group to evaluate if it should be overridden. Restrict creating
- internal tokens to ntsec.
-
-Wed May 23 10:11:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * syscalls.cc (chown_worker): Don't check for ENOSYS.
-
-Tue May 22 12:20:07 2001 Christopher Faylor <cgf@cygnus.com>
-
- * signal.cc (sleep): Protect with sigframe.
-
-Tue May 22 17:58:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * security.cc (get_file_attribute): Don't set errno.
-
-Mon May 21 15:08:00 2001 Christopher Faylor <cgf@cygnus.com>
-
- * configure.in: Allow --enable-newvfork to turn NEWVFORK on and off.
- * configure: Regenerate.
-
-Mon May 21 11:46:01 2001 Christopher Faylor <cgf@cygnus.com>
-
- * include/cygwin/version.h: Bump minor version number.
-
-Sun May 20 13:26:25 2001 Christopher Faylor <cgf@cygnus.com>
-
- * fhandler_dsp.cc: Reformat to GNU standards.
- (s_audio): Change to a pointer throughout.
- (fhandler_dev_dsp::open): Initialize s_audio, if required.
-
-Sat May 19 23:40:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * autoload.cc: Add load statements for `LookupAccountNameW',
- `LsaClose', `LsaEnumerateAccountRights', `LsaFreeMemory',
- `LsaOpenPolicy', `LsaQueryInformationPolicy', `NetLocalGroupEnum',
- `NetLocalGroupGetMembers', `NetServerEnum', `NetUserGetGroups' and
- `NtCreateToken'.
- * ntdll.h: Add declaration for `NtCreateToken'.
- * sec_helper.cc: Add `well_known_local_sid', `well_known_dialup_sid',
- `well_known_network_sid', `well_known_batch_sid',
- `well_known_interactive_sid', `well_known_service_sid' and
- `well_known_authenticated_users_sid'.
- (cygsid::string): Define as const method.
- (cygsid::get_sid): Set psid to NO_SID on error.
- (cygsid::getfromstr): Ditto.
- (cygsid::getfrompw): Simplify.
- (cygsid::getfromgr): Check for gr == NULL.
- (legal_sid_type): Move to security.h.
- (set_process_privilege): Return -1 on error, otherwise 0 or 1 related
- to previous privilege setting.
- * security.cc (extract_nt_dom_user): Remove `static'.
- (lsa2wchar): New function.
- (open_local_policy): Ditto.
- (close_local_policy): Ditto.
- (get_lsa_srv_inf): Ditto.
- (get_logon_server): Ditto.
- (get_logon_server_and_user_domain): Ditto.
- (get_user_groups): Ditto.
- (is_group_member): Ditto.
- (get_user_local_groups): Ditto.
- (sid_in_token_groups): Ditto.
- (get_user_primary_group): Ditto.
- (get_group_sidlist): Ditto.
- (get_system_priv_list): Ditto.
- (get_priv_list): Ditto.
- (get_dacl): Ditto.
- (create_token): Ditto.
- (subauth): Return immediately if SE_TCB_NAME can't be assigned.
- Change all return statements in case of error to jumps to `out'
- label. Add `out' label to support cleanup.
- * security.h: Add extern declarations for `well_known_local_sid',
- `well_known_dialup_sid', `well_known_network_sid',
- `well_known_batch_sid', `well_known_interactive_sid',
- `well_known_service_sid' and `well_known_authenticated_users_sid'.
- Add extern declarations for functions `create_token',
- `extract_nt_dom_user' and `get_logon_server_and_user_domain'.
- (class cygsid): Add method `assign'. Change operator= to call new
- `assign' method. Add `debug_print' method.
- (class cygsidlist): New class.
- (legal_sid_type): Moved from sec_helper.cc to here.
- * spawn.cc (spawn_guts) Revert reversion of previous patch.
- Call `RevertToSelf' and `ImpersonateLoggedOnUser' instead of `seteuid'
- again.
- * syscalls.cc (seteuid): Rearranged. Call `create_token' now when
- needed. Call `subauth' if `create_token' fails. Try setting token
- owner and primary group only if token was not explicitely created
- by `create_token'.
- * uinfo.cc (internal_getlogin): Try harder to generate correct user
- information. Especially don't trust return value of `GetUserName'.
-
-Sat May 19 21:16:07 2001 Christopher Faylor <cgf@cygnus.com>
-
- * fork.cc (fork_parent): Move atforkprepare call here.
- (fork): From here.
-
-Sat May 19 18:35:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * autoload.cc: Add missing load statement for `CancelIo'.
-
-Sat May 19 01:22:43 2001 Christopher Faylor <cgf@cygnus.com>
-
- * grp.cc (read_etc_group): Don't copy mutex on fork.
- * pwd.cc (read_etc_passwd): Ditto.
- * autoload.cc (LoadDLLfuncEx): Use LoadDLLprime to initialize DLL
- specific area.
-
-Fri May 18 10:31:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * net.cc (wsock_event::wait): Explicitely cancel IO when a signal
- arrived to avoid data loss. Fallback to blocking IO when canceling
- fails.
-
-Thu May 17 15:29:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * security.cc (cygwin_set_impersonation_token): Never destroy
- previous token object.
- (subauth): Create token source with well defined identifier.
-
-Wed May 16 23:27:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * uinfo.cc (uinfo_init): Just set user token to INVALID_HANDLE_VALUE.
- Token value is already invalid at that point.
-
-Wed May 16 21:34:00 2001 Fred Yankowski <fred@ontosys.com>
-
- * net.cc (errmap): Add missing mapping from WSAEINTR to EINTR.
-
-Wed May 16 09:20:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * sec_helper.cc (legal_sid_type): Fix conditional. Change to
- inline function.
-
-Wed May 16 01:01:48 2001 Christopher Faylor <cgf@cygnus.com>
-
- * autoload.h: Eliminate.
- * autoload.cc: Pull in autoload.h. Eliminate many macros. Rewrite to
- avoid necessity of initialization routines. Just use a standard one.
- (wsock_init): New function. Moved from net.cc.
- * net.cc (wsock_init): Move to autoload.cc.
- (wsadata): Make global.
- * dtable.cc (dtable::build_fhandler): Use more reliable method for
- checking if net stuff has been loaded.
-
-Tue May 15 19:52:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * fork.cc (fork): Eliminate superfluous call to getuid().
- * security.h: New define `NO_SID'. Remove declarations of functions
- moved to methods into class cygsid.
- (class cygsid): Declare new methods `getfromstr', `get_sid',
- `getfrompw', `getfromgr', `get_rid', `get_uid', `get_gid', `string'
- and new constructors and operators =, == and !=.
- Declare new global cygsids `well_known_XXX_sid' substituting the
- corresponding `get_XXX_sid' functions. Remove declarations of
- these functions.
- * sec_helper.cc (well_known_admin_sid): New global variable.
- (well_known_system_sid): Ditto
- (well_known_creator_owner_sid): Ditto
- (well_known_world_sid): Ditto
- (cygsid::string): New method, substituting `convert_sid_to_string_sid'.
- (cygsid::get_sid): New method, substituting `get_sid'.
- (cygsid::getfromstr): New method, substituting
- `convert_string_sid_to_sid'.
- (cygsid::getfrompw): New method, substituting `get_pw_sid'.
- (cygsid::getfromgr): New method, substituting `get_gr_sid'.
- (cygsid::get_id): New method, substituting `get_id_from_sid'.
- (get_admin_sid): Eliminated.
- (get_system_sid): Ditto.
- (get_creator_owner_sid): Ditto.
- (get_world_sid): Ditto.
- * grp.cc: Use new cygsid methods and well known sids throughout.
- * registry.cc: Ditto.
- * sec_acl.cc: Ditto.
- * security.cc: Ditto.
- * shared.cc: Ditto.
- * syscalls.cc (seteuid): Ditto. Eliminate redundant conditional.
- * uinfo.cc (internal_getlogin): Ditto.
- * spawn.cc (spawn_guts) Revert previous patch.
-
-Tue May 15 10:20:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * fhandler_socket.cc (fhandler_socket::ioctl): Convert s_addr
- field to host byte order before comparing with INADDR_LOOPBACK.
-
-Tue May 15 9:03:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * autoload.cc: Add autoload statements for ws2_32 functions
- `WSACloseEvent', `WSACreateEvent', `WSAGetOverlappedResult',
- `WSARecv', `WSARecvFrom', `WSASend', `WSASendTo' and `WSASetEvent',
- `WSAWaitForMultipleEvents'.
- * net.cc: Define wsock_evt.
- (wsock_event): New class.
- (cygwin_sendto): Use overlapped socket io if available.
- (cygwin_recvfrom): Ditto.
- (cygwin_recv): Ditto.
- (cygwin_send): Ditto.
- * security.cc (subauth): Set Win32 error to 0 to safely ask for the
- error code of dynamically loaded function `LsaRegisterLogonProcess'.
-
-Mon May 14 15:37:29 2001 Christopher Faylor <cgf@cygnus.com>
-
- * errno.cc (_sys_errlist): Add missing commas.
-
-Mon May 14 16:13:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * security.cc (subauth): Check if Secur32.dll could be loaded.
-
-Sun May 13 22:49:04 2001 Christopher Faylor <cgf@cygnus.com>
-
- * path.cc (path_conv::check): Revert allow_ntsec check so that volume
- info is always retrieved and isdisk setting is properly set.
-
-Sun May 13 14:02:36 2001 Christopher Faylor <cgf@cygnus.com>
-
- * fhandler_tty.cc (fhandler_tty_common::dup): Preserve O_NOCTTY when
- duping a filehandle.
-
-Sat May 12 18:19:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * dir.cc (rmdir): Rearrange slightly to allow removing directories
- even when R/O attribute is set.
-
-Fri May 11 16:53:38 2001 Christopher Faylor <cgf@cygnus.com>
-
- * external.cc (fillout_pinfo): Use correct pids.
- * path.cc (mount_info::conv_to_win32_path): Correct test for whether to
- include a slash.
-
-Fri May 11 01:04:17 2001 Christopher Faylor <cgf@cygnus.com>
-
- * exceptions.cc (handle_exceptions): Don't print message when executing
- from a cygwin program.
-
-2001-05-10 Egor Duda <deo@logos-m.ru>
- Christopher Faylor <cgf@redhat.com>
-
- * environ.cc (winenv): Always add SYSTEMDRIVE and SYSYEMROOT to
- win32-style environment if they don't already exist.
-
-2001-05-10 Kazuhiro Fujieda <fujieda@jaist.ac.jp>
-
- * path.cc (mount_info::conv_to_win32_path): Treat UNC paths the same as
- paths including `:' or `\'.
-
-Wed May 9 14:46:32 2001 Christopher Faylor <cgf@cygnus.com>
-
- * fhandler.h (fhandler_termios::echo_erase): Declare new method.
- * fhandler_termios.cc (fhandler_termios::echo_erase): New method for
- echoing erase characters.
- (fhandler_termios::line_edit): Check the echo flag before echoing
- control characters (from Kazuhiro Fujieda <fujieda@jaist.ac.jp>).
-
-Wed May 9 10:43:30 2001 Christopher Faylor <cgf@cygnus.com>
-
- * include/pthread.h: Remove C++ comment.
-
-Tue May 8 11:09:59 2001 Christopher Faylor <cgf@cygnus.com>
-
- * cygheap.cc (_cfree): Add regparm attribute.
- (_crealloc): Ditto.
-
- * dcrt0.cc (dll_crt0_1): Default to always checking for executable for now.
-
- * dtable.cc (dtable::not_open): Move method.
- * dtable.h (dtable): Here.
-
- * exceptions.cc (ctrl_c_handler): Don't expect process group leader to
- handle a signal if it doesn't exist.
-
- * fhandler.h (fhandler_base): Make openflags protected.
-
- * localtime.c (tzsetwall): Check for __CYGWIN__ as well as __WIN32__.
-
- * path.cc (path_conv::check): Add some comments. Change strcat to assignment.
-
- * lib/_cygwin_S_IEXEC.cc (_cygwin_bob__): Eliminate.
-
- * fhandler_tty.cc (fhandler_console::dup): Set controlling terminal if necessary.
- * fhandler_tty.cc (fhandler_tty_slave::dup): Ditto.
-
-Mon May 7 21:33:17 2001 Christopher Faylor <cgf@cygnus.com>
-
- * include/sys/file.h: Revert special X_OK usage. Just make it a
- constant.
-
-Sun May 6 17:05:00 2001 Robert Collins <rbtcollins@hotmail.com>
-
- * thread.h (pthread_cond): New element cond_access to allow atomic
- broadcasts.
- * thread.cc (pthread_cond::pthread_cond): Initialise cond_access.
- (pthread_cond::~pthread_cond): Destroy cond_access.
- (pthread_cond::Broadcast): Use cond_access.
- (pthread_cond::Signal): Use cond_access.
- (pthread_cond_wait): Use cond_access.
- (pthread_cond_timedwait): Use cond_access.
-
-Sun May 6 11:55:40 2001 Christopher Faylor <cgf@cygnus.com>
-
- * string.h (cygwin_strchr): Make 'static inline' so that things will
- still work when optimized.
-
-Sat May 5 01:04:11 2001 Christopher Faylor <cgf@cygnus.com>
-
- * exceptions.cc (handle_exceptions): Vastly increase test for exception
- loop guard variable.
-
-Fri May 4 22:23:33 2001 Christopher Faylor <cgf@cygnus.com>
-
- * exceptions.cc (stack_info): Add some controls.
- (stack_info::init): Add extra arguments to control method of
- initialization.. If we have a known good frame, set things up so that
- this frame is not skipped the first time through. Record whether
- caller cares about arguments or not.
- (stack_info::walk): Don't store arguments if they're unwanted.
- (stackdump): Add isexception parameter for use when called by exception
- handler.
- (cygwin_stackdump): Accomodate extra argument to stackdump.
- (handle_exceptions): Ditto.
- (sig_handle): Ditto.
- (interrupt_on_return): Accomodate extra arguments to stack walk
- initialization.
-
-Fri May 4 21:05:20 2001 Christopher Faylor <cgf@cygnus.com>
-
- * localtime.c: Revert exclusion of windows.h.
-
-Fri May 4 17:03:16 2001 Christopher Faylor <cgf@cygnus.com>
-
- * string.h: Fix last-minute typo.
-
-Fri May 4 16:49:34 2001 Christopher Faylor <cgf@cygnus.com>
-
- * pinfo.h: Correctly set __SIGOFFSET.
-
- * path.cc (hash_path_name): Avoid calling library functions for simple
- copying of characters.
-
- * shortcut.c: Use WIN32_LEAN_AND_MEAN.
- * smallprint.c: Ditto.
-
- * environ.cc (getwinenv): Minor clarity fix.
-
- * localtime.c: No need to include windows.h
-
- * string.h: New file.
-
-Fri May 4 16:37:30 2001 Christopher Faylor <cgf@cygnus.com>
-
- * exceptions.cc (ctrl_c_handler): Always send signal to process if it
- has no tty.
-
-2001-05-04 Egor Duda <deo@logos-m.ru>
-
- * fhandler_socket.cc (set_connect_secret): Use /dev/urandom to
- generate secret cookie.
-
-Thu May 3 16:37:55 2001 Christopher Faylor <cgf@cygnus.com>
-
- * include/pthread.h (pthread_cleanup_push): Eliminate space preceding
- arguments.
- (pthread_cleanup_pop): Ditto.
-
-Thu May 3 18:16:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * net.cc (wsock_init): Rename `was_in_progress' to `wsock_started'
- for clearness.
-
-Thu May 3 10:44:16 2001 Christopher Faylor <cgf@cygnus.com>
-
- * exceptions.cc (handle_exceptions): Break out of "loop" if the
- debugger doesn't seem to be attaching to our process.
-
-Wed May 2 20:18:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * autoload.cc: Use new definition of LoadDLLinitfunc throughout.
- Redefine wrapper for wsock32.dll and ws2_32.dll.
- (std_dll_init): New function.
- * autoload.h: Rename LoadDLLinitfunc to LoadDLLinitfuncdef.
- Add new defines LoadDLLinitfunc and LoadDLLstdfunc.
- * net.cc (wsock_init): Add guard variable handling. Take care
- to call WSAStartup only once. Load WSAStartup without using
- autoload wrapper to eliminate recursion. Eliminate FIONBIO
- and srandom stuff.
-
-Tue May 1 01:26:15 2001 Christopher Faylor <cgf@cygnus.com>
-
- * path.cc (mount_info::conv_to_win32_path): More path tweaking.
-
-Tue May 1 00:34:46 2001 Christopher Faylor <cgf@cygnus.com>
-
- * path.cc (mount_info::conv_to_win32_path): Fix debugging output to
- avoid a SIGSEGV. Avoid double backslashes in middle of filename.
-
-Mon Apr 30 21:51:14 2001 Christopher Faylor <cgf@cygnus.com>
-
- * path.cc (mkrelpath): New function.
- (mount_info::conv_to_win32_path): Eliminate now-unneeded relative path
- name arg and processing.
- (path_conv::check): Accomodate relative path names again. Accomodate
- one extra argument in mount_info::conv_to_win32_path. Tack trailing
- slash on end of relative path as a side effect, like before.
- * shared_info.h (mount_info::conv_to_win32_path): Reflect new argument
- ordering.
-
-Mon Apr 30 22:09:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * autoload.cc: Add LoadDLLinitfunc for secur32.dll.
- Add LoadDLLfuncEx statements for AllocateLocallyUniqueId@4,
- DuplicateTokenEx@24, LsaNtStatusToWinError@4,
- LsaDeregisterLogonProcess@4, LsaFreeReturnBuffer@4,
- LsaLogonUser@56, LsaLookupAuthenticationPackage@12,
- LsaRegisterLogonProcess@12,
- * environ.cc: Add extern declaration for `subauth_id'.
- (subauth_id_init): New function for setting `subauth_id'.
- (struct parse_thing): Add entry for `subauth_id'.
- * fork.cc (fork_parent): Call `RevertToSelf' and
- `ImpersonateLoggedOnUser' instead of `seteuid'.
- * security.cc: Define global variable `subauth_id'.
- (extract_nt_dom_user): New function.
- (cygwin_logon_user): Call `extract_nt_dom_user' now.
- (str2lsa): New static function.
- (str2buf2lsa): Ditto.
- (str2buf2uni): Ditto.
- (subauth): Ditto.
- * security.h: Add prototype for `subauth'.
- * spawn.cc (spawn_guts): Use cygheap->user.token only if impersonated.
- Use `cygsid' type. Remove impersonation before allowing access to
- workstation/desktop to everyone. Call `RevertToSelf' and
- `ImpersonateLoggedOnUser' instead of `seteuid'.
- * syscalls.cc (seteuid): Rearranged to allow using subauthentication
- to retrieve user tokens when needed.
-
-Mon Apr 30 20:26:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * uinfo.cc (internal_getlogin): Formatting change.
-
-Mon Apr 30 19:58:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * grp.cc: Eliminate MAX_DOMAIN_NAME define.
- (read_etc_group): Substitute MAX_DOMAIN_NAME by
- INTERNET_MAX_HOST_NAME_LENGTH.
- * passwd.cc (parse_pwd): Don't force pw_name to be lower case.
- * sec_helper.cc: Substitute MAX_USER_NAME by UNLEN,
- MAX_COMPUTERNAME_LENGTH by INTERNET_MAX_HOST_NAME_LENGTH throughout.
- (lookup_name): Slight cleanup.
- * security.cc (alloc_sd): Substitute MAX_USER_NAME by UNLEN.
- * security.h: Define DEFAULT_UID as DOMAIN_USER_RID_ADMIN and
- DEFAULT_GID as DOMAIN_ALIAS_RID_ADMINS.
- * shared.cc (memory_init): Substitute MAX_USER_NAME by UNLEN.
- * thread.h: Ditto.
- * uinfo.cc (internal_getlogin): Substitute MAX_USER_NAME by UNLEN.
- Substitute MAX_COMPUTERNAME_LENGTH and MAX_HOST_NAME by
- INTERNET_MAX_HOST_NAME_LENGTH.
- * winsup.h: Include lmcons.h. Eliminate MAX_USER_NAME and
- MAX_HOST_NAME. Move DEFAULT_UID and DEFAULT_GID to security.h.
-
-Mon Apr 30 12:35:40 2001 Christopher Faylor <cgf@cygnus.com>
-
- * path.cc (path_conv::check): Don't use path_flags when converting to
- MS-DOS syntax unless parsing tail of path component. Stop parsing path
- when we reach the 'root' of the path. Correctly copy tail to path
- component.
-
-Sun Apr 29 22:28:06 2001 Christopher Faylor <cgf@cygnus.com>
-
- * exceptions.cc (INIT_EXCEPTION_HANDLER): Eliminate.
- (init_exceptions): Just use init_exception_handler.
- (open_stackdumpfile): New function.
- (stack_info::first_time): Eliminate.
- (stack_info::init): Set up fields to avoid "first_time" consideration.
- (stack_info::walk): Remove "first_time" consideration.
- (stackdump): Change arguments to accept initial frame pointer and open
- stack file flag.
- (stack): Eliminate.
- (cygwin_stackdump): Use stackdump() rather than stack().
- (try_to_debug): Remove all synchronization logic. Just keep looping in
- exception handler until debugger notices us. Return 1 if successfully
- started debugger.
- (handle_exceptions): Just return if we know that we're debugging.
- Reorganize to avoid creating a stackdump file if we are starting a
- debugger. Return from exception handler if debugger started
- successfully.
- (sig_handle): Create a stackdump only if debugger wasn't started.
- * winsup.h (try_to_debug): Add an argument.
-
-Sun Apr 29 21:41:25 2001 Christopher Faylor <cgf@cygnus.com>
-
- * path.cc (symlink_info::check): Remove extra arguments, move
- functionality back to path_conv::check. Clear symlink bit from pflags
- argument before detecting if this is a symlink.
- (path_conv::check): Convert posix path here instead of
- symlink_info::check. Only grab volflags when using ntsec.
- (symlink_info::check_case): Just replace appropriate part of input
- path.
-
-Sat Apr 28 19:36:13 2001 Christopher Faylor <cgf@cygnus.com>
-
- Throughout, change 'tty_attached' to 'real_tty_attached', for clarity.
- Throughout, change 'OutputStopped' to 'output_stopped', for
- consistency.
- * dtable.cc (stdio_init): Set controlling tty if not set by stdio
- opens.
- * exceptions.cc (ctrl_c_handler): Avoid special pgid checking if no tty
- is associated with the process.
- (Suggested by Tim Baker <dbaker@direct.ca>)
- * external.cc (fillout_pinfo): Return actual tty number for ctty.
- * fhandler_console.cc (get_tty_stuff): Set ctty when shared memory is
- allocated. Accept flags input from open().
- (set_console_ctty): New function.
- (fhandler_console::open): Pass flags to get_tty_stuff and rely on this
- function to set the ctty, if appropriate.
- * fhandler_termios.cc (fhandler_termios::set_ctty): Move to tty_min
- class.
- * fhandler_tty.cc (fhandler_tty_slave::open): Use tc field to access
- set_ctty().
- * tty.h (TTY_CONSOLE): Move to include/sys/cygwin.h.
- (tty_min): Add set_ctty class here.
- * include/sys/cygwin.h (TTY_CONSOLE): New home here.
-
- * path.cc (symlink_info): Make contents an actual buffer. Pass more
- flags to case_check.
- (path_conv::check): Reorganize to do parsing based on posix path rather
- than native path.
- (symlink_info::check): Expect posix path as input. Translate to native
- path here. Accept path_conv flags. Stop parsing if not a symlink
- regardless of whether previous path was a symlink.
-
-2001-04-27 Kazuhiro Fujieda <fujieda@jaist.ac.jp>
-
- * thread.cc (thread_init_wrapper): Use _REENT_INIT to initialize the
- reent structure of newlib.
-
-Fri Apr 27 14:02:24 2001 Christopher Faylor <cgf@cygnus.com>
-
- * sigproc.h (sig_send): Add exception parameter to sig_send.
- * sigproc.cc (sig_send): Ditto. Use it when setting frame info.
- * exceptions.cc (handle_exceptions): Use exception flag when calling
- sig_send.
-
-2001-04-27 Egor Duda <deo@logos-m.ru>
-
- * tty.cc (tty::make_pipes): Set to_slave pipe mode to nonblocking.
- * fhandler_tty.cc (fhandler_pty_master::accept_input): If pipe buffer
- is full, give slave a chance to read data.
-
-2001-04-26 Kazuhiro Fujieda <fujieda@jaist.ac.jp>
-
- * security.cc (alloc_sd): Add unrelated ACCESS_ALLOWED_ACE behind
- the `everyone' ACE.
-
-Wed Apr 25 15:07:37 2001 Christopher Faylor <cgf@cygnus.com>
-
- * sigproc.h [sigthread]: Add exception field.
- [sigframe::~sigframe]: Clear exception field.
- [sigframe::set]: Set exception field from caller.
- * sigproc.cc (sig_send): Set exception field when frame pointer is
- passed in.
- * exceptions.cc (interrupt_on_return): Always treat exception as
- interruptible.
-
-2001-04-25 Egor Duda <deo@logos-m.ru>
-
- * cygwin.din: Export asctime_r, ctime_r, gmtime_r, localtime_r
- * include/cygwin/version.h: Bump CYGWIN_VERSION_API_MINOR to 39
-
-Wed Apr 25 10:57:36 2001 Christopher Faylor <cgf@cygnus.com>
-
- * include/cygwin/version.h: Bump minor version number.
- * childinfo.h: Bump child structure magic number.
-
-2001-04-25 Kazuhiro Fujieda <fujieda@jaist.ac.jp>
-
- * uinfo.cc (internal_getlogin): Return pointer to struct passwd.
- (uinfo_init): Accommodate the above change.
- * syscalls.cc (seteuid): Ditto.
-
-Tue Apr 25 11:08:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * autoload.cc: Add LoadDLLfunc statements for SetTokenInformation@16.
- * cygheap.cc: Include security.h.
- * grp.cc (internal_getgrent): New function.
- (getgroups): Rearranged using `internal_getgrent' and the new
- `cygsid' class.
- * passwd.cc (internal_getpwent): New function.
- * sec_acl.cc: Use new `cygsid' class throughout.
- (acl_access): Use `internal_getgrent' instead of `getgrent'.
- * sec_helper.cc: Use new `cygsid' class throughout.
- (get_id_from_sid): Use `internal_getgrent' instead of `getgrent'.
- Use `internal_getpwent' instead of `getpwent'.
- * security.cc: Use new `cygsid' class throughout.
- * security.h: Move `MAX_SID_LEN' from winsup.h to here.
- Add extern declarations for `internal_getgrent' and `internal_getpwent'.
- (class cygsid): New class.
- * shared.cc (sec_user): Use new `cygsid' class.
- * syscalls.cc (seteuid): Try to set owner to user and primary group to
- current group in impersonation token before performing impersonation.
- (setegid): Try to set primary group in process token to the new group
- if ntsec is on.
- * uinfo.cc (internal_getlogin): Use new `cygsid' class.
- Try to set owner to user and primary group to current group in process
- token if the process has been started from a non cygwin process.
- (uinfo_init): Set primary group only if the process has been started
- from a non cygwin process.
- * winsup.h: Move define for `MAX_SID_LEN' to security.h.
-
-Mon Apr 16 23:20:00 2001 Andy Younger <andylyounger@hotmail.com>
-
- * fhandler_dsp.cc: Improved handling of 8 bit playback modes.
- Put in mock support for SNDCTL_DSP_SETFRAGMENT.
-
-Tue Apr 24 23:51:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * passwd.cc (getpwnam_r): Add pw_passwd handling as well.
- (getpwuid_r): Ditto.
-
-Tue Apr 24 23:43:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * passwd.cc (getpwnam_r): Use correct offsets into buffer.
- Copy pw_gecos field as well.
- (getpwuid_r): Ditto.
-
-2001-04-24 Egor Duda <deo@logos-m.ru>
-
- * dlmalloc.c: New file. Port of Doug Lea's malloc
- * dlmalloc.h: Ditto.
- * Makefile.in: Add support for MALLOC_DEBUG
- * config.h.in: Ditto.
- * winsup.h: Ditto.
- * configure.in: Add --enable-malloc-debugging option.
- * configure: Regenerate.
- * debug.h: Include declarations for debugging malloc.
- * tty.cc (grantpt): Fix definition.
- (unlockpt): Ditto.
-
-Mon Apr 23 22:00:29 2001 Christopher Faylor <cgf@cygnus.com>
-
- Remove trailing underscore from fhandler_base and friends, throughout.
- * fhandler.h (fhandler_base::set_open_status): New method. Stores
- original open status.
- (fhandler_base::get_open_status): New method. Retrieves original open
- status.
- (fhandler_base::reset_to_open_binmode): New method.
- * fhandler.cc (fhandler_base::open): Save open status.
- (fhandler_base::init): Ditto.
- * fhandler_clipboard.cc (fhandler_clipboard::open): Ditto.
- * fhandler_console.cc (fhandler_console::open): Ditto.
- * fhandler_dsp.cc (fhandler_dsp::open): Ditto.
- * fhandler_dev_mem.cc (fhandler_dev_mem::open): Ditto.
- * fhandler_dev_random.cc (fhandler_dev_random::open): Ditto.
- * fhandler_serial.cc (fhandler_serial::open): Ditto.
- * fhandler_tty_slave.cc (fhandler_tty_slave::open): Ditto.
- * fhandler_tty_master.cc (fhandler_tty_master::open): Ditto.
- * fhandler_dev_zero.cc (fhandler_dev_zero::open): Ditto.
- * syscalls.cc (setmode): Rework so that 0 mode value causes reversion
- to open state.
-
- * fhandler_tty_slave.cc (fhandler_tty_slave::read): Use correct
- multiplier when converting from deciseconds to milliseconds.
-
-Mon Apr 23 13:28:35 2001 Christopher Faylor <cgf@cygnus.com>
-
- * fhandler.h (fhandler_base::clear_r_binary): New method.
- (fhandler_base::clear_w_binary): New method.
- * syscalls.cc (setmode): Accept 0 as mode value. Resets text/binary
- behavior for fd to default.
-
-Mon Apr 23 12:46:07 2001 Christopher Faylor <cgf@cygnus.com>
-
- * net.cc [errmap]: Add '0' condition.
- (find_winsock_errno): Don't translate no error to EPERM.
-
-Sun Apr 22 20:48:24 2001 Christopher Faylor <cgf@cygnus.com>
-
- * include/cygwin/version.h: Bump Cygwin version and API version.
-
-Mon Apr 23 9:27:00 2001 Robert Collins <rbtcollins@hotmail.com>
-
- * thread.cc (MTinterface::Init): Always initialise per process variables.
-
-Sun Apr 22 19:18:18 2001 Christopher Faylor <cgf@cygnus.com>
-
- * features.h: Reinstate as wrapper for sys/features.h.
-
-Mon Apr 23 0:10:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * security.cc (alloc_sd): Reformat comment.
- * shared.cc: Drop function declarations already in security.h.
-
-Sun Apr 22 12:17:57 2001 Christopher Faylor <cgf@cygnus.com>
-
- * shortcut.c (check_shortcut): Close input file handle before
- returning.
- * path.cc (check_sysfile): Ditto.
- (symlink_info::check): Rely on opened file handle being closed by
- symlink checking routines. Set ext_tacked_on when .lnk is detected.
-
-Sat Apr 21 19:26:05 2001 Christopher Faylor <cgf@cygnus.com>
-
- * thread.cc (MTinterface::Init): Remove accidentally checked in code.
-
-Sun Apr 22 00:22:00 2001 Robert Collins <rbtcollins@hotmail.com>
-
- * passwd.cc (getpwuid): Check for thread cancellation.
- (getpwuid_r): Ditto.
- (getpwname): Ditto.
- (getpwnam_r): Ditto.
- * thread.h (pthread_mutex): New constructors for pshared operation.
- (MTinterface): Associative array for pshared mutex's.
- * thread.cc (MTinterface::Init): Initailize pshared mutex array.
- (pthread_cond::BroadCast): Implementation notes.
- (pthread_cond::TimedWait): Remove use of SignalObjectAndWait on non-NT systems.
- (pthread_mutex::pthread_mutex(unsigned short)): New function.
- (pthread_mutex::pthread_mutex (pthread_mutex_t *, pthread_mutexattr *)):New function.
- (pthread_mutex::pthread_mutex(pthread_mutexattr *)): Fail on pshared mutex's.
- (__pthread_mutex_getpshared): New function.
- (__pthread_join): Check for thread cancellation.
- (__pthread_cond_timedwait): Support pshared mutex's.
- (__pthread_cond_wait): Ditto.
- (__pthread_condattr_setpshared): Error on PROCESS_SHARED requests.
- (__pthread_mutex_init): Support pshared mutex's.
- (__pthread_mutex_getprioceiling): Ditto.
- (__pthread_mutex_lock): Ditto.
- (__pthread_mutex_trylock): Ditto.
- (__pthread_mutex_unlock): Ditto.
- (__pthread_mutex_destroy): Ditto.
- (__pthread_mutex_setprioceiling): Ditto.
- (__pthread_mutexattr_setpshared): Support PTHREAD_PROCESS_PSHARED requests.
-
-Fri Apr 20 19:38:29 2001 Christopher Faylor <cgf@cygnus.com>
-
- * cygwin.din: Add *scanf and *scan_r functions.
-
-Fri Apr 20 22:25:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * security.cc (set_process_privileges): Swap out.
- * sec_helper.cc (set_process_privilege): Rename from
- `set_process_privileges'. Takes the privilege to enable or disable
- as parameter now.
- * security.h: Add prototype for `set_process_privileges'.
-
-2001-04-19 Egor Duda <deo@logos-m.ru>
-
- * path.cc (path_conv::check): Always initialize member variables.
-
-Fri Apr 20 12:27:49 2001 Christopher Faylor <cgf@cygnus.com>
-
- * include/sys/file.h: More cleanup for X_OK.
-
-Fri Apr 20 11:48:45 2001 Christopher Faylor <cgf@cygnus.com>
-
- * include/sys/file.h: Move X_OK protection earlier.
-
- * dtable.cc (dtable::vfork_child_fixup): Avoid closing already closed
- handles.
-
-Fri Apr 20 16:29:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * grp.cc (getgroups): Change so that SIDs get compared instead
- of strings to SIDs.
-
-Fri Apr 20 14:50:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * Makefile.in: Add object files `sec_helper.cc' and `sec_acl.cc'.
- * security.cc: Swap out several functions.
- * sec_acl.cc: New file. Move Sun compatibel ACL functions from
- `security.cc' to here.
- * sec_helper.cc: New file. Move security helper functions from
- `security.cc' to here.
- * security.h: Changed to accomodate the above changes.
-
-Fri Apr 20 14:12:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * grp.cc: Replace `group_in_memory_p' by `group_state'.
- Eliminate group_sem throughout.
- (enum grp_state): New enumeration type.
- (read_etc_group): Make race safe.
- * security.cc: Eliminate group_sem throughout.
-
-Thu Apr 19 9:40:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * mmap.cc (mmap): Drop usage of the same memory area if the same
- region of the same file is mapped twice.
-
-Wed Apr 18 16:53:54 2001 Christopher Faylor <cgf@cygnus.com>
-
- Throughout, change fdtab references to cygheap->fdtab.
- * child_info.h (cygheap_exec_info): Eliminate special fdtab stuff.
- * spawn.cc (spawn_guts): Ditto.
- * cygheap.cc (cygheap_init): Initialize fdtab, if appropriate.
- * cygheap.h (CYGHEAPSIZE): Include size of init_cygheap.
- (_cmalloc_entry): Include fdtab here.
- * dtable.h (dtable): Declare/define new methods.
- * dtable.cc (dtable::vfork_child_fixup): New method.
- (dtable::fixup_after_exec): Remove unneeded extra arguments.
- * dcrt0.cc (dll_crt0_1): Ditto.
-
- * environ.cc (getwinenv): Use case sensitive comparison.
- (winenv): Make a copy of environment cache to avoid realloc problems
- when duplicate environment variables exist in the environment. (From
- Egor Duda)
-
- * net.cc (cygwin_socket): Revert Apr 14 change.
-
- * include/sys/file.h: Protect against previous X_OK definition.
-
-Tue Apr 17 12:18:28 2001 Christopher Faylor <cgf@cygnus.com>
-
- * passwd.cc: Eliminate passwd_sem throughout.
- * security.cc: Ditto.
-
-Tue Apr 17 12:18:28 2001 Robert Collins <rbtcollins@hotmail.com>
-
- * cygwin.din: Export New functions.
- * passwd.cc (read_etc_passwd): Make race safe.
- (getpwuid_r): New function.
- (getpwnam_r): New function.
-
-2001-04-18 Egor Duda <deo@logos-m.ru>
-
- * grp.cc (getgroups): Avoid crash if passwd field if /etc/group is
- empty.
-
-Tue Apr 17 19:05:44 2001 Christopher Faylor <cgf@cygnus.com>
-
- * path.h (path_conv::add_ext_from_sym): Declare.
- * path.cc (path_conv::add_ext_from_sym): Convert to pure inline method.
-
-Tue Apr 17 18:50:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * path.cc (windows_device_names): Add missing NULL element.
-
-Tue Apr 17 12:14:54 2001 Christopher Faylor <cgf@cygnus.com>
-
- * path.cc (windows_device_names): Move dsp to proper location.
-
-Tue Apr 17 13:44:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * path.cc (path_conv::check): Set case_clash even if pcheck_case
- is set to PCHECK_ADJUST when a case clash is given for the last
- component in path.
- (symlink_info::case_check): Ditto.
- * syscalls.cc (_rename): Avoid overwriting an already existing file
- if a case clash is given even if pcheck_case is set to PCHECK_ADJUST.
-
-Tue Apr 17 2:07:07 2001 Christopher Faylor <cgf@cygnus.com>
-
- * config.h.in: Turn off VFORK again.
-
-Mon Apr 16 23:45:24 2001 Christopher Faylor <cgf@cygnus.com>
-
- * path.h (cwdstuff): Move class.
- * cygheap.h (cwdstuff): To here.
- (init_cygheap): Add cwd field.
- * child_info.h (cygheap_exec_info): Eliminate cwd stuff.
- (child_info_spawn): Ditto.
- * dcrt0.cc (dll_crt0_1): Remove cygcwd.fixup_after_exec call. Convert
- cygcwd reference to cygheap->cwd.
- * path.cc: Ditto, throughout.
- (cwdstuff::copy): Eliminate.
- (cwdstuff::fixup_after_exec): Ditto.
- * spawn.cc (spawn_guts): Eliminate call to cygcwd.copy.
-
- * fhandler.h (FH_OSS_DSP): Move into "fast" device category.
-
-Mon Apr 16 19:19:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * mmap.cc: Move fh_paging_file from some functions to be
- a global static variable.
- (class mmap_record): Add `devtype_' member to remember
- the device type of the file. Add declaration for methods
- `get_device', `alloc_fh' and `free_fh'.
- (mmap_record::mmap_record): Initialize `devtype_' correctly.
- (mmap_record::alloc_fh): New method.
- (mmap_record::free_fh): Ditto.
- (munmap): Use new mmap_record::alloc_fh and mmap_record::free_fh
- methods to create a correct fhandler.
- (msync): Ditto.
- (fixup_mmaps_after_fork): Ditto.
-
-Mon Apr 16 16:01:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * grp.cc (getgroups): If `allow_ntsec' is set, use the process token
- information to evaluate the groups list.
-
-Mon Apr 16 00:08:02 2001 Christopher Faylor <cgf@cygnus.com>
-
- * features.h: Remove this file as it is now being supplied by newlib.
-
-Sun Apr 15 23:23:29 2001 Christopher Faylor <cgf@cygnus.com>
-
- * autoload.cc: Add winmm functions needed by fhandler_dsp.cc.
-
-Sun Apr 15 22:53:52 2001 Andy Younger <andylyounger@hotmail.com>
-
- * fhandler_dsp.cc: New file. Implements OSS like /dev/dsp.
- * include/sys/soundcard.h: New file. User land includes for OSS
- /dev/dsp.
- * fhandler.h: Add new class fhandler_dev_dsp and a FH_OSS_DSP
- definition.
- * dtable.cc (dtable::build_fhandler): Allow creation of the /dev/dsp
- device.
- * path.cc (windows_device_names): Add /dev/dsp into list of device
- names.
- * Makefile.in (DLL_OFILES): Add fhandler_dsp.o.
-
-Sun Apr 15 16:36:27 2001 Christopher Faylor <cgf@cygnus.com>
-
- * uname.c (uname): Default n in in86 to 6 if Windows returns > 6.
-
-Sun Apr 15 15:56:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * path.cc (add_ext_from_sym): Redefine to call `add_ext_from_sym_'.
- (add_ext_from_sym_): New inline function.
-
-Sat Apr 14 19:23:52 2001 Christopher Faylor <cgf@cygnus.com>
-
- * config.h.in: Turn on VFORK by default.
-
-Sat Apr 14 18:04:35 2001 Christopher Faylor <cgf@cygnus.com>
-
- * net.cc (cygwin_socket): Set SO_LINGER to small value so closed UNIX
- domain sockets will not stay around.
-
-Sat Apr 14 18:01:43 2001 Pierre A. Humblet <Pierre.Humblet@ieee.org>
-
- * select.cc (socket_cleanup): Set SO_LINGER to small value so closed
- dummy sockets do not stay around. Use correct value for second argument
- to shutdown.
-
-Sat Apr 14 17:04:00 2001 Robert Collins <rbtcollins@hotmail.com>
-
- * thread.h (MTinterface): Add threadcount.
- * thread.cc (MTinterface::Init): Set threadcount to 1.
- (__pthread_create): Increment threadcount.
- (__pthread_exit): Decrement threadcount and call exit() from the last thread.
-
-Fri Apr 13 11:34:24 2001 Robert Collins <rbtcollins@hotmail.com>
-
- * fork.cc (fork_child): Call the __pthread_atforkchild function.
- (fork_parent): Call the __pthread_atforkparent function.
- * cygwin.din: Export pthread_atfork.
- * thread.h (callback): New class.
- (MTinterface): Use it.
- * thread.cc (__pthread_atforkprepare): New function.
- (__pthread_atforkparent): New function.
- (__pthread_atforkchild): New function.
- (__pthread_atfork): New function.
- * pthread.cc (pthread_atfork): New function.
-
-Fri Apr 13 9:52:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * path.cc (add_ext_from_sym): New define evaluating `known'suffix'.
- (path_conv::check): Use add_ext_from_sym throughout.
-
-Thu Apr 12 23:19:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * dir.cc (mkdir): Check for case clash.
- * environ.cc: Add extern declaration for `pcheck_case'.
- (check_case_init): New function.
- (struct parse_thing): Add "check_case" option.
- * errno.cc (_sys_nerrlist): Add text for ECASECLASH.
- (strerror): Add case branch for ECASECLASH.
- * fhandler.cc (fhandler_disk_file::open): Check for case clash.
- * path.cc: Add global variable `pcheck_case'.
- (struct symlink_info): Add member `case_clash' and method `case_check'.
- (path_prefix_p_): Call `pathnmatch' instead of `strncasematch'.
- (pathnmatch): New funtion.
- (pathmatch): Ditto.
- (path_conv::check): Add handling for case checking.
- (symlink): Check for case clash.
- (symlink_info::check): Add parameter for case checking.
- Handle case checking.
- (symlink_info::case_check): New method.
- (chdir): Don't use unconverted path if pcheck_case==PCHECK_STRICT.
- * path.h: Add extern declarations for `pathmatch' and
- `pathnmatch'.
- (enum case_checking): New enumeration type describing
- the case checking behaviour of path conversion routines.
- (class path_conv): Add member `case_clash'.
- * syscalls.cc (_link): Check for case clash.
-
-Thu Apr 12 12:49:53 2001 Christopher Faylor <cgf@cygnus.com>
-
- * syscalls.cc (mkfifo): New function stub.
-
-2001-04-12 Robert Collins <rbtcollins@hotmail.com>
-
- * configure.in: Remove PTH_ALLOW.
- * cygwin.din: Remove @PTH_ALLOW@ prefixes to pthread functions. Add
- new pthread exports.
- * pthread.cc: New wrapper functions for the above new exports.
- * sched.cc (valid_sched_parameters): New function.
- (sched_setparam): Use it.
- (sched_set_thread_priority): New function. Used by pthread_sched*.
- * thread.cc (pthread_key_destructor::InsertAfter): New function.
- (pthread_key_destructor::UnlinkNext): New function.
- (pthread_key_destructor::Next): New function.
- (pthread_key_destructor_list::Insert): New function.
- (pthread_key_destructor_list::Remove): New function.
- (pthread_key_destructor_list::Pop): New function.
- (pthread_key_destructor::pthread_key_destructor): New function.
- (pthread_key_destructor_list::IterateNull): New function.
- (MTinterface::Init): Initialise new member.
- (pthread::pthread): Initialise new members.
- (pthread::create): Copy new attributes. Set the new thread priority.
- (pthread_attr::pthread_attr): Initialise new members.
- (pthread_key::pthread_key): Setup destructor function.
- (pthread_key::~pthread_key): Remove destructor function.
- (pthread_mutexattr::pthread_mutexattr): New function.
- (pthread_mutexattr::~pthread_mutexattr): New function.
- (__pthread_once): New function.
- (__pthread_cleanup): New function.
- (__pthread_cancel): New function.
- (__pthread_setcancelstate): New function.
- (__pthread_setcanceltype): New function.
- (__pthread_testcancel): New function.
- (__pthread_attr_getinheritsched): New function.
- (__pthread_attr_getschedparam): New function.
- (__pthread_attr_getschedpolicy): New function.
- (__pthread_attr_getscope): New function.
- (__pthread_attr_setinheritsched): New function.
- (__pthread_attr_setschedparam): New function.
- (__pthread_attr_setschedpolicy): New function.
- (__pthread_attr_setscope): New function.
- (__pthread_exit): Call any key destructors on thread exit.
- (__pthread_join): Use the embedded attr values.
- (__pthread_detach): Use the embedded attr values.
- (__pthread_getconcurrency): New function.
- (__pthread_getschedparam): New function.
- (__pthread_key_create): Pass the destructor on object creation.
- (__pthread_key_delete): Correct incorrect prototype.
- (__pthread_setconcurrency): New function.
- (__pthread_setschedparam): New function.
- (__pthread_cond_timedwait): Support static mutex initialisers.
- (__pthread_cond_wait): Ditto.
- (__pthread_mutex_getprioceiling): New function.
- (__pthread_mutex_lock): Support static mutex initialisers.
- (__pthread_mutex_trylock): Ditto.
- (__pthread_mutex_unlock): Ditto.
- (__pthread_mutex_destroy): Ditto.
- (__pthread_mutex_setprioceiling): New function.
- (__pthread_mutexattr_getprotocol): New function.
- (__pthread_mutexattr_getpshared): New function.
- (__pthread_mutexattr_gettype): New function.
- (__pthread_mutexattr_init): New function.
- (__pthread_mutexattr_destroy): New function.
- (__pthread_mutexattr_setprotocol): New function.
- (__pthread_mutexattr_setprioceiling): New function.
- (__pthread_mutexattr_getprioceiling): New function.
- (__pthread_mutexattr_setpshared): New function.
- (__pthread_mutexattr_settype): New function. Remove stubs for non
- MT_SAFE compilation.
- * thread.h: Remove duplicate #defines. Add prototypes for new
- functions in thread.cc.
- (pthread_key_destructor): New class.
- (pthread_key_destructor_list): New class.
- (pthread_attr): Add new members.
- (pthread): Remove members that are duplicated in the pthread_attr
- class.
- (pthread_mutex_attr): Add new members.
- (pthread_once): New class.
- * include/pthread.h: Add prototypes for new functions exported from
- cygwin1.dll. Remove typedefs.
- * include/sched.h: Add prototypes for new functions in sched.cc.
- * include/cygwin/types.h: Add typedefs from pthread.h
-
-Tue Apr 10 22:02:53 2001 Christopher Faylor <cgf@cygnus.com>
-
- * path.cc (struct symlink_info): Add extn and ext_tacked_on fields.
- (path_conv::check): Only tack on extension if a known one didn't
- already exist.
- (suffix_scan::has): Return pointer to known extension.
- (symlink_info::check): Record location of extension, if any.
-
-2001-04-09 Egor Duda <deo@logos-m.ru>
-
- * fhandler.h (class fhandler_socket): Add members and methods to
- support secure connections on AF_UNIX sockets.
- * fhandler_socket.cc (fhandler_socket::set_connect_secret): New method.
- (fhandler_socket::get_connect_secret): Ditto.
- (fhandler_socket::create_secret_event): Ditto.
- (fhandler_socket::close_secret_event): Ditto.
- (fhandler_socket::check_peer_secret_event): Ditto.
- (fhandler_socket::fixup_after_fork): Duplicate secret event to child.
- (fhandler_socket::dup): Copy address family.
- (fhandler_socket::close): Close secret event.
- * net.cc (get_inet_addr): Read secret cookie.
- (cygwin_connect): Check if peer knows secret cookie value.
- (cygwin_accept): Ditto. Copy address family to newly created socket.
- (cygwin_bind): Generate and write secret cookie.
- (wsock_init): Initialize random number generator.
-
-Sun Apr 8 20:40:58 2001 Christopher Faylor <cgf@cygnus.com>
-
- * Makefile.in: Put -lgcc last in list of libraries, since stdc++
- library needs it.
- * cygwin.din: Remove obsolete "__empty" export.
- * exceptions.cc (call_signal_handler_now): Force inclusion of function
- even when -finline-functions is specified.
- * sigproc.h: Remove obsolete call_signal_handler declaration.
-
-Sun Apr 8 20:36:55 2001 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
-
- * fhandler_console.cc (cp_get_internal): New function.
- (cp_convert): New function.
- (con_to_str): New function.
- (str_to_con): New function.
- (fhandler_console::read): Replace OemToCharBuff with con_to_str.
- (fhandler_console::write_normal): Replace CharToOemBuff with str_to_con.
-
-Thu Apr 5 22:41:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * syscalls.cc (stat_worker): Fix conditional which still allowed
- successful stat'ing of non-existant files.
-
-Wed Apr 4 10:37:44 2001 Christopher Faylor <cgf@cygnus.com>
-
- * child_info.h: Bump magic number for fork/exec/spawn.
-
-Tue Apr 3 20:06:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * errno.cc (errmap): Map ERROR_FILE_INVALID to ENXIO.
-
-Mon Apr 2 22:48:58 2001 Christopher Faylor <cgf@cygnus.com>
-
- * cygrun.c (main): Fix compiler warning.
- * gmon.c (_mcleanup): Ditto.
- * profil.c (profile_off): Ditto.
-
- * net.cc (find_winsock_errno): New function.
- (__set_winsock_errno): Use find_winsock_errno.
- (cygwin_setsockopt): Detect SO_ERROR for debugging.
- (cygwin_getsockopt): Ditto. Translate error when getsockopt returns
- SO_ERROR.
- * winsup.h: regparmize __set_winsock_errno.
- * include/sys/strace.h: Document that strace functions can't use
- regparm.
-
-2001-04-02 Kazuhiro Fujieda <fujieda@jaist.ac.jp>
-
- * fhandler.cc (fhandler_disk_file::open): Avoid checking a magic
- number of a directory.
-
-Mon Apr 2 00:24:08 2001 Christopher Faylor <cgf@cygnus.com>
-
- * shared_info.h (mount_info): Remove mnt_ elements.
- * thread.h (struct _winsup_t): Add mnt_ elements.
- * path.cc (fillout_mntent): Use mnt_ elements from reent_winsup ().
-
-Sun Apr 1 20:10:34 2001 Christopher Faylor <cgf@cygnus.com>
-
- * exceptions.cc (sigframe::call_signal_handler): Return value of
- call_signal_handler_now.
- * sigproc.h (sigframe): Use constructor.
- * syscalls.cc (_read): Correct errno test prior to calling signal
- handler.
-
-Sun Apr 1 00:38:06 2001 Christopher Faylor <cgf@cygnus.com>
-
- * exceptions.cc (sigframe::call_signal_handler): Move outside of "C"
- block or some compilers will complain.
-
-Sun Apr 1 00:24:14 2001 Christopher Faylor <cgf@cygnus.com>
-
- * exceptions.cc (call_signal_handler_now): Rename from
- call_signal_handler to avoid C++ confusion.
-
-Sun Apr 1 00:08:15 2001 Christopher Faylor <cgf@cygnus.com>
-
- * path.cc (fillout_mntent): Always remove drive root directories from
- future consideration by "/cygdrive" reporting.
- (cygdrive_getmnt): Avoid reporting removable drives or drives with no
- media mounted.
-
-Sat Mar 31 21:56:19 2001 Christopher Faylor <cgf@cygnus.com>
-
- * thread.h (struct _winsup_t): Remove obsolete elements. Add
- available_drives element.
- * path.cc (mount_info::getmntent): Report "/cygdrive" drives when
- mounted drives are exhausted.
- (fillout_mntent): New function.
- (mount_item::getmntent): Use fillout_mntent.
- (cygdrives_mntent): New function. Returns next available "/cygdrive".
- (setmntent): Initialize available "/cygdrives".
- * syscalls.cc: Remove some if 0'ed code.
- * times.cc (timezone): Use more descriptive variable name.
-
-Sat Mar 31 18:59:52 2001 Christopher Faylor <cgf@cygnus.com>
-
- * sigproc.h (class sigframe): Implement 'unregister()' method.
- (sigframe::~sigframe): Use unregister method.
- (sigframe::call_signal_handler): Declare new method.
- * exceptions.cc (sigframe::call_signal_handler): New method.
- Unregisters current sigframe before calling signal handler.
- (setup_handler): Clear waiting threads prior to arming signal_arrived.
- * syscalls.cc (_read): Change goto to loop. Recalculate sigframe
- inside of loop so that constructor is called when appropriate.
- * wait.cc (wait4): Ditto.
-
- * signal.cc: Change "sig" to "signal" in debugging messages throughout.
- * sigproc.cc: Ditto.
-
-Sat Mar 31 17:12:08 2001 Christopher Faylor <cgf@cygnus.com>
-
- * fhandler_serial.cc (fhandler_serial::raw_write): Close protected
- handles with ForceCloseHandle or suffer spurious warnings.
-
-Sat Mar 31 16:23:32 2001 Christopher Faylor <cgf@cygnus.com>
-
- * fhandler.cc (fhandler_base::read): Remove special handling of CTRL-Z.
-
-Sat Mar 31 11:09:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * fhandler.h (class fhandler_console): Add members `insert_mode'.
- * fhandler_console.cc (fhandler_console::dup): Duplicate `insert_mode'.
- (fhandler_console::fhandler_console): Initialize `insert_mode'.
- (fhandler_console::char_command): Add terminal capabilities
- "enter insert mode" = \E[4h and "exit insert mode" = \E[4l.
- Care for insert mode on terminal capability "repeat char" = \E[x;yb.
- (fhandler_console::write_normal): Care for insert mode before writing
- to the console.
- (array keytable): Add keymapping for modified cursor and control
- block keys (xterm like).
-
-Fri Mar 30 13:02:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * fhandler.h (class fhandler_console): Add members `savebufsiz' and
- `savebuf' to allow save/restore of screen.
- * fhandler_console.cc (fhandler_console::dup): Duplicate `savebufsiz'
- and `savebuf'.
- (fhandler_console::fhandler_console): Initialize `savebufsiz' and
- `savebuf'.
- (fhandler_console::char_command): Add terminal capabilities
- "save screen content" = \E[?47h and "restore screen content" = \E[?47l.
-
-Wed Mar 28 19:28:50 2001 Christopher Faylor <cgf@cygnus.com>
-
- * path.cc (chdir): Eat trailing whitespace on input path.
-
-Tue Mar 27 22:38:42 2001 Christopher Faylor <cgf@cygnus.com>
-
- * lib/_cygwin_S_IEXEC.c: Remove "const" from globals or they never seem
- to be defined. Wrap definitions in extern "C". Include winsup.h to
- assure proper definitions.
-
- * dcrt0.cc (dll_crt0_1): Call stdio_init after premain run so that
- binmode.o, etc., will control default stdio settings.
- * dtable.cc (dtable::init_std_file_from_handle): Allow __fmode to force
- binmode/textmode settings. Default pipes to binmode.
-
-Tue Mar 27 11:31:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * mmap.cc (mmap): Fix conditional for previous patch.
-
-Mon Mar 26 18:48:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * mmap.cc (mmap): Outflank copy-on-write problem on 9x by
- setting access mode to FILE_MAP_READ when read access is requested.
-
-Sun Mar 25 20:12:21 2001 Christopher Faylor <cgf@cygnus.com>
-
- * dlfcn.cc (check_access): Eliminate.
- (check_path_access): Use passed in path_conv buf.
- (get_full_path_of_dll): Use passed in name buf to avoid a static. Rip
- out most of the path checking since LoadLibrary will do all of this
- automatically.
- (dlopen): Set errno when appropriate (may not be compliant?).
- * environ.cc (posify): Don't pass in "native" path if it seems to
- actually be posix.
-
-Thursday Mar 22 2001 Robert Collins <rbtcollins@hotmail.com>
-
- * fhandler.h (fhandler_dev_clipboard): Extend to support writing.
- * fhandler_clipboard.cc (fhandler_dev_clipboard::fhandler_dev_clipboard):
- Initialize new fields. Open clipboard here.
- (fhandler_dev_clipboard::dup): New method.
- (fhandler_dev_clipboard::open): Accomodate new fields. Register
- clipboard here, if appropriate.
- (set_clipboard): New function. Moves buffer to clipboard.
- (fhandler_dev_clipboard::write): Truly implement clipboard writing.
- (fhandler_dev_clipboard::read): Reimplement to allow successive reads.
- (fhandler_dev_clipboard::lseek): Truly implement seeks in clipboard.
- (fhandler_dev_clipboard::close): Clear out new fields. Support
- sequential reads and sequential writes. Support for binary data via a
- native clipboard format.
-
-2001-03-22 Egor Duda <deo@logos-m.ru>
-
- * fhandler_console.cc (fhandler_console::set_default_attr): Update
- console color attributes on tty reset.
-
-Wed Mar 21 22:12:36 2001 Christopher Faylor <cgf@cygnus.com>
-
- * autoload.cc (kernel32_init): New function for kernel32 autoload
- initialization.
- (SignalObjectAndWait): Add conditional load of this function when it is
- available.
-
-2001-03-21 Robert Collins <rbtcollins@hotmail.com>
-
- * sched.cc: New file. Implement sched*.
- * include/sched.h: New file. User land includes for sched*.
- * Makefile.in: Add sched.o
- * cygwin.din: Add exports for sched*.
-
-Tue Mar 20 14:48:46 2001 Christopher Faylor <cgf@cygnus.com>
-
- * dtable.cc: Guard against new winsock.h/winsock2.h warnings when
- mixing winsock*.h and sys/types.h.
- * fhandler_socket.cc: Ditto.
- * net.cc: Ditto.
- * select.cc: Ditto.
- * exceptions.cc: Remove unneeded define.
-
-Mon Mar 19 17:43:29 2001 Christopher Faylor <cgf@cygnus.com>
-
- * exceptions.cc (interruptible): Update debugging output.
- (setup_handler): Ensure that wait_sig loop wakes up when we punt on
- sending a signal.
- * poll.cc (poll): Add signal guard here.
-
-2001-03-19 Egor Duda <deo@logos-m.ru>
-
- * tty.h (tty::create_inuse): Add new parameter to allow non-
- inheritable 'inuse' events.
- * tty.cc (tty::create_inuse): Use new parameter.
- * fhandler_tty.cc (fhandler_tty_master::init): Ditto.
- * fhandler_tty.cc (fhandler_pty_master::open): Ditto.
- * fhandler_tty.cc (fhandler_tty_master::init): Create master_alive
- event.
- * tty.cc (tty_list::terminate): Close master_alive event.
- * fhandler_tty.cc (fhandler_tty_common::close): Send EOF to slaves
- when master side is closed.
-
-Mon Mar 19 14:32:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * mmap.cc (map::get_list_by_fd): Avoid calling `get_namehash' when
- file descriptor is -1.
-
-Sat Mar 17 18:30:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * syscalls.cc (check_posix_perm): New static function.
- (fpathconf): Add _PC_POSIX_PERMISSIONS and _PC_POSIX_SECURITY
- support.
- (pathconf): Ditto.
- * include/cygwin/version.h: Bump API minor number to 37.
-
-2001-03-18 Egor Duda <deo@logos-m.ru>
-
- * fhandler.h (fhandler_tty_slave): Declare new methods.
- * select.cc (fhandler_tty_slave::select_read): New method.
- * select.cc (fhandler_tty_slave::ready_for_read): Ditto.
- * select.cc (verify_tty_slave): New function.
- * fhandler_termios.cc (fhandler_termios::line_edit): Empty input
- buffer on signal.
- * fhandler_tty.cc (fhandler_tty_slave::read): Check for input data
- after reading from pipe. Reset event if input pipe is empty.
- * tty.h (class tty): Allow creating events with manual reset.
- * tty.cc (tty::get_event): Use manual_reset flag.
- * tty.cc (tty::common_init): Create input_available_event with
- manual reset.
-
-Sat Mar 17 21:48:03 2001 Christopher Faylor <cgf@cygnus.com>
-
- * external.cc (fillout_pinfo): Match windows pid, as well as cygwin pid
- when passed in pid. Don't prematurely break when searching for a pid.
-
- * thread.h (_winsup_t): Eliminate unneeded field.
-
-Sat Mar 17 20:46:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * net.cc (get_95_ifconf): Use strcasematch instead of strcasecmp.
- * syscalls.cc (_unlink): Ditto.
- (_rename): Ditto.
-
-Sat Mar 17 12:43:15 2001 Christopher Faylor <cgf@cygnus.com>
-
- * path.cc (suffix_scan::next): Avoid searching for foo.lnk twice when
- input is "foo".
-
-Sat Mar 17 18:10:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * net.cc (cygwin_socket): Set protocol to 0 when address family is
- AF_UNIX to avoid WSAEPROTONOSUPPORT error.
-
-Sat Mar 17 09:51:32 2001 Mathew Brozowski <brozow@tavve.com>
-
- * net.cc (cygwin_socket): Pass protocol parameter to socket call.
-
-Sat Mar 17 02:05:38 2001 Christopher Faylor <cgf@cygnus.com>
-
- * dir.cc (readdir): Use strcasematch for consistency.
- * path.cc (symlink_info): Eliminate known_suffix.
- (path_conv::check): Always copy ext_here to end of buffer, if found.
- (suffix_scan): Eliminate ext_here, add suffixes_start.
- (suffix_scan::has): Eliminate an argument. Reorganize. Always return
- pointer to end of input path.
- (suffix_scan::next): Take a second pass through the suffix list looking
- for .lnk.
- (symlink_info::check): Eliminate known_suffix usage.
-
-Sat Mar 17 00:10:52 2001 Christopher Faylor <cgf@cygnus.com>
-
- * syscalls.cc (stat_dev): Give devices full read/write by default.
-
-Saturday Mar 17 3:45 2001 Robert Collins <rbtcollins@hotmail.com>
-
- * thread.cc (MTinterface::CreateCond): Check for null attr pointer.
-
-Fri Mar 16 21:13:23 2001 Christopher Faylor <cgf@cygnus.com>
-
- * fhandler_termios.cc (fhandler_termios::line_edit): Don't accept input
- when a signal is sent or we'll end up in an EOF/signal race.
-
-Fri Mar 16 20:25:40 2001 Christopher Faylor <cgf@cygnus.com>
-
- * path.cc: Translate scan states from defines to enums.
- (suffix_scan): Rename state to nextstate for clarity.
- (lnk_match): Change to allow multiple states to indicate that a .lnk
- has been matched.
- (suffix_scan::has): Eliminate a goto. Handle .lnk as a special case,
- since a .lnk may also need to be tacked on the end of a .lnk.
- (suffix_scan::next): Don't increment next state. Set it specifically.
- Recognize new .lnk states.
-
-Saturday Mar 17 01:19 2001 Robert Collins rbtcollins@hotmail.com
-
- * cygwin.din: Export the new functions.
- * pthread.cc (pthread_cond_*): Add wrapper functions that call
- __pthread_cond* functions.
- * thread.cc (__pthread_cond_*): Implement the pthread_cond* functions.
- * thread.h: Add new class entries and prototypes for __pthread_cond*
- functions.
- * include/pthread.h: user land header prototypes for pthread_cond*
- functions and related defines.
-
-Wed Mar 14 16:30:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * environ.cc (parse_options): Use strtok_r instead of strtok.
- * security.cc (convert_string_sid_to_sid): Ditto.
- (aclfromtext): Ditto. Fix buffer usage.
-
-Wed Mar 14 10:11:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * path.cc (lnk_suffixes): Remove.
- (class suffix_scan): Add `lnk_state' flag.
- (suffix_scan::lnk_match): Return state of `lnk_state' now.
- (suffix_scan::has): Changed behaviour if file has `.lnk' suffix.
- (suffix_scan::next): Set `lnk_state' where appropriate.
- (symlink_info::check): Fix a wrong `break'.
- * syscalls.cc (chown_worker): Change debug statement to reflect
- lchown fix.
- (lchown): Call chown_worker with `PC_SYM_NOFOLLOW' instead of
- `PC_SYM_IGNORE'.
-
-Tue Mar 13 13:52:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * fhandler.cc (fhandler_disk_file::fstat): Add correct modes to
- symlinks when stat'ing on FAT or FAT32 file systems.
-
-2001-03-12 Egor Duda <deo@logos-m.ru>
-
- * fhandler.h (fhandler_termios::fixup_after_exec): New function.
- * fhandler_termios.cc (fhandler_termios::fixup_after_fork): New
- function. Fixup output handle.
- * fhandler_tty.cc (fhandler_tty_common::fixup_after_fork): Output
- handle is now fixed up in fhandler_termios::fixup_after_fork().
-
-2001-03-12 Egor Duda <deo@logos-m.ru>
-
- * fhandler.h (fhandler_termios::fhandler_termios): Enable fixup
- after fork.
- * fhandler_console.cc (fhandler_console::fhandler_console): Fixup
- after fork is now enabled in the base class constructor.
-
-Mon Mar 12 11:19:41 2001 Christopher Faylor <cgf@cygnus.com>
-
- * mkvers.sh: Include config.h so that DEBUGGING is correctly defined.
-
-Mon Mar 12 09:47:55 2001 Christopher Faylor <cgf@cygnus.com>
-
- * spawn.cc (spawn_guts): Don't set EXIT_REPARENTING if parent process
- is not a cygwin process (suggested by Jason Gouger
- <cygwin@jason-gouger.com>).
-
-Sun Mar 11 16:00:58 2001 Christopher Faylor <cgf@cygnus.com>
-
- * child_info.h: Bump magic number for fork/exec/spawn.
-
-Sat Mar 10 20:54:47 2001 Christopher Faylor <cgf@cygnus.com>
-
- * autoload.cc (noload): Use proper method for multiline strings or
- newer gcc's complain.
- * exceptions.cc (unused_sig_wrapper): Ditto.
- * fhandler.h (fhandler_base): Make get_io_handle and friends return
- self.
- * fhandler_tty.cc (fhandler_pty_common::close_on_exec): Accomodate
- DEBUGGING flag to avoid spurious warnings when inheritance is set.
-
-Sat Mar 10 16:52:12 2001 Christopher Faylor <cgf@cygnus.com>
-
- * shortcut.c (PATH_ALL_EXEC): Add parentheses to avoid a compiler
- warning.
-
- * exceptions.cc (setup_handler): Clarify debugging message.
- * sigproc.cc (proc_subproc): Remove PROC_CHILDSTOPPED test. It is
- handled by normal PROC_CLEARWAIT case.
- (wait_sig): Eliminate "dispatched" tracking. Remove __SIGCHILDSTOPPED
- test. Decrement counter again before jumping out of
- InterlockedDecrement loop so that subsequent InterlockedIncrement will
- keep the counter at the correctly decremented value and also detect
- when there are pending signals.
- * sigproc.h: Remove __SIGCHILDSTOPPED element.
- (procstuff): Remove PROC_CHILDSTOPPED element.
-
-Sat Mar 10 15:22:44 2001 Christopher Faylor <cgf@cygnus.com>
-
- * syscalls.cc (_rename): Set errno to ENOENT when an old path doesn't
- exist (from Kazuhiro Fujieda <fujieda@jaist.ac.jp>). Also set EACCES
- when directory is not writable.
-
-Wed Mar 7 15:49:47 2001 Christopher Faylor <cgf@cygnus.com>
-
- * syscalls.cc (_read): Change definition to return ssize_t to be
- consistent with read.
- (_write): Change definition to return ssize_t to be consistent with
- write.
-
-Wed Mar 7 01:08:21 2001 Christopher Faylor <cgf@cygnus.com>
-
- * sigproc.h (sigthread): Declare new methods. Create new winapi_lock
- field.
- (sigframe:;set): Call get_winapi_lock after frame is set so that signal
- handler thread knows not to call SuspendThread.
- (sigframe::~sigframe): Release winapi_lock.
- * exceptions.cc (sigthread::get_winapi_lock): New method.
- (sigthread::release_winapi_lock): New method.
- (setup_handler): Use get_winapi_lock to ensure that signalled thread is
- not blocked in a Windows API.
-
- * path.h (path_types): Avoid broken GCC warning.
-
-Tue Mar 6 14:02:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * path.cc (suffix_scan::has): Change order of conditionals
- to allow checking for .lnk suffixes even if in_suffixes is empty.
-
-Tue Mar 6 13:02:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * autoload.c (cygwin_premain0): Add missing parameter.
- * binmode.c (cygwin_premain0): Ditto.
- * textmode.c (cygwin_premain0): Ditto.
-
-Tue Mar 6 12:04:00 2001 Jason Tiller <jtiller@sjm.com>
-
- * auto_load.cc: Add "GetKeyboardLayout" entry in the list of
- Win32 User32.DLL exports to provide.
- * fhandler.h (class fhandler_console): Add meta_mask private
- member to remember which keystroke modifiers should generate
- META.
- * fhandler_console.cc (fhandler_console::read): Modify code that
- tests a keystroke for a META-escaped key to use the 'meta_mask'
- variable.
- (fhandler_console::fhandler_console): Add definition for
- variable "meta_mask" used to determine if a keystroke should be
- preceded by META in the client console stream. Set meta_mask
- based on whether or not user's keyboard language is English -
- non-English keyboards pass AltGr (right <ALT>) unmolested,
- whereas English keyboards now interpret left- and right-<ALT>
- as META.
-
-Mon Mar 5 20:15:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * include/a.out.h: Add copyright hint.
- * include/fcntl.h: Ditto.
- * include/lastlog.h: Ditto.
- * include/memory.h: Ditto.
- * include/mntent.h: Ditto.
- * include/paths.h: Ditto.
- * include/poll.h: Ditto.
- * include/syslog.h: Ditto.
- * include/termio.h: Ditto.
- * include/tzfile.h: Ditto.
- * include/arpa/inet.h: Ditto.
- * include/asm/byteorder.h: Ditto.
- * include/asm/socket.h: Ditto.
- * include/asm/types.h: Ditto.
- * include/cygwin/if.h: Ditto.
- * include/cygwin/mtio.h: Ditto.
- * include/cygwin/rdevio.h: Ditto.
- * include/cygwin/socket.h: Ditto.
- * include/net/if.h: Ditto.
- * include/netinet/in.h: Ditto.
- * include/netinet/in_systm.h: Ditto.
- * include/netinet/ip.h: Ditto.
- * include/netinet/ip_icmp.h: Ditto.
- * include/netinet/tcp.h: Ditto.
- * include/sys/cdefs.h: Ditto.
- * include/sys/cygwin.h: Ditto.
- * include/sys/ioctl.h: Ditto.
- * include/sys/mman.h: Ditto.
- * include/sys/mount.h: Ditto.
- * include/sys/mtio.h: Ditto.
- * include/sys/procfs.h: Ditto.
- * include/sys/resource.h: Ditto.
- * include/sys/smallprint.h: Ditto.
- * include/sys/socket.h: Ditto.
- * include/sys/strace.h: Ditto.
- * include/sys/syslog.h: Ditto.
- * include/sys/sysmacros.h: Ditto.
- * include/sys/termio.h: Ditto.
- * include/sys/termios.h: Ditto.
- * include/sys/uio.h: Ditto.
- * include/sys/un.h: Ditto.
- * include/sys/utsname.h: Ditto.
- * include/sys/vfs.h: Ditto.
- * include/sys/wait.h: Ditto.
- * regexp/regerror.c: Ditto.
- * regexp/regexp.h: Ditto.
- * regexp/regmagic.h: Ditto.
-
-Mon Mar 5 01:25:03 2001 Christopher Faylor <cgf@cygnus.com>
-
- * dlopen.c (dlopen): Return NULL when name is NULL (suggested by
- chrisiasci@aol.com).
-
- * cygwin.din: Add a new, internally used export -
- _check_for_executable.
- * dcrt0.cc (dll_crt0_1): Set _check_for_executable for older binaries.
- Pass user_data to premain functions.
- * fhandler.cc (fhandler_disk_file::open): Only check for executable if
- the linked program is interested in the executable bit.
- (fhandler_disk_file::check_execable_p): Delete.
- * fhandler.h (executable_states): New enumeration of various states of
- executable bit caring.
- (fhandler_base::set_execable_p): New method.
-
- * fhandler_termios.cc (fhandler_termios::line_edit): Flag when a signal
- has been sent to the tty. Return -1 when this is so.
- * fhandler_console.cc (fhandler_console::read): Return -1 when signal
- sending character encountered.
-
- * path.cc (path_conv::check): Record when path refers to a disk device.
- Move executable extension check here.
- (check_sysfile): Accomodate new EXEC path states.
- (has_suffix): Remove.
- (next_suffix): Remove.
- (class suffix_scan): New clas.
- (suffix_scan::has): New method.
- (suffix_scan:next): New method.
- (symlink_info::check): Use suffix_scan method to control for scanning
- for suffixes.
- * path.h (path_conv::exec_state): New method.
- * perprocess.h: Make "C" friendly.
- * include/cygwin/version.h: Define CYGWIN_VERSION_CHECK_FOR_S_IEXEC.
- Bump CYGWIN_VERSION_API_MINOR.
- * include/sys/cygwin.h: Change premain declarations.
-
- * winsup.h: Move __cplusplus test to after builtin defines.
-
-2001-03-04 Egor Duda <deo@logos-m.ru>
-
- * fhandler.h (class fhandler_tty_common): New mutex and event to
- syncronize input on master tty with slave tty.
- * fhandler_tty.cc (fhandler_pty_master::accept_input): Use them to
- syncronize with slave.
- * fhandler_tty.cc (fhandler_tty_slave::read): Use input mutex and
- event to syncronize with master. Do not limit amount of data read
- from master to vmin value. Interrupt on signal and return already
- read data, if any.
- * fhandler_tty.cc (fhandler_tty_slave::open): Handle input mutex and
- event.
- * fhandler_tty.cc (fhandler_tty_common::close): Ditto.
- * fhandler_tty.cc (fhandler_tty_common::set_close_on_exec): Ditto.
- * fhandler_tty.cc (fhandler_tty_common::fixup_after_fork): Ditto.
- * fhandler_tty.cc (fhandler_tty_common::dup): Ditto.
- * tty.h (tty::open_input_mutex): New function.
- * tty.cc (tty::common_init): Create input mutex and event.
-
-Fri Mar 2 13:32:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * dir.cc (readdir): Fix creating path in symlink check.
-
-Fri Mar 2 12:33:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * dir.cc (readdir): Fix shortcut==symlink condition.
- * environ.cc: Add extern decl for `allow_winsymlinks'.
- (struct parse_thing): Add entry for `[no]winsymlinks'.
- * path.cc (symlink): Change to be able to create both,
- symlink==shortcut and symlink==systemfile, dependent of
- the setting of `allow_winsymlinks'.
- * security.cc (cygwin_logon_user): Add debug output.
- * shortcut.c: Add defines from path.h.
- (has_exec_chars): Copy from path.h.
- (check_shortcut): Check for executable file condition if not a
- shortcut.
-
-Thu Mar 1 21:06:07 2001 Christopher Faylor <cgf@cygnus.com>
-
- * exceptions.cc (sig_handle_tty_stop): Ignore attempts to suspend a
- process if started by non-cygwin parent.
-
-Thu Mar 1 20:48:11 2001 Christopher Faylor <cgf@cygnus.com>
-
- * select.cc (peek_console): Don't report read_ready on mouse events
- unless we are looking for mouse events.
- * fhandler.h (fhandler_console::mouse_aware): New method.
-
-Wed Feb 28 15:10:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * uinfo.cc: Eliminate `#include <wchar.h>'.
-
-2001-02-28 Egor Duda <deo@logos-m.ru>
-
- * fhandler_floppy.cc (fhandler_dev_floppy::lseek): Determine
- drive geometry or partition size to allow seeking from the end of
- raw floppy device. Don't allow positioning past the end of media or
- to offsets bigger then max off_t.
-
-2001-02-27 Egor Duda <deo@logos-m.ru>
-
- * fhandler.h (class fhandler_console): Make all variables that
- describe "state" of console to be members of fhandler_console.
- default_color is now the color which is set when console recieves
- reset command.
- * fhandler_console.cc (fhandler_console::fhandler_console): Turn
- mouse handling and raw keyboard mode off by default. Initialize
- state information.
- * fhandler.cc (fhandler_console::set_raw_win32_keyboard_mode): New
- function.
- * fhandler_console.cc (fhandler_console::set_default_attr): New
- function. Reset console attributes to default values.
- * fhandler_console.cc (fhandler_console::open): Reset attributes.
- * fhandler_console.cc (fhandler_console::get_win32_attr): New function.
- Calculate win32-style console attribute based on terminal attributes.
- * fhandler_console.cc (fhandler_console::set_cursor_maybe): Use
- member variable.
- * fhandler_console.cc (fhandler_console::read): If in raw-win32
- keyboard mode, encode win32 keyboard events in \033{x;y;z;t;u;wK
- sequences.
- * fhandler_console.cc (fhandler_console::dup): Copy all state
- information to the dup()ed handle.
- * fhandler_console.cc (fhandler_console::scroll_screen): Use current
- fill-in attribute.
- * fhandler_console.cc (fhandler_console::clear_screen): Ditto.
- * fhandler_console.cc (fhandler_console::char_command): Check if we
- saw '?' symbol by member variable. Set terminal attributes on \033[Xm
- commands. \033[24m - turn off underline mode, \033[27m - turn off
- reverse mode, \033[39m - restore default foreground color.
- \033[49m - restore default background color. \033[2000h - turn on raw
- keyboard mode, \033[2000l - turn off raw keyboard mode.
- * fhandler_console.cc (fhandler_console::write): Set attribues to
- default values on reset command.
-
-2001-02-26 Mike Simons <msimons@moria.simons-clan.com>
-
- * times.cc (settimeofday): Replace function stub with working code.
-
-Mon Feb 26 10:42:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * strace.cc (strace::vprntf): Move prntf functionality to this function
- adding an va_list interface to strace.
- (strace::printf): Calls strace::vprntf now.
- (strace_printf): New function providing an extern "C" interface to
- trace output.
- * include/sys/strace.h: Make plain C clean.
- (class strace): Add `vprntf' method.
-
-Mon Feb 26 0:10:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * shortcut.c: Remove #include <sys/strace.h>.
-
-Sun Feb 25 10:32:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * path.cc (symlink): Add a ".lnk" suffix regardless. Add a comment.
-
-Sun Feb 25 10:18:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * shortcut.c (check_shortcut): Change symlink condition.
-
-Fri Feb 23 10:42:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * mmap.cc (fhandler_disk_file::mmap): Use `addr' correctly.
- * fhandler_mem.cc (fhandler_dev_mem::mmap): Ditto.
-
-Thu Feb 22 17:09:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * path.cc (symlink): Keep relative paths relative in the DOS
- path inside of a shortcut. If that's impossible or the target
- path is already absolute save an absolute path.
-
-Thu Feb 22 15:33:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * cygerrno.h: Revert previous patch.
- * errno.cc: Ditto.
- * dir.cc: Eliminate `dir_suffixes'.
- (opendir): Remove usage of `dir_suffixes'.
- (rmdir): Ditto.
- * fhandler.cc (fhandler_disk_file::open): Remove usage of
- `inner_suffixes'.
- * path.cc: Rename `inner_suffixes' to `lnk_suffixes'.
- (path_conv::check): Remove usage of `inner_suffixes'.
- (symlink): Ditto.
- (symlink_info::check): Handle checking for `.lnk' in path_conv
- exclusively here.
- (chdir): Remove usage of `dir_suffixes'.
- * shortcut.c: Eliminate debug_printf lines.
- (check_shortcut): Don't set error except on failing ReadFile.
- * spawn.cc: Remove ".lnk" from `std_suffixes'.
- * syscalls.cc (_unlink): Remove usage of `inner_suffixes'.
- Remove ".lnk" from `stat_suffixes'.
- (_rename): Add check for renaming a symlink to keep the ".lnk"
- suffix after renaming.
-
-Thu Feb 22 13:38:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * shortcut.c: New file. Provides a C interface to reading of
- Windows shortcuts to avoid compiler flag `-fvtable-thunks'.
- * shortcut.h: Ditto.
- * Makefile.in: Add shortcut.o to DLL_OFILES.
- * cygerrno.h: Provide a C interface to `geterrno_from_win_error' for
- using in shortcut.c.
- * errno.cc (geterrno_from_win_error): Define as extern "C".
- * path.cc (struct symlink_info): Remove methods `check_shortcut' and
- `check_sysfile'.
- (shortcut_header): Move to shortcut.c.
- (shortcut_initalized): Ditto.
- (create_shortcut_header): Ditto.
- (cmp_shortcut_header): Ditto.
- (symlink_info::check_shortcut): Ditto. Reorganize as a plain C function.
- (symlink_info::check_sysfile): Redefine as a global function using the
- same parameter list as `check_shortcut' for clearness.
- (symlink_info::check): Change parameter list for calls to
- `check_shortcut' and `check_sysfile'.
-
-Thu Feb 22 12:04:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * fhandler.cc (fhandler_disk_file::open): Use `inner_suffixes' when
- resolving real_path.
- * path.cc (symlink): Ditto for win32_topath.
-
-Wed Feb 21 22:41:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * Makefile.in: Add `-lshell32 -luuid' to link pass for new-cygwin1.dll.
- * autoload.cc: Add LoadDLLinitfunc for ole32.dll.
- Add LoadDLLfuncEx statements for CoInitialize@4, CoUninitialize@0
- and CoCreateInstance@20.
- * dir.cc (dir_suffixes): New datastructure.
- (readdir): Check for R/O *.lnk files to hide the suffix.
- (opendir): Use `dir_suffixes' in path conversion.
- (rmdir): Ditto.
- * fhandler.cc (fhandler_disk_file::fstat): Add S_IFLNK flag
- before calling `get_file_attribute'. Take FILE_ATTRIBUTE_READONLY
- into account only if the file is no symlink.
- * path.cc (inner_suffixes): New datastructure.
- (SYMLINKATTR): Eliminated.
- (path_conv::check): Use `inner_suffixes' on inner path components.
- (shortcut_header): New global static variable.
- (shortcut_initalized): Ditto.
- (create_shortcut_header): New function.
- (cmp_shortcut_header): Ditto.
- (symlink): Create symlinks by creating windows shortcuts. Preserve
- the old code.
- (symlink_info::check_shortcut): New method.
- (symlink_info::check_sysfile): Ditto.
- (symlink_info::check): Check for shortcuts. Move code reading
- old system attribute symlinks into symlink_info::check_sysfile().
- (chdir): Use `dir_suffixes' in path conversion.
- * security.cc (get_file_attribute): Check for S_IFLNK flag.
- Force 0777 permissions then.
- * spawn.cc (std_suffixes): Add ".lnk" suffix.
- * syscalls.cc (_unlink): Use `inner_suffixes' in path conversion.
- Check for shortcut symlinks to eliminate R/O attribute before
- calling DeleteFile().
- (stat_suffixes): Add ".lnk" suffix.
- (stat_worker): Force 0777 permissions if file is a symlink.
-
-2001-02-21 Egor Duda <deo@logos-m.ru>
-
- * sigproc.cc (getsem): Make semaphore always non-inheritable.
-
-Mon Feb 19 22:25:53 2001 Christopher Faylor <cgf@cygnus.com>
-
- * dcrt0.cc (locale_init): Remove.
-
-2001-02-15 Kazuhiro Fujieda <fujieda@jaist.ac.jp>
-
- * cygwin.din: Export rand48 functions.
- * thread.cc (MTinterface::Init): Remove the initialization of
- `reent_data'.
- * dcrt0.cc: Add the initalizer to the declaration of `reent_data'.
- * include/cygwin/version.h: Bump CYGWIN_VERSION_API_MINOR to 35.
-
-2001-02-16 Egor Duda <deo@logos-m.ru>
-
- * signal.cc (signal): Prohibit setting handlers for SIGKILL and
- SIGSTOP
- * signal.cc (sigaction): Ditto
- * syscalls.cc (_lseek): Return EINVAL on invalid input
-
-Wed Feb 14 14:54:40 2001 Christophe Iasci <chrisiasci@aol.com>
-
- * dlfcn.cc (dlopen): Do not call LoadLibrary with a NULL pointer, when
- the library is not found
-
-2001-02-14 Egor Duda <deo@logos-m.ru>
-
- * fhandler_console.cc (fhandler_console::char_command): Ignore unknown
- rendition codes in \033[xx;yym control sequences
-
-Fri Feb 9 23:19:01 2001 Christopher Faylor <cgf@cygnus.com>
-
- * fork.cc (fork_parent): Return EAGAIN when can't record pid.
- * pinfo.h (pinfo::remember): Return value of call to proc_subproc.
- * sigproc.cc (proc_subproc): Return error if can't record pid.
-
-Fri Feb 9 12:17:27 2001 Christopher Faylor <cgf@cygnus.com>
-
- * syscalls.cc (mknod): Add valid parameters.
-
-Thu Feb 8 22:09:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * mmap.cc (mmap): Check for reusing a mapping only on MAP_SHARED
- and on MAP_PRIVATE|MAP_ANON in the special case of offset 0.
-
-Thu Feb 8 21:57:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * mmap.cc (class list): Add member `hash'.
- (list::list): Initialize `hash'.
- (list::get_list_by_fd): Use filepath hash value to get the correct
- mapping list if it's not an anonymous mapping.
- (map::add_list): Initialize `hash' with filepath hash value.
- (mmap): Check for reusing a mapping only on MAP_SHARED.
-
-Wed Feb 7 18:47:36 2001 Christopher Faylor <cgf@cygnus.com>
-
- * signal.cc (killpg): Correct first argument.
-
-Wed Feb 7 22:22:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * autoload.cc: Add LoadDLLinitfunc for iphlpapi.dll.
- Add LoadDLLfuncEx statements for GetIfTable@12 and GetIpAddrTable@12.
- * fhandler_socket.cc (fhandler_socket::ioctl): Move variable
- definitions to the beginning of the function to allow better debugging.
- Add handling for SIOCGIFHWADDR, SIOCGIFMETRIC and SIOCGIFMTU.
- * net.cc: Include iphlpapi.h.
- (get_2k_ifconf): Rewritten. Uses IP Helper API now.
- (get_nt_ifconf): Add handling for SIOCGIFHWADDR, SIOCGIFMETRIC
- and SIOCGIFMTU.
- (get_95_ifconf): Ditto. Renamed from `get_9x_ifconf'.
- (get_ifconf): Name loopback `lo' instead of `lo0' as in Linux.
- Add handling for SIOCGIFHWADDR, SIOCGIFMETRIC and SIOCGIFMTU.
- Call `get_95_ifconf' only on Windows 95, `get_nt_ifconf' only
- on Windows NT < Service Pack 3, `get_2k_ifconf otherwise.
- * include/asm/socket.h: Add defines for SIOCGIFHWADDR, SIOCGIFMETRIC
- and SIOCGIFMTU.
- * include/cygwin/if.h: Add `ifr_hwaddr', `ifr_metric' and `ifr_mtu'.
- (struct ifreq): Add `ifru_hwaddr'.
-
-Tue Feb 6 15:04:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * syscalls.cc (stat_worker): Add a check for the special case when
- a process creates a file using mode 000 using ntsec.
-
-Mon Feb 5 17:00:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * fhandler.cc (fhandler_base::open): Always add GENERIC_READ access
- when opening raw disk devices.
- * fhandler_floppy.cc (fhandler_dev_floppy::lseek): Implement bytewise
- access.
- * fhandler_raw.cc (fhandler_dev_raw::open): Always open raw disk device
- binary.
- (fhandler_dev_raw::raw_write): Don't drop read buffer content when
- writing after read.
-
-Mon Feb 5 13:30:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * mmap.cc (mmap_record::fixup_map): New method to duplicate
- the memory protection in a just forked child.
- (mmap): Realign gran_len to page boundary only on anonymous
- mapping before saving in the mmap_record.
- (munmap): Cleanup code.
- (msync): Ditto.
- (fixup_mmaps_after_fork): Ditto. Call mmap_record::fixup_map now.
-
-Thu Feb 1 23:08:29 2001 Christopher Faylor <cgf@cygnus.com>
-
- * cygheap.cc (creturn): Correctly calculate cygheap_max.
-
-Wed Jan 31 10:04:58 2001 Christopher Faylor <cgf@cygnus.com>
-
- * shared.cc (shared_info::initialize): Reduce size of heap.
-
-Wed Jan 31 13:22:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * include/sys/resource.h: Fix typo.
-
-Wed Jan 31 13:20:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * include/sys/resource.h: Add RLIMIT_NLIMITS and RLIM_NLIMITS.
-
-Tue Jan 30 18:15:23 2001 Christopher Faylor <cgf@cygnus.com>
-
- * include/cygwin/version.h: Bump version to 1.3.0.
-
-Tue Jan 30 8:55:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * pinfo.cc (pinfo::init): Use INVALID_HANDLE_VALUE instead of
- explicit cast (HANDLE) 0xffffffff.
- * shared.cc (open_shared): Ditto.
-
-Mon Jan 29 17:15:22 2001 Bill Hegardt <bill@troyxcd.com>
-
- * fhandler_serial.cc (raw_write): Use local copy of OVERLAPPED
- structure instead of shared structure to fix a race condition between
- read/write.
-
-Mon Jan 29 14:30:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * mmap.cc (mmap): Remove obsolete check for MAP_SHARED|MAP_ANON as
- being invalid.
-
-Mon Jan 29 10:23:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * mmap.cc (mmap_record::find_empty): Fix loop condition.
-
-Sun Jan 28 19:40:40 2001 Christopher Faylor <cgf@cygnus.com>
-
- * syscalls.cc (_link): Make sure that newpath does not exist. Set
- errno if it does.
-
-Sun Jan 28 19:29:08 2001 Christopher Faylor <cgf@cygnus.com>
-
- * cygheap.cc (init_cheap): Don't specify a load address for the heap.
- It doesn't work on #!*& Windows 9x.
- (cygheap_init): Move GetUserName to memory_init.
- * dcrt0.cc (dll_crt0_1): Call new memory_init functin, eliminate call
- to heap_init.
- * heap.cc (heap_init): Improve error output.
- * heap.h: Correct some declarations.
- * shared.cc (mount_table_init): Remove.
- (memory_init): Renamed from shared_init. Reorganize to accomodate
- strange Windows 9x problems with cygheap/heap interaction.
- * shared_info.h: Rename shared_init to memory_init.
-
-Sun Jan 28 01:25:33 2001 Christopher Faylor <cgf@cygnus.com>
-
- * include/cygwin/version.h: Bump API version.
-
-Sun Jan 28 01:18:22 2001 Christopher Faylor <cgf@cygnus.com>
-
- * cygheap.cc (init_cheap): Move username initialization.
- (cygheap_init): Here.
- * shared_info.h (mount_info): Add a sys_mount_table_counter field.
- (shared_info): Ditto.
- * path.cc (mount_info::conv_to_win32_path): Check that our mount table
- is in sync with the system mount table and reinitialize it if not.
- (mount_info::add_reg_mount): Bump sys_mount_table counters if the
- system mount table changes.
- (mount_info::del_reg_mount): Ditto.
- (mount_info::write_cygdrive_info_to_registry): Ditto.
- (mount_info::remove_cygdrive_info_from_registry): Ditto.
-
-Sun Jan 28 00:28:30 2001 Christopher Faylor <cgf@cygnus.com>
-
- Throughout, change 'cygwin_shared.mount' to 'mount_table'.
- * child_info.h (child_info): Move shared_h, console_h to cygheap. Add
- mount_h.
- * cygheap.h (init_cygheap): Add shared_h, console_h.
- * cygheap.cc (init_cheap): Initialize heap at a fixed location after
- the shared memory regions. Initialize cygheap->user name here.
- * dcrt0.cc (dll_crt0_1): Call getpagesize () to initialize constants.
- Remove cygheap_init since it is done in shared_init now.
- (_dll_crt0): Initialize mount_h, remove shared_h and console_h
- initialization.
- * fhandler_console.cc (console_shared_h): Eliminate.
- (get_tty_stuff): Use cygheap->console_h rather than console_shared_h.
- * heap.cc (heap_init): Use page size constant calculated earlier in
- initialization.
- * shared.cc: Eliminate cygwin_shared_h. Add cygwin_mount_h.
- (mount_table_init): New function for initializing a user mount table.
- (open_shared_file_map): Use constant for shared memory region.
- Initialize cygheap and mount table here.
- (open_shared): Improve debugging output.
- (shared_info::initialize): Eliminate call to mount.init.
- (shared_terminate): Use cygheap->shared_h. Close cygwin_mount_h.
- (open_shared_file_map): Eliminate.
- * shared_info.h (mount_info): Add a version field.
- (shared_align_past): New macro for calculating location for shared
- memory regions.
- * sigproc.cc (init_child_info): Eliminate shared_h, console_h.
- * spawn.cc (spawn_guts): Pass on cygwin_mount_h iff not a different
- user.
- * syscalls.cc (system_info): New global holding system memory defaults.
- (getpagesize): Use system_info.
- * uinfo.cc (internal_getlogin): Only fill in user name if nonexistent.
- * winsup.h: Declare system_info.
-
- * passwd.cc (read_etc_passwd): Use cygheap->user.name () rather than
- retrieving the name again.
-
-Sat Jan 27 10:18:02 2001 Christopher Faylor <cgf@cygnus.com>
-
- * path.cc (path_conv::check): Detect when path has symlinks.
- (symlink_info::check): Remove debugging stuff.
- (chdir): Use posix'ized win32 path if cd'ed to a path using symlinks.
-
-Fri Jan 26 21:20:28 2001 Christopher Faylor <cgf@cygnus.com>
-
- * exceptions.cc (sigreturn): Call any pending signals prior to
- resetting the signal mask so that stacked signals behave correctly.
- (sigdelayed): Avoid a race where a signal could end up calling an
- incorrect signal handler if two signals come in close together.
-
-Tue Jan 23 21:56:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * mmap.cc (fhandler_disk_file::mmap): Call CreateFileMapping with
- len != 0 only when performing an anonymous mapping.
-
-Mon Jan 22 15:35:28 2001 Christopher Faylor <cgf@cygnus.com>
-
- * path.h: Add a new constant.
- * syscalls.cc (_read): Oscillate errno check.
-
-Mon Jan 22 15:27:12 2001 Christopher Faylor <cgf@cygnus.com>
-
- * include/cygwin/version.h: Bump API to reflect setlogmask.
-
-Sun Jan 21 22:40:25 2001 Jason Tishler <jt@dothill.com>
-
- * cygwin.din: Add export for setlogmask().
- * syslog.cc (setlogmask): New function.
-
-Thu Jan 18 10:27:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * resource.cc (setrlimit): Support RLIMIT_NOFILE.
-
-Wed Jan 17 23:23:12 2001 Christopher Faylor <cgf@cygnus.com>
-
- * syscalls.cc (setdtablesize): Call with amount to increment not total
- amount. Return success or failure error code.
-
-Wed Jan 17 09:47:13 2001 Christopher Faylor <cgf@cygnus.com>
-
- * autoload.cc (LoadDLLinitfunc): Remove debugging statement.
-
- * exceptions.cc (sig_handle_tty_stop): Move setting of PID_STOPPED to
- earlier in interrupt.
- (interrupt_setup): i.e., here.
- (sig_handle): Don't queue multiple SIGSTOPS.
- * fhandler.h (bg_check_types): Enumerate return value of bg_check for
- clarity.
- * signal.cc (kill_pgrp): Minor cleanup.
- * fhandler_termios.cc (fhandler_termios::bg_check): Use enumerated type
- for function return. Don't raise signal if a signal is already queued.
- * fhandler_console.cc (fhandler_console::read): Use enumerated return
- type for bg_check.
- * select.cc: Ditto, throughout.
- * read.cc: Ditto, throughout.
- * termios.cc: Ditto, throughout.
- (_read): YA interrupt detect simplification.
- * wait.cc (wait4): Ditto.
-
-Wed Jan 17 10:56:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * cygheap.cc (cygheap_user::~cygheap_user): Temporarily
- disable free'ing memory.
-
-Tue Jan 16 18:01:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * mmap.cc (mmap): Initialize fh to avoid compiler warnings.
-
-Mon Jan 15 21:07:00 2001 Christopher Faylor <cgf@cygnus.com>
-
- * wait.cc (wait4): Rename variable for consistency. Allow restartable
- signal behavior.
-
-Mon Jan 15 23:15:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * mmap.cc (mmap): Add more parameter checking. Change error output
- in case of EINVAL. Treat mmapping /dev/zero like MAP_ANONYMOUS.
-
-Mon Jan 15 20:34:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * mmap.cc: include <unistd.h>. Define some bit operations for
- the new page map.
- (mmap_record): Change type of base_address_ to caddr_t.
- Add map_map_ member. Add several methods to manipulate map_map_.
- (mmap_record::alloc_map): New method.
- (mmap_record::free_map): Ditto.
- (mmap_record::find_empty): Ditto.
- (mmap_record::map_map): Ditto.
- (mmap_record::unmap_map): Ditto.
- (list::add_record): Change return type to `mmap_record *'.
- Allocate page map.
- (list::match): New method.
- (mmap): Partly rewritten to take care for the new page map. Add some
- parameter checking.
- (munmap): Ditto.
-
-Mon Jan 15 13:50:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * heap.cc (heap_init): Fix extern declaration of getpagesize.
- * syscalls.cc (getpagesize): Fix another typo.
-
-Mon Jan 15 12:48:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * syscalls.cc (getpagesize): Save pagesize in global variable to
- avoid calling GetSystemInfo too often.
- * heap.cc (getpagesize): Eliminate.
- (heap_init): Use getpagesize function from syscalls.cc.
-
-Mon Jan 15 11:56:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * sysconf.cc (sysconf): return `getpagesize ()' on _SC_PAGESIZE
- request to avoid implementing the same twice.
-
-Sun Jan 14 14:07:50 2001 Christopher Faylor <cgf@cygnus.com>
-
- * syscalls.cc (_read): Use more lightweight method for determining if
- read has been interrupted by a signal.
-
-Fri Jan 12 00:35:15 2001 Christopher Faylor <cgf@cygnus.com>
-
- * debug.h: Add regparm attributes to some functions.
-
- * signal.cc (sigaction): Don't treat SIGCONT specially.
-
- * exceptions.cc (interrupt_setup): Save sa_flags of interrupted signal
- for later use.
- (sig_handler): Default any stopping signal to SIGSTOP.
- (call_signal_handler): New function.
- (sigdelayed0): New function.
- * sigproc.cc (sigproc_init): Initialize SIGSTOP sigaction for special
- behavior.
- * sigproc.h: Define call_signal_handler.
- * syscalls.cc (_read): Allow restartable signal behavior.
-
-Thu Jan 11 13:17:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * fhandler.h (fhandler_base): New method `fixup_mmap_after_fork'.
- (fhandler_disk_file: Ditto.
- (fhandler_dev_mem): Ditto.
- * fhandler_mem.cc (fhandler_dev_mem::open): Set OBJ_INHERIT attribute
- for device\physicalmemory handle.
- (fhandler_dev_mem::mmap): Ditto.
- * fhandler_mem.cc (fhandler_dev_mem::fixup_mmap_after_fork): New
- method.
- * mmap.cc (mmap_record): Add private `fdesc_' member. Change
- constructor accordingly.
- (get_fd): New method.
- (mmap): Use new mmap_record constructor.
- (fhandler_base::fixup_mmap_after_fork): New method.
- (fhandler_disk_file::fixup_mmap_after_fork): Ditto.
- (fixup_mmaps_after_fork): Call `fixup_mmap_after_fork' of appropriate
- fhandler class.
-
-Wed Jan 10 22:08:30 2001 Kazuhiro Fujieda <fujieda@jaist.ac.jp>
-
- * sigproc.cc (wait_sig): Allow SIGCONT when stopped.
-
-Tue Jan 9 16:55:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- Patch suggested by René Møller Fonseca <fonseca@mip.sdu.dk>
- * include/sys/socket.h: Change prototype to have 2nd parameter `const'.
- * net.cc (cygwin_bind): Change 2nd parameter to `const'.
-
-Sun Jan 7 22:59:37 2001 Christopher Faylor <cgf@cygnus.com>
-
- * pinfo.cc (codepage_init): Move function.
- * environ.cc (codepage_init): To here.
- * exceptoins.cc (SIG_NONMASKABLE): Remove SIGCONT from consideration
- since it is supposed to be maskable.
- * signal.cc (sigaction): Ditto.
- * sigproc.cc (wait_sig): Ditto.
- * winsup.h: Eliminate global declaration of codepage_init.
-
-Thu Jan 5 9:33:00 2001 Corinna Vinschen <corinna@vinschen.de>
-
- * resource.cc (getrlimit): Set errno on EFAULT instead of returning
- it.
- (setrlimit): Ditto.
-
-Thu Jan 5 3:38:00 2001 David Sainty <David.Sainty@optimation.co.nz>
-
- * resource.cc (setrlimit): Prevent failing with an error when the
- operation would not have changed anything.
-
-Thu Jan 4 10:29:54 2001 Earnie Boyd <earnie_boyd@yahoo.com>
-
- * thread.cc: Need LONG_MAX definition.
-
-Wed Jan 3 13:47:23 2001 Christopher Faylor <cgf@cygnus.com>
-
- * thread.cc (MTinterface::CreateSemaphore): Correctly set semaphore
- max.
-
-Wed Jan 3 09:44:51 2001 Christopher Faylor <cgf@cygnus.com>
-
- * fhandler_console.cc (fhandler_console::read): Restore missing test
- for code page before doing OemToCharBuff.
-
-Wed Jan 3 09:20:20 2001 Jason Tishler <jt@dothill.com>
-
- * include/cygwin/version.h: Fix typo in CYGWIN_VERSION_DLL_COMBINED
- macro.
+2002-01-01 Christopher Faylor <cgf@redhat.com>
+
+ * speclib: Remove temp files automatically.
+
+2002-01-01 Corinna Vinschen <corinna@vinschen.de>
+ * fhandler.h (fhandler_socket::sun_path): New private member.
+ (fhandler_socket::set_sun_path): New method.
+ (fhandler_socket::get_sun_path): Ditto.
+ * fhandler_socket.cc (fhandler_socket::fhandler_socket): Initialize
+ sun_path to NULL.
+ (fhandler_socket::~fhandler_socket): Free sun_path if needed.
+ (fhandler_socket::set_sun_path): New method.
+ * net.cc (cygwin_bind): Set sun_path to path of local socket file.
+ (cygwin_getsockname): Add code to return correct sockaddr for unix
+ domain sockets.
diff --git a/winsup/cygwin/ChangeLog-1998 b/winsup/cygwin/ChangeLog-1998
index e22a158ed..aa657e01e 100644
--- a/winsup/cygwin/ChangeLog-1998
+++ b/winsup/cygwin/ChangeLog-1998
@@ -24,7 +24,7 @@ Wed Dec 30 21:41:25 1998 Christopher Faylor <cgf@cygnus.com>
assignment here but only do it when it is necessary or
programs will die abnormally.
* fhandler.h: Add raw_write method to fhandler_serial.
- * fhandler_serial.cc (raw_write): New method. Accomodates
+ * fhandler_serial.cc (raw_write): New method. Accommodates
overlapped I/O that now must be used with serial.
* utils/kill.cc (main): Allow `0' signal. Just checks
for existence of process.
@@ -430,7 +430,7 @@ Tue Dec 1 14:43:35 1998 Christopher Faylor <cgf@cygnus.com>
Tue Dec 1 08:34:18 1998 Christopher Faylor <cgf@cygnus.com>
- * mkvers.sh: Accomodate lack of timezone in date output so that
+ * mkvers.sh: Accommodate lack of timezone in date output so that
year shows up correctly.
Mon Nov 30 14:30:51 1998 Jeff Johnston <jjohnstn@cygnus.com>
@@ -2113,7 +2113,7 @@ Thu Sep 10 21:09:51 1998 Christopher Faylor <cgf@cygnus.com>
overhead.
(symlink_check_one): Check extensions for existence for use
with spawn.
- (readlink): Accomodate changes to symlink_check_one.
+ (readlink): Accommodate changes to symlink_check_one.
* spawn.cc (perhaps_suffix): Use new extension checking
capabilities of path_conv.
(find_exec_1): Delete.
@@ -2369,7 +2369,7 @@ Thu Sep 10 21:09:51 1998 Christopher Faylor <cgf@cygnus.com>
(setenv): Convert special environment variables to native here,
when they are set.
(struct parse_thing): Simplify struct.
- (struct parse_things): Extend table to accomodate "envcache"
+ (struct parse_things): Extend table to accommodate "envcache"
setting.
(parse_options): Add "envcache" option to control whether special
environment variables are cached. Simplify handling of remembered
@@ -2722,7 +2722,7 @@ Thu Aug 27 14:20:38 1998 Christopher Faylor <cgf@cygnus.com>
Wed Aug 26 14:15:22 1998 Christopher Faylor <cgf@cygnus.com>
* fhandler.h (fhandler_base): Make set_name() public and implement
- clear_name() to accomodate dup2.
+ clear_name() to accommodate dup2.
* hinfo.cc (dup2): Previous change exposed problem with dup2.
Same unix_path_name_ ptr was being used in two separate fds.
Fix this.
@@ -3722,7 +3722,7 @@ Tue Mar 10 15:41:29 1998 Geoffrey Noer <noer@cygnus.com>
Reorganize lpReserved2 buffer to avoid conflicts with Microsoft
usage which resulted in incorrect stdin/stdout operation with
programs compiled using MSVC.
- * pinfo.cc (pinfo_init): Accomodate change to lpReserved2
+ * pinfo.cc (pinfo_init): Accommodate change to lpReserved2
organization.
Mon Mar 9 19:27:17 1998 Geoffrey Noer <noer@cygnus.com>
diff --git a/winsup/cygwin/ChangeLog-1999 b/winsup/cygwin/ChangeLog-1999
index 49d6fe468..f2da41f51 100644
--- a/winsup/cygwin/ChangeLog-1999
+++ b/winsup/cygwin/ChangeLog-1999
@@ -73,7 +73,7 @@ Fri Dec 10 20:22:41 1999 Christopher Faylor <cgf@cygnus.com>
signal handler.
(handle_sigsuspend): Use set_sig_errno to ensure that the correct errno
is set after a signal handler.
- (interrupt_now): Accomodate default errno field in stack.
+ (interrupt_now): Accommodate default errno field in stack.
(intterupt_on_return): Ditto.
(sigreturn): Pop, test, and possibly restore saved errno on return from
signal handler.
@@ -117,9 +117,9 @@ Wed Dec 8 23:06:07 1999 Christopher Faylor <cgf@cygnus.com>
* Makefile.in: Ensure that winver.o is a dependency for building the
dll.
- * mkvers.sh: Attempt to call windres in a fashion that accomodates
+ * mkvers.sh: Attempt to call windres in a fashion that accommodates
older and newer versions.
- * winver.c: Reorganize slightly to accomodate older versions of
+ * winver.c: Reorganize slightly to accommodate older versions of
windres.
* fhandler.cc (fhandler_disk_file::fstat): Avoid using Windows "inodes"
on disks which do not support them.
@@ -207,7 +207,7 @@ Fri Dec 3 22:52:05 1999 Christopher Faylor <cgf@cygnus.com>
(events_init): Allocate mask_sync muto.
(unused_sig_wrapper): New function. Encapsulates assembly language
signal handling support.
- * fhandler.h (class select_stuff): Accomodate new signal-handling
+ * fhandler.h (class select_stuff): Accommodate new signal-handling
scheme.
* fhandler_console.cc (fhandler_console): Simplify to use new
signal-handling scheme.
@@ -321,7 +321,7 @@ Tue Nov 16 23:29:17 1999 Christopher Faylor <cgf@cygnus.com>
Sat Oct 30 00:59:38 1999 Christopher Faylor <cgf@cygnus.com>
* Makefile.in: Some general cleanup.
- * smallprint.c (__small_vsprintf): Accomodate new format for
+ * smallprint.c (__small_vsprintf): Accommodate new format for
__PRETTY_FUNCTION__.
Wed Oct 27 16:13:36 1999 Christopher Faylor <cgf@cygnus.com>
@@ -384,7 +384,7 @@ Tue Oct 19 22:10:21 1999 Christopher Faylor <cgf@cygnus.com>
Tue Oct 19 21:09:42 1999 Christopher Faylor <cgf@cygnus.com>
- Make minor changes throughout to accomodate new gcc merge.
+ Make minor changes throughout to accommodate new gcc merge.
* Makefile.in: Remvoe -fpermissive option when compiling using g++.
* dcrt0.cc (noload): Mark as "unused" to avoid a compiler warning.
* exceptions.cc (sigreturn): Make this "extern" since it essentially
@@ -393,7 +393,7 @@ Tue Oct 19 21:09:42 1999 Christopher Faylor <cgf@cygnus.com>
considered void.
* heap.cc (sbrk): Remove debugging code.
* passwd.cc (getpass): Don't use fprintf to print the prompt.
- * path.cc (mount_info::conv_to_win32_path): Accomodate compiler
+ * path.cc (mount_info::conv_to_win32_path): Accommodate compiler
warning.
* select.cc (cygwin_select): Experimental version of select which
handles fd_sets with non-standard FD_SETSIZE.
@@ -851,7 +851,7 @@ Mon Sep 6 13:36:34 1999 Christopher Faylor <cgf@cygnus.com>
* fhandler_tty.cc (fhandler_tty_master::init_console): Remove retrieval
of stderr handle since it is not required for correct init operation.
- * hinfo.cc (hinfo_init): Reorganize to accomodate potential closing of
+ * hinfo.cc (hinfo_init): Reorganize to accommodate potential closing of
console handles by fhandler_console::init.
(init_std_file_from_handle): Set standard handle as appropriate.
(hinfo::de_linearize_fd_arry): Ditto.
@@ -1407,9 +1407,9 @@ Tue Jul 27 23:31:28 1999 Christopher Faylor <cgf@cygnus.com>
or suffer weird behavior. Suggested by Andrew Dalgleish
<andrewd@axonet.com.au>.
* shared.cc: Make SHAREDVER "unsigned" to avoid a compiler warning.
- * spawn.cc : Accomodate additional argument to _spawnve, throughout.
+ * spawn.cc : Accommodate additional argument to _spawnve, throughout.
(_spawnve): Make this a global function and take an hToken argument so
- that it can be used by sexecve. Accomodate experimental vfork
+ that it can be used by sexecve. Accommodate experimental vfork
functionality.
* winsup.h: Add initial support for per-thread vfork stuff.
* include/cygwin/version.h: Bump shared memory version number.
@@ -1440,7 +1440,7 @@ Sat Jul 17 00:45:34 1999 Christopher Faylor <cgf@cygnus.com>
Fri Jul 16 23:47:31 1999 Christopher Faylor <cgf@cygnus.com>
- * sigproc.cc (proc_can_be_signalled): Accomodate different flavors of
+ * sigproc.cc (proc_can_be_signalled): Accommodate different flavors of
myself.
* include/ddeml.h: Add missing struct.
* include/wingdi.h: Add missing defines.
@@ -1534,7 +1534,7 @@ Wed Jul 14 22:08:52 1999 Christopher Faylor <cgf@cygnus.com>
(sig_wait): Set active state after all handles have been set up and
before protecting the handles. Use ForceCloseHandle to close
subproc_ready as it is now protected. Close signal_mutex here.
- * sigproc.h: Accomodate alive_parent rename.
+ * sigproc.h: Accommodate alive_parent rename.
* spawn.cc Use init_child_info to initilize memory block passed to
subprocess.
* strace.cc (__system_printf): Write to screen before writing to strace
@@ -1614,7 +1614,7 @@ Wed Jul 7 23:59:50 1999 Christopher Faylor <cgf@cygnus.com>
* fhandler.h: Add an extra 'fd' argument to all ready_for_read methods.
* select.cc: Ditto, throughout.
* fhandler_console (get_tty_stuff): Protect the tty_stuff handle here.
- * fhandler_termios.cc (fhandler_termios::line_edit): Accomodate fd
+ * fhandler_termios.cc (fhandler_termios::line_edit): Accommodate fd
argument to ready_for_read.
* fhandler_tty.cc (fhandler_tty_master::init): Close an unneeded thread
handle.
@@ -1724,7 +1724,7 @@ Thu Jul 1 22:36:31 1999 Christopher Faylor <cgf@cygnus.com>
* net.cc: Redo winsock functions to use dynamic loading scheme.
* shared.cc (shared_info::initialize): Cosmetic change.
* shared.h: Change magic number for memory block sent to child
- processes. Accomodate new heap information in child_info.
+ processes. Accommodate new heap information in child_info.
* sigproc.cc (sig_dispatch_pending): Remove some memory debugging checks.
(__release_signal_mutex): Ditto.
* syscalls.cc (stat_worker): Don't attempt the .exe hack unless the
@@ -1732,7 +1732,7 @@ Thu Jul 1 22:36:31 1999 Christopher Faylor <cgf@cygnus.com>
and the file did not already contain an extension.
* times.cc: Initialize static NO_COPY variables throughout or they will
not actually be NO_COPY.
- * winsup.h: Rename heap fields in per_process to accomodate new sbrk.
+ * winsup.h: Rename heap fields in per_process to accommodate new sbrk.
Eliminate winsock stuff invalidated by dynamic loading change.
* include/winsock.h: Make this file C++ safe.
@@ -1876,7 +1876,7 @@ Mon Jun 14 12:43:32 1999 Christopher Faylor <cgf@cygnus.com>
(strace_dump): Delete.
(mark): Gut.
* winsup.h: Remove a declaration. Add a new one.
- * include/sys/strace.h: Modify to accomodate new strace scheme.
+ * include/sys/strace.h: Modify to accommodate new strace scheme.
* utils/Makefile.in: Build strace.exe
* utils/strace.cc: New file.
@@ -2036,7 +2036,7 @@ Mon May 31 22:10:57 1999 Christopher Faylor <cgf@cygnus.com>
* fhandler.cc: Use methods to access path_conv flags
throughout.
* path.cc: (symlink-check_one): Accept a bitmask flags
- variable to accomodate path_conv changes.
+ variable to accommodate path_conv changes.
(path_conv::path_conv): Propagate path_flags from mount
table to path_conv class. Avoid walking the mount table
twice to find "binary" info.
@@ -2593,7 +2593,7 @@ Wed Mar 24 20:04:21 1999 Christopher Faylor <cgf@cygnus.com>
there is no change or Windows 95 will eat input.
(fhandler_console::tcsetattr): Use ONLRET to control binary behavior
since it is more closely analgous.
- (fhandler_console::fhandler_console): Accomodate fhandler_termios
+ (fhandler_console::fhandler_console): Accommodate fhandler_termios
base class.
(fhandler_console::init): Ditto.
(fhandler_console::igncr_enabled): Ditto.
@@ -2601,20 +2601,20 @@ Wed Mar 24 20:04:21 1999 Christopher Faylor <cgf@cygnus.com>
(fhandler_console::de_linearize): New function.
* fhandler_serial.cc: Need additional include.
* fhandler_tty.cc (fhandler_tty_master::fhandler_tty_master):
- Accomodate fhandler_termios base class.
+ Accommodate fhandler_termios base class.
(fhandler_tty_master::init): Ditto.
(fhandler_tty_master::accept_input): New function. Sends
(possibly line-edited) input to slave.
(process_input): Use line editing capabilities of fhandler_termios
base class when processing input.
- (fhandler_tty_slave::open): Accomodate fhandler_termios base class.
+ (fhandler_tty_slave::open): Accommodate fhandler_termios base class.
(fhandler_tty_slave::tcgetattr): Ditto.
(fhandler_tty_slave::ioctl): Ditto.
(fhandler_pty_master::fhandler_pty_master): Ditto.
(fhandler_pty_master::read): Ditto.
(fhandler_tty_slave::dup): Be more paranoid about setting output
handle in case of error.
- * fhandler_tty.h: Accomodate new tty_min base class in tty class.
+ * fhandler_tty.h: Accommodate new tty_min base class in tty class.
* hinfo.cc (hinfo::build_fhandler): Send tty 'unit' to constructor.
* select.cc (peek_console): Send resize event to window regardless
of tty setting. Eliminate ReadFile kludge.
diff --git a/winsup/cygwin/ChangeLog-2000 b/winsup/cygwin/ChangeLog-2000
index 10e7e30af..54494e610 100644
--- a/winsup/cygwin/ChangeLog-2000
+++ b/winsup/cygwin/ChangeLog-2000
@@ -120,7 +120,7 @@ Sat Dec 9 16:29:45 2000 Christopher Faylor <cgf@cygnus.com>
Fri Dec 8 22:21:01 2000 Christopher Faylor <cgf@cygnus.com>
- * path.cc (normalize_win32_path): Reorganize logic to accomodate
+ * path.cc (normalize_win32_path): Reorganize logic to accommodate
chroot. Always check for MAX_PATH overrun. Avoid adding one too many
backslashes when src path begins with a slash. From Corinna Vinschen.
* winsup.h: Force demangling for dll_crt0 for newer compilers.
@@ -567,7 +567,7 @@ Thu Nov 2 00:10:23 2000 Christopher Faylor <cgf@cygnus.com>
psapi.h.
(EnumProcesses9x): Rename from EnumProcessesW95. Change arguments to
be more useful for cygwin.
- (winpids::init): Accomodate argument changes.
+ (winpids::init): Accommodate argument changes.
(enum_init): Ditto.
* pinfo.h (winpids): Make pidlist dynamically extendable by storing it
as a pointer and remembering the size.
@@ -958,7 +958,7 @@ Mon Oct 16 18:37:22 2000 Christopher Faylor <cgf@cygnus.com>
(normalize_win32_path): Ditto.
(cwdstuff::get_initial): Always set lock.
* sigproc.h: Remove hExeced.
- * strace.cc (strace::vsprntf): Modify to accomodate for lack of hExeced.
+ * strace.cc (strace::vsprntf): Modify to accommodate for lack of hExeced.
* thread.cc (MTinterface::Init): Merge Init1 and ClearReent into this method.
(MTinterface::Init1): Eliminate.
(MTinterface::ClearReent): Eliminate.
@@ -1301,7 +1301,7 @@ Sun Oct 1 16:36:00 2000 Corinna Vinschen <corinna@vinschen.de>
Sun Oct 1 22:20:39 2000 Christopher Faylor <cgf@cygnus.com>
* cygheap.cc (cygheap_init): Born again function.
- (_cmalloc): Reorganize to accomodate muto locking.
+ (_cmalloc): Reorganize to accommodate muto locking.
(_cfree): Use muto lock to avoid multi-thread problems.
* cygheap.h (incygheap): Just use cygheap_max to find upper cygwin heap
bounds.
@@ -1334,8 +1334,8 @@ Sat Sep 30 00:43:42 2000 Christopher Faylor <cgf@cygnus.com>
execed or not. In execed case, walk the heap, cleaning up any orphaned
blocks.
* cygheap.h: Add a "MAX" value to cygheap_types. Remove cygheap_init
- declaration. Accomodate new argument to cygheap_fixup_in child.
- * fork.cc (fork): Accomodate extra argument to cygheap_fixup_in_child.
+ declaration. Accommodate new argument to cygheap_fixup_in child.
+ * fork.cc (fork): Accommodate extra argument to cygheap_fixup_in_child.
* dcrt0.cc (dll_crt0_1): Ditto. Remove call to cygheap_init.
Fri Sep 29 21:49:27 2000 Christopher Faylor <cgf@cygnus.com>
@@ -1360,7 +1360,7 @@ Thu Sep 28 01:46:00 2000 Corinna Vinschen <corinna@vinschen.de>
Wed Sep 27 01:10:07 2000 Christopher Faylor <cgf@cygnus.com>
- * spawn.cc (spawn_guts): Attempt to accomodate archaic windows quoting
+ * spawn.cc (spawn_guts): Attempt to accommodate archaic windows quoting
mechanism when dealing with '\' and '"'.
Mon Sep 25 20:47:04 2000 Christopher Faylor <cgf@cygnus.com>
@@ -1606,7 +1606,7 @@ Mon Sep 4 22:53:58 2000 Christopher Faylor <cgf@cygnus.com>
(normalize_win32_path): Ditto.
(mount_info::conv_to_win32_path): Eliminate cwd retrieval here.
(mount_info::conv_to_posix_path): Ditto.
- (hash_path_name): Accomodate additional methods in cwdstuff.
+ (hash_path_name): Accommodate additional methods in cwdstuff.
(get_cwd_win32): Eliminate.
(getcwd): Use cwdstuff methods. Properly handle case where buf == NULL
and len < 0.
@@ -1641,7 +1641,7 @@ Sun Sep 3 00:07:32 2000 Christopher Faylor <cgf@cygnus.com>
* dcrt0.cc (quoted): Simplify due to new method for passing arguments
between cygwin programs.
(alloc_stack_hard_way): Attempt to handle overlapped stack.
- (dll_crt0_1): Move child_info processing here. Accomodate new method
+ (dll_crt0_1): Move child_info processing here. Accommodate new method
for passing arguments between cygwin programs. Initialize cygwin heap.
Establish __argc and __argv variables.
(_dll_crt0): Move most of child_info processing to dll_crt0_1.
@@ -1668,7 +1668,7 @@ Sun Sep 3 00:07:32 2000 Christopher Faylor <cgf@cygnus.com>
(fhandler_base::de_linearize): Delete.
(fhandler_base::operator delete): Free from cygwin heap.
(fhandler_base::~fhandler_base): Ditto.
- * fhandler.h: Accomodate elimination of *linearize and other changes
+ * fhandler.h: Accommodate elimination of *linearize and other changes
above.
* fhandler_console.cc (fhandler_console::fixup_after_exec): Rename from
de_linearize.
@@ -1687,10 +1687,10 @@ Sun Sep 3 00:07:32 2000 Christopher Faylor <cgf@cygnus.com>
(cwd_posix): New function.
(cwd_hash): New function.
(cwd_fixup_after_exec): New function.
- * path.h: Accomodate path.cc changes.
+ * path.h: Accommodate path.cc changes.
* pinfo.cc (pinfo_init): Accept a pointer to an environment table.
Pass this to environ_init. Eliminate old 'title' tests.
- * pinfo.h: Accomodate above change in argument.
+ * pinfo.h: Accommodate above change in argument.
* spawn.cc (struct av): New method for building argv list.
(av::unshift): New method.
(spawn_guts): Allocate everything that the child process needs in the
@@ -2069,8 +2069,8 @@ Sat Jul 29 12:01:32 2000 Christopher Faylor <cgf@cygnus.com>
Redefine process structure to avoid a fixed size table. Redefine
pinfo/_pinfo classes. Use these throughout.
- * dcrt0.cc (dll_crt0_1): Accomodate set_myself argument change.
- (__api_fatal): Accomodate _pinfo::record_death argument change.
+ * dcrt0.cc (dll_crt0_1): Accommodate set_myself argument change.
+ (__api_fatal): Accommodate _pinfo::record_death argument change.
* exceptions.cc (really_exit): Ditto.
(sig_handle_tty_stop): Use pinfo constructor to access process info.
(events_init): Don't create pinfo_mutex since it is no longer required.
@@ -2089,7 +2089,7 @@ Sat Jul 29 12:01:32 2000 Christopher Faylor <cgf@cygnus.com>
(set_myself): Accept a pid argument now. Call pinfo initializer to
initialize myself. Detect when this is an "execed" process and create
an "indirect" pid block.
- (pinfo_init): Accomodate set_myself arg change.
+ (pinfo_init): Accommodate set_myself arg change.
(procinfo): Remove.
(pinfo::lock_pinfo): Remove.
(pinfo::unlock_pinfo): Remove.
@@ -2126,7 +2126,7 @@ Sat Jul 29 12:01:32 2000 Christopher Faylor <cgf@cygnus.com>
(internal_getlogin): Use _pinfo.
* winsup.h: Eliminate pinfo_mutex. Eliminate spawn_guts declaration
since it is static now. Reflect set_myself argument change.
- * include/sys/cygwin.h: Add some PID_* enums to accomodate new pinfo
+ * include/sys/cygwin.h: Add some PID_* enums to accommodate new pinfo
stuff.
Sat Jul 29 12:13:27 2000 Christopher Faylor <cgf@cygnus.com>
@@ -2312,7 +2312,7 @@ Fri Jul 21 12:03:00 2000 Corinna Vinschen <corinna@vinschen.de>
Wed Jul 19 22:24:00 2000 Corinna Vinschen <corinna@vinschen.de>
* spawn.cc (spawn_guts): Don't restore impersonation in case
- of _P_OVERLAY. Clean up slightly. Accomodate comments.
+ of _P_OVERLAY. Clean up slightly. Accommodate comments.
Wed Jul 19 22:11:00 2000 Corinna Vinschen <corinna@vinschen.de>
@@ -2488,7 +2488,7 @@ Sat Jul 8 00:15:01 2000 Christopher Faylor <cgf@cygnus.com>
__cygwin_user_data pointer from cygwin_internal. If it doesn't exist,
return failure. Use either this pointer or passed in pointer
throughout. Clear forkee.
- * lib/crt0.h: Accomodate argument changes to _cygwin_crt0_common.
+ * lib/crt0.h: Accommodate argument changes to _cygwin_crt0_common.
* lib/cygwin_attach_dll.c (cygwin_attach_dll): Reorganize to allow use
of newer binaries with older DLLs. Detect older DLLs when
_cygwin_crt0_common returns 0 and allocate space for a per_process
@@ -2518,7 +2518,7 @@ Wed Jul 5 18:56:58 2000 Christopher Faylor <cgf@cygnus.com>
(DllListIterator::operator *): Ditto.
(dll_dllcrt0): Default to __cygwin_user_data if arg is NULL.
* include/sys/cygwin.h: Reorganize per_process to eliminate obsolete
- fields and accomodate new way of initializing.
+ fields and accommodate new way of initializing.
* lib/_cygwin_crt0_common: Initialize _impure_ptr from
__cygwin_user_data.impure_ptr.
@@ -2624,7 +2624,7 @@ Sat Jul 1 11:43:32 2000 Christopher Faylor <cgf@cygnus.com>
Sat Jul 1 00:24:04 2000 Christopher Faylor <cgf@cygnus.com>
* dcrt0.cc (_dll_crt0): Renamed from dll_crt0 ().
- * winsup.h: Accomodate above change.
+ * winsup.h: Accommodate above change.
* cygwin.din: Ditto.
* lib/cygwin_crt0.c: Ditto.
@@ -2813,7 +2813,7 @@ Sat Jun 17 13:51:48 2000 Christopher Faylor <cgf@cygnus.com>
* configure.in: Detect "cross-hosting" situation and set appropriate
variables in Makefile to avoid building excess stuff.
* configure: Regenerate.
- * Makefile.in: Accomodate above change.
+ * Makefile.in: Accommodate above change.
Sat Jun 17 19:52:00 2000 Corinna Vinschen <corinna@vinschen.de>
@@ -3189,7 +3189,7 @@ Mon May 15 00:35:35 2000 Christopher Faylor <cgf@cygnus.com>
Sun May 14 23:41:24 2000 Christopher Faylor <cgf@cygnus.com>
* shared.h: Bump PROC_MAGIC.
- * include/cygwin/version.h: Bump API minor to accomodate two recent
+ * include/cygwin/version.h: Bump API minor to accommodate two recent
exports.
2000-05-13 Mumit Khan <khan@xraylith.wisc.edu>
@@ -3438,7 +3438,7 @@ Fri Apr 21 10:37:08 2000 Christopher Faylor <cgf@cygnus.com>
Thu Apr 20 17:32:42 2000 Christopher Faylor <cgf@cygnus.com>
* exceptions.cc (handle_exceptions): Search further for stack info to
- accomodate Windows 95.
+ accommodate Windows 95.
Thu Apr 20 16:39:18 2000 Christopher Faylor <cgf@cygnus.com>
@@ -3956,7 +3956,7 @@ Sat Feb 5 00:26:01 2000 Christopher Faylor <cgf@cygnus.com>
* exceptions.cc (sigWaitForSingleObject): Eliminate obsolete function
definition.
* fhandler.h: Reflect change to select_stuff wait method.
- * fhandler_tape.cc (get_ll): Accomodate new w32api LARGE_INTEGER
+ * fhandler_tape.cc (get_ll): Accommodate new w32api LARGE_INTEGER
definition.
* ntea.c (NTReadEARaw): Ditto.
(NTWriteEA): Ditto.
diff --git a/winsup/cygwin/Makefile.in b/winsup/cygwin/Makefile.in
index 6aaca814f..2e324a606 100644
--- a/winsup/cygwin/Makefile.in
+++ b/winsup/cygwin/Makefile.in
@@ -14,7 +14,7 @@ srcdir:=@srcdir@
objdir:=.
CONFIG_DIR:=$(srcdir)/config/@CONFIG_DIR@
-VPATH:=$(srcdir):$(CONFIG_DIR):$(srcdir)/regexp:$(srcdir)/lib
+VPATH:=$(srcdir):$(CONFIG_DIR):$(srcdir)/regex:$(srcdir)/regexp:$(srcdir)/lib
target_alias:=@target_alias@
build_alias:=@build_alias@
@@ -44,14 +44,14 @@ INSTALL_PROGRAM:=@INSTALL_PROGRAM@
#
# --enable options from configure
#
-MT_SAFE = @MT_SAFE@
-DEFS = @DEFS@
+MT_SAFE:=@MT_SAFE@
+DEFS:=@DEFS@
CC:=@CC@
# FIXME: Which is it, CC or CC_FOR_TARGET?
CC_FOR_TARGET:=$(CC)
CFLAGS:=@CFLAGS@
-CFLAGS+=-MD -fbuiltin
+CFLAGS+=-MMD -fbuiltin
CXX:=@CXX@
CXXFLAGS:=@CXXFLAGS@
@@ -65,7 +65,8 @@ LD:=@LD@
DLLTOOL:=@DLLTOOL@
WINDRES:=@WINDRES@
AS:=@AS@
-LDSCRIPT=cygwin.sc
+NM:=@NM@
+LDSCRIPT:=cygwin.sc
#
# Include common definitions for winsup directory
@@ -122,23 +123,34 @@ DLL_OFILES:=assert.o autoload.o cygheap.o cygserver_client.o \
delqueue.o dir.o \
dlfcn.o dll_init.o dtable.o environ.o errno.o exceptions.o exec.o \
external.o fcntl.o fhandler.o fhandler_clipboard.o fhandler_console.o \
- fhandler_dsp.o fhandler_floppy.o fhandler_mem.o fhandler_random.o \
- fhandler_raw.o fhandler_serial.o fhandler_socket.o fhandler_tape.o \
- fhandler_termios.o fhandler_tty.o fhandler_windows.o fhandler_zero.o \
- fork.o glob.o grp.o heap.o init.o ioctl.o ipc.o localtime.o malloc.o \
- miscfuncs.o mmap.o net.o ntea.o passwd.o path.o pinfo.o pipe.o poll.o \
- pthread.o regexp.o regerror.o regsub.o registry.o resource.o scandir.o \
- sched.o sec_acl.o sec_helper.o security.o select.o shared.o shm.o \
- shortcut.o signal.o sigproc.o \
- smallprint.o spawn.o strace.o strsep.o sync.o syscalls.o sysconf.o \
- syslog.o termios.o thread.o times.o tty.o uinfo.o uname.o wait.o \
- wincap.o window.o \
- $(EXTRA_DLL_OFILES) $(EXTRA_OFILES) $(MALLOC_OFILES) $(MT_SAFE_OBJECTS)
-
-GMON_OFILES:= gmon.o mcount.o profil.o
-
+ fhandler_disk_file.o fhandler_dsp.o fhandler_floppy.o fhandler_mem.o \
+ fhandler_random.o fhandler_raw.o fhandler_serial.o fhandler_socket.o \
+ fhandler_tape.o fhandler_termios.o fhandler_tty.o fhandler_windows.o \
+ fhandler_zero.o fork.o glob.o grp.o heap.o init.o ioctl.o ipc.o \
+ localtime.o malloc.o miscfuncs.o mmap.o net.o ntea.o passwd.o path.o \
+ pinfo.o pipe.o poll.o pthread.o regcomp.o regerror.o regexec.o \
+ regfree.o registry.o resource.o scandir.o sched.o sec_acl.o \
+ sec_helper.o security.o select.o shared.o shm.o shortcut.o signal.o \
+ sigproc.o smallprint.o spawn.o strace.o strsep.o sync.o syscalls.o \
+ sysconf.o syslog.o termios.o thread.o times.o tty.o uinfo.o uname.o \
+ v8_regexp.o v8_regerror.o v8_regsub.o wait.o wincap.o window.o \
+ $(EXTRA_DLL_OFILES) $(EXTRA_OFILES) $(MALLOC_OFILES) $(MT_SAFE_OBJECTS)
+
+GMON_OFILES:=gmon.o mcount.o profil.o
+
+OBSOLETE_FUNCTIONS:=regcomp regerror regexec regfree regsub
+NEW_FUNCTIONS:=regcomp posix_regcomp \
+ regerror posix_regerror \
+ regexec posix_regexec \
+ regfree posix_regfree
+
+PWD:=${shell pwd}
+SUBLIBS:=libpthread.a $(PWD)/libm.a libc.a
+EXTRALIBS:=libautomode.a libbinmode.a libtextmode.a
+INSTOBJS:=automode.o binmode.o textmode.o
+TARGET_LIBS:=$(LIB_NAME) $(SUBLIBS) $(GMON_START) $(LIBGMON_A) $(SUBLIBS) $(INSTOBJS) $(EXTRALIBS)
.PHONY: all force dll_ofiles install all_target install_target all_host install_host \
- install install_target install-libs install-headers
+ install install-libs install-headers
.SUFFIXES:
.SUFFIXES: .c .cc .def .a .o .d
@@ -148,7 +160,7 @@ install_host=@install_host@
all: all_target $(all_host)
-all_target: $(LIB_NAME) automode.o binmode.o textmode.o $(LIBGMON_A) cygserver.exe
+all_target: $(TARGET_LIBS) cygserver.exe
all_host: new-$(LIB_NAME) cygrun.exe
@@ -156,13 +168,13 @@ force:
install: install-bin install-libs install-headers $(install_host) $(install_target)
-install-bin: cygserver.exe
- $(INSTALL_PROGRAM) cygserver.exe $(bindir)/cygserver.exe
+install: install-libs install-headers install-man install_target \
+ $(install_host) $(install_target)
-install-libs: $(LIB_NAME)
+install-libs: $(TARGET_LIBS)
$(INSTALL_DATA) new-$(DLL_NAME) $(bindir)/$(DLL_NAME); \
- for i in $(LIB_NAME) $(GMON_START) $(LIBGMON_A) automode.o binmode.o textmode.o ; do \
- $(INSTALL_DATA) $$i $(tooldir)/lib/$$i ; \
+ for i in $^; do \
+ $(INSTALL_DATA) $$i $(tooldir)/lib/`basename $$i` ; \
done
install-headers:
@@ -172,43 +184,57 @@ install-headers:
$(INSTALL_DATA) $$i $(tooldir)/$$sub/`basename $$i` ; \
done ; \
done ; \
- $(INSTALL_DATA) regexp/regexp.h $(tooldir)/include/regexp.h
+ $(INSTALL_DATA) regex/regex.h $(tooldir)/include/regex.h
+
+install-man:
+ cd $(srcdir); \
+ for i in `find . -type f -name '*.2'`; do \
+ $(INSTALL_DATA) $$i $(tooldir)/man/man2/`basename $$i` ; \
+ done; \
+ for i in `find . -type f -name '*.3'`; do \
+ $(INSTALL_DATA) $$i $(tooldir)/man/man3/`basename $$i` ; \
+ done; \
+ for i in `find . -type f -name '*.5'`; do \
+ $(INSTALL_DATA) $$i $(tooldir)/man/man5/`basename $$i` ; \
+ done; \
+ for i in `find . -type f -name '*.7'`; do \
+ $(INSTALL_DATA) $$i $(tooldir)/man/man7/`basename $$i` ; \
+ done
+install_target: cygserver.exe
+ $(INSTALL_PROGRAM) cygserver.exe $(bindir)/cygserver.exe
+
install_host:
clean:
- -rm -f *.o *.dll *.a *.exp junk *.base version.cc regexp/*.o winver_stamp *.exe *.d
+ -rm -f *.o *.dll *.a *.exp junk *.base version.cc regexp/*.o winver_stamp *.exe *.d *stamp* *_magic.h
maintainer-clean realclean: clean
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
-rm -fr configure
-# Rule to build libcygwin.a
-
-# Rule to make stub library used by testsuite
-
-# dependency set to $(LIB_NAME) to accomodate make -j2.
-# Otherwise dlltool gets confused. cgf (11-16-2000)
-new-$(LIB_NAME): $(LIB_NAME)
- $(DLLTOOL) --as=$(AS) --dllname new-$(DLL_NAME) --def $(DEF_FILE) --output-lib new-templib.a
- $(AR) rcv new-templib.a $(LIBCOS)
- mv new-templib.a new-$(LIB_NAME)
# Rule to build cygwin.dll
-
new-$(DLL_NAME): $(LDSCRIPT) $(DLL_OFILES) $(DEF_FILE) $(DLL_IMPORTS) $(LIBC) $(LIBM) Makefile winver_stamp
- $(CXX) $(CXXFLAGS) -nostdlib -Wl,-T$(firstword $^) -Wl,--out-implib,$(LIB_NAME) -shared -o $@ \
+ $(CXX) $(CXXFLAGS) -nostdlib -Wl,-T$(firstword $^) -Wl,--out-implib,cygdll.a -shared -o $@ \
-e $(DLL_ENTRY) $(DEF_FILE) $(DLL_OFILES) version.o winver.o \
$(DLL_IMPORTS) $(MALLOC_OBJ) $(LIBM) $(LIBC) \
-lstdc++ -lgcc -lshell32 -luuid
- @rm -f stamp-cygwin-lib
-$(LIB_NAME): new-$(DLL_NAME) $(LIBCOS) stamp-cygwin-lib
- $(AR) rcv $(LIB_NAME) $(LIBCOS)
+# Rule to build libcygwin.a
+$(LIB_NAME): rmsym newsym new-$(DLL_NAME) $(LIBCOS)
+ /bin/sh ${word 1,$^} ./cygdll.a "$(NM)" "$(AR)" "$(RANLIB)" $(OBSOLETE_FUNCTIONS) || exit 0
+ /bin/sh ${word 2,$^} ./cygdll.a "$(AS)" "$(AR)" "$(RANLIB)" $(NEW_FUNCTIONS) || exit 0
+ (echo create $(LIB_NAME); echo addmod $(LIBCOS); echo addlib cygdll.a; echo save) | $(AR) -M
-stamp-cygwin-lib:
- @touch stamp-cygwin-lib
+# Rule to make stub library used by testsuite
+# dependency set to $(LIB_NAME) to accommodate make -j2.
+# Otherwise dlltool gets confused. cgf (11-16-2000)
+new-$(LIB_NAME): $(LIB_NAME)
+ $(DLLTOOL) --as=$(AS) --dllname new-$(DLL_NAME) --def $(DEF_FILE) --output-lib new-templib.a
+ $(AR) rcv new-templib.a $(LIBCOS)
+ mv new-templib.a new-$(LIB_NAME)
dll_ofiles: $(DLL_OFILES)
@@ -218,6 +244,28 @@ $(LIBGMON_A): $(GMON_OFILES) $(GMON_START)
version.cc winver.o: winver_stamp
@ :
+shared_info_magic.h: cygmagic shared_info.h
+ /bin/sh ${word 1,$^} $@ "$(CC)" ${word 2,$^} MOUNT_MAGIC 'class mount_info' SHARED_MAGIC 'class shared_info'
+
+child_info_magic.h: cygmagic child_info.h
+ /bin/sh ${word 1,$^} $@ "$(CC)" ${word 2,$^} CHILD_INFO_MAGIC 'class child_info'
+
+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}" ${wordlist 2, 99, $^}
+
+$(PWD)/libm.a: speclib cygwin.def $(LIBM)
+ /bin/sh ${word 1, $^} $@ "${NM}" "${DLLTOOL}" ${wordlist 2, 99, $^}
+
+$(PWD)/libc.a: speclib cygwin.def $(PWD)/libm.a libpthread.a
+ /bin/sh ${word 1, $^} -v $@ "${NM}" "${DLLTOOL}" ${wordlist 2, 99, $^}
+
+lib%.a: %.o
+ $(AR) cru $@ $?
+
winver_stamp: mkvers.sh include/cygwin/version.h winver.rc $(DLL_OFILES)
@echo "Making version.o and winver.o";\
$(SHELL) ${word 1,$^} ${word 2,$^} ${word 3,$^} $(WINDRES) && \
diff --git a/winsup/cygwin/autoload.cc b/winsup/cygwin/autoload.cc
index ffd9f0078..ec71b6641 100644
--- a/winsup/cygwin/autoload.cc
+++ b/winsup/cygwin/autoload.cc
@@ -241,10 +241,8 @@ static long long
wsock_init ()
{
static LONG NO_COPY here = -1L;
- extern WSADATA wsadata;
struct func_info *func = (struct func_info *) __builtin_return_address (0);
struct dll_info *dll = func->dll;
- retchain ret;
__asm__ (" \n\
.section .ws2_32_info \n\
@@ -262,7 +260,7 @@ wsock_init ()
Sleep (0);
}
- if (!wsock_started && (wsock32_handle || ws2_32_handle))
+ if (!wsock_started && (winsock_active || winsock2_active))
{
/* Don't use autoload to load WSAStartup to eliminate recursion. */
int (*wsastartup) (int, WSADATA *);
@@ -293,6 +291,7 @@ wsock_init ()
movl $dll_chain1,4(%ebp) \n\
");
+ volatile retchain ret;
/* Set "arguments for dll_chain1. */
ret.low = (long) dll_func_load;
ret.high = (long) func;
@@ -375,6 +374,7 @@ LoadDLLfunc (NetWkstaUserGetInfo, 12, netapi32)
LoadDLLfuncEx (NtCreateToken, 52, ntdll, 1)
LoadDLLfuncEx (NtMapViewOfSection, 40, ntdll, 1)
+LoadDLLfuncEx (NtOpenFile, 24, ntdll, 1)
LoadDLLfuncEx (NtOpenSection, 12, ntdll, 1)
LoadDLLfuncEx (NtQuerySystemInformation, 16, ntdll, 1)
LoadDLLfuncEx (NtUnmapViewOfSection, 8, ntdll, 1)
@@ -382,6 +382,8 @@ LoadDLLfuncEx (RtlInitUnicodeString, 8, ntdll, 1)
LoadDLLfuncEx (RtlNtStatusToDosError, 4, ntdll, 1)
LoadDLLfuncEx (ZwQuerySystemInformation, 16, ntdll, 1)
+LoadDLLfuncEx (GetProcessMemoryInfo, 12, psapi, 1)
+
LoadDLLfuncEx (LsaDeregisterLogonProcess, 4, secur32, 1)
LoadDLLfuncEx (LsaFreeReturnBuffer, 4, secur32, 1)
LoadDLLfuncEx (LsaLogonUser, 56, secur32, 1)
@@ -418,11 +420,12 @@ LoadDLLfunc (SetClipboardData, 8, user32)
LoadDLLfunc (SetTimer, 16, user32)
LoadDLLfunc (SetUserObjectSecurity, 12, user32)
+LoadDLLfuncEx (load_wsock32, 0, wsock32, 1) // non-existent function forces wsock32 load
LoadDLLfunc (WSAAsyncSelect, 16, wsock32)
LoadDLLfunc (WSACleanup, 0, wsock32)
LoadDLLfunc (WSAGetLastError, 0, wsock32)
LoadDLLfunc (WSASetLastError, 4, wsock32)
-LoadDLLfunc (WSAStartup, 8, wsock32)
+// LoadDLLfunc (WSAStartup, 8, wsock32)
LoadDLLfunc (__WSAFDIsSet, 8, wsock32)
LoadDLLfunc (accept, 12, wsock32)
LoadDLLfunc (bind, 12, wsock32)
@@ -474,12 +477,13 @@ LoadDLLfunc (CoInitialize, 4, ole32)
LoadDLLfunc (CoUninitialize, 0, ole32)
LoadDLLfunc (CoCreateInstance, 20, ole32)
-LoadDLLfuncEx (SignalObjectAndWait, 16, kernel32, 1)
LoadDLLfuncEx (CancelIo, 4, kernel32, 1)
+LoadDLLfuncEx (CreateHardLinkA, 12, kernel32, 1)
+LoadDLLfuncEx (CreateToolhelp32Snapshot, 8, kernel32, 1)
+LoadDLLfuncEx (IsDebuggerPresent, 0, kernel32, 1)
LoadDLLfuncEx (Process32First, 8, kernel32, 1)
LoadDLLfuncEx (Process32Next, 8, kernel32, 1)
-LoadDLLfuncEx (CreateToolhelp32Snapshot, 8, kernel32, 1)
-LoadDLLfuncEx (CreateHardLinkA, 12, kernel32, 1)
+LoadDLLfuncEx (SignalObjectAndWait, 16, kernel32, 1)
LoadDLLfunc (TryEnterCriticalSection, 4, kernel32)
LoadDLLfuncEx (waveOutGetNumDevs, 0, winmm, 1)
diff --git a/winsup/cygwin/child_info.h b/winsup/cygwin/child_info.h
index 983675877..4b249a808 100644
--- a/winsup/cygwin/child_info.h
+++ b/winsup/cygwin/child_info.h
@@ -12,26 +12,35 @@ details. */
enum
{
- PROC_MAGIC = 0xaf12f000,
- PROC_FORK = PROC_MAGIC + 1,
- PROC_EXEC = PROC_MAGIC + 2,
- PROC_SPAWN = PROC_MAGIC + 3,
- PROC_FORK1 = PROC_MAGIC + 4, // Newer versions provide stack
- // location information
- PROC_SPAWN1 = PROC_MAGIC + 5
+ _PROC_EXEC,
+ _PROC_SPAWN,
+ _PROC_FORK
};
-#define PROC_MAGIC_MASK 0xff00f000
-#define PROC_MAGIC_GENERIC 0xaf00f000
-#define PROC_MAGIC_VER_MASK 0x0ff0000
+#define OPROC_MAGIC_MASK 0xff00ff00
+#define OPROC_MAGIC_GENERIC 0xaf00f000
+
+#define PROC_MAGIC_GENERIC 0xaf00fa00
+
+#define PROC_EXEC (_PROC_EXEC)
+#define PROC_SPAWN (_PROC_SPAWN)
+#define PROC_FORK (_PROC_FORK)
#define EXEC_MAGIC_SIZE sizeof(child_info)
+
+#define CURR_CHILD_INFO_MAGIC 0x8b3c
+
+/* NOTE: Do not make gratuitous changes to the names or organization of the
+ below class. The layout is checksummed to determine compatibility between
+ different cygwin versions. */
class child_info
{
public:
DWORD zero[4]; // must be zeroed
DWORD cb; // size of this record
- DWORD type; // type of record
+ DWORD intro; // improbable string
+ unsigned short magic; // magic number unique to child_info
+ unsigned short type; // type of record, exec, spawn, fork
int cygpid; // cygwin pid of child process
HANDLE subproc_ready; // used for synchronization with parent
HANDLE mount_h;
@@ -40,6 +49,7 @@ public:
init_cygheap *cygheap;
void *cygheap_max;
HANDLE cygheap_h;
+ unsigned fhandler_union_cb;
};
class child_info_fork: public child_info
diff --git a/winsup/cygwin/configure b/winsup/cygwin/configure
index 11311edda..3f41211fb 100755
--- a/winsup/cygwin/configure
+++ b/winsup/cygwin/configure
@@ -1274,10 +1274,77 @@ else
fi
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
+if eval "test \"`echo '$''{'ac_cv_prog_NM'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$NM"; then
+ ac_cv_prog_NM="$NM" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_NM="${ac_tool_prefix}nm"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+fi
+fi
+NM="$ac_cv_prog_NM"
+if test -n "$NM"; then
+ echo "$ac_t""$NM" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+
+if test -z "$ac_cv_prog_NM"; then
+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
+if eval "test \"`echo '$''{'ac_cv_prog_NM'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$NM"; then
+ ac_cv_prog_NM="$NM" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_NM="nm"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+ test -z "$ac_cv_prog_NM" && ac_cv_prog_NM="nm"
+fi
+fi
+NM="$ac_cv_prog_NM"
+if test -n "$NM"; then
+ echo "$ac_t""$NM" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+else
+ NM="nm"
+fi
+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:1281: checking for $ac_word" >&5
+echo "configure:1348: 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
@@ -1309,7 +1376,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:1313: checking for $ac_word" >&5
+echo "configure:1380: 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
@@ -1344,7 +1411,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:1348: checking for $ac_word" >&5
+echo "configure:1415: 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
@@ -1376,7 +1443,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:1380: checking for $ac_word" >&5
+echo "configure:1447: 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
@@ -1410,7 +1477,7 @@ fi
echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:1414: checking how to run the C preprocessor" >&5
+echo "configure:1481: checking how to run the C preprocessor" >&5
# On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then
CPP=
@@ -1425,13 +1492,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 1429 "configure"
+#line 1496 "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:1435: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1502: \"$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
:
@@ -1442,13 +1509,13 @@ else
rm -rf conftest*
CPP="${CC-cc} -E -traditional-cpp"
cat > conftest.$ac_ext <<EOF
-#line 1446 "configure"
+#line 1513 "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:1452: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1519: \"$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
:
@@ -1459,13 +1526,13 @@ else
rm -rf conftest*
CPP="${CC-cc} -nologo -E"
cat > conftest.$ac_ext <<EOF
-#line 1463 "configure"
+#line 1530 "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:1469: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1536: \"$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
:
@@ -1492,19 +1559,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:1496: checking for working alloca.h" >&5
+echo "configure:1563: 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 1501 "configure"
+#line 1568 "configure"
#include "confdefs.h"
#include <alloca.h>
int main() {
char *p = alloca(2 * sizeof(int));
; return 0; }
EOF
-if { (eval echo configure:1508: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1575: \"$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
@@ -1525,12 +1592,12 @@ EOF
fi
echo $ac_n "checking for alloca""... $ac_c" 1>&6
-echo "configure:1529: checking for alloca" >&5
+echo "configure:1596: 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 1534 "configure"
+#line 1601 "configure"
#include "confdefs.h"
#ifdef __GNUC__
@@ -1558,7 +1625,7 @@ int main() {
char *p = (char *) alloca(1);
; return 0; }
EOF
-if { (eval echo configure:1562: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1629: \"$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
@@ -1590,12 +1657,12 @@ EOF
echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6
-echo "configure:1594: checking whether alloca needs Cray hooks" >&5
+echo "configure:1661: 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 1599 "configure"
+#line 1666 "configure"
#include "confdefs.h"
#if defined(CRAY) && ! defined(CRAY2)
webecray
@@ -1620,12 +1687,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:1624: checking for $ac_func" >&5
+echo "configure:1691: 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 1629 "configure"
+#line 1696 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -1648,7 +1715,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:1652: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1719: \"$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
@@ -1675,7 +1742,7 @@ done
fi
echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6
-echo "configure:1679: checking stack direction for C alloca" >&5
+echo "configure:1746: 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
@@ -1683,7 +1750,7 @@ else
ac_cv_c_stack_direction=0
else
cat > conftest.$ac_ext <<EOF
-#line 1687 "configure"
+#line 1754 "configure"
#include "confdefs.h"
find_stack_direction ()
{
@@ -1702,7 +1769,7 @@ main ()
exit (find_stack_direction() < 0);
}
EOF
-if { (eval echo configure:1706: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1773: \"$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
@@ -1724,7 +1791,7 @@ EOF
fi
echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
-echo "configure:1728: checking whether ${MAKE-make} sets \${MAKE}" >&5
+echo "configure:1795: 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
@@ -1761,7 +1828,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 1765 "configure"
+#line 1832 "configure"
#include "confdefs.h"
#include <string.h>
@@ -1774,7 +1841,7 @@ int main() {
; return 0; }
EOF
-if { (eval echo configure:1778: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1845: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
use_builtin_memset=yes
else
@@ -1899,7 +1966,7 @@ esac
echo $ac_n "checking if newlib is part of the build tree""... $ac_c" 1>&6
-echo "configure:1903: checking if newlib is part of the build tree" >&5
+echo "configure:1970: checking if newlib is part of the build tree" >&5
EXE_LDFLAGS=
if test -d ../newlib
@@ -1914,9 +1981,9 @@ fi
if test x"$EXE_LDFLAGS" = x
then
echo $ac_n "checking if installed newlib needed""... $ac_c" 1>&6
-echo "configure:1918: checking if installed newlib needed" >&5
+echo "configure:1985: checking if installed newlib needed" >&5
cat > conftest.$ac_ext <<EOF
-#line 1920 "configure"
+#line 1987 "configure"
#include "confdefs.h"
int main() {
@@ -1924,7 +1991,7 @@ int main() {
; return 0; }
EOF
-if { (eval echo configure:1928: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1995: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
echo "$ac_t""no" 1>&6
@@ -2115,6 +2182,7 @@ s%@AR@%$AR%g
s%@AS@%$AS%g
s%@RANLIB@%$RANLIB%g
s%@LD@%$LD%g
+s%@NM@%$NM%g
s%@DLLTOOL@%$DLLTOOL%g
s%@WINDRES@%$WINDRES%g
s%@CPP@%$CPP%g
diff --git a/winsup/cygwin/configure.in b/winsup/cygwin/configure.in
index 8a20f084b..3934992a7 100644
--- a/winsup/cygwin/configure.in
+++ b/winsup/cygwin/configure.in
@@ -91,6 +91,8 @@ AC_CHECK_TOOL(RANLIB, ranlib, ranlib)
dnl C_SUBST(RANLIB)
AC_CHECK_TOOL(LD, ld, ld)
dnl C_SUBST(LD)
+AC_CHECK_TOOL(NM, nm, nm)
+dnl C_SUBST(NM)
AC_CHECK_TOOL(DLLTOOL, dlltool, dlltool)
dnl C_SUBST(DLLTOOL)
AC_CHECK_TOOL(WINDRES, windres, windres)
diff --git a/winsup/cygwin/cygerrno.h b/winsup/cygwin/cygerrno.h
index dd40819b9..0c1513f25 100644
--- a/winsup/cygwin/cygerrno.h
+++ b/winsup/cygwin/cygerrno.h
@@ -15,7 +15,12 @@ int __stdcall geterrno_from_win_error (DWORD code, int deferrno) __attribute__ (
#define __seterrno() seterrno (__FILE__, __LINE__)
#define __seterrno_from_win_error(val) seterrno_from_win_error (__FILE__, __LINE__, val)
+#ifndef DEBUGGING
#define set_errno(val) (_impure_ptr->_errno = (val))
+#else
+int __stdcall __set_errno (const char *ln, int ln, int val) __attribute ((regparm(3)));
+#define set_errno(val) __set_errno (__PRETTY_FUNCTION__, __LINE__, (val))
+#endif
#define get_errno() (_impure_ptr->_errno)
extern "C" void __stdcall set_sig_errno (int e);
diff --git a/winsup/cygwin/cygheap.cc b/winsup/cygwin/cygheap.cc
index a0e00d3c7..79fb48410 100644
--- a/winsup/cygwin/cygheap.cc
+++ b/winsup/cygwin/cygheap.cc
@@ -17,10 +17,10 @@
#include "fhandler.h"
#include "path.h"
#include "dtable.h"
+#include "cygerrno.h"
#include "cygheap.h"
#include "child_info.h"
#include "heap.h"
-#include "cygerrno.h"
#include "sync.h"
#include "shared_info.h"
@@ -93,12 +93,12 @@ cygheap_setup_for_child (child_info *ci, bool dup_later)
void __stdcall
cygheap_setup_for_child_cleanup (void *newcygheap, child_info *ci,
- bool dup_it_now)
+ bool dup_it_now)
{
if (dup_it_now)
{
/* NOTE: There is an assumption here that cygheap_max has not changed
- between the time that cygheap_setup_for_child was called and now.
+ between the time that cygheap_setup_for_child was called and now.
Make sure that this is a correct assumption. */
cygheap_protect->acquire ();
dup_now (newcygheap, ci, (char *) cygheap_max - (char *) cygheap);
@@ -322,7 +322,6 @@ crealloc (void *s, DWORD n)
extern "C" void __stdcall
cfree (void *s)
{
- MALLOC_CHECK;
assert (!inheap (s));
(void) _cfree (tocygheap (s));
MALLOC_CHECK;
@@ -378,13 +377,13 @@ init_cygheap::etc_changed ()
FILE_NOTIFY_CHANGE_LAST_WRITE);
if (etc_changed_h == INVALID_HANDLE_VALUE)
system_printf ("Can't open /etc for checking, %E", (char *) pwd,
- etc_changed_h);
+ etc_changed_h);
else if (!DuplicateHandle (hMainProc, etc_changed_h, hMainProc,
- &etc_changed_h, 0, TRUE,
+ &etc_changed_h, 0, TRUE,
DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE))
{
system_printf ("Can't inherit /etc handle, %E", (char *) pwd,
- etc_changed_h);
+ etc_changed_h);
etc_changed_h = INVALID_HANDLE_VALUE;
}
}
diff --git a/winsup/cygwin/cygheap.h b/winsup/cygwin/cygheap.h
index 1972411c7..d3025b452 100644
--- a/winsup/cygwin/cygheap.h
+++ b/winsup/cygwin/cygheap.h
@@ -165,6 +165,7 @@ struct init_cygheap
HANDLE shared_h;
HANDLE console_h;
HANDLE etc_changed_h;
+ char *cygwin_regname;
cwdstuff cwd;
dtable fdtab;
@@ -176,6 +177,88 @@ struct init_cygheap
extern init_cygheap *cygheap;
extern void *cygheap_max;
+class cygheap_fdmanip
+{
+ protected:
+ int fd;
+ fhandler_base **fh;
+ bool locked;
+ public:
+ cygheap_fdmanip (): fh (NULL) {}
+ virtual ~cygheap_fdmanip ()
+ {
+ if (locked)
+ ReleaseResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "cygheap_fdmanip");
+ }
+ void release ()
+ {
+ cygheap->fdtab.release (fd);
+ }
+ operator int &() {return fd;}
+ operator fhandler_base* &() {return *fh;}
+ void operator = (fhandler_base *fh) {*this->fh = fh;}
+ fhandler_base *operator -> () const {return *fh;}
+ bool isopen () const
+ {
+ if (*fh)
+ return true;
+ set_errno (EBADF);
+ return false;
+ }
+};
+
+class cygheap_fdnew : public cygheap_fdmanip
+{
+ public:
+ cygheap_fdnew (int seed_fd = -1, bool lockit = true)
+ {
+ if (lockit)
+ SetResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "cygheap_fdnew");
+ if (seed_fd < 0)
+ fd = cygheap->fdtab.find_unused_handle ();
+ else
+ fd = cygheap->fdtab.find_unused_handle (seed_fd + 1);
+ if (fd >= 0)
+ {
+ locked = lockit;
+ fh = cygheap->fdtab + fd;
+ }
+ else
+ {
+ set_errno (EMFILE);
+ if (lockit)
+ ReleaseResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "cygheap_fdnew");
+ locked = false;
+ }
+ }
+ void operator = (fhandler_base *fh) {*this->fh = fh;}
+};
+
+class cygheap_fdget : public cygheap_fdmanip
+{
+ public:
+ cygheap_fdget (int fd, bool lockit = false, bool do_set_errno = true)
+ {
+ if (lockit)
+ SetResourceLock (LOCK_FD_LIST, READ_LOCK, "cygheap_fdget");
+ if (fd >= 0 && fd < (int) cygheap->fdtab.size
+ && *(fh = cygheap->fdtab + fd) != NULL)
+ {
+ this->fd = fd;
+ locked = lockit;
+ }
+ else
+ {
+ this->fd = -1;
+ if (do_set_errno)
+ set_errno (EBADF);
+ if (lockit)
+ ReleaseResourceLock (LOCK_FD_LIST, READ_LOCK, "cygheap_fdget");
+ locked = false;
+ }
+ }
+};
+
class child_info;
void *__stdcall cygheap_setup_for_child (child_info *ci, bool dup_later) __attribute__ ((regparm(2)));
void __stdcall cygheap_setup_for_child_cleanup (void *, child_info *, bool) __attribute__ ((regparm(3)));
diff --git a/winsup/cygwin/cygwin.din b/winsup/cygwin/cygwin.din
index 690f4aec3..359e2c33d 100644
--- a/winsup/cygwin/cygwin.din
+++ b/winsup/cygwin/cygwin.din
@@ -159,6 +159,8 @@ ecvtf
_ecvtf = ecvtf
endgrent
_endgrent = endgrent
+endutent
+_endutent = endutent
erf
_erf = erf
erfc
@@ -376,6 +378,12 @@ gettimeofday
_gettimeofday = gettimeofday
getuid
_getuid = getuid
+getutent
+_getutent = getutent
+getutid
+_getutid = getutid
+getutline
+_getutline = getutline
glob
_glob = glob
globfree
@@ -594,16 +602,10 @@ readv
_readv = readv
realloc = export_realloc
_realloc = export_realloc
-regcomp
-_regcomp = regcomp
-regexec
-_regexec = regexec
-regerror
-_regerror = regerror
-regfree
-_regfree = regfree
-regsub
-_regsub = regsub
+posix_regcomp
+posix_regerror
+posix_regexec
+posix_regfree
remainder
_remainder = remainder
remainderf
@@ -666,6 +668,8 @@ setegid
_setegid = setegid
setuid
_setuid = setuid
+setutent
+_setutent = setutent
chroot
_chroot = chroot
setvbuf
@@ -858,6 +862,8 @@ ttyname
_ttyname = ttyname
tzset
_tzset = tzset
+ualarm
+_ualarm = ualarm
umask
_umask = umask
uname
@@ -866,10 +872,14 @@ ungetc
_ungetc = ungetc
unlink
_unlink = unlink
+usleep
+_usleep = usleep
utime
_utime = utime
utimes
_utimes = utimes
+utmpname
+_utmpname = utmpname
vfiprintf
_vfiprintf = vfiprintf
vfork
@@ -906,6 +916,7 @@ wctomb
_wctomb = wctomb
write
_write = write
+barfly = write
writev
_writev = writev
y0
@@ -963,8 +974,6 @@ wcscmp
_wcscmp = wcscmp
wcslen
_wcslen = wcslen
-usleep
-_usleep = usleep
wprintf
_wprintf = wprintf
memccpy
diff --git a/winsup/cygwin/cygwin.sc b/winsup/cygwin/cygwin.sc
index 43d880c06..b050e3e37 100644
--- a/winsup/cygwin/cygwin.sc
+++ b/winsup/cygwin/cygwin.sc
@@ -107,5 +107,5 @@ SECTIONS
{
__system_dlls__ = ABSOLUTE(.) ;
__cygheap_start = ABSOLUTE(.) ;
- }
+ }
}
diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc
index 9fb6ca906..5bc4481be 100644
--- a/winsup/cygwin/dcrt0.cc
+++ b/winsup/cygwin/dcrt0.cc
@@ -17,6 +17,7 @@ details. */
#include <limits.h>
#include <wingdi.h>
#include <winuser.h>
+#include <errno.h>
#include "sync.h"
#include "sigproc.h"
#include "pinfo.h"
@@ -29,7 +30,7 @@ details. */
#include "path.h"
#include "dtable.h"
#include "cygheap.h"
-#include "child_info.h"
+#include "child_info_magic.h"
#include "perthread.h"
#include "shared_info.h"
#include "cygwin_version.h"
@@ -74,6 +75,7 @@ ResourceLocks _reslock NO_COPY;
MTinterface _mtinterf;
bool NO_COPY _cygwin_testing;
+unsigned NO_COPY _cygwin_testing_magic;
extern "C"
{
@@ -517,18 +519,13 @@ alloc_stack (child_info_fork *ci)
fork on Win95, but I don't know exactly why yet. DJ */
volatile char b[ci->stacksize + 16384];
- if (ci->type == PROC_FORK)
- ci->stacksize = 0; // flag to fork not to do any funny business
- else
- {
- if (!VirtualQuery ((LPCVOID) &b, &sm, sizeof sm))
- api_fatal ("fork: couldn't get stack info, %E");
+ if (!VirtualQuery ((LPCVOID) &b, &sm, sizeof sm))
+ api_fatal ("fork: couldn't get stack info, %E");
- if (sm.AllocationBase != ci->stacktop)
- alloc_stack_hard_way (ci, b + sizeof (b) - 1);
- else
- ci->stacksize = 0;
- }
+ if (sm.AllocationBase != ci->stacktop)
+ alloc_stack_hard_way (ci, b + sizeof (b) - 1);
+ else
+ ci->stacksize = 0;
return;
}
@@ -592,17 +589,17 @@ dll_crt0_1 ()
{
switch (child_proc_info->type)
{
- case PROC_FORK:
- case PROC_FORK1:
+ case _PROC_FORK:
cygheap_fixup_in_child (child_proc_info, 0);
alloc_stack (fork_info);
set_myself (mypid);
ProtectHandle (child_proc_info->forker_finished);
break;
- case PROC_SPAWN:
- CloseHandle (spawn_info->hexec_proc);
+ case _PROC_SPAWN:
+ if (spawn_info->hexec_proc)
+ CloseHandle (spawn_info->hexec_proc);
goto around;
- case PROC_EXEC:
+ case _PROC_EXEC:
hexec_proc = spawn_info->hexec_proc;
around:
HANDLE h;
@@ -776,6 +773,31 @@ dll_crt0_1 ()
exit (user_data->main (__argc, __argv, *user_data->envptr));
}
+void
+initial_env ()
+{
+ char buf[MAX_PATH + 1];
+#ifdef DEBUGGING
+ if (GetEnvironmentVariable ("CYGWIN_SLEEP", buf, sizeof (buf) - 1))
+ {
+ console_printf ("Sleeping %d, pid %u\n", atoi (buf), GetCurrentProcessId ());
+ Sleep (atoi (buf));
+ }
+#endif
+
+ if (GetEnvironmentVariable ("CYGWIN_TESTING", buf, sizeof (buf) - 1))
+ {
+ _cygwin_testing = 1;
+ DWORD len;
+ if ((len = GetModuleFileName (cygwin_hmodule, buf, MAX_PATH))
+ && len > sizeof ("new-cygwin1.dll")
+ && strcasematch (buf + len - sizeof ("new-cygwin1.dll"),
+ "\\new-cygwin1.dll"))
+ _cygwin_testing_magic = 0x10;
+ }
+}
+
+
/* Wrap the real one, otherwise gdb gets confused about
two symbols with the same name, but different addresses.
@@ -785,18 +807,8 @@ dll_crt0_1 ()
extern "C" void __stdcall
_dll_crt0 ()
{
- char envbuf[8];
-#ifdef DEBUGGING
- if (GetEnvironmentVariable ("CYGWIN_SLEEP", envbuf, sizeof (envbuf) - 1))
- {
- console_printf ("Sleeping %d, pid %u\n", atoi (envbuf), GetCurrentProcessId ());
- Sleep (atoi (envbuf));
- }
-#endif
-
- if (GetEnvironmentVariable ("CYGWIN_TESTING", envbuf, sizeof (envbuf) - 1))
- _cygwin_testing = 1;
-
+ DECLARE_TLS_STORAGE;
+ initial_env ();
char zeros[sizeof (fork_info->zero)] = {0};
#ifdef DEBUGGING
strace.microseconds ();
@@ -818,31 +830,37 @@ _dll_crt0 ()
if (si.cbReserved2 >= EXEC_MAGIC_SIZE &&
memcmp (fork_info->zero, zeros, sizeof (zeros)) == 0)
{
+ if ((fork_info->intro & OPROC_MAGIC_MASK) == OPROC_MAGIC_GENERIC)
+ multiple_cygwin_problem ("proc", fork_info->intro, 0);
+ else if (fork_info->intro == PROC_MAGIC_GENERIC
+ && fork_info->magic != CHILD_INFO_MAGIC)
+ multiple_cygwin_problem ("proc", fork_info->magic, CHILD_INFO_MAGIC);
+ unsigned should_be_cb = 0;
switch (fork_info->type)
{
- case PROC_FORK:
- case PROC_FORK1:
+ case _PROC_FORK:
user_data->forkee = fork_info->cygpid;
- case PROC_SPAWN:
+ should_be_cb = sizeof (child_info_fork);
+ case _PROC_SPAWN:
if (fork_info->pppid_handle)
CloseHandle (fork_info->pppid_handle);
- case PROC_EXEC:
- {
- child_proc_info = fork_info;
- cygwin_mount_h = child_proc_info->mount_h;
- mypid = child_proc_info->cygpid;
- break;
- }
+ case _PROC_EXEC:
+ if (!should_be_cb)
+ should_be_cb = sizeof (child_info);
+ if (should_be_cb != fork_info->cb)
+ multiple_cygwin_problem ("proc size", fork_info->cb, should_be_cb);
+ else if (sizeof (fhandler_union) != fork_info->fhandler_union_cb)
+ multiple_cygwin_problem ("fhandler size", fork_info->fhandler_union_cb, sizeof (fhandler_union));
+ else
+ {
+ child_proc_info = fork_info;
+ cygwin_mount_h = child_proc_info->mount_h;
+ mypid = child_proc_info->cygpid;
+ break;
+ }
default:
- if (_cygwin_testing)
- fork_info = NULL;
- else if ((fork_info->type & PROC_MAGIC_MASK) == PROC_MAGIC_GENERIC)
- api_fatal ("\
-You have multiple copies of cygwin1.dll on your system.\n\
-Search for cygwin1.dll using the Windows Start->Find/Search facility\n\
-and delete all but the most recent version. This will probably be\n\
-the one that resides in x:\\cygwin\\bin, where 'x' is the drive on which\n\
-you have installed the cygwin distribution.\n");
+ system_printf ("unknown exec type %d", fork_info->type);
+ fork_info = NULL;
break;
}
}
@@ -852,6 +870,7 @@ you have installed the cygwin distribution.\n");
void
dll_crt0 (per_process *uptr)
{
+ DECLARE_TLS_STORAGE;
/* Set the local copy of the pointer into the user space. */
if (uptr && uptr != user_data)
{
@@ -1016,6 +1035,27 @@ __api_fatal (const char *fmt, ...)
myself->exit (1);
}
+void
+multiple_cygwin_problem (const char *what, unsigned magic_version, unsigned version)
+{
+ if (_cygwin_testing && strstr (what, "proc"))
+ {
+ fork_info = NULL;
+ return;
+ }
+ if (CYGWIN_VERSION_MAGIC_VERSION (magic_version) != version)
+ api_fatal ("%s version mismatch detected - %p/%p.\n\
+You have multiple copies of cygwin1.dll on your system.\n\
+Search for cygwin1.dll using the Windows Start->Find/Search facility\n\
+and delete all but the most recent version. The most recent version *should*\n\
+reside in x:\\cygwin\\bin, where 'x' is the drive on which you have\n\
+installed the cygwin distribution.", what, magic_version, version);
+
+ char buf[1024];
+ if (!GetEnvironmentVariable ("CYGWIN_MISMATCH_OK", buf, sizeof (buf)))
+ system_printf ("%s magic number mismatch detected - %p/%p", what, magic_version, version);
+}
+
#ifdef DEBUGGING
void __stdcall
cygbench (const char *s)
diff --git a/winsup/cygwin/debug.cc b/winsup/cygwin/debug.cc
index e8293b91f..76cce92ff 100644
--- a/winsup/cygwin/debug.cc
+++ b/winsup/cygwin/debug.cc
@@ -14,6 +14,7 @@ details. */
#include "perthread.h"
#include "perprocess.h"
#include "security.h"
+#include "cygerrno.h"
#undef CloseHandle
@@ -81,6 +82,7 @@ thread_start NO_COPY start_buf[NTHREADS] = {{0, NULL,NULL}};
static DWORD WINAPI
thread_stub (VOID *arg)
{
+ DECLARE_TLS_STORAGE;
LPTHREAD_START_ROUTINE threadfunc = ((thread_start *) arg)->func;
VOID *threadarg = ((thread_start *) arg)->arg;
@@ -93,7 +95,6 @@ thread_stub (VOID *arg)
SIGSEGV or SIGFPE. */
init_exceptions (&except_entry);
- set_reent (user_data->impure_ptr);
ExitThread (threadfunc (threadarg));
}
@@ -123,7 +124,7 @@ out:
info->arg = param; /* The single parameter to the thread */
if ((h = CreateThread (&sec_none_nih, 0, thread_stub, (VOID *) info, flags,
- &tid)))
+ &tid)))
regthread (name, tid); /* Register for debugging output. */
return h;
@@ -213,11 +214,14 @@ out:
}
void
-setclexec_pid (HANDLE h, bool setit)
+setclexec_pid (HANDLE oh, HANDLE nh, bool setit)
{
- handle_list *hl = find_handle (h);
+ handle_list *hl = find_handle (oh);
if (hl)
- hl->clexec_pid = setit ? GetCurrentProcessId () : 0;
+ {
+ hl->clexec_pid = setit ? GetCurrentProcessId () : 0;
+ hl->h = nh;
+ }
}
/* Create a new handle record */
@@ -348,4 +352,12 @@ close_handle (const char *func, int ln, HANDLE h, const char *name, BOOL force)
#endif
return ret;
}
+
+/* Add a handle to the linked list of known handles. */
+int __stdcall
+__set_errno (const char *func, int ln, int val)
+{
+ debug_printf ("%s:%d val %d", func, ln, val);
+ return _impure_ptr->_errno = val;
+}
#endif /*DEBUGGING*/
diff --git a/winsup/cygwin/debug.h b/winsup/cygwin/debug.h
index 8323e617a..0b7e53359 100644
--- a/winsup/cygwin/debug.h
+++ b/winsup/cygwin/debug.h
@@ -43,7 +43,7 @@ int __stdcall iscygthread ();
# define ProtectHandle1(h,n) do {} while (0)
# define ProtectHandle2(h,n) do {} while (0)
# define debug_init() do {} while (0)
-# define setclexec_pid(h, b) do {} while (0)
+# define setclexec_pid(h, nh, b) do {} while (0)
# define debug_fixup_after_fork() do {} while (0)
#else
@@ -72,7 +72,7 @@ BOOL __stdcall close_handle (const char *, int, HANDLE, const char *, BOOL)
__attribute__ ((regparm (3)));
void __stdcall cygbench (const char *s) __attribute__ ((regparm (1)));
extern "C" void console_printf (const char *fmt,...);
-void setclexec_pid (HANDLE, bool);
+void setclexec_pid (HANDLE, HANDLE, bool);
void debug_fixup_after_fork ();
extern int pinger;
diff --git a/winsup/cygwin/dir.cc b/winsup/cygwin/dir.cc
index 079c5c4fe..5713c5767 100644
--- a/winsup/cygwin/dir.cc
+++ b/winsup/cygwin/dir.cc
@@ -65,6 +65,8 @@ writable_directory (const char *file)
extern "C" int
dirfd (DIR *dir)
{
+ if (check_null_invalid_struct_errno (dir))
+ return -1;
if (dir->__d_cookie != __DIRENT_COOKIE)
{
set_errno (EBADF);
@@ -76,220 +78,85 @@ dirfd (DIR *dir)
/* opendir: POSIX 5.1.2.1 */
extern "C" DIR *
-opendir (const char *dirname)
+opendir (const char *name)
{
- int len;
- DIR *dir;
- DIR *res = 0;
- struct stat statbuf;
-
- path_conv real_dirname (dirname, PC_SYM_FOLLOW | PC_FULL);
-
- if (real_dirname.error)
- {
- set_errno (real_dirname.error);
- goto failed;
- }
-
- if (stat (real_dirname, &statbuf) == -1)
- goto failed;
-
- if (!(statbuf.st_mode & S_IFDIR))
- {
- set_errno (ENOTDIR);
- goto failed;
- }
-
- len = strlen (real_dirname);
- if (len > MAX_PATH - 3)
- {
- set_errno (ENAMETOOLONG);
- goto failed;
- }
-
- if ((dir = (DIR *) malloc (sizeof (DIR))) == NULL)
- {
- set_errno (ENOMEM);
- goto failed;
- }
- if ((dir->__d_dirname = (char *) malloc (len + 3)) == NULL)
- {
- free (dir);
- set_errno (ENOMEM);
- goto failed;
- }
- if ((dir->__d_dirent =
- (struct dirent *) malloc (sizeof (struct dirent))) == NULL)
+ fhandler_base *fh;
+ path_conv pc;
+ DIR *res;
+
+ fh = cygheap->fdtab.build_fhandler_from_name (-1, name, NULL, pc,
+ PC_SYM_FOLLOW | PC_FULL, NULL);
+ if (!fh)
+ res = NULL;
+ else
{
- free (dir->__d_dirname);
- free (dir);
- set_errno (ENOMEM);
- goto failed;
+ res = fh->opendir (pc);
+ if (!res)
+ delete fh;
}
- strcpy (dir->__d_dirname, real_dirname.get_win32 ());
- dir->__d_dirent->d_version = __DIRENT_VERSION;
- dir->__d_dirent->d_fd = open (dir->__d_dirname, O_RDONLY | O_DIROPEN);
- /* FindFirstFile doesn't seem to like duplicate /'s. */
- len = strlen (dir->__d_dirname);
- if (len == 0 || SLASH_P (dir->__d_dirname[len - 1]))
- strcat (dir->__d_dirname, "*");
- else
- strcat (dir->__d_dirname, "\\*"); /**/
- dir->__d_cookie = __DIRENT_COOKIE;
- dir->__d_u.__d_data.__handle = INVALID_HANDLE_VALUE;
- dir->__d_position = 0;
- dir->__d_dirhash = statbuf.st_ino;
-
- res = dir;
-
-failed:
- syscall_printf ("%p = opendir (%s)", res, dirname);
return res;
}
/* readdir: POSIX 5.1.2.1 */
extern "C" struct dirent *
-readdir (DIR * dir)
+readdir (DIR *dir)
{
- WIN32_FIND_DATA buf;
- HANDLE handle;
- struct dirent *res = NULL;
+ if (check_null_invalid_struct_errno (dir))
+ return NULL;
if (dir->__d_cookie != __DIRENT_COOKIE)
{
set_errno (EBADF);
- syscall_printf ("%p = readdir (%p)", res, dir);
- return res;
- }
-
- if (dir->__d_u.__d_data.__handle == INVALID_HANDLE_VALUE
- && dir->__d_position == 0)
- {
- handle = FindFirstFileA (dir->__d_dirname, &buf);
- DWORD lasterr = GetLastError ();
- dir->__d_u.__d_data.__handle = handle;
- if (handle == INVALID_HANDLE_VALUE && (lasterr != ERROR_NO_MORE_FILES))
- {
- seterrno_from_win_error (__FILE__, __LINE__, lasterr);
- return res;
- }
- }
- else if (dir->__d_u.__d_data.__handle == INVALID_HANDLE_VALUE)
- {
- return res;
- }
- else if (!FindNextFileA (dir->__d_u.__d_data.__handle, &buf))
- {
- DWORD lasterr = GetLastError ();
- (void) FindClose (dir->__d_u.__d_data.__handle);
- dir->__d_u.__d_data.__handle = INVALID_HANDLE_VALUE;
- /* POSIX says you shouldn't set errno when readdir can't
- find any more files; so, if another error we leave it set. */
- if (lasterr != ERROR_NO_MORE_FILES)
- seterrno_from_win_error (__FILE__, __LINE__, lasterr);
- syscall_printf ("%p = readdir (%p)", res, dir);
- return res;
- }
-
- /* We get here if `buf' contains valid data. */
- strcpy (dir->__d_dirent->d_name, buf.cFileName);
-
- /* Check for Windows shortcut. If it's a Cygwin or U/WIN
- symlink, drop the .lnk suffix. */
- if (buf.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
- {
- char *c = dir->__d_dirent->d_name;
- int len = strlen (c);
- if (strcasematch (c + len - 4, ".lnk"))
- {
- char fbuf[MAX_PATH + 1];
- strcpy (fbuf, dir->__d_dirname);
- strcpy (fbuf + strlen (fbuf) - 1, dir->__d_dirent->d_name);
- path_conv fpath (fbuf, PC_SYM_NOFOLLOW);
- if (fpath.issymlink ())
- c[len - 4] = '\0';
- }
+ syscall_printf ("%p = readdir (%p)", NULL, dir);
+ return NULL;
}
- /* Compute d_ino by combining filename hash with the directory hash
- (which was stored in dir->__d_dirhash when opendir was called). */
- if (buf.cFileName[0] == '.')
- {
- if (buf.cFileName[1] == '\0')
- dir->__d_dirent->d_ino = dir->__d_dirhash;
- else if (buf.cFileName[1] != '.' || buf.cFileName[2] != '\0')
- goto hashit;
- else
- {
- char *p, up[strlen (dir->__d_dirname) + 1];
- strcpy (up, dir->__d_dirname);
- if (!(p = strrchr (up, '\\')))
- goto hashit;
- *p = '\0';
- if (!(p = strrchr (up, '\\')))
- dir->__d_dirent->d_ino = hash_path_name (0, ".");
- else
- {
- *p = '\0';
- dir->__d_dirent->d_ino = hash_path_name (0, up);
- }
- }
- }
- else
- {
- hashit:
- ino_t dino = hash_path_name (dir->__d_dirhash, "\\");
- dir->__d_dirent->d_ino = hash_path_name (dino, buf.cFileName);
- }
-
- ++dir->__d_position;
- res = dir->__d_dirent;
- syscall_printf ("%p = readdir (%p) (%s)",
- &dir->__d_dirent, dir, buf.cFileName);
- return res;
+ return ((fhandler_base *) dir->__d_u.__d_data.__fh)->readdir (dir);
}
/* telldir */
extern "C" off_t
-telldir (DIR * dir)
+telldir (DIR *dir)
{
+ if (check_null_invalid_struct_errno (dir))
+ return -1;
+
if (dir->__d_cookie != __DIRENT_COOKIE)
return 0;
- return dir->__d_position;
+ return ((fhandler_base *) dir->__d_u.__d_data.__fh)->telldir (dir);
}
/* seekdir */
extern "C" void
-seekdir (DIR * dir, off_t loc)
+seekdir (DIR *dir, off_t loc)
{
+ if (check_null_invalid_struct_errno (dir))
+ return;
+
if (dir->__d_cookie != __DIRENT_COOKIE)
return;
- rewinddir (dir);
- while (loc > dir->__d_position)
- if (! readdir (dir))
- break;
+ return ((fhandler_base *) dir->__d_u.__d_data.__fh)->seekdir (dir, loc);
}
/* rewinddir: POSIX 5.1.2.1 */
extern "C" void
-rewinddir (DIR * dir)
+rewinddir (DIR *dir)
{
- syscall_printf ("rewinddir (%p)", dir);
+ if (check_null_invalid_struct_errno (dir))
+ return;
if (dir->__d_cookie != __DIRENT_COOKIE)
return;
- if (dir->__d_u.__d_data.__handle != INVALID_HANDLE_VALUE)
- {
- (void) FindClose (dir->__d_u.__d_data.__handle);
- dir->__d_u.__d_data.__handle = INVALID_HANDLE_VALUE;
- }
- dir->__d_position = 0;
+ return ((fhandler_base *) dir->__d_u.__d_data.__fh)->rewinddir (dir);
}
/* closedir: POSIX 5.1.2.1 */
extern "C" int
-closedir (DIR * dir)
+closedir (DIR *dir)
{
+ if (check_null_invalid_struct_errno (dir))
+ return -1;
+
if (dir->__d_cookie != __DIRENT_COOKIE)
{
set_errno (EBADF);
@@ -297,25 +164,18 @@ closedir (DIR * dir)
return -1;
}
- if (dir->__d_u.__d_data.__handle != INVALID_HANDLE_VALUE &&
- FindClose (dir->__d_u.__d_data.__handle) == 0)
- {
- __seterrno ();
- syscall_printf ("-1 = closedir (%p)", dir);
- return -1;
- }
-
- if (dir->__d_dirent->d_fd >= 0)
- close (dir->__d_dirent->d_fd);
-
/* Reset the marker in case the caller tries to use `dir' again. */
dir->__d_cookie = 0;
+ int res = ((fhandler_base *) dir->__d_u.__d_data.__fh)->closedir (dir);
+
+ cygheap->fdtab.release (dir->__d_dirent->d_fd);
+
free (dir->__d_dirname);
free (dir->__d_dirent);
free (dir);
- syscall_printf ("0 = closedir (%p)", dir);
- return 0;
+ syscall_printf ("%d = closedir (%p)", res);
+ return res;
}
/* mkdir: POSIX 5.4.1.1 */
@@ -346,6 +206,11 @@ mkdir (const char *dir, mode_t mode)
if (!allow_ntsec && allow_ntea)
set_file_attribute (real_dir.has_acls (), real_dir.get_win32 (),
S_IFDIR | ((mode & 07777) & ~cygheap->umask));
+#ifdef HIDDEN_DOT_FILES
+ char *c = strrchr (real_dir.get_win32 (), '\\');
+ if ((c && c[1] == '.') || *real_dir.get_win32 () == '.')
+ SetFileAttributes (real_dir.get_win32 (), FILE_ATTRIBUTE_HIDDEN);
+#endif
res = 0;
}
else
@@ -384,7 +249,7 @@ rmdir (const char *dir)
/* Even own directories can't be removed if R/O attribute is set. */
if (real_dir.has_attribute (FILE_ATTRIBUTE_READONLY))
SetFileAttributes (real_dir,
- (DWORD) real_dir & ~FILE_ATTRIBUTE_READONLY);
+ (DWORD) real_dir & ~FILE_ATTRIBUTE_READONLY);
if (RemoveDirectory (real_dir))
{
diff --git a/winsup/cygwin/dlfcn.cc b/winsup/cygwin/dlfcn.cc
index 69716cc8a..b6babe66b 100644
--- a/winsup/cygwin/dlfcn.cc
+++ b/winsup/cygwin/dlfcn.cc
@@ -22,8 +22,8 @@ details. */
#include "dll_init.h"
#include "cygerrno.h"
-#define _dl_error _reent_winsup()->_dl_error
-#define _dl_buffer _reent_winsup()->_dl_buffer
+#define _dl_error _reent_winsup ()->_dl_error
+#define _dl_buffer _reent_winsup ()->_dl_buffer
static void __stdcall
set_dl_error (const char *str)
@@ -38,7 +38,7 @@ set_dl_error (const char *str)
inline const char * __stdcall
check_path_access (const char *mywinenv, const char *name, path_conv& buf)
{
- return find_exec (name, buf, mywinenv, TRUE);
+ return find_exec (name, buf, mywinenv, FE_NNF | FE_NATIVE | FE_CWD);
}
/* Search LD_LIBRARY_PATH for dll, if it exists.
@@ -85,7 +85,7 @@ get_full_path_of_dll (const char* str, char *name)
void *
dlopen (const char *name, int)
{
- SetResourceLock(LOCK_DLL_LIST,READ_LOCK|WRITE_LOCK," dlopen");
+ SetResourceLock (LOCK_DLL_LIST, READ_LOCK | WRITE_LOCK, "dlopen");
void *ret;
@@ -110,7 +110,7 @@ dlopen (const char *name, int)
set_dl_error ("dlopen");
debug_printf ("ret %p", ret);
- ReleaseResourceLock(LOCK_DLL_LIST,READ_LOCK|WRITE_LOCK," dlopen");
+ ReleaseResourceLock (LOCK_DLL_LIST, READ_LOCK | WRITE_LOCK, "dlopen");
return ret;
}
@@ -127,7 +127,7 @@ dlsym (void *handle, const char *name)
int
dlclose (void *handle)
{
- SetResourceLock(LOCK_DLL_LIST,READ_LOCK|WRITE_LOCK," dlclose");
+ SetResourceLock (LOCK_DLL_LIST, READ_LOCK | WRITE_LOCK, "dlclose");
int ret = -1;
void *temphandle = (void *) GetModuleHandle (NULL);
@@ -137,7 +137,7 @@ dlclose (void *handle)
set_dl_error ("dlclose");
CloseHandle ((HMODULE) temphandle);
- ReleaseResourceLock(LOCK_DLL_LIST,READ_LOCK|WRITE_LOCK," dlclose");
+ ReleaseResourceLock (LOCK_DLL_LIST, READ_LOCK | WRITE_LOCK, "dlclose");
return ret;
}
diff --git a/winsup/cygwin/dll_init.cc b/winsup/cygwin/dll_init.cc
index d4dcca0e9..e5e650fa9 100644
--- a/winsup/cygwin/dll_init.cc
+++ b/winsup/cygwin/dll_init.cc
@@ -8,6 +8,7 @@ details. */
#include "winsup.h"
#include <stdlib.h>
+#include <errno.h>
#include "exceptions.h"
#include "cygerrno.h"
#include "perprocess.h"
@@ -97,7 +98,7 @@ dll_list::operator[] (const char *name)
return NULL;
}
-#define RETRIES 100
+#define RETRIES 1000
/* Allocate space for a dll struct contiguous with the just-loaded dll. */
dll *
diff --git a/winsup/cygwin/dll_init.h b/winsup/cygwin/dll_init.h
index a5b33d572..bc9687bf7 100644
--- a/winsup/cygwin/dll_init.h
+++ b/winsup/cygwin/dll_init.h
@@ -73,12 +73,6 @@ public:
void detach (dll *);
void init ();
void load_after_fork (HANDLE, dll *);
- dll *istart (dll_type t)
- {
- hold_type = t;
- hold = &start;
- return inext ();
- }
dll *inext ()
{
while ((hold = hold->next))
@@ -86,6 +80,12 @@ public:
break;
return hold;
}
+ dll *istart (dll_type t)
+ {
+ hold_type = t;
+ hold = &start;
+ return inext ();
+ }
};
extern dll_list dlls;
diff --git a/winsup/cygwin/dlmalloc.c b/winsup/cygwin/dlmalloc.c
index 3435950b4..c0802989c 100644
--- a/winsup/cygwin/dlmalloc.c
+++ b/winsup/cygwin/dlmalloc.c
@@ -28,6 +28,32 @@
* malloc_usable_size(P) is equivalent to realloc(P, malloc_usable_size(P))
*
* $Log$
+ * Revision 1.4.4.1 2002/01/04 03:56:06 rbcollins
+ * Merged changes from HEAD
+ *
+ * Revision 1.5 2001/10/03 03:49:25 cgf
+ * * cygheap.cc (cfree): Remove malloc debugging probe.
+ * * dlmalloc.c (errprint): Remove abort() call which causes interesting error
+ * message printing to abort prematurely.
+ * * environ.cc: Sprinkle MALLOC_CHECKs liberally throughout.
+ * (_addenv): Allocate two empty elements at end of environ to
+ * (apparently) work around problems with some buggy applications.
+ * (winenv): Avoid calling alloca if no forced environment variable is present.
+ *
+ * * exceptions.cc (open_stackdumpfile): Don't print "Dumping stack trace to..."
+ * when running in a cygwin environment (i.e., the parent is a cygwin process).
+ *
+ * * dtable.cc (dtable::init_std_file_from_handle): Move device type detection
+ * code from build_fhandler here since it is only used by this function.
+ * (dtable::build_fhandler_from_name): New method. Renamed from
+ * dtable::build_fhandler.
+ * (dtable::build_fhandler): Use build_fhandler_from_name.
+ * (cygwin_attach_handle_to_fd): Ditto.
+ * * syscalls.cc (_open): Ditto.
+ * (stat_worker): Ditto.
+ * * dtable.h (dtable::build_fhandler_from_name): Rename declaration from
+ * dtable::build_fhandler.
+ *
* Revision 1.4 2001/09/07 21:32:04 cgf
* * cygheap.h (init_cygheap): Move heap pointers here.
* * include/sys/cygwin.h (perprocess): Remove heap pointers.
@@ -1843,7 +1869,6 @@ static void errprint(const char *file, int line, const char *err)
write(2, err, strlen(err));
write(2, "\n", 1);
recurs--;
- abort ();
}
static void malloc_err(const char *err, mchunkptr p)
diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc
index 96ee5a503..a6f5b075c 100644
--- a/winsup/cygwin/dtable.cc
+++ b/winsup/cygwin/dtable.cc
@@ -18,6 +18,7 @@ details. */
#include <unistd.h>
#include <fcntl.h>
#include <sys/cygwin.h>
+#include <assert.h>
#define USE_SYS_TYPES_FD_SET
#include <winsock.h>
@@ -55,7 +56,8 @@ set_std_handle (int fd)
void
dtable::dec_console_fds ()
{
- if (console_fds > 0 && !--console_fds && myself->ctty != TTY_CONSOLE)
+ if (console_fds > 0 && !--console_fds &&
+ myself->ctty != TTY_CONSOLE && !check_pty_fds())
FreeConsole ();
}
@@ -168,22 +170,42 @@ dtable::release (int fd)
}
}
+extern "C"
+int
+cygwin_attach_handle_to_fd (char *name, int fd, HANDLE handle, mode_t bin,
+ DWORD myaccess)
+{
+ if (fd == -1)
+ fd = cygheap->fdtab.find_unused_handle ();
+ path_conv pc;
+ fhandler_base *res = cygheap->fdtab.build_fhandler_from_name (fd, name, handle,
+ pc);
+ res->init (handle, myaccess, bin);
+ return fd;
+}
+
void
-dtable::init_std_file_from_handle (int fd, HANDLE handle,
- DWORD myaccess)
+dtable::init_std_file_from_handle (int fd, HANDLE handle, DWORD myaccess)
{
int bin;
- const char *name = NULL;
+ const char *name;
+ CONSOLE_SCREEN_BUFFER_INFO buf;
+ struct sockaddr sa;
+ int sal = sizeof (sa);
+ DCB dcb;
+
+ first_fd_for_open = 0;
+
+ if (!handle || handle == INVALID_HANDLE_VALUE)
+ return;
if (__fmode)
bin = __fmode;
else
bin = binmode ?: 0;
- first_fd_for_open = 0;
/* See if we can consoleify it - if it is a console,
don't open it in binary. That will screw up our crlfs*/
- CONSOLE_SCREEN_BUFFER_INFO buf;
if (GetConsoleScreenBufferInfo (handle, &buf))
{
if (ISSTATE (myself, PID_USETTY))
@@ -192,7 +214,7 @@ dtable::init_std_file_from_handle (int fd, HANDLE handle,
name = "/dev/conout";
bin = 0;
}
- else if (FlushConsoleInputBuffer (handle))
+ else if (GetNumberOfConsoleInputEvents (handle, (DWORD *) &buf))
{
if (ISSTATE (myself, PID_USETTY))
name = "/dev/tty";
@@ -204,57 +226,29 @@ dtable::init_std_file_from_handle (int fd, HANDLE handle,
{
if (fd == 0)
name = "/dev/piper";
- else if (fd == 1 || fd == 2)
+ else
name = "/dev/pipew";
if (bin == 0)
bin = O_BINARY;
}
+ else if (wsock_started && getpeername ((SOCKET) handle, &sa, &sal) == 0)
+ name = "/dev/socket";
+ else if (GetCommState (handle, &dcb))
+ name = "/dev/ttyS0"; // FIXME - determine correct device
+ else
+ name = "unknown disk file";
path_conv pc;
- build_fhandler (fd, name, handle, pc)->init (handle, myaccess, bin);
+ build_fhandler_from_name (fd, name, handle, pc)->init (handle, myaccess, bin);
set_std_handle (fd);
paranoid_printf ("fd %d, handle %p", fd, handle);
}
-extern "C"
-int
-cygwin_attach_handle_to_fd (char *name, int fd, HANDLE handle, mode_t bin,
- DWORD myaccess)
-{
- if (fd == -1)
- fd = cygheap->fdtab.find_unused_handle ();
- path_conv pc;
- fhandler_base *res = cygheap->fdtab.build_fhandler (fd, name, handle, pc);
- res->init (handle, myaccess, bin);
- return fd;
-}
-
fhandler_base *
-dtable::build_fhandler (int fd, const char *name, HANDLE handle, path_conv& pc,
- unsigned opt, suffix_info *si)
+dtable::build_fhandler_from_name (int fd, const char *name, HANDLE handle,
+ path_conv& pc, unsigned opt, suffix_info *si)
{
- if (!name && handle)
- {
- struct sockaddr sa;
- int sal = sizeof (sa);
- CONSOLE_SCREEN_BUFFER_INFO cinfo;
- DCB dcb;
-
- if (GetNumberOfConsoleInputEvents (handle, (DWORD *) &cinfo))
- name = "/dev/conin";
- else if (GetConsoleScreenBufferInfo (handle, &cinfo))
- name = "/dev/conout";
- else if (wsock_started && getpeername ((SOCKET) handle, &sa, &sal) == 0)
- name = "/dev/socket";
- else if (GetFileType (handle) == FILE_TYPE_PIPE)
- name = "/dev/pipe";
- else if (GetCommState (handle, &dcb))
- name = "/dev/ttyS0"; // FIXME - determine correct device
- else
- name = "some disk file";
- }
-
- pc.check (name, opt | PC_NULLEMPTY, si);
+ pc.check (name, opt | PC_NULLEMPTY | PC_FULL, si);
if (pc.error)
{
set_errno (pc.error);
@@ -266,84 +260,84 @@ dtable::build_fhandler (int fd, const char *name, HANDLE handle, path_conv& pc,
return fh;
}
+#define cnew(name) new ((void *) ccalloc (HEAP_FHANDLER, 1, sizeof (name))) name
fhandler_base *
dtable::build_fhandler (int fd, DWORD dev, const char *name, int unit)
{
fhandler_base *fh;
- void *buf = ccalloc (HEAP_FHANDLER, 1, sizeof (fhandler_union) + 100);
dev &= FH_DEVMASK;
switch (dev)
{
case FH_TTYM:
- fh = new (buf) fhandler_tty_master (name, unit);
+ fh = cnew (fhandler_tty_master) (unit);
break;
case FH_CONSOLE:
case FH_CONIN:
case FH_CONOUT:
- fh = new (buf) fhandler_console (name);
- inc_console_fds ();
+ if ((fh = cnew (fhandler_console) ()))
+ inc_console_fds ();
break;
case FH_PTYM:
- fh = new (buf) fhandler_pty_master (name);
+ fh = cnew (fhandler_pty_master) ();
break;
case FH_TTYS:
if (unit < 0)
- fh = new (buf) fhandler_tty_slave (name);
+ fh = cnew (fhandler_tty_slave) ();
else
- fh = new (buf) fhandler_tty_slave (unit, name);
+ fh = cnew (fhandler_tty_slave) (unit);
break;
case FH_WINDOWS:
- fh = new (buf) fhandler_windows (name);
+ fh = cnew (fhandler_windows) ();
break;
case FH_SERIAL:
- fh = new (buf) fhandler_serial (name, dev, unit);
+ fh = cnew (fhandler_serial) (unit);
break;
case FH_PIPE:
case FH_PIPER:
case FH_PIPEW:
- fh = new (buf) fhandler_pipe (name, dev);
+ fh = cnew (fhandler_pipe) (dev);
break;
case FH_SOCKET:
- fh = new (buf) fhandler_socket (name);
+ if ((fh = cnew (fhandler_socket) ()))
+ inc_need_fixup_before ();
break;
case FH_DISK:
- fh = new (buf) fhandler_disk_file (NULL);
+ fh = cnew (fhandler_disk_file) ();
+ break;
+ case FH_CYGDRIVE:
+ fh = cnew (fhandler_cygdrive) (unit);
break;
case FH_FLOPPY:
- fh = new (buf) fhandler_dev_floppy (name, unit);
+ fh = cnew (fhandler_dev_floppy) (unit);
break;
case FH_TAPE:
- fh = new (buf) fhandler_dev_tape (name, unit);
+ fh = cnew (fhandler_dev_tape) (unit);
break;
case FH_NULL:
- fh = new (buf) fhandler_dev_null (name);
+ fh = cnew (fhandler_dev_null) ();
break;
case FH_ZERO:
- fh = new (buf) fhandler_dev_zero (name);
+ fh = cnew (fhandler_dev_zero) ();
break;
case FH_RANDOM:
- fh = new (buf) fhandler_dev_random (name, unit);
+ fh = cnew (fhandler_dev_random) (unit);
break;
case FH_MEM:
- fh = new (buf) fhandler_dev_mem (name, unit);
+ fh = cnew (fhandler_dev_mem) (unit);
break;
case FH_CLIPBOARD:
- fh = new (buf) fhandler_dev_clipboard (name);
+ fh = cnew (fhandler_dev_clipboard) ();
break;
case FH_OSS_DSP:
- fh = new (buf) fhandler_dev_dsp (name);
+ fh = cnew (fhandler_dev_dsp) ();
break;
default:
- {
- /* FIXME - this could recurse forever */
- path_conv pc;
- return build_fhandler (fd, name, NULL, pc);
- }
+ system_printf ("internal error -- unknown device - %p", dev);
+ fh = NULL;
}
- debug_printf ("%s - cb %d, fd %d, fh %p", fh->get_name () ?: "", fh->cb,
- fd, fh);
+ debug_printf ("fd %d, fh %p", fd, fh);
return fd >= 0 ? (fds[fd] = fh) : fh;
}
@@ -394,6 +388,7 @@ dtable::dup2 (int oldfd, int newfd)
goto done;
}
+ debug_printf ("newfh->io_handle %p, oldfh->io_handle %p", newfh->get_io_handle (), fds[oldfd]->get_io_handle ());
SetResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "dup");
if (newfd < 0)
@@ -403,21 +398,17 @@ dtable::dup2 (int oldfd, int newfd)
goto done;
}
- if ((size_t) newfd >= cygheap->fdtab.size)
+ if ((size_t) newfd >= size)
{
int inc_size = NOFILE_INCR * ((newfd + NOFILE_INCR - 1) / NOFILE_INCR) -
- cygheap->fdtab.size;
- cygheap->fdtab.extend (inc_size);
+ size;
+ extend (inc_size);
}
if (!not_open (newfd))
_close (newfd);
fds[newfd] = newfh;
- /* Count sockets. */
- if ((fds[newfd]->get_device () & FH_DEVMASK) == FH_SOCKET)
- inc_need_fixup_before ();
-
ReleaseResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "dup");
MALLOC_CHECK;
@@ -569,6 +560,10 @@ dtable::vfork_child_dup ()
newtable = (fhandler_base **) ccalloc (HEAP_ARGV, size, sizeof (fds[0]));
int res = 1;
+ /* Remove impersonation */
+ if (cygheap->user.impersonated && cygheap->user.token != INVALID_HANDLE_VALUE)
+ RevertToSelf ();
+
for (size_t i = 0; i < size; i++)
if (not_open (i))
continue;
@@ -581,6 +576,10 @@ dtable::vfork_child_dup ()
goto out;
}
+ /* Restore impersonation */
+ if (cygheap->user.impersonated && cygheap->user.token != INVALID_HANDLE_VALUE)
+ ImpersonateLoggedOnUser (cygheap->user.token);
+
fds_on_hold = fds;
fds = newtable;
@@ -596,6 +595,7 @@ dtable::vfork_parent_restore ()
close_all_files ();
fhandler_base **deleteme = fds;
+ assert (fds_on_hold != NULL);
fds = fds_on_hold;
fds_on_hold = NULL;
cfree (deleteme);
diff --git a/winsup/cygwin/dtable.h b/winsup/cygwin/dtable.h
index 0a00d91f5..ebf8ab2a9 100644
--- a/winsup/cygwin/dtable.h
+++ b/winsup/cygwin/dtable.h
@@ -50,9 +50,10 @@ public:
void fixup_after_fork (HANDLE);
fhandler_base *build_fhandler (int fd, DWORD dev, const char *name,
int unit = -1);
- fhandler_base *build_fhandler (int fd, const char *name, HANDLE h,
- path_conv& pc, unsigned opts = PC_SYM_FOLLOW,
- suffix_info *si = NULL);
+ fhandler_base *build_fhandler_from_name (int fd, const char *name, HANDLE h,
+ path_conv& pc,
+ unsigned opts = PC_SYM_FOLLOW,
+ suffix_info *si = NULL);
inline int not_open (int fd)
{
SetResourceLock (LOCK_FD_LIST, READ_LOCK, "not_open");
diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc
index d88ab35e5..3857c4496 100644
--- a/winsup/cygwin/environ.cc
+++ b/winsup/cygwin/environ.cc
@@ -37,7 +37,7 @@ extern BOOL allow_winsymlinks;
extern BOOL strip_title_path;
extern int pcheck_case;
extern int subauth_id;
-BOOL reset_com = TRUE;
+BOOL reset_com = FALSE;
static BOOL envcache = TRUE;
static char **lastenviron;
@@ -77,6 +77,7 @@ static unsigned char conv_start_chars[256] = {0};
void
win_env::add_cache (const char *in_posix, const char *in_native)
{
+ MALLOC_CHECK;
posix = (char *) realloc (posix, strlen (in_posix) + 1);
strcpy (posix, in_posix);
if (in_native)
@@ -91,6 +92,7 @@ win_env::add_cache (const char *in_posix, const char *in_native)
(void) strcpy (native, name);
towin32 (in_posix, native + namelen);
}
+ MALLOC_CHECK;
debug_printf ("posix %s", posix);
debug_printf ("native %s", native);
}
@@ -146,6 +148,7 @@ posify (char **here, const char *value)
debug_printf ("env var converted to %s", outenv);
*here = outenv;
free (src);
+ MALLOC_CHECK;
}
/*
@@ -178,6 +181,7 @@ my_findenv (const char *name, int *offset)
*offset = p - cur_environ ();
return (char *) (++c);
}
+ MALLOC_CHECK;
return NULL;
}
@@ -232,12 +236,12 @@ _addenv (const char *name, const char *value, int overwrite)
else
{ /* Create new slot. */
int sz = envsize (cur_environ ());
- int allocsz = sz + sizeof (char *);
+ int allocsz = sz + (2 * sizeof (char *));
offset = (sz - 1) / sizeof (char *);
/* Allocate space for additional element plus terminating NULL. */
- if (__cygwin_environ == lastenviron)
+ if (cur_environ () == lastenviron)
lastenviron = __cygwin_environ = (char **) realloc (cur_environ (),
allocsz);
else if ((lastenviron = (char **) malloc (allocsz)) != NULL)
@@ -249,7 +253,7 @@ _addenv (const char *name, const char *value, int overwrite)
#ifdef DEBUGGING
try_to_debug ();
#endif
- return -1; /* Oops. No more memory. */
+ return -1; /* Oops. No more memory. */
}
__cygwin_environ[offset + 1] = NULL; /* NULL terminate. */
@@ -283,6 +287,7 @@ _addenv (const char *name, const char *value, int overwrite)
if ((spenv = getwinenv (envhere)))
spenv->add_cache (value);
+ MALLOC_CHECK;
return 0;
}
@@ -614,13 +619,11 @@ parse_options (char *buf)
static void __stdcall
regopt (const char *name)
{
- MALLOC_CHECK;
/* FIXME: should not be under mount */
reg_key r (KEY_READ, CYGWIN_INFO_PROGRAM_OPTIONS_NAME, NULL);
char buf[MAX_PATH];
char lname[strlen(name) + 1];
strlwr (strcpy (lname, name));
- MALLOC_CHECK;
if (r.get_string (lname, buf, sizeof (buf) - 1, "") == ERROR_SUCCESS)
parse_options (buf);
else
@@ -812,18 +815,21 @@ winenv (const char * const *envp, int keep_posix)
for (int i = 0; forced_winenv_vars[i]; i++)
if (!saw_forced_winenv[i])
{
- int namelen = strlen (forced_winenv_vars[i]) + 1;
- int vallen = GetEnvironmentVariable (forced_winenv_vars[i], dum, 0) + 1;
- p = (char *) alloca (namelen + vallen);
- strcpy (p, forced_winenv_vars[i]);
- strcat (p, "=");
- if (!GetEnvironmentVariable (forced_winenv_vars[i], p + namelen,
- vallen + 1))
- debug_printf ("warning: %s not present in environment", *srcp);
- else
+ int vallen = GetEnvironmentVariable (forced_winenv_vars[i], dum, 0);
+ if (vallen > 0)
{
- *dstp++ = p;
- tl += strlen (p) + 1;
+ int namelen = strlen (forced_winenv_vars[i]) + 1;
+ p = (char *) alloca (namelen + ++vallen);
+ strcpy (p, forced_winenv_vars[i]);
+ strcat (p, "=");
+ if (!GetEnvironmentVariable (forced_winenv_vars[i], p + namelen,
+ vallen))
+ debug_printf ("warning: %s not present in environment", *srcp);
+ else
+ {
+ *dstp++ = p;
+ tl += strlen (p) + 1;
+ }
}
}
diff --git a/winsup/cygwin/environ.h b/winsup/cygwin/environ.h
index 888b473dd..86f70f675 100644
--- a/winsup/cygwin/environ.h
+++ b/winsup/cygwin/environ.h
@@ -28,7 +28,8 @@ struct win_env
int (*posix_len) (const char *);
int (*win32_len) (const char *);
void add_cache (const char *in_posix, const char *in_native = NULL);
- const char * get_native () {return native ? native + namelen : NULL;}
+ const char * get_native () const {return native ? native + namelen : NULL;}
+ const char * get_posix () const {return posix ? posix : NULL;}
};
win_env * __stdcall getwinenv (const char *name, const char *posix = NULL);
diff --git a/winsup/cygwin/errno.cc b/winsup/cygwin/errno.cc
index 540951c56..0643647b2 100644
--- a/winsup/cygwin/errno.cc
+++ b/winsup/cygwin/errno.cc
@@ -8,12 +8,16 @@ This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
+#define _sys_nerr FOO_sys_nerr
+#define sys_nerr FOOsys_nerr
#include "winsup.h"
#define _REENT_ONLY
#include <stdio.h>
#include <errno.h>
#include "cygerrno.h"
#include "thread.h"
+#undef _sys_nerr
+#undef sys_nerr
/* Table to map Windows error codes to Errno values. */
/* FIXME: Doing things this way is a little slow. It's trivial to change
@@ -145,7 +149,8 @@ seterrno (const char *file, int line)
extern char *_user_strerror _PARAMS ((int));
-extern const NO_COPY char __declspec(dllexport) * const _sys_errlist[]=
+extern "C" {
+const NO_COPY char __declspec(dllexport) * const _sys_errlist[]=
{
/* NOERROR 0 */ "No error",
/* EPERM 1 */ "Not super-user",
@@ -287,8 +292,8 @@ extern const NO_COPY char __declspec(dllexport) * const _sys_errlist[]=
/* ECASECLASH 137 */ "Filename exists with different case"
};
-int NO_COPY __declspec(dllexport) _sys_nerr =
- sizeof (_sys_errlist) / sizeof (_sys_errlist[0]);
+extern int const NO_COPY __declspec(dllexport) _sys_nerr = sizeof (_sys_errlist) / sizeof (_sys_errlist[0]);
+};
/* FIXME: Why is strerror() a long switch and not just:
return sys_errlist[errnum];
diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc
index 0102371a7..a9481167b 100644
--- a/winsup/cygwin/exceptions.cc
+++ b/winsup/cygwin/exceptions.cc
@@ -11,6 +11,7 @@ details. */
#include "winsup.h"
#include <imagehlp.h>
#include <errno.h>
+#include <stdlib.h>
#include "exceptions.h"
#include "sync.h"
@@ -49,11 +50,11 @@ static NO_COPY muto *mask_sync = NULL;
HMODULE NO_COPY cygwin_hmodule;
-static const struct
+NO_COPY static struct
{
unsigned int code;
const char *name;
-} status_info[] NO_COPY =
+} status_info[] =
{
#define X(s) s, #s
{ X (STATUS_ABANDONED_WAIT_0) },
@@ -170,7 +171,10 @@ open_stackdumpfile ()
CREATE_ALWAYS, 0, 0);
if (h != INVALID_HANDLE_VALUE)
{
- system_printf ("Dumping stack trace to %s", corefile);
+ if (!myself->ppid_handle)
+ system_printf ("Dumping stack trace to %s", corefile);
+ else
+ debug_printf ("Dumping stack trace to %s", corefile);
SetStdHandle (STD_ERROR_HANDLE, h);
}
}
@@ -379,19 +383,19 @@ try_to_debug (bool waitloop)
&si,
&pi);
- static int NO_COPY keep_looping = 0;
-
- if (dbg)
+ if (!dbg)
+ system_printf ("Failed to start debugger: %E");
+ else
{
if (!waitloop)
return 1;
SetThreadPriority (hMainThread, THREAD_PRIORITY_IDLE);
- while (keep_looping)
+ while (!IsDebuggerPresent ())
/* spin */;
+ Sleep (4000);
+ small_printf ("*** continuing from debugger call\n");
}
-
- system_printf ("Failed to start debugger: %E");
/* FIXME: need to know handles of all running threads to
resume_all_threads_except (current_thread_id);
*/
@@ -1065,6 +1069,7 @@ signal_exit (int rc)
causes random, inexplicable hangs. So, instead, we set up the priority
of this thread really high so that it should do its thing and then exit. */
(void) SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_TIME_CRITICAL);
+ (void) SetThreadPriority (hMainThread, THREAD_PRIORITY_IDLE);
/* Unlock any main thread mutos since we're executing with prejudice. */
muto *m;
diff --git a/winsup/cygwin/exec.cc b/winsup/cygwin/exec.cc
index 228aa69b0..21b18cfcf 100644
--- a/winsup/cygwin/exec.cc
+++ b/winsup/cygwin/exec.cc
@@ -25,8 +25,7 @@ details. */
/* This is called _execve and not execve because the real execve is defined
in libc/posix/execve.c. It calls us. */
-extern "C"
-int
+extern "C" int
_execve (const char *path, char *const argv[], char *const envp[])
{
static char *const empty_env[] = { 0 };
@@ -36,8 +35,7 @@ _execve (const char *path, char *const argv[], char *const envp[])
return _spawnve (NULL, _P_OVERLAY, path, argv, envp);
}
-extern "C"
-int
+extern "C" int
execl (const char *path, const char *arg0, ...)
{
int i;
@@ -55,8 +53,7 @@ execl (const char *path, const char *arg0, ...)
return _execve (path, (char * const *) argv, cur_environ ());
}
-extern "C"
-int
+extern "C" int
execv (const char *path, char * const *argv)
{
MALLOC_CHECK;
@@ -65,8 +62,7 @@ execv (const char *path, char * const *argv)
/* the same as a standard exec() calls family, but with NT security support */
-extern "C"
-pid_t
+extern "C" pid_t
sexecve (HANDLE hToken, const char *path, const char *const argv[],
const char *const envp[])
{
@@ -74,8 +70,7 @@ sexecve (HANDLE hToken, const char *path, const char *const argv[],
return -1;
}
-extern "C"
-int
+extern "C" int
sexecl (HANDLE hToken, const char *path, const char *arg0, ...)
{
int i;
@@ -96,8 +91,7 @@ sexecl (HANDLE hToken, const char *path, const char *arg0, ...)
return sexecve (hToken, path, (char * const *) argv, cur_environ ());
}
-extern "C"
-int
+extern "C" int
sexecle (HANDLE hToken, const char *path, const char *arg0, ...)
{
int i;
@@ -120,8 +114,7 @@ sexecle (HANDLE hToken, const char *path, const char *arg0, ...)
return sexecve(hToken, path, (char * const *) argv, (char * const *) envp);
}
-extern "C"
-int
+extern "C" int
sexeclp (HANDLE hToken, const char *path, const char *arg0, ...)
{
int i;
@@ -142,8 +135,7 @@ sexeclp (HANDLE hToken, const char *path, const char *arg0, ...)
return sexecvpe (hToken, path, (const char * const *) argv, cur_environ ());
}
-extern "C"
-int
+extern "C" int
sexeclpe (HANDLE hToken, const char *path, const char *arg0, ...)
{
int i;
@@ -166,16 +158,14 @@ sexeclpe (HANDLE hToken, const char *path, const char *arg0, ...)
return sexecvpe (hToken, path, argv, envp);
}
-extern "C"
-int
+extern "C" int
sexecv (HANDLE hToken, const char *path, const char * const *argv)
{
MALLOC_CHECK;
return sexecve (hToken, path, argv, cur_environ ());
}
-extern "C"
-int
+extern "C" int
sexecp (HANDLE hToken, const char *path, const char * const *argv)
{
MALLOC_CHECK;
@@ -199,8 +189,7 @@ strccpy (char *s1, const char **s2, char c)
return s1;
}
-extern "C"
-int
+extern "C" int
sexecvpe (HANDLE hToken, const char *file, const char * const *argv,
const char *const *envp)
{
@@ -208,3 +197,17 @@ sexecvpe (HANDLE hToken, const char *file, const char * const *argv,
MALLOC_CHECK;
return sexecve (hToken, find_exec (file, buf), argv, envp);
}
+
+extern "C" int
+execvp (const char *path, char * const *argv)
+{
+ path_conv buf;
+ return execv (find_exec (path, buf), argv);
+}
+
+extern "C" int
+execvpe (const char *path, char * const *argv, char *const *envp)
+{
+ path_conv buf;
+ return execve (find_exec (path, buf), argv, envp);
+}
diff --git a/winsup/cygwin/external.cc b/winsup/cygwin/external.cc
index 099993e5c..1589e92a1 100644
--- a/winsup/cygwin/external.cc
+++ b/winsup/cygwin/external.cc
@@ -11,6 +11,7 @@ Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
#include "winsup.h"
+#include <errno.h>
#include "security.h"
#include "fhandler.h"
#include "sync.h"
@@ -20,6 +21,11 @@ details. */
#include "shared_info.h"
#include "cygwin_version.h"
#include "perprocess.h"
+#include "cygerrno.h"
+#include "fhandler.h"
+#include "path.h"
+#include "dtable.h"
+#include "cygheap.h"
static external_pinfo *
fillout_pinfo (pid_t pid, int winpid)
@@ -32,10 +38,13 @@ fillout_pinfo (pid_t pid, int winpid)
static winpids pids (0);
+ static unsigned int i;
if (!pids.npids || !nextpid)
- pids.init (winpid);
+ {
+ pids.init (winpid);
+ i = 0;
+ }
- static unsigned int i;
if (!pid)
i = 0;
@@ -172,6 +181,19 @@ cygwin_internal (cygwin_getinfo_types t, ...)
return get_cygdrive_info (user, system, user_flags, system_flags);
}
+ case CW_SET_CYGWIN_REGISTRY_NAME:
+ {
+# define cr ((char *) arg)
+ if (check_null_empty_str_errno (cr))
+ return (DWORD) NULL;
+ cygheap->cygwin_regname = (char *) crealloc (cygheap->cygwin_regname,
+ strlen (cr) + 1);
+ strcpy (cygheap->cygwin_regname, cr);
+ case CW_GET_CYGWIN_REGISTRY_NAME:
+ return (DWORD) cygheap->cygwin_regname;
+# undef cr
+ }
+
default:
return (DWORD) -1;
}
diff --git a/winsup/cygwin/fcntl.cc b/winsup/cygwin/fcntl.cc
index b531218f6..95b622c04 100644
--- a/winsup/cygwin/fcntl.cc
+++ b/winsup/cygwin/fcntl.cc
@@ -17,8 +17,8 @@ details. */
#include "fhandler.h"
#include "path.h"
#include "dtable.h"
-#include "cygheap.h"
#include "cygerrno.h"
+#include "cygheap.h"
#include "thread.h"
extern "C"
@@ -29,22 +29,20 @@ _fcntl (int fd, int cmd,...)
va_list args;
int res;
- if (cygheap->fdtab.not_open (fd))
+ cygheap_fdget cfd (fd, true);
+ if (cfd < 0)
{
- set_errno (EBADF);
res = -1;
goto done;
}
- SetResourceLock(LOCK_FD_LIST,WRITE_LOCK|READ_LOCK, "_fcntl");
va_start (args, cmd);
arg = va_arg (args, void *);
- if (cmd == F_DUPFD)
- res = dup2 (fd, cygheap->fdtab.find_unused_handle ((int) arg));
+ if (cmd != F_DUPFD)
+ res = cfd->fcntl(cmd, arg);
else
- res = cygheap->fdtab[fd]->fcntl(cmd, arg);
+ res = dup2 (fd, cygheap_fdnew (((int) arg) - 1));
va_end (args);
- ReleaseResourceLock(LOCK_FD_LIST,WRITE_LOCK|READ_LOCK,"_fcntl");
done:
syscall_printf ("%d = fcntl (%d, %d, %p)", res, fd, cmd, arg);
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index 54adc8dc2..21f4fb39c 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -24,6 +24,8 @@ details. */
#include "dtable.h"
#include "cygheap.h"
#include "shared_info.h"
+#include "sigproc.h"
+#include "pinfo.h"
#include <assert.h>
static NO_COPY const int CHUNK_SIZE = 1024; /* Used for crlf conversions */
@@ -187,6 +189,7 @@ fhandler_base::set_name (const char *unix_path, const char *win32_path, int unit
system_printf ("fatal error. strdup failed");
exit (ENOMEM);
}
+ namehash = hash_path_name (0, win32_path_name);
}
void
@@ -305,16 +308,9 @@ fhandler_base::get_default_fmode (int flags)
return __fmode;
}
+/* Open system call handler function. */
int
-fhandler_base::open (path_conv& real_path, int flags, mode_t mode)
-{
- return open ((char *) real_path, flags, mode);
-}
-
-/* Open system call handler function.
- Path is now already checked for symlinks */
-int
-fhandler_base::open (int flags, mode_t mode)
+fhandler_base::open (path_conv *, int flags, mode_t mode)
{
int res = 0;
HANDLE x;
@@ -375,6 +371,15 @@ fhandler_base::open (int flags, mode_t mode)
if (get_device () == FH_SERIAL)
file_attributes |= FILE_FLAG_OVERLAPPED;
+#ifdef HIDDEN_DOT_FILES
+ if (flags & O_CREAT && get_device () == FH_DISK)
+ {
+ char *c = strrchr (get_win32_name (), '\\');
+ if ((c && c[1] == '.') || *get_win32_name () == '.')
+ file_attributes |= FILE_ATTRIBUTE_HIDDEN;
+ }
+#endif
+
/* CreateFile() with dwDesiredAccess == 0 when called on remote
share returns some handle, even if file doesn't exist. This code
works around this bug. */
@@ -392,15 +397,12 @@ fhandler_base::open (int flags, mode_t mode)
if (flags & O_CREAT && get_device () == FH_DISK && allow_ntsec && has_acls ())
set_security_attribute (mode, &sa, alloca (4096), 4096);
- x = CreateFileA (get_win32_name (), access, shared,
- &sa, creation_distribution,
- file_attributes,
- 0);
+ x = CreateFile (get_win32_name (), access, shared, &sa, creation_distribution,
+ file_attributes, 0);
syscall_printf ("%p = CreateFileA (%s, %p, %p, %p, %p, %p, 0)",
- x, get_win32_name (), access, shared,
- &sa, creation_distribution,
- file_attributes);
+ x, get_win32_name (), access, shared, &sa,
+ creation_distribution, file_attributes);
if (x == INVALID_HANDLE_VALUE)
{
@@ -419,7 +421,6 @@ fhandler_base::open (int flags, mode_t mode)
&& !allow_ntsec && allow_ntea)
set_file_attribute (has_acls (), get_win32_name (), mode);
- namehash = hash_path_name (0, get_win32_name ());
set_io_handle (x);
int bin;
int fmode;
@@ -487,6 +488,9 @@ fhandler_base::read (void *in_ptr, size_t in_len)
len--;
}
+ if (copied_chars && is_slow ())
+ return copied_chars;
+
if (len)
{
int readlen = raw_read (ptr + copied_chars, len);
@@ -792,7 +796,7 @@ fhandler_base::close ()
{
int res = -1;
- syscall_printf ("handle %p", get_handle());
+ syscall_printf ("closing '%s' handle %p", get_name (), get_handle());
if (CloseHandle (get_handle()))
res = 0;
else
@@ -857,172 +861,28 @@ rootdir(char *full_path)
return root;
}
-int
-fhandler_disk_file::fstat (struct stat *buf)
+int __stdcall
+fhandler_base::fstat (struct stat *buf, path_conv *)
{
- int res = 0; // avoid a compiler warning
- BY_HANDLE_FILE_INFORMATION local;
- save_errno saved_errno;
-
- memset (buf, 0, sizeof (*buf));
-
- /* NT 3.51 seems to have a bug when attempting to get vol serial
- numbers. This loop gets around this. */
- for (int i = 0; i < 2; i++)
- {
- if (!(res = GetFileInformationByHandle (get_handle (), &local)))
- break;
- if (local.dwVolumeSerialNumber && (long) local.dwVolumeSerialNumber != -1)
- break;
- }
- debug_printf ("%d = GetFileInformationByHandle (%s, %d)",
- res, get_win32_name (), get_handle ());
- if (res == 0)
- {
- /* GetFileInformationByHandle will fail if it's given stdin/out/err
- or a pipe*/
- DWORD lsize, hsize;
-
- if (GetFileType (get_handle ()) != FILE_TYPE_DISK)
- buf->st_mode = S_IFCHR;
-
- lsize = GetFileSize (get_handle (), &hsize);
- if (lsize == 0xffffffff && GetLastError () != NO_ERROR)
- buf->st_mode = S_IFCHR;
- else
- buf->st_size = lsize;
- /* We expect these to fail! */
- buf->st_mode |= STD_RBITS | STD_WBITS;
- buf->st_blksize = S_BLKSIZE;
- buf->st_ino = get_namehash ();
- syscall_printf ("0 = fstat (, %p)", buf);
- return 0;
- }
-
- if (!get_win32_name ())
+ switch (get_device ())
{
- saved_errno.set (ENOENT);
- return -1;
- }
-
- buf->st_atime = to_time_t (&local.ftLastAccessTime);
- buf->st_mtime = to_time_t (&local.ftLastWriteTime);
- buf->st_ctime = to_time_t (&local.ftCreationTime);
- buf->st_nlink = local.nNumberOfLinks;
- buf->st_dev = local.dwVolumeSerialNumber;
- buf->st_size = local.nFileSizeLow;
-
- /* This is for FAT filesystems, which don't support atime/ctime */
- if (buf->st_atime == 0)
- buf->st_atime = buf->st_mtime;
- if (buf->st_ctime == 0)
- buf->st_ctime = buf->st_mtime;
-
- /* Allocate some place to determine the root directory. Need to allocate
- enough so that rootdir can add a trailing slash if path starts with \\. */
- char root[strlen (get_win32_name ()) + 3];
- strcpy (root, get_win32_name ());
-
- /* Assume that if a drive has ACL support it MAY have valid "inodes".
- It definitely does not have valid inodes if it does not have ACL
- support. */
- switch (has_acls () ? GetDriveType (rootdir (root)) : DRIVE_UNKNOWN)
- {
- case DRIVE_FIXED:
- case DRIVE_REMOVABLE:
- case DRIVE_CDROM:
- case DRIVE_RAMDISK:
- /* Although the documentation indicates otherwise, it seems like
- "inodes" on these devices are persistent, at least across reboots. */
- buf->st_ino = local.nFileIndexHigh | local.nFileIndexLow;
+ case FH_PIPEW:
+ buf->st_mode = STD_WBITS | S_IWGRP | S_IWOTH;
+ break;
+ case FH_PIPER:
+ buf->st_mode = STD_RBITS;
break;
default:
- /* Either the nFileIndex* fields are unreliable or unavailable. Use the
- next best alternative. */
- buf->st_ino = get_namehash ();
+ buf->st_mode = STD_RBITS | STD_WBITS | S_IWGRP | S_IWOTH;
break;
}
+ buf->st_mode |= get_device () == FH_FLOPPY ? S_IFBLK : S_IFCHR;
+ buf->st_nlink = 1;
buf->st_blksize = S_BLKSIZE;
- buf->st_blocks = ((unsigned long) buf->st_size + S_BLKSIZE-1) / S_BLKSIZE;
-
- buf->st_mode = 0;
- /* Using a side effect: get_file_attibutes checks for
- directory. This is used, to set S_ISVTX, if needed. */
- if (local.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
- buf->st_mode = S_IFDIR;
- else if (get_symlink_p ())
- buf->st_mode = S_IFLNK;
- else if (get_socket_p ())
- buf->st_mode = S_IFSOCK;
- if (get_file_attribute (has_acls (), get_win32_name (), &buf->st_mode,
- &buf->st_uid, &buf->st_gid) == 0)
- {
- /* If read-only attribute is set, modify ntsec return value */
- if ((local.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
- && !get_symlink_p ())
- buf->st_mode &= ~(S_IWUSR | S_IWGRP | S_IWOTH);
-
- if (!(buf->st_mode & S_IFMT))
- buf->st_mode |= S_IFREG;
- }
- else
- {
- buf->st_mode |= STD_RBITS;
-
- if (!(local.dwFileAttributes & FILE_ATTRIBUTE_READONLY))
- buf->st_mode |= STD_WBITS;
- /* | S_IWGRP | S_IWOTH; we don't give write to group etc */
-
- if (buf->st_mode & S_IFDIR)
- buf->st_mode |= S_IFDIR | STD_XBITS;
- else if (buf->st_mode & S_IFMT)
- /* nothing */;
- else if (get_socket_p ())
- buf->st_mode |= S_IFSOCK;
- else
- switch (GetFileType (get_handle ()))
- {
- case FILE_TYPE_CHAR:
- case FILE_TYPE_UNKNOWN:
- buf->st_mode |= S_IFCHR;
- break;
- case FILE_TYPE_DISK:
- buf->st_mode |= S_IFREG;
- if (!dont_care_if_execable () && !get_execable_p ())
- {
- DWORD cur, done;
- char magic[3];
-
- /* First retrieve current position, set to beginning
- of file if not already there. */
- cur = SetFilePointer (get_handle(), 0, NULL, FILE_CURRENT);
- if (cur != INVALID_SET_FILE_POINTER &&
- (!cur ||
- SetFilePointer (get_handle(), 0, NULL, FILE_BEGIN)
- != INVALID_SET_FILE_POINTER))
- {
- /* FIXME should we use /etc/magic ? */
- magic[0] = magic[1] = magic[2] = '\0';
- if (ReadFile (get_handle (), magic, 3, &done, NULL) &&
- has_exec_chars (magic, done))
- set_execable_p ();
- SetFilePointer (get_handle(), cur, NULL, FILE_BEGIN);
- }
- }
- if (get_execable_p ())
- buf->st_mode |= STD_XBITS;
- break;
- case FILE_TYPE_PIPE:
- buf->st_mode |= S_IFSOCK;
- break;
- }
- }
-
- syscall_printf ("0 = fstat (, %p) st_atime=%x st_size=%d, st_mode=%p, st_ino=%d, sizeof=%d",
- buf, buf->st_atime, buf->st_size, buf->st_mode,
- (int) buf->st_ino, sizeof (*buf));
-
+ buf->st_dev = buf->st_rdev = FHDEVN (get_device ()) << 8 | (get_unit () & 0xff);
+ buf->st_ino = get_namehash ();
+ buf->st_atime = buf->st_mtime = buf->st_ctime = time (NULL) - 1;
return 0;
}
@@ -1056,7 +916,9 @@ fhandler_base::dup (fhandler_base *child)
debug_printf ("in fhandler_base dup");
HANDLE nh;
- if (!DuplicateHandle (hMainProc, get_handle(), hMainProc, &nh, 0, TRUE,
+ if (get_nohandle ())
+ nh = NULL;
+ else if (!DuplicateHandle (hMainProc, get_handle(), hMainProc, &nh, 0, TRUE,
DUPLICATE_SAME_ACCESS))
{
system_printf ("dup(%s) failed, handle %x, %E",
@@ -1184,7 +1046,8 @@ fhandler_base::operator delete (void *p)
}
/* Normal I/O constructor */
-fhandler_base::fhandler_base (DWORD devtype, const char *name, int unit):
+fhandler_base::fhandler_base (DWORD devtype, int unit):
+ status (devtype),
access (0),
io_handle (NULL),
namehash (0),
@@ -1198,7 +1061,6 @@ fhandler_base::fhandler_base (DWORD devtype, const char *name, int unit):
win32_path_name (NULL),
open_status (0)
{
- status = devtype;
int bin = __fmode & O_TEXT ? 0 : 1;
if (status != FH_DISK && status != FH_CONSOLE)
{
@@ -1222,257 +1084,11 @@ fhandler_base::~fhandler_base (void)
}
/**********************************************************************/
-/* fhandler_disk_file */
-
-fhandler_disk_file::fhandler_disk_file (const char *name) :
- fhandler_base (FH_DISK, name)
-{
- set_cb (sizeof *this);
-}
-
-int
-fhandler_disk_file::open (const char *path, int flags, mode_t mode)
-{
- syscall_printf ("(%s, %p)", path, flags);
-
- /* O_NOSYMLINK is an internal flag for implementing lstat, nothing more. */
- path_conv real_path (path, (flags & O_NOSYMLINK) ?
- PC_SYM_NOFOLLOW : PC_SYM_FOLLOW);
-
- if (real_path.error &&
- (flags & O_NOSYMLINK || real_path.error != ENOENT
- || !(flags & O_CREAT) || real_path.case_clash))
- {
- set_errno (flags & O_CREAT && real_path.case_clash ? ECASECLASH
- : real_path.error);
- syscall_printf ("0 = fhandler_disk_file::open (%s, %p)", path, flags);
- return 0;
- }
-
- set_name (path, real_path.get_win32 ());
- return open (real_path, flags, mode);
-}
-
-int
-fhandler_disk_file::open (path_conv& real_path, int flags, mode_t mode)
-{
- if (real_path.isbinary ())
- {
- set_r_binary (1);
- set_w_binary (1);
- }
-
- set_has_acls (real_path.has_acls ());
- set_isremote (real_path.isremote ());
-
- if (real_path.isdir ())
- flags |= O_DIROPEN;
-
- int res = this->fhandler_base::open (flags, mode);
-
- if (!res)
- goto out;
-
- /* This is for file systems known for having a buggy CreateFile call
- which might return a valid HANDLE without having actually opened
- the file.
- The only known file system to date is the SUN NFS Solstice Client 3.1
- which returns a valid handle when trying to open a file in a nonexistent
- directory. */
- if (real_path.has_buggy_open ()
- && GetFileAttributes (win32_path_name) == (DWORD) -1)
- {
- debug_printf ("Buggy open detected.");
- close ();
- set_errno (ENOENT);
- return 0;
- }
-
- if (flags & O_APPEND)
- SetFilePointer (get_handle(), 0, 0, FILE_END);
-
- set_symlink_p (real_path.issymlink ());
- set_execable_p (real_path.exec_state ());
- set_socket_p (real_path.issocket ());
-
-out:
- syscall_printf ("%d = fhandler_disk_file::open (%s, %p)", res,
- get_win32_name (), flags);
- return res;
-}
-
-int
-fhandler_disk_file::close ()
-{
- int res = this->fhandler_base::close ();
- if (!res)
- cygwin_shared->delqueue.process_queue ();
- return res;
-}
-
-/*
- * FIXME !!!
- * The correct way to do this to get POSIX locking
- * semantics is to keep a linked list of posix lock
- * requests and map them into Win32 locks. The problem
- * is that Win32 does not deal correctly with overlapping
- * lock requests. Also another pain is that Win95 doesn't do
- * non-blocking or non exclusive locks at all. For '95 just
- * convert all lock requests into blocking,exclusive locks.
- * This shouldn't break many apps but denying all locking
- * would.
- * For now just convert to Win32 locks and hope for the best.
- */
-
-int
-fhandler_disk_file::lock (int cmd, struct flock *fl)
-{
- int win32_start;
- int win32_len;
- DWORD win32_upper;
- DWORD startpos;
-
- /*
- * We don't do getlck calls yet.
- */
-
- if (cmd == F_GETLK)
- {
- set_errno (ENOSYS);
- return -1;
- }
-
- /*
- * Calculate where in the file to start from,
- * then adjust this by fl->l_start.
- */
-
- switch (fl->l_whence)
- {
- case SEEK_SET:
- startpos = 0;
- break;
- case SEEK_CUR:
- if ((off_t) (startpos = lseek (0, SEEK_CUR)) == (off_t)-1)
- return -1;
- break;
- case SEEK_END:
- {
- BY_HANDLE_FILE_INFORMATION finfo;
- if (GetFileInformationByHandle (get_handle(), &finfo) == 0)
- {
- __seterrno ();
- return -1;
- }
- startpos = finfo.nFileSizeLow; /* Nowhere to keep high word */
- break;
- }
- default:
- set_errno (EINVAL);
- return -1;
- }
-
- /*
- * Now the fun starts. Adjust the start and length
- * fields until they make sense.
- */
-
- win32_start = startpos + fl->l_start;
- if (fl->l_len < 0)
- {
- win32_start -= fl->l_len;
- win32_len = -fl->l_len;
- }
- else
- win32_len = fl->l_len;
-
- if (win32_start < 0)
- {
- /* watch the signs! */
- win32_len -= -win32_start;
- if (win32_len <= 0)
- {
- /* Failure ! */
- set_errno (EINVAL);
- return -1;
- }
- win32_start = 0;
- }
-
- /*
- * Special case if len == 0 for POSIX means lock
- * to the end of the entire file (and all future extensions).
- */
- if (win32_len == 0)
- {
- win32_len = 0xffffffff;
- win32_upper = wincap.lock_file_highword ();
- }
- else
- win32_upper = 0;
-
- BOOL res;
-
- if (wincap.has_lock_file_ex ())
- {
- DWORD lock_flags = (cmd == F_SETLK) ? LOCKFILE_FAIL_IMMEDIATELY : 0;
- lock_flags |= (fl->l_type == F_WRLCK) ? LOCKFILE_EXCLUSIVE_LOCK : 0;
-
- OVERLAPPED ov;
-
- ov.Internal = 0;
- ov.InternalHigh = 0;
- ov.Offset = (DWORD)win32_start;
- ov.OffsetHigh = 0;
- ov.hEvent = (HANDLE) 0;
-
- if (fl->l_type == F_UNLCK)
- {
- res = UnlockFileEx (get_handle (), 0, (DWORD)win32_len, win32_upper, &ov);
- }
- else
- {
- res = LockFileEx (get_handle (), lock_flags, 0, (DWORD)win32_len,
- win32_upper, &ov);
- /* Deal with the fail immediately case. */
- /*
- * FIXME !! I think this is the right error to check for
- * but I must admit I haven't checked....
- */
- if ((res == 0) && (lock_flags & LOCKFILE_FAIL_IMMEDIATELY) &&
- (GetLastError () == ERROR_LOCK_FAILED))
- {
- set_errno (EAGAIN);
- return -1;
- }
- }
- }
- else
- {
- /* Windows 95 -- use primitive lock call */
- if (fl->l_type == F_UNLCK)
- res = UnlockFile (get_handle (), (DWORD)win32_start, 0, (DWORD)win32_len,
- win32_upper);
- else
- res = LockFile (get_handle (), (DWORD)win32_start, 0, (DWORD)win32_len, win32_upper);
- }
-
- if (res == 0)
- {
- __seterrno ();
- return -1;
- }
-
- return 0;
-}
-
-/**********************************************************************/
/* /dev/null */
-fhandler_dev_null::fhandler_dev_null (const char *name) :
- fhandler_base (FH_NULL, name)
+fhandler_dev_null::fhandler_dev_null () :
+ fhandler_base (FH_NULL)
{
- set_cb (sizeof *this);
}
void
@@ -1484,6 +1100,9 @@ fhandler_dev_null::dump (void)
void
fhandler_base::set_inheritance (HANDLE &h, int not_inheriting)
{
+#ifdef DEBUGGING
+ HANDLE oh = h;
+#endif
/* Note that we could use SetHandleInformation here but it is not available
on all platforms. Test cases seem to indicate that using DuplicateHandle
in this fashion does not actually close the original handle, which is
@@ -1493,18 +1112,30 @@ fhandler_base::set_inheritance (HANDLE &h, int not_inheriting)
DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE))
debug_printf ("DuplicateHandle failed, %E");
#ifdef DEBUGGING
- setclexec_pid (h, not_inheriting);
+ if (h)
+ setclexec_pid (oh, h, not_inheriting);
#endif
}
void
fhandler_base::fork_fixup (HANDLE parent, HANDLE &h, const char *name)
{
- if (!get_close_on_exec ())
+#ifdef DEBUGGING
+ HANDLE oh = h;
+#endif
+ if (/* !is_socket () && */ !get_close_on_exec ())
debug_printf ("handle %p already opened", h);
else if (!DuplicateHandle (parent, h, hMainProc, &h, 0, !get_close_on_exec (),
- DUPLICATE_SAME_ACCESS))
+ DUPLICATE_SAME_ACCESS))
system_printf ("%s - %E, handle %s<%p>", get_name (), name, h);
+#ifdef DEBUGGING
+ else
+ {
+ debug_printf ("%s success - oldh %p, h %p", get_name (), oh, h);
+ // someday, maybe ProtectHandle2 (h, name);
+ setclexec_pid (oh, h, !get_close_on_exec ());
+ }
+#endif
}
void
@@ -1522,7 +1153,7 @@ fhandler_base::fixup_after_fork (HANDLE parent)
fork_fixup (parent, io_handle, "io_handle");
}
-int
+bool
fhandler_base::is_nonblocking ()
{
return (openflags & O_NONBLOCK_MASK) != 0;
@@ -1535,3 +1166,45 @@ fhandler_base::set_nonblocking (int yes)
int new_flags = yes ? (!current ? O_NONBLOCK : current) : 0;
openflags = (openflags & ~O_NONBLOCK_MASK) | new_flags;
}
+
+DIR *
+fhandler_base::opendir (path_conv&)
+{
+ set_errno (ENOTDIR);
+ return NULL;
+}
+
+struct dirent *
+fhandler_base::readdir (DIR *)
+{
+ set_errno (ENOTDIR);
+ return NULL;
+}
+
+off_t
+fhandler_base::telldir (DIR *)
+{
+ set_errno (ENOTDIR);
+ return -1;
+}
+
+void
+fhandler_base::seekdir (DIR *, off_t)
+{
+ set_errno (ENOTDIR);
+ return;
+}
+
+void
+fhandler_base::rewinddir (DIR *)
+{
+ set_errno (ENOTDIR);
+ return;
+}
+
+int
+fhandler_base::closedir (DIR *)
+{
+ set_errno (ENOTDIR);
+ return -1;
+}
diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
index 753508266..916000452 100644
--- a/winsup/cygwin/fhandler.h
+++ b/winsup/cygwin/fhandler.h
@@ -1,6 +1,6 @@
/* fhandler.h
- Copyright 1996, 1997, 1998, 1999, 2000, 2001 Red Hat, Inc.
+ Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
This file is part of Cygwin.
@@ -13,41 +13,6 @@ details. */
#include <sys/ioctl.h>
-/* Classes
-
- Code is located in fhandler.cc unless another file name is given.
-
- fhandler_base normal I/O
-
- fhandler_disk_file
- fhandler_serial Adds vmin and vtime.
- fhandler_dev_null Not really I/O
- fhandler_dev_zero Faked
-
- fhandler_dev_raw (fhandler_raw.cc)
- fhandler_dev_floppy (fhandler_floppy.cc)
- fhandler_dev_tape (fhandler_tape.cc)
-
- fhandler_pipe
- fhandler_socket (fhandler_socket.cc)
-
- fhandler_tty_slave (tty.cc)
- fhandler_pty_master (tty.cc)
- fhandler_tty_master (tty.cc)
-
- fhandler_console Out with ansi control. (console.cc)
-
- fhandler_windows Windows messages I/O (fhandler_windows.cc)
-
- fhandler_dev_random /dev/[u]random implementation (fhandler_random.cc)
-
- fhandler_dev_mem /dev/mem implementation (fhandler_mem.cc)
-
- fhandler_dev_clipboard /dev/clipboard implementation (fhandler_clipboard.cc)
-
- fhandler_proc Interesting possibility, not implemented yet
-*/
-
enum
{
FH_RBINARY = 0x00001000, /* binary read mode */
@@ -65,7 +30,7 @@ enum
FH_W95LSBUG = 0x00400000, /* set when lseek is called as a flag that
* _write should check if we've moved beyond
* EOF, zero filling if so. */
- FH_UNUSED = 0x00800000, /* currently unused. */
+ FH_NOHANDLE = 0x00800000, /* No handle associated with fhandler. */
FH_NOEINTR = 0x01000000, /* Set if I/O should be uninterruptible. */
FH_FFIXUP = 0x02000000, /* Set if need to fixup after fork. */
FH_LOCAL = 0x04000000, /* File is unix domain socket */
@@ -102,10 +67,11 @@ enum
FH_ZERO = 0x00000014, /* is the zero device */
FH_RANDOM = 0x00000015, /* is a random device */
FH_MEM = 0x00000016, /* is a mem device */
- FH_CLIPBOARD = 0x00000017, /* is a clipbaord device */
+ FH_CLIPBOARD = 0x00000017, /* is a clipboard device */
FH_OSS_DSP = 0x00000018, /* is a dsp audio device */
+ FH_CYGDRIVE= 0x00000019, /* /cygdrive/x */
- FH_NDEV = 0x00000019, /* Maximum number of devices */
+ FH_NDEV = 0x0000001a, /* Maximum number of devices */
FH_DEVMASK = 0x00000fff, /* devices live here */
FH_BAD = 0xffffffff
};
@@ -124,7 +90,7 @@ enum
/* newlib used to define O_NDELAY differently from O_NONBLOCK. Now it
properly defines both to be the same. Unfortunately, we have to
- behave properly the old version, too, to accomodate older executables. */
+ behave properly the old version, too, to accommodate older executables. */
#define OLD_O_NDELAY (CYGWIN_VERSION_CHECK_FOR_OLD_O_NONBLOCK ? 4 : 0)
/* Care for the old O_NDELAY flag. If one of the flags is set,
@@ -138,6 +104,8 @@ extern struct __cygwin_perfile *perfile_table;
class select_record;
class path_conv;
class fhandler_disk_file;
+typedef struct __DIR DIR;
+struct dirent;
enum bg_check_types
{
@@ -157,17 +125,15 @@ enum executable_states
class fhandler_base
{
-protected:
+ protected:
DWORD status;
-public:
- int cb;
-private:
+ private:
int access;
HANDLE io_handle;
unsigned long namehash; /* hashed filename, used as inode num */
-protected:
+ protected:
/* Full unix path name of this file */
/* File open flags from open () and fcntl () calls */
int openflags;
@@ -182,19 +148,18 @@ protected:
char *win32_path_name;
DWORD open_status;
-public:
+ public:
void set_name (const char * unix_path, const char * win32_path = NULL,
int unit = 0);
void reset_unix_path_name (const char *);
virtual fhandler_base& operator =(fhandler_base &x);
- fhandler_base (DWORD dev, const char *name = 0, int unit = 0);
+ fhandler_base (DWORD dev, int unit = 0);
virtual ~fhandler_base ();
/* Non-virtual simple accessor functions. */
void set_io_handle (HANDLE x) { io_handle = x; }
- void set_cb (size_t size) { cb = size; }
DWORD get_device () { return status & FH_DEVMASK; }
virtual int get_unit () { return 0; }
virtual BOOL is_slow () { return get_device () < FH_SLOW; }
@@ -202,25 +167,29 @@ public:
int get_access () { return access; }
void set_access (int x) { access = x; }
- int get_async () { return FHISSETF (ASYNC); }
+ bool get_async () { return FHISSETF (ASYNC); }
void set_async (int x) { FHCONDSETF (x, ASYNC); }
int get_flags () { return openflags; }
void set_flags (int x) { openflags = x; }
- int is_nonblocking ();
+ bool is_nonblocking ();
void set_nonblocking (int yes);
- int get_w_binary () { return FHISSETF (WBINARY); }
- int get_r_binary () { return FHISSETF (RBINARY); }
+ bool get_w_binary () { return FHISSETF (WBINARY); }
+ bool get_r_binary () { return FHISSETF (RBINARY); }
- int get_w_binset () { return FHISSETF (WBINSET); }
- int get_r_binset () { return FHISSETF (RBINSET); }
+ bool get_w_binset () { return FHISSETF (WBINSET); }
+ bool get_r_binset () { return FHISSETF (RBINSET); }
void set_w_binary (int b) { FHCONDSETF (b, WBINARY); FHSETF (WBINSET); }
void set_r_binary (int b) { FHCONDSETF (b, RBINARY); FHSETF (RBINSET); }
void clear_w_binary () {FHCLEARF (WBINARY); FHCLEARF (WBINSET); }
void clear_r_binary () {FHCLEARF (RBINARY); FHCLEARF (RBINSET); }
+
+ bool get_nohandle () { return FHISSETF (NOHANDLE); }
+ void set_nohandle (int x) { FHCONDSETF (x, NOHANDLE); }
+
void set_open_status () {open_status = status;}
DWORD get_open_status () {return open_status;}
void reset_to_open_binmode ()
@@ -232,10 +201,10 @@ public:
int get_default_fmode (int flags);
- int get_r_no_interrupt () { return FHISSETF (NOEINTR); }
+ bool get_r_no_interrupt () { return FHISSETF (NOEINTR); }
void set_r_no_interrupt (int b) { FHCONDSETF (b, NOEINTR); }
- int get_close_on_exec () { return FHISSETF (CLOEXEC); }
+ bool get_close_on_exec () { return FHISSETF (CLOEXEC); }
int set_close_on_exec_flag (int b) { return FHCONDSETF (b, CLOEXEC); }
LPSECURITY_ATTRIBUTES get_inheritance (bool all = 0)
@@ -247,9 +216,9 @@ public:
}
void set_check_win95_lseek_bug (int b = 1) { FHCONDSETF (b, W95LSBUG); }
- int get_check_win95_lseek_bug () { return FHISSETF (W95LSBUG); }
+ bool get_check_win95_lseek_bug () { return FHISSETF (W95LSBUG); }
- int get_need_fork_fixup () { return FHISSETF (FFIXUP); }
+ bool get_need_fork_fixup () { return FHISSETF (FFIXUP); }
void set_need_fork_fixup () { FHSETF (FFIXUP); }
virtual void set_close_on_exec (int val);
@@ -258,31 +227,31 @@ public:
virtual void fixup_after_fork (HANDLE);
virtual void fixup_after_exec (HANDLE) {}
- int get_symlink_p () { return FHISSETF (SYMLINK); }
+ bool get_symlink_p () { return FHISSETF (SYMLINK); }
void set_symlink_p (int val) { FHCONDSETF (val, SYMLINK); }
void set_symlink_p () { FHSETF (SYMLINK); }
- int get_socket_p () { return FHISSETF (LOCAL); }
+ bool get_socket_p () { return FHISSETF (LOCAL); }
void set_socket_p (int val) { FHCONDSETF (val, LOCAL); }
void set_socket_p () { FHSETF (LOCAL); }
- int get_execable_p () { return FHISSETF (EXECABL); }
+ bool get_execable_p () { return FHISSETF (EXECABL); }
void set_execable_p (executable_states val)
{
FHCONDSETF (val == is_executable, EXECABL);
FHCONDSETF (val == dont_care_if_executable, DCEXEC);
}
void set_execable_p () { FHSETF (EXECABL); }
- int dont_care_if_execable () { return FHISSETF (DCEXEC); }
+ bool dont_care_if_execable () { return FHISSETF (DCEXEC); }
- int get_append_p () { return FHISSETF (APPEND); }
+ bool get_append_p () { return FHISSETF (APPEND); }
void set_append_p (int val) { FHCONDSETF (val, APPEND); }
void set_append_p () { FHSETF (APPEND); }
- int get_query_open () { return FHISSETF (QUERYOPEN); }
+ bool get_query_open () { return FHISSETF (QUERYOPEN); }
void set_query_open (int val) { FHCONDSETF (val, QUERYOPEN); }
- int get_readahead_valid () { return raixget < ralen; }
+ bool get_readahead_valid () { return raixget < ralen; }
int puts_readahead (const char *s, size_t len = (size_t) -1);
int put_readahead (char value);
@@ -295,10 +264,10 @@ public:
int get_readahead_into_buffer (char *buf, size_t buflen);
- int has_acls () { return FHISSETF (HASACLS); }
+ bool has_acls () { return FHISSETF (HASACLS); }
void set_has_acls (int val) { FHCONDSETF (val, HASACLS); }
- int isremote () { return FHISSETF (ISREMOTE); }
+ bool isremote () { return FHISSETF (ISREMOTE); }
void set_isremote (int val) { FHCONDSETF (val, ISREMOTE); }
const char *get_name () { return unix_path_name; }
@@ -311,19 +280,13 @@ public:
/* fixup fd possibly non-inherited handles after fork */
void fork_fixup (HANDLE parent, HANDLE &h, const char *name);
- /* Potentially overridden virtual functions. */
- virtual int open (const char *, int flags, mode_t mode = 0)
- {
- return open (flags, mode);
- }
- virtual int open (path_conv& real_path, int flags, mode_t mode);
- virtual int open (int flags, mode_t mode = 0);
+ virtual int open (path_conv * real_path, int flags, mode_t mode = 0);
virtual int close ();
- virtual int fstat (struct stat *buf) { return stat_dev (get_device (), get_unit (), get_namehash (), buf); }
+ virtual int __stdcall fstat (struct stat *buf, path_conv *) __attribute__ ((regparm (3)));
virtual int ioctl (unsigned int cmd, void *);
virtual int fcntl (int cmd, void *);
virtual char const * ttyname () { return get_name(); }
- virtual int read (void *ptr, size_t len);
+ virtual int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (3)));
virtual int write (const void *ptr, size_t len);
virtual off_t lseek (off_t offset, int whence);
virtual int lock (int, struct flock *);
@@ -368,7 +331,7 @@ public:
virtual select_record *select_read (select_record *s);
virtual select_record *select_write (select_record *s);
virtual select_record *select_except (select_record *s);
- virtual int ready_for_read (int fd, DWORD howlong, int ignra);
+ virtual int ready_for_read (int fd, DWORD howlong);
virtual const char * get_native_name ()
{
return windows_device_names[FHDEVN (status)];
@@ -380,18 +343,27 @@ public:
rabuf = NULL;
}
void operator delete (void *);
+ virtual HANDLE get_guard () const {return NULL;}
+ virtual void set_eof () {}
+ virtual DIR *opendir (path_conv& pc);
+ virtual dirent *readdir (DIR *);
+ virtual off_t telldir (DIR *);
+ virtual void seekdir (DIR *, off_t);
+ virtual void rewinddir (DIR *);
+ virtual int closedir (DIR *);
};
class fhandler_socket: public fhandler_base
{
-private:
+ private:
int addr_family;
int connect_secret [4];
HANDLE secret_event;
struct _WSAPROTOCOL_INFOA *prot_info_ptr;
+ char *sun_path;
-public:
- fhandler_socket (const char *name = 0);
+ public:
+ fhandler_socket ();
~fhandler_socket ();
int get_socket () { return (int) get_handle(); }
fhandler_socket * is_socket () { return this; }
@@ -403,7 +375,7 @@ public:
void set_shutdown_write () {FHSETF (SHUTWR);}
int write (const void *ptr, size_t len);
- int read (void *ptr, size_t len);
+ int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (3)));
int ioctl (unsigned int cmd, void *);
int fcntl (int cmd, void *);
off_t lseek (off_t, int) { return 0; }
@@ -419,43 +391,47 @@ public:
select_record *select_read (select_record *s);
select_record *select_write (select_record *s);
select_record *select_except (select_record *s);
- int ready_for_read (int fd, DWORD howlong, int ignra);
int get_addr_family () {return addr_family;}
void set_addr_family (int af) {addr_family = af;}
+ void set_sun_path (const char *path);
+ char *get_sun_path () {return sun_path;}
void set_connect_secret ();
void get_connect_secret (char*);
HANDLE create_secret_event (int *secret = NULL);
int check_peer_secret_event (struct sockaddr_in *peer, int *secret = NULL);
void signal_secret_event ();
void close_secret_event ();
+ int __stdcall fstat (struct stat *buf, path_conv *) __attribute__ ((regparm (3)));
};
class fhandler_pipe: public fhandler_base
{
HANDLE guard;
+ bool broken_pipe;
HANDLE writepipe_exists;
DWORD orig_pid;
unsigned id;
-public:
- fhandler_pipe (const char *name = 0, DWORD devtype = FH_PIPE);
+ public:
+ fhandler_pipe (DWORD devtype);
off_t lseek (off_t offset, int whence);
select_record *select_read (select_record *s);
select_record *select_write (select_record *s);
select_record *select_except (select_record *s);
- int ready_for_read (int fd, DWORD howlong, int ignra);
void set_close_on_exec (int val);
- int read (void *ptr, size_t len);
+ int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (3)));
int close ();
void create_guard (SECURITY_ATTRIBUTES *sa) {guard = CreateMutex (sa, FALSE, NULL);}
int dup (fhandler_base *child);
void fixup_after_fork (HANDLE);
bool hit_eof ();
+ void set_eof () {broken_pipe = true;}
friend int make_pipe (int fildes[2], unsigned int psize, int mode);
+ HANDLE get_guard () const {return guard;}
};
class fhandler_dev_raw: public fhandler_base
{
-protected:
+ protected:
char *devbuf;
size_t devbufsiz;
size_t devbufstart;
@@ -476,19 +452,19 @@ protected:
/* returns not null, if `win_error' determines an end of file condition */
virtual int is_eof(int win_error) = 0;
- fhandler_dev_raw (DWORD dev, const char *name, int unit);
+ fhandler_dev_raw (DWORD dev, int unit);
-public:
+ public:
~fhandler_dev_raw (void);
- int open (const char *path, int flags, mode_t mode = 0);
+ int get_unit () { return unit; }
+
+ int open (path_conv *, int flags, mode_t mode = 0);
int close (void);
int raw_read (void *ptr, size_t ulen);
int raw_write (const void *ptr, size_t ulen);
- int fstat (struct stat *buf);
-
int dup (fhandler_base *child);
int ioctl (unsigned int cmd, void *buf);
@@ -499,14 +475,14 @@ public:
class fhandler_dev_floppy: public fhandler_dev_raw
{
-protected:
+ protected:
virtual int is_eom (int win_error);
virtual int is_eof (int win_error);
-public:
- fhandler_dev_floppy (const char *name, int unit);
+ public:
+ fhandler_dev_floppy (int unit);
- virtual int open (const char *path, int flags, mode_t mode = 0);
+ virtual int open (path_conv *, int flags, mode_t mode = 0);
virtual int close (void);
virtual off_t lseek (off_t offset, int whence);
@@ -516,30 +492,31 @@ public:
class fhandler_dev_tape: public fhandler_dev_raw
{
- int norewind;
int lasterr;
-protected:
+ bool is_rewind_device () { return get_unit () < 128; }
+
+ protected:
virtual void clear (void);
virtual int is_eom (int win_error);
virtual int is_eof (int win_error);
-public:
- fhandler_dev_tape (const char *name, int unit);
+ public:
+ fhandler_dev_tape (int unit);
- virtual int open (const char *path, int flags, mode_t mode = 0);
- virtual int close (void);
+ int open (path_conv *, int flags, mode_t mode = 0);
+ int close (void);
- virtual off_t lseek (off_t offset, int whence);
+ off_t lseek (off_t offset, int whence);
- virtual int fstat (struct stat *buf);
+ int __stdcall fstat (struct stat *buf, path_conv *) __attribute__ ((regparm (3)));
- virtual int dup (fhandler_base *child);
+ int dup (fhandler_base *child);
- virtual int ioctl (unsigned int cmd, void *buf);
+ int ioctl (unsigned int cmd, void *buf);
-private:
+ private:
int tape_write_marks (int marktype, DWORD len);
int tape_get_pos (unsigned long *ret);
int tape_set_pos (int mode, long count, BOOLEAN sfm_func = FALSE);
@@ -556,38 +533,64 @@ private:
class fhandler_disk_file: public fhandler_base
{
-public:
- fhandler_disk_file (const char *name);
+ public:
+ fhandler_disk_file ();
+ fhandler_disk_file (DWORD devtype);
- int open (const char *path, int flags, mode_t mode = 0);
- int open (path_conv& real_path, int flags, mode_t mode);
+ int open (path_conv * real_path, int flags, mode_t mode);
int close ();
int lock (int, struct flock *);
BOOL is_device () { return FALSE; }
- int fstat (struct stat *buf);
+ int __stdcall fstat (struct stat *buf, path_conv *pc) __attribute__ ((regparm (3)));
+ int __stdcall fstat_helper (struct stat *buf) __attribute__ ((regparm (2)));
HANDLE mmap (caddr_t *addr, size_t len, DWORD access, int flags, off_t off);
int munmap (HANDLE h, caddr_t addr, size_t len);
int msync (HANDLE h, caddr_t addr, size_t len, int flags);
BOOL fixup_mmap_after_fork (HANDLE h, DWORD access, DWORD offset,
DWORD size, void *address);
+ DIR *opendir (path_conv& pc);
+ struct dirent *readdir (DIR *);
+ off_t telldir (DIR *);
+ void seekdir (DIR *, off_t);
+ void rewinddir (DIR *);
+ int closedir (DIR *);
+};
+
+class fhandler_cygdrive: public fhandler_disk_file
+{
+ int unit;
+ int ndrives;
+ const char *pdrive;
+ void set_drives ();
+ public:
+ bool iscygdrive_root () const { return !unit; }
+ fhandler_cygdrive (int unit);
+ DIR *opendir (path_conv& pc);
+ struct dirent *readdir (DIR *);
+ off_t telldir (DIR *);
+ void seekdir (DIR *, off_t);
+ void rewinddir (DIR *);
+ int closedir (DIR *);
+ int __stdcall fstat (struct stat *buf, path_conv *pc) __attribute__ ((regparm (3)));
};
class fhandler_serial: public fhandler_base
{
-private:
+ private:
unsigned int vmin_; /* from termios */
unsigned int vtime_; /* from termios */
pid_t pgrp_;
-public:
+ public:
int overlapped_armed;
OVERLAPPED io_status;
+ DWORD ev;
/* Constructor */
- fhandler_serial (const char *name, DWORD devtype = FH_SERIAL, int unit = 0);
+ fhandler_serial (int unit);
- int open (const char *path, int flags, mode_t mode);
+ int open (path_conv *, int flags, mode_t mode);
int close ();
void init (HANDLE h, DWORD a, mode_t flags);
void overlapped_setup ();
@@ -614,7 +617,6 @@ public:
select_record *select_read (select_record *s);
select_record *select_write (select_record *s);
select_record *select_except (select_record *s);
- int ready_for_read (int fd, DWORD howlong, int ignra);
};
#define acquire_output_mutex(ms) \
@@ -627,14 +629,14 @@ class tty;
class tty_min;
class fhandler_termios: public fhandler_base
{
-protected:
+ protected:
HANDLE output_handle;
virtual void doecho (const void *, DWORD) {};
virtual int accept_input () {return 1;};
-public:
+ public:
tty_min *tc;
- fhandler_termios (DWORD dev, const char *name = 0, int unit = 0) :
- fhandler_base (dev, name, unit)
+ fhandler_termios (DWORD dev, int unit = 0) :
+ fhandler_base (dev, unit)
{
set_need_fork_fixup ();
}
@@ -674,7 +676,7 @@ enum ansi_intensity
/* This is a input and output console handle */
class fhandler_console: public fhandler_termios
{
-private:
+ private:
WORD default_color, underline_color, dim_color;
@@ -686,13 +688,13 @@ private:
int args_[MAXARGS];
int nargs_;
unsigned rarg;
- BOOL saw_question_mark;
+ bool saw_question_mark;
char my_title_buf [TITLESIZE + 1];
WORD current_win32_attr;
ansi_intensity intensity;
- BOOL underline, blink, reverse;
+ bool underline, blink, reverse;
WORD fg, bg;
/* saved cursor coordinates */
@@ -720,9 +722,9 @@ private:
DWORD dwLastButtonState;
int nModifiers;
- BOOL insert_mode;
- BOOL use_mouse;
- BOOL raw_win32_keyboard_mode;
+ bool insert_mode;
+ bool use_mouse;
+ bool raw_win32_keyboard_mode;
/* Output calls */
void set_default_attr ();
@@ -744,17 +746,17 @@ private:
int input_tcsetattr (int a, const struct termios *t);
void set_cursor_maybe ();
-public:
+ public:
- fhandler_console (const char *name);
+ fhandler_console ();
fhandler_console* is_console () { return this; }
- int open (const char *path, int flags, mode_t mode = 0);
+ int open (path_conv *, int flags, mode_t mode = 0);
int write (const void *ptr, size_t len);
void doecho (const void *str, DWORD len) { (void) write (str, len); }
- int read (void *ptr, size_t len);
+ int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (3)));
int close ();
int tcflush (int);
@@ -771,7 +773,6 @@ public:
select_record *select_read (select_record *s);
select_record *select_write (select_record *s);
select_record *select_except (select_record *s);
- int ready_for_read (int fd, DWORD howlong, int ignra);
void fixup_after_exec (HANDLE);
void set_close_on_exec (int val);
void fixup_after_fork (HANDLE parent);
@@ -780,10 +781,11 @@ public:
class fhandler_tty_common: public fhandler_termios
{
-public:
- fhandler_tty_common (DWORD dev, const char *name = 0, int unit = 0) :
- fhandler_termios (dev, name, unit),
- ttynum (unit)
+ public:
+ fhandler_tty_common (DWORD dev, int unit = 0)
+ : fhandler_termios (dev, unit), output_done_event (NULL),
+ ioctl_request_event (NULL), ioctl_done_event (NULL), output_mutex (NULL),
+ input_mutex (NULL), input_available_event (NULL), inuse (NULL), ttynum (unit)
{
// nothing to do
}
@@ -796,12 +798,11 @@ public:
HANDLE output_mutex, input_mutex;
HANDLE input_available_event;
HANDLE inuse; // used to indicate that a tty is in use
-
+ int ttynum; // Master tty num.
DWORD __acquire_output_mutex (const char *fn, int ln, DWORD ms);
void __release_output_mutex (const char *fn, int ln);
- int ttynum; // Master tty num.
virtual int dup (fhandler_base *child);
tty *get_ttyp () { return (tty *)tc; }
@@ -813,19 +814,18 @@ public:
select_record *select_read (select_record *s);
select_record *select_write (select_record *s);
select_record *select_except (select_record *s);
- int ready_for_read (int fd, DWORD howlong, int ignra);
};
class fhandler_tty_slave: public fhandler_tty_common
{
-public:
+ public:
/* Constructor */
- fhandler_tty_slave (const char *name);
- fhandler_tty_slave (int, const char *name);
+ fhandler_tty_slave ();
+ fhandler_tty_slave (int);
- int open (const char *path, int flags, mode_t mode = 0);
+ int open (path_conv *, int flags, mode_t mode = 0);
int write (const void *ptr, size_t len);
- int read (void *ptr, size_t len);
+ int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (3)));
void init (HANDLE, DWORD, mode_t);
int tcsetattr (int a, const struct termios *t);
@@ -835,7 +835,7 @@ public:
off_t lseek (off_t, int) { return 0; }
select_record *select_read (select_record *s);
- int ready_for_read (int fd, DWORD howlong, int ignra);
+ int ready_for_read (int fd, DWORD howlong);
int cygserver_attach_tty (HANDLE*, HANDLE*);
};
@@ -843,18 +843,18 @@ public:
class fhandler_pty_master: public fhandler_tty_common
{
int pktmode; // non-zero if pty in a packet mode.
-public:
+ public:
int need_nl; // Next read should start with \n
/* Constructor */
- fhandler_pty_master (const char *name, DWORD devtype = FH_PTYM, int unit = -1);
+ fhandler_pty_master (DWORD devtype = FH_PTYM, int unit = -1);
int process_slave_output (char *buf, size_t len, int pktmode_on);
void doecho (const void *str, DWORD len);
int accept_input ();
- int open (const char *path, int flags, mode_t mode = 0);
+ int open (path_conv *, int flags, mode_t mode = 0);
int write (const void *ptr, size_t len);
- int read (void *ptr, size_t len);
+ int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (3)));
int close ();
int tcsetattr (int a, const struct termios *t);
@@ -871,12 +871,12 @@ public:
class fhandler_tty_master: public fhandler_pty_master
{
-public:
+ public:
/* Constructor */
- fhandler_tty_master (const char *name, int unit);
fhandler_console *console; // device handler to perform real i/o.
HANDLE hThread; // process_output thread handle.
+ fhandler_tty_master (int unit);
int init (int);
int init_console ();
void fixup_after_fork (HANDLE parent);
@@ -885,8 +885,8 @@ public:
class fhandler_dev_null: public fhandler_base
{
-public:
- fhandler_dev_null (const char *name);
+ public:
+ fhandler_dev_null ();
void dump ();
select_record *select_read (select_record *s);
@@ -896,11 +896,11 @@ public:
class fhandler_dev_zero: public fhandler_base
{
-public:
- fhandler_dev_zero (const char *name);
- int open (const char *path, int flags, mode_t mode = 0);
+ public:
+ fhandler_dev_zero ();
+ int open (path_conv *, int flags, mode_t mode = 0);
int write (const void *ptr, size_t len);
- int read (void *ptr, size_t len);
+ int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (3)));
off_t lseek (off_t offset, int whence);
int close (void);
@@ -909,7 +909,7 @@ public:
class fhandler_dev_random: public fhandler_base
{
-protected:
+ protected:
int unit;
HCRYPTPROV crypt_prov;
long pseudo;
@@ -918,12 +918,12 @@ protected:
int pseudo_write (const void *ptr, size_t len);
int pseudo_read (void *ptr, size_t len);
-public:
- fhandler_dev_random (const char *name, int unit);
+ public:
+ fhandler_dev_random (int unit);
int get_unit () { return unit; }
- int open (const char *path, int flags, mode_t mode = 0);
+ int open (path_conv *, int flags, mode_t mode = 0);
int write (const void *ptr, size_t len);
- int read (void *ptr, size_t len);
+ int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (3)));
off_t lseek (off_t offset, int whence);
int close (void);
int dup (fhandler_base *child);
@@ -933,21 +933,21 @@ public:
class fhandler_dev_mem: public fhandler_base
{
-protected:
+ protected:
int unit;
DWORD mem_size;
DWORD pos;
-public:
- fhandler_dev_mem (const char *name, int unit);
+ public:
+ fhandler_dev_mem (int unit);
~fhandler_dev_mem (void);
- int open (const char *path, int flags, mode_t mode = 0);
+ int open (path_conv *, int flags, mode_t mode = 0);
int write (const void *ptr, size_t ulen);
- int read (void *ptr, size_t ulen);
+ int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (3)));
off_t lseek (off_t offset, int whence);
int close (void);
- int fstat (struct stat *buf);
+ int __stdcall fstat (struct stat *buf, path_conv *) __attribute__ ((regparm (3)));
int dup (fhandler_base *child);
HANDLE mmap (caddr_t *addr, size_t len, DWORD access, int flags, off_t off);
@@ -961,12 +961,12 @@ public:
class fhandler_dev_clipboard: public fhandler_base
{
-public:
- fhandler_dev_clipboard (const char *name);
+ public:
+ fhandler_dev_clipboard ();
int is_windows (void) { return 1; }
- int open (const char *path, int flags, mode_t mode = 0);
+ int open (path_conv *, int flags, mode_t mode = 0);
int write (const void *ptr, size_t len);
- int read (void *ptr, size_t len);
+ int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (3)));
off_t lseek (off_t offset, int whence);
int close (void);
@@ -974,24 +974,24 @@ public:
void dump ();
-private:
+ private:
off_t pos;
void *membuffer;
size_t msize;
- BOOL eof;
+ bool eof;
};
class fhandler_windows: public fhandler_base
{
-private:
+ private:
HWND hWnd_; // the window whose messages are to be retrieved by read() call
int method_; // write method (Post or Send)
-public:
- fhandler_windows (const char *name = 0);
+ public:
+ fhandler_windows ();
int is_windows (void) { return 1; }
- int open (const char *path, int flags, mode_t mode = 0);
+ int open (path_conv *, int flags, mode_t mode = 0);
int write (const void *ptr, size_t len);
- int read (void *ptr, size_t len);
+ int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (3)));
int ioctl (unsigned int cmd, void *);
off_t lseek (off_t, int) { return 0; }
int close (void) { return 0; }
@@ -1001,24 +1001,23 @@ public:
select_record *select_read (select_record *s);
select_record *select_write (select_record *s);
select_record *select_except (select_record *s);
- int ready_for_read (int fd, DWORD howlong, int ignra);
};
class fhandler_dev_dsp : public fhandler_base
{
-private:
+ private:
int audioformat_;
int audiofreq_;
int audiobits_;
int audiochannels_;
bool setupwav(const char *pData, int nBytes);
-public:
- fhandler_dev_dsp (const char *name = 0);
+ public:
+ fhandler_dev_dsp ();
~fhandler_dev_dsp();
- int open (const char *path, int flags, mode_t mode = 0);
+ int open (path_conv *, int flags, mode_t mode = 0);
int write (const void *ptr, size_t len);
- int read (void *ptr, size_t len);
+ int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (3)));
int ioctl (unsigned int cmd, void *);
off_t lseek (off_t, int);
int close (void);
@@ -1027,30 +1026,42 @@ public:
void fixup_after_exec (HANDLE);
};
-#if 0
-/* You can't do this */
typedef union
{
- fhandler_normal normal;
- fhandler_dev_null dev_null;
- fhandler bare;
- fhandler_serial tty;
+ char base[sizeof(fhandler_base)];
+ char console[sizeof(fhandler_console)];
+ char dev_clipboard[sizeof(fhandler_dev_clipboard)];
+ char dev_dsp[sizeof(fhandler_dev_dsp)];
+ char dev_floppy[sizeof(fhandler_dev_floppy)];
+ char dev_mem[sizeof(fhandler_dev_mem)];
+ char dev_null[sizeof(fhandler_dev_null)];
+ char dev_random[sizeof(fhandler_dev_random)];
+ char dev_raw[sizeof(fhandler_dev_raw)];
+ char dev_tape[sizeof(fhandler_dev_tape)];
+ char dev_zero[sizeof(fhandler_dev_zero)];
+ char disk_file[sizeof(fhandler_disk_file)];
+ char pipe[sizeof(fhandler_pipe)];
+ char pty_master[sizeof(fhandler_pty_master)];
+ char serial[sizeof(fhandler_serial)];
+ char socket[sizeof(fhandler_socket)];
+ char termios[sizeof(fhandler_termios)];
+ char tty_common[sizeof(fhandler_tty_common)];
+ char tty_master[sizeof(fhandler_tty_master)];
+ char tty_slave[sizeof(fhandler_tty_slave)];
+ char windows[sizeof(fhandler_windows)];
} fhandler_union;
-#else
-#define fhandler_union fhandler_console
-#endif
+
struct select_record
{
int fd;
HANDLE h;
fhandler_base *fh;
- BOOL saw_error;
- BOOL windows_handle;
- BOOL read_ready, write_ready, except_ready;
- BOOL read_selected, write_selected, except_selected;
+ bool saw_error;
+ bool windows_handle;
+ bool read_ready, write_ready, except_ready;
+ bool read_selected, write_selected, except_selected;
int (*startup) (select_record *me, class select_stuff *stuff);
- int (*poll) (select_record *me, fd_set *readfds, fd_set *writefds,
- fd_set *exceptfds);
+ int (*peek) (select_record *, bool);
int (*verify) (select_record *me, fd_set *readfds, fd_set *writefds,
fd_set *exceptfds);
void (*cleanup) (select_record *me, class select_stuff *stuff);
@@ -1060,19 +1071,19 @@ struct select_record
fh (in_fh), saw_error (0), windows_handle (0),
read_ready (0), write_ready (0), except_ready (0),
read_selected (0), write_selected (0), except_selected (0),
- startup (NULL), poll (NULL), verify (NULL), cleanup (NULL),
+ startup (NULL), peek (NULL), verify (NULL), cleanup (NULL),
next (NULL) {}
};
class select_stuff
{
-public:
+ public:
~select_stuff ();
select_stuff (): always_ready (0), windows_used (0), start (0)
{
memset (device_specific, 0, sizeof (device_specific));
}
- BOOL always_ready, windows_used;
+ bool always_ready, windows_used;
select_record start;
void *device_specific[FH_NDEV];
diff --git a/winsup/cygwin/fhandler_clipboard.cc b/winsup/cygwin/fhandler_clipboard.cc
index 6a22855aa..69065865a 100644
--- a/winsup/cygwin/fhandler_clipboard.cc
+++ b/winsup/cygwin/fhandler_clipboard.cc
@@ -32,14 +32,10 @@ static const NO_COPY char *CYGWIN_NATIVE = "CYGWIN_NATIVE_CLIPBOARD";
/* this is MT safe because windows format id's are atomic */
static UINT cygnativeformat;
-fhandler_dev_clipboard::fhandler_dev_clipboard (const char *name):
-fhandler_base (FH_CLIPBOARD, name)
+fhandler_dev_clipboard::fhandler_dev_clipboard ()
+ : fhandler_base (FH_CLIPBOARD), pos (0), membuffer (NULL), msize (0),
+ eof (true)
{
- set_cb (sizeof *this);
- eof = true;
- pos = 0;
- membuffer = NULL;
- msize = 0;
/* FIXME: check for errors and loop until we can open the clipboard */
OpenClipboard (NULL);
cygnativeformat = RegisterClipboardFormat (CYGWIN_NATIVE);
@@ -56,7 +52,7 @@ fhandler_dev_clipboard::dup (fhandler_base * child)
{
fhandler_dev_clipboard *fhc = (fhandler_dev_clipboard *) child;
- if (!fhc->open (get_name (), get_flags (), 0))
+ if (!fhc->open (NULL, get_flags (), 0))
system_printf ("error opening clipboard, %E");
fhc->membuffer = membuffer;
@@ -67,7 +63,7 @@ fhandler_dev_clipboard::dup (fhandler_base * child)
}
int
-fhandler_dev_clipboard::open (const char *, int flags, mode_t)
+fhandler_dev_clipboard::open (path_conv *, int flags, mode_t)
{
set_flags (flags);
eof = false;
@@ -188,7 +184,7 @@ fhandler_dev_clipboard::write (const void *buf, size_t len)
}
}
-int
+int __stdcall
fhandler_dev_clipboard::read (void *ptr, size_t len)
{
HGLOBAL hglb;
diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc
index 9dd98e7f8..3598810cb 100644
--- a/winsup/cygwin/fhandler_console.cc
+++ b/winsup/cygwin/fhandler_console.cc
@@ -104,7 +104,7 @@ get_tty_stuff (int flags = 0)
if (shared_console_info)
return shared_console_info;
- shared_console_info = (tty_min *) open_shared (NULL, cygheap->console_h,
+ shared_console_info = (tty_min *) open_shared (NULL, 0, cygheap->console_h,
sizeof (*shared_console_info),
NULL);
ProtectHandle (cygheap->console_h);
@@ -195,12 +195,9 @@ fhandler_console::set_cursor_maybe ()
}
}
-int
+int __stdcall
fhandler_console::read (void *pv, size_t buflen)
{
- if (!buflen)
- return 0;
-
HANDLE h = get_io_handle ();
#define buf ((char *) pv)
@@ -310,7 +307,7 @@ fhandler_console::read (void *pv, size_t buflen)
tmp[1] = ich;
/* Need this check since US code page seems to have a bug when
converting a CTRL-U. */
- if ((unsigned char)ich > 0x7f)
+ if ((unsigned char) ich > 0x7f)
con_to_str (tmp + 1, tmp + 1, 1);
/* Determine if the keystroke is modified by META. The tricky
part is to distinguish whether the right Alt key should be
@@ -542,7 +539,7 @@ fhandler_console::scroll_screen (int x1, int y1, int x2, int y2, int xn, int yn)
}
int
-fhandler_console::open (const char *, int flags, mode_t)
+fhandler_console::open (path_conv *, int flags, mode_t)
{
HANDLE h;
@@ -617,7 +614,7 @@ fhandler_console::dup (fhandler_base *child)
{
fhandler_console *fhc = (fhandler_console *) child;
- if (!fhc->open (get_name (), get_flags () & ~O_NOCTTY, 0))
+ if (!fhc->open (NULL, get_flags () & ~O_NOCTTY, 0))
system_printf ("error opening console, %E");
fhc->default_color = default_color;
@@ -858,29 +855,21 @@ fhandler_console::tcgetattr (struct termios *t)
return res;
}
-/*
- * Constructor.
- */
-
-fhandler_console::fhandler_console (const char *name) :
- fhandler_termios (FH_CONSOLE, name, -1)
+fhandler_console::fhandler_console () :
+ fhandler_termios (FH_CONSOLE, -1),
+ default_color (FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE),
+ underline_color (FOREGROUND_GREEN | FOREGROUND_BLUE),
+ dim_color (FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE),
+ meta_mask (LEFT_ALT_PRESSED), state_ (normal), nargs_ (0), savex (0),
+ savey (0), savebuf (NULL), dwLastButtonState (0), nModifiers (0),
+ insert_mode (false), use_mouse (false), raw_win32_keyboard_mode (false)
{
- set_cb (sizeof *this);
- default_color = dim_color = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
- underline_color = FOREGROUND_GREEN | FOREGROUND_BLUE;
- state_ = normal;
- nargs_ = 0;
for (int i = 0; i < MAXARGS; i++) args_ [i] = 0;
- savex = savey = 0;
savebufsiz.X = savebufsiz.Y = 0;
- savebuf = NULL;
scroll_region.Top = 0;
scroll_region.Bottom = -1;
dwLastCursorPosition.X = -1;
dwLastCursorPosition.Y = -1;
- dwLastButtonState = 0;
- nModifiers = 0;
- insert_mode = use_mouse = raw_win32_keyboard_mode = FALSE;
/* Set the mask that determines if an input keystroke is modified by
META. We set this based on the keyboard layout language loaded
for the current thread. The left <ALT> key always generates
@@ -890,7 +879,6 @@ fhandler_console::fhandler_console (const char *name) :
language-specific characters (umlaut, accent grave, etc.). On
these keyboards right <ALT> (called AltGr) is used to produce the
shell symbols and should not be interpreted as META. */
- meta_mask = LEFT_ALT_PRESSED;
if (PRIMARYLANGID (LOWORD (GetKeyboardLayout (0))) == LANG_ENGLISH)
meta_mask |= RIGHT_ALT_PRESSED;
@@ -1647,7 +1635,7 @@ fhandler_console::write (const void *vsrc, size_t len)
static struct {
int vk;
const char *val[4];
-} const keytable[] NO_COPY = {
+} keytable[] NO_COPY = {
/* NORMAL */ /* SHIFT */ /* CTRL */ /* ALT */
{VK_LEFT, {"\033[D", "\033[D", "\033[D", "\033\033[D"}},
{VK_RIGHT, {"\033[C", "\033[C", "\033[C", "\033\033[C"}},
@@ -1723,7 +1711,7 @@ fhandler_console::init (HANDLE f, DWORD a, mode_t bin)
mode = O_WRONLY;
if (a == (GENERIC_READ | GENERIC_WRITE))
mode = O_RDWR;
- open (0, mode);
+ open ((path_conv *) NULL, mode);
if (f != INVALID_HANDLE_VALUE)
CloseHandle (f); /* Reopened by open */
@@ -1752,7 +1740,7 @@ fhandler_console::fixup_after_fork (HANDLE)
/* Windows does not allow duplication of console handles between processes
so open the console explicitly. */
- if (!open (get_name (), O_NOCTTY | get_flags (), 0))
+ if (!open (NULL, O_NOCTTY | get_flags (), 0))
system_printf ("error opening console after fork, %E");
if (!get_close_on_exec ())
@@ -1782,7 +1770,7 @@ fhandler_console::fixup_after_exec (HANDLE)
HANDLE h = get_handle ();
HANDLE oh = get_output_handle ();
- if (!open (get_name (), O_NOCTTY | get_flags (), 0))
+ if (!open (NULL, O_NOCTTY | get_flags (), 0))
{
int sawerr = 0;
if (!get_io_handle ())
diff --git a/winsup/cygwin/fhandler_dsp.cc b/winsup/cygwin/fhandler_dsp.cc
index 914caeec8..e380b3e46 100644
--- a/winsup/cygwin/fhandler_dsp.cc
+++ b/winsup/cygwin/fhandler_dsp.cc
@@ -420,10 +420,9 @@ fhandler_dev_dsp::setupwav (const char *pData, int nBytes)
}
//------------------------------------------------------------------------
-fhandler_dev_dsp::fhandler_dev_dsp (const char *name):
- fhandler_base (FH_OSS_DSP, name)
+fhandler_dev_dsp::fhandler_dev_dsp ():
+ fhandler_base (FH_OSS_DSP)
{
- set_cb (sizeof *this);
}
fhandler_dev_dsp::~fhandler_dev_dsp ()
@@ -431,7 +430,7 @@ fhandler_dev_dsp::~fhandler_dev_dsp ()
}
int
-fhandler_dev_dsp::open (const char *path, int flags, mode_t mode = 0)
+fhandler_dev_dsp::open (path_conv *, int flags, mode_t mode = 0)
{
// currently we only support writing
if ((flags & (O_WRONLY | O_RDONLY | O_RDWR)) != O_WRONLY)
@@ -443,14 +442,11 @@ fhandler_dev_dsp::open (const char *path, int flags, mode_t mode = 0)
s_audio = new (audio_buf) Audio;
// Work out initial sample format & frequency
- if (strcmp (path, "/dev/dsp") == 0L)
- {
// dev/dsp defaults
- audioformat_ = AFMT_S8;
- audiofreq_ = 8000;
- audiobits_ = 8;
- audiochannels_ = 1;
- }
+ audioformat_ = AFMT_S8;
+ audiofreq_ = 8000;
+ audiobits_ = 8;
+ audiochannels_ = 1;
if (!s_audio->open (audiofreq_, audiobits_, audiochannels_))
debug_printf ("/dev/dsp: failed to open\n");
@@ -480,7 +476,7 @@ fhandler_dev_dsp::write (const void *ptr, size_t len)
return len;
}
-int
+int __stdcall
fhandler_dev_dsp::read (void *ptr, size_t len)
{
return len;
@@ -529,7 +525,7 @@ fhandler_dev_dsp::ioctl (unsigned int cmd, void *ptr)
CASE (SNDCTL_DSP_GETBLKSIZE)
*intptr = Audio::BLOCK_SIZE;
- break;
+ return 0;
CASE (SNDCTL_DSP_SETFMT)
{
diff --git a/winsup/cygwin/fhandler_floppy.cc b/winsup/cygwin/fhandler_floppy.cc
index 994bba9f1..193e75a37 100644
--- a/winsup/cygwin/fhandler_floppy.cc
+++ b/winsup/cygwin/fhandler_floppy.cc
@@ -40,13 +40,12 @@ fhandler_dev_floppy::is_eof (int)
return ret;
}
-fhandler_dev_floppy::fhandler_dev_floppy (const char *name, int unit) : fhandler_dev_raw (FH_FLOPPY, name, unit)
+fhandler_dev_floppy::fhandler_dev_floppy (int unit) : fhandler_dev_raw (FH_FLOPPY, unit)
{
- set_cb (sizeof *this);
}
int
-fhandler_dev_floppy::open (const char *path, int flags, mode_t)
+fhandler_dev_floppy::open (path_conv *real_path, int flags, mode_t)
{
/* The correct size of the buffer would be 512 bytes,
* which is the atomic size, supported by WinNT.
@@ -61,7 +60,7 @@ fhandler_dev_floppy::open (const char *path, int flags, mode_t)
* and cpio buffer sizes by default!
*/
devbufsiz = 61440L; /* 512L; */
- return fhandler_dev_raw::open (path, flags);
+ return fhandler_dev_raw::open (real_path, flags);
}
int
diff --git a/winsup/cygwin/fhandler_mem.cc b/winsup/cygwin/fhandler_mem.cc
index b6b461a62..14cdac0be 100644
--- a/winsup/cygwin/fhandler_mem.cc
+++ b/winsup/cygwin/fhandler_mem.cc
@@ -23,9 +23,8 @@
/**********************************************************************/
/* fhandler_dev_mem */
-fhandler_dev_mem::fhandler_dev_mem (const char *name, int nunit)
-: fhandler_base (FH_MEM, name),
- unit (nunit)
+fhandler_dev_mem::fhandler_dev_mem (int nunit)
+ : fhandler_base (FH_MEM), unit (nunit)
{
/* Reading physical memory only supported on NT/W2K. */
if (!wincap.has_physical_mem_access ())
@@ -72,7 +71,7 @@ fhandler_dev_mem::~fhandler_dev_mem (void)
}
int
-fhandler_dev_mem::open (const char *, int flags, mode_t)
+fhandler_dev_mem::open (path_conv *, int flags, mode_t)
{
if (!wincap.has_physical_mem_access ())
{
@@ -178,7 +177,7 @@ fhandler_dev_mem::write (const void *ptr, size_t ulen)
return ulen;
}
-int
+int __stdcall
fhandler_dev_mem::read (void *ptr, size_t ulen)
{
if (!ulen || pos >= mem_size)
@@ -403,23 +402,15 @@ fhandler_dev_mem::fixup_mmap_after_fork (HANDLE h, DWORD access, DWORD offset,
}
int
-fhandler_dev_mem::fstat (struct stat *buf)
+fhandler_dev_mem::fstat (struct stat *buf, path_conv *pc)
{
- if (!buf)
- {
- set_errno (EINVAL);
- return -1;
- }
-
- memset (buf, 0, sizeof *buf);
+ this->fhandler_base::fstat (buf, pc);
buf->st_mode = S_IFCHR;
- if (!wincap.has_physical_mem_access ())
+ if (wincap.has_physical_mem_access ())
buf->st_mode |= S_IRUSR | S_IWUSR |
S_IRGRP | S_IWGRP |
S_IROTH | S_IWOTH;
- buf->st_nlink = 1;
buf->st_blksize = getpagesize ();
- buf->st_dev = buf->st_rdev = get_device () << 8 | (unit & 0xff);
return 0;
}
diff --git a/winsup/cygwin/fhandler_random.cc b/winsup/cygwin/fhandler_random.cc
index 71e9d5822..8f43b600c 100644
--- a/winsup/cygwin/fhandler_random.cc
+++ b/winsup/cygwin/fhandler_random.cc
@@ -23,16 +23,13 @@ details. */
#define PSEUDO_MULTIPLIER (6364136223846793005LL)
#define PSEUDO_SHIFTVAL (21)
-fhandler_dev_random::fhandler_dev_random (const char *name, int nunit)
- : fhandler_base (FH_RANDOM, name),
- unit(nunit),
- crypt_prov((HCRYPTPROV)NULL)
+fhandler_dev_random::fhandler_dev_random (int nunit)
+ : fhandler_base (FH_RANDOM), unit(nunit), crypt_prov((HCRYPTPROV) NULL)
{
- set_cb (sizeof *this);
}
int
-fhandler_dev_random::open (const char *, int flags, mode_t)
+fhandler_dev_random::open (path_conv *, int flags, mode_t)
{
set_flags (flags);
set_open_status ();
@@ -112,7 +109,7 @@ fhandler_dev_random::pseudo_read (void *ptr, size_t len)
return len;
}
-int
+int __stdcall
fhandler_dev_random::read (void *ptr, size_t len)
{
if (!len)
diff --git a/winsup/cygwin/fhandler_raw.cc b/winsup/cygwin/fhandler_raw.cc
index 20f2de513..7cbbe0a53 100644
--- a/winsup/cygwin/fhandler_raw.cc
+++ b/winsup/cygwin/fhandler_raw.cc
@@ -16,6 +16,7 @@
#include <cygwin/rdevio.h>
#include <sys/mtio.h>
+#include <ntdef.h>
#include "cygerrno.h"
#include "perprocess.h"
#include "security.h"
@@ -23,6 +24,7 @@
#include "path.h"
#include "dtable.h"
#include "cygheap.h"
+#include "ntdll.h"
/* static wrapper functions to hide the effect of media changes and
bus resets which occurs after a new media is inserted. This is
@@ -84,7 +86,6 @@ fhandler_dev_raw::clear (void)
eof_detected = 0;
lastblk_to_read = 0;
varblkop = 0;
- unit = 0;
}
int
@@ -116,10 +117,10 @@ fhandler_dev_raw::writebuf (void)
return ret;
}
-fhandler_dev_raw::fhandler_dev_raw (DWORD devtype, const char *name, int unit) : fhandler_base (devtype, name)
+fhandler_dev_raw::fhandler_dev_raw (DWORD devtype, int nunit)
+ : fhandler_base (devtype), unit (nunit)
{
clear ();
- this->unit = unit;
set_need_fork_fixup ();
}
@@ -131,25 +132,59 @@ fhandler_dev_raw::~fhandler_dev_raw (void)
}
int
-fhandler_dev_raw::open (const char *path, int flags, mode_t)
+fhandler_dev_raw::open (path_conv *real_path, int flags, mode_t)
{
- path_conv real_path (path, PC_SYM_IGNORE);
- int ret;
+ if (!wincap.has_raw_devices ())
+ {
+ set_errno (ENOENT);
+ debug_printf("%s is accessible under NT/W2K only",real_path->get_win32());
+ return 0;
+ }
- set_name (path, real_path.get_win32 ());
+ /* Check for illegal flags. */
+ if (flags & (O_APPEND | O_EXCL))
+ {
+ set_errno (EINVAL);
+ return 0;
+ }
/* Always open a raw device existing and binary. */
flags &= ~(O_CREAT | O_TRUNC);
flags |= O_BINARY;
- ret = fhandler_base::open (path, flags);
- if (ret)
+
+ DWORD access = GENERIC_READ | SYNCHRONIZE;
+ if (get_device () == FH_TAPE
+ || (flags & (O_RDONLY | O_WRONLY | O_RDWR)) == O_WRONLY
+ || (flags & (O_RDONLY | O_WRONLY | O_RDWR)) == O_RDWR)
+ access |= GENERIC_WRITE;
+
+ extern void str2buf2uni (UNICODE_STRING &, WCHAR *, const char *);
+ UNICODE_STRING dev;
+ WCHAR devname[MAX_PATH + 1];
+ str2buf2uni (dev, devname, real_path->get_win32 ());
+ OBJECT_ATTRIBUTES attr;
+ InitializeObjectAttributes (&attr, &dev, OBJ_CASE_INSENSITIVE, NULL, NULL);
+
+ HANDLE h;
+ IO_STATUS_BLOCK io;
+ NTSTATUS status = NtOpenFile (&h, access, &attr, &io, wincap.shared (),
+ FILE_SYNCHRONOUS_IO_NONALERT);
+ if (!NT_SUCCESS (status))
{
- if (devbufsiz > 1L)
- devbuf = new char [devbufsiz];
+ set_errno (RtlNtStatusToDosError (status));
+ debug_printf ("NtOpenFile: NTSTATUS: %d, Win32: %E", status);
+ return 0;
}
- else
- devbufsiz = 0;
- return ret;
+
+ set_io_handle (h);
+ set_flags (flags);
+ set_r_binary (O_BINARY);
+ set_w_binary (O_BINARY);
+
+ if (devbufsiz > 1L)
+ devbuf = new char [devbufsiz];
+
+ return 1;
}
int
@@ -159,27 +194,6 @@ fhandler_dev_raw::close (void)
}
int
-fhandler_dev_raw::fstat (struct stat *buf)
-{
- if (!buf)
- {
- set_errno (EINVAL);
- return -1;
- }
-
- memset (buf, 0, sizeof *buf);
- buf->st_mode = S_IFCHR |
- S_IRUSR | S_IWUSR |
- S_IRGRP | S_IWGRP |
- S_IROTH | S_IWOTH;
- buf->st_nlink = 1;
- buf->st_blksize = devbuf ? devbufsiz : 1;
- buf->st_dev = buf->st_rdev = get_device () << 8 | (unit & 0xff);
-
- return 0;
-}
-
-int
fhandler_dev_raw::raw_read (void *ptr, size_t ulen)
{
DWORD bytes_read = 0;
diff --git a/winsup/cygwin/fhandler_serial.cc b/winsup/cygwin/fhandler_serial.cc
index 20ad4d8e1..b4a813b04 100644
--- a/winsup/cygwin/fhandler_serial.cc
+++ b/winsup/cygwin/fhandler_serial.cc
@@ -24,13 +24,9 @@ details. */
/**********************************************************************/
/* fhandler_serial */
-fhandler_serial::fhandler_serial (const char *name, DWORD devtype, int unit) :
- fhandler_base (devtype, name, unit)
+fhandler_serial::fhandler_serial (int unit)
+ : fhandler_base (FH_SERIAL, unit), vmin_ (0), vtime_ (0), pgrp_ (myself->pgid)
{
- set_cb (sizeof *this);
- vmin_ = 0;
- vtime_ = 0;
- pgrp_ = myself->pgid;
set_need_fork_fixup ();
}
@@ -64,7 +60,6 @@ fhandler_serial::raw_read (void *ptr, size_t ulen)
for (n = 0, tot = 0; ulen; ulen -= n, ptr = (char *)ptr + n)
{
- DWORD ev;
COMSTAT st;
DWORD inq = 1;
@@ -212,7 +207,7 @@ fhandler_serial::init (HANDLE f, DWORD flags, mode_t bin)
}
int
-fhandler_serial::open (const char *name, int flags, mode_t mode)
+fhandler_serial::open (path_conv *, int flags, mode_t mode)
{
int res;
COMMTIMEOUTS to;
@@ -221,10 +216,10 @@ fhandler_serial::open (const char *name, int flags, mode_t mode)
syscall_printf ("fhandler_serial::open (%s, %p, %p)",
get_name (), flags, mode);
- if (name && !(res = this->fhandler_base::open (flags, mode)))
+ if (!(res = this->fhandler_base::open (NULL, flags, mode)))
return 0;
- else
- res = 1;
+
+ res = 1;
(void) SetCommMask (get_handle (), EV_RXCHAR);
@@ -378,7 +373,6 @@ fhandler_serial::tcflush (int queue)
(we stop after 1000 chars anyway) */
for (int max = 1000; max > 0; max--)
{
- DWORD ev;
COMSTAT st;
if (!PurgeComm (get_handle (), PURGE_RXABORT | PURGE_RXCLEAR))
break;
diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc
index a34272f6a..b62a203bf 100644
--- a/winsup/cygwin/fhandler_socket.cc
+++ b/winsup/cygwin/fhandler_socket.cc
@@ -1,6 +1,6 @@
/* fhandler_socket.cc. See fhandler.h for a description of the fhandler classes.
- Copyright 2000, 2001 Red Hat, Inc.
+ Copyright 2000, 2001, 2002 Red Hat, Inc.
This file is part of Cygwin.
@@ -41,12 +41,11 @@ fhandler_dev_random* entropy_source;
/**********************************************************************/
/* fhandler_socket */
-fhandler_socket::fhandler_socket (const char *name) :
- fhandler_base (FH_SOCKET, name)
+fhandler_socket::fhandler_socket ()
+ : fhandler_base (FH_SOCKET), sun_path (NULL)
{
- set_cb (sizeof *this);
set_need_fork_fixup ();
- prot_info_ptr = (LPWSAPROTOCOL_INFOA) cmalloc (HEAP_BUF,
+ prot_info_ptr = (LPWSAPROTOCOL_INFOA) cmalloc (HEAP_BUF,
sizeof (WSAPROTOCOL_INFOA));
}
@@ -54,6 +53,8 @@ fhandler_socket::~fhandler_socket ()
{
if (prot_info_ptr)
cfree (prot_info_ptr);
+ if (sun_path)
+ cfree (sun_path);
}
void
@@ -62,11 +63,10 @@ fhandler_socket::set_connect_secret ()
if (!entropy_source)
{
void *buf = malloc (sizeof (fhandler_dev_random));
- entropy_source = new (buf) fhandler_dev_random (ENTROPY_SOURCE_NAME,
- ENTROPY_SOURCE_DEV_UNIT);
+ entropy_source = new (buf) fhandler_dev_random (ENTROPY_SOURCE_DEV_UNIT);
}
if (entropy_source &&
- !entropy_source->open (ENTROPY_SOURCE_NAME, O_RDONLY))
+ !entropy_source->open (NULL, O_RDONLY))
{
delete entropy_source;
entropy_source = NULL;
@@ -115,8 +115,13 @@ fhandler_socket::create_secret_event (int* secret)
void
fhandler_socket::signal_secret_event ()
{
- if (secret_event)
- SetEvent (secret_event);
+ if (!secret_event)
+ debug_printf ("no secret event?");
+ else
+ {
+ SetEvent (secret_event);
+ debug_printf ("signaled secret_event");
+ }
}
void
@@ -160,54 +165,51 @@ fhandler_socket::check_peer_secret_event (struct sockaddr_in* peer, int* secret)
void
fhandler_socket::fixup_before_fork_exec (DWORD win_proc_id)
{
- int ret = 1;
-
- if (prot_info_ptr &&
- (ret = WSADuplicateSocketA (get_socket (), win_proc_id, prot_info_ptr)))
+ if (!winsock2_active)
{
- debug_printf ("WSADuplicateSocket error");
- set_winsock_errno ();
- }
- if (!ret && ws2_32_handle)
- {
- debug_printf ("WSADuplicateSocket went fine, dwServiceFlags1=%d",
- prot_info_ptr->dwServiceFlags1);
+ fhandler_base::fixup_before_fork_exec (win_proc_id);
+ debug_printf ("Without Winsock 2.0");
}
+ else if (!WSADuplicateSocketA (get_socket (), win_proc_id, prot_info_ptr))
+ debug_printf ("WSADuplicateSocket went fine, sock %p, win_proc_id %d, prot_info_ptr %p",
+ get_socket (), win_proc_id, prot_info_ptr);
else
{
- fhandler_base::fixup_before_fork_exec (win_proc_id);
- debug_printf ("Without Winsock 2.0");
+ debug_printf ("WSADuplicateSocket error, sock %p, win_proc_id %d, prot_info_ptr %p",
+ get_socket (), win_proc_id, prot_info_ptr);
+ set_winsock_errno ();
}
}
+extern "C" void __stdcall load_wsock32 ();
void
fhandler_socket::fixup_after_fork (HANDLE parent)
{
- SOCKET new_sock = INVALID_SOCKET;
+ SOCKET new_sock;
debug_printf ("WSASocket begin, dwServiceFlags1=%d",
prot_info_ptr->dwServiceFlags1);
- if (prot_info_ptr &&
- (new_sock = WSASocketA (FROM_PROTOCOL_INFO,
- FROM_PROTOCOL_INFO,
- FROM_PROTOCOL_INFO,
- prot_info_ptr, 0, 0)) == INVALID_SOCKET)
+
+ if ((new_sock = WSASocketA (FROM_PROTOCOL_INFO,
+ FROM_PROTOCOL_INFO,
+ FROM_PROTOCOL_INFO,
+ prot_info_ptr, 0, 0)) == INVALID_SOCKET)
{
debug_printf ("WSASocket error");
set_winsock_errno ();
}
- if (new_sock != INVALID_SOCKET && ws2_32_handle)
+ else if (!new_sock && !winsock2_active)
{
- debug_printf ("WSASocket went fine");
- set_io_handle ((HANDLE) new_sock);
+ load_wsock32 ();
+ fhandler_base::fixup_after_fork (parent);
+ debug_printf ("Without Winsock 2.0");
}
else
{
-#if 0
- fhandler_base::fixup_after_fork (parent);
-#endif
- debug_printf ("Without Winsock 2.0");
+ debug_printf ("WSASocket went fine new_sock %p, old_sock %p", new_sock, get_io_handle ());
+ set_io_handle ((HANDLE) new_sock);
}
+
if (secret_event)
fork_fixup (parent, secret_event, "secret_event");
}
@@ -215,21 +217,25 @@ fhandler_socket::fixup_after_fork (HANDLE parent)
void
fhandler_socket::fixup_after_exec (HANDLE parent)
{
- extern WSADATA wsadata;
+ debug_printf ("here");
if (!get_close_on_exec ())
fixup_after_fork (parent);
- else if (wsadata.wVersion < 512) /* < Winsock 2.0 */
+#if 0
+ else if (!winsock2_active)
closesocket (get_socket ());
+#endif
}
int
fhandler_socket::dup (fhandler_base *child)
{
+ debug_printf ("here");
fhandler_socket *fhs = (fhandler_socket *) child;
fhs->addr_family = addr_family;
fhs->set_io_handle (get_io_handle ());
+
fhs->fixup_before_fork_exec (GetCurrentProcessId ());
- if (ws2_32_handle)
+ if (winsock2_active)
{
fhs->fixup_after_fork (hMainProc);
return 0;
@@ -237,15 +243,21 @@ fhandler_socket::dup (fhandler_base *child)
return fhandler_base::dup (child);
}
-int
+int __stdcall
+fhandler_socket::fstat (struct stat *buf, path_conv *pc)
+{
+ fhandler_disk_file fh;
+ fh.set_name (get_name (), get_win32_name ());
+ return fh.fstat (buf, pc);
+}
+
+int __stdcall
fhandler_socket::read (void *ptr, size_t len)
{
sigframe thisframe (mainthread);
int res = recv (get_socket (), (char *) ptr, len, 0);
if (res == SOCKET_ERROR)
- {
- set_winsock_errno ();
- }
+ set_winsock_errno ();
return res;
}
@@ -279,7 +291,10 @@ fhandler_socket::close ()
setsockopt (get_socket (), SOL_SOCKET, SO_LINGER,
(const char *)&linger, sizeof linger);
- if (closesocket (get_socket ()))
+ while ((res = closesocket (get_socket ()))
+ && WSAGetLastError () == WSAEWOULDBLOCK)
+ continue;
+ if (res)
{
set_winsock_errno ();
res = -1;
@@ -414,7 +429,7 @@ fhandler_socket::ioctl (unsigned int cmd, void *p)
if (cmd == FIONBIO)
{
syscall_printf ("socket is now %sblocking",
- *(int *) p ? "un" : "");
+ *(int *) p ? "non" : "");
/* Start AsyncSelect if async socket unblocked */
if (*(int *) p && get_async ())
WSAAsyncSelect (get_socket (), gethwnd (), WM_ASYNCIO, ASYNC_MASK);
@@ -460,11 +475,16 @@ fhandler_socket::fcntl (int cmd, void *arg)
void
fhandler_socket::set_close_on_exec (int val)
{
-#if 0
- extern WSADATA wsadata;
- if (wsadata.wVersion < 512) /* < Winsock 2.0 */
+ if (!winsock2_active) /* < Winsock 2.0 */
set_inheritance (get_handle (), val);
-#endif
set_close_on_exec_flag (val);
debug_printf ("set close_on_exec for %s to %d", get_name (), val);
}
+
+void
+fhandler_socket::set_sun_path (const char *path)
+{
+ if (sun_path)
+ cfree (sun_path);
+ sun_path = cstrdup (path);
+}
diff --git a/winsup/cygwin/fhandler_tape.cc b/winsup/cygwin/fhandler_tape.cc
index 48561351a..558dc0bad 100644
--- a/winsup/cygwin/fhandler_tape.cc
+++ b/winsup/cygwin/fhandler_tape.cc
@@ -29,7 +29,6 @@ details. */
void
fhandler_dev_tape::clear (void)
{
- norewind = 0;
lasterr = 0;
fhandler_dev_raw::clear ();
}
@@ -55,34 +54,27 @@ fhandler_dev_tape::is_eof (int win_error)
return ret;
}
-fhandler_dev_tape::fhandler_dev_tape (const char *name, int unit) : fhandler_dev_raw (FH_TAPE, name, unit)
+fhandler_dev_tape::fhandler_dev_tape (int unit)
+ : fhandler_dev_raw (FH_TAPE, unit)
{
- set_cb (sizeof *this);
+ debug_printf ("unit: %d", unit);
}
int
-fhandler_dev_tape::open (const char *path, int flags, mode_t)
+fhandler_dev_tape::open (path_conv *real_path, int flags, mode_t)
{
int ret;
- int minor;
- if (get_device_number (path, minor) != FH_TAPE)
- {
- set_errno (EINVAL);
- return -1;
- }
-
- norewind = (minor >= 128);
devbufsiz = 1L;
- ret = fhandler_dev_raw::open (path, flags);
+ ret = fhandler_dev_raw::open (real_path, flags);
if (ret)
{
struct mtget get;
struct mtop op;
struct mtpos pos;
- if (! ioctl (MTIOCGET, &get))
+ if (!ioctl (MTIOCGET, &get))
/* Tape drive supports and is set to variable block size. */
if (get.mt_dsreg == 0)
devbufsiz = get.mt_maxblksize;
@@ -138,7 +130,7 @@ fhandler_dev_tape::close (void)
// To protected reads on signaling (e.g. Ctrl-C)
eof_detected = 1;
- if (! norewind)
+ if (is_rewind_device ())
{
debug_printf ("rewinding\n");
op.mt_op = MTREW;
@@ -155,11 +147,11 @@ fhandler_dev_tape::close (void)
}
int
-fhandler_dev_tape::fstat (struct stat *buf)
+fhandler_dev_tape::fstat (struct stat *buf, path_conv *pc)
{
int ret;
- if (! (ret = fhandler_dev_raw::fstat (buf)))
+ if (!(ret = fhandler_base::fstat (buf, pc)))
{
struct mtget get;
@@ -233,7 +225,6 @@ fhandler_dev_tape::dup (fhandler_base *child)
{
fhandler_dev_tape *fhc = (fhandler_dev_tape *) child;
- fhc->norewind = norewind;
fhc->lasterr = lasterr;
return fhandler_dev_raw::dup (child);
}
@@ -701,7 +692,7 @@ fhandler_dev_tape::tape_set_blocksize (long count)
if (lasterr)
return lasterr;
- if (count < min || count > max)
+ if (count != 0 && (count < min || count > max))
return tape_error (ERROR_INVALID_PARAMETER, "tape_set_blocksize");
mp.BlockSize = count;
@@ -804,6 +795,7 @@ fhandler_dev_tape::tape_status (struct mtget *get)
get->mt_defblksize = dp.DefaultBlockSize;
get->mt_featureslow = dp.FeaturesLow;
get->mt_featureshigh = dp.FeaturesHigh;
+ get->mt_eotwarningzonesize = dp.EOTWarningZoneSize;
return 0;
}
diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index 62d0c91d9..05649125f 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -37,12 +37,9 @@ static DWORD WINAPI process_input (void *); // Input queue thread
static DWORD WINAPI process_output (void *); // Output queue thread
static DWORD WINAPI process_ioctl (void *); // Ioctl requests thread
-fhandler_tty_master::fhandler_tty_master (const char *name, int unit) :
- fhandler_pty_master (name, FH_TTYM, unit)
+fhandler_tty_master::fhandler_tty_master (int unit)
+ : fhandler_pty_master (FH_TTYM, unit), console (NULL), hThread (NULL)
{
- set_cb (sizeof *this);
- console = NULL;
- hThread = NULL;
}
int
@@ -439,26 +436,20 @@ process_ioctl (void *)
/**********************************************************************/
/* Tty slave stuff */
-fhandler_tty_slave::fhandler_tty_slave (int num, const char *name) :
- fhandler_tty_common (FH_TTYS, name, num)
+fhandler_tty_slave::fhandler_tty_slave (int num)
+ : fhandler_tty_common (FH_TTYS, num)
{
- set_cb (sizeof *this);
- ttynum = num;
- debug_printf ("unix '%s', win32 '%s'", unix_path_name, win32_path_name);
- inuse = NULL;
}
-fhandler_tty_slave::fhandler_tty_slave (const char *name) :
- fhandler_tty_common (FH_TTYS, name, 0)
+fhandler_tty_slave::fhandler_tty_slave ()
+ : fhandler_tty_common (FH_TTYS, 0)
{
- set_cb (sizeof *this);
- inuse = NULL;
}
/* FIXME: This function needs to close handles when it has
a failing condition. */
int
-fhandler_tty_slave::open (const char *, int flags, mode_t)
+fhandler_tty_slave::open (path_conv *, int flags, mode_t)
{
tcinit (cygwin_shared->tty[ttynum]);
@@ -677,7 +668,7 @@ fhandler_tty_slave::write (const void *ptr, size_t len)
return towrite;
}
-int
+int __stdcall
fhandler_tty_slave::read (void *ptr, size_t len)
{
DWORD n;
@@ -999,18 +990,13 @@ out:
/*******************************************************
fhandler_pty_master
*/
-fhandler_pty_master::fhandler_pty_master (const char *name, DWORD devtype, int unit) :
- fhandler_tty_common (devtype, name, unit)
+fhandler_pty_master::fhandler_pty_master (DWORD devtype, int unit)
+ : fhandler_tty_common (devtype, unit)
{
- set_cb (sizeof *this);
- ioctl_request_event = NULL;
- ioctl_done_event = NULL;
- pktmode = need_nl = 0;
- inuse = NULL;
}
int
-fhandler_pty_master::open (const char *, int flags, mode_t)
+fhandler_pty_master::open (path_conv *, int flags, mode_t)
{
ttynum = cygwin_shared->tty.allocate_tty (0);
if (ttynum < 0)
@@ -1095,7 +1081,7 @@ fhandler_pty_master::write (const void *ptr, size_t len)
return len;
}
-int
+int __stdcall
fhandler_pty_master::read (void *ptr, size_t len)
{
return process_slave_output ((char *) ptr, len, pktmode);
@@ -1192,15 +1178,9 @@ fhandler_tty_common::fixup_after_fork (HANDLE parent)
if (ioctl_done_event)
fork_fixup (parent, ioctl_done_event, "ioctl_done_event");
if (output_mutex)
- {
- fork_fixup (parent, output_mutex, "output_mutex");
- ProtectHandle (output_mutex);
- }
+ fork_fixup (parent, output_mutex, "output_mutex");
if (input_mutex)
- {
- fork_fixup (parent, input_mutex, "input_mutex");
- ProtectHandle (input_mutex);
- }
+ fork_fixup (parent, input_mutex, "input_mutex");
if (input_available_event)
fork_fixup (parent, input_available_event, "input_available_event");
fork_fixup (parent, inuse, "inuse");
diff --git a/winsup/cygwin/fhandler_windows.cc b/winsup/cygwin/fhandler_windows.cc
index 7a5870f64..861ddefa1 100644
--- a/winsup/cygwin/fhandler_windows.cc
+++ b/winsup/cygwin/fhandler_windows.cc
@@ -46,16 +46,13 @@ The following unix-style calls are supported:
select () call marks read fd when any message posted to queue.
*/
-fhandler_windows::fhandler_windows (const char *name) :
- fhandler_base (FH_WINDOWS, name)
+fhandler_windows::fhandler_windows ()
+ : fhandler_base (FH_WINDOWS), hWnd_ (NULL), method_ (WINDOWS_POST)
{
- set_cb (sizeof *this);
- hWnd_ = NULL;
- method_ = WINDOWS_POST;
}
int
-fhandler_windows::open (const char *, int flags, mode_t)
+fhandler_windows::open (path_conv *, int flags, mode_t)
{
set_flags (flags);
set_close_on_exec_flag (1);
@@ -82,7 +79,7 @@ fhandler_windows::write (const void *buf, size_t)
return SendMessage (ptr->hwnd, ptr->message, ptr->wParam, ptr->lParam);
}
-int
+int __stdcall
fhandler_windows::read (void *buf, size_t len)
{
MSG *ptr = (MSG *) buf;
diff --git a/winsup/cygwin/fhandler_zero.cc b/winsup/cygwin/fhandler_zero.cc
index df864798d..93b4544f3 100644
--- a/winsup/cygwin/fhandler_zero.cc
+++ b/winsup/cygwin/fhandler_zero.cc
@@ -15,14 +15,13 @@ details. */
#include "security.h"
#include "fhandler.h"
-fhandler_dev_zero::fhandler_dev_zero (const char *name)
- : fhandler_base (FH_ZERO, name)
+fhandler_dev_zero::fhandler_dev_zero ()
+ : fhandler_base (FH_ZERO)
{
- set_cb (sizeof *this);
}
int
-fhandler_dev_zero::open (const char *, int flags, mode_t)
+fhandler_dev_zero::open (path_conv *, int flags, mode_t)
{
set_flags (flags);
set_open_status ();
@@ -35,7 +34,7 @@ fhandler_dev_zero::write (const void *, size_t len)
return len;
}
-int
+int __stdcall
fhandler_dev_zero::read (void *ptr, size_t len)
{
memset(ptr, 0, len);
diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc
index e0d9445ac..964ce6193 100644
--- a/winsup/cygwin/fork.cc
+++ b/winsup/cygwin/fork.cc
@@ -218,7 +218,7 @@ sync_with_parent(const char *s, bool hang_self)
WaitForSingleObject (child_proc_info->forker_finished, 1) != WAIT_FAILED)
break;
api_fatal ("WFSO failed for %s, fork_finished %p, %E", s,
- child_proc_info->forker_finished);
+ child_proc_info->forker_finished);
break;
default:
debug_printf ("no problems");
@@ -425,14 +425,14 @@ fork_parent (HANDLE& hParent, dll *&first_dll,
{
CloseHandle (hParent);
CloseHandle (subproc_ready);
- system_printf ("unable to allocate subproc_ready event, %E");
+ system_printf ("unable to allocate forker_finished event, %E");
return -1;
}
ProtectHandle (subproc_ready);
ProtectHandle (forker_finished);
- init_child_info (PROC_FORK1, &ch, 1, subproc_ready);
+ init_child_info (PROC_FORK, &ch, 1, subproc_ready);
ch.forker_finished = forker_finished;
@@ -548,7 +548,7 @@ fork_parent (HANDLE& hParent, dll *&first_dll,
slow_pid_reuse (pi.hProcess);
/* Wait for subproc to initialize itself. */
- if (!sync_with_child(pi, subproc_ready, TRUE, "waiting for longjmp"))
+ if (!sync_with_child (pi, subproc_ready, TRUE, "waiting for longjmp"))
goto cleanup;
/* CHILD IS STOPPED */
@@ -724,6 +724,7 @@ vfork ()
*pp = *esp;
int res = cygheap->fdtab.vfork_child_dup () ? 0 : -1;
debug_printf ("%d = vfork()", res);
+ debug_printf ("exiting vfork, res %d", res);
return res;
}
@@ -746,6 +747,7 @@ vfork ()
int pid = vf->pid;
vf->pid = 0;
+ debug_printf ("exiting vfork, pid %d", pid);
sig_dispatch_pending ();
return pid;
#endif
diff --git a/winsup/cygwin/glob.c b/winsup/cygwin/glob.c
index f50ef8e3c..c8a6ffbaa 100644
--- a/winsup/cygwin/glob.c
+++ b/winsup/cygwin/glob.c
@@ -63,10 +63,6 @@
* Number of matches in the current invocation of glob.
*/
-/* CYGNUS LOCAL: don't include */
-/* #include "namespace.h" */
-/* end CYGNUS LOCAL */
-
#include "winsup.h"
#include <sys/param.h>
@@ -649,7 +645,7 @@ glob3(pathbuf, pathend, pattern, restpattern, pglob)
/*
- * Extend the gl_pathv member of a glob_t structure to accomodate a new item,
+ * Extend the gl_pathv member of a glob_t structure to accommodate a new item,
* add the new item, and update gl_pathc.
*
* This assumes the BSD realloc, which only copies the block when its size
diff --git a/winsup/cygwin/grp.cc b/winsup/cygwin/grp.cc
index 87cc4b484..fee420992 100644
--- a/winsup/cygwin/grp.cc
+++ b/winsup/cygwin/grp.cc
@@ -24,8 +24,8 @@ details. */
#include "fhandler.h"
#include "path.h"
#include "dtable.h"
-#include "cygheap.h"
#include "cygerrno.h"
+#include "cygheap.h"
#include "pwdgrp.h"
/* Read /etc/group only once for better performance. This is done
@@ -198,7 +198,7 @@ read_etc_group ()
debug_printf ("Failed to get local admins group name. %E");
}
- snprintf (linebuf, sizeof (linebuf), "%s::%u:\n", group_name, DEFAULT_GID);
+ snprintf (linebuf, sizeof (linebuf), "%s::%u:\n", group_name, (unsigned) DEFAULT_GID);
add_grp_line (linebuf);
group_state = emulated;
}
diff --git a/winsup/cygwin/heap.cc b/winsup/cygwin/heap.cc
index eaa500c62..9a3e2b87a 100644
--- a/winsup/cygwin/heap.cc
+++ b/winsup/cygwin/heap.cc
@@ -70,14 +70,14 @@ heap_init ()
* to assure contiguous memory. */
cygheap->heapptr = cygheap->heaptop = cygheap->heapbase =
VirtualAlloc(NULL, cygwin_shared->heap_chunk_size (), MEM_RESERVE,
- PAGE_NOACCESS);
+ PAGE_NOACCESS);
if (cygheap->heapbase == NULL)
api_fatal ("2. unable to allocate heap, heap_chunk_size %d, %E",
cygwin_shared->heap_chunk_size ());
}
debug_printf ("heap base %p, heap top %p", cygheap->heapbase,
- cygheap->heaptop);
+ cygheap->heaptop);
page_const--;
malloc_init ();
}
diff --git a/winsup/cygwin/heap.h b/winsup/cygwin/heap.h
index df652ac22..bcea4bae0 100644
--- a/winsup/cygwin/heap.h
+++ b/winsup/cygwin/heap.h
@@ -15,5 +15,5 @@ void heap_init ();
void malloc_init ();
#define inheap(s) \
- (cygheap->heapptr && ((char *) (s) >= (char *) cygheap->heapbase) \
+ (cygheap->heapptr && s && ((char *) (s) >= (char *) cygheap->heapbase) \
&& ((char *) (s) <= (char *) cygheap->heaptop))
diff --git a/winsup/cygwin/how-cygheap-works.txt b/winsup/cygwin/how-cygheap-works.txt
index 53bd55d65..b60f88808 100644
--- a/winsup/cygwin/how-cygheap-works.txt
+++ b/winsup/cygwin/how-cygheap-works.txt
@@ -101,7 +101,7 @@ both the parent or the child.
for the cygheap. Unfortunately gcc does not support that feature, as of
this writing.)
-The reason for choosing a fixed, arbitrary location is to accomodate
+The reason for choosing a fixed, arbitrary location is to accommodate
Windows XP, although there were sporadic complaints of cygwin heap
failures in other pathological situations with both NT and 9x. In
Windows XP, Microsoft made the allocation of memory less deterministic.
diff --git a/winsup/cygwin/how-to-debug-cygwin.txt b/winsup/cygwin/how-to-debug-cygwin.txt
index 731cc1d71..90b1cd957 100644
--- a/winsup/cygwin/how-to-debug-cygwin.txt
+++ b/winsup/cygwin/how-to-debug-cygwin.txt
@@ -1,17 +1,17 @@
Copyright 2001 Red Hat Inc., Egor Duda
-So, your favourite program has crashed? And did you say something about
+So, your favorite program has crashed? And did you say something about
'stackdump'? Or it just prints its output from left to right and upside-down?
Well, you can file an angry bug report and wait until some of the core
developers try to reproduce your problem, try to find what's the matter
with your program and cygwin and fix the bug, if any. But you can do something
better than that. You can debug the problem yourself, and even if you can't
-fix it, your analysis may be very helpful. Here's the (incoplete) howto on
+fix it, your analysis may be very helpful. Here's the (incomplete) howto on
cygwin debugging.
1. The first thing you'll need to do is to build cygwin1.dll and your crashed
application from sources. To debug them you'll need debug information, which
-is normally stripped from executables.
+is normally stripped from executables.
2. Create known-working cygwin debugging environment.
- create a separate directory, say, c:\cygdeb, and put known-working
@@ -19,7 +19,7 @@ is normally stripped from executables.
- create a wrapper c:\cygdeb\debug_wrapper.cmd:
========= debug_wrapper.cmd =========
-rem setting CYGWIN_TESTING environement variable makes cygwin application
+rem setting CYGWIN_TESTING environment variable makes cygwin application
rem not to interfere with other already running cygwin applications.
set CYGWIN_TESTING=1
c:\cygdeb\gdb.exe -nw %1 %2
@@ -33,27 +33,27 @@ c:\cygdeb\gdb.exe -nw %1 %2
4. Strace.
You can run your program under 'strace' utility, described if user's manual.
- If you know where the problem approximately is, you can add a bunch of
- additional debug_printf()s in the source code and see what they print in
+ If you know where the problem approximately is, you can add a bunch of
+ additional debug_printf()s in the source code and see what they print in
strace log. There's one common problem with this method, that some bugs
- may misteriously disappear once the program is run under strace. Then the
+ may mysteriously disappear once the program is run under strace. Then the
bug is likely a race condition. strace has two useful options to deal with
such situation: -b enables buffering of output and reduces additional
timeouts introduced by strace, and -m option allows you to mask certain
classes of *_printf() functions, reducing timeouts even more.
-5. Problems at early startup.
+5. Problems at early startup.
Sometimes, something crashes at the very early stages of application
initialization, when JIT debugging facility is not yet active. Ok, there's
another environment variable that may help. Create program_wrapper.cmd:
========= program_wrapper.cmd =========
-rem setting CYGWIN_SLEEP environement variable makes cygwin application
+rem setting CYGWIN_SLEEP environment variable makes cygwin application
rem to sleep for x milliseconds at startup
set CYGWIN_SLEEP=20000
c:\some\path\bad_program.exe some parameters
===================================
-
+
Now, run program_wrapper.cmd. It should print running program pid.
After starting program_wrapper.cmd you've got 20 seconds to open another
window, cd to c:\cygdeb in it, run gdb there and in gdb prompt type
@@ -70,4 +70,27 @@ c:\some\path\bad_program.exe some parameters
build special version of cygwin1.dll which includes heap sanity checking.
To do it, just add --enable-malloc-debugging option to configure. Be warned,
however, that this version of dll is _very_ slow (10-100 times slower than
- normal), so use it only when absolutely neccessary.
+ normal), so use it only when absolutely necessary.
+
+7. Program dies when running under strace.
+ If your program crashes when you run it using strace but runs ok (or has a
+ different problem) otherwise, then there may be a problem in one of the
+ strace *_printf statements. Usually this is caused by a change in arguments
+ resulting in a %s being used with something other than a pointer to a
+ string.
+
+ To debug this scenario, do something like this:
+
+ bash$ gdb -nw yourapp.exe
+ (gdb) dll cygwin1
+ (gdb) l dll_crt0_1
+ (gdb) bp <<first line in the function>>
+ (gdb) run
+ (gdb) set strace.active=1
+ (gdb) continue
+
+ The program will then run in "strace mode", calling each strace *_printf,
+ just like it does when run under the strace program. Eventually, the
+ program will crash, probably in small_printf. At that point, a 'bt'
+ command should show you the offending call to strace_printf with the
+ improper format string.
diff --git a/winsup/cygwin/include/cygwin/if.h b/winsup/cygwin/include/cygwin/if.h
index a743ed5ce..b0953de36 100644
--- a/winsup/cygwin/include/cygwin/if.h
+++ b/winsup/cygwin/include/cygwin/if.h
@@ -38,20 +38,20 @@ struct ifreq
{
#define IFNAMSIZ 16
#define IFHWADDRLEN 6
- union
- {
- char ifrn_name[IFNAMSIZ]; /* if name, e.g. "en0" */
- } ifr_ifrn;
-
- union {
- struct sockaddr ifru_addr;
- struct sockaddr ifru_broadaddr;
- struct sockaddr ifru_netmask;
- struct sockaddr ifru_hwaddr;
- short ifru_flags;
- int ifru_metric;
- int ifru_mtu;
- } ifr_ifru;
+ union
+ {
+ char ifrn_name[IFNAMSIZ]; /* if name, e.g. "en0" */
+ } ifr_ifrn;
+
+ union {
+ struct sockaddr ifru_addr;
+ struct sockaddr ifru_broadaddr;
+ struct sockaddr ifru_netmask;
+ struct sockaddr ifru_hwaddr;
+ short ifru_flags;
+ int ifru_metric;
+ int ifru_mtu;
+ } ifr_ifru;
};
#define ifr_name ifr_ifrn.ifrn_name /* interface name */
@@ -73,12 +73,12 @@ struct ifreq
struct ifconf
{
- int ifc_len; /* size of buffer */
- union
- {
- caddr_t ifcu_buf;
- struct ifreq *ifcu_req;
- } ifc_ifcu;
+ int ifc_len; /* size of buffer */
+ union
+ {
+ caddr_t ifcu_buf;
+ struct ifreq *ifcu_req;
+ } ifc_ifcu;
};
#define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */
#define ifc_req ifc_ifcu.ifcu_req /* array of structures */
diff --git a/winsup/cygwin/include/cygwin/mtio.h b/winsup/cygwin/include/cygwin/mtio.h
index 213fc7dc0..04e65234c 100644
--- a/winsup/cygwin/include/cygwin/mtio.h
+++ b/winsup/cygwin/include/cygwin/mtio.h
@@ -20,6 +20,10 @@ details. */
#include <sys/ioctl.h>
#include <asm/socket.h>
+#ifndef DEFTAPE
+#define DEFTAPE "/dev/tape"
+#endif
+
/*
* Structures and definitions for mag tape io control commands
*/
@@ -85,7 +89,8 @@ struct mtget {
* Cygwin: remaining KB.
*/
/* the following registers are device dependent */
- long mt_dsreg; /* status register */
+ long mt_dsreg; /* status register, Cygwin returns current
+ blocksize here. */
long mt_gstat; /* generic (device independent) status */
long mt_erreg; /* error register */
/* The next two fields are not always used */
@@ -99,6 +104,7 @@ struct mtget {
int mt_defblksize;
unsigned long mt_featureslow;
unsigned long mt_featureshigh;
+ unsigned long mt_eotwarningzonesize;
};
/* structure for MTIOCPOS - mag tape get position command */
diff --git a/winsup/cygwin/include/cygwin/types.h b/winsup/cygwin/include/cygwin/types.h
index 7114b7c4a..c17eca4c6 100644
--- a/winsup/cygwin/include/cygwin/types.h
+++ b/winsup/cygwin/include/cygwin/types.h
@@ -1,6 +1,6 @@
/* types.h
- Copyright 2001 Red Hat Inc.
+ Copyright 2001 Red Hat Inc.
Written by Robert Collins <rbtcollins@hotmail.com>
This file is part of Cygwin.
diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h
index 65adf7c9a..f6c3b750f 100644
--- a/winsup/cygwin/include/cygwin/version.h
+++ b/winsup/cygwin/include/cygwin/version.h
@@ -41,10 +41,10 @@ details. */
the Cygwin library". This version is used to track important
changes to the DLL and is mainly informative in nature. */
- /* The current cygwin version is 1.3.4 */
+ /* The current cygwin version is 1.3.6 */
#define CYGWIN_VERSION_DLL_MAJOR 1003
-#define CYGWIN_VERSION_DLL_MINOR 4
+#define CYGWIN_VERSION_DLL_MINOR 7
/* Major numbers before CYGWIN_VERSION_DLL_EPOCH are
incompatible. */
@@ -93,12 +93,12 @@ details. */
/* API_MAJOR 0.0: Initial version. API_MINOR changes:
1: Export cygwin32_ calls as cygwin_ as well.
2: Export j1, jn, y1, yn.
- 3: Export dll_noncygwin_dllcrt0.
- 4: New socket ioctls, revamped ifconf support.
- 5: Thread support/exports.
- 6: Change in termios handling.
- 7: Export scandir and alphasort.
- 8: Export _ctype_, _sys_errlist, _sys_nerr.
+ 3: Export dll_noncygwin_dllcrt0.
+ 4: New socket ioctls, revamped ifconf support.
+ 5: Thread support/exports.
+ 6: Change in termios handling.
+ 7: Export scandir and alphasort.
+ 8: Export _ctype_, _sys_errlist, _sys_nerr.
9: Mount-related changes, new cygwin_umount export.
Raw device support (tape, floppies).
10: Fast math routine support added.
@@ -114,10 +114,10 @@ details. */
20: regsub, inet_network
21: incompatible change to stdio cr/lf and buffering
22: Export cygwin_logon_user, cygwin_set_impersonation_token.
- geteuid, getegid return effective uid/gid.
- getuid, getgid return real uid/gid.
- seteuid, setegid set only effective uid/gid.
- setuid, setgid set effective and real uid/gid.
+ geteuid, getegid return effective uid/gid.
+ getuid, getgid return real uid/gid.
+ seteuid, setegid set only effective uid/gid.
+ setuid, setgid set effective and real uid/gid.
23: Export new dll_crt0 interface and cygwin_user_data for use
with crt0 startup code.
24: Export poll and _poll.
@@ -132,7 +132,7 @@ details. */
33: Export setlogmask
34: Separated out mount table
35: Export drand48, erand48, jrand48, lcong48, lrand48,
- mrand48, nrand48, seed48, and srand48.
+ mrand48, nrand48, seed48, and srand48.
36: Added _cygwin_S_IEXEC, et al
37: [f]pathconv support _PC_POSIX_PERMISSIONS and _PC_POSIX_SECURITY
38: vscanf, vscanf_r, and random pthread functions
@@ -144,10 +144,15 @@ details. */
44: Export dirfd
45: perprocess change, gamma_r, gammaf_r, lgamma_r, lgammaf_r
46: Remove cygwin_getshared
+ 47: Report EOTWarningZoneSize in struct mtget.
+ 48: Export "posix" regex functions
+ 49: Export setutent, endutent, utmpname, getutent, getutid, getutline.
*/
+ /* Note that we forgot to bump the api for ualarm, strtoll, strtoull */
+
#define CYGWIN_VERSION_API_MAJOR 0
-#define CYGWIN_VERSION_API_MINOR 46
+#define CYGWIN_VERSION_API_MINOR 49
/* There is also a compatibity version number associated with the
shared memory regions. It is incremented when incompatible
@@ -212,3 +217,5 @@ details. */
cygwin_internal (CW_GETVERSIONINFO).
*/
+#define CYGWIN_VERSION_MAGIC(a, b) ((unsigned) (((unsigned short) a) | (unsigned short) b))
+#define CYGWIN_VERSION_MAGIC_VERSION(a) ((unsigned) ((unsigned)a & 0xffff))
diff --git a/winsup/cygwin/include/getopt.h b/winsup/cygwin/include/getopt.h
index b05b32fdd..6b6f643b7 100644
--- a/winsup/cygwin/include/getopt.h
+++ b/winsup/cygwin/include/getopt.h
@@ -38,13 +38,6 @@
extern "C" {
#endif
-struct option {
- const char *name;
- int has_arg;
- int *flag;
- int val;
-};
-
extern int opterr; /* if error message should be printed */
extern int optind; /* index into parent argv vector */
extern int optopt; /* character checked for validity */
@@ -53,7 +46,31 @@ extern char *optarg; /* argument associated with option */
int getopt (int, char * const *, const char *);
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __GETOPT_H__ */
+
+#ifndef __UNISTD_GETOPT__
+#ifndef __GETOPT_LONG_H__
+#define __GETOPT_LONG_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct option {
+ const char *name;
+ int has_arg;
+ int *flag;
+ int val;
+};
+
int getopt_long (int, char *const *, const char *, const struct option *, int *);
+#ifndef HAVE_DECL_GETOPT
+#define HAVE_DECL_GETOPT 1
+#endif
#define no_argument 0
#define required_argument 1
@@ -63,4 +80,5 @@ int getopt_long (int, char *const *, const char *, const struct option *, int *)
}
#endif
-#endif /* __GETOPT_H__ */
+#endif /* __GETOPT_LONG_H__ */
+#endif /* __UNISTD_GETOPT__ */
diff --git a/winsup/cygwin/include/glob.h b/winsup/cygwin/include/glob.h
index 3fdf3e8ae..e6e648f11 100644
--- a/winsup/cygwin/include/glob.h
+++ b/winsup/cygwin/include/glob.h
@@ -41,8 +41,6 @@
#ifndef _GLOB_H_
#define _GLOB_H_
-/* CYGNUS LOCAL: end */
-
#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -93,7 +91,6 @@ typedef struct {
#define GLOB_ABEND (-2) /* Unignored error. */
__BEGIN_DECLS
-/* CYGNUS LOCAL: normal protos */
#undef DLLEXPORT
#ifdef __INSIDE_CYGWIN__
@@ -105,7 +102,6 @@ int DLLEXPORT glob(const char *, int, int (*)(const char *, int), glob_t *);
void DLLEXPORT globfree(glob_t *);
#undef DLLEXPORT
-/* end CYGNUS LOCAL */
__END_DECLS
#endif /* !_GLOB_H_ */
diff --git a/winsup/cygwin/include/limits.h b/winsup/cygwin/include/limits.h
index 715a49ac3..78c475170 100644
--- a/winsup/cygwin/include/limits.h
+++ b/winsup/cygwin/include/limits.h
@@ -88,11 +88,12 @@ details. */
#undef ULONG_MAX
#define ULONG_MAX (LONG_MAX * 2UL + 1)
-#if defined (__GNU_LIBRARY__) ? defined (__USE_GNU) : !defined (__STRICT_ANSI__)
/* Minimum and maximum values a `signed long long int' can hold. */
#ifndef __LONG_LONG_MAX__
#define __LONG_LONG_MAX__ 9223372036854775807LL
#endif
+
+#if defined (__GNU_LIBRARY__) ? defined (__USE_GNU) : !defined (__STRICT_ANSI__)
#undef LONG_LONG_MIN
#define LONG_LONG_MIN (-LONG_LONG_MAX-1)
#undef LONG_LONG_MAX
@@ -103,6 +104,18 @@ details. */
#define ULONG_LONG_MAX (LONG_LONG_MAX * 2ULL + 1)
#endif
+#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+/* Minimum and maximum values a `signed long long int' can hold. */
+#undef LLONG_MIN
+#define LLONG_MIN (-LLONG_MAX-1)
+#undef LLONG_MAX
+#define LLONG_MAX __LONG_LONG_MAX__
+
+/* Maximum value an `unsigned long long int' can hold. (Minimum is 0). */
+#undef ULLONG_MAX
+#define ULLONG_MAX (LLONG_MAX * 2ULL + 1)
+#endif
+
/* Maximum number of iovcnt in a writev */
#undef IOV_MAX
#define IOV_MAX (__INT_MAX__-1)
diff --git a/winsup/cygwin/include/pthread.h b/winsup/cygwin/include/pthread.h
index 486635da7..102ba650c 100644
--- a/winsup/cygwin/include/pthread.h
+++ b/winsup/cygwin/include/pthread.h
@@ -43,7 +43,8 @@ extern "C"
#define PTHREAD_CANCEL_DEFERRED 0
#define PTHREAD_CANCEL_DISABLE 1
#define PTHREAD_CANCELED
-#define PTHREAD_COND_INITIALIZER
+/* this should be a value that can never be a valid address */
+#define PTHREAD_COND_INITIALIZER (void *)21
#define PTHREAD_CREATE_DETACHED 1
/* the default : joinable */
#define PTHREAD_CREATE_JOINABLE 0
@@ -83,7 +84,7 @@ int pthread_attr_setscope (pthread_attr_t *, int);
#ifdef _POSIX_THREAD_ATTR_STACKADDR
/* These functions may be implementable via some low level trickery. For now they are
- * Not supported or implemented. The prototypes are here so if someone greps the
+ * Not supported or implemented. The prototypes are here so if someone greps the
* source they will see these comments
*/
int pthread_attr_getstackaddr (const pthread_attr_t *, void **);
@@ -96,7 +97,7 @@ int pthread_attr_setstacksize (pthread_attr_t *, size_t);
#endif
int pthread_cancel (pthread_t);
-/* Macros for cleanup_push and pop;
+/* Macros for cleanup_push and pop;
* The function definitions are
void pthread_cleanup_push (void (*routine)(void*), void *arg);
void pthread_cleanup_pop (int execute);
diff --git a/winsup/cygwin/include/sys/cygwin.h b/winsup/cygwin/include/sys/cygwin.h
index 1d53f636b..a4a8cf699 100644
--- a/winsup/cygwin/include/sys/cygwin.h
+++ b/winsup/cygwin/include/sys/cygwin.h
@@ -64,7 +64,9 @@ typedef enum
CW_GET_CYGDRIVE_PREFIXES,
CW_GETPINFO_FULL,
CW_INIT_EXCEPTIONS,
- CW_GET_CYGDRIVE_INFO
+ CW_GET_CYGDRIVE_INFO,
+ CW_SET_CYGWIN_REGISTRY_NAME,
+ CW_GET_CYGWIN_REGISTRY_NAME
} cygwin_getinfo_types;
#define CW_NEXTPID 0x80000000 // or with pid to get next one
diff --git a/winsup/cygwin/include/sys/resource.h b/winsup/cygwin/include/sys/resource.h
index c68a206e1..c1fe544a9 100644
--- a/winsup/cygwin/include/sys/resource.h
+++ b/winsup/cygwin/include/sys/resource.h
@@ -50,16 +50,16 @@ struct rusage {
long ru_ixrss; /* XXX: 0 */
long ru_idrss; /* XXX: sum of rm_asrss */
long ru_isrss; /* XXX: 0 */
- long ru_minflt; /* any page faults not requiring I/O */
- long ru_majflt; /* any page faults requiring I/O */
- long ru_nswap; /* swaps */
- long ru_inblock; /* block input operations */
- long ru_oublock; /* block output operations */
- long ru_msgsnd; /* messages sent */
- long ru_msgrcv; /* messages received */
- long ru_nsignals; /* signals received */
- long ru_nvcsw; /* voluntary context switches */
- long ru_nivcsw; /* involuntary " */
+ long ru_minflt; /* any page faults not requiring I/O */
+ long ru_majflt; /* any page faults requiring I/O */
+ long ru_nswap; /* swaps */
+ long ru_inblock; /* block input operations */
+ long ru_oublock; /* block output operations */
+ long ru_msgsnd; /* messages sent */
+ long ru_msgrcv; /* messages received */
+ long ru_nsignals; /* signals received */
+ long ru_nvcsw; /* voluntary context switches */
+ long ru_nivcsw; /* involuntary " */
#define ru_last ru_nivcsw
};
diff --git a/winsup/cygwin/include/sys/soundcard.h b/winsup/cygwin/include/sys/soundcard.h
index 1a40bff61..79341c547 100644
--- a/winsup/cygwin/include/sys/soundcard.h
+++ b/winsup/cygwin/include/sys/soundcard.h
@@ -53,10 +53,10 @@
#define SNDCARD_UART6850 8
#define SNDCARD_GUS16 9
#define SNDCARD_MSS 10
-#define SNDCARD_PSS 11
+#define SNDCARD_PSS 11
#define SNDCARD_SSCAPE 12
-#define SNDCARD_PSS_MPU 13
-#define SNDCARD_PSS_MSS 14
+#define SNDCARD_PSS_MPU 13
+#define SNDCARD_PSS_MSS 14
#define SNDCARD_SSCAPE_MSS 15
#define SNDCARD_TRXPRO 16
#define SNDCARD_TRXPRO_SB 17
@@ -112,7 +112,7 @@
#define _SIOW(x,y,t) ((int)(SIOC_IN|((sizeof(t)&SIOCPARM_MASK)<<16)|(x<<8)|y))
/* this should be _SIORW, but stdio got there first */
#define _SIOWR(x,y,t) ((int)(SIOC_INOUT|((sizeof(t)&SIOCPARM_MASK)<<16)|(x<<8)|y))
-#define _SIOC_SIZE(x) ((x>>16)&SIOCPARM_MASK)
+#define _SIOC_SIZE(x) ((x>>16)&SIOCPARM_MASK)
#define _SIOC_DIR(x) (x & 0xf0000000)
#define _SIOC_NONE SIOC_VOID
#define _SIOC_READ SIOC_OUT
@@ -194,7 +194,7 @@ typedef struct seq_event_rec {
* Gravis UltraSound. It tries to be universal format for uploading
* sample based patches but is probably too limited.
*
- * (PBD) As Hannu guessed, the GUS structure is too limited for
+ * (PBD) As Hannu guessed, the GUS structure is too limited for
* the WaveFront, but this is the right place for a constant definition.
*/
@@ -220,7 +220,7 @@ struct patch_info {
#define WAVE_SUSTAIN_ON 0x20 /* bit 5 = Turn sustaining on. (Env. pts. 3)*/
#define WAVE_ENVELOPES 0x40 /* bit 6 = Enable envelopes - 1 */
#define WAVE_FAST_RELEASE 0x80 /* bit 7 = Shut off immediately after note off */
- /* (use the env_rate/env_offs fields). */
+ /* (use the env_rate/env_offs fields). */
/* Linux specific bits */
#define WAVE_VIBRATO 0x00010000 /* The vibrato info is valid */
#define WAVE_TREMOLO 0x00020000 /* The tremolo info is valid */
@@ -234,7 +234,7 @@ struct patch_info {
int len; /* Size of the wave data in bytes */
int loop_start, loop_end; /* Byte offsets from the beginning */
-/*
+/*
* The base_freq and base_note fields are used when computing the
* playback speed for a note. The base_note defines the tone frequency
* which is heard if the sample is played using the base_freq as the
@@ -263,7 +263,7 @@ struct patch_info {
unsigned char env_rate[ 6 ]; /* GUS HW ramping rate */
unsigned char env_offset[ 6 ]; /* 255 == 100% */
- /*
+ /*
* The tremolo, vibrato and scale info are not supported yet.
* Enable by setting the mode bits WAVE_TREMOLO, WAVE_VIBRATO or
* WAVE_SCALE
@@ -272,18 +272,18 @@ struct patch_info {
unsigned char tremolo_sweep;
unsigned char tremolo_rate;
unsigned char tremolo_depth;
-
+
unsigned char vibrato_sweep;
unsigned char vibrato_rate;
unsigned char vibrato_depth;
int scale_frequency;
unsigned int scale_factor; /* from 0 to 2048 or 0 to 2 */
-
- int volume;
+
+ int volume;
int fractions;
int reserved1;
- int spare[2];
+ int spare[2];
char data[1]; /* The waveform data starts here */
};
@@ -300,7 +300,7 @@ struct sysex_info {
* /dev/sequencer input events.
*
* The data written to the /dev/sequencer is a stream of events. Events
- * are records of 4 or 8 bytes. The first byte defines the size.
+ * are records of 4 or 8 bytes. The first byte defines the size.
* Any number of events can be written with a write call. There
* is a set of macros for sending these events. Use these macros if you
* want to maximize portability of your program.
@@ -408,7 +408,7 @@ struct sysex_info {
#define CTRL_EXPRESSION 253 /* Obsolete */
#define CTRL_MAIN_VOLUME 252 /* Obsolete */
#define SEQ_BALANCE 11
-#define SEQ_VOLMODE 12
+#define SEQ_VOLMODE 12
/*
* Volume mode decides how volumes are used
@@ -433,13 +433,13 @@ struct sysex_info {
* of the associated synthesizer device. There is no limit to the size
* of the extended events. These events are not queued but executed
* immediately when the write() is called (execution can take several
- * seconds of time).
+ * seconds of time).
*
* When a SEQ_FULLSIZE message is written to the device, it must
* be written using exactly one write() call. Other events cannot
* be mixed to the same write.
- *
- * For FM synths (YM3812/OPL3) use struct sbi_instrument and write it to the
+ *
+ * For FM synths (YM3812/OPL3) use struct sbi_instrument and write it to the
* /dev/sequencer. Don't write other data together with the instrument structure
* Set the key field of the structure to FM_PATCH. The device field is used to
* route the patch to the corresponding device.
@@ -461,7 +461,7 @@ struct sbi_instrument {
#define FM_PATCH _PATCHKEY(0x01)
#define OPL3_PATCH _PATCHKEY(0x03)
short device; /* Synth# (0-4) */
- int channel; /* Program# to be initialized */
+ int channel; /* Program# to be initialized */
sbi_instr_data operators; /* Register settings for operator cells (.SBI format) */
};
@@ -480,13 +480,13 @@ struct synth_info { /* Read only */
#define SAMPLE_TYPE_BASIC 0x10
#define SAMPLE_TYPE_GUS SAMPLE_TYPE_BASIC
-#define SAMPLE_TYPE_WAVEFRONT 0x11
+#define SAMPLE_TYPE_WAVEFRONT 0x11
int perc_mode; /* No longer supported */
int nr_voices;
int nr_drums; /* Obsolete field */
int instr_bank_size;
- unsigned int capabilities;
+ unsigned int capabilities;
#define SYNTH_CAP_PERCMODE 0x00000001 /* No longer used */
#define SYNTH_CAP_OPL3 0x00000002 /* Set if OPL3 supported */
#define SYNTH_CAP_INPUT 0x00000004 /* Input (MIDI) device */
@@ -625,7 +625,7 @@ typedef struct buffmem_desc {
/*
* Application's profile defines the way how playback underrun situations should be handled.
- *
+ *
* APF_NORMAL (the default) and APF_NETWORK make the driver to cleanup the
* playback buffer whenever an underrun occurs. This consumes some time
* prevents looping the existing buffer.
@@ -687,7 +687,7 @@ typedef struct copr_debug_buf {
int command; /* Used internally. Set to 0 */
int parm1;
int parm2;
- int flags;
+ int flags;
int len; /* Length of data in bytes */
} copr_debug_buf;
@@ -696,7 +696,7 @@ typedef struct copr_msg {
unsigned char data[4000];
} copr_msg;
-#define SNDCTL_COPR_RESET _SIO ('C', 0)
+#define SNDCTL_COPR_RESET _SIO ('C', 0)
#define SNDCTL_COPR_LOAD _SIOWR('C', 1, copr_buffer)
#define SNDCTL_COPR_RDATA _SIOWR('C', 2, copr_debug_buf)
#define SNDCTL_COPR_RCODE _SIOWR('C', 3, copr_debug_buf)
@@ -710,12 +710,12 @@ typedef struct copr_msg {
/*********************************************
* IOCTL commands for /dev/mixer
*/
-
-/*
+
+/*
* Mixer devices
*
* There can be up to 20 different analog mixer channels. The
- * SOUND_MIXER_NRDEVICES gives the currently supported maximum.
+ * SOUND_MIXER_NRDEVICES gives the currently supported maximum.
* The SOUND_MIXER_READ_DEVMASK returns a bitmask which tells
* the devices supported by the particular mixer.
*/
@@ -735,7 +735,7 @@ typedef struct copr_msg {
#define SOUND_MIXER_RECLEV 11 /* Recording level */
#define SOUND_MIXER_IGAIN 12 /* Input gain */
#define SOUND_MIXER_OGAIN 13 /* Output gain */
-/*
+/*
* The AD1848 codec and compatibles have three line level inputs
* (line, aux1 and aux2). Since each card manufacturer have assigned
* different meanings to these inputs, it's inpractical to assign
@@ -940,7 +940,7 @@ typedef struct mixer_vol_table {
#define SOUND_MIXER_GETLEVELS _SIOWR('M', 116, mixer_vol_table)
#define SOUND_MIXER_SETLEVELS _SIOWR('M', 117, mixer_vol_table)
-/*
+/*
* An ioctl for identifying the driver version. It will return value
* of the SOUND_VERSION macro used when compiling the driver.
* This call was introduced in OSS version 3.6 and it will not work
@@ -954,7 +954,7 @@ typedef struct mixer_vol_table {
/*
* The 4 most significant bits of byte 0 specify the class of
- * the event:
+ * the event:
*
* 0x8X = system level events,
* 0x9X = device/port specific events, event[1] = device/port,
@@ -1014,7 +1014,7 @@ typedef struct mixer_vol_table {
*/
#define LOCL_STARTAUDIO 1
-#if (!defined(__KERNEL__) && !defined(KERNEL) && !defined(INKERNEL) && !defined(_KERNEL)) || defined(USE_SEQ_MACROS)
+#if (!defined(__KERNEL__) && !defined(KERNEL) && !defined(INKERNEL) && !defined(_KERNEL)) || defined(USE_SEQ_MACROS)
/*
* Some convenience macros to simplify programming of the
* /dev/sequencer interface
@@ -1087,16 +1087,16 @@ extern int OSS_write_patch2(int fd, unsigned char *buf, int len);
/*
* This variation of the sequencer macros is used just to format one event
* using fixed buffer.
- *
+ *
* The program using the macro library must define the following macros before
* using this library.
*
- * #define _seqbuf name of the buffer (unsigned char[])
+ * #define _seqbuf name of the buffer (unsigned char[])
* #define _SEQ_ADVBUF(len) If the applic needs to know the exact
* size of the event, this macro can be used.
* Otherwise this must be defined as empty.
* #define _seqbufptr Define the name of index variable or 0 if
- * not required.
+ * not required.
*/
#define _SEQ_NEEDBUF(len) /* empty */
#endif
@@ -1157,7 +1157,7 @@ extern int OSS_write_patch2(int fd, unsigned char *buf, int len);
* sending any MIDI bytes but it's absolutely not possible. Trying to do
* so _will_ cause problems with MPU401 intelligent mode).
*
- * Sysex messages are sent in blocks of 1 to 6 bytes. Longer messages must be
+ * Sysex messages are sent in blocks of 1 to 6 bytes. Longer messages must be
* sent by calling SEQ_SYSEX() several times (there must be no other events
* between them). First sysex fragment must have 0xf0 in the first byte
* and the last byte (buf[len-1] of the last fragment must be 0xf7. No byte
@@ -1225,11 +1225,11 @@ extern int OSS_write_patch2(int fd, unsigned char *buf, int len);
*/
#define _TIMER_EVENT(ev, parm) {_SEQ_NEEDBUF(8);\
- _seqbuf[_seqbufptr+0] = EV_TIMING; \
- _seqbuf[_seqbufptr+1] = (ev); \
+ _seqbuf[_seqbufptr+0] = EV_TIMING; \
+ _seqbuf[_seqbufptr+1] = (ev); \
_seqbuf[_seqbufptr+2] = 0;\
_seqbuf[_seqbufptr+3] = 0;\
- *(unsigned int *)&_seqbuf[_seqbufptr+4] = (parm); \
+ *(unsigned int *)&_seqbuf[_seqbufptr+4] = (parm); \
_SEQ_ADVBUF(8);}
#define SEQ_START_TIMER() _TIMER_EVENT(TMR_START, 0)
@@ -1247,16 +1247,16 @@ extern int OSS_write_patch2(int fd, unsigned char *buf, int len);
*/
#define _LOCAL_EVENT(ev, parm) {_SEQ_NEEDBUF(8);\
- _seqbuf[_seqbufptr+0] = EV_SEQ_LOCAL; \
- _seqbuf[_seqbufptr+1] = (ev); \
+ _seqbuf[_seqbufptr+0] = EV_SEQ_LOCAL; \
+ _seqbuf[_seqbufptr+1] = (ev); \
_seqbuf[_seqbufptr+2] = 0;\
_seqbuf[_seqbufptr+3] = 0;\
- *(unsigned int *)&_seqbuf[_seqbufptr+4] = (parm); \
+ *(unsigned int *)&_seqbuf[_seqbufptr+4] = (parm); \
_SEQ_ADVBUF(8);}
#define SEQ_PLAYAUDIO(devmask) _LOCAL_EVENT(LOCL_STARTAUDIO, devmask)
/*
- * Events for the level 1 interface only
+ * Events for the level 1 interface only
*/
#define SEQ_MIDIOUT(device, byte) {_SEQ_NEEDBUF(4);\
diff --git a/winsup/cygwin/include/sys/un.h b/winsup/cygwin/include/sys/un.h
index 25588e2b2..4e3eee82b 100644
--- a/winsup/cygwin/include/sys/un.h
+++ b/winsup/cygwin/include/sys/un.h
@@ -21,6 +21,6 @@ struct sockaddr_un {
/* Evaluates the actual length of `sockaddr_un' structure. */
#define SUN_LEN(p) ((size_t)(((struct sockaddr_un *) NULL)->sun_path) \
- + strlen ((p)->sun_path))
+ + strlen ((p)->sun_path))
#endif
diff --git a/winsup/cygwin/init.cc b/winsup/cygwin/init.cc
index 5d2c75056..525ec29b1 100644
--- a/winsup/cygwin/init.cc
+++ b/winsup/cygwin/init.cc
@@ -13,8 +13,6 @@ details. */
#include "thread.h"
#include "perprocess.h"
-extern HMODULE cygwin_hmodule;
-
int NO_COPY dynamically_loaded;
extern "C" int
diff --git a/winsup/cygwin/ioctl.cc b/winsup/cygwin/ioctl.cc
index 93fe9ddf5..98c157800 100644
--- a/winsup/cygwin/ioctl.cc
+++ b/winsup/cygwin/ioctl.cc
@@ -25,15 +25,12 @@ details. */
extern "C" int
ioctl (int fd, int cmd, void *buf)
{
- if (cygheap->fdtab.not_open (fd))
- {
- set_errno (EBADF);
- return -1;
- }
+ cygheap_fdget cfd (fd);
+ if (cfd < 0)
+ return -1;
debug_printf ("fd %d, cmd %x\n", fd, cmd);
- fhandler_base *fh = cygheap->fdtab[fd];
- if (fh->is_tty () && fh->get_device () != FH_PTYM)
+ if (cfd->is_tty () && cfd->get_device () != FH_PTYM)
switch (cmd)
{
case TCGETA:
@@ -46,5 +43,5 @@ ioctl (int fd, int cmd, void *buf)
return tcsetattr (fd, TCSAFLUSH, (struct termios *) buf);
}
- return fh->ioctl (cmd, buf);
+ return cfd->ioctl (cmd, buf);
}
diff --git a/winsup/cygwin/lib/cygwin_crt0.c b/winsup/cygwin/lib/cygwin_crt0.c
index d8f781746..fb2a84b18 100644
--- a/winsup/cygwin/lib/cygwin_crt0.c
+++ b/winsup/cygwin/lib/cygwin_crt0.c
@@ -11,10 +11,9 @@ details. */
#undef __INSIDE_CYGWIN__
#include <windows.h>
#include <sys/cygwin.h>
+#include <stdlib.h>
#include "crt0.h"
-#define alloca __builtin_alloca
-
extern void dll_crt0__FP11per_process (struct per_process *) __declspec (dllimport) __attribute ((noreturn));
/* for main module */
diff --git a/winsup/cygwin/lib/dll_main.cc b/winsup/cygwin/lib/dll_main.cc
index e4486a3d8..a224a0a2f 100644
--- a/winsup/cygwin/lib/dll_main.cc
+++ b/winsup/cygwin/lib/dll_main.cc
@@ -15,7 +15,7 @@ details. */
extern "C"
BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason,
- LPVOID reserved /* Not used. */);
+ LPVOID reserved /* Not used. */);
BOOL APIENTRY
DllMain (
diff --git a/winsup/cygwin/lib/getopt.c b/winsup/cygwin/lib/getopt.c
index 12763ea9b..effa5d774 100644
--- a/winsup/cygwin/lib/getopt.c
+++ b/winsup/cygwin/lib/getopt.c
@@ -147,7 +147,7 @@ gcd(a, b)
b = c;
c = a % b;
}
-
+
return b;
}
@@ -214,7 +214,7 @@ getopt_internal(int nargc, char *const * nargv, const char *options)
* XXX re-initialize optind to 0 and have getopt_long(3)
* XXX properly function again. Work around this braindamage.
*/
- if (optind == 0)
+ if (optind == 0 && optreset == 0)
optind = 1;
if (optreset)
@@ -245,7 +245,7 @@ start:
place = EMSG;
if (IN_ORDER) {
/*
- * GNU extension:
+ * GNU extension:
* return non-option as argument to option 1
*/
optarg = nargv[optind++];
@@ -291,7 +291,7 @@ start:
}
if (optchar == 'W' && oli[1] == ';') { /* -W long-option */
/* XXX: what if no long options provided (called by getopt)? */
- if (*place)
+ if (*place)
return -2;
if (++optind >= nargc) { /* no arg */
@@ -411,7 +411,7 @@ getopt_long(int nargc, char * const *nargv, const char *options,
has_equal++;
} else
current_argv_len = strlen(current_argv);
-
+
for (i = 0; long_options[i].name; i++) {
/* find matching long option */
if (strncmp(current_argv, long_options[i].name,
@@ -436,7 +436,7 @@ getopt_long(int nargc, char * const *nargv, const char *options,
}
}
if (match != -1) { /* option found */
- if (long_options[match].has_arg == no_argument
+ if (long_options[match].has_arg == no_argument
&& has_equal) {
if (PRINT_ERROR)
warnx(noarg, (int)current_argv_len,
@@ -492,7 +492,7 @@ getopt_long(int nargc, char * const *nargv, const char *options,
if (long_options[match].flag) {
*long_options[match].flag = long_options[match].val;
retval = 0;
- } else
+ } else
retval = long_options[match].val;
if (idx)
*idx = match;
diff --git a/winsup/cygwin/localtime.cc b/winsup/cygwin/localtime.cc
index 43c64ce3c..48006e25a 100644
--- a/winsup/cygwin/localtime.cc
+++ b/winsup/cygwin/localtime.cc
@@ -4,7 +4,6 @@
*/
/* Temporarily merged private.h and tzfile.h for ease of management - DJ */
-/* CYGNUS LOCAL */
#include "winsup.h"
#include "cygerrno.h"
#include <windows.h>
@@ -12,8 +11,6 @@
#define USG_COMPAT
-/* END CYGNUS LOCAL */
-
#ifndef lint
#ifndef NOID
static char elsieid[] = "@(#)localtime.c 7.66";
@@ -501,7 +498,7 @@ struct tzhead {
static char wildabbr[] NO_COPY = WILDABBR;
-static const char gmt[] NO_COPY = "GMT";
+static char gmt[] NO_COPY = "GMT";
struct ttinfo { /* time type information */
long tt_gmtoff; /* UTC offset in seconds */
diff --git a/winsup/cygwin/malloc_wrapper.cc b/winsup/cygwin/malloc_wrapper.cc
index 2fa93b1a1..60c67aca8 100644
--- a/winsup/cygwin/malloc_wrapper.cc
+++ b/winsup/cygwin/malloc_wrapper.cc
@@ -18,6 +18,8 @@ details. */
#include "fhandler.h"
#include "path.h"
#include "dtable.h"
+#include <errno.h>
+#include "cygerrno.h"
#include "cygheap.h"
#include "heap.h"
#include "sync.h"
diff --git a/winsup/cygwin/miscfuncs.cc b/winsup/cygwin/miscfuncs.cc
index c5d46fbf0..5d3010470 100644
--- a/winsup/cygwin/miscfuncs.cc
+++ b/winsup/cygwin/miscfuncs.cc
@@ -12,7 +12,7 @@ details. */
#include "cygerrno.h"
#include <sys/errno.h>
-/********************** String Helper Functions ************************/
+long tls_ix = -1;
const char case_folded_lower[] NO_COPY = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
@@ -116,15 +116,21 @@ strcasestr (const char *searchee, const char *lookfor)
}
int __stdcall
-check_null_empty_str (const char *name)
+check_null_str (const char *name)
{
- if (!name || IsBadStringPtr (name, MAX_PATH))
- return EFAULT;
+ if (name && !IsBadStringPtr (name, MAX_PATH))
+ return 0;
+
+ return EFAULT;
+}
- if (!*name)
- return ENOENT;
+int __stdcall
+check_null_empty_str (const char *name)
+{
+ if (name && !IsBadStringPtr (name, MAX_PATH))
+ return !*name ? ENOENT : 0;
- return 0;
+ return EFAULT;
}
int __stdcall
@@ -137,19 +143,36 @@ check_null_empty_str_errno (const char *name)
}
int __stdcall
+check_null_str_errno (const char *name)
+{
+ int __err;
+ if ((__err = check_null_str (name)))
+ set_errno (__err);
+ return __err;
+}
+
+int __stdcall
__check_null_invalid_struct (const void *s, unsigned sz)
{
- if (!s || IsBadWritePtr ((void *) s, sz))
- return EFAULT;
+ if (s && !IsBadWritePtr ((void *) s, sz))
+ return 0;
- return 0;
+ return EFAULT;
}
int __stdcall
__check_null_invalid_struct_errno (const void *s, unsigned sz)
{
- int __err;
- if ((__err = __check_null_invalid_struct (s, sz)))
- set_errno (__err);
- return __err;
+ int err;
+ if ((err = __check_null_invalid_struct (s, sz)))
+ set_errno (err);
+ return err;
+}
+
+int __stdcall
+__check_invalid_read_ptr_errno (const void *s, unsigned sz)
+{
+ if (s && !IsBadReadPtr ((void *) s, sz))
+ return 0;
+ return set_errno (EFAULT);
}
diff --git a/winsup/cygwin/mmap.cc b/winsup/cygwin/mmap.cc
index c13a3f365..884941ae4 100644
--- a/winsup/cygwin/mmap.cc
+++ b/winsup/cygwin/mmap.cc
@@ -109,6 +109,8 @@ mmap_record::find_empty (DWORD pages)
DWORD mapped_pages = PAGE_CNT (size_to_map_);
DWORD start;
+ if (pages > mapped_pages)
+ return (DWORD)-1;
for (start = 0; start <= mapped_pages - pages; ++start)
if (!MAP_ISSET (start))
{
@@ -217,7 +219,7 @@ mmap_record::fixup_map ()
&old_prot);
}
-static fhandler_disk_file fh_paging_file (NULL);
+static fhandler_disk_file fh_paging_file;
fhandler_base *
mmap_record::alloc_fh ()
@@ -445,21 +447,21 @@ mmap (caddr_t addr, size_t len, int prot, int flags, int fd, off_t off)
DWORD gran_off = off & ~(granularity - 1);
DWORD gran_len = howmany (len, granularity) * granularity;
- fhandler_base *fh = NULL;
+ fhandler_base *fh;
caddr_t base = addr;
HANDLE h;
if (fd != -1)
{
/* Ensure that fd is open */
- if (cygheap->fdtab.not_open (fd))
+ cygheap_fdget cfd (fd);
+ if (cfd < 0)
{
- set_errno (EBADF);
syscall_printf ("-1 = mmap(): EBADF");
ReleaseResourceLock(LOCK_MMAP_LIST, READ_LOCK | WRITE_LOCK, "mmap");
return MAP_FAILED;
}
- fh = cygheap->fdtab[fd];
+ fh = cfd;
if (fh->get_device () == FH_DISK)
{
DWORD fsiz = GetFileSize (fh->get_handle (), NULL);
@@ -503,7 +505,7 @@ mmap (caddr_t addr, size_t len, int prot, int flags, int fd, off_t off)
While the changes are not propagated to the file, they are
visible to other processes sharing the same file mapping object.
Workaround: Don't use named file mapping. That should work since
- sharing file mappings only works reliable using named
+ sharing file mappings only works reliable using named
file mapping on 9x.
*/
if ((flags & MAP_PRIVATE)
diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc
index c310c78b3..9e02085e1 100644
--- a/winsup/cygwin/net.cc
+++ b/winsup/cygwin/net.cc
@@ -1,6 +1,6 @@
/* net.cc: network-related routines.
- Copyright 1996, 1997, 1998, 1999, 2000, 2001 Red Hat, Inc.
+ Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
This file is part of Cygwin.
@@ -118,23 +118,26 @@ wsock_event::wait (int socket, LPDWORD flags)
WSADATA wsadata;
/* Cygwin internal */
+static fhandler_socket *
+get (int fd)
+{
+ cygheap_fdget cfd (fd);
+ if (cfd < 0)
+ return 0;
+
+ return cfd->is_socket ();
+}
+
+/* Cygwin internal */
static SOCKET __stdcall
set_socket_inheritance (SOCKET sock)
{
- if (wincap.has_set_handle_information ())
- (void) SetHandleInformation ((HANDLE) sock, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT);
+ SOCKET osock = sock;
+ if (!DuplicateHandle (hMainProc, (HANDLE) sock, hMainProc, (HANDLE *) &sock,
+ 0, TRUE, DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE))
+ system_printf ("DuplicateHandle failed %E");
else
- {
- SOCKET newsock;
- if (!DuplicateHandle (hMainProc, (HANDLE) sock, hMainProc, (HANDLE *) &newsock,
- 0, TRUE, DUPLICATE_SAME_ACCESS))
- small_printf ("DuplicateHandle failed %E");
- else
- {
- closesocket (sock);
- sock = newsock;
- }
- }
+ debug_printf ("DuplicateHandle succeeded osock %p, sock %p", osock, sock);
return sock;
}
@@ -203,6 +206,8 @@ cygwin_inet_ntoa (struct in_addr in)
extern "C" unsigned long
cygwin_inet_addr (const char *cp)
{
+ if (check_null_str_errno (cp))
+ return INADDR_NONE;
unsigned long res = inet_addr (cp);
return res;
}
@@ -213,6 +218,9 @@ cygwin_inet_addr (const char *cp)
extern "C" int
cygwin_inet_aton (const char *cp, struct in_addr *inp)
{
+ if (check_null_str_errno (cp) || check_null_invalid_struct_errno (inp))
+ return 0;
+
unsigned long res = inet_addr (cp);
if (res == INADDR_NONE && strcmp (cp, "255.255.255.255"))
return 0;
@@ -227,6 +235,8 @@ extern "C" unsigned int WINAPI inet_network (const char *);
extern "C" unsigned int
cygwin_inet_network (const char *cp)
{
+ if (check_null_str_errno (cp))
+ return INADDR_NONE;
unsigned int res = inet_network (cp);
return res;
}
@@ -240,7 +250,6 @@ inet_netof (struct in_addr in)
{
unsigned long i, res;
-
i = ntohl (in.s_addr);
if (IN_CLASSA (i))
res = (i & IN_CLASSA_NET) >> IN_CLASSA_NSHIFT;
@@ -263,7 +272,6 @@ inet_makeaddr (int net, int lna)
unsigned long i;
struct in_addr in;
-
if (net < IN_CLASSA_MAX)
i = (net << IN_CLASSA_NSHIFT) | (lna & IN_CLASSA_HOST);
else if (net < IN_CLASSB_MAX)
@@ -356,7 +364,7 @@ __set_winsock_errno (const char *fn, int ln)
* Since the member `s' isn't used for debug output we can use it
* for the error text returned by herror and hstrerror.
*/
-const static NO_COPY struct tl host_errmap[] =
+static NO_COPY struct tl host_errmap[] =
{
{WSAHOST_NOT_FOUND, "Unknown host", HOST_NOT_FOUND},
{WSATRY_AGAIN, "Host name lookup failure", TRY_AGAIN},
@@ -481,6 +489,8 @@ out:
extern "C" struct protoent *
cygwin_getprotobyname (const char *p)
{
+ if (check_null_str_errno (p))
+ return NULL;
free_protoent_ptr (protoent_buf);
protoent_buf = dup_protoent_ptr (getprotobyname (p));
if (!protoent_buf)
@@ -504,14 +514,17 @@ cygwin_getprotobynumber (int number)
}
fhandler_socket *
-fdsock (int fd, const char *name, SOCKET soc)
+fdsock (int& fd, const char *name, SOCKET soc)
{
- if (wsadata.wVersion < 512) /* < Winsock 2.0 */
+ if (!winsock2_active)
soc = set_socket_inheritance (soc);
+ else
+ debug_printf ("not setting socket inheritance since winsock2_active %d", winsock2_active);
fhandler_socket *fh = (fhandler_socket *) cygheap->fdtab.build_fhandler (fd, FH_SOCKET, name);
fh->set_io_handle ((HANDLE) soc);
fh->set_flags (O_RDWR);
- cygheap->fdtab.inc_need_fixup_before ();
+ fh->set_name (name, name);
+ debug_printf ("fd %d, name '%s', soc %p", fd, name, soc);
return fh;
}
@@ -520,15 +533,11 @@ extern "C" int
cygwin_socket (int af, int type, int protocol)
{
int res = -1;
- SetResourceLock (LOCK_FD_LIST, WRITE_LOCK|READ_LOCK, "socket");
+ SOCKET soc = 0;
- SOCKET soc;
+ cygheap_fdnew fd;
- int fd = cygheap->fdtab.find_unused_handle ();
-
- if (fd < 0)
- set_errno (EMFILE);
- else
+ if (fd >= 0)
{
debug_printf ("socket (%d, %d, %d)", af, type, protocol);
@@ -552,7 +561,6 @@ cygwin_socket (int af, int type, int protocol)
done:
syscall_printf ("%d = socket (%d, %d, %d)", res, af, type, protocol);
- ReleaseResourceLock (LOCK_FD_LIST, WRITE_LOCK|READ_LOCK, "socket");
return res;
}
@@ -605,46 +613,54 @@ static int get_inet_addr (const struct sockaddr *in, int inlen,
/* exported as sendto: standards? */
extern "C" int
cygwin_sendto (int fd,
- const void *buf,
- int len,
- unsigned int flags,
- const struct sockaddr *to,
- int tolen)
+ const void *buf,
+ int len,
+ unsigned int flags,
+ const struct sockaddr *to,
+ int tolen)
{
int res;
wsock_event wsock_evt;
LPWSAOVERLAPPED ovr;
- fhandler_socket *h = (fhandler_socket *) cygheap->fdtab[fd];
- sockaddr_in sin;
- sigframe thisframe (mainthread);
-
- if (get_inet_addr (to, tolen, &sin, &tolen) == 0)
- return -1;
+ fhandler_socket *h = get (fd);
- if (h->is_nonblocking () || !(ovr = wsock_evt.prepare ()))
+ if ((len && __check_invalid_read_ptr_errno (buf, (unsigned) len))
+ || __check_null_invalid_struct_errno (to, tolen)
+ || !h)
+ res = -1;
+ else
{
- debug_printf ("Fallback to winsock 1 sendto call");
- if ((res = sendto (h->get_socket (), (const char *) buf, len, flags,
- to, tolen)) == SOCKET_ERROR)
+ sockaddr_in sin;
+ sigframe thisframe (mainthread);
+
+ if (get_inet_addr (to, tolen, &sin, &tolen) == 0)
+ return -1;
+
+ if (h->is_nonblocking () || !(ovr = wsock_evt.prepare ()))
{
- set_winsock_errno ();
- res = -1;
+ debug_printf ("Fallback to winsock 1 sendto call");
+ if ((res = sendto (h->get_socket (), (const char *) buf, len, flags,
+ (sockaddr *) &sin, tolen)) == SOCKET_ERROR)
+ {
+ set_winsock_errno ();
+ res = -1;
+ }
}
- }
- else
- {
- WSABUF wsabuf = { len, (char *) buf };
- DWORD ret = 0;
- if (WSASendTo (h->get_socket (), &wsabuf, 1, &ret, (DWORD)flags,
- to, tolen, ovr, NULL) != SOCKET_ERROR)
- res = ret;
- else if ((res = WSAGetLastError ()) != WSA_IO_PENDING)
+ else
{
- set_winsock_errno ();
- res = -1;
+ WSABUF wsabuf = { len, (char *) buf };
+ DWORD ret = 0;
+ if (WSASendTo (h->get_socket (), &wsabuf, 1, &ret, (DWORD)flags,
+ (sockaddr *) &sin, tolen, ovr, NULL) != SOCKET_ERROR)
+ res = ret;
+ else if ((res = WSAGetLastError ()) != WSA_IO_PENDING)
+ {
+ set_winsock_errno ();
+ res = -1;
+ }
+ else if ((res = wsock_evt.wait (h->get_socket (), (DWORD *)&flags)) == -1)
+ set_winsock_errno ();
}
- else if ((res = wsock_evt.wait (h->get_socket (), (DWORD *)&flags)) == -1)
- set_winsock_errno ();
}
syscall_printf ("%d = sendto (%d, %x, %x, %x)", res, fd, buf, len, flags);
@@ -664,33 +680,42 @@ cygwin_recvfrom (int fd,
int res;
wsock_event wsock_evt;
LPWSAOVERLAPPED ovr;
- fhandler_socket *h = (fhandler_socket *) cygheap->fdtab[fd];
- sigframe thisframe (mainthread);
+ fhandler_socket *h = get (fd);
- if (h->is_nonblocking () ||!(ovr = wsock_evt.prepare ()))
+ if (__check_null_invalid_struct_errno (buf, (unsigned) len)
+ || check_null_invalid_struct_errno (fromlen)
+ || (from && __check_null_invalid_struct_errno (from, (unsigned) *fromlen))
+ || !h)
+ res = -1;
+ else
{
- debug_printf ("Fallback to winsock 1 recvfrom call");
- if ((res = recvfrom (h->get_socket (), buf, len, flags, from, fromlen))
- == SOCKET_ERROR)
+ sigframe thisframe (mainthread);
+
+ if (h->is_nonblocking () ||!(ovr = wsock_evt.prepare ()))
{
- set_winsock_errno ();
- res = -1;
+ debug_printf ("Fallback to winsock 1 recvfrom call");
+ if ((res = recvfrom (h->get_socket (), buf, len, flags, from, fromlen))
+ == SOCKET_ERROR)
+ {
+ set_winsock_errno ();
+ res = -1;
+ }
}
- }
- else
- {
- WSABUF wsabuf = { len, (char *) buf };
- DWORD ret = 0;
- if (WSARecvFrom (h->get_socket (), &wsabuf, 1, &ret, (DWORD *)&flags,
- from, fromlen, ovr, NULL) != SOCKET_ERROR)
- res = ret;
- else if ((res = WSAGetLastError ()) != WSA_IO_PENDING)
+ else
{
- set_winsock_errno ();
- res = -1;
+ WSABUF wsabuf = { len, (char *) buf };
+ DWORD ret = 0;
+ if (WSARecvFrom (h->get_socket (), &wsabuf, 1, &ret, (DWORD *)&flags,
+ from, fromlen, ovr, NULL) != SOCKET_ERROR)
+ res = ret;
+ else if ((res = WSAGetLastError ()) != WSA_IO_PENDING)
+ {
+ set_winsock_errno ();
+ res = -1;
+ }
+ else if ((res = wsock_evt.wait (h->get_socket (), (DWORD *)&flags)) == -1)
+ set_winsock_errno ();
}
- else if ((res = wsock_evt.wait (h->get_socket (), (DWORD *)&flags)) == -1)
- set_winsock_errno ();
}
syscall_printf ("%d = recvfrom (%d, %x, %x, %x)", res, fd, buf, len, flags);
@@ -698,19 +723,6 @@ cygwin_recvfrom (int fd,
return res;
}
-/* Cygwin internal */
-fhandler_socket *
-get (int fd)
-{
- if (cygheap->fdtab.not_open (fd))
- {
- set_errno (EINVAL);
- return 0;
- }
-
- return cygheap->fdtab[fd]->is_socket ();
-}
-
/* exported as setsockopt: standards? */
extern "C" int
cygwin_setsockopt (int fd,
@@ -723,7 +735,7 @@ cygwin_setsockopt (int fd,
int res = -1;
const char *name = "error";
- if (h)
+ if ((!optval || !__check_invalid_read_ptr_errno (optval, optlen)) && h)
{
/* For the following debug_printf */
switch (optname)
@@ -786,7 +798,9 @@ cygwin_getsockopt (int fd,
fhandler_socket *h = get (fd);
int res = -1;
const char *name = "error";
- if (h)
+ if (!check_null_invalid_struct_errno (optlen)
+ && (!optval || !__check_null_invalid_struct_errno (optval, (unsigned) *optlen))
+ && h)
{
/* For the following debug_printf */
switch (optname)
@@ -855,13 +869,14 @@ cygwin_connect (int fd,
int secret [4];
sigframe thisframe (mainthread);
+ if (__check_invalid_read_ptr_errno (name, namelen))
+ return -1;
+
if (get_inet_addr (name, namelen, &sin, &namelen, secret) == 0)
return -1;
if (!sock)
- {
- res = -1;
- }
+ res = -1;
else
{
res = connect (sock->get_socket (), (sockaddr *) &sin, namelen);
@@ -987,6 +1002,10 @@ out:
extern "C" struct servent *
cygwin_getservbyname (const char *name, const char *proto)
{
+ if (check_null_str_errno (name)
+ || (proto != NULL && check_null_str_errno (proto)))
+ return NULL;
+
free_servent_ptr (servent_buf);
servent_buf = dup_servent_ptr (getservbyname (name, proto));
if (!servent_buf)
@@ -1000,6 +1019,9 @@ cygwin_getservbyname (const char *name, const char *proto)
extern "C" struct servent *
cygwin_getservbyport (int port, const char *proto)
{
+ if (proto != NULL && check_null_str_errno (proto))
+ return NULL;
+
free_servent_ptr (servent_buf);
servent_buf = dup_servent_ptr (getservbyport (port, proto));
if (!servent_buf)
@@ -1014,6 +1036,9 @@ cygwin_gethostname (char *name, size_t len)
{
int PASCAL win32_gethostname (char*, int);
+ if (__check_null_invalid_struct_errno (name, len))
+ return -1;
+
if (wsock32_handle == NULL ||
win32_gethostname (name, len) == SOCKET_ERROR)
{
@@ -1092,6 +1117,9 @@ cygwin_gethostbyname (const char *name)
static char *tmp_addr_list[2];
static int a, b, c, d;
+ if (check_null_str_errno (name))
+ return NULL;
+
if (sscanf (name, "%d.%d.%d.%d", &a, &b, &c, &d) == 4)
{
/* In case you don't have DNS, at least x.x.x.x still works */
@@ -1128,6 +1156,9 @@ cygwin_gethostbyname (const char *name)
extern "C" struct hostent *
cygwin_gethostbyaddr (const char *addr, int len, int type)
{
+ if (__check_null_invalid_struct_errno (addr, len))
+ return NULL;
+
free_hostent_ptr (hostent_buf);
hostent_buf = dup_hostent_ptr (gethostbyaddr (addr, len, type));
if (!hostent_buf)
@@ -1147,6 +1178,11 @@ cygwin_gethostbyaddr (const char *addr, int len, int type)
extern "C" int
cygwin_accept (int fd, struct sockaddr *peer, int *len)
{
+ if (peer != NULL
+ && (check_null_invalid_struct_errno (len)
+ || __check_null_invalid_struct_errno (peer, (unsigned) *len)))
+ return -1;
+
int res = -1;
BOOL secret_check_failed = FALSE;
BOOL in_progress = FALSE;
@@ -1210,16 +1246,11 @@ cygwin_accept (int fd, struct sockaddr *peer, int *len)
}
}
- SetResourceLock (LOCK_FD_LIST, WRITE_LOCK|READ_LOCK, "accept");
- int res_fd = cygheap->fdtab.find_unused_handle ();
- if (res_fd == -1)
- {
- /* FIXME: what is correct errno? */
- set_errno (EMFILE);
- goto lock_done;
- }
- if ((SOCKET) res == (SOCKET) INVALID_SOCKET)
+ cygheap_fdnew res_fd;
+ if (res_fd < 0)
+ /* FIXME: what is correct errno? */;
+ else if ((SOCKET) res == (SOCKET) INVALID_SOCKET)
set_winsock_errno ();
else
{
@@ -1228,9 +1259,7 @@ cygwin_accept (int fd, struct sockaddr *peer, int *len)
res = res_fd;
}
}
-lock_done:
- ReleaseResourceLock (LOCK_FD_LIST, WRITE_LOCK|READ_LOCK, "accept");
-done:
+ done:
syscall_printf ("%d = accept (%d, %x, %x)", res, fd, peer, len);
return res;
}
@@ -1239,6 +1268,9 @@ done:
extern "C" int
cygwin_bind (int fd, const struct sockaddr *my_addr, int addrlen)
{
+ if (__check_null_invalid_struct_errno (my_addr, addrlen))
+ return -1;
+
int res = -1;
fhandler_socket *sock = get (fd);
@@ -1306,6 +1338,7 @@ cygwin_bind (int fd, const struct sockaddr *my_addr, int addrlen)
_close (fd);
chmod (un_addr->sun_path,
(S_IFSOCK | S_IRWXU | S_IRWXG | S_IRWXO) & ~cygheap->umask);
+ sock->set_sun_path (un_addr->sun_path);
res = 0;
}
#undef un_addr
@@ -1325,15 +1358,36 @@ out:
extern "C" int
cygwin_getsockname (int fd, struct sockaddr *addr, int *namelen)
{
+ if (check_null_invalid_struct_errno (namelen)
+ || __check_null_invalid_struct_errno (addr, (unsigned) *namelen))
+ return -1;
+
int res = -1;
fhandler_socket *sock = get (fd);
if (sock)
{
- res = getsockname (sock->get_socket (), addr, namelen);
- if (res)
- set_winsock_errno ();
-
+ if (sock->get_addr_family () == AF_UNIX)
+ {
+ struct sockaddr_un *sun = (struct sockaddr_un *) addr;
+ memset (sun, 0, *namelen);
+ sun->sun_family = AF_UNIX;
+ /* According to SUSv2 "If the actual length of the address is greater
+ than the length of the supplied sockaddr structure, the stored
+ address will be truncated." We play it save here so that the
+ path always has a trailing 0 even if it's truncated. */
+ strncpy (sun->sun_path, sock->get_sun_path (),
+ *namelen - sizeof *sun + sizeof sun->sun_path - 1);
+ *namelen = sizeof *sun - sizeof sun->sun_path
+ + strlen (sun->sun_path) + 1;
+ res = 0;
+ }
+ else
+ {
+ res = getsockname (sock->get_socket (), addr, namelen);
+ if (res)
+ set_winsock_errno ();
+ }
}
syscall_printf ("%d = getsockname (%d, %x, %d)", res, fd, addr, namelen);
return res;
@@ -1406,6 +1460,8 @@ cygwin_hstrerror (int err)
extern "C" void
cygwin_herror (const char *s)
{
+ if (s && check_null_str (s))
+ return;
if (cygheap->fdtab.not_open (2))
return;
@@ -1438,12 +1494,21 @@ cygwin_herror (const char *s)
extern "C" int
cygwin_getpeername (int fd, struct sockaddr *name, int *len)
{
- fhandler_socket *h = (fhandler_socket *) cygheap->fdtab[fd];
+ int res;
+ if (check_null_invalid_struct_errno (len)
+ || __check_null_invalid_struct_errno (name, (unsigned) *len))
+ return -1;
- debug_printf ("getpeername %d", h->get_socket ());
- int res = getpeername (h->get_socket (), name, len);
- if (res)
- set_winsock_errno ();
+ fhandler_socket *h = get (fd);
+
+ if (!h)
+ res = -1;
+ else
+ {
+ res = getpeername (h->get_socket (), name, len);
+ if (res)
+ set_winsock_errno ();
+ }
debug_printf ("%d = getpeername %d", res, h->get_socket ());
return res;
@@ -1456,33 +1521,39 @@ cygwin_recv (int fd, void *buf, int len, unsigned int flags)
int res;
wsock_event wsock_evt;
LPWSAOVERLAPPED ovr;
- fhandler_socket *h = (fhandler_socket *) cygheap->fdtab[fd];
- sigframe thisframe (mainthread);
+ fhandler_socket *h = get (fd);
- if (h->is_nonblocking () || !(ovr = wsock_evt.prepare ()))
+ if (__check_null_invalid_struct_errno (buf, len) || !h)
+ res = -1;
+ else
{
- debug_printf ("Fallback to winsock 1 recv call");
- if ((res = recv (h->get_socket (), (char *) buf, len, flags))
- == SOCKET_ERROR)
+ sigframe thisframe (mainthread);
+
+ if (h->is_nonblocking () || !(ovr = wsock_evt.prepare ()))
{
- set_winsock_errno ();
- res = -1;
+ debug_printf ("Fallback to winsock 1 recv call");
+ if ((res = recv (h->get_socket (), (char *) buf, len, flags))
+ == SOCKET_ERROR)
+ {
+ set_winsock_errno ();
+ res = -1;
+ }
}
- }
- else
- {
- WSABUF wsabuf = { len, (char *) buf };
- DWORD ret = 0;
- if (WSARecv (h->get_socket (), &wsabuf, 1, &ret, (DWORD *)&flags,
- ovr, NULL) != SOCKET_ERROR)
- res = ret;
- else if ((res = WSAGetLastError ()) != WSA_IO_PENDING)
+ else
{
- set_winsock_errno ();
- res = -1;
+ WSABUF wsabuf = { len, (char *) buf };
+ DWORD ret = 0;
+ if (WSARecv (h->get_socket (), &wsabuf, 1, &ret, (DWORD *)&flags,
+ ovr, NULL) != SOCKET_ERROR)
+ res = ret;
+ else if ((res = WSAGetLastError ()) != WSA_IO_PENDING)
+ {
+ set_winsock_errno ();
+ res = -1;
+ }
+ else if ((res = wsock_evt.wait (h->get_socket (), (DWORD *)&flags)) == -1)
+ set_winsock_errno ();
}
- else if ((res = wsock_evt.wait (h->get_socket (), (DWORD *)&flags)) == -1)
- set_winsock_errno ();
}
syscall_printf ("%d = recv (%d, %x, %x, %x)", res, fd, buf, len, flags);
@@ -1497,33 +1568,39 @@ cygwin_send (int fd, const void *buf, int len, unsigned int flags)
int res;
wsock_event wsock_evt;
LPWSAOVERLAPPED ovr;
- fhandler_socket *h = (fhandler_socket *) cygheap->fdtab[fd];
- sigframe thisframe (mainthread);
+ fhandler_socket *h = get (fd);
- if (h->is_nonblocking () || !(ovr = wsock_evt.prepare ()))
+ if (__check_invalid_read_ptr_errno (buf, len) || !h)
+ res = -1;
+ else
{
- debug_printf ("Fallback to winsock 1 send call");
- if ((res = send (h->get_socket (), (const char *) buf, len, flags))
- == SOCKET_ERROR)
+ sigframe thisframe (mainthread);
+
+ if (h->is_nonblocking () || !(ovr = wsock_evt.prepare ()))
{
- set_winsock_errno ();
- res = -1;
+ debug_printf ("Fallback to winsock 1 send call");
+ if ((res = send (h->get_socket (), (const char *) buf, len, flags))
+ == SOCKET_ERROR)
+ {
+ set_winsock_errno ();
+ res = -1;
+ }
}
- }
- else
- {
- WSABUF wsabuf = { len, (char *) buf };
- DWORD ret = 0;
- if (WSASend (h->get_socket (), &wsabuf, 1, &ret, (DWORD)flags,
- ovr, NULL) != SOCKET_ERROR)
- res = ret;
- else if ((res = WSAGetLastError ()) != WSA_IO_PENDING)
+ else
{
- set_winsock_errno ();
- res = -1;
+ WSABUF wsabuf = { len, (char *) buf };
+ DWORD ret = 0;
+ if (WSASend (h->get_socket (), &wsabuf, 1, &ret, (DWORD)flags,
+ ovr, NULL) != SOCKET_ERROR)
+ res = ret;
+ else if ((res = WSAGetLastError ()) != WSA_IO_PENDING)
+ {
+ set_winsock_errno ();
+ res = -1;
+ }
+ else if ((res = wsock_evt.wait (h->get_socket (), (DWORD *)&flags)) == -1)
+ set_winsock_errno ();
}
- else if ((res = wsock_evt.wait (h->get_socket (), (DWORD *)&flags)) == -1)
- set_winsock_errno ();
}
syscall_printf ("%d = send (%d, %x, %d, %x)", res, fd, buf, len, flags);
@@ -1542,6 +1619,9 @@ getdomainname (char *domain, int len)
* in use and include paths for the Domain name in each ?
* Punt for now and assume MS-TCP on Win95.
*/
+ if (__check_null_invalid_struct_errno (domain, len))
+ return -1;
+
reg_key r (HKEY_LOCAL_MACHINE, KEY_READ,
(!wincap.is_winnt ()) ? "System" : "SYSTEM",
"CurrentControlSet", "Services",
@@ -1569,7 +1649,7 @@ static void
get_2k_ifconf (struct ifconf *ifc, int what)
{
int cnt = 0;
- char eth[2] = "/", ppp[2] = "/", slp[2] = "/";
+ char eth[2] = "/", ppp[2] = "/", slp[2] = "/", sub[2] = "0";
/* Union maps buffer to correct struct */
struct ifreq *ifr = ifc->ifc_req;
@@ -1589,84 +1669,98 @@ get_2k_ifconf (struct ifconf *ifc, int what)
!GetIfTable(ift, &siz_if_table, TRUE) &&
!GetIpAddrTable(ipt, &siz_ip_table, TRUE))
{
+ /* Iterate over all known interfaces */
for (if_cnt = 0; if_cnt < ift->dwNumEntries; ++if_cnt)
{
- switch (ift->table[if_cnt].dwType)
- {
- case MIB_IF_TYPE_ETHERNET:
- ++*eth;
- strcpy (ifr->ifr_name, "eth");
- strcat (ifr->ifr_name, eth);
- break;
- case MIB_IF_TYPE_PPP:
- ++*ppp;
- strcpy (ifr->ifr_name, "ppp");
- strcat (ifr->ifr_name, ppp);
- break;
- case MIB_IF_TYPE_SLIP:
- ++*slp;
- strcpy (ifr->ifr_name, "slp");
- strcat (ifr->ifr_name, slp);
- break;
- case MIB_IF_TYPE_LOOPBACK:
- strcpy (ifr->ifr_name, "lo");
- break;
- default:
- continue;
- }
+ *sub = '0';
+ /* Iterate over all configured IP-addresses */
for (ip_cnt = 0; ip_cnt < ipt->dwNumEntries; ++ip_cnt)
- if (ipt->table[ip_cnt].dwIndex == ift->table[if_cnt].dwIndex)
- {
- switch (what)
- {
- case SIOCGIFCONF:
- case SIOCGIFADDR:
- sa = (struct sockaddr_in *) &ifr->ifr_addr;
- sa->sin_addr.s_addr = ipt->table[ip_cnt].dwAddr;
- sa->sin_family = AF_INET;
- sa->sin_port = 0;
- break;
- case SIOCGIFBRDADDR:
- sa = (struct sockaddr_in *) &ifr->ifr_broadaddr;
+ {
+ /* Does the IP address belong to the interface? */
+ if (ipt->table[ip_cnt].dwIndex == ift->table[if_cnt].dwIndex)
+ {
+ /* Setup the interface name */
+ switch (ift->table[if_cnt].dwType)
+ {
+ case MIB_IF_TYPE_ETHERNET:
+ if (*sub == '0')
+ ++*eth;
+ strcpy (ifr->ifr_name, "eth");
+ strcat (ifr->ifr_name, eth);
+ break;
+ case MIB_IF_TYPE_PPP:
+ ++*ppp;
+ strcpy (ifr->ifr_name, "ppp");
+ strcat (ifr->ifr_name, ppp);
+ break;
+ case MIB_IF_TYPE_SLIP:
+ ++*slp;
+ strcpy (ifr->ifr_name, "slp");
+ strcat (ifr->ifr_name, slp);
+ break;
+ case MIB_IF_TYPE_LOOPBACK:
+ strcpy (ifr->ifr_name, "lo");
+ break;
+ default:
+ continue;
+ }
+ if (*sub > '0')
+ {
+ strcat (ifr->ifr_name, ":");
+ strcat (ifr->ifr_name, sub);
+ }
+ ++*sub;
+ /* setup sockaddr struct */
+ switch (what)
+ {
+ case SIOCGIFCONF:
+ case SIOCGIFADDR:
+ sa = (struct sockaddr_in *) &ifr->ifr_addr;
+ sa->sin_addr.s_addr = ipt->table[ip_cnt].dwAddr;
+ sa->sin_family = AF_INET;
+ sa->sin_port = 0;
+ break;
+ case SIOCGIFBRDADDR:
+ sa = (struct sockaddr_in *) &ifr->ifr_broadaddr;
#if 0
- /* Unfortunately, the field returns only crap. */
- sa->sin_addr.s_addr = ipt->table[ip_cnt].dwBCastAddr;
+ /* Unfortunately, the field returns only crap. */
+ sa->sin_addr.s_addr = ipt->table[ip_cnt].dwBCastAddr;
#else
- lip = ipt->table[ip_cnt].dwAddr;
- lnp = ipt->table[ip_cnt].dwMask;
- sa->sin_addr.s_addr = lip & lnp | ~lnp;
- sa->sin_family = AF_INET;
- sa->sin_port = 0;
+ lip = ipt->table[ip_cnt].dwAddr;
+ lnp = ipt->table[ip_cnt].dwMask;
+ sa->sin_addr.s_addr = lip & lnp | ~lnp;
+ sa->sin_family = AF_INET;
+ sa->sin_port = 0;
#endif
- break;
- case SIOCGIFNETMASK:
- sa = (struct sockaddr_in *) &ifr->ifr_netmask;
- sa->sin_addr.s_addr = ipt->table[ip_cnt].dwMask;
- sa->sin_family = AF_INET;
- sa->sin_port = 0;
- break;
- case SIOCGIFHWADDR:
- so = &ifr->ifr_hwaddr;
- for (UINT i = 0; i < IFHWADDRLEN; ++i)
- if (i >= ift->table[if_cnt].dwPhysAddrLen)
- so->sa_data[i] = '\0';
- else
- so->sa_data[i] = ift->table[if_cnt].bPhysAddr[i];
- so->sa_family = AF_INET;
- break;
- case SIOCGIFMETRIC:
- ifr->ifr_metric = 1;
- break;
- case SIOCGIFMTU:
- ifr->ifr_mtu = ift->table[if_cnt].dwMtu;
- break;
- }
- ++cnt;
- if ((caddr_t) ++ifr >
- ifc->ifc_buf + ifc->ifc_len - sizeof (struct ifreq))
- goto done;
- break;
- }
+ break;
+ case SIOCGIFNETMASK:
+ sa = (struct sockaddr_in *) &ifr->ifr_netmask;
+ sa->sin_addr.s_addr = ipt->table[ip_cnt].dwMask;
+ sa->sin_family = AF_INET;
+ sa->sin_port = 0;
+ break;
+ case SIOCGIFHWADDR:
+ so = &ifr->ifr_hwaddr;
+ for (UINT i = 0; i < IFHWADDRLEN; ++i)
+ if (i >= ift->table[if_cnt].dwPhysAddrLen)
+ so->sa_data[i] = '\0';
+ else
+ so->sa_data[i] = ift->table[if_cnt].bPhysAddr[i];
+ so->sa_family = AF_INET;
+ break;
+ case SIOCGIFMETRIC:
+ ifr->ifr_metric = 1;
+ break;
+ case SIOCGIFMTU:
+ ifr->ifr_mtu = ift->table[if_cnt].dwMtu;
+ break;
+ }
+ ++cnt;
+ if ((caddr_t) ++ifr >
+ ifc->ifc_buf + ifc->ifc_len - sizeof (struct ifreq))
+ goto done;
+ }
+ }
}
}
done:
@@ -1921,7 +2015,7 @@ get_95_ifconf (struct ifconf *ifc, int what)
++i)
{
HKEY ifkey, subkey;
- char driver[256], classname[256], bindname[256], netname[256];
+ char driver[256], classname[256], netname[256];
char adapter[256], ip[256], np[256];
if (res != ERROR_SUCCESS
@@ -1997,57 +2091,34 @@ get_95_ifconf (struct ifconf *ifc, int what)
RegCloseKey (subkey);
- if (RegOpenKeyEx (ifkey, "Bindings",
- 0, KEY_READ, &subkey) != ERROR_SUCCESS)
- {
+ strcpy (netname, "System\\CurrentControlSet\\Services\\Class\\Net\\");
+ strcat (netname, ifname);
+
+ if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, netname,
+ 0, KEY_READ, &subkey) != ERROR_SUCCESS)
+ {
RegCloseKey (ifkey);
--ifr;
continue;
- }
-
- for (int j = 0;
- (res = RegEnumValue (subkey, j, bindname,
- (size = sizeof bindname, &size),
- 0, NULL, NULL, NULL)) != ERROR_NO_MORE_ITEMS;
- ++j)
- if (!strncasecmp (bindname, "VREDIR\\", 7))
- break;
-
- RegCloseKey (subkey);
-
- if (res == ERROR_SUCCESS)
- {
- strcpy (netname, "System\\CurrentControlSet\\Services\\Class\\Net\\");
- strcat (netname, bindname + 7);
-
- if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, netname,
- 0, KEY_READ, &subkey) != ERROR_SUCCESS)
- {
- RegCloseKey (ifkey);
- --ifr;
- continue;
- }
+ }
- if (RegQueryValueEx (subkey, "AdapterName", 0,
- NULL, (unsigned char *) adapter,
- (size = sizeof adapter, &size)) == ERROR_SUCCESS
+ if (RegQueryValueEx (subkey, "AdapterName", 0,
+ NULL, (unsigned char *) adapter,
+ (size = sizeof adapter, &size)) == ERROR_SUCCESS
&& strcasematch (adapter, "MS$PPP"))
- {
- ++*ppp;
- strcpy (ifr->ifr_name, "ppp");
- strcat (ifr->ifr_name, ppp);
- }
- else
- {
- ++*eth;
- strcpy (ifr->ifr_name, "eth");
- strcat (ifr->ifr_name, eth);
- }
-
- RegCloseKey (subkey);
-
- }
+ {
+ ++*ppp;
+ strcpy (ifr->ifr_name, "ppp");
+ strcat (ifr->ifr_name, ppp);
+ }
+ else
+ {
+ ++*eth;
+ strcpy (ifr->ifr_name, "eth");
+ strcat (ifr->ifr_name, eth);
+ }
+ RegCloseKey (subkey);
RegCloseKey (ifkey);
++cnt;
@@ -2067,6 +2138,9 @@ get_ifconf (struct ifconf *ifc, int what)
unsigned long lip, lnp;
struct sockaddr_in *sa;
+ if (check_null_invalid_struct_errno (ifc))
+ return -1;
+
/* Union maps buffer to correct struct */
struct ifreq *ifr = ifc->ifc_req;
@@ -2141,18 +2215,25 @@ cygwin_rcmd (char **ahost, unsigned short inport, char *locuser,
SOCKET fd2s;
sigframe thisframe (mainthread);
- int res_fd = cygheap->fdtab.find_unused_handle ();
- if (res_fd == -1)
+ if (check_null_invalid_struct_errno (ahost) ||
+ check_null_empty_str_errno (*ahost) ||
+ (locuser && check_null_empty_str_errno (locuser)) ||
+ (remuser && check_null_str_errno (remuser)))
+ return (int) INVALID_SOCKET;
+
+ cygheap_fdnew res_fd;
+ if (res_fd < 0)
goto done;
if (fd2p)
{
- *fd2p = cygheap->fdtab.find_unused_handle (res_fd + 1);
- if (*fd2p == -1)
+ cygheap_fdnew newfd (res_fd, false);
+ if (*fd2p < 0)
goto done;
+ *fd2p = newfd;
}
- res = rcmd (ahost, inport, locuser, remuser, cmd, fd2p? &fd2s: NULL);
+ res = rcmd (ahost, inport, locuser, remuser, cmd, fd2p ? &fd2s : NULL);
if (res == (int) INVALID_SOCKET)
goto done;
else
@@ -2160,10 +2241,10 @@ cygwin_rcmd (char **ahost, unsigned short inport, char *locuser,
fdsock (res_fd, "/dev/tcp", res);
res = res_fd;
}
+
if (fd2p)
- {
- fdsock (*fd2p, "/dev/tcp", fd2s);
- }
+ fdsock (*fd2p, "/dev/tcp", fd2s);
+
done:
syscall_printf ("%d = rcmd (...)", res);
return res;
@@ -2173,22 +2254,26 @@ done:
extern "C" int
cygwin_rresvport (int *port)
{
- int res = -1;
+ int res;
sigframe thisframe (mainthread);
- int res_fd = cygheap->fdtab.find_unused_handle ();
- if (res_fd == -1)
- goto done;
- res = rresvport (port);
+ if (check_null_invalid_struct_errno (port))
+ return -1;
- if (res == (int) INVALID_SOCKET)
- goto done;
+ cygheap_fdnew res_fd;
+ if (res_fd < 0)
+ res = -1;
else
{
- fdsock (res_fd, "/dev/tcp", res);
- res = res_fd;
+ res = rresvport (port);
+
+ if (res != (int) INVALID_SOCKET)
+ {
+ fdsock (res_fd, "/dev/tcp", res);
+ res = res_fd;
+ }
}
-done:
+
syscall_printf ("%d = rresvport (%d)", res, port ? *port : 0);
return res;
}
@@ -2202,14 +2287,21 @@ cygwin_rexec (char **ahost, unsigned short inport, char *locuser,
SOCKET fd2s;
sigframe thisframe (mainthread);
- int res_fd = cygheap->fdtab.find_unused_handle ();
- if (res_fd == -1)
+ if (check_null_invalid_struct_errno (ahost) ||
+ check_null_empty_str_errno (*ahost) ||
+ (locuser && check_null_empty_str_errno (locuser)) ||
+ (password && check_null_str_errno (password)))
+ return (int) INVALID_SOCKET;
+
+ cygheap_fdnew res_fd;
+ if (res_fd < 0)
goto done;
if (fd2p)
{
- *fd2p = cygheap->fdtab.find_unused_handle (res_fd + 1);
- if (*fd2p == -1)
+ cygheap_fdnew newfd (res_fd);
+ if (newfd < 0)
goto done;
+ *fd2p = newfd;
}
res = rexec (ahost, inport, locuser, password, cmd, fd2p ? &fd2s : NULL);
if (res == (int) INVALID_SOCKET)
@@ -2237,21 +2329,21 @@ socketpair (int, int type, int, int *sb)
struct sockaddr_in sock_in;
int len = sizeof (sock_in);
- SetResourceLock (LOCK_FD_LIST, WRITE_LOCK|READ_LOCK, "socketpair");
+ if (__check_null_invalid_struct_errno (sb, 2 * sizeof(int)))
+ return -1;
- sb[0] = cygheap->fdtab.find_unused_handle ();
- if (sb[0] == -1)
- {
- set_errno (EMFILE);
- goto done;
- }
- sb[1] = cygheap->fdtab.find_unused_handle (sb[0] + 1);
- if (sb[1] == -1)
+ cygheap_fdnew sb0;
+ if (sb0 < 0)
+ goto done;
+ else
{
- set_errno (EMFILE);
- goto done;
- }
+ sb[0] = sb0;
+ cygheap_fdnew sb1 (sb0, false);
+ if (sb1 < 0)
+ goto done;
+ sb[1] = sb1;
+ }
/* create a listening socket */
newsock = socket (AF_INET, type, 0);
if (newsock == INVALID_SOCKET)
@@ -2326,7 +2418,6 @@ socketpair (int, int type, int, int *sb)
done:
syscall_printf ("%d = socketpair (...)", res);
- ReleaseResourceLock (LOCK_FD_LIST, WRITE_LOCK|READ_LOCK, "socketpair");
return res;
}
diff --git a/winsup/cygwin/ntdll.h b/winsup/cygwin/ntdll.h
index 6dd617c60..e1ec33bc1 100644
--- a/winsup/cygwin/ntdll.h
+++ b/winsup/cygwin/ntdll.h
@@ -9,6 +9,7 @@
details. */
#define STATUS_INFO_LENGTH_MISMATCH ((NTSTATUS) 0xc0000004)
+#define FILE_SYNCHRONOUS_IO_NONALERT 32
typedef enum _SYSTEM_INFORMATION_CLASS
{
@@ -132,6 +133,12 @@ typedef struct _SYSTEM_PROCESSES
SYSTEM_THREADS Threads[1];
} SYSTEM_PROCESSES, *PSYSTEM_PROCESSES;
+typedef struct _IO_STATUS_BLOCK
+{
+ NTSTATUS Status;
+ ULONG Information;
+} IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
+
/* Function declarations for ntdll.dll. These don't appear in any
standard Win32 header. */
extern "C"
@@ -144,6 +151,8 @@ extern "C"
NTSTATUS NTAPI NtMapViewOfSection (HANDLE, HANDLE, PVOID *, ULONG, ULONG,
PLARGE_INTEGER, PULONG, SECTION_INHERIT,
ULONG, ULONG);
+ NTSTATUS NTAPI NtOpenFile (PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES,
+ PIO_STATUS_BLOCK, ULONG, ULONG);
NTSTATUS NTAPI NtOpenSection (PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES);
NTSTATUS NTAPI NtQuerySystemInformation (SYSTEM_INFORMATION_CLASS,
PVOID, ULONG, PULONG);
diff --git a/winsup/cygwin/passwd.cc b/winsup/cygwin/passwd.cc
index 2f52473c7..c18ee1601 100644
--- a/winsup/cygwin/passwd.cc
+++ b/winsup/cygwin/passwd.cc
@@ -170,7 +170,7 @@ read_etc_passwd ()
{
debug_printf ("Emulating /etc/passwd");
snprintf (linebuf, sizeof (linebuf), "%s::%u:%u::%s:/bin/sh", cygheap->user.name (),
- DEFAULT_UID, DEFAULT_GID, getenv ("HOME") ?: "/");
+ (unsigned) DEFAULT_UID, (unsigned) DEFAULT_GID, getenv ("HOME") ?: "/");
add_pwd_line (linebuf);
passwd_state = emulated;
}
@@ -385,14 +385,12 @@ getpass (const char * prompt)
if (passwd_state <= initializing)
read_etc_passwd ();
- if (cygheap->fdtab.not_open (0))
- {
- set_errno (EBADF);
- pass[0] = '\0';
- }
+ cygheap_fdget fhstdin (0);
+
+ if (fhstdin < 0)
+ pass[0] = '\0';
else
{
- fhandler_base *fhstdin = cygheap->fdtab[0];
fhstdin->tcgetattr (&ti);
newti = ti;
newti.c_lflag &= ~ECHO;
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index 2aa19e1aa..aa0ec5454 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -100,19 +100,21 @@ struct symlink_info
int is_symlink;
bool ext_tacked_on;
int error;
- BOOL case_clash;
+ bool case_clash;
int check (char *path, const suffix_info *suffixes, unsigned opt);
BOOL case_check (char *path);
};
int pcheck_case = PCHECK_RELAXED; /* Determines the case check behaviour. */
+#define CYGWIN_REGNAME (cygheap->cygwin_regname ?: CYGWIN_INFO_CYGWIN_REGISTRY_NAME)
+
/* Determine if path prefix matches current cygdrive */
#define iscygdrive(path) \
(path_prefix_p (mount_table->cygdrive, (path), mount_table->cygdrive_len))
#define iscygdrive_device(path) \
- (iscygdrive(path) && isalpha(path[mount_table->cygdrive_len]) && \
+ (isalpha(path[mount_table->cygdrive_len]) && \
(isdirsep(path[mount_table->cygdrive_len + 1]) || \
!path[mount_table->cygdrive_len + 1]))
@@ -209,6 +211,12 @@ normalize_posix_path (const char *src, char *dst)
*dst++ = '/';
src = src_start + 1;
}
+ else if (src[0] == '.' && isslash (src[1]))
+ {
+ *dst++ = '.';
+ *dst++ = '/';
+ src += 2;
+ }
}
else
*dst = '\0';
@@ -393,7 +401,7 @@ path_conv::check (const char *src, unsigned opt,
path_flags = 0;
known_suffix = NULL;
fileattr = (DWORD) -1;
- case_clash = FALSE;
+ case_clash = false;
devn = unit = 0;
root_dir[0] = '\0';
fs_name[0] = '\0';
@@ -471,21 +479,38 @@ path_conv::check (const char *src, unsigned opt,
if (error)
return;
- update_fs_info (full_path);
-
+ if (devn == FH_CYGDRIVE)
+ {
+ if (!component)
+ fileattr = FILE_ATTRIBUTE_DIRECTORY;
+ else
+ {
+ devn = FH_BAD;
+ fileattr = GetFileAttributes (this->path);
+ }
+ goto out;
+ }
/* devn should not be a device. If it is, then stop parsing now. */
- if (devn != FH_BAD)
+ else if (devn != FH_BAD)
{
fileattr = 0;
+ if (component)
+ {
+ error = ENOTDIR;
+ return;
+ }
goto out; /* Found a device. Stop parsing. */
}
+ update_fs_info (full_path);
+
/* Eat trailing slashes */
char *dostail = strchr (full_path, '\0');
- /* If path is only a drivename, Windows interprets it as the current working
- directory on this drive instead of the root dir which is what we want. So
- we need the trailing backslash in this case. */
+ /* If path is only a drivename, Windows interprets it as the
+ current working directory on this drive instead of the root
+ dir which is what we want. So we need the trailing backslash
+ in this case. */
while (dostail > full_path + 3 && (*--dostail == '\\'))
*tail = '\0';
@@ -497,7 +522,7 @@ path_conv::check (const char *src, unsigned opt,
if ((opt & PC_SYM_IGNORE) && pcheck_case == PCHECK_RELAXED)
{
- fileattr = GetFileAttributesA (full_path);
+ fileattr = GetFileAttributes (this->path);
goto out;
}
@@ -518,7 +543,6 @@ path_conv::check (const char *src, unsigned opt,
if (!component)
case_clash = TRUE;
}
-
if (!(opt & PC_SYM_IGNORE))
{
if (!component)
@@ -668,25 +692,32 @@ out:
return;
}
- update_fs_info (path);
- if (!fs_name[0])
- {
- set_has_acls (FALSE);
- set_has_buggy_open (FALSE);
- }
- else
+ if (devn == FH_BAD)
{
- set_isdisk ();
- debug_printf ("root_dir(%s), this->path(%s), set_has_acls(%d)",
- root_dir, this->path, fs_flags & FS_PERSISTENT_ACLS);
- if (!allow_smbntsec && is_remote_drive)
- set_has_acls (FALSE);
+ update_fs_info (path);
+ if (!fs_name[0])
+ {
+ set_has_acls (false);
+ set_has_buggy_open (false);
+ }
else
- set_has_acls (fs_flags & FS_PERSISTENT_ACLS);
- /* Known file systems with buggy open calls. Further explanation
- in fhandler.cc (fhandler_disk_file::open). */
- set_has_buggy_open (strcmp (fs_name, "SUNWNFS") == 0);
+ {
+ set_isdisk ();
+ debug_printf ("root_dir(%s), this->path(%s), set_has_acls(%d)",
+ root_dir, this->path, fs_flags & FS_PERSISTENT_ACLS);
+ if (!allow_smbntsec && is_remote_drive)
+ set_has_acls (false);
+ else
+ set_has_acls (fs_flags & FS_PERSISTENT_ACLS);
+ /* Known file systems with buggy open calls. Further explanation
+ in fhandler.cc (fhandler_disk_file::open). */
+ set_has_buggy_open (strcmp (fs_name, "SUNWNFS") == 0);
+ }
}
+#if 0
+ if (issocket ())
+ devn = FH_SOCKET;
+#endif
if (!(opt & PC_FULL))
{
@@ -728,9 +759,6 @@ out:
#endif
}
-#define deveq(s) (strcasematch (name, (s)))
-#define deveqn(s, n) (strncasematch (name, (s), (n)))
-
static __inline int
digits (const char *name)
{
@@ -769,106 +797,220 @@ const char *windows_device_names[] NO_COPY =
"\\dev\\dsp"
};
-static int
-get_raw_device_number (const char *uxname, const char *w32path, int &unit)
-{
- DWORD devn = FH_BAD;
+#define deveq(s) (strcasematch (name, (s)))
+#define deveqn(s, n) (strncasematch (name, (s), (n)))
+#define wdeveq(s) (strcasematch (w32_path, (s)))
+#define wdeveqn(s, n) (strncasematch (w32_path, (s), (n)))
+#define udeveq(s) (strcasematch (unix_path, (s)))
+#define udeveqn(s, n) (strncasematch (unix_path, (s), (n)))
- if (strncasematch (w32path, "\\\\.\\tape", 8))
- {
- devn = FH_TAPE;
- unit = digits (w32path + 8);
- // norewind tape devices have leading n in name
- if (strncasematch (uxname, "/dev/n", 6))
- unit += 128;
- }
- else if (isdrive (w32path + 4))
+static int __stdcall
+get_devn (const char *name, int &unit)
+{
+ int devn = FH_BAD;
+ name += 5;
+ if (deveq ("tty"))
{
- devn = FH_FLOPPY;
- unit = cyg_tolower (w32path[4]) - 'a';
+ if (real_tty_attached (myself))
+ {
+ unit = myself->ctty;
+ devn = FH_TTYS;
+ }
+ else if (myself->ctty > 0)
+ devn = FH_CONSOLE;
+ }
+ else if (deveqn ("tty", 3) && (unit = digits (name + 3)) >= 0)
+ devn = FH_TTYS;
+ else if (deveq ("ttym"))
+ devn = FH_TTYM;
+ else if (deveq ("ptmx"))
+ devn = FH_PTYM;
+ else if (deveq ("windows"))
+ devn = FH_WINDOWS;
+ else if (deveq ("dsp"))
+ devn = FH_OSS_DSP;
+ else if (deveq ("conin"))
+ devn = FH_CONIN;
+ else if (deveq ("conout"))
+ devn = FH_CONOUT;
+ else if (deveq ("null"))
+ devn = FH_NULL;
+ else if (deveq ("zero"))
+ devn = FH_ZERO;
+ else if (deveq ("random") || deveq ("urandom"))
+ {
+ devn = FH_RANDOM;
+ unit = 8 + (deveqn ("u", 1) ? 1 : 0); /* Keep unit Linux conformant */
+ }
+ else if (deveq ("mem"))
+ {
+ devn = FH_MEM;
+ unit = 1;
+ }
+ else if (deveq ("clipboard"))
+ devn = FH_CLIPBOARD;
+ else if (deveq ("port"))
+ {
+ devn = FH_MEM;
+ unit = 4;
}
- else if (strncasematch (w32path, "\\\\.\\physicaldrive", 17))
+ else if (deveqn ("com", 3) && (unit = digits (name + 3)) >= 0)
+ devn = FH_SERIAL;
+ else if (deveqn ("ttyS", 4) && (unit = digits (name + 4)) >= 0)
{
- devn = FH_FLOPPY;
- unit = digits (w32path + 17) + 128;
+ devn = FH_SERIAL;
+ unit++;
}
+ else if (deveq ("pipe"))
+ devn = FH_PIPE;
+ else if (deveq ("piper"))
+ devn = FH_PIPER;
+ else if (deveq ("pipew"))
+ devn = FH_PIPEW;
+ else if (deveq ("tcp") || deveq ("udp") || deveq ("streamsocket")
+ || deveq ("dgsocket"))
+ devn = FH_SOCKET;
+
return devn;
}
-int __stdcall
-get_device_number (const char *name, int &unit, BOOL from_conv)
+/*
+ major minor POSIX filename NT filename
+ ----- ----- -------------- -------------------------
+ FH_TAPE 0 /dev/st0 \device\tape0
+ FH_TAPE 1 /dev/st1 \device\tape1
+ ...
+ FH_TAPE 128 /dev/nst0 \device\tape0
+ FH_TAPE 129 /dev/nst1 \device\tape1
+ ...
+
+ FH_FLOPPY 0 /dev/fd0 \device\floppy0
+ FH_FLOPPY 1 /dev/fd1 \device\floppy1
+ ...
+
+ FH_FLOPPY 16 /dev/scd0 \device\cdrom0
+ FH_FLOPPY 17 /dev/scd0 \device\cdrom1
+ ...
+
+ FH_FLOPPY 32 /dev/sda \device\harddisk0\partition0
+ FH_FLOPPY 33 /dev/sda1 \device\harddisk0\partition1
+ ...
+ FH_FLOPPY 47 /dev/sda15 \device\harddisk0\partition15
+
+ FH_FLOPPY 48 /dev/sdb \device\harddisk1\partition0
+ FH_FLOPPY 33 /dev/sdb1 \device\harddisk1\partition1
+ ...
+ FH_FLOPPY 208 /dev/sdl \device\harddisk11\partition0
+ ...
+ FH_FLOPPY 223 /dev/sdl15 \device\harddisk11\partition15
+
+ The following are needed to maintain backward compatibility with
+ the old Win32 partitioning scheme on W2K/XP.
+
+ FH_FLOPPY 224 from mount tab \\.\A:
+ ...
+ FH_FLOPPY 250 from mount tab \\.\Z:
+*/
+static int
+get_raw_device_number (const char *name, const char *w32_path, int &unit)
{
DWORD devn = FH_BAD;
- unit = 0;
- if ((*name == '/' && deveqn ("/dev/", 5)) ||
- (*name == '\\' && deveqn ("\\dev\\", 5)))
+ if (!w32_path) /* New approach using fixed device names. */
{
- name += 5;
- if (deveq ("tty"))
+ if (deveqn ("st", 2))
{
- if (real_tty_attached (myself))
- {
- unit = myself->ctty;
- devn = FH_TTYS;
- }
- else if (myself->ctty > 0)
- devn = FH_CONSOLE;
+ unit = digits (name + 2);
+ if (unit >= 0 && unit < 128)
+ devn = FH_TAPE;
}
- else if (deveqn ("tty", 3) && (unit = digits (name + 3)) >= 0)
- devn = FH_TTYS;
- else if (deveq ("ttym"))
- devn = FH_TTYM;
- else if (deveq ("ptmx"))
- devn = FH_PTYM;
- else if (deveq ("windows"))
- devn = FH_WINDOWS;
- else if (deveq ("dsp"))
- devn = FH_OSS_DSP;
- else if (deveq ("conin"))
- devn = FH_CONIN;
- else if (deveq ("conout"))
- devn = FH_CONOUT;
- else if (deveq ("null"))
- devn = FH_NULL;
- else if (deveq ("zero"))
- devn = FH_ZERO;
- else if (deveq ("random") || deveq ("urandom"))
+ else if (deveqn ("nst", 3))
{
- devn = FH_RANDOM;
- unit = 8 + (deveqn ("u", 1) ? 1 : 0); /* Keep unit Linux conformant */
+ unit = digits (name + 3) + 128;
+ if (unit >= 128 && unit < 256)
+ devn = FH_TAPE;
}
- else if (deveq ("mem"))
+ else if (deveqn ("fd", 2))
{
- devn = FH_MEM;
- unit = 1;
+ unit = digits (name + 2);
+ if (unit >= 0 && unit < 16)
+ devn = FH_FLOPPY;
}
- else if (deveq ("clipboard"))
- devn = FH_CLIPBOARD;
- else if (deveq ("port"))
+ else if (deveqn ("scd", 3))
{
- devn = FH_MEM;
- unit = 4;
+ unit = digits (name + 3) + 16;
+ if (unit >= 16 && unit < 32)
+ devn = FH_FLOPPY;
}
- else if (deveqn ("com", 3) && (unit = digits (name + 3)) >= 0)
- devn = FH_SERIAL;
- else if (deveqn ("ttyS", 4) && (unit = digits (name + 4)) >= 0)
+ else if (deveqn ("sd", 2) && isalpha (name[2]))
+ {
+ unit = (cyg_tolower (name[2]) - 'a') * 16 + 32;
+ if (unit >= 32 && unit < 224)
+ if (!name[3])
+ devn = FH_FLOPPY;
+ else
+ {
+ int d = digits (name + 3);
+ if (d >= 1 && d < 16)
+ {
+ unit += d;
+ devn = FH_FLOPPY;
+ }
+ }
+ }
+ }
+ else /* Backward compatible checking of mount table device mapping. */
+ {
+ if (wdeveqn ("tape", 4))
+ {
+ unit = digits (w32_path + 4);
+ /* Norewind tape devices have leading n in name. */
+ if (deveqn ("n", 1))
+ unit += 128;
+ devn = FH_TAPE;
+ }
+ else if (wdeveqn ("physicaldrive", 13))
+ {
+ unit = digits (w32_path + 13) * 16 + 32;
+ devn = FH_FLOPPY;
+ }
+ else if (isdrive (w32_path))
+ {
+ unit = cyg_tolower (w32_path[0]) - 'a' + 224;
+ devn = FH_FLOPPY;
+ }
+ }
+ return devn;
+}
+
+static int __stdcall get_device_number (const char *unix_path,
+ const char *w32_path, int &unit)
+ __attribute__ ((regparm(3)));
+static int __stdcall
+get_device_number (const char *unix_path, const char *w32_path, int &unit)
+{
+ DWORD devn = FH_BAD;
+ unit = 0;
+
+ if (*unix_path == '/' && udeveqn ("/dev/", 5))
+ {
+ devn = get_devn (unix_path, unit);
+ if (devn == FH_BAD && *w32_path == '\\' && wdeveqn ("\\dev\\", 5))
+ devn = get_devn (w32_path, unit);
+ if (devn == FH_BAD && wdeveqn ("\\\\.\\", 4))
+ devn = get_raw_device_number (unix_path + 5, w32_path + 4, unit);
+ if (devn == FH_BAD)
+ devn = get_raw_device_number (unix_path + 5, NULL, unit);
+ }
+ else
+ {
+ char *p = strrchr (unix_path, '/');
+ if (p)
+ unix_path = p + 1;
+ if (udeveqn ("com", 3)
+ && (unit = digits (unix_path + 3)) >= 0)
devn = FH_SERIAL;
- else if (deveq ("pipe") || deveq ("piper") || deveq ("pipew"))
- devn = FH_PIPE;
- else if (deveq ("tcp") || deveq ("udp") || deveq ("streamsocket")
- || deveq ("dgsocket"))
- devn = FH_SOCKET;
- else if (!from_conv)
- devn = get_raw_device_number (name - 5,
- path_conv (name - 5,
- PC_SYM_IGNORE).get_win32 (),
- unit);
}
- else if (deveqn ("com", 3) && (unit = digits (name + 3)) >= 0)
- devn = FH_SERIAL;
- else if (deveqn ("ttyS", 4) && (unit = digits (name + 4)) >= 0)
- devn = FH_SERIAL;
return devn;
}
@@ -882,17 +1024,36 @@ win32_device_name (const char *src_path, char *win32_path,
{
const char *devfmt;
- devn = get_device_number (src_path, unit, TRUE);
+ devn = get_device_number (src_path, win32_path, unit);
if (devn == FH_BAD)
- return FALSE;
+ return false;
if ((devfmt = windows_device_names[FHDEVN (devn)]) == NULL)
- return FALSE;
- if (devn == FH_RANDOM)
- __small_sprintf (win32_path, devfmt, unit == 8 ? "" : "u");
- else
- __small_sprintf (win32_path, devfmt, unit);
+ return false;
+ switch (devn)
+ {
+ case FH_RANDOM:
+ __small_sprintf (win32_path, devfmt, unit == 8 ? "" : "u");
+ break;
+ case FH_TAPE:
+ __small_sprintf (win32_path, "\\Device\\Tape%d", unit % 128);
+ break;
+ case FH_FLOPPY:
+ if (unit < 16)
+ __small_sprintf (win32_path, "\\Device\\Floppy%d", unit);
+ else if (unit < 32)
+ __small_sprintf (win32_path, "\\Device\\CdRom%d", unit - 16);
+ else if (unit < 224)
+ __small_sprintf (win32_path, "\\Device\\Harddisk%d\\Partition%d",
+ (unit - 32) / 16, unit % 16);
+ else
+ __small_sprintf (win32_path, "\\DosDevices\\%c:", unit - 224 + 'A');
+ break;
+ default:
+ __small_sprintf (win32_path, devfmt, unit);
+ break;
+ }
return TRUE;
}
@@ -913,7 +1074,13 @@ normalize_win32_path (const char *src, char *dst)
if (beg_src_slash && isdirsep (src[1]))
{
*dst++ = '\\';
- ++src;
+ src++;
+ if (src[1] == '.' && isdirsep (src[2]))
+ {
+ *dst++ = '\\';
+ *dst++ = '.';
+ src += 2;
+ }
}
else if (strchr (src, ':') == NULL && *src != '/')
{
@@ -1083,25 +1250,20 @@ conv_path_list (const char *src, char *dst, int to_posix_p)
? cygwin_conv_to_posix_path
: cygwin_conv_to_win32_path);
- do
+ char *srcbuf = (char *) alloca (strlen (src) + 1);
+
+ for (;;)
{
- s = strchr (src, src_delim);
- if (s)
- {
- *s = 0;
- (*conv_fn) (src[0] != 0 ? src : ".", d);
- d += strlen (d);
- *d++ = dst_delim;
- *s = src_delim;
- src = s + 1;
- }
- else
- {
- /* Last one. */
- (*conv_fn) (src[0] != 0 ? src : ".", d);
- }
+ s = strccpy (srcbuf, &src, src_delim);
+ int len = s - srcbuf;
+ if (len >= MAX_PATH)
+ srcbuf[MAX_PATH - 1] = '\0';
+ (*conv_fn) (len ? srcbuf : ".", d);
+ if (!*src++)
+ break;
+ d = strchr (d, '\0');
+ *d++ = dst_delim;
}
- while (s != NULL);
}
/* init: Initialize the mount table. */
@@ -1224,12 +1386,24 @@ mount_info::conv_to_win32_path (const char *src_path, char *dst,
/* Check if the cygdrive prefix was specified. If so, just strip
off the prefix and transform it into an MS-DOS path. */
MALLOC_CHECK;
- if (iscygdrive_device (pathbuf))
+ if (iscygdrive (pathbuf))
{
- if (!cygdrive_win32_path (pathbuf, dst, 0))
+ int n = mount_table->cygdrive_len - 1;
+ if (!pathbuf[n] ||
+ (pathbuf[n] == '/' && pathbuf[n + 1] == '.' && !pathbuf[n + 2]))
+ {
+ unit = 0;
+ dst[0] = '\0';
+ if (mount_table->cygdrive_len > 1)
+ devn = FH_CYGDRIVE;
+ }
+ else if (cygdrive_win32_path (pathbuf, dst, unit))
+ {
+ *flags = cygdrive_flags;
+ goto out;
+ }
+ else if (mount_table->cygdrive_len > 1)
return ENOENT;
- *flags = cygdrive_flags;
- goto out;
}
int chrooted_path_len;
@@ -1298,6 +1472,9 @@ mount_info::conv_to_win32_path (const char *src_path, char *dst,
*flags = mi->flags;
}
+ if (devn != FH_CYGDRIVE)
+ win32_device_name (src_path, dst, devn, unit);
+
out:
MALLOC_CHECK;
if (chroot_ok || cygheap->root.ischroot_native (dst))
@@ -1345,17 +1522,27 @@ mount_info::cygdrive_posix_path (const char *src, char *dst, int trailing_slash_
}
int
-mount_info::cygdrive_win32_path (const char *src, char *dst, int trailing_slash_p)
+mount_info::cygdrive_win32_path (const char *src, char *dst, int& unit)
{
+ int res;
const char *p = src + cygdrive_len;
if (!isalpha (*p) || (!isdirsep (p[1]) && p[1]))
- return 0;
- dst[0] = *p;
- dst[1] = ':';
- strcpy (dst + 2, p + 1);
- backslashify (dst, dst, trailing_slash_p || !dst[2]);
+ {
+ unit = -1;
+ dst[0] = '\0';
+ res = 0;
+ }
+ else
+ {
+ dst[0] = cyg_tolower (*p);
+ dst[1] = ':';
+ strcpy (dst + 2, p + 1);
+ backslashify (dst, dst, !dst[2]);
+ unit = dst[0];
+ res = 1;
+ }
debug_printf ("src '%s', dst '%s'", src, dst);
- return 1;
+ return res;
}
/* conv_to_posix_path: Ensure src_path is a POSIX path.
@@ -1542,7 +1729,7 @@ mount_info::read_mounts (reg_key& r)
mount_flags = subkey.get_int ("flags", 0);
/* Add mount_item corresponding to registry mount point. */
- res = mount_table->add_item (native_path, posix_path, mount_flags, FALSE);
+ res = mount_table->add_item (native_path, posix_path, mount_flags, false);
if (res && get_errno () == EMFILE)
break; /* The number of entries exceeds MAX_MOUNTS */
}
@@ -1569,8 +1756,7 @@ mount_info::from_registry ()
/* Then read mounts from system-wide mount table. */
reg_key r1 (HKEY_LOCAL_MACHINE, KEY_READ, "SOFTWARE",
- CYGWIN_INFO_CYGNUS_REGISTRY_NAME,
- CYGWIN_INFO_CYGWIN_REGISTRY_NAME,
+ CYGWIN_INFO_CYGNUS_REGISTRY_NAME, CYGWIN_REGNAME,
CYGWIN_INFO_CYGWIN_MOUNT_REGISTRY_NAME,
NULL);
read_mounts (r1);
@@ -1615,8 +1801,7 @@ mount_info::add_reg_mount (const char * native_path, const char * posix_path, un
{
/* reg_key for system mounts in HKEY_LOCAL_MACHINE. */
reg_key reg_sys (HKEY_LOCAL_MACHINE, KEY_ALL_ACCESS, "SOFTWARE",
- CYGWIN_INFO_CYGNUS_REGISTRY_NAME,
- CYGWIN_INFO_CYGWIN_REGISTRY_NAME,
+ CYGWIN_INFO_CYGNUS_REGISTRY_NAME, CYGWIN_REGNAME,
CYGWIN_INFO_CYGWIN_MOUNT_REGISTRY_NAME,
NULL);
@@ -1664,8 +1849,7 @@ mount_info::del_reg_mount (const char * posix_path, unsigned flags)
sys_mount_table_counter++;
cygwin_shared->sys_mount_table_counter++;
reg_key reg_sys (HKEY_LOCAL_MACHINE, KEY_ALL_ACCESS, "SOFTWARE",
- CYGWIN_INFO_CYGNUS_REGISTRY_NAME,
- CYGWIN_INFO_CYGWIN_REGISTRY_NAME,
+ CYGWIN_INFO_CYGNUS_REGISTRY_NAME, CYGWIN_REGNAME,
CYGWIN_INFO_CYGWIN_MOUNT_REGISTRY_NAME,
NULL);
res = reg_sys.kill (posix_path);
@@ -1690,34 +1874,22 @@ mount_info::read_cygdrive_info_from_registry ()
/* reg_key for user path prefix in HKEY_CURRENT_USER. */
reg_key r;
- if (r.get_string (CYGWIN_INFO_CYGDRIVE_PREFIX, cygdrive, sizeof (cygdrive),
- "") != 0)
+ if (r.get_string (CYGWIN_INFO_CYGDRIVE_PREFIX, cygdrive, sizeof (cygdrive), "") != 0)
{
/* Didn't find the user path prefix so check the system path prefix. */
/* reg_key for system path prefix in HKEY_LOCAL_MACHINE. */
reg_key r2 (HKEY_LOCAL_MACHINE, KEY_READ, "SOFTWARE",
- CYGWIN_INFO_CYGNUS_REGISTRY_NAME,
- CYGWIN_INFO_CYGWIN_REGISTRY_NAME,
+ CYGWIN_INFO_CYGNUS_REGISTRY_NAME, CYGWIN_REGNAME,
CYGWIN_INFO_CYGWIN_MOUNT_REGISTRY_NAME,
NULL);
- if (r2.get_string (CYGWIN_INFO_CYGDRIVE_PREFIX, cygdrive, sizeof (cygdrive),
- "") != 0)
- {
- /* Didn't find either so write the default to the registry and use it.
- NOTE: We are writing and using the user path prefix. */
- write_cygdrive_info_to_registry (CYGWIN_INFO_CYGDRIVE_DEFAULT_PREFIX,
- MOUNT_AUTO);
- }
- else
- {
- /* Fetch system cygdrive_flags from registry; returns MOUNT_AUTO on
- error. */
- cygdrive_flags = r2.get_int (CYGWIN_INFO_CYGDRIVE_FLAGS, MOUNT_AUTO);
- slashify (cygdrive, cygdrive, 1);
- cygdrive_len = strlen(cygdrive);
- }
+ if (r2.get_string (CYGWIN_INFO_CYGDRIVE_PREFIX, cygdrive,
+ sizeof (cygdrive), ""))
+ strcpy (cygdrive, CYGWIN_INFO_CYGDRIVE_DEFAULT_PREFIX);
+ cygdrive_flags = r2.get_int (CYGWIN_INFO_CYGDRIVE_FLAGS, MOUNT_AUTO);
+ slashify (cygdrive, cygdrive, 1);
+ cygdrive_len = strlen (cygdrive);
}
else
{
@@ -1748,8 +1920,7 @@ mount_info::write_cygdrive_info_to_registry (const char *cygdrive_prefix, unsign
/* reg_key for user path prefix in HKEY_CURRENT_USER or system path prefix in
HKEY_LOCAL_MACHINE. */
reg_key r (top, KEY_ALL_ACCESS, "SOFTWARE",
- CYGWIN_INFO_CYGNUS_REGISTRY_NAME,
- CYGWIN_INFO_CYGWIN_REGISTRY_NAME,
+ CYGWIN_INFO_CYGNUS_REGISTRY_NAME, CYGWIN_REGNAME,
CYGWIN_INFO_CYGWIN_MOUNT_REGISTRY_NAME,
NULL);
@@ -1805,8 +1976,7 @@ mount_info::remove_cygdrive_info_from_registry (const char *cygdrive_prefix, uns
/* reg_key for user path prefix in HKEY_CURRENT_USER or system path prefix in
HKEY_LOCAL_MACHINE. */
reg_key r (top, KEY_ALL_ACCESS, "SOFTWARE",
- CYGWIN_INFO_CYGNUS_REGISTRY_NAME,
- CYGWIN_INFO_CYGWIN_REGISTRY_NAME,
+ CYGWIN_INFO_CYGNUS_REGISTRY_NAME, CYGWIN_REGNAME,
CYGWIN_INFO_CYGWIN_MOUNT_REGISTRY_NAME,
NULL);
@@ -1838,8 +2008,7 @@ mount_info::get_cygdrive_info (char *user, char *system, char* user_flags,
/* Get the system path prefix from HKEY_LOCAL_MACHINE. */
reg_key r2 (HKEY_LOCAL_MACHINE, KEY_READ, "SOFTWARE",
- CYGWIN_INFO_CYGNUS_REGISTRY_NAME,
- CYGWIN_INFO_CYGWIN_REGISTRY_NAME,
+ CYGWIN_INFO_CYGNUS_REGISTRY_NAME, CYGWIN_REGNAME,
CYGWIN_INFO_CYGWIN_MOUNT_REGISTRY_NAME,
NULL);
int res2 = r2.get_string (CYGWIN_INFO_CYGDRIVE_PREFIX, system, MAX_PATH, "");
@@ -2023,7 +2192,7 @@ int
mount_info::del_item (const char *path, unsigned flags, int reg_p)
{
char pathtmp[MAX_PATH];
- int posix_path_p = FALSE;
+ int posix_path_p = false;
/* Something's wrong if path is NULL or empty. */
if (path == NULL || *path == 0 || !isabspath (path))
@@ -2160,7 +2329,7 @@ fillout_mntent (const char *native_path, const char *posix_path, unsigned flags)
/* Remove drivenum from list if we see a x: style path */
if (strlen (native_path) == 2 && native_path[1] == ':')
{
- int drivenum = tolower (native_path[0]) - 'a';
+ int drivenum = cyg_tolower (native_path[0]) - 'a';
if (drivenum >= 0 && drivenum <= 31)
available_drives &= ~(1 << drivenum);
}
@@ -2274,8 +2443,7 @@ mount_item::init (const char *native, const char *posix, unsigned mountflags)
that will cause paths under win32_path to be translated to paths
under posix_path. */
-extern "C"
-int
+extern "C" int
mount (const char *win32_path, const char *posix_path, unsigned flags)
{
int res = -1;
@@ -2300,8 +2468,7 @@ mount (const char *win32_path, const char *posix_path, unsigned flags)
mount from the user or global mount registry table, assume the user
table. */
-extern "C"
-int
+extern "C" int
umount (const char *path)
{
return cygwin_umount (path, 0);
@@ -2311,8 +2478,7 @@ umount (const char *path)
parameter that specifies whether to umount from the user or system-wide
registry area. */
-extern "C"
-int
+extern "C" int
cygwin_umount (const char *path, unsigned flags)
{
int res = -1;
@@ -2333,8 +2499,7 @@ cygwin_umount (const char *path, unsigned flags)
return res;
}
-extern "C"
-FILE *
+extern "C" FILE *
setmntent (const char *filep, const char *)
{
iteration = 0;
@@ -2342,15 +2507,13 @@ setmntent (const char *filep, const char *)
return (FILE *) filep;
}
-extern "C"
-struct mntent *
+extern "C" struct mntent *
getmntent (FILE *)
{
return mount_table->getmntent (iteration++);
}
-extern "C"
-int
+extern "C" int
endmntent (FILE *)
{
return 1;
@@ -2375,19 +2538,18 @@ set_symlink_ea (const char* frompath, const char* topath)
if (!NTWriteEA (frompath, SYMLINK_EA_NAME, topath, strlen (topath) + 1))
{
debug_printf ("Cannot save symlink in EA");
- return FALSE;
+ return false;
}
return TRUE;
}
/* Create a symlink from FROMPATH to TOPATH. */
-/* If TRUE create symlinks as Windows shortcuts, if FALSE create symlinks
+/* If TRUE create symlinks as Windows shortcuts, if false create symlinks
as normal files with magic number and system bit set. */
int allow_winsymlinks = TRUE;
-extern "C"
-int
+extern "C" int
symlink (const char *topath, const char *frompath)
{
HANDLE h;
@@ -2401,7 +2563,7 @@ symlink (const char *topath, const char *frompath)
/* POSIX says that empty 'frompath' is invalid input whlie empty
'topath' is valid -- it's symlink resolver job to verify if
- symlink contents point to existing filesystem object */
+ symlink contents point to existing filesystem object */
if (check_null_empty_str_errno (topath) == EFAULT ||
check_null_empty_str_errno (frompath))
goto done;
@@ -2465,9 +2627,9 @@ symlink (const char *topath, const char *frompath)
&sa, alloca (4096), 4096);
h = CreateFileA(win32_path, GENERIC_WRITE, 0, &sa,
- CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0);
+ CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0);
if (h == INVALID_HANDLE_VALUE)
- __seterrno ();
+ __seterrno ();
else
{
BOOL success;
@@ -2511,9 +2673,16 @@ symlink (const char *topath, const char *frompath)
set_file_attribute (win32_path.has_acls (),
win32_path.get_win32 (),
S_IFLNK | S_IRWXU | S_IRWXG | S_IRWXO);
- SetFileAttributesA (win32_path.get_win32 (),
- allow_winsymlinks ? FILE_ATTRIBUTE_READONLY
- : FILE_ATTRIBUTE_SYSTEM);
+
+ DWORD attr = allow_winsymlinks ? FILE_ATTRIBUTE_READONLY
+ : FILE_ATTRIBUTE_SYSTEM;
+#ifdef HIDDEN_DOT_FILES
+ cp = strrchr (win32_path, '\\');
+ if ((cp && cp[1] == '.') || *win32_path == '.')
+ attr |= FILE_ATTRIBUTE_HIDDEN;
+#endif
+ SetFileAttributes (win32_path.get_win32 (), attr);
+
if (win32_path.fs_fast_ea ())
set_symlink_ea (win32_path, topath);
res = 0;
@@ -2736,18 +2905,18 @@ symlink_info::check (char *path, const suffix_info *suffixes, unsigned opt)
pflags &= ~PATH_SYMLINK;
- case_clash = FALSE;
+ case_clash = false;
while (suffix.next ())
{
error = 0;
- fileattr = GetFileAttributesA (suffix.path);
+ fileattr = GetFileAttributes (suffix.path);
if (fileattr == (DWORD) -1)
{
- /* The GetFileAttributesA call can fail for reasons that don't
+ /* The GetFileAttributes call can fail for reasons that don't
matter, so we just return 0. For example, getting the
attributes of \\HOST will typically fail. */
- debug_printf ("GetFileAttributesA (%s) failed", suffix.path);
+ debug_printf ("GetFileAttributes (%s) failed", suffix.path);
error = geterrno_from_win_error (GetLastError (), EACCES);
continue;
}
@@ -2820,7 +2989,7 @@ symlink_info::check (char *path, const suffix_info *suffixes, unsigned opt)
break;
file_not_symlink:
- is_symlink = FALSE;
+ is_symlink = false;
syscall_printf ("not a symlink");
res = 0;
break;
@@ -2833,7 +3002,7 @@ symlink_info::check (char *path, const suffix_info *suffixes, unsigned opt)
/* Check the correct case of the last path component (given in DOS style).
Adjust the case in this->path if pcheck_case == PCHECK_ADJUST or return
- FALSE if pcheck_case == PCHECK_STRICT.
+ false if pcheck_case == PCHECK_STRICT.
Dont't call if pcheck_case == PCHECK_RELAXED.
*/
@@ -2863,7 +3032,7 @@ symlink_info::case_check (char *path)
/* If check is set to STRICT, a wrong case results
in returning a ENOENT. */
if (pcheck_case == PCHECK_STRICT)
- return FALSE;
+ return false;
/* PCHECK_ADJUST adjusts the case in the incoming
path which points to the path in *this. */
@@ -2875,8 +3044,7 @@ symlink_info::case_check (char *path)
/* readlink system call */
-extern "C"
-int
+extern "C" int
readlink (const char *path, char *buf, int buflen)
{
extern suffix_info stat_suffixes[];
@@ -2986,16 +3154,15 @@ char *
getcwd (char *buf, size_t ulen)
{
char* res = NULL;
- if (ulen == 0)
+ if (ulen == 0 && buf)
set_errno (EINVAL);
- else if (!__check_null_invalid_struct_errno (buf, ulen))
+ else if (buf == NULL || !__check_null_invalid_struct_errno (buf, ulen))
res = cygheap->cwd.get (buf, 1, 1, ulen);
return res;
}
/* getwd: standards? */
-extern "C"
-char *
+extern "C" char *
getwd (char *buf)
{
return getcwd (buf, MAX_PATH);
@@ -3054,7 +3221,7 @@ chdir (const char *in_dir)
return -1;
}
- char *native_dir = path.get_win32 ();
+ const char *native_dir = path.get_win32 ();
/* Check to see if path translates to something like C:.
If it does, append a \ to the native directory specification to
@@ -3062,10 +3229,17 @@ chdir (const char *in_dir)
the last directory visited on the given drive. */
if (isdrive (native_dir) && !native_dir[2])
{
- native_dir[2] = '\\';
- native_dir[3] = '\0';
+ path.get_win32 ()[2] = '\\';
+ path.get_win32 ()[3] = '\0';
+ }
+ int res;
+ if (path.get_devn () != FH_CYGDRIVE)
+ res = SetCurrentDirectory (native_dir) ? 0 : -1;
+ else
+ {
+ native_dir = "c:\\";
+ res = 0;
}
- int res = SetCurrentDirectoryA (native_dir) ? 0 : -1;
/* If res < 0, we didn't change to a new directory.
Otherwise, set the current windows and posix directory cache from input.
@@ -3081,9 +3255,9 @@ chdir (const char *in_dir)
__seterrno ();
else if (!path.has_symlinks () && strpbrk (dir, ":\\") == NULL
&& pcheck_case == PCHECK_RELAXED)
- cygheap->cwd.set (path, dir);
+ cygheap->cwd.set (native_dir, dir);
else
- cygheap->cwd.set (path, NULL);
+ cygheap->cwd.set (native_dir, NULL);
/* Note that we're accessing cwd.posix without a lock here. I didn't think
it was worth locking just for strace. */
@@ -3093,39 +3267,20 @@ chdir (const char *in_dir)
return res;
}
-extern "C"
-int
+extern "C" int
fchdir (int fd)
{
+ int res;
sigframe thisframe (mainthread);
- if (cygheap->fdtab.not_open (fd))
- {
- syscall_printf ("-1 = fchdir (%d)", fd);
- set_errno (EBADF);
- return -1;
- }
- SetResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "fchdir");
- int ret = chdir (cygheap->fdtab[fd]->get_name ());
- if (ret == 0)
- {
- /* The name in the fhandler is explicitely overwritten with the full path.
- Otherwise fchmod() to a path originally given as a relative path could
- end up in a completely different directory. Imagine:
-
- fd = open ("..");
- fchmod(fd);
- fchmod(fd);
-
- The 2nd fchmod should chdir to the same dir as the first call, not
- to it's parent dir. */
- char posix_path[MAX_PATH];
- cygheap->fdtab.reset_unix_path_name (fd, cygheap->cwd.get (posix_path, 1, 1));
- }
+ cygheap_fdget cfd (fd);
+ if (cfd >= 0)
+ res = chdir (cfd->get_name ());
+ else
+ res = -1;
- ReleaseResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "fchdir");
- syscall_printf ("%d = fchdir (%d)", ret, fd);
- return ret;
+ syscall_printf ("%d = fchdir (%d)", res, fd);
+ return res;
}
/******************** Exported Path Routines *********************/
@@ -3133,40 +3288,39 @@ fchdir (int fd)
/* Cover functions to the path conversion routines.
These are exported to the world as cygwin_foo by cygwin.din. */
-extern "C"
-int
+extern "C" int
cygwin_conv_to_win32_path (const char *path, char *win32_path)
{
path_conv p (path, PC_SYM_FOLLOW);
if (p.error)
{
+ win32_path[0] = '\0';
set_errno (p.error);
return -1;
}
- strcpy (win32_path, p.get_win32 ());
+ strcpy (win32_path, p);
return 0;
}
-extern "C"
-int
+extern "C" int
cygwin_conv_to_full_win32_path (const char *path, char *win32_path)
{
path_conv p (path, PC_SYM_FOLLOW | PC_FULL);
if (p.error)
{
+ win32_path[0] = '\0';
set_errno (p.error);
return -1;
}
- strcpy (win32_path, p.get_win32 ());
+ strcpy (win32_path, p);
return 0;
}
/* This is exported to the world as cygwin_foo by cygwin.din. */
-extern "C"
-int
+extern "C" int
cygwin_conv_to_posix_path (const char *path, char *posix_path)
{
if (check_null_empty_str_errno (path))
@@ -3175,8 +3329,7 @@ cygwin_conv_to_posix_path (const char *path, char *posix_path)
return 0;
}
-extern "C"
-int
+extern "C" int
cygwin_conv_to_full_posix_path (const char *path, char *posix_path)
{
if (check_null_empty_str_errno (path))
@@ -3187,8 +3340,7 @@ cygwin_conv_to_full_posix_path (const char *path, char *posix_path)
/* The realpath function is supported on some UNIX systems. */
-extern "C"
-char *
+extern "C" char *
realpath (const char *path, char *resolved)
{
int err;
@@ -3228,8 +3380,7 @@ DOCTOOL-START
DOCTOOL-END
*/
-extern "C"
-int
+extern "C" int
cygwin_posix_path_list_p (const char *path)
{
int posix_p = !(strchr (path, ';') || isdrive (path));
@@ -3270,30 +3421,26 @@ conv_path_list_buf_size (const char *path_list, int to_posix_p)
return size;
}
-extern "C"
-int
+extern "C" int
cygwin_win32_to_posix_path_list_buf_size (const char *path_list)
{
return conv_path_list_buf_size (path_list, 1);
}
-extern "C"
-int
+extern "C" int
cygwin_posix_to_win32_path_list_buf_size (const char *path_list)
{
return conv_path_list_buf_size (path_list, 0);
}
-extern "C"
-int
+extern "C" int
cygwin_win32_to_posix_path_list (const char *win32, char *posix)
{
conv_path_list (win32, posix, 1);
return 0;
}
-extern "C"
-int
+extern "C" int
cygwin_posix_to_win32_path_list (const char *posix, char *win32)
{
conv_path_list (posix, win32, 0);
@@ -3319,8 +3466,7 @@ cygwin_posix_to_win32_path_list (const char *posix, char *win32)
c:/foo -> `c:/' / `foo'
*/
-extern "C"
-void
+extern "C" void
cygwin_split_path (const char *path, char *dir, char *file)
{
int dir_started_p = 0;
@@ -3400,7 +3546,7 @@ cwdstuff::get_hash ()
void
cwdstuff::init ()
{
- lock = new_muto (FALSE, "cwd");
+ lock = new_muto (false, "cwd");
}
/* Get initial cwd. Should only be called once in a
diff --git a/winsup/cygwin/path.h b/winsup/cygwin/path.h
index 1052debda..766c2a261 100644
--- a/winsup/cygwin/path.h
+++ b/winsup/cygwin/path.h
@@ -136,6 +136,7 @@ class path_conv
DWORD file_attributes () {return fileattr;}
DWORD get_drive_type () {return drive_type;}
BOOL fs_fast_ea () {return sym_opt & PC_CHECK_EA;}
+ void set_path (const char *p) {strcpy (path, p);}
};
/* Symlink marker */
@@ -148,12 +149,20 @@ class path_conv
/* Maximum depth of symlinks (after which ELOOP is issued). */
#define MAX_LINK_DEPTH 10
-
-int __stdcall get_device_number (const char *name, int &unit, BOOL from_conv = FALSE) __attribute__ ((regparm(3)));
int __stdcall slash_unc_prefix_p (const char *path) __attribute__ ((regparm(1)));
-const char * __stdcall find_exec (const char *name, path_conv& buf, const char *winenv = "PATH=",
- int null_if_notfound = 0, const char **known_suffix = NULL) __attribute__ ((regparm(3)));
+enum fe_types
+{
+ FE_NADA = 0, /* Nothing special */
+ FE_NNF = 1, /* Return NULL if not found */
+ FE_NATIVE = 2, /* Return native path in path_conv struct */
+ FE_CWD = 4 /* Search CWD for program */
+};
+const char * __stdcall find_exec (const char *name, path_conv& buf,
+ const char *winenv = "PATH=",
+ unsigned opt = FE_NADA,
+ const char **known_suffix = NULL)
+ __attribute__ ((regparm(3)));
/* Common macros for checking for invalid path names */
#define isdrive(s) (isalpha (*(s)) && (s)[1] == ':')
diff --git a/winsup/cygwin/perthread.h b/winsup/cygwin/perthread.h
index 185cc04d6..48ad97621 100644
--- a/winsup/cygwin/perthread.h
+++ b/winsup/cygwin/perthread.h
@@ -15,27 +15,6 @@ details. */
struct _reent;
extern struct _reent reent_data;
-extern DWORD *__stackbase __asm__ ("%fs:4");
-
-extern __inline struct _reent *
-get_reent ()
-{
- DWORD *base = __stackbase - 1;
-
- if (*base != PTMAGIC)
- return &reent_data;
- return (struct _reent *) base[-1];
-}
-
-extern inline void
-set_reent (struct _reent *r)
-{
- DWORD *base = __stackbase - 1;
-
- *base = PTMAGIC;
- base[-1] = (DWORD) r;
-}
-
#define PER_THREAD_FORK_CLEAR ((void *)0xffffffff)
class per_thread
{
diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc
index 6e66e47a1..43e3c5aae 100644
--- a/winsup/cygwin/pinfo.cc
+++ b/winsup/cygwin/pinfo.cc
@@ -117,14 +117,17 @@ pinfo_init (char **envp, int envc)
void
_pinfo::exit (UINT n, bool norecord)
{
- if (!norecord)
- process_state = PID_EXITED;
-
- /* FIXME: There is a potential race between an execed process and its
- parent here. I hated to add a mutex just for this, though. */
- struct rusage r;
- fill_rusage (&r, hMainProc);
- add_rusage (&rusage_self, &r);
+ if (this)
+ {
+ if (!norecord)
+ process_state = PID_EXITED;
+
+ /* FIXME: There is a potential race between an execed process and its
+ parent here. I hated to add a mutex just for this, though. */
+ struct rusage r;
+ fill_rusage (&r, hMainProc);
+ add_rusage (&rusage_self, &r);
+ }
sigproc_printf ("Calling ExitProcess %d", n);
ExitProcess (n);
@@ -182,7 +185,8 @@ pinfo::init (pid_t n, DWORD flag, HANDLE in_h)
procinfo = (_pinfo *) MapViewOfFile (h, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0);
ProtectHandle1 (h, pinfo_shared_handle);
- if ((procinfo->process_state & PID_INITIALIZING) && (flag & PID_NOREDIR))
+ if ((procinfo->process_state & PID_INITIALIZING) && (flag & PID_NOREDIR)
+ && cygwin_pid (procinfo->dwProcessId) != procinfo->pid)
{
release ();
set_errno (ENOENT);
@@ -293,8 +297,8 @@ winpids::add (DWORD& nelem, bool winpid, DWORD pid)
if (nelem >= npidlist)
{
npidlist += slop_pidlist;
- pidlist = (DWORD *) realloc (pidlist, size_pidlist (npidlist));
- pinfolist = (pinfo *) realloc (pinfolist, size_pinfolist (npidlist));
+ pidlist = (DWORD *) realloc (pidlist, size_pidlist (npidlist + 1));
+ pinfolist = (pinfo *) realloc (pinfolist, size_pinfolist (npidlist + 1));
}
pinfolist[nelem].init (cygpid, PID_NOREDIR);
@@ -324,7 +328,7 @@ winpids::enumNT (bool winpid)
DWORD nelem = 0;
if (!szprocs)
- procs = (SYSTEM_PROCESSES *) malloc (szprocs = 200 * sizeof (*procs));
+ procs = (SYSTEM_PROCESSES *) malloc (sizeof (*procs) + (szprocs = 200 * sizeof (*procs)));
NTSTATUS res;
for (;;)
@@ -387,7 +391,8 @@ void
winpids::init (bool winpid)
{
npids = (this->*enum_processes) (winpid);
- pidlist[npids] = 0;
+ if (pidlist)
+ pidlist[npids] = 0;
}
DWORD
diff --git a/winsup/cygwin/pipe.cc b/winsup/cygwin/pipe.cc
index 099aa37b3..6e5266d7c 100644
--- a/winsup/cygwin/pipe.cc
+++ b/winsup/cygwin/pipe.cc
@@ -25,11 +25,10 @@ details. */
static unsigned pipecount;
static const NO_COPY char pipeid_fmt[] = "stupid_pipe.%u.%u";
-fhandler_pipe::fhandler_pipe (const char *name, DWORD devtype) :
- fhandler_base (devtype, name),
- guard (0), writepipe_exists(0), orig_pid (0), id (0)
+fhandler_pipe::fhandler_pipe (DWORD devtype)
+ : fhandler_base (devtype), guard (NULL), broken_pipe (false), writepipe_exists(0),
+ orig_pid (0), id (0)
{
- set_cb (sizeof *this);
}
off_t
@@ -50,11 +49,13 @@ fhandler_pipe::set_close_on_exec (int val)
set_inheritance (writepipe_exists, val);
}
-int
+int __stdcall
fhandler_pipe::read (void *in_ptr, size_t in_len)
{
+ if (broken_pipe)
+ return 0;
int res = this->fhandler_base::read (in_ptr, in_len);
- ReleaseMutex (guard);
+ (void) ReleaseMutex (guard);
return res;
}
@@ -73,6 +74,8 @@ fhandler_pipe::hit_eof ()
{
char buf[80];
HANDLE ev;
+ if (broken_pipe)
+ return 1;
if (!orig_pid)
return false;
__small_sprintf (buf, pipeid_fmt, orig_pid, id);
@@ -129,51 +132,51 @@ fhandler_pipe::dup (fhandler_base *child)
int
make_pipe (int fildes[2], unsigned int psize, int mode)
{
- SetResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "make_pipe");
-
HANDLE r, w;
- int fdr = -1, fdw = -1;
SECURITY_ATTRIBUTES *sa = (mode & O_NOINHERIT) ? &sec_none_nih : &sec_none;
int res = -1;
- if ((fdr = cygheap->fdtab.find_unused_handle ()) < 0)
- set_errno (ENMFILE);
- else if ((fdw = cygheap->fdtab.find_unused_handle (fdr + 1)) < 0)
- set_errno (ENMFILE);
- else if (!CreatePipe (&r, &w, sa, psize))
- __seterrno ();
- else
+ cygheap_fdnew fdr;
+ if (fdr >= 0)
{
- fhandler_pipe *fhr = (fhandler_pipe *) cygheap->fdtab.build_fhandler (fdr, FH_PIPER, "/dev/piper");
- fhandler_pipe *fhw = (fhandler_pipe *) cygheap->fdtab.build_fhandler (fdw, FH_PIPEW, "/dev/pipew");
-
- int binmode = mode & O_TEXT ? 0 : 1;
- fhr->init (r, GENERIC_READ, binmode);
- fhw->init (w, GENERIC_WRITE, binmode);
- if (mode & O_NOINHERIT)
- {
- fhr->set_close_on_exec_flag (1);
- fhw->set_close_on_exec_flag (1);
- }
-
- fildes[0] = fdr;
- fildes[1] = fdw;
-
- res = 0;
- fhr->create_guard (sa);
- if (wincap.has_unreliable_pipes ())
+ cygheap_fdnew fdw (fdr, false);
+ if (fdw < 0)
+ /* out of fds? */;
+ else if (!CreatePipe (&r, &w, sa, psize))
+ __seterrno ();
+ else
{
- char buf[80];
- int count = pipecount++; /* FIXME: Should this be InterlockedIncrement? */
- __small_sprintf (buf, pipeid_fmt, myself->pid, count);
- fhw->writepipe_exists = CreateEvent (sa, TRUE, FALSE, buf);
- fhr->orig_pid = myself->pid;
- fhr->id = count;
+ fhandler_pipe *fhr = (fhandler_pipe *) cygheap->fdtab.build_fhandler (fdr, FH_PIPER, "/dev/piper");
+ fhandler_pipe *fhw = (fhandler_pipe *) cygheap->fdtab.build_fhandler (fdw, FH_PIPEW, "/dev/pipew");
+
+ int binmode = mode & O_TEXT ? 0 : 1;
+ fhr->init (r, GENERIC_READ, binmode);
+ fhw->init (w, GENERIC_WRITE, binmode);
+ if (mode & O_NOINHERIT)
+ {
+ fhr->set_close_on_exec_flag (1);
+ fhw->set_close_on_exec_flag (1);
+ }
+
+ fildes[0] = fdr;
+ fildes[1] = fdw;
+
+ res = 0;
+ fhr->create_guard (sa);
+ if (wincap.has_unreliable_pipes ())
+ {
+ char buf[80];
+ int count = pipecount++; /* FIXME: Should this be InterlockedIncrement? */
+ __small_sprintf (buf, pipeid_fmt, myself->pid, count);
+ fhw->writepipe_exists = CreateEvent (sa, TRUE, FALSE, buf);
+ fhr->orig_pid = myself->pid;
+ fhr->id = count;
+ }
}
}
- syscall_printf ("%d = make_pipe ([%d, %d], %d, %p)", res, fdr, fdw, psize, mode);
- ReleaseResourceLock(LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "make_pipe");
+ syscall_printf ("%d = make_pipe ([%d, %d], %d, %p)", res, fildes[0],
+ fildes[1], psize, mode);
return res;
}
diff --git a/winsup/cygwin/poll.cc b/winsup/cygwin/poll.cc
index 2ac606849..8b73c5afd 100644
--- a/winsup/cygwin/poll.cc
+++ b/winsup/cygwin/poll.cc
@@ -12,12 +12,13 @@
#include <sys/time.h>
#include <sys/poll.h>
#include <errno.h>
+#include <stdlib.h>
#include "security.h"
#include "fhandler.h"
#include "path.h"
#include "dtable.h"
-#include "cygheap.h"
#include "cygerrno.h"
+#include "cygheap.h"
#include "sigproc.h"
extern "C"
@@ -51,10 +52,12 @@ poll (struct pollfd *fds, unsigned int nfds, int timeout)
memset (write_fds, 0, fds_size);
memset (except_fds, 0, fds_size);
- bool invalid_fds = false;
+ bool valid_fds = false;
for (unsigned int i = 0; i < nfds; ++i)
if (!cygheap->fdtab.not_open (fds[i].fd))
{
+ valid_fds = true;
+ fds[i].revents = 0;
FD_SET (fds[i].fd, open_fds);
if (fds[i].events & POLLIN)
FD_SET (fds[i].fd, read_fds);
@@ -64,20 +67,17 @@ poll (struct pollfd *fds, unsigned int nfds, int timeout)
FD_SET (fds[i].fd, except_fds);
}
else
- invalid_fds = true;
+ fds[i].revents = POLLNVAL;
int ret = 0;
- if (!invalid_fds)
+ if (valid_fds)
ret = cygwin_select (max_fd + 1, read_fds, write_fds, except_fds,
timeout < 0 ? NULL : &tv);
for (unsigned int i = 0; i < nfds; ++i)
{
- if (!FD_ISSET (fds[i].fd, open_fds))
- {
- fds[i].revents = POLLNVAL;
- ret++;
- }
+ if (fds[i].revents == POLLNVAL && ret >= 0)
+ ret++;
else if (cygheap->fdtab.not_open(fds[i].fd))
fds[i].revents = POLLHUP;
else if (ret < 0)
diff --git a/winsup/cygwin/pwdgrp.h b/winsup/cygwin/pwdgrp.h
index 38a7c80f4..568259db2 100644
--- a/winsup/cygwin/pwdgrp.h
+++ b/winsup/cygwin/pwdgrp.h
@@ -27,17 +27,17 @@ public:
operator pwdgrp_state ()
{
if (state != uninitialized && file_w32[0] && cygheap->etc_changed ())
- {
- HANDLE h;
- WIN32_FIND_DATA data;
-
- if ((h = FindFirstFile (file_w32, &data)) != INVALID_HANDLE_VALUE)
- {
- if (CompareFileTime (&data.ftLastWriteTime, &last_modified) > 0)
- state = uninitialized;
- FindClose (h);
- }
- }
+ {
+ HANDLE h;
+ WIN32_FIND_DATA data;
+
+ if ((h = FindFirstFile (file_w32, &data)) != INVALID_HANDLE_VALUE)
+ {
+ if (CompareFileTime (&data.ftLastWriteTime, &last_modified) > 0)
+ state = uninitialized;
+ FindClose (h);
+ }
+ }
return state;
}
void operator = (pwdgrp_state nstate)
@@ -47,7 +47,7 @@ public:
void set_last_modified (FILE *f)
{
if (!file_w32[0])
- strcpy (file_w32, cygheap->fdtab[fileno (f)]->get_win32_name ());
+ strcpy (file_w32, cygheap->fdtab[fileno (f)]->get_win32_name ());
GetFileTime (cygheap->fdtab[fileno (f)]->get_handle (),
NULL, NULL, &last_modified);
diff --git a/winsup/cygwin/regexp/regerror.c b/winsup/cygwin/regexp/regerror.c
deleted file mode 100644
index 0f6159bb7..000000000
--- a/winsup/cygwin/regexp/regerror.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/* regerror.c
-
- Copyright 1996, 1998, 2001 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. */
-
-#include "winsup.h"
-#include "regexp.h"
-#include <stdio.h>
-
-void
-regerror(const char *s __attribute__ ((unused)))
-{
-#ifdef ERRAVAIL
- error("regexp: %s", s);
-#else
-/*
- fprintf(stderr, "regexp(3): %s\n", s);
- exit(1);
-*/
- return; /* let std. egrep handle errors */
-#endif
- /* NOTREACHED */
-}
diff --git a/winsup/cygwin/regexp/regexp.3 b/winsup/cygwin/regexp/regexp.3
deleted file mode 100644
index d1a3a000d..000000000
--- a/winsup/cygwin/regexp/regexp.3
+++ /dev/null
@@ -1,321 +0,0 @@
-.\" Copyright (c) 1991, 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" @(#)regexp.3 8.1 (Berkeley) 6/4/93
-.\"
-.Dd June 4, 1993
-.Dt REGEXP 3
-.Os
-.Sh NAME
-.Nm regcomp ,
-.Nm regexec ,
-.Nm regsub ,
-.Nm regerror
-.Nd regular expression handlers
-.Sh SYNOPSIS
-.Fd #include <regexp.h>
-.Ft regexp *
-.Fn regcomp "const char *exp"
-.Ft int
-.Fn regexec "const regexp *prog" "const char *string"
-.Ft void
-.Fn regsub "const regexp *prog" "const char *source" "char *dest"
-.Sh DESCRIPTION
-.Bf -symbolic
-This interface is made obsolete by
-.Xr regex 3 .
-It is available from the compatibility library, libcompat.
-.Ef
-.Pp
-The
-.Fn regcomp ,
-.Fn regexec ,
-.Fn regsub ,
-and
-.Fn regerror
-functions
-implement
-.Xr egrep 1 Ns -style
-regular expressions and supporting facilities.
-.Pp
-The
-.Fn regcomp
-function
-compiles a regular expression into a structure of type
-.Xr regexp ,
-and returns a pointer to it.
-The space has been allocated using
-.Xr malloc 3
-and may be released by
-.Xr free .
-.Pp
-The
-.Fn regexec
-function
-matches a
-.Dv NUL Ns -terminated
-.Fa string
-against the compiled regular expression
-in
-.Fa prog .
-It returns 1 for success and 0 for failure, and adjusts the contents of
-.Fa prog Ns 's
-.Em startp
-and
-.Em endp
-(see below) accordingly.
-.Pp
-The members of a
-.Xr regexp
-structure include at least the following (not necessarily in order):
-.Bd -literal -offset indent
-char *startp[NSUBEXP];
-char *endp[NSUBEXP];
-.Ed
-.Pp
-where
-.Dv NSUBEXP
-is defined (as 10) in the header file.
-Once a successful
-.Fn regexec
-has been done using the
-.Fn regexp ,
-each
-.Em startp Ns - Em endp
-pair describes one substring
-within the
-.Fa string ,
-with the
-.Em startp
-pointing to the first character of the substring and
-the
-.Em endp
-pointing to the first character following the substring.
-The 0th substring is the substring of
-.Fa string
-that matched the whole
-regular expression.
-The others are those substrings that matched parenthesized expressions
-within the regular expression, with parenthesized expressions numbered
-in left-to-right order of their opening parentheses.
-.Pp
-The
-.Fn regsub
-function
-copies
-.Fa source
-to
-.Fa dest ,
-making substitutions according to the
-most recent
-.Fn regexec
-performed using
-.Fa prog .
-Each instance of `&' in
-.Fa source
-is replaced by the substring
-indicated by
-.Em startp Ns Bq
-and
-.Em endp Ns Bq .
-Each instance of
-.Sq \e Ns Em n ,
-where
-.Em n
-is a digit, is replaced by
-the substring indicated by
-.Em startp Ns Bq Em n
-and
-.Em endp Ns Bq Em n .
-To get a literal `&' or
-.Sq \e Ns Em n
-into
-.Fa dest ,
-prefix it with `\e';
-to get a literal `\e' preceding `&' or
-.Sq \e Ns Em n ,
-prefix it with
-another `\e'.
-.Pp
-The
-.Fn regerror
-function
-is called whenever an error is detected in
-.Fn regcomp ,
-.Fn regexec ,
-or
-.Fn regsub .
-The default
-.Fn regerror
-writes the string
-.Fa msg ,
-with a suitable indicator of origin,
-on the standard
-error output
-and invokes
-.Xr exit 2 .
-The
-.Fn regerror
-function
-can be replaced by the user if other actions are desirable.
-.Sh REGULAR EXPRESSION SYNTAX
-A regular expression is zero or more
-.Em branches ,
-separated by `|'.
-It matches anything that matches one of the branches.
-.Pp
-A branch is zero or more
-.Em pieces ,
-concatenated.
-It matches a match for the first, followed by a match for the second, etc.
-.Pp
-A piece is an
-.Em atom
-possibly followed by `*', `+', or `?'.
-An atom followed by `*' matches a sequence of 0 or more matches of the atom.
-An atom followed by `+' matches a sequence of 1 or more matches of the atom.
-An atom followed by `?' matches a match of the atom, or the null string.
-.Pp
-An atom is a regular expression in parentheses (matching a match for the
-regular expression), a
-.Em range
-(see below), `.'
-(matching any single character), `^' (matching the null string at the
-beginning of the input string), `$' (matching the null string at the
-end of the input string), a `\e' followed by a single character (matching
-that character), or a single character with no other significance
-(matching that character).
-.Pp
-A
-.Em range
-is a sequence of characters enclosed in `[]'.
-It normally matches any single character from the sequence.
-If the sequence begins with `^',
-it matches any single character
-.Em not
-from the rest of the sequence.
-If two characters in the sequence are separated by `\-', this is shorthand
-for the full list of
-.Tn ASCII
-characters between them
-(e.g. `[0-9]' matches any decimal digit).
-To include a literal `]' in the sequence, make it the first character
-(following a possible `^').
-To include a literal `\-', make it the first or last character.
-.Sh AMBIGUITY
-If a regular expression could match two different parts of the input string,
-it will match the one which begins earliest.
-If both begin in the same place but match different lengths, or match
-the same length in different ways, life gets messier, as follows.
-.Pp
-In general, the possibilities in a list of branches are considered in
-left-to-right order, the possibilities for `*', `+', and `?' are
-considered longest-first, nested constructs are considered from the
-outermost in, and concatenated constructs are considered leftmost-first.
-The match that will be chosen is the one that uses the earliest
-possibility in the first choice that has to be made.
-If there is more than one choice, the next will be made in the same manner
-(earliest possibility) subject to the decision on the first choice.
-And so forth.
-.Pp
-For example,
-.Sq Li (ab|a)b*c
-could match
-`abc' in one of two ways.
-The first choice is between `ab' and `a'; since `ab' is earlier, and does
-lead to a successful overall match, it is chosen.
-Since the `b' is already spoken for,
-the `b*' must match its last possibility\(emthe empty string\(emsince
-it must respect the earlier choice.
-.Pp
-In the particular case where no `|'s are present and there is only one
-`*', `+', or `?', the net effect is that the longest possible
-match will be chosen.
-So
-.Sq Li ab* ,
-presented with `xabbbby', will match `abbbb'.
-Note that if
-.Sq Li ab* ,
-is tried against `xabyabbbz', it
-will match `ab' just after `x', due to the begins-earliest rule.
-(In effect, the decision on where to start the match is the first choice
-to be made, hence subsequent choices must respect it even if this leads them
-to less-preferred alternatives.)
-.Sh RETURN VALUES
-The
-.Fn regcomp
-function
-returns
-.Dv NULL
-for a failure
-.Pf ( Fn regerror
-permitting),
-where failures are syntax errors, exceeding implementation limits,
-or applying `+' or `*' to a possibly-null operand.
-.Sh SEE ALSO
-.Xr ed 1 ,
-.Xr ex 1 ,
-.Xr expr 1 ,
-.Xr egrep 1 ,
-.Xr fgrep 1 ,
-.Xr grep 1 ,
-.Xr regex 3
-.Sh HISTORY
-Both code and manual page for
-.Fn regcomp ,
-.Fn regexec ,
-.Fn regsub ,
-and
-.Fn regerror
-were written at the University of Toronto
-and appeared in
-.Bx 4.3 tahoe .
-They are intended to be compatible with the Bell V8
-.Xr regexp 3 ,
-but are not derived from Bell code.
-.Sh BUGS
-Empty branches and empty regular expressions are not portable to V8.
-.Pp
-The restriction against
-applying `*' or `+' to a possibly-null operand is an artifact of the
-simplistic implementation.
-.Pp
-Does not support
-.Xr egrep Ns 's
-newline-separated branches;
-neither does the V8
-.Xr regexp 3 ,
-though.
-.Pp
-Due to emphasis on
-compactness and simplicity,
-it's not strikingly fast.
-It does give special attention to handling simple cases quickly.
diff --git a/winsup/cygwin/regexp/regexp.c b/winsup/cygwin/regexp/regexp.c
deleted file mode 100644
index 2f60d6463..000000000
--- a/winsup/cygwin/regexp/regexp.c
+++ /dev/null
@@ -1,1321 +0,0 @@
-/*
- * regcomp and regexec -- regsub and regerror are elsewhere
- *
- * Copyright (c) 1986 by University of Toronto.
- * Written by Henry Spencer. Not derived from licensed software.
- *
- * Permission is granted to anyone to use this software for any
- * purpose on any computer system, and to redistribute it freely,
- * subject to the following restrictions:
- *
- * 1. The author is not responsible for the consequences of use of
- * this software, no matter how awful, even if they arise
- * from defects in it.
- *
- * 2. The origin of this software must not be misrepresented, either
- * by explicit claim or by omission.
- *
- * 3. Altered versions must be plainly marked as such, and must not
- * be misrepresented as being the original software.
- *** THIS IS AN ALTERED VERSION. It was altered by John Gilmore,
- *** hoptoad!gnu, on 27 Dec 1986, to add \n as an alternative to |
- *** to assist in implementing egrep.
- *** THIS IS AN ALTERED VERSION. It was altered by John Gilmore,
- *** hoptoad!gnu, on 27 Dec 1986, to add \< and \> for word-matching
- *** as in BSD grep and ex.
- *** THIS IS AN ALTERED VERSION. It was altered by John Gilmore,
- *** hoptoad!gnu, on 28 Dec 1986, to optimize characters quoted with \.
- *** THIS IS AN ALTERED VERSION. It was altered by James A. Woods,
- *** ames!jaw, on 19 June 1987, to quash a regcomp() redundancy.
- *** THIS IS AN ALTERED VERSION. It was altered by Geoffrey Noer,
- *** noer@cygnus.com, on 6 Oct 1997, to change the prototype format
- *** for inclusion in the Cygwin32 library.
- *
- * Beware that some of this code is subtly aware of the way operator
- * precedence is structured in regular expressions. Serious changes in
- * regular-expression syntax might require a total rethink.
- */
-
-#include "winsup.h"
-#include "regexp.h"
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include <stdlib.h>
-#include "regmagic.h"
-
-/*
- * The "internal use only" fields in regexp.h are present to pass info from
- * compile to execute that permits the execute phase to run lots faster on
- * simple cases. They are:
- *
- * regstart char that must begin a match; '\0' if none obvious
- * reganch is the match anchored (at beginning-of-line only)?
- * regmust string (pointer into program) that match must include, or NULL
- * regmlen length of regmust string
- *
- * Regstart and reganch permit very fast decisions on suitable starting points
- * for a match, cutting down the work a lot. Regmust permits fast rejection
- * of lines that cannot possibly match. The regmust tests are costly enough
- * that regcomp() supplies a regmust only if the r.e. contains something
- * potentially expensive (at present, the only such thing detected is * or +
- * at the start of the r.e., which can involve a lot of backup). Regmlen is
- * supplied because the test in regexec() needs it and regcomp() is computing
- * it anyway.
- */
-
-/*
- * Structure for regexp "program". This is essentially a linear encoding
- * of a nondeterministic finite-state machine (aka syntax charts or
- * "railroad normal form" in parsing technology). Each node is an opcode
- * plus a "next" pointer, possibly plus an operand. "Next" pointers of
- * all nodes except BRANCH implement concatenation; a "next" pointer with
- * a BRANCH on both ends of it is connecting two alternatives. (Here we
- * have one of the subtle syntax dependencies: an individual BRANCH (as
- * opposed to a collection of them) is never concatenated with anything
- * because of operator precedence.) The operand of some types of node is
- * a literal string; for others, it is a node leading into a sub-FSM. In
- * particular, the operand of a BRANCH node is the first node of the branch.
- * (NB this is *not* a tree structure: the tail of the branch connects
- * to the thing following the set of BRANCHes.) The opcodes are:
- */
-
-/* definition number opnd? meaning */
-#define END 0 /* no End of program. */
-#define BOL 1 /* no Match "" at beginning of line. */
-#define EOL 2 /* no Match "" at end of line. */
-#define ANY 3 /* no Match any one character. */
-#define ANYOF 4 /* str Match any character in this string. */
-#define ANYBUT 5 /* str Match any character not in this string. */
-#define BRANCH 6 /* node Match this alternative, or the next... */
-#define BACK 7 /* no Match "", "next" ptr points backward. */
-#define EXACTLY 8 /* str Match this string. */
-#define NOTHING 9 /* no Match empty string. */
-#define STAR 10 /* node Match this (simple) thing 0 or more times. */
-#define PLUS 11 /* node Match this (simple) thing 1 or more times. */
-#define WORDA 12 /* no Match "" at wordchar, where prev is nonword */
-#define WORDZ 13 /* no Match "" at nonwordchar, where prev is word */
-#define OPEN 20 /* no Mark this point in input as start of #n. */
- /* OPEN+1 is number 1, etc. */
-#define CLOSE 30 /* no Analogous to OPEN. */
-
-/*
- * Opcode notes:
- *
- * BRANCH The set of branches constituting a single choice are hooked
- * together with their "next" pointers, since precedence prevents
- * anything being concatenated to any individual branch. The
- * "next" pointer of the last BRANCH in a choice points to the
- * thing following the whole choice. This is also where the
- * final "next" pointer of each individual branch points; each
- * branch starts with the operand node of a BRANCH node.
- *
- * BACK Normal "next" pointers all implicitly point forward; BACK
- * exists to make loop structures possible.
- *
- * STAR,PLUS '?', and complex '*' and '+', are implemented as circular
- * BRANCH structures using BACK. Simple cases (one character
- * per match) are implemented with STAR and PLUS for speed
- * and to minimize recursive plunges.
- *
- * OPEN,CLOSE ...are numbered at compile time.
- */
-
-/*
- * A node is one char of opcode followed by two chars of "next" pointer.
- * "Next" pointers are stored as two 8-bit pieces, high order first. The
- * value is a positive offset from the opcode of the node containing it.
- * An operand, if any, simply follows the node. (Note that much of the
- * code generation knows about this implicit relationship.)
- *
- * Using two bytes for the "next" pointer is vast overkill for most things,
- * but allows patterns to get big without disasters.
- */
-#define OP(p) (*(p))
-#define NEXT(p) (((*((p)+1)&0377)<<8) + (*((p)+2)&0377))
-#define OPERAND(p) ((p) + 3)
-
-/*
- * See regmagic.h for one further detail of program structure.
- */
-
-
-/*
- * Utility definitions.
- */
-#ifndef CHARBITS
-#define UCHARAT(p) ((int)*(unsigned char *)(p))
-#else
-#define UCHARAT(p) ((int)*(p)&CHARBITS)
-#endif
-
-#define FAIL(m) { regerror(m); return(NULL); }
-#define ISMULT(c) ((c) == '*' || (c) == '+' || (c) == '?')
-
-/*
- * Flags to be passed up and down.
- */
-#define HASWIDTH 01 /* Known never to match null string. */
-#define SIMPLE 02 /* Simple enough to be STAR/PLUS operand. */
-#define SPSTART 04 /* Starts with * or +. */
-#define WORST 0 /* Worst case. */
-
-/*
- * Global work variables for regcomp().
- */
-static char *regparse; /* Input-scan pointer. */
-static int regnpar; /* () count. */
-static char regdummy;
-static char *regcode; /* Code-emit pointer; &regdummy = don't. */
-static long regsize; /* Code size. */
-
-/*
- * Forward declarations for regcomp()'s friends.
- */
-#ifndef STATIC
-#define STATIC static
-#endif
-STATIC char *reg (int, int *);
-STATIC char *regbranch (int *);
-STATIC char *regpiece (int *);
-STATIC char *regatom (int *);
-STATIC char *regnode (char);
-STATIC char *regnext (char *);
-STATIC void regc (char);
-STATIC void reginsert (char, char *);
-STATIC void regtail (char *, char *);
-STATIC void regoptail (char *, char *);
-#ifdef STRCSPN
-STATIC int strcspn (char *, char *);
-#endif
-
-/*
- - regcomp - compile a regular expression into internal code
- *
- * We can't allocate space until we know how big the compiled form will be,
- * but we can't compile it (and thus know how big it is) until we've got a
- * place to put the code. So we cheat: we compile it twice, once with code
- * generation turned off and size counting turned on, and once "for real".
- * This also means that we don't allocate space until we are sure that the
- * thing really will compile successfully, and we never have to move the
- * code and thus invalidate pointers into it. (Note that it has to be in
- * one piece because free() must be able to free it all.)
- *
- * Beware that the optimization-preparation code in here knows about some
- * of the structure of the compiled regexp.
- */
-regexp *
-regcomp(exp)
-const char *exp;
-{
- register regexp *r;
- register char *scan;
- register char *longest;
- register int len;
- int flags;
-
- if (exp == NULL)
- FAIL("NULL argument");
-
- /* First pass: determine size, legality. */
-#ifdef notdef
- if (exp[0] == '.' && exp[1] == '*') exp += 2; /* aid grep */
-#endif
- regparse = (char *)exp;
- regnpar = 1;
- regsize = 0L;
- regcode = &regdummy;
- regc(MAGIC);
- if (reg(0, &flags) == NULL)
- return(NULL);
-
- /* Small enough for pointer-storage convention? */
- if (regsize >= 32767L) /* Probably could be 65535L. */
- FAIL("regexp too big");
-
- /* Allocate space. */
- r = (regexp *)malloc(sizeof(regexp) + (unsigned)regsize);
- if (r == NULL)
- FAIL("out of space");
-
- /* Second pass: emit code. */
- regparse = (char *)exp;
- regnpar = 1;
- regcode = r->program;
- regc(MAGIC);
- if (reg(0, &flags) == NULL)
- return(NULL);
-
- /* Dig out information for optimizations. */
- r->regstart = '\0'; /* Worst-case defaults. */
- r->reganch = 0;
- r->regmust = NULL;
- r->regmlen = 0;
- scan = r->program+1; /* First BRANCH. */
- if (OP(regnext(scan)) == END) { /* Only one top-level choice. */
- scan = OPERAND(scan);
-
- /* Starting-point info. */
- if (OP(scan) == EXACTLY)
- r->regstart = *OPERAND(scan);
- else if (OP(scan) == BOL)
- r->reganch++;
-
- /*
- * If there's something expensive in the r.e., find the
- * longest literal string that must appear and make it the
- * regmust. Resolve ties in favor of later strings, since
- * the regstart check works with the beginning of the r.e.
- * and avoiding duplication strengthens checking. Not a
- * strong reason, but sufficient in the absence of others.
- */
- if (flags&SPSTART) {
- longest = NULL;
- len = 0;
- for (; scan != NULL; scan = regnext(scan))
- if (OP(scan) == EXACTLY && (int) strlen(OPERAND(scan)) >= len) {
- longest = OPERAND(scan);
- len = strlen(OPERAND(scan));
- }
- r->regmust = longest;
- r->regmlen = len;
- }
- }
-
- return(r);
-}
-
-/*
- - reg - regular expression, i.e. main body or parenthesized thing
- *
- * Caller must absorb opening parenthesis.
- *
- * Combining parenthesis handling with the base level of regular expression
- * is a trifle forced, but the need to tie the tails of the branches to what
- * follows makes it hard to avoid.
- */
-static char *
-reg(paren, flagp)
-int paren; /* Parenthesized? */
-int *flagp;
-{
- register char *ret;
- register char *br;
- register char *ender;
- register int parno = 0;
- int flags;
-
- *flagp = HASWIDTH; /* Tentatively. */
-
- /* Make an OPEN node, if parenthesized. */
- if (paren) {
- if (regnpar >= NSUBEXP)
- FAIL("too many ()");
- parno = regnpar;
- regnpar++;
- ret = regnode(OPEN+parno);
- } else
- ret = NULL;
-
- /* Pick up the branches, linking them together. */
- br = regbranch(&flags);
- if (br == NULL)
- return(NULL);
- if (ret != NULL)
- regtail(ret, br); /* OPEN -> first. */
- else
- ret = br;
- if (!(flags&HASWIDTH))
- *flagp &= ~HASWIDTH;
- *flagp |= flags&SPSTART;
- while (*regparse == '|' || *regparse == '\n') {
- regparse++;
- br = regbranch(&flags);
- if (br == NULL)
- return(NULL);
- regtail(ret, br); /* BRANCH -> BRANCH. */
- if (!(flags&HASWIDTH))
- *flagp &= ~HASWIDTH;
- *flagp |= flags&SPSTART;
- }
-
- /* Make a closing node, and hook it on the end. */
- ender = regnode((paren) ? CLOSE+parno : END);
- regtail(ret, ender);
-
- /* Hook the tails of the branches to the closing node. */
- for (br = ret; br != NULL; br = regnext(br))
- regoptail(br, ender);
-
- /* Check for proper termination. */
- if (paren && *regparse++ != ')') {
- FAIL("unmatched ()");
- } else if (!paren && *regparse != '\0') {
- if (*regparse == ')') {
- FAIL("unmatched ()");
- } else
- FAIL("junk on end"); /* "Can't happen". */
- /* NOTREACHED */
- }
-
- return(ret);
-}
-
-/*
- - regbranch - one alternative of an | operator
- *
- * Implements the concatenation operator.
- */
-static char *
-regbranch(flagp)
-int *flagp;
-{
- register char *ret;
- register char *chain;
- register char *latest;
- int flags;
-
- *flagp = WORST; /* Tentatively. */
-
- ret = regnode(BRANCH);
- chain = NULL;
- while (*regparse != '\0' && *regparse != ')' &&
- *regparse != '\n' && *regparse != '|') {
- latest = regpiece(&flags);
- if (latest == NULL)
- return(NULL);
- *flagp |= flags&HASWIDTH;
- if (chain == NULL) /* First piece. */
- *flagp |= flags&SPSTART;
- else
- regtail(chain, latest);
- chain = latest;
- }
- if (chain == NULL) /* Loop ran zero times. */
- (void) regnode(NOTHING);
-
- return(ret);
-}
-
-/*
- - regpiece - something followed by possible [*+?]
- *
- * Note that the branching code sequences used for ? and the general cases
- * of * and + are somewhat optimized: they use the same NOTHING node as
- * both the endmarker for their branch list and the body of the last branch.
- * It might seem that this node could be dispensed with entirely, but the
- * endmarker role is not redundant.
- */
-static char *
-regpiece(flagp)
-int *flagp;
-{
- register char *ret;
- register char op;
- register char *next;
- int flags;
-
- ret = regatom(&flags);
- if (ret == NULL)
- return(NULL);
-
- op = *regparse;
- if (!ISMULT(op)) {
- *flagp = flags;
- return(ret);
- }
-
- if (!(flags&HASWIDTH) && op != '?')
- FAIL("*+ operand could be empty");
- *flagp = (op != '+') ? (WORST|SPSTART) : (WORST|HASWIDTH);
-
- if (op == '*' && (flags&SIMPLE))
- reginsert(STAR, ret);
- else if (op == '*') {
- /* Emit x* as (x&|), where & means "self". */
- reginsert(BRANCH, ret); /* Either x */
- regoptail(ret, regnode(BACK)); /* and loop */
- regoptail(ret, ret); /* back */
- regtail(ret, regnode(BRANCH)); /* or */
- regtail(ret, regnode(NOTHING)); /* null. */
- } else if (op == '+' && (flags&SIMPLE))
- reginsert(PLUS, ret);
- else if (op == '+') {
- /* Emit x+ as x(&|), where & means "self". */
- next = regnode(BRANCH); /* Either */
- regtail(ret, next);
- regtail(regnode(BACK), ret); /* loop back */
- regtail(next, regnode(BRANCH)); /* or */
- regtail(ret, regnode(NOTHING)); /* null. */
- } else if (op == '?') {
- /* Emit x? as (x|) */
- reginsert(BRANCH, ret); /* Either x */
- regtail(ret, regnode(BRANCH)); /* or */
- next = regnode(NOTHING); /* null. */
- regtail(ret, next);
- regoptail(ret, next);
- }
- regparse++;
- if (ISMULT(*regparse))
- FAIL("nested *?+");
-
- return(ret);
-}
-
-/*
- - regatom - the lowest level
- *
- * Optimization: gobbles an entire sequence of ordinary characters so that
- * it can turn them into a single node, which is smaller to store and
- * faster to run. Backslashed characters are exceptions, each becoming a
- * separate node; the code is simpler that way and it's not worth fixing.
- */
-static char *
-regatom(flagp)
-int *flagp;
-{
- register char *ret;
- int flags;
-
- *flagp = WORST; /* Tentatively. */
-
- switch (*regparse++) {
- /* FIXME: these chars only have meaning at beg/end of pat? */
- case '^':
- ret = regnode(BOL);
- break;
- case '$':
- ret = regnode(EOL);
- break;
- case '.':
- ret = regnode(ANY);
- *flagp |= HASWIDTH|SIMPLE;
- break;
- case '[': {
- register int class;
- register int classend;
-
- if (*regparse == '^') { /* Complement of range. */
- ret = regnode(ANYBUT);
- regparse++;
- } else
- ret = regnode(ANYOF);
- if (*regparse == ']' || *regparse == '-')
- regc(*regparse++);
- while (*regparse != '\0' && *regparse != ']') {
- if (*regparse == '-') {
- regparse++;
- if (*regparse == ']' || *regparse == '\0')
- regc('-');
- else {
- class = UCHARAT(regparse-2)+1;
- classend = UCHARAT(regparse);
- if (class > classend+1)
- FAIL("invalid [] range");
- for (; class <= classend; class++)
- regc(class);
- regparse++;
- }
- } else
- regc(*regparse++);
- }
- regc('\0');
- if (*regparse != ']')
- FAIL("unmatched []");
- regparse++;
- *flagp |= HASWIDTH|SIMPLE;
- }
- break;
- case '(':
- ret = reg(1, &flags);
- if (ret == NULL)
- return(NULL);
- *flagp |= flags&(HASWIDTH|SPSTART);
- break;
- case '\0':
- case '|':
- case '\n':
- case ')':
- FAIL("internal urp"); /* Supposed to be caught earlier. */
- break;
- case '?':
- case '+':
- case '*':
- FAIL("?+* follows nothing");
- break;
- case '\\':
- switch (*regparse++) {
- case '\0':
- FAIL("trailing \\");
- break;
- case '<':
- ret = regnode(WORDA);
- break;
- case '>':
- ret = regnode(WORDZ);
- break;
- /* FIXME: Someday handle \1, \2, ... */
- default:
- /* Handle general quoted chars in exact-match routine */
- goto de_fault;
- }
- break;
- de_fault:
- default:
- /*
- * Encode a string of characters to be matched exactly.
- *
- * This is a bit tricky due to quoted chars and due to
- * '*', '+', and '?' taking the SINGLE char previous
- * as their operand.
- *
- * On entry, the char at regparse[-1] is going to go
- * into the string, no matter what it is. (It could be
- * following a \ if we are entered from the '\' case.)
- *
- * Basic idea is to pick up a good char in ch and
- * examine the next char. If it's *+? then we twiddle.
- * If it's \ then we frozzle. If it's other magic char
- * we push ch and terminate the string. If none of the
- * above, we push ch on the string and go around again.
- *
- * regprev is used to remember where "the current char"
- * starts in the string, if due to a *+? we need to back
- * up and put the current char in a separate, 1-char, string.
- * When regprev is NULL, ch is the only char in the
- * string; this is used in *+? handling, and in setting
- * flags |= SIMPLE at the end.
- */
- {
- char *regprev;
- register char ch = 0;
-
- regparse--; /* Look at cur char */
- ret = regnode(EXACTLY);
- for ( regprev = 0 ; ; ) {
- ch = *regparse++; /* Get current char */
- switch (*regparse) { /* look at next one */
-
- default:
- regc(ch); /* Add cur to string */
- break;
-
- case '.': case '[': case '(':
- case ')': case '|': case '\n':
- case '$': case '^':
- case '\0':
- /* FIXME, $ and ^ should not always be magic */
- magic:
- regc(ch); /* dump cur char */
- goto done; /* and we are done */
-
- case '?': case '+': case '*':
- if (!regprev) /* If just ch in str, */
- goto magic; /* use it */
- /* End mult-char string one early */
- regparse = regprev; /* Back up parse */
- goto done;
-
- case '\\':
- regc(ch); /* Cur char OK */
- switch (regparse[1]){ /* Look after \ */
- case '\0':
- case '<':
- case '>':
- /* FIXME: Someday handle \1, \2, ... */
- goto done; /* Not quoted */
- default:
- /* Backup point is \, scan * point is after it. */
- regprev = regparse;
- regparse++;
- continue; /* NOT break; */
- }
- }
- regprev = regparse; /* Set backup point */
- }
- done:
- regc('\0');
- *flagp |= HASWIDTH;
- if (!regprev) /* One char? */
- *flagp |= SIMPLE;
- }
- break;
- }
-
- return(ret);
-}
-
-/*
- - regnode - emit a node
- */
-static char * /* Location. */
-regnode(op)
-char op;
-{
- register char *ret;
- register char *ptr;
-
- ret = regcode;
- if (ret == &regdummy) {
- regsize += 3;
- return(ret);
- }
-
- ptr = ret;
- *ptr++ = op;
- *ptr++ = '\0'; /* Null "next" pointer. */
- *ptr++ = '\0';
- regcode = ptr;
-
- return(ret);
-}
-
-/*
- - regc - emit (if appropriate) a byte of code
- */
-static void
-regc(b)
-char b;
-{
- if (regcode != &regdummy)
- *regcode++ = b;
- else
- regsize++;
-}
-
-/*
- - reginsert - insert an operator in front of already-emitted operand
- *
- * Means relocating the operand.
- */
-static void
-reginsert(op, opnd)
-char op;
-char *opnd;
-{
- register char *src;
- register char *dst;
- register char *place;
-
- if (regcode == &regdummy) {
- regsize += 3;
- return;
- }
-
- src = regcode;
- regcode += 3;
- dst = regcode;
- while (src > opnd)
- *--dst = *--src;
-
- place = opnd; /* Op node, where operand used to be. */
- *place++ = op;
- *place++ = '\0';
- *place++ = '\0';
-}
-
-/*
- - regtail - set the next-pointer at the end of a node chain
- */
-static void
-regtail(p, val)
-char *p;
-char *val;
-{
- register char *scan;
- register char *temp;
- register int offset;
-
- if (p == &regdummy)
- return;
-
- /* Find last node. */
- scan = p;
- for (;;) {
- temp = regnext(scan);
- if (temp == NULL)
- break;
- scan = temp;
- }
-
- if (OP(scan) == BACK)
- offset = scan - val;
- else
- offset = val - scan;
- *(scan+1) = (offset>>8)&0377;
- *(scan+2) = offset&0377;
-}
-
-/*
- - regoptail - regtail on operand of first argument; nop if operandless
- */
-static void
-regoptail(p, val)
-char *p;
-char *val;
-{
- /* "Operandless" and "op != BRANCH" are synonymous in practice. */
- if (p == NULL || p == &regdummy || OP(p) != BRANCH)
- return;
- regtail(OPERAND(p), val);
-}
-
-/*
- * regexec and friends
- */
-
-/*
- * Global work variables for regexec().
- */
-static char *reginput; /* String-input pointer. */
-static char *regbol; /* Beginning of input, for ^ check. */
-static char **regstartp; /* Pointer to startp array. */
-static char **regendp; /* Ditto for endp. */
-
-/*
- * Forwards.
- */
-STATIC int regtry (const regexp *, const char *);
-STATIC int regmatch (char *);
-STATIC int regrepeat (char *);
-
-#ifdef DEBUG
-int regnarrate = 0;
-void regdump __P((regexp *));
-STATIC char *regprop __P((char *));
-#endif
-
-/*
- - regexec - match a regexp against a string
- */
-int
-regexec(prog, string)
-register const regexp *prog;
-register const char *string;
-{
- register char *s;
-
- /* Be paranoid... */
- if (prog == NULL || string == NULL) {
- regerror("NULL parameter");
- return(0);
- }
-
- /* Check validity of program. */
- if (UCHARAT(prog->program) != MAGIC) {
- regerror("corrupted program");
- return(0);
- }
-
- /* If there is a "must appear" string, look for it. */
- if (prog->regmust != NULL) {
- s = (char *)string;
- while ((s = strchr(s, prog->regmust[0])) != NULL) {
- if (strncmp(s, prog->regmust, prog->regmlen) == 0)
- break; /* Found it. */
- s++;
- }
- if (s == NULL) /* Not present. */
- return(0);
- }
-
- /* Mark beginning of line for ^ . */
- regbol = (char *)string;
-
- /* Simplest case: anchored match need be tried only once. */
- if (prog->reganch)
- return(regtry(prog, string));
-
- /* Messy cases: unanchored match. */
- s = (char *)string;
- if (prog->regstart != '\0')
- /* We know what char it must start with. */
- while ((s = strchr(s, prog->regstart)) != NULL) {
- if (regtry(prog, s))
- return(1);
- s++;
- }
- else
- /* We don't -- general case. */
- do {
- if (regtry(prog, s))
- return(1);
- } while (*s++ != '\0');
-
- /* Failure. */
- return(0);
-}
-
-/*
- - regtry - try match at specific point
- */
-static int /* 0 failure, 1 success */
-regtry(prog, string)
-const regexp *prog;
-const char *string;
-{
- register int i;
- register char **sp;
- register char **ep;
-
- reginput = (char *)string; /* XXX */
- regstartp = (char **)prog->startp; /* XXX */
- regendp = (char **)prog->endp; /* XXX */
-
- sp = (char **)prog->startp; /* XXX */
- ep = (char **)prog->endp; /* XXX */
- for (i = NSUBEXP; i > 0; i--) {
- *sp++ = NULL;
- *ep++ = NULL;
- }
- if (regmatch((char *)prog->program + 1)) { /* XXX */
- ((regexp *)prog)->startp[0] = (char *)string; /* XXX */
- ((regexp *)prog)->endp[0] = reginput; /* XXX */
- return(1);
- } else
- return(0);
-}
-
-/*
- - regmatch - main matching routine
- *
- * Conceptually the strategy is simple: check to see whether the current
- * node matches, call self recursively to see whether the rest matches,
- * and then act accordingly. In practice we make some effort to avoid
- * recursion, in particular by going through "ordinary" nodes (that don't
- * need to know whether the rest of the match failed) by a loop instead of
- * by recursion.
- */
-static int /* 0 failure, 1 success */
-regmatch(prog)
-char *prog;
-{
- register char *scan; /* Current node. */
- char *next; /* Next node. */
-
- scan = prog;
-#ifdef DEBUG
- if (scan != NULL && regnarrate)
- fprintf(stderr, "%s(\n", regprop(scan));
-#endif
- while (scan != NULL) {
-#ifdef DEBUG
- if (regnarrate)
- fprintf(stderr, "%s...\n", regprop(scan));
-#endif
- next = regnext(scan);
-
- switch (OP(scan)) {
- case BOL:
- if (reginput != regbol)
- return(0);
- break;
- case EOL:
- if (*reginput != '\0')
- return(0);
- break;
- case WORDA:
- /* Must be looking at a letter, digit, or _ */
- if ((!isalnum(*reginput)) && *reginput != '_')
- return(0);
- /* Prev must be BOL or nonword */
- if (reginput > regbol &&
- (isalnum(reginput[-1]) || reginput[-1] == '_'))
- return(0);
- break;
- case WORDZ:
- /* Must be looking at non letter, digit, or _ */
- if (isalnum(*reginput) || *reginput == '_')
- return(0);
- /* We don't care what the previous char was */
- break;
- case ANY:
- if (*reginput == '\0')
- return(0);
- reginput++;
- break;
- case EXACTLY: {
- register int len;
- register char *opnd;
-
- opnd = OPERAND(scan);
- /* Inline the first character, for speed. */
- if (*opnd != *reginput)
- return(0);
- len = strlen(opnd);
- if (len > 1 && strncmp(opnd, reginput, len) != 0)
- return(0);
- reginput += len;
- }
- break;
- case ANYOF:
- if (*reginput == '\0' || strchr(OPERAND(scan), *reginput) == NULL)
- return(0);
- reginput++;
- break;
- case ANYBUT:
- if (*reginput == '\0' || strchr(OPERAND(scan), *reginput) != NULL)
- return(0);
- reginput++;
- break;
- case NOTHING:
- break;
- case BACK:
- break;
- case OPEN+1:
- case OPEN+2:
- case OPEN+3:
- case OPEN+4:
- case OPEN+5:
- case OPEN+6:
- case OPEN+7:
- case OPEN+8:
- case OPEN+9: {
- register int no;
- register char *save;
-
- no = OP(scan) - OPEN;
- save = reginput;
-
- if (regmatch(next)) {
- /*
- * Don't set startp if some later
- * invocation of the same parentheses
- * already has.
- */
- if (regstartp[no] == NULL)
- regstartp[no] = save;
- return(1);
- } else
- return(0);
- }
- break;
- case CLOSE+1:
- case CLOSE+2:
- case CLOSE+3:
- case CLOSE+4:
- case CLOSE+5:
- case CLOSE+6:
- case CLOSE+7:
- case CLOSE+8:
- case CLOSE+9: {
- register int no;
- register char *save;
-
- no = OP(scan) - CLOSE;
- save = reginput;
-
- if (regmatch(next)) {
- /*
- * Don't set endp if some later
- * invocation of the same parentheses
- * already has.
- */
- if (regendp[no] == NULL)
- regendp[no] = save;
- return(1);
- } else
- return(0);
- }
- break;
- case BRANCH: {
- register char *save;
-
- if (OP(next) != BRANCH) /* No choice. */
- next = OPERAND(scan); /* Avoid recursion. */
- else {
- do {
- save = reginput;
- if (regmatch(OPERAND(scan)))
- return(1);
- reginput = save;
- scan = regnext(scan);
- } while (scan != NULL && OP(scan) == BRANCH);
- return(0);
- /* NOTREACHED */
- }
- }
- break;
- case STAR:
- case PLUS: {
- register char nextch;
- register int no;
- register char *save;
- register int min;
-
- /*
- * Lookahead to avoid useless match attempts
- * when we know what character comes next.
- */
- nextch = '\0';
- if (OP(next) == EXACTLY)
- nextch = *OPERAND(next);
- min = (OP(scan) == STAR) ? 0 : 1;
- save = reginput;
- no = regrepeat(OPERAND(scan));
- while (no >= min) {
- /* If it could work, try it. */
- if (nextch == '\0' || *reginput == nextch)
- if (regmatch(next))
- return(1);
- /* Couldn't or didn't -- back up. */
- no--;
- reginput = save + no;
- }
- return(0);
- }
- break;
- case END:
- return(1); /* Success! */
- break;
- default:
- regerror("memory corruption");
- return(0);
- break;
- }
-
- scan = next;
- }
-
- /*
- * We get here only if there's trouble -- normally "case END" is
- * the terminating point.
- */
- regerror("corrupted pointers");
- return(0);
-}
-
-/*
- - regrepeat - repeatedly match something simple, report how many
- */
-static int
-regrepeat(p)
-char *p;
-{
- register int count = 0;
- register char *scan;
- register char *opnd;
-
- scan = reginput;
- opnd = OPERAND(p);
- switch (OP(p)) {
- case ANY:
- count = strlen(scan);
- scan += count;
- break;
- case EXACTLY:
- while (*opnd == *scan) {
- count++;
- scan++;
- }
- break;
- case ANYOF:
- while (*scan != '\0' && strchr(opnd, *scan) != NULL) {
- count++;
- scan++;
- }
- break;
- case ANYBUT:
- while (*scan != '\0' && strchr(opnd, *scan) == NULL) {
- count++;
- scan++;
- }
- break;
- default: /* Oh dear. Called inappropriately. */
- regerror("internal foulup");
- count = 0; /* Best compromise. */
- break;
- }
- reginput = scan;
-
- return(count);
-}
-
-/*
- - regnext - dig the "next" pointer out of a node
- */
-static char *
-regnext(p)
-register char *p;
-{
- register int offset;
-
- if (p == &regdummy)
- return(NULL);
-
- offset = NEXT(p);
- if (offset == 0)
- return(NULL);
-
- if (OP(p) == BACK)
- return(p-offset);
- else
- return(p+offset);
-}
-
-#ifdef DEBUG
-
-/*
- - regdump - dump a regexp onto stdout in vaguely comprehensible form
- */
-void
-regdump(r)
-regexp *r;
-{
- register char *s;
- register char op = EXACTLY; /* Arbitrary non-END op. */
- register char *next;
- extern char *strchr();
-
-
- s = r->program + 1;
- while (op != END) { /* While that wasn't END last time... */
- op = OP(s);
- printf("%2d%s", s-r->program, regprop(s)); /* Where, what. */
- next = regnext(s);
- if (next == NULL) /* Next ptr. */
- printf("(0)");
- else
- printf("(%d)", (s-r->program)+(next-s));
- s += 3;
- if (op == ANYOF || op == ANYBUT || op == EXACTLY) {
- /* Literal string, where present. */
- while (*s != '\0') {
- putchar(*s);
- s++;
- }
- s++;
- }
- putchar('\n');
- }
-
- /* Header fields of interest. */
- if (r->regstart != '\0')
- printf("start `%c' ", r->regstart);
- if (r->reganch)
- printf("anchored ");
- if (r->regmust != NULL)
- printf("must have \"%s\"", r->regmust);
- printf("\n");
-}
-
-/*
- - regprop - printable representation of opcode
- */
-static char *
-regprop(op)
-char *op;
-{
- register char *p;
- static char buf[50];
-
- (void) strcpy(buf, ":");
-
- switch (OP(op)) {
- case BOL:
- p = "BOL";
- break;
- case EOL:
- p = "EOL";
- break;
- case ANY:
- p = "ANY";
- break;
- case ANYOF:
- p = "ANYOF";
- break;
- case ANYBUT:
- p = "ANYBUT";
- break;
- case BRANCH:
- p = "BRANCH";
- break;
- case EXACTLY:
- p = "EXACTLY";
- break;
- case NOTHING:
- p = "NOTHING";
- break;
- case BACK:
- p = "BACK";
- break;
- case END:
- p = "END";
- break;
- case OPEN+1:
- case OPEN+2:
- case OPEN+3:
- case OPEN+4:
- case OPEN+5:
- case OPEN+6:
- case OPEN+7:
- case OPEN+8:
- case OPEN+9:
- sprintf(buf+strlen(buf), "OPEN%d", OP(op)-OPEN);
- p = NULL;
- break;
- case CLOSE+1:
- case CLOSE+2:
- case CLOSE+3:
- case CLOSE+4:
- case CLOSE+5:
- case CLOSE+6:
- case CLOSE+7:
- case CLOSE+8:
- case CLOSE+9:
- sprintf(buf+strlen(buf), "CLOSE%d", OP(op)-CLOSE);
- p = NULL;
- break;
- case STAR:
- p = "STAR";
- break;
- case PLUS:
- p = "PLUS";
- break;
- case WORDA:
- p = "WORDA";
- break;
- case WORDZ:
- p = "WORDZ";
- break;
- default:
- regerror("corrupted opcode");
- break;
- }
- if (p != NULL)
- (void) strcat(buf, p);
- return(buf);
-}
-#endif
-
-/*
- * The following is provided for those people who do not have strcspn() in
- * their C libraries. They should get off their butts and do something
- * about it; at least one public-domain implementation of those (highly
- * useful) string routines has been published on Usenet.
- */
-#ifdef STRCSPN
-/*
- * strcspn - find length of initial segment of s1 consisting entirely
- * of characters not from s2
- */
-
-static int
-strcspn(s1, s2)
-char *s1;
-char *s2;
-{
- register char *scan1;
- register char *scan2;
- register int count;
-
- count = 0;
- for (scan1 = s1; *scan1 != '\0'; scan1++) {
- for (scan2 = s2; *scan2 != '\0';) /* ++ moved down. */
- if (*scan1 == *scan2++)
- return(count);
- count++;
- }
- return(count);
-}
-#endif
diff --git a/winsup/cygwin/regexp/regsub.c b/winsup/cygwin/regexp/regsub.c
deleted file mode 100644
index e544072c1..000000000
--- a/winsup/cygwin/regexp/regsub.c
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * regsub
- *
- * Copyright (c) 1986 by University of Toronto.
- * Written by Henry Spencer. Not derived from licensed software.
- *
- * Permission is granted to anyone to use this software for any
- * purpose on any computer system, and to redistribute it freely,
- * subject to the following restrictions:
- *
- * 1. The author is not responsible for the consequences of use of
- * this software, no matter how awful, even if they arise
- * from defects in it.
- *
- * 2. The origin of this software must not be misrepresented, either
- * by explicit claim or by omission.
- *
- * 3. Altered versions must be plainly marked as such, and must not
- * be misrepresented as being the original software.
- */
-
-#if 0
-#ifndef lint
-static char *rcsid = "$Id$";
-#endif /* not lint */
-#endif
-
-#include "regexp.h"
-#include <stdio.h>
-#include <string.h>
-#include "regmagic.h"
-
-#ifndef CHARBITS
-#define UCHARAT(p) ((int)*(unsigned char *)(p))
-#else
-#define UCHARAT(p) ((int)*(p)&CHARBITS)
-#endif
-
-/*
- - regsub - perform substitutions after a regexp match
- */
-void
-regsub(prog, source, dest)
-const regexp *prog;
-const char *source;
-char *dest;
-{
- register char *src;
- register char *dst;
- register char c;
- register int no;
- register int len;
-
- if (prog == NULL || source == NULL || dest == NULL) {
- regerror("NULL parm to regsub");
- return;
- }
- if (UCHARAT(prog->program) != MAGIC) {
- regerror("damaged regexp fed to regsub");
- return;
- }
-
- src = (char *)source;
- dst = dest;
- while ((c = *src++) != '\0') {
- if (c == '&')
- no = 0;
- else if (c == '\\' && '0' <= *src && *src <= '9')
- no = *src++ - '0';
- else
- no = -1;
- if (no < 0) { /* Ordinary character. */
- if (c == '\\' && (*src == '\\' || *src == '&'))
- c = *src++;
- *dst++ = c;
- } else if (prog->startp[no] != NULL && prog->endp[no] != NULL) {
- len = prog->endp[no] - prog->startp[no];
- (void) strncpy(dst, prog->startp[no], len);
- dst += len;
- if (len != 0 && *(dst-1) == '\0') { /* strncpy hit NUL. */
- regerror("damaged match string");
- return;
- }
- }
- }
- *dst++ = '\0';
-}
diff --git a/winsup/cygwin/resource.cc b/winsup/cygwin/resource.cc
index 8dd373b6f..e9121e94c 100644
--- a/winsup/cygwin/resource.cc
+++ b/winsup/cygwin/resource.cc
@@ -20,6 +20,7 @@ details. */
#include "sync.h"
#include "sigproc.h"
#include "pinfo.h"
+#include "psapi.h"
/* add timeval values */
static void
@@ -73,6 +74,15 @@ fill_rusage (struct rusage *r, HANDLE h)
add_timeval (&r->ru_stime, &tv);
totimeval (&tv, &user_time, 0, 0);
add_timeval (&r->ru_utime, &tv);
+
+ PROCESS_MEMORY_COUNTERS pmc;
+
+ memset (&pmc, 0, sizeof (pmc));
+ if (GetProcessMemoryInfo( h, &pmc, sizeof (pmc)))
+ {
+ r->ru_maxrss += (long) (pmc.WorkingSetSize /1024);
+ r->ru_majflt += pmc.PageFaultCount;
+ }
}
extern "C"
@@ -102,8 +112,7 @@ getrusage (int intwho, struct rusage *rusage_in)
unsigned long rlim_core = RLIM_INFINITY;
-extern "C"
-int
+extern "C" int
getrlimit (int resource, struct rlimit *rlp)
{
MEMORY_BASIC_INFORMATION m;
@@ -147,8 +156,7 @@ getrlimit (int resource, struct rlimit *rlp)
return 0;
}
-extern "C"
-int
+extern "C" int
setrlimit (int resource, const struct rlimit *rlp)
{
if (check_null_invalid_struct_errno (rlp))
diff --git a/winsup/cygwin/sec_acl.cc b/winsup/cygwin/sec_acl.cc
index 36bff09c2..3a806d05e 100644
--- a/winsup/cygwin/sec_acl.cc
+++ b/winsup/cygwin/sec_acl.cc
@@ -577,13 +577,13 @@ extern "C"
int
facl (int fd, int cmd, int nentries, aclent_t *aclbufp)
{
- if (cygheap->fdtab.not_open (fd))
+ cygheap_fdget cfd (fd);
+ if (cfd < 0)
{
syscall_printf ("-1 = facl (%d)", fd);
- set_errno (EBADF);
return -1;
}
- const char *path = cygheap->fdtab[fd]->get_name ();
+ const char *path = cfd->get_name ();
if (path == NULL)
{
syscall_printf ("-1 = facl (%d) (no name)", fd);
diff --git a/winsup/cygwin/security.cc b/winsup/cygwin/security.cc
index d4dd03c70..77ea8fbcc 100644
--- a/winsup/cygwin/security.cc
+++ b/winsup/cygwin/security.cc
@@ -157,7 +157,7 @@ str2buf2lsa (LSA_STRING &tgt, char *buf, const char *srcstr)
memcpy(buf, srcstr, tgt.MaximumLength);
}
-static void
+void
str2buf2uni (UNICODE_STRING &tgt, WCHAR *buf, const char *srcstr)
{
tgt.Length = strlen (srcstr) * sizeof (WCHAR);
@@ -181,9 +181,9 @@ static LSA_HANDLE
open_local_policy ()
{
LSA_OBJECT_ATTRIBUTES oa = { 0, 0, 0, 0, 0, 0 };
- LSA_HANDLE lsa = INVALID_HANDLE_VALUE;
+ LSA_HANDLE lsa = NULL;
- NTSTATUS ret = LsaOpenPolicy(NULL, &oa, POLICY_ALL_ACCESS, &lsa);
+ NTSTATUS ret = LsaOpenPolicy(NULL, &oa, POLICY_EXECUTE, &lsa);
if (ret != STATUS_SUCCESS)
set_errno (LsaNtStatusToWinError (ret));
return lsa;
@@ -326,11 +326,8 @@ is_group_member (WCHAR *wlogonserver, WCHAR *wgroup,
NET_API_STATUS ret;
BOOL retval = FALSE;
- ret = NetLocalGroupGetMembers (wlogonserver, wgroup, 0, (LPBYTE *) &buf,
+ ret = NetLocalGroupGetMembers (NULL, wgroup, 0, (LPBYTE *) &buf,
MAX_PREFERRED_LENGTH, &cnt, &tot, NULL);
- if (ret == ERROR_BAD_NETPATH || ret == RPC_S_SERVER_UNAVAILABLE)
- ret = NetLocalGroupGetMembers (NULL, wgroup, 0, (LPBYTE *) &buf,
- MAX_PREFERRED_LENGTH, &cnt, &tot, NULL);
if (ret)
return FALSE;
@@ -354,11 +351,8 @@ get_user_local_groups (WCHAR *wlogonserver, const char *logonserver,
DWORD cnt, tot;
NET_API_STATUS ret;
- ret = NetLocalGroupEnum (wlogonserver, 0, (LPBYTE *) &buf,
+ ret = NetLocalGroupEnum (NULL, 0, (LPBYTE *) &buf,
MAX_PREFERRED_LENGTH, &cnt, &tot, NULL);
- if (ret == ERROR_BAD_NETPATH || ret == RPC_S_SERVER_UNAVAILABLE)
- ret = NetLocalGroupEnum (NULL, 0, (LPBYTE *) &buf,
- MAX_PREFERRED_LENGTH, &cnt, &tot, NULL);
if (ret)
{
debug_printf ("%d = NetLocalGroupEnum ()", ret);
@@ -454,6 +448,30 @@ get_user_primary_group (WCHAR *wlogonserver, const char *user,
return retval;
}
+static int
+get_supplementary_group_sidlist (const char *username, cygsidlist &grp_list)
+{
+ struct group *gr;
+ int cnt = 0;
+
+ for (int gidx = 0; (gr = internal_getgrent (gidx)); ++gidx)
+ {
+ if (gr->gr_mem)
+ for (int gi = 0; gr->gr_mem[gi]; ++gi)
+ if (strcasematch (username, gr->gr_mem[gi]))
+ {
+ if (gr->gr_passwd && *gr->gr_passwd)
+ {
+ cygsid sid (gr->gr_passwd);
+ if ((PSID)sid && grp_list.add (sid))
+ ++cnt;
+ }
+ break;
+ }
+ }
+ return cnt;
+}
+
static BOOL
get_group_sidlist (const char *logonserver, cygsidlist &grp_list,
cygsid &usersid, cygsid &pgrpsid,
@@ -465,6 +483,7 @@ get_group_sidlist (const char *logonserver, cygsidlist &grp_list,
DWORD ulen = INTERNET_MAX_HOST_NAME_LENGTH + 1;
DWORD dlen = INTERNET_MAX_HOST_NAME_LENGTH + 1;
SID_NAME_USE use;
+ cygsidlist sup_list;
auth_pos = -1;
sys_mbstowcs (wserver, logonserver, INTERNET_MAX_HOST_NAME_LENGTH + 1);
@@ -520,6 +539,12 @@ get_group_sidlist (const char *logonserver, cygsidlist &grp_list,
return FALSE;
if (!grp_list.contains (pgrpsid))
grp_list += pgrpsid;
+ if (get_supplementary_group_sidlist (user, sup_list))
+ {
+ for (int i = 0; i < sup_list.count; ++i)
+ if (!grp_list.contains (sup_list.sids[i]))
+ grp_list += sup_list.sids[i];
+ }
return TRUE;
}
@@ -714,7 +739,7 @@ create_token (cygsid &usersid, cygsid &pgrpsid)
goto out;
/* Open policy object. */
- if ((lsa = open_local_policy ()) == INVALID_HANDLE_VALUE)
+ if (!(lsa = open_local_policy ()))
goto out;
/* Get logon server. */
diff --git a/winsup/cygwin/security.h b/winsup/cygwin/security.h
index 8555fe461..c1636aab0 100644
--- a/winsup/cygwin/security.h
+++ b/winsup/cygwin/security.h
@@ -39,6 +39,15 @@ class cygsid {
}
public:
+ inline operator const PSID () { return psid; }
+
+ inline const PSID operator= (cygsid &nsid)
+ { return assign (nsid); }
+ inline const PSID operator= (const PSID nsid)
+ { return assign (nsid); }
+ inline const PSID operator= (const char *nsidstr)
+ { return getfromstr (nsidstr); }
+
inline cygsid () : psid ((PSID) sbuf) {}
inline cygsid (const PSID nsid) { *this = nsid; }
inline cygsid (const char *nstrsid) { *this = nstrsid; }
@@ -54,13 +63,6 @@ public:
char *string (char *nsidstr) const;
- inline const PSID operator= (cygsid &nsid)
- { return assign (nsid); }
- inline const PSID operator= (const PSID nsid)
- { return assign (nsid); }
- inline const PSID operator= (const char *nsidstr)
- { return getfromstr (nsidstr); }
-
inline BOOL operator== (const PSID nsid) const
{
if (!psid || !nsid)
@@ -77,8 +79,6 @@ public:
inline BOOL operator!= (const char *nsidstr) const
{ return !(*this == nsidstr); }
- inline operator const PSID () { return psid; }
-
void debug_print (const char *prefix = NULL) const
{
char buf[256];
diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc
index e66d078c8..56d818d56 100644
--- a/winsup/cygwin/select.cc
+++ b/winsup/cygwin/select.cc
@@ -84,30 +84,12 @@ typedef long fd_mask;
#define allocfd_set(n) ((fd_set *) memset (alloca (sizeof_fd_set (n)), 0, sizeof_fd_set (n)))
#define copyfd_set(to, from, n) memcpy (to, from, sizeof_fd_set (n));
-/* Make a fhandler_foo::ready_for_ready method.
- Assumption: The "ready_for_read" methods are called with one level of
- signal blocking. */
-#define MAKEready(what) \
-int \
-fhandler_##what::ready_for_read (int fd, DWORD howlong, int ignra) \
-{ \
- select_record me (this); \
- me.fd = fd; \
- (void) select_read (&me); \
- while (!peek_##what (&me, ignra) && howlong == INFINITE) \
- if (fd >= 0 && cygheap->fdtab.not_open (fd)) \
- break; \
- else if (WaitForSingleObject (signal_arrived, 10) == WAIT_OBJECT_0) \
- break; \
- return me.read_ready; \
-}
-
#define set_handle_or_return_if_not_open(h, s) \
h = (s)->fh->get_handle (); \
if (cygheap->fdtab.not_open ((s)->fd)) \
{ \
- (s)->saw_error = TRUE; \
- set_errno (EBADF); \
+ (s)->saw_error = true; \
+ set_sig_errno (EBADF); \
return -1; \
} \
@@ -228,28 +210,16 @@ select_stuff::test_and_set (int i, fd_set *readfds, fd_set *writefds,
return 1; /* nothing to do */
if (s->read_ready || s->write_ready || s->except_ready)
- always_ready = TRUE;
+ always_ready = true;
if (s->windows_handle || s->windows_handle || s->windows_handle)
- windows_used = TRUE;
+ windows_used = true;
s->next = start.next;
start.next = s;
return 1;
}
-/* Poll every fd in the select chain. Set appropriate fd in mask. */
-int
-select_stuff::poll (fd_set *readfds, fd_set *writefds, fd_set *exceptfds)
-{
- int n = 0;
- select_record *s = &start;
- while ((s = s->next))
- n += s->poll (s, readfds, writefds, exceptfds);
- select_printf ("returning %d", n);
- return n;
-}
-
/* The heart of select. Waits for an fd to do something interesting. */
int
select_stuff::wait (fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
@@ -268,7 +238,7 @@ select_stuff::wait (fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
{
if (m > MAXIMUM_WAIT_OBJECTS)
{
- set_errno (EINVAL);
+ set_sig_errno (EINVAL);
return -1;
}
if (!s->startup (s, this))
@@ -315,12 +285,16 @@ select_stuff::wait (fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
select_printf ("woke up. wait_ret %d. verifying", wait_ret);
s = &start;
int gotone = FALSE;
+ /* Some types of object (e.g., consoles) wake up on "inappropriate" events
+ like mouse movements. The verify function will detect these situations.
+ If it returns false, then this wakeup was a false alarm and we should go
+ back to waiting. */
while ((s = s->next))
if (s->saw_error)
return -1; /* Somebody detected an error */
else if ((((wait_ret >= m && s->windows_handle) || s->h == w4[wait_ret])) &&
s->verify (s, readfds, writefds, exceptfds))
- gotone = TRUE;
+ gotone = true;
select_printf ("gotone %d", gotone);
if (gotone)
@@ -351,7 +325,7 @@ out:
static int
set_bits (select_record *me, fd_set *readfds, fd_set *writefds,
- fd_set *exceptfds)
+ fd_set *exceptfds)
{
int ready = 0;
select_printf ("me %p, testing fd %d (%s)", me, me->fd, me->fh->get_name ());
@@ -365,7 +339,7 @@ set_bits (select_record *me, fd_set *readfds, fd_set *writefds,
UNIX_FD_SET (me->fd, writefds);
ready++;
}
- if (me->except_ready && me->except_ready)
+ if (me->except_selected && me->except_ready)
{
UNIX_FD_SET (me->fd, exceptfds);
ready++;
@@ -374,6 +348,19 @@ set_bits (select_record *me, fd_set *readfds, fd_set *writefds,
return ready;
}
+/* Poll every fd in the select chain. Set appropriate fd in mask. */
+int
+select_stuff::poll (fd_set *readfds, fd_set *writefds, fd_set *exceptfds)
+{
+ int n = 0;
+ select_record *s = &start;
+ while ((s = s->next))
+ n += (!s->peek || s->peek (s, true)) ?
+ set_bits (s, readfds, writefds, exceptfds) : 0;
+ select_printf ("returning %d", n);
+ return n;
+}
+
static int
verify_true (select_record *, fd_set *, fd_set *, fd_set *)
{
@@ -400,7 +387,7 @@ no_verify (select_record *, fd_set *, fd_set *, fd_set *)
}
static int
-peek_pipe (select_record *s, int ignra, HANDLE guard_mutex = NULL)
+peek_pipe (select_record *s, bool from_select)
{
int n = 0;
int gotone = 0;
@@ -409,6 +396,15 @@ peek_pipe (select_record *s, int ignra, HANDLE guard_mutex = NULL)
HANDLE h;
set_handle_or_return_if_not_open (h, s);
+ /* pipes require a guard mutex to guard against the situation where multiple
+ readers are attempting to read from the same pipe. In this scenario, it
+ is possible for PeekNamedPipe to report available data to two readers but
+ only one will actually get the data. This will result in the other reader
+ entering fhandler_base::raw_read and blocking indefinitely in an interruptible
+ state. This causes things like "make -j2" to hang. So, for the non-select case
+ we use the pipe mutex, if it is available. */
+ HANDLE guard_mutex = from_select ? NULL : fh->get_guard ();
+
/* Don't perform complicated tests if we don't need to. */
if (!s->read_selected && !s->except_selected)
goto out;
@@ -428,22 +424,22 @@ peek_pipe (select_record *s, int ignra, HANDLE guard_mutex = NULL)
case FH_TTYM:
if (((fhandler_pty_master *)fh)->need_nl)
{
- gotone = s->read_ready = 1;
+ gotone = s->read_ready = true;
goto out;
}
break;
default:
- if (!ignra && fh->get_readahead_valid ())
+ if (fh->get_readahead_valid ())
{
select_printf ("readahead");
- gotone = s->read_ready = 1;
+ gotone = s->read_ready = true;
goto out;
}
}
if (fh->bg_check (SIGTTIN) <= bg_eof)
{
- gotone = s->read_ready = 1;
+ gotone = s->read_ready = true;
goto out;
}
}
@@ -455,34 +451,48 @@ peek_pipe (select_record *s, int ignra, HANDLE guard_mutex = NULL)
select_printf ("%s, PeekNamedPipe failed, %E", fh->get_name ());
n = -1;
}
- else if (n && guard_mutex
- && WaitForSingleObject (guard_mutex, 0) != WAIT_OBJECT_0)
+ else if (!n || !guard_mutex)
+ /* no guard mutex or nothing to read fromt he pipe. */;
+ else if (WaitForSingleObject (guard_mutex, 0) != WAIT_OBJECT_0)
{
select_printf ("%s, couldn't get mutex %p, %E", fh->get_name (),
- guard_mutex);
+ guard_mutex);
n = 0;
}
+ else
+ {
+ /* Now that we have the mutex, make sure that no one else has snuck
+ in and grabbed the data that we originally saw. */
+ if (!PeekNamedPipe (h, NULL, 0, NULL, (DWORD *) &n, NULL))
+ {
+ select_printf ("%s, PeekNamedPipe failed, %E", fh->get_name ());
+ n = -1;
+ }
+ if (n <= 0)
+ ReleaseMutex (guard_mutex); /* Oops. We lost the race. */
+ }
if (n < 0)
{
+ fh->set_eof (); /* Flag that other end of pipe is gone */
select_printf ("%s, n %d", fh->get_name (), n);
if (s->except_selected)
- gotone += s->except_ready = TRUE;
+ gotone += s->except_ready = true;
if (s->read_selected)
- gotone += s->read_ready = TRUE;
+ gotone += s->read_ready = true;
}
if (n > 0 && s->read_selected)
{
select_printf ("%s, ready for read", fh->get_name ());
- gotone += s->read_ready = TRUE;
+ gotone += s->read_ready = true;
}
if (!gotone && s->fh->hit_eof ())
{
select_printf ("%s, saw EOF", fh->get_name ());
if (s->except_selected)
- gotone = s->except_ready = TRUE;
+ gotone = s->except_ready = true;
if (s->read_selected)
- gotone += s->read_ready = TRUE;
+ gotone += s->read_ready = true;
select_printf ("saw eof on '%s'", fh->get_name ());
}
@@ -490,30 +500,6 @@ out:
return gotone || s->write_ready;
}
-static int
-poll_pipe (select_record *me, fd_set *readfds, fd_set *writefds,
- fd_set *exceptfds)
-{
- return peek_pipe (me, 0) ?
- set_bits (me, readfds, writefds, exceptfds) :
- 0;
-}
-
-int
-fhandler_pipe::ready_for_read (int fd, DWORD howlong, int ignra)
-{
- select_record me (this);
- me.fd = fd;
- (void) select_read (&me);
- while (!peek_pipe (&me, ignra, guard) && howlong == INFINITE)
- if (fd >= 0 && cygheap->fdtab.not_open (fd))
- break;
- else if (WaitForSingleObject (signal_arrived, 10) == WAIT_OBJECT_0)
- break;
- select_printf ("returning %d", me.read_ready);
- return me.read_ready;
-}
-
static int start_thread_pipe (select_record *me, select_stuff *stuff);
struct pipeinf
@@ -535,8 +521,8 @@ thread_pipe (void *arg)
while ((s = s->next))
if (s->startup == start_thread_pipe)
{
- if (peek_pipe (s, 0))
- gotone = TRUE;
+ if (peek_pipe (s, true))
+ gotone = true;
if (pi->stop_thread_pipe)
{
select_printf ("stopping");
@@ -581,7 +567,7 @@ pipe_cleanup (select_record *, select_stuff *stuff)
pipeinf *pi = (pipeinf *)stuff->device_specific[FHDEVN(FH_PIPE)];
if (pi && pi->thread)
{
- pi->stop_thread_pipe = TRUE;
+ pi->stop_thread_pipe = true;
WaitForSingleObject (pi->thread, INFINITE);
CloseHandle (pi->thread);
delete pi;
@@ -595,9 +581,10 @@ fhandler_pipe::select_read (select_record *s)
if (!s)
s = new select_record;
s->startup = start_thread_pipe;
- s->poll = poll_pipe;
+ s->peek = peek_pipe;
s->verify = verify_ok;
- s->read_selected = TRUE;
+ s->read_selected = true;
+ s->read_ready = false;
s->cleanup = pipe_cleanup;
return s;
}
@@ -609,11 +596,11 @@ fhandler_pipe::select_write (select_record *s)
{
s = new select_record;
s->startup = no_startup;
- s->poll = poll_pipe;
s->verify = no_verify;
}
- s->write_selected = TRUE;
- s->write_ready = TRUE;
+ s->peek = peek_pipe;
+ s->write_selected = true;
+ s->write_ready = true;
return s;
}
@@ -623,15 +610,16 @@ fhandler_pipe::select_except (select_record *s)
if (!s)
s = new select_record;
s->startup = start_thread_pipe;
- s->poll = poll_pipe;
+ s->peek = peek_pipe;
s->verify = verify_ok;
s->cleanup = pipe_cleanup;
- s->except_selected = TRUE;
+ s->except_selected = true;
+ s->except_ready = false;
return s;
}
static int
-peek_console (select_record *me, int ignra)
+peek_console (select_record *me, bool)
{
extern const char * get_nonascii_key (INPUT_RECORD& input_rec, char *);
fhandler_console *fh = (fhandler_console *)me->fh;
@@ -639,10 +627,10 @@ peek_console (select_record *me, int ignra)
if (!me->read_selected)
return me->write_ready;
- if (!ignra && fh->get_readahead_valid ())
+ if (fh->get_readahead_valid ())
{
select_printf ("readahead");
- return me->read_ready = 1;
+ return me->read_ready = true;
}
if (me->read_ready)
@@ -659,7 +647,7 @@ peek_console (select_record *me, int ignra)
for (;;)
if (fh->bg_check (SIGTTIN) <= bg_eof)
- return me->read_ready = 1;
+ return me->read_ready = true;
else if (!PeekConsoleInput (h, &irec, 1, &events_read) || !events_read)
break;
else
@@ -671,11 +659,11 @@ peek_console (select_record *me, int ignra)
irec.Event.MouseEvent.dwEventFlags == DOUBLE_CLICK))
{
if (fh->mouse_aware ())
- return me->read_ready = 1;
+ return me->read_ready = true;
}
- else if (irec.EventType == KEY_EVENT && irec.Event.KeyEvent.bKeyDown == TRUE &&
+ else if (irec.EventType == KEY_EVENT && irec.Event.KeyEvent.bKeyDown == true &&
(irec.Event.KeyEvent.uChar.AsciiChar || get_nonascii_key (irec, tmpbuf)))
- return me->read_ready = 1;
+ return me->read_ready = true;
/* Read and discard the event */
ReadConsoleInput (h, &irec, 1, &events_read);
@@ -685,15 +673,12 @@ peek_console (select_record *me, int ignra)
}
static int
-poll_console (select_record *me, fd_set *readfds, fd_set *writefds,
- fd_set *exceptfds)
+verify_console (select_record *me, fd_set *rfds, fd_set *wfds,
+ fd_set *efds)
{
- return peek_console (me, 0) ?
- set_bits (me, readfds, writefds, exceptfds) :
- 0;
+ return peek_console (me, true);
}
-MAKEready (console)
select_record *
fhandler_console::select_read (select_record *s)
@@ -702,13 +687,14 @@ fhandler_console::select_read (select_record *s)
{
s = new select_record;
s->startup = no_startup;
- s->poll = poll_console;
- s->verify = poll_console;
+ s->verify = verify_console;
set_cursor_maybe ();
}
+ s->peek = peek_console;
s->h = get_handle ();
- s->read_selected = TRUE;
+ s->read_selected = true;
+ s->read_ready = false;
return s;
}
@@ -719,13 +705,13 @@ fhandler_console::select_write (select_record *s)
{
s = new select_record;
s->startup = no_startup;
- s->poll = poll_console;
s->verify = no_verify;
set_cursor_maybe ();
}
- s->write_selected = TRUE;
- s->write_ready = TRUE;
+ s->peek = peek_console;
+ s->write_selected = true;
+ s->write_ready = true;
return s;
}
@@ -736,30 +722,16 @@ fhandler_console::select_except (select_record *s)
{
s = new select_record;
s->startup = no_startup;
- s->poll = poll_console;
s->verify = no_verify;
set_cursor_maybe ();
}
- s->except_selected = TRUE;
+ s->peek = peek_console;
+ s->except_selected = true;
+ s->except_ready = false;
return s;
}
-int
-fhandler_tty_common::ready_for_read (int fd, DWORD howlong, int ignra)
-{
- select_record me (this);
- me.fd = fd;
- (void) select_read (&me);
- while (!peek_pipe (&me, ignra) && howlong == INFINITE)
- if (fd >= 0 && cygheap->fdtab.not_open (fd))
- break;
- else if (WaitForSingleObject (signal_arrived, 10) == WAIT_OBJECT_0)
- break;
- select_printf ("returning %d", me.read_ready);
- return me.read_ready;
-}
-
select_record *
fhandler_tty_common::select_read (select_record *s)
{
@@ -783,7 +755,7 @@ verify_tty_slave (select_record *me, fd_set *readfds, fd_set *writefds,
fd_set *exceptfds)
{
if (WaitForSingleObject (me->h, 0) == WAIT_OBJECT_0)
- me->read_ready = 1;
+ me->read_ready = true;
return set_bits (me, readfds, writefds, exceptfds);
}
@@ -794,18 +766,24 @@ fhandler_tty_slave::select_read (select_record *s)
s = new select_record;
s->h = input_available_event;
s->startup = no_startup;
- s->poll = poll_pipe;
+ s->peek = peek_pipe;
s->verify = verify_tty_slave;
- s->read_selected = TRUE;
+ s->read_selected = true;
+ s->read_ready = false;
s->cleanup = NULL;
return s;
}
int
-fhandler_tty_slave::ready_for_read (int fd, DWORD howlong, int ignra)
+fhandler_tty_slave::ready_for_read (int fd, DWORD howlong)
{
HANDLE w4[2];
- if (!ignra && get_readahead_valid ())
+ if (cygheap->fdtab.not_open (fd))
+ {
+ set_sig_errno (EBADF);
+ return 0;
+ }
+ if (get_readahead_valid ())
{
select_printf ("readahead");
return 1;
@@ -814,13 +792,18 @@ fhandler_tty_slave::ready_for_read (int fd, DWORD howlong, int ignra)
w4[1] = input_available_event;
switch (WaitForMultipleObjects (2, w4, FALSE, howlong))
{
+ case WAIT_OBJECT_0:
+ set_sig_errno (EINTR);
+ return 0;
case WAIT_OBJECT_0 + 1:
return 1;
case WAIT_FAILED:
select_printf ("wait failed %E");
- case WAIT_OBJECT_0:
- case WAIT_TIMEOUT:
+ set_sig_errno (EINVAL); /* FIXME: correct errno? */
+ return 0;
default:
+ if (!howlong)
+ set_sig_errno (EAGAIN);
return 0;
}
}
@@ -832,12 +815,11 @@ fhandler_dev_null::select_read (select_record *s)
{
s = new select_record;
s->startup = no_startup;
- s->poll = set_bits;
s->verify = no_verify;
}
s->h = get_handle ();
- s->read_selected = TRUE;
- s->read_ready = TRUE;
+ s->read_selected = true;
+ s->read_ready = true;
return s;
}
@@ -848,12 +830,11 @@ fhandler_dev_null::select_write (select_record *s)
{
s = new select_record;
s->startup = no_startup;
- s->poll = set_bits;
s->verify = no_verify;
}
s->h = get_handle ();
- s->write_selected = TRUE;
- s->write_ready = TRUE;
+ s->write_selected = true;
+ s->write_ready = true;
return s;
}
@@ -864,12 +845,11 @@ fhandler_dev_null::select_except (select_record *s)
{
s = new select_record;
s->startup = no_startup;
- s->poll = set_bits;
s->verify = no_verify;
}
s->h = get_handle ();
- s->except_selected = TRUE;
- s->except_ready = TRUE;
+ s->except_selected = true;
+ s->except_ready = true;
return s;
}
@@ -883,15 +863,14 @@ struct serialinf
};
static int
-peek_serial (select_record *s, int)
+peek_serial (select_record *s, bool)
{
- DWORD ev;
COMSTAT st;
fhandler_serial *fh = (fhandler_serial *)s->fh;
if (fh->get_readahead_valid () || fh->overlapped_armed < 0)
- return s->read_ready = 1;
+ return s->read_ready = true;
select_printf ("fh->overlapped_armed %d", fh->overlapped_armed);
@@ -910,20 +889,19 @@ peek_serial (select_record *s, int)
if (!fh->overlapped_armed)
{
- DWORD ev;
COMSTAT st;
ResetEvent (fh->io_status.hEvent);
- if (!ClearCommError (h, &ev, &st))
+ if (!ClearCommError (h, &fh->ev, &st))
{
debug_printf ("ClearCommError");
goto err;
}
else if (st.cbInQue)
- return s->read_ready = 1;
- else if (WaitCommEvent (h, &ev, &fh->io_status))
- return s->read_ready = 1;
+ return s->read_ready = true;
+ else if (WaitCommEvent (h, &fh->ev, &fh->io_status))
+ return s->read_ready = true;
else if (GetLastError () == ERROR_IO_PENDING)
fh->overlapped_armed = 1;
else
@@ -943,7 +921,7 @@ peek_serial (select_record *s, int)
switch (WaitForMultipleObjects (2, w4, FALSE, to))
{
case WAIT_OBJECT_0:
- if (!ClearCommError (h, &ev, &st))
+ if (!ClearCommError (h, &fh->ev, &st))
{
debug_printf ("ClearCommError");
goto err;
@@ -952,7 +930,7 @@ peek_serial (select_record *s, int)
Sleep (to);
else
{
- return s->read_ready = 1;
+ return s->read_ready = true;
select_printf ("got something");
}
PurgeComm (h, PURGE_TXABORT | PURGE_RXABORT);
@@ -983,7 +961,7 @@ err:
}
__seterrno ();
- s->saw_error = TRUE;
+ s->saw_error = true;
select_printf ("error %E");
return -1;
}
@@ -1000,8 +978,8 @@ thread_serial (void *arg)
while ((s = s->next))
if (s->startup == start_thread_serial)
{
- if (peek_serial (s, 0))
- gotone = TRUE;
+ if (peek_serial (s, true))
+ gotone = true;
}
if (si->stop_thread_serial)
{
@@ -1040,7 +1018,7 @@ serial_cleanup (select_record *, select_stuff *stuff)
serialinf *si = (serialinf *)stuff->device_specific[FHDEVN(FH_SERIAL)];
if (si && si->thread)
{
- si->stop_thread_serial = TRUE;
+ si->stop_thread_serial = true;
WaitForSingleObject (si->thread, INFINITE);
CloseHandle (si->thread);
delete si;
@@ -1048,18 +1026,6 @@ serial_cleanup (select_record *, select_stuff *stuff)
}
}
-static int
-poll_serial (select_record *me, fd_set *readfds, fd_set *writefds,
- fd_set *exceptfds)
-
-{
- return peek_serial (me, 0) ?
- set_bits (me, readfds, writefds, exceptfds) :
- 0;
-}
-
-MAKEready (serial)
-
select_record *
fhandler_serial::select_read (select_record *s)
{
@@ -1067,11 +1033,12 @@ fhandler_serial::select_read (select_record *s)
{
s = new select_record;
s->startup = start_thread_serial;
- s->poll = poll_serial;
s->verify = verify_ok;
s->cleanup = serial_cleanup;
}
- s->read_selected = TRUE;
+ s->peek = peek_serial;
+ s->read_selected = true;
+ s->read_ready = false;
return s;
}
@@ -1082,12 +1049,12 @@ fhandler_serial::select_write (select_record *s)
{
s = new select_record;
s->startup = no_startup;
- s->poll = set_bits;
s->verify = verify_ok;
}
+ s->peek = peek_serial;
s->h = get_handle ();
- s->write_selected = TRUE;
- s->write_ready = TRUE;
+ s->write_selected = true;
+ s->write_ready = true;
return s;
}
@@ -1098,18 +1065,53 @@ fhandler_serial::select_except (select_record *s)
{
s = new select_record;
s->startup = no_startup;
- s->poll = set_bits;
s->verify = verify_ok;
}
s->h = NULL;
- s->except_selected = FALSE; // Can't do this
+ s->peek = peek_serial;
+ s->except_selected = false; // Can't do this
+ s->except_ready = false;
return s;
}
int
-fhandler_base::ready_for_read (int, DWORD, int)
+fhandler_base::ready_for_read (int fd, DWORD howlong)
{
- return 1;
+ int avail = 0;
+ select_record me (this);
+ me.fd = fd;
+ while (!avail)
+ {
+ (void) select_read (&me);
+ avail = me.read_ready ?: me.peek (&me, false);
+
+ if (fd >= 0 && cygheap->fdtab.not_open (fd))
+ {
+ set_sig_errno (EBADF);
+ avail = 0;
+ break;
+ }
+
+ if (howlong != INFINITE)
+ {
+ if (!avail)
+ set_sig_errno (EAGAIN);
+ break;
+ }
+
+ if (WaitForSingleObject (signal_arrived, avail ? 0 : 10) == WAIT_OBJECT_0)
+ {
+ set_sig_errno (EINTR);
+ avail = 0;
+ break;
+ }
+ }
+
+ if (get_guard () && !avail && me.read_ready)
+ ReleaseMutex (get_guard ());
+
+ select_printf ("read_ready %d, avail %d", me.read_ready, avail);
+ return avail;
}
select_record *
@@ -1119,12 +1121,11 @@ fhandler_base::select_read (select_record *s)
{
s = new select_record;
s->startup = no_startup;
- s->poll = set_bits;
s->verify = verify_ok;
}
s->h = get_handle ();
- s->read_selected = TRUE;
- s->read_ready = TRUE;
+ s->read_selected = true;
+ s->read_ready = true;
return s;
}
@@ -1135,12 +1136,11 @@ fhandler_base::select_write (select_record *s)
{
s = new select_record;
s->startup = no_startup;
- s->poll = set_bits;
s->verify = verify_ok;
}
s->h = get_handle ();
- s->write_selected = TRUE;
- s->write_ready = TRUE;
+ s->write_selected = true;
+ s->write_ready = true;
return s;
}
@@ -1151,11 +1151,11 @@ fhandler_base::select_except (select_record *s)
{
s = new select_record;
s->startup = no_startup;
- s->poll = set_bits;
s->verify = verify_ok;
}
s->h = NULL;
- s->write_selected = TRUE;
+ s->except_selected = true;
+ s->except_ready = false;
return s;
}
@@ -1169,14 +1169,13 @@ struct socketinf
};
static int
-peek_socket (select_record *me, int)
+peek_socket (select_record *me, bool)
{
winsock_fd_set ws_readfds, ws_writefds, ws_exceptfds;
struct timeval tv = {0, 0};
WINSOCK_FD_ZERO (&ws_readfds);
WINSOCK_FD_ZERO (&ws_writefds);
WINSOCK_FD_ZERO (&ws_exceptfds);
- int gotone = 0;
HANDLE h;
set_handle_or_return_if_not_open (h, me);
@@ -1205,29 +1204,19 @@ peek_socket (select_record *me, int)
if (r == -1)
{
select_printf ("error %d", WSAGetLastError ());
+ set_winsock_errno ();
return 0;
}
if (WINSOCK_FD_ISSET (h, &ws_readfds) || (me->read_selected && me->read_ready))
- gotone = me->read_ready = TRUE;
+ me->read_ready = true;
if (WINSOCK_FD_ISSET (h, &ws_writefds) || (me->write_selected && me->write_ready))
- gotone = me->write_ready = TRUE;
+ me->write_ready = true;
if (WINSOCK_FD_ISSET (h, &ws_exceptfds) || (me->except_selected && me->except_ready))
- gotone = me->except_ready = TRUE;
- return gotone;
-}
-
-static int
-poll_socket (select_record *me, fd_set *readfds, fd_set *writefds,
- fd_set *exceptfds)
-{
- return peek_socket (me, 0) ?
- set_bits (me, readfds, writefds, exceptfds) :
- 0;
+ me->except_ready = true;
+ return me->read_ready || me->write_ready || me->except_ready;
}
-MAKEready (socket)
-
static int start_thread_socket (select_record *, select_stuff *);
static DWORD WINAPI
@@ -1249,17 +1238,17 @@ thread_socket (void *arg)
if (WINSOCK_FD_ISSET (h, &si->readfds))
{
select_printf ("read_ready");
- s->read_ready = TRUE;
+ s->read_ready = true;
}
if (WINSOCK_FD_ISSET (h, &si->writefds))
{
select_printf ("write_ready");
- s->write_ready = TRUE;
+ s->write_ready = true;
}
if (WINSOCK_FD_ISSET (h, &si->exceptfds))
{
select_printf ("except_ready");
- s->except_ready = TRUE;
+ s->except_ready = true;
}
}
@@ -1402,12 +1391,12 @@ fhandler_socket::select_read (select_record *s)
{
s = new select_record;
s->startup = start_thread_socket;
- s->poll = poll_socket;
s->verify = verify_true;
s->cleanup = socket_cleanup;
}
+ s->peek = peek_socket;
s->read_ready = saw_shutdown_read ();
- s->read_selected = TRUE;
+ s->read_selected = true;
return s;
}
@@ -1418,12 +1407,12 @@ fhandler_socket::select_write (select_record *s)
{
s = new select_record;
s->startup = start_thread_socket;
- s->poll = poll_socket;
s->verify = verify_true;
s->cleanup = socket_cleanup;
}
+ s->peek = peek_socket;
s->write_ready = saw_shutdown_write ();
- s->write_selected = TRUE;
+ s->write_selected = true;
return s;
}
@@ -1434,18 +1423,18 @@ fhandler_socket::select_except (select_record *s)
{
s = new select_record;
s->startup = start_thread_socket;
- s->poll = poll_socket;
s->verify = verify_true;
s->cleanup = socket_cleanup;
}
+ s->peek = peek_socket;
/* FIXME: Is this right? Should these be used as criteria for except? */
s->except_ready = saw_shutdown_write () || saw_shutdown_read ();
- s->except_selected = TRUE;
+ s->except_selected = true;
return s;
}
static int
-peek_windows (select_record *me, int)
+peek_windows (select_record *me, bool)
{
MSG m;
HANDLE h;
@@ -1456,7 +1445,7 @@ peek_windows (select_record *me, int)
if (PeekMessage (&m, (HWND) h, 0, 0, PM_NOREMOVE))
{
- me->read_ready = TRUE;
+ me->read_ready = true;
select_printf ("window %d(%p) ready", me->fd, me->fh->get_handle ());
return 1;
}
@@ -1466,17 +1455,12 @@ peek_windows (select_record *me, int)
}
static int
-poll_windows (select_record *me, fd_set *readfds, fd_set *writefds,
- fd_set *exceptfds)
+verify_windows (select_record *me, fd_set *rfds, fd_set *wfds,
+ fd_set *efds)
{
-
- return peek_windows (me, 0) ?
- set_bits (me, readfds, writefds, exceptfds) :
- 0;
+ return peek_windows (me, true);
}
-MAKEready (windows)
-
select_record *
fhandler_windows::select_read (select_record *s)
{
@@ -1484,13 +1468,13 @@ fhandler_windows::select_read (select_record *s)
{
s = new select_record;
s->startup = no_startup;
- s->poll = poll_windows;
- s->verify = poll_windows;
}
+ s->verify = verify_windows;
+ s->peek = peek_windows;
+ s->read_selected = true;
+ s->read_ready = false;
s->h = get_handle ();
- s->read_selected = TRUE;
- s->h = get_handle ();
- s->windows_handle = TRUE;
+ s->windows_handle = true;
return s;
}
@@ -1501,13 +1485,13 @@ fhandler_windows::select_write (select_record *s)
{
s = new select_record;
s->startup = no_startup;
- s->poll = set_bits;
s->verify = verify_ok;
}
+ s->peek = peek_windows;
s->h = get_handle ();
- s->write_selected = TRUE;
- s->write_ready = TRUE;
- s->windows_handle = TRUE;
+ s->write_selected = true;
+ s->write_ready = true;
+ s->windows_handle = true;
return s;
}
@@ -1518,12 +1502,12 @@ fhandler_windows::select_except (select_record *s)
{
s = new select_record;
s->startup = no_startup;
- s->poll = set_bits;
s->verify = verify_ok;
}
+ s->peek = peek_windows;
s->h = get_handle ();
- s->except_selected = TRUE;
- s->except_ready = TRUE;
- s->windows_handle = TRUE;
+ s->except_selected = true;
+ s->except_ready = true;
+ s->windows_handle = true;
return s;
}
diff --git a/winsup/cygwin/shared.cc b/winsup/cygwin/shared.cc
index 81d39e3ed..f10fd7f10 100644
--- a/winsup/cygwin/shared.cc
+++ b/winsup/cygwin/shared.cc
@@ -14,6 +14,7 @@ details. */
#include <stdlib.h>
#include <grp.h>
#include <pwd.h>
+#include <errno.h>
#include "sync.h"
#include "sigproc.h"
#include "pinfo.h"
@@ -21,15 +22,13 @@ details. */
#include "fhandler.h"
#include "path.h"
#include "dtable.h"
+#include "cygerrno.h"
#include "cygheap.h"
#include "heap.h"
-#include "shared_info.h"
+#include "shared_info_magic.h"
#include "registry.h"
#include "cygwin_version.h"
-#define SHAREDVER (unsigned)(cygwin_version.api_major << 16 | \
- cygwin_version.api_minor)
-
shared_info NO_COPY *cygwin_shared = NULL;
mount_info NO_COPY *mount_table = NULL;
HANDLE cygwin_mount_h;
@@ -53,7 +52,7 @@ shared_name (const char *str, int num)
}
void * __stdcall
-open_shared (const char *name, HANDLE &shared_h, DWORD size, void *addr)
+open_shared (const char *name, int n, HANDLE &shared_h, DWORD size, void *addr)
{
void *shared;
@@ -64,7 +63,7 @@ open_shared (const char *name, HANDLE &shared_h, DWORD size, void *addr)
mapname = NULL;
else
{
- mapname = shared_name (name, 0);
+ mapname = shared_name (name, n);
shared_h = OpenFileMappingA (FILE_MAP_READ | FILE_MAP_WRITE,
TRUE, mapname);
}
@@ -104,13 +103,12 @@ open_shared (const char *name, HANDLE &shared_h, DWORD size, void *addr)
void
shared_info::initialize ()
{
- if (inited)
+ if (version)
{
- if (inited != SHAREDVER)
- api_fatal ("Shared region version mismatch. Version %x != %x.\n"
- "Are you using multiple versions of cygwin1.dll?\n"
- "Run 'cygcheck -r -s -v' to find out.",
- inited, SHAREDVER);
+ if (version != SHARED_VERSION_MAGIC)
+ multiple_cygwin_problem ("shared", version, SHARED_VERSION);
+ else if (cb != SHARED_INFO_CB)
+ multiple_cygwin_problem ("shared size", cb, SHARED_INFO_CB);
return;
}
@@ -119,7 +117,11 @@ shared_info::initialize ()
/* Initialize tty table. */
tty.init ();
- inited = SHAREDVER;
+ version = SHARED_VERSION_MAGIC;
+ cb = sizeof (*this);
+ if (cb != SHARED_INFO_CB)
+ system_printf ("size of shared memory region changed from %u to %u",
+ SHARED_INFO_CB, cb);
}
void __stdcall
@@ -128,6 +130,7 @@ memory_init ()
/* Initialize general shared memory */
HANDLE shared_h = cygheap ? cygheap->shared_h : NULL;
cygwin_shared = (shared_info *) open_shared ("shared",
+ CYGWIN_VERSION_SHARED_DATA,
shared_h,
sizeof (*cygwin_shared),
cygwin_shared_address);
@@ -152,7 +155,8 @@ memory_init ()
ProtectHandle (cygheap->shared_h);
heap_init ();
- mount_table = (mount_info *) open_shared (user_name, cygwin_mount_h,
+ mount_table = (mount_info *) open_shared (user_name, MOUNT_VERSION,
+ cygwin_mount_h,
sizeof (mount_info), 0);
debug_printf ("opening mount table for '%s' at %p", cygheap->user.name (),
mount_table_address);
@@ -162,10 +166,19 @@ memory_init ()
/* Initialize the Cygwin per-user mount table, if necessary */
if (!mount_table->version)
{
- mount_table->version = MOUNT_VERSION;
+ mount_table->version = MOUNT_VERSION_MAGIC;
debug_printf ("initializing mount table");
+ mount_table->cb = sizeof (*mount_table);
+ if (mount_table->cb != MOUNT_INFO_CB)
+ system_printf ("size of mount table region changed from %u to %u",
+ MOUNT_INFO_CB, mount_table->cb);
mount_table->init (); /* Initialize the mount table. */
}
+ else if (mount_table->version != MOUNT_VERSION_MAGIC)
+ multiple_cygwin_problem ("mount", mount_table->version, MOUNT_VERSION);
+ else if (mount_table->cb != MOUNT_INFO_CB)
+ multiple_cygwin_problem ("mount table size", mount_table->cb, MOUNT_INFO_CB);
+
}
void __stdcall
diff --git a/winsup/cygwin/shared_info.h b/winsup/cygwin/shared_info.h
index 088b3f908..16d71eef6 100644
--- a/winsup/cygwin/shared_info.h
+++ b/winsup/cygwin/shared_info.h
@@ -17,7 +17,6 @@ class mount_item
public:
/* FIXME: Nasty static allocation. Need to have a heap in the shared
area [with the user being able to configure at runtime the max size]. */
-
/* Win32-style mounted partition source ("C:\foo\bar").
native_path[0] == 0 for unused entries. */
char native_path[MAX_PATH];
@@ -40,13 +39,21 @@ class mount_item
scheme should be satisfactory for a long while yet. */
#define MAX_MOUNTS 30
-#define MOUNT_VERSION 0x01010103
+#define MOUNT_VERSION 27 // increment when mount table changes and
+#define MOUNT_VERSION_MAGIC CYGWIN_VERSION_MAGIC (MOUNT_MAGIC, MOUNT_VERSION)
+#define CURR_MOUNT_MAGIC 0x41e0
+#define MOUNT_INFO_CB 16488
class reg_key;
+
+/* NOTE: Do not make gratuitous changes to the names or organization of the
+ below class. The layout is checksummed to determine compatibility between
+ different cygwin versions. */
class mount_info
{
public:
DWORD version;
+ unsigned cb;
DWORD sys_mount_table_counter;
int nmounts;
mount_item mount[MAX_MOUNTS];
@@ -97,7 +104,7 @@ class mount_info
void mount_slash ();
void to_registry ();
- int cygdrive_win32_path (const char *src, char *dst, int trailing_slash_p);
+ int cygdrive_win32_path (const char *src, char *dst, int& unit);
void cygdrive_posix_path (const char *src, char *dst, int trailing_slash_p);
void read_cygdrive_info_from_registry ();
};
@@ -128,9 +135,21 @@ public:
/******** Shared Info ********/
/* Data accessible to all tasks */
+#define SHARED_VERSION (unsigned)(cygwin_version.api_major << 8 | \
+ cygwin_version.api_minor)
+#define SHARED_VERSION_MAGIC CYGWIN_VERSION_MAGIC (SHARED_MAGIC, SHARED_VERSION)
+
+#define SHARED_INFO_CB 47112
+
+#define CURR_SHARED_MAGIC 0x88e
+
+/* NOTE: Do not make gratuitous changes to the names or organization of the
+ below class. The layout is checksummed to determine compatibility between
+ different cygwin versions. */
class shared_info
{
- DWORD inited;
+ DWORD version;
+ DWORD cb;
public:
int heap_chunk_in_mb;
DWORD sys_mount_table_counter;
@@ -158,4 +177,4 @@ void __stdcall shared_terminate (void);
#define cygheap_address shared_align_past ((mount_info *) shared_align_past (cygwin_shared))
char *__stdcall shared_name (const char *, int);
-void *__stdcall open_shared (const char *name, HANDLE &shared_h, DWORD size, void *addr);
+void *__stdcall open_shared (const char *name, int n, HANDLE &shared_h, DWORD size, void *addr);
diff --git a/winsup/cygwin/shortcut.c b/winsup/cygwin/shortcut.c
index d0c511da5..55710e86b 100644
--- a/winsup/cygwin/shortcut.c
+++ b/winsup/cygwin/shortcut.c
@@ -11,8 +11,8 @@ Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
#define WIN32_LEAN_AND_MEAN
-#include <shlobj.h>
#include "winsup.h"
+#include <shlobj.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/mount.h>
diff --git a/winsup/cygwin/signal.cc b/winsup/cygwin/signal.cc
index 70671b884..652348302 100644
--- a/winsup/cygwin/signal.cc
+++ b/winsup/cygwin/signal.cc
@@ -56,6 +56,9 @@ signal (int sig, _sig_func_ptr func)
prev = myself->getsig (sig).sa_handler;
myself->getsig (sig).sa_handler = func;
myself->getsig (sig).sa_mask = 0;
+ /* SA_RESTART is set to maintain BSD compatible signal behaviour by default.
+ This is also compatible to the behaviour of signal(2) in Linux. */
+ myself->getsig (sig).sa_flags |= SA_RESTART;
set_sigcatchers (prev, func);
syscall_printf ("%p = signal (%d, %p)", prev, sig, func);
diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc
index 7b55487bb..2e409820a 100644
--- a/winsup/cygwin/sigproc.cc
+++ b/winsup/cygwin/sigproc.cc
@@ -26,7 +26,7 @@ details. */
#include "path.h"
#include "dtable.h"
#include "cygheap.h"
-#include "child_info.h"
+#include "child_info_magic.h"
#define NEED_VFORK
#include "perthread.h"
#include <assert.h>
@@ -179,6 +179,29 @@ wait_for_me ()
}
}
+/* Get the sync_proc_subproc muto to control access to
+ * children, zombie arrays.
+ * Attempt to handle case where process is exiting as we try to grab
+ * the mutex.
+ */
+static BOOL
+get_proc_lock (DWORD what, DWORD val)
+{
+ Static int lastwhat = -1;
+ if (!sync_proc_subproc)
+ return FALSE;
+ if (sync_proc_subproc->acquire (WPSP))
+ {
+ lastwhat = what;
+ return TRUE;
+ }
+ if (!sync_proc_subproc)
+ return FALSE;
+ system_printf ("Couldn't aquire sync_proc_subproc for(%d,%d), %E, last %d",
+ what, val, lastwhat);
+ return TRUE;
+}
+
static BOOL __stdcall
proc_can_be_signalled (_pinfo *p)
{
@@ -612,7 +635,7 @@ sigproc_terminate (void)
// finished with anything it is doing
// sig_dispatch_pending (TRUE); // wake up and die
/* In case of a sigsuspend */
- SetEvent (signal_arrived);
+ // SetEvent (signal_arrived);
/* If !hwait_sig, then the process probably hasn't even finished
* its initialization phase.
@@ -834,11 +857,14 @@ void __stdcall
init_child_info (DWORD chtype, child_info *ch, pid_t pid, HANDLE subproc_ready)
{
memset (ch, 0, sizeof *ch);
- ch->cb = sizeof *ch;
+ ch->cb = chtype == PROC_FORK ? sizeof (child_info_fork) : sizeof (child_info);
+ ch->intro = PROC_MAGIC_GENERIC;
+ ch->magic = CHILD_INFO_MAGIC;
ch->type = chtype;
ch->cygpid = pid;
ch->subproc_ready = subproc_ready;
ch->pppid_handle = myself->ppid_handle;
+ ch->fhandler_union_cb = sizeof (fhandler_union);
}
/* Check the state of all of our children to see if any are stopped or
@@ -899,7 +925,7 @@ getsem (_pinfo *p, const char *str, int init, int max)
set_errno (ESRCH);
return NULL;
}
- int wait = 10000;
+ int wait = 1000;
sigproc_printf ("pid %d, ppid %d, wait %d, initializing %x", p->pid, p->ppid, wait,
ISSTATE (p, PID_INITIALIZING));
for (int i = 0; ISSTATE (p, PID_INITIALIZING) && i < wait; i++)
@@ -939,29 +965,6 @@ getsem (_pinfo *p, const char *str, int init, int max)
return h;
}
-/* Get the sync_proc_subproc muto to control access to
- * children, zombie arrays.
- * Attempt to handle case where process is exiting as we try to grab
- * the mutex.
- */
-static BOOL
-get_proc_lock (DWORD what, DWORD val)
-{
- Static int lastwhat = -1;
- if (!sync_proc_subproc)
- return FALSE;
- if (sync_proc_subproc->acquire (WPSP))
- {
- lastwhat = what;
- return TRUE;
- }
- if (!sync_proc_subproc)
- return FALSE;
- system_printf ("Couldn't aquire sync_proc_subproc for(%d,%d), %E, last %d",
- what, val, lastwhat);
- return TRUE;
-}
-
/* Remove a zombie from zombies by swapping it with the last child in the list.
*/
static void __stdcall
diff --git a/winsup/cygwin/sigproc.h b/winsup/cygwin/sigproc.h
index 0afb02771..dc67b6b08 100644
--- a/winsup/cygwin/sigproc.h
+++ b/winsup/cygwin/sigproc.h
@@ -50,7 +50,7 @@ class sigframe
{
private:
sigthread *st;
- bool unregister ()
+ inline bool unregister ()
{
if (!st)
return 0;
@@ -64,7 +64,7 @@ private:
}
public:
- void set (sigthread &t, DWORD ebp, bool is_exception = 0)
+ inline void set (sigthread &t, DWORD ebp, bool is_exception = 0)
{
DWORD oframe = t.frame;
st = &t;
@@ -73,16 +73,16 @@ public:
if (!oframe)
t.get_winapi_lock ();
}
-
- sigframe (): st (NULL) {}
- sigframe (sigthread &t, DWORD ebp = (DWORD) __builtin_frame_address (0)) {init (t, ebp);}
- void init (sigthread &t, DWORD ebp = (DWORD) __builtin_frame_address (0))
+ inline void init (sigthread &t, DWORD ebp = (DWORD) __builtin_frame_address (0))
{
if (!t.frame && t.id == GetCurrentThreadId ())
set (t, ebp);
else
st = NULL;
}
+
+ sigframe (): st (NULL) {}
+ sigframe (sigthread &t, DWORD ebp = (DWORD) __builtin_frame_address (0)) {init (t, ebp);}
~sigframe ()
{
unregister ();
diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc
index 0a0a84deb..72fb649bf 100644
--- a/winsup/cygwin/spawn.cc
+++ b/winsup/cygwin/spawn.cc
@@ -63,7 +63,7 @@ perhaps_suffix (const char *prog, path_conv &buf)
debug_printf ("prog '%s'", prog);
buf.check (prog, PC_SYM_FOLLOW | PC_FULL, std_suffixes);
- if (buf.isdir ())
+ if (!buf.exists () || buf.isdir ())
ext = NULL;
else if (buf.known_suffix)
ext = (char *) buf + (buf.known_suffix - buf.get_win32 ());
@@ -84,21 +84,34 @@ perhaps_suffix (const char *prog, path_conv &buf)
const char * __stdcall
find_exec (const char *name, path_conv& buf, const char *mywinenv,
- int null_if_notfound, const char **known_suffix)
+ unsigned opt, const char **known_suffix)
{
const char *suffix = "";
debug_printf ("find_exec (%s)", name);
char *retval = buf;
+ char tmp[MAX_PATH];
+ const char *posix = (opt & FE_NATIVE) ? NULL : name;
+ bool has_slash = strchr (name, '/');
/* Check to see if file can be opened as is first.
Win32 systems always check . first, but PATH may not be set up to
do this. */
- if ((suffix = perhaps_suffix (name, buf)) != NULL)
- goto out;
+ if ((has_slash || opt & FE_CWD)
+ && (suffix = perhaps_suffix (name, buf)) != NULL)
+ {
+ if (posix && !has_slash)
+ {
+ tmp[0] = '.';
+ tmp[1] = '/';
+ strcpy (tmp + 2, name);
+ posix = tmp;
+ }
+ goto out;
+ }
win_env *winpath;
const char *path;
- char tmp[MAX_PATH];
+ const char *posix_path;
/* Return the error condition if this is an absolute path or if there
is no PATH to search. */
@@ -111,14 +124,17 @@ find_exec (const char *name, path_conv& buf, const char *mywinenv,
debug_printf ("%s%s", mywinenv, path);
+ posix = (opt & FE_NATIVE) ? NULL : tmp;
+ posix_path = winpath->get_posix () - 1;
/* Iterate over the specified path, looking for the file with and
without executable extensions. */
do
{
+ posix_path++;
char *eotmp = strccpy (tmp, &path, ';');
/* An empty path or '.' means the current directory, but we've
already tried that. */
- if (tmp[0] == '\0' || (tmp[0] == '.' && tmp[1] == '\0'))
+ if (opt & FE_CWD && (tmp[0] == '\0' || (tmp[0] == '.' && tmp[1] == '\0')))
continue;
*eotmp++ = '\\';
@@ -127,19 +143,32 @@ find_exec (const char *name, path_conv& buf, const char *mywinenv,
debug_printf ("trying %s", tmp);
if ((suffix = perhaps_suffix (tmp, buf)) != NULL)
- goto out;
+ {
+ if (posix == tmp)
+ {
+ eotmp = strccpy (tmp, &posix_path, ':');
+ if (eotmp == tmp)
+ *eotmp++ = '.';
+ *eotmp++ = '/';
+ strcpy (eotmp, name);
+ }
+ goto out;
+ }
}
- while (*path && *++path);
+ while (*path && *++path && (posix_path = strchr (posix_path, ':')));
errout:
+ posix = NULL;
/* Couldn't find anything in the given path.
Take the appropriate action based on null_if_not_found. */
- if (null_if_notfound)
+ if (opt & FE_NNF)
retval = NULL;
- else
+ else if (opt & FE_NATIVE)
buf.check (name);
out:
+ if (posix)
+ buf.set_path (posix);
debug_printf ("%s = find_exec (%s)", (char *) buf, name);
if (known_suffix)
*known_suffix = suffix ?: strchr (buf, '\0');
@@ -322,13 +351,13 @@ spawn_guts (HANDLE hToken, const char * prog_arg, const char *const *argv,
si.cbReserved2 = sizeof (ciresrv);
DWORD chtype;
- if (mode != _P_OVERLAY && mode != _P_VFORK)
+ if (mode != _P_OVERLAY)
chtype = PROC_SPAWN;
else
chtype = PROC_EXEC;
HANDLE spr;
- if (mode != _P_OVERLAY)
+ if (chtype != PROC_EXEC)
spr = NULL;
else
{
@@ -336,7 +365,8 @@ spawn_guts (HANDLE hToken, const char * prog_arg, const char *const *argv,
ProtectHandle (spr);
}
- init_child_info (chtype, &ciresrv, (mode == _P_OVERLAY) ? myself->pid : 1, spr);
+ init_child_info (chtype, &ciresrv, (mode == _P_OVERLAY) ? myself->pid : 1,
+ spr);
if (!DuplicateHandle (hMainProc, hMainProc, hMainProc, &ciresrv.parent, 0, 1,
DUPLICATE_SAME_ACCESS))
{
@@ -465,7 +495,9 @@ spawn_guts (HANDLE hToken, const char * prog_arg, const char *const *argv,
if (arg1)
newargv.unshift (arg1);
- find_exec (pgm, real_path, "PATH=", 0, &ext);
+ /* FIXME: This should not be using FE_NATIVE. It should be putting
+ the posix path on the argv list. */
+ find_exec (pgm, real_path, "PATH=", FE_NATIVE, &ext);
newargv.unshift (real_path, 1);
}
@@ -674,7 +706,7 @@ spawn_guts (HANDLE hToken, const char * prog_arg, const char *const *argv,
&pi);
/* Restore impersonation. In case of _P_OVERLAY this isn't
allowed since it would overwrite child data. */
- if (mode != _P_OVERLAY && mode != _P_VFORK
+ if (mode != _P_OVERLAY
&& cygheap->user.impersonated
&& cygheap->user.token != INVALID_HANDLE_VALUE)
ImpersonateLoggedOnUser (cygheap->user.token);
@@ -746,6 +778,13 @@ spawn_guts (HANDLE hToken, const char * prog_arg, const char *const *argv,
child->hProcess = pi.hProcess;
child.remember ();
strcpy (child->progname, real_path);
+ /* FIXME: This introduces an unreferenced, open handle into the child.
+ The purpose is to keep the pid shared memory open so that all of
+ the fields filled out by child.remember do not disappear and so there
+ is not a brief period during which the pid is not available.
+ However, we should try to find another way to do this eventually. */
+ (void) DuplicateHandle (hMainProc, child.shared_handle (), pi.hProcess,
+ NULL, 0, 0, DUPLICATE_SAME_ACCESS);
/* Start the child running */
ResumeThread (pi.hThread);
}
diff --git a/winsup/cygwin/strace.cc b/winsup/cygwin/strace.cc
index 7ffea8501..b7e0a2a32 100644
--- a/winsup/cygwin/strace.cc
+++ b/winsup/cygwin/strace.cc
@@ -229,7 +229,7 @@ strace_printf (unsigned category, const char *func, const char *fmt, ...)
}
}
-static NO_COPY const struct tab
+static NO_COPY struct tab
{
int v;
const char *n;
diff --git a/winsup/cygwin/sync.h b/winsup/cygwin/sync.h
index 9552801b3..a32dadb97 100644
--- a/winsup/cygwin/sync.h
+++ b/winsup/cygwin/sync.h
@@ -22,14 +22,16 @@ class muto
public:
class muto *next;
const char *name;
+
+ muto() {}
+ /* The real constructor. */
+ muto(int inh, const char *name);
+
void *operator new (size_t, void *p) {return p;}
void *operator new (size_t) {return ::new muto; }
void operator delete (void *) {;} /* can't handle allocated mutos
currently */
- muto() {}
- /* The real constructor. */
- muto(int inh, const char *name);
~muto ();
int acquire (DWORD ms = INFINITE) __attribute__ ((regparm(1))); /* Acquire the lock. */
int release (); /* Release the lock. */
@@ -47,7 +49,7 @@ extern muto muto_start;
#define new_muto(__inh, __name) \
({ \
static __attribute__((section(".data_cygwin_nocopy"))) muto __mbuf; \
- (void) new ((char *) &__mbuf) muto (__inh, __name); \
+ (void) new ((void *) &__mbuf) muto (__inh, __name); \
__mbuf.next = muto_start.next; \
muto_start.next = &__mbuf; \
&__mbuf; \
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index f4e53db50..df5e4d202 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -65,19 +65,20 @@ close_all_files (void)
cygwin_shared->delqueue.process_queue ();
}
-static BOOL __stdcall
-check_ttys_fds (void)
+BOOL __stdcall
+check_pty_fds (void)
{
int res = FALSE;
- SetResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "close_all_files");
+ SetResourceLock (LOCK_FD_LIST, WRITE_LOCK, "check_pty_fds");
fhandler_base *fh;
for (int i = 0; i < (int) cygheap->fdtab.size; i++)
- if ((fh = cygheap->fdtab[i]) != NULL && fh->get_device() == FH_TTYS)
+ if ((fh = cygheap->fdtab[i]) != NULL &&
+ (fh->get_device () == FH_TTYS || fh->get_device () == FH_PTYM))
{
res = TRUE;
break;
}
- ReleaseResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "close_all_files");
+ ReleaseResourceLock (LOCK_FD_LIST, WRITE_LOCK, "check_pty_fds");
return res;
}
@@ -85,11 +86,12 @@ int
dup (int fd)
{
int res;
- SetResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "dup");
-
- res = dup2 (fd, cygheap->fdtab.find_unused_handle ());
+ cygheap_fdnew newfd;
- ReleaseResourceLock(LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "dup");
+ if (newfd < 0)
+ res = -1;
+ else
+ res = dup2 (fd, newfd);
return res;
}
@@ -185,7 +187,7 @@ _unlink (const char *ourname)
bool delete_on_close_ok;
delete_on_close_ok = !win32_name.isremote ()
- && wincap.has_delete_on_close ();
+ && wincap.has_delete_on_close ();
/* Attempt to use "delete on close" semantics to handle removing
a file which may be open. */
@@ -270,7 +272,7 @@ setsid (void)
{
if (myself->ctty == TTY_CONSOLE &&
!cygheap->fdtab.has_console_fds () &&
- !check_ttys_fds ())
+ !check_pty_fds ())
FreeConsole ();
myself->ctty = -1;
myself->sid = _getpid ();
@@ -285,8 +287,13 @@ setsid (void)
extern "C" ssize_t
_read (int fd, void *ptr, size_t len)
{
+ if (len == 0)
+ return 0;
+
+ if (__check_null_invalid_struct_errno (ptr, len))
+ return -1;
+
int res;
- fhandler_base *fh;
extern int sigcatchers;
int e = get_errno ();
@@ -294,38 +301,42 @@ _read (int fd, void *ptr, size_t len)
{
sigframe thisframe (mainthread);
- if (cygheap->fdtab.not_open (fd))
- {
- set_errno (EBADF);
- return -1;
- }
+ cygheap_fdget cfd (fd);
+ if (cfd < 0)
+ return -1;
- // set_sig_errno (0);
- fh = cygheap->fdtab[fd];
- DWORD wait = fh->is_nonblocking () ? 0 : INFINITE;
+ DWORD wait = cfd->is_nonblocking () ? 0 : INFINITE;
/* Could block, so let user know we at least got here. */
syscall_printf ("read (%d, %p, %d) %sblocking, sigcatchers %d", fd, ptr, len, wait ? "" : "non", sigcatchers);
- if (wait && (/*!sigcatchers || */!fh->is_slow () || fh->get_r_no_interrupt ()))
+ if (wait && (!cfd->is_slow () || cfd->get_r_no_interrupt ()))
debug_printf ("non-interruptible read\n");
- else if (!fh->ready_for_read (fd, wait, 0))
+ else if (!cfd->ready_for_read (fd, wait))
{
- if (!wait)
- set_sig_errno (EAGAIN); /* Don't really need 'set_sig_errno' here, but... */
- else
- set_sig_errno (EINTR);
res = -1;
goto out;
}
+ /* FIXME: This is not thread safe. We need some method to
+ ensure that an fd, closed in another thread, aborts I/O
+ operations. */
+ if (!cfd.isopen())
+ return -1;
+
/* Check to see if this is a background read from a "tty",
sending a SIGTTIN, if appropriate */
- res = fh->bg_check (SIGTTIN);
+ res = cfd->bg_check (SIGTTIN);
+
+ if (!cfd.isopen())
+ return -1;
+
if (res > bg_eof)
{
myself->process_state |= PID_TTYIN;
- res = fh->read (ptr, len);
+ if (!cfd.isopen())
+ return -1;
+ res = cfd->read (ptr, len);
myself->process_state &= ~PID_TTYIN;
}
@@ -335,8 +346,8 @@ _read (int fd, void *ptr, size_t len)
set_errno (e);
}
- syscall_printf ("%d = read (%d<%s>, %p, %d), bin %d, errno %d", res, fd, fh->get_name (),
- ptr, len, fh->get_r_binary (), get_errno ());
+ syscall_printf ("%d = read (%d, %p, %d), errno %d", res, fd, ptr, len,
+ get_errno ());
MALLOC_CHECK;
return res;
}
@@ -345,29 +356,34 @@ extern "C" ssize_t
_write (int fd, const void *ptr, size_t len)
{
int res = -1;
+
sigframe thisframe (mainthread);
+ cygheap_fdget cfd (fd);
+ if (cfd < 0)
+ goto done;
- if (cygheap->fdtab.not_open (fd))
+ /* No further action required for len == 0 */
+ if (len == 0)
{
- set_errno (EBADF);
+ res = 0;
goto done;
}
+ if (len && __check_invalid_read_ptr_errno (ptr, len))
+ goto done;
+
/* Could block, so let user know we at least got here. */
if (fd == 1 || fd == 2)
paranoid_printf ("write (%d, %p, %d)", fd, ptr, len);
else
syscall_printf ("write (%d, %p, %d)", fd, ptr, len);
- fhandler_base *fh;
- fh = cygheap->fdtab[fd];
-
- res = fh->bg_check (SIGTTOU);
+ res = cfd->bg_check (SIGTTOU);
if (res > bg_eof)
{
myself->process_state |= PID_TTYOU;
- res = fh->write (ptr, len);
+ res = cfd->write (ptr, len);
myself->process_state &= ~PID_TTYOU;
}
@@ -377,8 +393,7 @@ done:
else
syscall_printf ("%d = write (%d, %p, %d)", res, fd, ptr, len);
- MALLOC_CHECK;
- return (ssize_t)res;
+ return (ssize_t) res;
}
/*
@@ -475,41 +490,36 @@ readv (int fd, const struct iovec *iov, int iovcnt)
extern "C" int
_open (const char *unix_path, int flags, ...)
{
- int fd;
int res = -1;
va_list ap;
mode_t mode = 0;
- fhandler_base *fh;
sigframe thisframe (mainthread);
syscall_printf ("open (%s, %p)", unix_path, flags);
if (!check_null_empty_str_errno (unix_path))
{
- SetResourceLock (LOCK_FD_LIST, WRITE_LOCK|READ_LOCK, " open ");
-
/* check for optional mode argument */
va_start (ap, flags);
mode = va_arg (ap, mode_t);
va_end (ap);
- fd = cygheap->fdtab.find_unused_handle ();
+ fhandler_base *fh;
+ cygheap_fdnew fd;
- if (fd < 0)
- set_errno (ENMFILE);
- else
+ if (fd >= 0)
{
path_conv pc;
- if (!(fh = cygheap->fdtab.build_fhandler (fd, unix_path, NULL, pc)))
+ if (!(fh = cygheap->fdtab.build_fhandler_from_name (fd, unix_path,
+ NULL, pc)))
res = -1; // errno already set
- else if (!fh->open (pc, flags, (mode & 07777) & ~cygheap->umask))
+ else if (!fh->open (&pc, flags, (mode & 07777) & ~cygheap->umask))
{
- cygheap->fdtab.release (fd);
+ fd.release ();
res = -1;
}
else if ((res = fd) <= 2)
set_std_handle (res);
}
- ReleaseResourceLock (LOCK_FD_LIST,WRITE_LOCK|READ_LOCK," open");
}
syscall_printf ("%d = open (%s, %p)", res, unix_path, flags);
@@ -527,14 +537,13 @@ _lseek (int fd, off_t pos, int dir)
set_errno (EINVAL);
res = -1;
}
- else if (cygheap->fdtab.not_open (fd))
- {
- set_errno (EBADF);
- res = -1;
- }
else
{
- res = cygheap->fdtab[fd]->lseek (pos, dir);
+ cygheap_fdget cfd (fd);
+ if (cfd >= 0)
+ res = cfd->lseek (pos, dir);
+ else
+ res = -1;
}
syscall_printf ("%d = lseek (%d, %d, %d)", res, fd, pos, dir);
@@ -550,18 +559,14 @@ _close (int fd)
syscall_printf ("close (%d)", fd);
MALLOC_CHECK;
- if (cygheap->fdtab.not_open (fd))
- {
- debug_printf ("handle %d not open", fd);
- set_errno (EBADF);
- res = -1;
- }
+ cygheap_fdget cfd (fd, true);
+ if (cfd < 0)
+ res = -1;
else
{
- SetResourceLock (LOCK_FD_LIST,WRITE_LOCK|READ_LOCK," close");
- res = cygheap->fdtab[fd]->close ();
- cygheap->fdtab.release (fd);
- ReleaseResourceLock (LOCK_FD_LIST,WRITE_LOCK|READ_LOCK," close");
+ cfd->close ();
+ cfd.release ();
+ res = 0;
}
syscall_printf ("%d = close (%d)", res, fd);
@@ -575,13 +580,11 @@ isatty (int fd)
int res;
sigframe thisframe (mainthread);
- if (cygheap->fdtab.not_open (fd))
- {
- syscall_printf ("0 = isatty (%d)", fd);
- return 0;
- }
-
- res = cygheap->fdtab[fd]->is_tty ();
+ cygheap_fdget cfd (fd);
+ if (cfd < 0)
+ res = 0;
+ else
+ res = cfd->is_tty ();
syscall_printf ("%d = isatty (%d)", res, fd);
return res;
}
@@ -788,7 +791,7 @@ chown_worker (const char *name, unsigned fmode, uid_t uid, gid_t gid)
if (win32_path.isdir())
attrib |= S_IFDIR;
res = set_file_attribute (win32_path.has_acls (), win32_path, uid,
- gid, attrib, cygheap->user.logsrv ());
+ gid, attrib, cygheap->user.logsrv ());
}
if (res != 0 && (!win32_path.has_acls () || !allow_ntsec))
{
@@ -822,14 +825,14 @@ extern "C" int
fchown (int fd, uid_t uid, gid_t gid)
{
sigframe thisframe (mainthread);
- if (cygheap->fdtab.not_open (fd))
+ cygheap_fdget cfd (fd);
+ if (cfd < 0)
{
syscall_printf ("-1 = fchown (%d,...)", fd);
- set_errno (EBADF);
return -1;
}
- const char *path = cygheap->fdtab[fd]->get_name ();
+ const char *path = cfd->get_name ();
if (path == NULL)
{
@@ -931,14 +934,14 @@ extern "C" int
fchmod (int fd, mode_t mode)
{
sigframe thisframe (mainthread);
- if (cygheap->fdtab.not_open (fd))
+ cygheap_fdget cfd (fd);
+ if (cfd < 0)
{
syscall_printf ("-1 = fchmod (%d, 0%o)", fd, mode);
- set_errno (EBADF);
return -1;
}
- const char *path = cygheap->fdtab[fd]->get_name ();
+ const char *path = cfd->get_name ();
if (path == NULL)
{
@@ -952,56 +955,23 @@ fchmod (int fd, mode_t mode)
return chmod (path, mode);
}
-/* Cygwin internal */
-static int
-num_entries (const char *win32_name)
-{
- WIN32_FIND_DATA buf;
- HANDLE handle;
- char buf1[MAX_PATH];
- int count = 0;
-
- strcpy (buf1, win32_name);
- int len = strlen (buf1);
- if (len == 0 || isdirsep (buf1[len - 1]))
- strcat (buf1, "*");
- else
- strcat (buf1, "/*"); /* */
-
- handle = FindFirstFileA (buf1, &buf);
-
- if (handle == INVALID_HANDLE_VALUE)
- return 0;
- count ++;
- while (FindNextFileA (handle, &buf))
- {
- if ((buf.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
- count ++;
- }
- FindClose (handle);
- return count;
-}
-
extern "C" int
_fstat (int fd, struct stat *buf)
{
- int r;
+ int res;
sigframe thisframe (mainthread);
- if (cygheap->fdtab.not_open (fd))
- {
- syscall_printf ("-1 = fstat (%d, %p)", fd, buf);
- set_errno (EBADF);
- r = -1;
- }
+ cygheap_fdget cfd (fd);
+ if (cfd < 0)
+ res = -1;
else
{
memset (buf, 0, sizeof (struct stat));
- r = cygheap->fdtab[fd]->fstat (buf);
- syscall_printf ("%d = fstat (%d, %x)", r, fd, buf);
+ res = cfd->fstat (buf, NULL);
}
- return r;
+ syscall_printf ("%d = fstat (%d, %p)", res, fd, buf);
+ return res;
}
/* fsync: P96 6.6.1.1 */
@@ -1009,16 +979,20 @@ extern "C" int
fsync (int fd)
{
sigframe thisframe (mainthread);
- if (cygheap->fdtab.not_open (fd))
+ cygheap_fdget cfd (fd);
+ if (cfd < 0)
{
syscall_printf ("-1 = fsync (%d)", fd);
- set_errno (EBADF);
return -1;
}
+<<<<<<< syscalls.cc
HANDLE h = cygheap->fdtab[fd]->get_handle ();
if (FlushFileBuffers (h) == 0)
+=======
+ if (FlushFileBuffers (cfd->get_handle ()) == 0)
+>>>>>>> 1.176
{
__seterrno ();
return -1;
@@ -1033,32 +1007,6 @@ sync ()
return 0;
}
-int __stdcall
-stat_dev (DWORD devn, int unit, unsigned long ino, struct stat *buf)
-{
- sigframe thisframe (mainthread);
- switch (devn)
- {
- case FH_PIPEW:
- buf->st_mode = STD_WBITS | S_IWGRP | S_IWOTH;
- break;
- case FH_PIPER:
- buf->st_mode = STD_RBITS;
- break;
- default:
- buf->st_mode = STD_RBITS | STD_WBITS | S_IWGRP | S_IWOTH;
- break;
- }
-
- buf->st_mode |= devn == FH_FLOPPY ? S_IFBLK : S_IFCHR;
- buf->st_blksize = S_BLKSIZE;
- buf->st_nlink = 1;
- buf->st_dev = buf->st_rdev = FHDEVN (devn) << 8 | (unit & 0xff);
- buf->st_ino = ino;
- buf->st_atime = buf->st_mtime = buf->st_ctime = time (NULL);
- return 0;
-}
-
suffix_info stat_suffixes[] =
{
suffix_info ("", 1),
@@ -1067,136 +1015,43 @@ suffix_info stat_suffixes[] =
};
/* Cygwin internal */
-static int
-stat_worker (const char *caller, const char *name, struct stat *buf,
- int nofollow)
+int __stdcall
+stat_worker (const char *name, struct stat *buf, int nofollow, path_conv *pc)
{
int res = -1;
- int oret;
- uid_t uid;
- gid_t gid;
path_conv real_path;
fhandler_base *fh = NULL;
- MALLOC_CHECK;
- int open_flags = O_RDONLY | O_BINARY | O_DIROPEN
- | (nofollow ? O_NOSYMLINK : 0);
-
- debug_printf ("%s (%s, %p)", caller, name, buf);
+ if (!pc)
+ pc = &real_path;
+ MALLOC_CHECK;
if (check_null_invalid_struct_errno (buf))
goto done;
- fh = cygheap->fdtab.build_fhandler (-1, name, NULL, real_path,
- (nofollow ? PC_SYM_NOFOLLOW : PC_SYM_FOLLOW)
- | PC_FULL, stat_suffixes);
-
- if (real_path.error)
+ fh = cygheap->fdtab.build_fhandler_from_name (-1, name, NULL, *pc,
+ (nofollow ?
+ PC_SYM_NOFOLLOW
+ : PC_SYM_FOLLOW)
+ | PC_FULL, stat_suffixes);
+ if (pc->error)
{
- set_errno (real_path.error);
- goto done;
+ debug_printf ("got %d error from build_fhandler_from_name", pc->error);
+ set_errno (pc->error);
}
-
- memset (buf, 0, sizeof (struct stat));
-
- if (real_path.is_device ())
- return stat_dev (real_path.get_devn (), real_path.get_unitn (),
- hash_path_name (0, real_path.get_win32 ()), buf);
-
- debug_printf ("%d = file_attributes for '%s'", (DWORD) real_path,
- (char *) real_path);
-
- if ((oret = fh->open (real_path, open_flags, 0)))
- /* ok */;
else
{
- int ntsec_atts = 0;
- /* If we couldn't open the file, try a "query open" with no permissions.
- This will allow us to determine *some* things about the file, at least. */
- fh->set_query_open (TRUE);
- if ((oret = fh->open (real_path, open_flags, 0)))
- /* ok */;
- else if (allow_ntsec && real_path.has_acls () && get_errno () == EACCES
- && !get_file_attribute (TRUE, real_path, &ntsec_atts, &uid, &gid)
- && !ntsec_atts && uid == myself->uid && gid == myself->gid)
- {
- /* Check a special case here. If ntsec is ON it happens
- that a process creates a file using mode 000 to disallow
- other processes access. In contrast to UNIX, this results
- in a failing open call in the same process. Check that
- case. */
- set_file_attribute (TRUE, real_path, 0400);
- oret = fh->open (real_path, open_flags, 0);
- set_file_attribute (TRUE, real_path, ntsec_atts);
- }
- }
- if (oret)
- {
- res = fh->fstat (buf);
- /* The number of links to a directory includes the
- number of subdirectories in the directory, since all
- those subdirectories point to it.
- This is too slow on remote drives, so we do without it and
- set the number of links to 2. */
- /* Unfortunately the count of 2 confuses `find (1)' command. So
- let's try it with `1' as link count. */
- if (real_path.isdir ())
- buf->st_nlink = (real_path.isremote ()
- ? 1 : num_entries (real_path.get_win32 ()));
- fh->close ();
- }
- else if (real_path.exists ())
- {
- /* Unfortunately, the above open may fail if the file exists, though.
- So we have to care for this case here, too. */
- WIN32_FIND_DATA wfd;
- HANDLE handle;
- buf->st_nlink = 1;
- if (real_path.isdir () && real_path.isremote ())
- buf->st_nlink = num_entries (real_path.get_win32 ());
- buf->st_dev = FHDEVN (FH_DISK) << 8;
- buf->st_ino = hash_path_name (0, real_path.get_win32 ());
- if (real_path.isdir ())
- buf->st_mode = S_IFDIR;
- else if (real_path.issymlink ())
- buf->st_mode = S_IFLNK;
- else if (real_path.issocket ())
- buf->st_mode = S_IFSOCK;
- else
- buf->st_mode = S_IFREG;
- if (!real_path.has_acls ()
- || get_file_attribute (TRUE, real_path.get_win32 (),
- &buf->st_mode,
- &buf->st_uid, &buf->st_gid))
- {
- buf->st_mode |= STD_RBITS | STD_XBITS;
- if (!(real_path.has_attribute (FILE_ATTRIBUTE_READONLY)))
- buf->st_mode |= STD_WBITS;
- if (real_path.issymlink ())
- buf->st_mode |= S_IRWXU | S_IRWXG | S_IRWXO;
- get_file_attribute (FALSE, real_path.get_win32 (),
- NULL, &buf->st_uid, &buf->st_gid);
- }
- if ((handle = FindFirstFile (real_path.get_win32 (), &wfd))
- != INVALID_HANDLE_VALUE)
- {
- buf->st_atime = to_time_t (&wfd.ftLastAccessTime);
- buf->st_mtime = to_time_t (&wfd.ftLastWriteTime);
- buf->st_ctime = to_time_t (&wfd.ftCreationTime);
- buf->st_size = wfd.nFileSizeLow;
- buf->st_blksize = S_BLKSIZE;
- buf->st_blocks = ((unsigned long) buf->st_size +
- S_BLKSIZE-1) / S_BLKSIZE;
- FindClose (handle);
- }
- res = 0;
+ debug_printf ("(%s, %p, %d, %p), file_attributes %d", name, buf, nofollow,
+ pc, (DWORD) real_path);
+ memset (buf, 0, sizeof (struct stat));
+ res = fh->fstat (buf, pc);
}
done:
if (fh)
delete fh;
MALLOC_CHECK;
- syscall_printf ("%d = %s (%s, %p)", res, caller, name, buf);
+ syscall_printf ("%d = (%s, %p)", res, name, buf);
return res;
}
@@ -1204,7 +1059,8 @@ extern "C" int
_stat (const char *name, struct stat *buf)
{
sigframe thisframe (mainthread);
- return stat_worker ("stat", name, buf, 0);
+ syscall_printf ("entering");
+ return stat_worker (name, buf, 0);
}
/* lstat: Provided by SVR4 and 4.3+BSD, POSIX? */
@@ -1212,7 +1068,8 @@ extern "C" int
lstat (const char *name, struct stat *buf)
{
sigframe thisframe (mainthread);
- return stat_worker ("lstat", name, buf, 1);
+ syscall_printf ("entering");
+ return stat_worker (name, buf, 1);
}
extern int acl_access (const char *, int);
@@ -1222,7 +1079,7 @@ access (const char *fn, int flags)
{
sigframe thisframe (mainthread);
// flags were incorrectly specified
- if (flags & ~ (F_OK|R_OK|W_OK|X_OK))
+ if (flags & ~(F_OK|R_OK|W_OK|X_OK))
{
set_errno (EINVAL);
return -1;
@@ -1232,7 +1089,7 @@ access (const char *fn, int flags)
return acl_access (fn, flags);
struct stat st;
- int r = stat (fn, &st);
+ int r = stat_worker (fn, &st, 0);
if (r)
return -1;
r = -1;
@@ -1396,7 +1253,16 @@ done:
else
{
/* make the new file have the permissions of the old one */
- SetFileAttributes (real_new, real_old);
+ DWORD attr = real_old;
+#ifdef HIDDEN_DOT_FILES
+ char *c = strrchr (real_old.get_win32 (), '\\');
+ if ((c && c[1] == '.') || *real_old.get_win32 () == '.')
+ attr &= ~FILE_ATTRIBUTE_HIDDEN;
+ c = strrchr (real_new.get_win32 (), '\\');
+ if ((c && c[1] == '.') || *real_new.get_win32 () == '.')
+ attr |= FILE_ATTRIBUTE_HIDDEN;
+#endif
+ SetFileAttributes (real_new, attr);
/* Shortcut hack, No. 2, part 2 */
/* if the new filename was an existing shortcut, remove it now if the
@@ -1417,6 +1283,9 @@ done:
extern "C" int
system (const char *cmdstring)
{
+ if (check_null_empty_str_errno (cmdstring))
+ return -1;
+
sigframe thisframe (mainthread);
int res;
const char* command[4];
@@ -1511,11 +1380,9 @@ check_posix_perm (const char *fname, int v)
extern "C" long int
fpathconf (int fd, int v)
{
- if (cygheap->fdtab.not_open (fd))
- {
- set_errno (EBADF);
- return -1;
- }
+ cygheap_fdget cfd (fd);
+ if (cfd < 0)
+ return -1;
switch (v)
{
case _PC_LINK_MAX:
@@ -1538,7 +1405,7 @@ fpathconf (int fd, int v)
case _PC_NO_TRUNC:
return -1;
case _PC_VDISABLE:
- if (isatty (fd))
+ if (cfd->is_tty ())
return -1;
else
{
@@ -1547,13 +1414,10 @@ fpathconf (int fd, int v)
}
case _PC_POSIX_PERMISSIONS:
case _PC_POSIX_SECURITY:
- {
- fhandler_base *fh = cygheap->fdtab[fd];
- if (fh->get_device () == FH_DISK)
- return check_posix_perm (fh->get_win32_name (), v);
- set_errno (EINVAL);
- return -1;
- }
+ if (cfd->get_device () == FH_DISK)
+ return check_posix_perm (cfd->get_win32_name (), v);
+ set_errno (EINVAL);
+ return -1;
default:
set_errno (EINVAL);
return -1;
@@ -1606,11 +1470,12 @@ pathconf (const char *file, int v)
extern "C" char *
ttyname (int fd)
{
- if (cygheap->fdtab.not_open (fd) || !cygheap->fdtab[fd]->is_tty ())
+ cygheap_fdget cfd (fd);
+ if (cfd < 0 || !cfd->is_tty ())
{
return 0;
}
- return (char *) (cygheap->fdtab[fd]->ttyname ());
+ return (char *) (cfd->ttyname ());
}
extern "C" char *
@@ -1637,21 +1502,20 @@ _cygwin_istext_for_stdio (int fd)
return 0; /* we do it for old apps, due to getc/putc macros */
}
- if (cygheap->fdtab.not_open (fd))
+ cygheap_fdget cfd (fd, false, false);
+ if (cfd < 0)
{
syscall_printf (" _cifs: fd not open\n");
return 0;
}
- fhandler_base *p = cygheap->fdtab[fd];
-
- if (p->get_device () != FH_DISK)
+ if (cfd->get_device () != FH_DISK)
{
syscall_printf (" _cifs: fd not disk file\n");
return 0;
}
- if (p->get_w_binary () || p->get_r_binary ())
+ if (cfd->get_w_binary () || cfd->get_r_binary ())
{
syscall_printf (" _cifs: get_*_binary\n");
return 0;
@@ -1685,13 +1549,11 @@ setmode_helper (FILE *f)
extern "C" int
getmode (int fd)
{
- if (cygheap->fdtab.not_open (fd))
- {
- set_errno (EBADF);
- return -1;
- }
+ cygheap_fdget cfd (fd);
+ if (cfd < 0)
+ return -1;
- return cygheap->fdtab[fd]->get_flags () & (O_BINARY | O_TEXT);
+ return cfd->get_flags () & (O_BINARY | O_TEXT);
}
/* Set a file descriptor into text or binary mode, returning the
@@ -1700,43 +1562,39 @@ getmode (int fd)
extern "C" int
setmode (int fd, int mode)
{
- if (cygheap->fdtab.not_open (fd))
- {
- set_errno (EBADF);
- return -1;
- }
+ cygheap_fdget cfd (fd);
+ if (cfd < 0)
+ return -1;
if (mode != O_BINARY && mode != O_TEXT && mode != 0)
{
set_errno (EINVAL);
return -1;
}
- fhandler_base *p = cygheap->fdtab[fd];
-
/* Note that we have no way to indicate the case that writes are
binary but not reads, or vice-versa. These cases can arise when
using the tty or console interface. People using those
interfaces should not use setmode. */
int res;
- if (p->get_w_binary () && p->get_r_binary ())
+ if (cfd->get_w_binary () && cfd->get_r_binary ())
res = O_BINARY;
- else if (p->get_w_binset () && p->get_r_binset ())
+ else if (cfd->get_w_binset () && cfd->get_r_binset ())
res = O_TEXT; /* Specifically set O_TEXT */
else
res = 0;
if (!mode)
- p->reset_to_open_binmode ();
+ cfd->reset_to_open_binmode ();
else if (mode & O_BINARY)
{
- p->set_w_binary (1);
- p->set_r_binary (1);
+ cfd->set_w_binary (1);
+ cfd->set_r_binary (1);
}
else
{
- p->set_w_binary (0);
- p->set_r_binary (0);
+ cfd->set_w_binary (0);
+ cfd->set_r_binary (0);
}
if (_cygwin_istext_for_stdio (fd))
@@ -1746,7 +1604,7 @@ setmode (int fd, int mode)
setmode_file = fd;
_fwalk (_REENT, setmode_helper);
- syscall_printf ("setmode (%d<%s>, %s) returns %s\n", fd, p->get_name (),
+ syscall_printf ("setmode (%d<%s>, %s) returns %s\n", fd, cfd->get_name (),
mode & O_TEXT ? "text" : "binary",
res & O_TEXT ? "text" : "binary");
return res;
@@ -1760,37 +1618,32 @@ ftruncate (int fd, off_t length)
int res = -1;
if (length < 0)
- {
- set_errno (EINVAL);
- }
- else if (cygheap->fdtab.not_open (fd))
- {
- set_errno (EBADF);
- }
+ set_errno (EINVAL);
else
{
- HANDLE h = cygheap->fdtab[fd]->get_handle ();
- off_t prev_loc;
-
- if (h)
+ cygheap_fdget cfd (fd);
+ if (cfd >= 0)
{
- /* remember curr file pointer location */
- prev_loc = cygheap->fdtab[fd]->lseek (0, SEEK_CUR);
+ HANDLE h = cygheap->fdtab[fd]->get_handle ();
- cygheap->fdtab[fd]->lseek (length, SEEK_SET);
- if (!SetEndOfFile (h))
+ if (cfd->get_handle ())
{
- __seterrno ();
- }
- else
- res = 0;
+ /* remember curr file pointer location */
+ off_t prev_loc = cfd->lseek (0, SEEK_CUR);
+
+ cfd->lseek (length, SEEK_SET);
+ if (!SetEndOfFile (h))
+ __seterrno ();
+ else
+ res = 0;
- /* restore original file pointer location */
- cygheap->fdtab[fd]->lseek (prev_loc, 0);
+ /* restore original file pointer location */
+ cfd->lseek (prev_loc, 0);
+ }
}
}
- syscall_printf ("%d = ftruncate (%d, %d)", res, fd, length);
+ syscall_printf ("%d = ftruncate (%d, %d)", res, fd, length);
return res;
}
@@ -1819,12 +1672,13 @@ truncate (const char *pathname, off_t length)
extern "C" long
get_osfhandle (int fd)
{
- long res = -1;
+ long res;
- if (cygheap->fdtab.not_open (fd))
- set_errno (EBADF);
+ cygheap_fdget cfd (fd);
+ if (cfd >= 0)
+ res = (long) cfd->get_handle ();
else
- res = (long) cygheap->fdtab[fd]->get_handle ();
+ res = -1;
syscall_printf ("%d = get_osfhandle (%d)", res, fd);
return res;
@@ -1875,13 +1729,10 @@ extern "C" int
fstatfs (int fd, struct statfs *sfs)
{
sigframe thisframe (mainthread);
- if (cygheap->fdtab.not_open (fd))
- {
- set_errno (EBADF);
- return -1;
- }
- fhandler_disk_file *f = (fhandler_disk_file *) cygheap->fdtab[fd];
- return statfs (f->get_name (), sfs);
+ cygheap_fdget cfd (fd);
+ if (cfd < 0)
+ return -1;
+ return statfs (cfd->get_name (), sfs);
}
/* setpgid: POSIX 4.3.3.1 */
@@ -1961,12 +1812,10 @@ extern "C" char *
ptsname (int fd)
{
sigframe thisframe (mainthread);
- if (cygheap->fdtab.not_open (fd))
- {
- set_errno (EBADF);
- return 0;
- }
- return (char *) (cygheap->fdtab[fd]->ptsname ());
+ cygheap_fdget cfd (fd);
+ if (cfd < 0)
+ return 0;
+ return (char *) (cfd->ptsname ());
}
/* FIXME: what is this? */
@@ -2214,6 +2063,11 @@ seteuid (uid_t uid)
retrieving user's SID. */
user.token = cygheap->user.impersonated ? cygheap->user.token
: INVALID_HANDLE_VALUE;
+ /* Unsetting these both env vars is necessary to get NetUserGetInfo()
+ called in internal_getlogin (). Otherwise the wrong path is used
+ after a user switch, probably. */
+ unsetenv ("HOMEDRIVE");
+ unsetenv ("HOMEPATH");
struct passwd *pw_cur = internal_getlogin (user);
if (pw_cur != pw_new)
{
@@ -2559,3 +2413,101 @@ logout (char *line)
return res;
}
+
+static int utmp_fd = -2;
+static char *utmp_file = (char *) _PATH_UTMP;
+
+static struct utmp utmp_data;
+
+extern "C" void
+setutent ()
+{
+ sigframe thisframe (mainthread);
+ if (utmp_fd == -2)
+ {
+ utmp_fd = _open (utmp_file, O_RDONLY);
+ }
+ _lseek (utmp_fd, 0, SEEK_SET);
+}
+
+extern "C" void
+endutent ()
+{
+ sigframe thisframe (mainthread);
+ _close (utmp_fd);
+ utmp_fd = -2;
+}
+
+extern "C" void
+utmpname (_CONST char *file)
+{
+ sigframe thisframe (mainthread);
+ if (check_null_empty_str (file))
+ {
+ debug_printf ("Invalid file");
+ return;
+ }
+ utmp_file = strdup (file);
+ debug_printf ("New UTMP file: %s", utmp_file);
+}
+
+extern "C" struct utmp *
+getutent ()
+{
+ sigframe thisframe (mainthread);
+ if (utmp_fd == -2)
+ setutent ();
+ if (_read (utmp_fd, &utmp_data, sizeof (utmp_data)) != sizeof (utmp_data))
+ return NULL;
+ return &utmp_data;
+}
+
+extern "C" struct utmp *
+getutid (struct utmp *id)
+{
+ sigframe thisframe (mainthread);
+ if (check_null_invalid_struct_errno (id))
+ return NULL;
+ while (_read (utmp_fd, &utmp_data, sizeof (utmp_data)) == sizeof (utmp_data))
+ {
+ switch (id->ut_type)
+ {
+#if 0 /* Not available in Cygwin. */
+ case RUN_LVL:
+ case BOOT_TIME:
+ case OLD_TIME:
+ case NEW_TIME:
+ if (id->ut_type == utmp_data.ut_type)
+ return &utmp_data;
+ break;
+#endif
+ case INIT_PROCESS:
+ case LOGIN_PROCESS:
+ case USER_PROCESS:
+ case DEAD_PROCESS:
+ if (id->ut_id == utmp_data.ut_id)
+ return &utmp_data;
+ break;
+ default:
+ return NULL;
+ }
+ }
+ return NULL;
+}
+
+extern "C" struct utmp *
+getutline (struct utmp *line)
+{
+ sigframe thisframe (mainthread);
+ if (check_null_invalid_struct_errno (line))
+ 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;
+}
diff --git a/winsup/cygwin/sysconf.cc b/winsup/cygwin/sysconf.cc
index 5e1d91ba6..efc3e5dc1 100644
--- a/winsup/cygwin/sysconf.cc
+++ b/winsup/cygwin/sysconf.cc
@@ -18,8 +18,8 @@ details. */
#include "fhandler.h"
#include "path.h"
#include "dtable.h"
-#include "cygheap.h"
#include "cygerrno.h"
+#include "cygheap.h"
#include "ntdll.h"
/* sysconf: POSIX 4.8.1.1 */
@@ -89,7 +89,7 @@ sysconf (int in)
return sbi.HighestPhysicalPage - sbi.LowestPhysicalPage + 1;
}
}
- break;
+ break;
}
/* Invalid input or unimplemented sysconf name */
diff --git a/winsup/cygwin/syslog.cc b/winsup/cygwin/syslog.cc
index 66e9ed1cc..11ae4b46c 100644
--- a/winsup/cygwin/syslog.cc
+++ b/winsup/cygwin/syslog.cc
@@ -14,6 +14,7 @@ details. */
#include <syslog.h>
#include <stdarg.h>
#include <unistd.h>
+#include <errno.h>
#include "security.h"
#include "fhandler.h"
#include "path.h"
@@ -257,13 +258,18 @@ syslog (int priority, const char *message, ...)
WORD eventType;
switch (LOG_PRI (priority))
{
+ case LOG_EMERG:
+ case LOG_ALERT:
+ case LOG_CRIT:
case LOG_ERR:
eventType = EVENTLOG_ERROR_TYPE;
break;
case LOG_WARNING:
eventType = EVENTLOG_WARNING_TYPE;
break;
+ case LOG_NOTICE:
case LOG_INFO:
+ case LOG_DEBUG:
eventType = EVENTLOG_INFORMATION_TYPE;
break;
default:
@@ -307,14 +313,29 @@ syslog (int priority, const char *message, ...)
eventlog capability. */
switch (LOG_PRI (priority))
{
+ case LOG_EMERG:
+ pass.print ("%s : ", "LOG_EMERG");
+ break;
+ case LOG_ALERT:
+ pass.print ("%s : ", "LOG_ALERT");
+ break;
+ case LOG_CRIT:
+ pass.print ("%s : ", "LOG_CRIT");
+ break;
case LOG_ERR:
pass.print ("%s : ", "LOG_ERR");
break;
case LOG_WARNING:
pass.print ("%s : ", "LOG_WARNING");
break;
+ case LOG_NOTICE:
+ pass.print ("%s : ", "LOG_NOTICE");
+ break;
case LOG_INFO:
pass.print ("%s : ", "LOG_INFO");
+ break;
+ case LOG_DEBUG:
+ pass.print ("%s : ", "LOG_DEBUG");
break;
default:
pass.print ("%s : ", "LOG_ERR");
diff --git a/winsup/cygwin/termios.cc b/winsup/cygwin/termios.cc
index 5488185c4..499072f51 100644
--- a/winsup/cygwin/termios.cc
+++ b/winsup/cygwin/termios.cc
@@ -14,6 +14,7 @@ details. */
#include "winsup.h"
#include <errno.h>
#include <signal.h>
+#include <stdlib.h>
#include "cygerrno.h"
#include "security.h"
#include "fhandler.h"
@@ -30,22 +31,14 @@ tcsendbreak (int fd, int duration)
{
int res = -1;
- if (cygheap->fdtab.not_open (fd))
- {
- set_errno (EBADF);
- goto out;
- }
+ cygheap_fdget cfd (fd);
+ if (cfd < 0)
+ goto out;
- fhandler_base *fh;
- fh = cygheap->fdtab[fd];
-
- if (!fh->is_tty ())
+ if (!cfd->is_tty ())
set_errno (ENOTTY);
- else
- {
- if ((res = fh->bg_check (-SIGTTOU)) > bg_eof)
- res = fh->tcsendbreak (duration);
- }
+ else if ((res = cfd->bg_check (-SIGTTOU)) > bg_eof)
+ res = cfd->tcsendbreak (duration);
out:
syscall_printf ("%d = tcsendbreak (%d, %d)", res, fd, duration);
@@ -60,22 +53,14 @@ tcdrain (int fd)
termios_printf ("tcdrain");
- if (cygheap->fdtab.not_open (fd))
- {
- set_errno (EBADF);
- goto out;
- }
-
- fhandler_base *fh;
- fh = cygheap->fdtab[fd];
+ cygheap_fdget cfd (fd);
+ if (cfd < 0)
+ goto out;
- if (!fh->is_tty ())
+ if (!cfd->is_tty ())
set_errno (ENOTTY);
- else
- {
- if ((res = fh->bg_check (-SIGTTOU)) > bg_eof)
- res = fh->tcdrain ();
- }
+ else if ((res = cfd->bg_check (-SIGTTOU)) > bg_eof)
+ res = cfd->tcdrain ();
out:
syscall_printf ("%d = tcdrain (%d)", res, fd);
@@ -88,22 +73,14 @@ tcflush (int fd, int queue)
{
int res = -1;
- if (cygheap->fdtab.not_open (fd))
- {
- set_errno (EBADF);
- goto out;
- }
-
- fhandler_base *fh;
- fh = cygheap->fdtab[fd];
+ cygheap_fdget cfd (fd);
+ if (cfd < 0)
+ goto out;
- if (!fh->is_tty ())
+ if (!cfd->is_tty ())
set_errno (ENOTTY);
- else
- {
- if ((res = fh->bg_check (-SIGTTOU)) > bg_eof)
- res = fh->tcflush (queue);
- }
+ else if ((res = cfd->bg_check (-SIGTTOU)) > bg_eof)
+ res = cfd->tcflush (queue);
out:
termios_printf ("%d = tcflush (%d, %d)", res, fd, queue);
@@ -116,22 +93,14 @@ tcflow (int fd, int action)
{
int res = -1;
- if (cygheap->fdtab.not_open (fd))
- {
- set_errno (EBADF);
- goto out;
- }
+ cygheap_fdget cfd (fd);
+ if (cfd < 0)
+ goto out;
- fhandler_base *fh;
- fh = cygheap->fdtab[fd];
-
- if (!fh->is_tty ())
+ if (!cfd->is_tty ())
set_errno (ENOTTY);
- else
- {
- if ((res = fh->bg_check (-SIGTTOU)) > bg_eof)
- res = fh->tcflow (action);
- }
+ else if ((res = cfd->bg_check (-SIGTTOU)) > bg_eof)
+ res = cfd->tcflow (action);
out:
syscall_printf ("%d = tcflow (%d, %d)", res, fd, action);
@@ -144,24 +113,16 @@ tcsetattr (int fd, int a, const struct termios *t)
{
int res = -1;
- if (cygheap->fdtab.not_open (fd))
- {
- set_errno (EBADF);
- goto out;
- }
+ cygheap_fdget cfd (fd);
+ if (cfd < 0)
+ goto out;
t = __tonew_termios (t);
- fhandler_base *fh;
- fh = cygheap->fdtab[fd];
-
- if (!fh->is_tty ())
+ if (!cfd->is_tty ())
set_errno (ENOTTY);
- else
- {
- if ((res = fh->bg_check (-SIGTTOU)) > bg_eof)
- res = fh->tcsetattr (a, t);
- }
+ else if ((res = cfd->bg_check (-SIGTTOU)) > bg_eof)
+ res = cfd->tcsetattr (a, t);
out:
termios_printf ("iflag %x, oflag %x, cflag %x, lflag %x, VMIN %d, VTIME %d",
@@ -178,15 +139,13 @@ tcgetattr (int fd, struct termios *in_t)
int res = -1;
struct termios *t = __makenew_termios (in_t);
- if (cygheap->fdtab.not_open (fd))
- set_errno (EBADF);
- else if (!cygheap->fdtab[fd]->is_tty ())
+ cygheap_fdget cfd (fd);
+ if (cfd < 0)
+ /* saw an error */;
+ else if (!cfd->is_tty ())
set_errno (ENOTTY);
- else
- {
- if ((res = cygheap->fdtab[fd]->tcgetattr (t)) == 0)
- (void) __toapp_termios (in_t, t);
- }
+ else if ((res = cfd->tcgetattr (t)) == 0)
+ (void) __toapp_termios (in_t, t);
if (res)
termios_printf ("%d = tcgetattr (%d, %p)", res, fd, in_t);
@@ -204,12 +163,13 @@ tcgetpgrp (int fd)
{
int res = -1;
- if (cygheap->fdtab.not_open (fd))
- set_errno (EBADF);
- else if (!cygheap->fdtab[fd]->is_tty ())
+ cygheap_fdget cfd (fd);
+ if (cfd < 0)
+ /* saw an error */;
+ else if (!cfd->is_tty ())
set_errno (ENOTTY);
else
- res = cygheap->fdtab[fd]->tcgetpgrp ();
+ res = cfd->tcgetpgrp ();
termios_printf ("%d = tcgetpgrp (%d)", res, fd);
return res;
@@ -221,12 +181,13 @@ tcsetpgrp (int fd, pid_t pgid)
{
int res = -1;
- if (cygheap->fdtab.not_open (fd))
- set_errno (EBADF);
- else if (!cygheap->fdtab[fd]->is_tty ())
+ cygheap_fdget cfd (fd);
+ if (cfd < 0)
+ /* saw an error */;
+ else if (!cfd->is_tty ())
set_errno (ENOTTY);
else
- res = cygheap->fdtab[fd]->tcsetpgrp (pgid);
+ res = cfd->tcsetpgrp (pgid);
termios_printf ("%d = tcsetpgrp (%d, %x)", res, fd, pgid);
return res;
diff --git a/winsup/cygwin/test.c b/winsup/cygwin/test.c
deleted file mode 100644
index a7c61665a..000000000
--- a/winsup/cygwin/test.c
+++ /dev/null
@@ -1,165 +0,0 @@
-/* test.c: misc Cygwin testing code
-
- Copyright 1996, 1998, 1999, 2000, 2001 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. */
-
-#include <stdio.h>
-#include <windows.h>
-
-char a[] ="This is static data";
-
-void
-test1()
-{
- int depth = 0;
- while (depth < 5)
- {
- int r;
- printf ("about to fork %d\n", depth);
-
- r = fork ();
-
- if (r == 0)
- {
- int res;
- depth++;
- printf ("************Depth is %d\n", depth);
- sleep (1);
- }
- else
- {
- printf ("This is the parent, quitting %d\n", depth);
- sleep (1);
- exit (1);
- }
- printf ("done loop, depth %d\n", depth);
- }
-}
-
-#define N 10
-int v[N];
-startup ()
-{
- int i;
- for (i = 0; i < N; i++)
- {
- int r;
- fflush (stdout);
- r = fork ();
- if (r)
- {
- v[i] = r;
- printf ("started %d, were'id %d\n", v[i], GetCurrentProcessId ());
- fflush (stdout);
- }
- else
- {
- /* running the child, sleep a bit and exit. */
- printf ("the fork said 0, were %d\n", GetCurrentProcessId ());
- fflush (stdout);
- sleep (2);
- printf ("Running, and exiting %d\n", i);
- fflush (stdout);
- _exit (i + 0x30);
- }
- }
-}
-
-test2()
-{
- int i;
- startup ();
- sleep (1);
- /* Wait for them one by one */
- for (i = 0; i < N; i++)
- {
- int res;
-
- waitpid (v[i], &res, 0);
- printf ("Process %d gave res %x\n", v[i], res);
- if (res != (0x30 + i) << 8)
- printf ("***** BAD *** Process %d gave res %x\n", v[i], res);
- }
-}
-
-test3()
-{
- int i;
- startup ();
- /* Wait for them all at the same time */
- for (i = 0; i < N; i++)
- {
- int res;
- wait (&res);
- printf ("Got res %x\n", res);
- }
-}
-
-test5()
-{
- char *c = strdup ("HI STEVE");
- printf ("c is %s\n", c);
- free (c);
-}
-
-int count;
-
-main (int ac, char **av)
-{
- int r;
- int done;
- int test;
- fprintf (stderr,"TO STDERR\n");
- if (ac < 2) {
- printf ("usage: test <n>\n");
- exit (2);
- }
- test = atoi (av[1]);
-
- printf ("%d %d Hi steve, about to start fork test %d %d.\n",getpid (), count++, test,
- GetCurrentProcessId ());
-fflush (stdout);
- switch (test)
- {
- case 1:
- test1();
- break;
- case 2:
- test2();
- break;
- case 3:
- test3();
- break;
- case 4:
-SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE), FOREGROUND_RED);
-break;
- case 5:
- test5();
-break;
- }
-
-}
-
-free ()
-{
- printf ("MY FREE!\n");
-}
-
-char b[100000];
-int i;
-
-malloc (x)
-{
-char *r = b + i;
-i += x;
-return r;
-}
-
-realloc ()
-{
-}
diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc
index 8b6f1b6d6..ced5f6f80 100644
--- a/winsup/cygwin/thread.cc
+++ b/winsup/cygwin/thread.cc
@@ -1,9 +1,9 @@
-/*thread.cc: Locking and threading module functions
+/* thread.cc: Locking and threading module functions
Copyright 1998, 1999, 2000, 2001 Red Hat, Inc.
Originally written by Marco Fuykschot <marco@ddi.nl>
- Substantialy enhanced by Robert Collins <<rbtcollins@hotmail.com>
+ Substantialy enhanced by Robert Collins <rbtcollins@hotmail.com>
This file is part of Cygwin.
@@ -289,7 +289,7 @@ MTinterface::Init (int forked)
thread_self_dwTlsIndex = TlsAlloc ();
if (thread_self_dwTlsIndex == TLS_OUT_OF_INDEXES)
system_printf
- ("local storage for thread couldn't be set\nThis means that we are not thread safe!\n");
+ ("local storage for thread couldn't be set\nThis means that we are not thread safe!");
}
concurrency = 0;
@@ -323,21 +323,21 @@ void
MTinterface::fixup_after_fork (void)
{
pthread_mutex *mutex = mutexs;
- debug_printf("mutexs is %x\n",mutexs);
+ debug_printf ("mutexs is %x",mutexs);
while (mutex)
{
mutex->fixup_after_fork ();
mutex = mutex->next;
}
pthread_cond *cond = conds;
- debug_printf("conds is %x\n",conds);
+ debug_printf ("conds is %x",conds);
while (cond)
{
cond->fixup_after_fork ();
cond = cond->next;
}
semaphore *sem = semaphores;
- debug_printf("semaphores is %x\n",semaphores);
+ debug_printf ("semaphores is %x",semaphores);
while (sem)
{
sem->fixup_after_fork ();
@@ -375,7 +375,7 @@ pthread::create (void *(*func) (void *), pthread_attr *newattr,
function = func;
arg = threadarg;
- win32_obj_id =::CreateThread (&sec_none_nih, attr.stacksize,
+ win32_obj_id = ::CreateThread (&sec_none_nih, attr.stacksize,
(LPTHREAD_START_ROUTINE) thread_init_wrapper,
this, CREATE_SUSPENDED, &thread_id);
@@ -420,14 +420,14 @@ pthread_cond::pthread_cond (pthread_condattr *attr):verifyable_object (PTHREAD_C
this->mutex = NULL;
this->waiting = 0;
- this->win32_obj_id =::CreateEvent (&sec_none_nih, false, /*auto signal reset - which I think is pthreads like ? */
+ this->win32_obj_id = ::CreateEvent (&sec_none_nih, false, /*auto signal reset - which I think is pthreads like ? */
false, /*start non signaled */
NULL /*no name */);
/*TODO: make a shared mem mutex if out attributes request shared mem cond */
- cond_access=NULL;
+ cond_access = NULL;
if ((temperr = pthread_mutex_init (&this->cond_access, NULL)))
{
- system_printf ("couldn't init mutex, this %0p errno=%d\n", this, temperr);
+ system_printf ("couldn't init mutex, this %p errno %d", this, temperr);
/*we need the mutex for correct behaviour */
magic = 0;
}
@@ -435,7 +435,7 @@ pthread_cond::pthread_cond (pthread_condattr *attr):verifyable_object (PTHREAD_C
if (!this->win32_obj_id)
magic = 0;
/* threadsafe addition is easy */
- next = (pthread_cond *)InterlockedExchangePointer (&MT_INTERFACE->conds, this);
+ next = (pthread_cond *) InterlockedExchangePointer (&MT_INTERFACE->conds, this);
}
pthread_cond::~pthread_cond ()
@@ -461,33 +461,33 @@ pthread_cond::BroadCast ()
{
/* TODO: implement the same race fix as Signal has */
if (pthread_mutex_lock (&cond_access))
- system_printf ("Failed to lock condition variable access mutex, this %0p\n", this);
+ system_printf ("Failed to lock condition variable access mutex, this %p", this);
int count = waiting;
if (verifyable_object_isvalid (&mutex, PTHREAD_MUTEX_MAGIC) != VALID_OBJECT)
{
if (pthread_mutex_unlock (&cond_access))
- system_printf ("Failed to unlock condition variable access mutex, this %0p\n", this);
+ system_printf ("Failed to unlock condition variable access mutex, this %p", this);
/*This isn't and API error - users are allowed to call this when no threads
are waiting
- system_printf ("Broadcast called with invalid mutex\n");
+ system_printf ("Broadcast called with invalid mutex");
*/
return;
}
while (count--)
PulseEvent (win32_obj_id);
if (pthread_mutex_unlock (&cond_access))
- system_printf ("Failed to unlock condition variable access mutex, this %0p\n", this);
+ system_printf ("Failed to unlock condition variable access mutex, this %p", this);
}
void
pthread_cond::Signal ()
{
if (pthread_mutex_lock (&cond_access))
- system_printf ("Failed to lock condition variable access mutex, this %0p\n", this);
+ system_printf ("Failed to lock condition variable access mutex, this %p", this);
if (verifyable_object_isvalid (&mutex, PTHREAD_MUTEX_MAGIC) != VALID_OBJECT)
{
if (pthread_mutex_unlock (&cond_access))
- system_printf ("Failed to unlock condition variable access mutex, this %0p\n",
+ system_printf ("Failed to unlock condition variable access mutex, this %p",
this);
return;
}
@@ -496,29 +496,42 @@ pthread_cond::Signal ()
/* nothing to signal */
{
if (pthread_mutex_unlock (&cond_access))
- system_printf ("Failed to unlock condition variable access mutex, this %0p\n", this);
+ system_printf ("Failed to unlock condition variable access mutex, this %p", this);
return;
}
+ /* Prime the detection flag */
+ ExitingWait = 1;
+ /* Signal any waiting thread */
PulseEvent (win32_obj_id);
/* No one can start waiting until we release the condition access mutex */
/* The released thread will decrement waiting when it gets a time slice...
without waiting for the access mutex
+ * InterLockedIncrement on 98 +, NT4 + returns the incremented value.
+ * On 95, nt 3.51 < it returns a sign correct number - 0=0, + for greater than 0, -
+ * for less than 0.
+ * Because of this we cannot spin on the waiting count, but rather we need a
+ * dedicated flag for a thread exiting the Wait function.
+ * Also not that Interlocked* sync CPU caches with memory.
*/
int spins = 10;
- while (InterlockedIncrement (&waiting) != (temp - 1) && spins)
+ /* When ExitingWait is nonzero after a decrement, the leaving thread has
+ * done it's thing
+ */
+ while (InterlockedDecrement (&ExitingWait) == 0 && spins)
{
- InterlockedDecrement (&waiting);
+ InterlockedIncrement (&ExitingWait);
/* give up the cpu to force a context switch. */
Sleep (0);
if (spins == 5)
- /* we've had 5 timeslices, and the woekn thread still hasn't done it's
+ /* we've had 5 timeslices, and the woken thread still hasn't done it's
* thing - maybe we raced it with the event? */
PulseEvent (win32_obj_id);
spins--;
}
- InterlockedDecrement (&waiting);
+ if (waiting + 1 != temp)
+ system_printf ("Released too many threads - %d now %d originally", waiting, temp);
if (pthread_mutex_unlock (&cond_access))
- system_printf ("Failed to unlock condition variable access mutex, this %0p\n", this);
+ system_printf ("Failed to unlock condition variable access mutex, this %p", this);
}
int
@@ -563,16 +576,16 @@ pthread_cond::TimedWait (DWORD dwMilliseconds)
void
pthread_cond::fixup_after_fork ()
{
- debug_printf("cond %x in fixup_after_fork\n", this);
+ debug_printf ("cond %x in fixup_after_fork", this);
if (shared != PTHREAD_PROCESS_PRIVATE)
- api_fatal("doesn't understand PROCESS_SHARED condition variables\n");
+ api_fatal ("doesn't understand PROCESS_SHARED condition variables");
/* FIXME: duplicate code here and in the constructor. */
- this->win32_obj_id =::CreateEvent (&sec_none_nih, false, false, NULL);
+ this->win32_obj_id = ::CreateEvent (&sec_none_nih, false, false, NULL);
if (!win32_obj_id)
- api_fatal("failed to create new win32 mutex\n");
+ api_fatal ("failed to create new win32 mutex");
#if DETECT_BAD_APPS
if (waiting)
- api_fatal("Forked() while a condition variable has waiting threads.\nReport to cygwin@cygwin.com\n");
+ api_fatal ("Forked () while a condition variable has waiting threads.\nReport to cygwin@cygwin.com");
#else
waiting = 0;
mutex = NULL;
@@ -641,7 +654,7 @@ pthread_key::get ()
pthread_mutex::pthread_mutex (pthread_mutexattr *attr):verifyable_object (PTHREAD_MUTEX_MAGIC)
{
/*attr checked in the C call */
- if (attr && attr->pshared==PTHREAD_PROCESS_SHARED)
+ if (attr && attr->pshared == PTHREAD_PROCESS_SHARED)
{
// fail
magic = 0;
@@ -651,14 +664,14 @@ pthread_mutex::pthread_mutex (pthread_mutexattr *attr):verifyable_object (PTHREA
InitializeCriticalSection (&criticalsection);
else
{
- this->win32_obj_id =::CreateMutex (&sec_none_nih, false, NULL);
+ this->win32_obj_id = ::CreateMutex (&sec_none_nih, false, NULL);
if (!win32_obj_id)
magic = 0;
}
condwaits = 0;
pshared = PTHREAD_PROCESS_PRIVATE;
/* threadsafe addition is easy */
- next = (pthread_mutex *)InterlockedExchangePointer (&MT_INTERFACE->mutexs, this);
+ next = (pthread_mutex *) InterlockedExchangePointer (&MT_INTERFACE->mutexs, this);
}
pthread_mutex::~pthread_mutex ()
@@ -721,21 +734,21 @@ pthread_mutex::UnLock ()
void
pthread_mutex::fixup_after_fork ()
{
- debug_printf("mutex %x in fixup_after_fork\n", this);
+ debug_printf ("mutex %x in fixup_after_fork", this);
if (pshared != PTHREAD_PROCESS_PRIVATE)
- api_fatal("pthread_mutex::fixup_after_fork () doesn'tunderstand PROCESS_SHARED mutex's\n");
+ api_fatal ("pthread_mutex::fixup_after_fork () doesn'tunderstand PROCESS_SHARED mutex's");
/* FIXME: duplicate code here and in the constructor. */
if (wincap.has_try_enter_critical_section ())
- InitializeCriticalSection(&criticalsection);
+ InitializeCriticalSection (&criticalsection);
else
{
- win32_obj_id =::CreateMutex (&sec_none_nih, false, NULL);
+ win32_obj_id = ::CreateMutex (&sec_none_nih, false, NULL);
if (!win32_obj_id)
- api_fatal("pthread_mutex::fixup_after_fork() failed to create new win32 mutex\n");
+ api_fatal ("pthread_mutex::fixup_after_fork () failed to create new win32 mutex");
}
#if DETECT_BAD_APPS
if (condwaits)
- api_fatal("Forked() while a mutex has condition variables waiting on it.\nReport to cygwin@cygwin.com\n");
+ api_fatal ("Forked () while a mutex has condition variables waiting on it.\nReport to cygwin@cygwin.com");
#else
condwaits = 0;
#endif
@@ -752,14 +765,14 @@ pthread_mutexattr::~pthread_mutexattr ()
semaphore::semaphore (int pshared, unsigned int value):verifyable_object (SEM_MAGIC)
{
- this->win32_obj_id =::CreateSemaphore (&sec_none_nih, value, LONG_MAX,
+ this->win32_obj_id = ::CreateSemaphore (&sec_none_nih, value, LONG_MAX,
NULL);
if (!this->win32_obj_id)
magic = 0;
this->shared = pshared;
currentvalue = value;
/* threadsafe addition is easy */
- next = (semaphore *)InterlockedExchangePointer (&MT_INTERFACE->semaphores, this);
+ next = (semaphore *) InterlockedExchangePointer (&MT_INTERFACE->semaphores, this);
}
semaphore::~semaphore ()
@@ -809,13 +822,13 @@ semaphore::Wait ()
void
semaphore::fixup_after_fork ()
{
- debug_printf("sem %x in fixup_after_fork\n", this);
+ debug_printf ("sem %x in fixup_after_fork", this);
if (shared != PTHREAD_PROCESS_PRIVATE)
- api_fatal("doesn't understand PROCESS_SHARED semaphores variables\n");
+ api_fatal ("doesn't understand PROCESS_SHARED semaphores variables");
/* FIXME: duplicate code here and in the constructor. */
- this->win32_obj_id =::CreateSemaphore (&sec_none_nih, currentvalue, LONG_MAX, NULL);
+ this->win32_obj_id = ::CreateSemaphore (&sec_none_nih, currentvalue, LONG_MAX, NULL);
if (!win32_obj_id)
- api_fatal("failed to create new win32 semaphore\n");
+ api_fatal ("failed to create new win32 semaphore");
}
verifyable_object::verifyable_object (long verifyer):
@@ -891,7 +904,7 @@ thread_init_wrapper (void *_arg)
if (!TlsSetValue (MT_INTERFACE->reent_index, &local_reent))
system_printf ("local storage for thread couldn't be set");
- /*the OS doesn't check this for <=64 Tls entries (pre win2k) */
+ /*the OS doesn't check this for <= 64 Tls entries (pre win2k) */
TlsSetValue (MT_INTERFACE->thread_self_dwTlsIndex, thread);
#ifdef _CYG_THREAD_FAILSAFE
@@ -919,6 +932,7 @@ int
__pthread_create (pthread_t *thread, const pthread_attr_t *attr,
void *(*start_routine) (void *), void *arg)
{
+ DECLARE_TLS_STORAGE;
if (attr && verifyable_object_isvalid (attr, PTHREAD_ATTR_MAGIC) != VALID_OBJECT)
return EINVAL;
@@ -1293,7 +1307,7 @@ __pthread_atfork (void (*prepare)(void), void (*parent)(void), void (*child)(voi
if (prepcb)
{
prepcb->cb = prepare;
- prepcb->next=(callback *)InterlockedExchangePointer ((LONG *) &MT_INTERFACE->pthread_prepare, (long int) prepcb);
+ prepcb->next = (callback *) InterlockedExchangePointer ((LONG *) &MT_INTERFACE->pthread_prepare, (long int) prepcb);
}
if (parentcb)
{
@@ -1302,7 +1316,7 @@ __pthread_atfork (void (*prepare)(void), void (*parent)(void), void (*child)(voi
while (*t)
t = &(*t)->next;
/*t = pointer to last next in the list */
- parentcb->next=(callback *)InterlockedExchangePointer ((LONG *) t, (long int) parentcb);
+ parentcb->next = (callback *) InterlockedExchangePointer ((LONG *) t, (long int) parentcb);
}
if (childcb)
{
@@ -1311,7 +1325,7 @@ __pthread_atfork (void (*prepare)(void), void (*parent)(void), void (*child)(voi
while (*t)
t = &(*t)->next;
/*t = pointer to last next in the list */
- childcb->next=(callback *)InterlockedExchangePointer ((LONG *) t, (long int) childcb);
+ childcb->next = (callback *) InterlockedExchangePointer ((LONG *) t, (long int) childcb);
}
return 0;
}
@@ -1676,6 +1690,8 @@ __pthread_getspecific (pthread_key_t key)
int
__pthread_cond_destroy (pthread_cond_t *cond)
{
+ if (check_valid_pointer (cond) && (*cond == PTHREAD_COND_INITIALIZER))
+ return 0;
if (verifyable_object_isvalid (cond, PTHREAD_COND_MAGIC) != VALID_OBJECT)
return EINVAL;
@@ -1695,7 +1711,7 @@ __pthread_cond_init (pthread_cond_t *cond, const pthread_condattr_t *attr)
if (attr && verifyable_object_isvalid (attr, PTHREAD_CONDATTR_MAGIC) != VALID_OBJECT)
return EINVAL;
- if (verifyable_object_isvalid (cond, PTHREAD_COND_MAGIC) != INVALID_OBJECT)
+ if (verifyable_object_isvalid (cond, PTHREAD_COND_MAGIC, PTHREAD_COND_INITIALIZER) == VALID_OBJECT)
return EBUSY;
*cond = new pthread_cond (attr ? (*attr) : NULL);
@@ -1713,6 +1729,8 @@ __pthread_cond_init (pthread_cond_t *cond, const pthread_condattr_t *attr)
int
__pthread_cond_broadcast (pthread_cond_t *cond)
{
+ if (*cond == PTHREAD_COND_INITIALIZER)
+ __pthread_cond_init (cond, NULL);
if (verifyable_object_isvalid (cond, PTHREAD_COND_MAGIC) != VALID_OBJECT)
return EINVAL;
@@ -1724,6 +1742,8 @@ __pthread_cond_broadcast (pthread_cond_t *cond)
int
__pthread_cond_signal (pthread_cond_t *cond)
{
+ if (*cond == PTHREAD_COND_INITIALIZER)
+ __pthread_cond_init (cond, NULL);
if (verifyable_object_isvalid (cond, PTHREAD_COND_MAGIC) != VALID_OBJECT)
return EINVAL;
@@ -1743,6 +1763,8 @@ __pthread_cond_dowait (pthread_cond_t *cond, pthread_mutex_t *mutex,
if (*mutex == PTHREAD_MUTEX_INITIALIZER)
__pthread_mutex_init (mutex, NULL);
themutex = mutex;
+ if (*cond == PTHREAD_COND_INITIALIZER)
+ __pthread_cond_init (cond, NULL);
if (verifyable_object_isvalid (themutex, PTHREAD_MUTEX_MAGIC) != VALID_OBJECT)
return EINVAL;
@@ -1751,13 +1773,13 @@ __pthread_cond_dowait (pthread_cond_t *cond, pthread_mutex_t *mutex,
/*if the cond variable is blocked, then the above timer test maybe wrong. *shrug**/
if (pthread_mutex_lock (&(*cond)->cond_access))
- system_printf ("Failed to lock condition variable access mutex, this %0p\n", *cond);
+ system_printf ("Failed to lock condition variable access mutex, this %p", *cond);
if ((*cond)->waiting)
if ((*cond)->mutex && ((*cond)->mutex != (*themutex)))
{
if (pthread_mutex_unlock (&(*cond)->cond_access))
- system_printf ("Failed to unlock condition variable access mutex, this %0p\n", *cond);
+ system_printf ("Failed to unlock condition variable access mutex, this %p", *cond);
return EINVAL;
}
InterlockedIncrement (&((*cond)->waiting));
@@ -1765,22 +1787,24 @@ __pthread_cond_dowait (pthread_cond_t *cond, pthread_mutex_t *mutex,
(*cond)->mutex = (*themutex);
InterlockedIncrement (&((*themutex)->condwaits));
if (pthread_mutex_unlock (&(*cond)->cond_access))
- system_printf ("Failed to unlock condition variable access mutex, this %0p\n", *cond);
+ system_printf ("Failed to unlock condition variable access mutex, this %p", *cond);
rv = (*cond)->TimedWait (waitlength);
- /* this may allow a race on the mutex acquisition and waits..
+ /* this may allow a race on the mutex acquisition and waits..
* But doing this within the cond access mutex creates a different race
*/
bool last = false;
if (InterlockedDecrement (&((*cond)->waiting)) == 0)
last = true;
+ /* Tell Signal that we have been released */
+ InterlockedDecrement (&((*cond)->ExitingWait));
(*themutex)->Lock ();
if (last == true)
(*cond)->mutex = NULL;
if (pthread_mutex_lock (&(*cond)->cond_access))
- system_printf ("Failed to lock condition variable access mutex, this %0p\n", *cond);
+ system_printf ("Failed to lock condition variable access mutex, this %p", *cond);
InterlockedDecrement (&((*themutex)->condwaits));
if (pthread_mutex_unlock (&(*cond)->cond_access))
- system_printf ("Failed to unlock condition variable access mutex, this %0p\n", *cond);
+ system_printf ("Failed to unlock condition variable access mutex, this %p", *cond);
return rv;
}
@@ -1789,11 +1813,11 @@ extern "C" int
pthread_cond_timedwait (pthread_cond_t *cond, pthread_mutex_t *mutex,
const struct timespec *abstime)
{
- if (check_valid_pointer(abstime))
+ if (check_valid_pointer (abstime))
return EINVAL;
struct timeb currSysTime;
long waitlength;
- ftime(&currSysTime);
+ ftime (&currSysTime);
waitlength = (abstime->tv_sec - currSysTime.time) *1000;
if (waitlength < 0)
return ETIMEDOUT;
@@ -1920,7 +1944,7 @@ __pthread_mutex_init (pthread_mutex_t *mutex,
if (attr && verifyable_object_isvalid (attr, PTHREAD_MUTEXATTR_MAGIC) != VALID_OBJECT || check_valid_pointer (mutex))
return EINVAL;
- if (verifyable_object_isvalid (mutex, PTHREAD_MUTEX_MAGIC, PTHREAD_MUTEX_INITIALIZER) != INVALID_OBJECT)
+ if (verifyable_object_isvalid (mutex, PTHREAD_MUTEX_MAGIC, PTHREAD_MUTEX_INITIALIZER) == VALID_OBJECT)
return EBUSY;
*mutex = new pthread_mutex (attr ? (*attr) : NULL);
@@ -1937,7 +1961,7 @@ int
__pthread_mutex_getprioceiling (const pthread_mutex_t *mutex,
int *prioceiling)
{
- pthread_mutex_t *themutex=(pthread_mutex_t *) mutex;
+ pthread_mutex_t *themutex = (pthread_mutex_t *) mutex;
if (*mutex == PTHREAD_MUTEX_INITIALIZER)
__pthread_mutex_init ((pthread_mutex_t *) mutex, NULL);
if (verifyable_object_isvalid (themutex, PTHREAD_MUTEX_MAGIC) != VALID_OBJECT)
@@ -1964,11 +1988,11 @@ __pthread_mutex_lock (pthread_mutex_t *mutex)
break;
case VALID_STATIC_OBJECT:
if (*mutex == PTHREAD_MUTEX_INITIALIZER)
- {
- int rv = __pthread_mutex_init (mutex, NULL);
- if (rv)
+ {
+ int rv = __pthread_mutex_init (mutex, NULL);
+ if (rv)
return rv;
- }
+ }
break;
case VALID_OBJECT:
break;
diff --git a/winsup/cygwin/thread.h b/winsup/cygwin/thread.h
index c724bea14..23aaa6860 100644
--- a/winsup/cygwin/thread.h
+++ b/winsup/cygwin/thread.h
@@ -164,7 +164,7 @@ public:
~verifyable_object ();
};
-typedef enum
+typedef enum
{
VALID_OBJECT,
INVALID_OBJECT,
@@ -306,6 +306,7 @@ class pthread_cond:public verifyable_object
public:
int shared;
LONG waiting;
+ LONG ExitingWait;
pthread_mutex *mutex;
/* to allow atomic behaviour for cond_broadcast */
pthread_mutex_t cond_access;
diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc
index 9bbbe9e9c..c128d8a44 100644
--- a/winsup/cygwin/uinfo.cc
+++ b/winsup/cygwin/uinfo.cc
@@ -17,6 +17,7 @@ details. */
#include <limits.h>
#include <stdlib.h>
#include <lm.h>
+#include <errno.h>
#include <sys/cygwin.h>
#include "sync.h"
#include "sigproc.h"
@@ -25,12 +26,14 @@ details. */
#include "fhandler.h"
#include "path.h"
#include "dtable.h"
+#include "cygerrno.h"
#include "cygheap.h"
#include "registry.h"
struct passwd *
internal_getlogin (cygheap_user &user)
{
+ char buf[512];
char username[UNLEN + 1];
DWORD username_len = UNLEN + 1;
struct passwd *pw = NULL;
@@ -45,7 +48,6 @@ internal_getlogin (cygheap_user &user)
{
LPWKSTA_USER_INFO_1 wui;
NET_API_STATUS ret;
- char buf[512];
char *env;
user.set_logsrv (NULL);
@@ -59,7 +61,7 @@ internal_getlogin (cygheap_user &user)
if (user.name () && user.domain ())
debug_printf ("User: %s, Domain: %s, Logon Server: %s",
user.name (), user.domain (), user.logsrv ());
- else if (!(ret = NetWkstaUserGetInfo (NULL, 1, (LPBYTE *)&wui)))
+ else if (!(ret = NetWkstaUserGetInfo (NULL, 1, (LPBYTE *) &wui)))
{
sys_wcstombs (buf, wui->wkui1_username, UNLEN + 1);
user.set_name (buf);
@@ -76,44 +78,54 @@ internal_getlogin (cygheap_user &user)
user.set_logsrv (buf + 2);
setenv ("LOGONSERVER", buf, 1);
}
- LPUSER_INFO_3 ui = NULL;
- WCHAR wuser[UNLEN + 1];
- WCHAR wlogsrv[INTERNET_MAX_HOST_NAME_LENGTH + 3];
+ debug_printf ("Domain: %s, Logon Server: %s, Windows Username: %s",
+ user.domain (), user.logsrv (), user.name ());
- /* HOMEDRIVE and HOMEPATH are wrong most of the time, too,
- after changing user context! */
- sys_mbstowcs (wuser, user.name (), UNLEN + 1);
- wlogsrv[0] = '\0';
- if (user.logsrv ())
+ /* NetUserGetInfo() can be slow in NT domain environment, thus we
+ * only obtain HOMEDRIVE and HOMEPATH if they are not already set
+ * in the environment. */
+ if (!getenv ("HOMEPATH") || !getenv ("HOMEDRIVE"))
{
- strcat (strcpy (buf, "\\\\"), user.logsrv ());
- sys_mbstowcs (wlogsrv, buf, INTERNET_MAX_HOST_NAME_LENGTH + 3);
- }
- if (!NetUserGetInfo (NULL, wuser, 3, (LPBYTE *)&ui)
- || (wlogsrv[0] && !NetUserGetInfo (wlogsrv, wuser, 3,(LPBYTE *)&ui)))
- {
- sys_wcstombs (buf, ui->usri3_home_dir, MAX_PATH);
- if (!buf[0])
+ LPUSER_INFO_3 ui = NULL;
+ WCHAR wuser[UNLEN + 1];
+
+ sys_mbstowcs (wuser, user.name (), sizeof (wuser) / sizeof (*wuser));
+ if ((ret = NetUserGetInfo (NULL, wuser, 3, (LPBYTE *)&ui)))
+ {
+ if (user.logsrv ())
+ {
+ WCHAR wlogsrv[INTERNET_MAX_HOST_NAME_LENGTH + 3];
+ strcat (strcpy (buf, "\\\\"), user.logsrv ());
+
+ sys_mbstowcs (wlogsrv, buf,
+ sizeof (wlogsrv) / sizeof(*wlogsrv));
+ ret = NetUserGetInfo (wlogsrv, wuser, 3,(LPBYTE *)&ui);
+ }
+ }
+ if (!ret)
{
- sys_wcstombs (buf, ui->usri3_home_dir_drive, MAX_PATH);
- if (buf[0])
- strcat (buf, "\\");
- else
+ sys_wcstombs (buf, ui->usri3_home_dir, MAX_PATH);
+ if (!buf[0])
{
- env = getenv ("SYSTEMDRIVE");
- if (env && *env)
- strcat (strcpy (buf, env), "\\");
+ sys_wcstombs (buf, ui->usri3_home_dir_drive, MAX_PATH);
+ if (buf[0])
+ strcat (buf, "\\");
else
- GetSystemDirectoryA (buf, MAX_PATH);
+ {
+ env = getenv ("SYSTEMDRIVE");
+ if (env && *env)
+ strcat (strcpy (buf, env), "\\");
+ else
+ GetSystemDirectoryA (buf, MAX_PATH);
+ }
}
+ setenv ("HOMEPATH", buf + 2, 1);
+ buf[2] = '\0';
+ setenv ("HOMEDRIVE", buf, 1);
}
- setenv ("HOMEPATH", buf + 2, 1);
- buf[2] = '\0';
- setenv ("HOMEDRIVE", buf, 1);
- NetApiBufferFree (ui);
+ if (ui)
+ NetApiBufferFree (ui);
}
- debug_printf ("Domain: %s, Logon Server: %s, Windows Username: %s",
- user.domain (), user.logsrv (), user.name ());
if (allow_ntsec)
{
@@ -200,7 +212,28 @@ internal_getlogin (cygheap_user &user)
}
}
debug_printf ("Cygwins Username: %s", user.name ());
- return pw ?: getpwnam(user.name ());
+ if (!pw)
+ pw = getpwnam(user.name ());
+ if (!getenv ("HOME"))
+ {
+ const char *homedrive, *homepath;
+ if (pw && pw->pw_dir && *pw->pw_dir)
+ {
+ setenv ("HOME", pw->pw_dir, 1);
+ debug_printf ("Set HOME (from /etc/passwd) to %s", pw->pw_dir);
+ }
+ else if ((homedrive = getenv ("HOMEDRIVE"))
+ && (homepath = getenv ("HOMEPATH")))
+ {
+ char home[MAX_PATH];
+ strcpy (buf, homedrive);
+ strcat (buf, homepath);
+ cygwin_conv_to_full_posix_path (buf, home);
+ setenv ("HOME", home, 1);
+ debug_printf ("Set HOME (from HOMEDRIVE/HOMEPATH) to %s", home);
+ }
+ }
+ return pw;
}
void
diff --git a/winsup/cygwin/uname.cc b/winsup/cygwin/uname.cc
index b73dc970f..aff158340 100644
--- a/winsup/cygwin/uname.cc
+++ b/winsup/cygwin/uname.cc
@@ -24,7 +24,7 @@ uname (struct utsname *name)
if (check_null_invalid_struct_errno (name))
return -1;
-
+
char *snp = strstr (cygwin_version.dll_build_date, "SNP");
memset (name, 0, sizeof (*name));
@@ -57,13 +57,23 @@ uname (struct utsname *name)
{
case PROCESSOR_ARCHITECTURE_INTEL:
unsigned int ptype;
- if (sysinfo.dwProcessorType < 3) /* Shouldn't happen. */
- ptype = 3;
- else if (sysinfo.dwProcessorType > 9) /* P4 */
- ptype = 6;
+ if (wincap.has_valid_processorlevel ())
+ {
+ if (sysinfo.wProcessorLevel < 3) /* Shouldn't happen. */
+ ptype = 3;
+ else if (sysinfo.wProcessorLevel > 9) /* P4 */
+ ptype = 6;
+ else
+ ptype = sysinfo.wProcessorLevel;
+ }
else
- ptype = sysinfo.dwProcessorType;
-
+ {
+ if (sysinfo.dwProcessorType == PROCESSOR_INTEL_386 ||
+ sysinfo.dwProcessorType == PROCESSOR_INTEL_486)
+ ptype = sysinfo.dwProcessorType / 100;
+ else
+ ptype = PROCESSOR_INTEL_PENTIUM / 100;
+ }
__small_sprintf (name->machine, "i%d86", ptype);
break;
case PROCESSOR_ARCHITECTURE_ALPHA:
diff --git a/winsup/cygwin/wincap.cc b/winsup/cygwin/wincap.cc
index 4026167ad..14211a5e8 100644
--- a/winsup/cygwin/wincap.cc
+++ b/winsup/cygwin/wincap.cc
@@ -43,6 +43,8 @@ static NO_COPY wincaps wincap_unknown = {
has_negative_pids:false,
has_unreliable_pipes:false,
has_try_enter_critical_section:false,
+ has_raw_devices:false,
+ has_valid_processorlevel:false,
};
static NO_COPY wincaps wincap_95 = {
@@ -77,6 +79,8 @@ static NO_COPY wincaps wincap_95 = {
has_negative_pids:true,
has_unreliable_pipes:true,
has_try_enter_critical_section:false,
+ has_raw_devices:false,
+ has_valid_processorlevel:false,
};
static NO_COPY wincaps wincap_95osr2 = {
@@ -111,6 +115,8 @@ static NO_COPY wincaps wincap_95osr2 = {
has_negative_pids:true,
has_unreliable_pipes:true,
has_try_enter_critical_section:false,
+ has_raw_devices:false,
+ has_valid_processorlevel:false,
};
static NO_COPY wincaps wincap_98 = {
@@ -145,6 +151,8 @@ static NO_COPY wincaps wincap_98 = {
has_negative_pids:true,
has_unreliable_pipes:true,
has_try_enter_critical_section:false,
+ has_raw_devices:false,
+ has_valid_processorlevel:true,
};
static NO_COPY wincaps wincap_98se = {
@@ -179,6 +187,8 @@ static NO_COPY wincaps wincap_98se = {
has_negative_pids:true,
has_unreliable_pipes:true,
has_try_enter_critical_section:false,
+ has_raw_devices:false,
+ has_valid_processorlevel:true,
};
static NO_COPY wincaps wincap_me = {
@@ -213,6 +223,8 @@ static NO_COPY wincaps wincap_me = {
has_negative_pids:true,
has_unreliable_pipes:true,
has_try_enter_critical_section:false,
+ has_raw_devices:false,
+ has_valid_processorlevel:true,
};
static NO_COPY wincaps wincap_nt3 = {
@@ -247,6 +259,8 @@ static NO_COPY wincaps wincap_nt3 = {
has_negative_pids:false,
has_unreliable_pipes:false,
has_try_enter_critical_section:false,
+ has_raw_devices:true,
+ has_valid_processorlevel:true,
};
static NO_COPY wincaps wincap_nt4 = {
@@ -281,6 +295,8 @@ static NO_COPY wincaps wincap_nt4 = {
has_negative_pids:false,
has_unreliable_pipes:false,
has_try_enter_critical_section:true,
+ has_raw_devices:true,
+ has_valid_processorlevel:true,
};
static NO_COPY wincaps wincap_nt4sp4 = {
@@ -315,6 +331,8 @@ static NO_COPY wincaps wincap_nt4sp4 = {
has_negative_pids:false,
has_unreliable_pipes:false,
has_try_enter_critical_section:true,
+ has_raw_devices:true,
+ has_valid_processorlevel:true,
};
static NO_COPY wincaps wincap_2000 = {
@@ -349,6 +367,8 @@ static NO_COPY wincaps wincap_2000 = {
has_negative_pids:false,
has_unreliable_pipes:false,
has_try_enter_critical_section:true,
+ has_raw_devices:true,
+ has_valid_processorlevel:true,
};
static NO_COPY wincaps wincap_xp = {
@@ -383,6 +403,8 @@ static NO_COPY wincaps wincap_xp = {
has_negative_pids:false,
has_unreliable_pipes:false,
has_try_enter_critical_section:true,
+ has_raw_devices:true,
+ has_valid_processorlevel:true,
};
wincapc NO_COPY wincap;
@@ -408,9 +430,9 @@ wincapc::init ()
case 4:
os = "NT";
if (strcmp (version.szCSDVersion, "Service Pack 4") < 0)
- caps = &wincap_nt4;
+ caps = &wincap_nt4;
else
- caps = &wincap_nt4sp4;
+ caps = &wincap_nt4sp4;
break;
case 5:
os = "NT";
@@ -424,7 +446,7 @@ wincapc::init ()
caps = &wincap_unknown;
break;
}
- break;
+ break;
case VER_PLATFORM_WIN32_WINDOWS:
switch (version.dwMinorVersion)
{
@@ -438,9 +460,9 @@ wincapc::init ()
case 10:
os = "98";
if (strchr(version.szCSDVersion, 'A'))
- caps = &wincap_98se;
+ caps = &wincap_98se;
else
- caps = &wincap_98;
+ caps = &wincap_98;
break;
case 90:
os = "ME";
@@ -451,9 +473,9 @@ wincapc::init ()
caps = &wincap_unknown;
break;
}
- break;
+ break;
default:
- os = "??";
+ os = "??";
caps = &wincap_unknown;
break;
}
diff --git a/winsup/cygwin/wincap.h b/winsup/cygwin/wincap.h
index 038947636..a3cd3176c 100644
--- a/winsup/cygwin/wincap.h
+++ b/winsup/cygwin/wincap.h
@@ -12,7 +12,7 @@ details. */
#define _WINCAP_H
struct wincaps
-{
+{
DWORD lock_file_highword;
DWORD chunksize;
int shared;
@@ -44,6 +44,8 @@ struct wincaps
unsigned has_negative_pids : 1;
unsigned has_unreliable_pipes : 1;
unsigned has_try_enter_critical_section : 1;
+ unsigned has_raw_devices : 1;
+ unsigned has_valid_processorlevel : 1;
};
class wincapc
@@ -56,7 +58,7 @@ public:
void init ();
void set_chunksize (DWORD nchunksize);
-
+
const char *osname () const { return osnam; }
#define IMPLEMENT(cap) cap() const { return ((wincaps *)this->caps)->cap; }
@@ -92,6 +94,8 @@ public:
bool IMPLEMENT (has_negative_pids)
bool IMPLEMENT (has_unreliable_pipes)
bool IMPLEMENT (has_try_enter_critical_section)
+ bool IMPLEMENT (has_raw_devices)
+ bool IMPLEMENT (has_valid_processorlevel)
#undef IMPLEMENT
};
diff --git a/winsup/cygwin/window.cc b/winsup/cygwin/window.cc
index 4567da6a7..953f603ba 100644
--- a/winsup/cygwin/window.cc
+++ b/winsup/cygwin/window.cc
@@ -18,6 +18,7 @@ details. */
#include <limits.h>
#include <wingdi.h>
#include <winuser.h>
+#include <unistd.h>
#include "cygerrno.h"
#include "perprocess.h"
#include "security.h"
@@ -74,7 +75,7 @@ Winmain (VOID *)
{
MSG msg;
WNDCLASS wc;
- static const NO_COPY char classname[] = "CygwinWndClass";
+ static NO_COPY char classname[] = "CygwinWndClass";
/* Register the window class for the main window. */
@@ -150,8 +151,7 @@ window_terminate ()
SendMessage (ourhwnd, WM_DESTROY, 0, 0);
}
-extern "C"
-int
+extern "C" int
setitimer (int which, const struct itimerval *value, struct itimerval *oldvalue)
{
UINT elapse;
@@ -195,8 +195,7 @@ setitimer (int which, const struct itimerval *value, struct itimerval *oldvalue)
return 0;
}
-extern "C"
-int
+extern "C" int
getitimer (int which, struct itimerval *value)
{
UINT elapse, val;
@@ -221,27 +220,41 @@ getitimer (int which, struct itimerval *value)
elapse = GetTickCount () - start_time;
val = itv.it_value.tv_sec * 1000 + itv.it_value.tv_usec / 1000;
val -= elapse;
- value->it_value.tv_sec = val/1000;
- value->it_value.tv_usec = val%1000;
+ value->it_value.tv_sec = val / 1000;
+ value->it_value.tv_usec = val % 1000;
return 0;
}
-extern "C"
-unsigned int
+extern "C" unsigned int
alarm (unsigned int seconds)
{
int ret;
struct itimerval newt, oldt;
- getitimer (ITIMER_REAL, &oldt);
-
newt.it_value.tv_sec = seconds;
newt.it_value.tv_usec = 0;
newt.it_interval.tv_sec = 0;
newt.it_interval.tv_usec = 0;
- setitimer (ITIMER_REAL, &newt, NULL);
+ setitimer (ITIMER_REAL, &newt, &oldt);
ret = oldt.it_value.tv_sec;
if (ret == 0 && oldt.it_value.tv_usec)
ret = 1;
return ret;
}
+
+extern "C" useconds_t
+ualarm (useconds_t value, useconds_t interval)
+{
+ struct itimerval timer, otimer;
+
+ timer.it_value.tv_sec = 0;
+ timer.it_value.tv_usec = value;
+ timer.it_interval.tv_sec = 0;
+ timer.it_interval.tv_usec = interval;
+
+ if (setitimer (ITIMER_REAL, &timer, &otimer) < 0)
+ return (u_int)-1;
+
+ return (otimer.it_value.tv_sec * 1000000) + otimer.it_value.tv_usec;
+}
+
diff --git a/winsup/cygwin/winsup.h b/winsup/cygwin/winsup.h
index e40dfb68a..9759f1348 100644
--- a/winsup/cygwin/winsup.h
+++ b/winsup/cygwin/winsup.h
@@ -14,7 +14,6 @@ details. */
#define __INSIDE_CYGWIN__
-#define alloca __builtin_alloca
#define strlen __builtin_strlen
#define strcmp __builtin_strcmp
#define strcpy __builtin_strcpy
@@ -26,6 +25,13 @@ details. */
#define NO_COPY __attribute__((section(".data_cygwin_nocopy")))
+#ifdef EXPCGF
+#define DECLARE_TLS_STORAGE char **tls[4096] __attribute__ ((unused))
+#else
+#define DECLARE_TLS_STORAGE do {} while (0)
+#define _WINBASE2_H
+#endif
+
#ifdef __cplusplus
#if !defined(__STDC_VERSION__) || __STDC_VERSION__ >= 199900L
@@ -146,6 +152,7 @@ void events_init (void);
void events_terminate (void);
void __stdcall close_all_files (void);
+BOOL __stdcall check_pty_fds (void);
/* Invisible window initialization/termination. */
HWND __stdcall gethwnd (void);
@@ -190,13 +197,16 @@ long __stdcall to_time_t (FILETIME * ptr);
void __stdcall set_console_title (char *);
void set_console_handler ();
+int __stdcall check_null_str (const char *name) __attribute__ ((regparm(1)));
int __stdcall check_null_empty_str (const char *name) __attribute__ ((regparm(1)));
int __stdcall check_null_empty_str_errno (const char *name) __attribute__ ((regparm(1)));
-int __stdcall __check_null_invalid_struct (const void *s, unsigned sz) __attribute__ ((regparm(1)));
-int __stdcall __check_null_invalid_struct_errno (const void *s, unsigned sz) __attribute__ ((regparm(1)));
+int __stdcall check_null_str_errno (const char *name) __attribute__ ((regparm(1)));
+int __stdcall __check_null_invalid_struct (const void *s, unsigned sz) __attribute__ ((regparm(2)));
+int __stdcall __check_null_invalid_struct_errno (const void *s, unsigned sz) __attribute__ ((regparm(2)));
+int __stdcall __check_invalid_read_ptr_errno (const void *s, unsigned sz) __attribute__ ((regparm(2)));
#define check_null_invalid_struct(s) \
- __check_null_invalid ((s), sizeof (*(s)))
+ __check_null_invalid_struct ((s), sizeof (*(s)))
#define check_null_invalid_struct_errno(s) \
__check_null_invalid_struct_errno ((s), sizeof (*(s)))
@@ -209,6 +219,7 @@ extern bool wsock_started;
extern "C" void __api_fatal (const char *, ...) __attribute__ ((noreturn));
extern "C" int __small_sprintf (char *dst, const char *fmt, ...) /*__attribute__ ((regparm (2)))*/;
extern "C" int __small_vsprintf (char *dst, const char *fmt, va_list ap) /*__attribute__ ((regparm (3)))*/;
+extern void multiple_cygwin_problem (const char *, unsigned, unsigned);
extern "C" void __malloc_lock (struct _reent *);
extern "C" void __malloc_unlock (struct _reent *);
@@ -216,6 +227,10 @@ extern "C" void __malloc_unlock (struct _reent *);
extern "C" void __malloc_lock (struct _reent *);
extern "C" void __malloc_unlock (struct _reent *);
+class path_conv;
+int __stdcall stat_worker (const char *name, struct stat *buf, int nofollow,
+ path_conv *pc = NULL) __attribute__ ((regparm (3)));
+
/**************************** Exports ******************************/
extern "C" {
@@ -258,4 +273,12 @@ extern BOOL display_title;
extern HANDLE hMainThread;
extern HANDLE hMainProc;
+extern bool cygwin_testing;
+extern unsigned _cygwin_testing_magic;
+extern HMODULE cygwin_hmodule;
+
+#define winsock2_active (wsadata.wVersion >= 512)
+#define winsock_active (wsadata.wVersion < 512)
+extern struct WSAData wsadata;
+
#endif /* defined __cplusplus */