Commit Graph

19432 Commits

Author SHA1 Message Date
Ken Brown 13c65c43c2 Cygwin: FIFO: dup/fork/exec: make sure child starts unlocked
There can be deadlocks if the child starts with its fifo_client_lock
in the locked state.
2020-05-08 06:32:00 -04:00
Ken Brown 624fda1e96 Cygwin: FIFO: honor the flags argument in dup
Also improve the error handling.
2020-05-08 06:32:00 -04:00
Ken Brown 25e8727368 Cygwin: FIFO: remove the arm method
There's no reason to check for errors when we set read_ready or
write_ready.  We don't do that for other events.
2020-05-08 06:32:00 -04:00
Ken Brown 9b2afd78ce Cygwin: FIFO: simplify the listen_client_thread code
Always return 0; no one is doing anything with the return value
anyway.

Remove the return value from stop_listen_client.

Make the connection event auto-reset, so that we don't have to reset
it later.

Simplify the process of connecting a bogus client when thread
termination is signaled.

Make some failures fatal.

Remove the unnecessary extra check for thread termination near the end
of listen_client_thread.
2020-05-08 06:32:00 -04:00
Ken Brown 32dbc3d215 Cygwin: FIFO: change the fifo_client_connect_state enum
Make the values correspond to the possible return values of
fifo_client_handler::pipe_state().

When cleaning up the fc_handler list in listen_client_thread(), don't
delete handlers in the fc_closing state.  I think the pipe might still
have input to be read in that case.

Set the state to fc_closing later in the same function if a connection
is made and the status returned by NtFsControlFile is
STATUS_PIPE_CLOSING.

In raw_read, don't error out if NtReadFile returns an unexpected
status; just set the state of that handler to fc_error.  One writer in
a bad state doesn't justify giving up on reading.
2020-05-08 06:32:00 -04:00
Ken Brown ce23e97640 Cygwin: FIFO: simplify the fifo_client_handler structure
Replace the 'fhandler_base *' member by a HANDLE to the server side of
the Windows named pipe instance.  Make the corresponding
simplifications throughout.
2020-05-08 06:32:00 -04:00
Ken Brown d05124dc6b Cygwin: FIFO: minor change - use NtClose
Replace CloseHandle by NtClose since all handles are created by NT
functions.
2020-05-08 06:32:00 -04:00
Corinna Vinschen 72865dc2a3 Revert "localtime define _DIAGASSERT" and followups affecting localtime.cc
This reverts commits 453b6d17bf,
                     489a47d603,
                     3003c3dacd,
                     9e29639ca0,
                     a40701c7dc,
                     0a41de2725,
                     b8aa5f7a0f,
                     0f4bda8792,
                     65bf580752,
                     3f0c2ac96e,
                     76d4d40b8b,
                     f2e06d8af5.
2020-05-04 11:25:30 +02:00
Johannes Schindelin 717db9fd1c setup_pseudoconsole(): handle missing/incorrect helper gracefully
When `cygwin-console-helper.exe` is either missing, or corresponds to a
different Cygwin runtime, we currently wait forever while setting up
access to the pseudo console, even long after the process is gone that
was supposed to signal that it set up access to the pseudo console.

Let's handle that more gracefully: if the process exited without
signaling, we cannot use the pseudo console. In that case, let's just
fall back to not using it.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2020-05-04 11:19:19 +02:00
Corinna Vinschen 453b6d17bf localtime define _DIAGASSERT 2020-04-29 09:51:52 +02:00
Corinna Vinschen 489a47d603 localtime 1.82 2020-04-28 21:35:41 +02:00
Corinna Vinschen 3003c3dacd localtime 1.81 2020-04-28 21:26:45 +02:00
Corinna Vinschen 9e29639ca0 localtime 1.80 2020-04-28 21:21:14 +02:00
Corinna Vinschen a40701c7dc localtime 1.79 2020-04-28 21:20:18 +02:00
Corinna Vinschen 0a41de2725 localtime 1.78 2020-04-28 21:14:01 +02:00
Corinna Vinschen b8aa5f7a0f localtime 1.77 2020-04-28 20:58:29 +02:00
Corinna Vinschen 0f4bda8792 localtime 1.76 2020-04-28 20:57:34 +02:00
Corinna Vinschen 65bf580752 localtime 1.75 2020-04-28 20:56:16 +02:00
Corinna Vinschen 3f0c2ac96e localtime 1.74 2020-04-28 20:50:57 +02:00
Corinna Vinschen 76d4d40b8b localtime 1.73 2020-04-27 11:22:57 +02:00
Corinna Vinschen f2e06d8af5 Cygwin: localtime.cc: reformat for easier patching
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-04-27 11:22:51 +02:00
Corinna Vinschen d94763fc2e Cygwin: add release message for fixed floppy bugs
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-04-24 16:40:25 +02:00
Corinna Vinschen 39a1c3c96f Cygwin: raw disk I/O: lock floppys as well
The workaround to access the full disk required since Vista
and described in http://support.microsoft.com/kb/942448
(NOT ACCESSIBLE at the time of writing this commit message)
is required on floppy drives as well.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-04-24 16:22:26 +02:00
Corinna Vinschen b834921895 Cygwin: raw disk I/O: Fix return value in error case
The cast to generate the return value uses a DWORD variable
as test and set value.  The error case is the constant -1.
Given the type of the other half of the conditioal expression,
-1 is cast to DWORD as well.

On 64 bit, this results in the error case returning a 32 bit
-1 value which is equivalent to (ssize_t) 4294967295 rather
than (ssize_t) -1.

Add a fixing cast.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-04-24 16:19:09 +02:00
Corinna Vinschen 5a7e130c31 Cygwin: file I/O: make sure to treat write return value as ssize_t
The return type of fhandler write methods is ssize_t.  Don't
use an int to store the return value, use ssize_t.  Use ptrdiff_t
for the buffer size.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-04-24 16:14:43 +02:00
David Macek via Cygwin-patches 8a0bdd84b8 Cygwin: accounts: Report unrecognized db_* nsswitch.conf keywords
Signed-off-by: David Macek <david.macek.0@gmail.com>
2020-04-22 09:32:33 +02:00
David Macek via Cygwin-patches 969c8392fe Cygwin: accounts: Don't keep old schemes when parsing nsswitch.conf
The implicit assumption seemed to be that any subsequent occurence of
the same setting in nsswitch.conf is supposed to rewrite the previous
ones completely.  This was not the case if the third or any further
schema was previously defined and the last line defined less than that
(but at least 2), for example:

```
db_home: windows cygwin /myhome/%U
db_home: cygwin desc
```

Let's document this behavior as well.

Signed-off-by: David Macek <david.macek.0@gmail.com>
2020-04-22 09:32:33 +02:00
David Macek via Cygwin-patches d5add9ee5e Cygwin: accounts: Unify nsswitch.conf db_* defaults
Signed-off-by: David Macek <david.macek.0@gmail.com>
2020-04-22 09:32:33 +02:00
Corinna Vinschen f47347716c Cygwin: Add David Macek to CONTRIBUTORS
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-04-21 10:39:36 +02:00
Corinna Vinschen 6b97962073 Cygwin: symlinks: fix WSL symlink creation if cygdrive prefix is /
If the cygdrive prefix is /, then the following happens right now:

  $ ln -s /tmp/foo .
  $ ls -l foo
  lrwxrwxrwx 1 user group 12 Apr 15 23:44 foo -> /mnt/tmp/foo

Fix this by skipping cygdrive prefix conversion to WSL drive
prefix "/mnt", if the cygdrive prefix is just "/".  There's no
satisfying way to do the right thing all the time in this case
anyway.  For a description and the alternatives, see
https://cygwin.com/pipermail/cygwin-developers/2020-April/011859.html

Also, fix a typo in a comment.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-04-21 10:39:36 +02:00
David Macek via Cygwin-patches 5951b3e600 cygheap_pwdgrp: Handle invalid db_* entries correctly
If the first scheme in db_* was invalid, the code would think there
were no schemes specified and replace the second scheme with
NSS_SCHEME_DESC.

Signed-off-by: David Macek <david.macek.0@gmail.com>
2020-04-17 09:54:40 +02:00
Corinna Vinschen 1fac24078a Cygwin: faq: disable outdated "sshd in domain" faq
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-04-14 13:26:37 +02:00
Brian Inglis 073edd5329 proc_cpuinfo: Add PPIN support for AMD
Newer AMD CPUs support a feature called protected processor
identification number (PPIN). This feature can be detected via
CPUID_Fn80000008_EBX[23].
2020-04-14 12:35:51 +02:00
Corinna Vinschen 3d1360113d Cygwin: utils: override definition of PMEM_EXTENDED_PARAMETER
PMEM_EXTENDED_PARAMETER is defined in the local winlean.h as long
as mingw-w64 doesn't define it (in winnt.h).  ntdll.h needs the
definition for declaring NtMapViewOfSectionEx.  cygpath.cc and ps.cc
both include ntdll.h but not winlean.h, so they complain about the
missing definition.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-04-07 19:04:41 +02:00
Corinna Vinschen 3fe9b02ccd Cygwin: mmap_alloc: fix comment to document using the extended memory API
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-04-07 18:23:11 +02:00
Corinna Vinschen b8ecbaaac0 Cygwin: threads: use extended memory API if available
So far Cygwin was jumping through hoops to restrict memory
allocation to specific regions.  With the advent of VirtualAlloc2
and MapViewOfFile3 (and it's NT counterpart NtMapViewOfSectionEx),
we can skip searching for free space in the specific regions
and just call these functions and let the OS do the job more
efficiently and less racy.

Use VirtualAlloc2 on W10 1803 and later in thread stack allocation.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-04-07 18:23:11 +02:00
Corinna Vinschen 8d0a7701aa Cygwin: mmap: use extended memory API if available
So far Cygwin was jumping through hoops to restrict memory
allocation to specific regions.  With the advent of VirtualAlloc2
and MapViewOfFile3 (and it's NT counterpart NtMapViewOfSectionEx),
we can skip searching for free space in the specific regions
and just call these functions and let the OS do the job more
efficiently and less racy.

Use the new functions on W10 1803 and later in mmap.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-04-07 17:42:02 +02:00
Corinna Vinschen e18f7f99cc Cygwin: memory: declare extended memory API
Windows 10 1803 introduced an extended memory API allowing
to specify memory regions allocations are to be taken off.

In preparation of using this API, define the struct
MEM_EXTENDED_PARAMETER and friends.  Declare and allow to
autoload the functions VirtualAlloc2 and NtMapViewOfSectionEx.

Introduce a wincap flag has_extended_mem_api.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-04-07 17:42:02 +02:00
Corinna Vinschen ccb3a40dad Cygwin: threads: add missing include of mmap_alloc.h
This is needed for using mmap_alloc.alloc()

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-04-07 17:42:02 +02:00
Corinna Vinschen e8ae404440 Cygwin: threads: lower thread size from pool to 256 Megs
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-04-07 14:18:08 +02:00
Corinna Vinschen aa4d960306 Cygwin: threads: use mmap area to fulfill requests for big stacks
Otherwise big stacks have a higher probability to collide with
randomized PEBs and TEBs after fork.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-04-07 14:18:08 +02:00
Corinna Vinschen ece49e4090 Cygwin: symlinks: Allow traversing WSL symlinks
Unfortunately Windows doesn't understand WSL symlinks,
despite being a really easy job.  NT functions trying
to access paths traversing WSL symlinks return the status
code STATUS_IO_REPARSE_TAG_NOT_HANDLED.  Handle this
status code same as STATUS_OBJECT_PATH_NOT_FOUND in
symlink_info::check to align behaviour to traversing
paths with other non-NTFS type symlinks.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-04-05 16:18:05 +02:00
Corinna Vinschen 44fe41a766 Cygwin: docs: revamp docs explaining symlinks
The descriptions of symlink handling are a bit dated, so
revamp them and add the new WSL symlink type.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-04-03 21:44:00 +02:00
Corinna Vinschen 44da5e4b8c Cygwin: symlinks: create WSL symlinks on supporting filesystems
WSL symlinks are reparse points containing a POSIX path in UTF-8.
On filesystems supporting reparse points, use this symlink type.
On other filesystems, or in case of error, fall back to the good
old plain SYSTEM file.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-04-03 21:40:01 +02:00
Corinna Vinschen fb834beebe Cygwin: symlinks: fix WSL symlinks pointing to /mnt
Commit 4a36897af3 allowed to convert /mnt/<drive> path
prefixes to Cygwin cygdrive prefixes on the fly.  However,
the patch neglected WSL symlinks pointing to the /mnt
directory.  Rearrange path conversion so /mnt is converted
to the cygdrive prefix path itself.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-04-02 22:25:55 +02:00
Biswapriyo Nath 1171927f1a winsup/cygwin: remove defines added in mingw-w64 v7.0.0
Signed-off-by: Biswapriyo Nath <nathbappai@gmail.com>
2020-04-01 11:15:25 +02:00
Corinna Vinschen 4a36897af3 Cygwin: symlinks: support WSL symlinks
Treat WSL symlinks just like other symlinks.  Convert
absolute paths pointing to Windows drives via
/mnt/<driveletter> to Windows-style paths <driveletter>:

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-03-27 12:12:31 +01:00
Corinna Vinschen d2e0b65a7f Cygwin: serial: fix GCC warning
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-03-26 14:13:37 +01:00
Keith Packard via Newlib 6295d75913 newlib/libm/math: Make pow/powf return qnan for snan arg
The IEEE spec for pow only has special case for x**0 and 1**y when x/y
are quiet NaN. For signaling NaN, the general case applies and these functions
should signal the invalid exception and return a quiet NaN.

Signed-off-by: Keith Packard <keithp@keithp.com>
2020-03-26 12:21:33 +01:00
Keith Packard via Newlib 3439f3b0e9 newlib/libm/common: Don't re-convert float to bits in modf/modff
These functions shared a pattern of re-converting the argument to bits
when returning +/-0. Skip that as the initial conversion still has the
sign bit.

Signed-off-by: Keith Packard <keithp@keithp.com>
2020-03-26 12:21:33 +01:00