]> sourceware.org Git - newlib-cygwin.git/log
newlib-cygwin.git
3 years agosys/stat.h: Enable UTIME_NOW and UTIME_OMIT for RTEMS
Joel Sherrill [Wed, 19 May 2021 18:43:25 +0000 (13:43 -0500)]
sys/stat.h: Enable UTIME_NOW and UTIME_OMIT for RTEMS

3 years agoCygwin: autoload: fix case in DLL name for sanity
Corinna Vinschen [Thu, 20 May 2021 07:59:00 +0000 (09:59 +0200)]
Cygwin: autoload: fix case in DLL name for sanity

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: Add missing IsWow64Process2 declaration
Corinna Vinschen [Thu, 20 May 2021 08:03:34 +0000 (10:03 +0200)]
Cygwin: Add missing IsWow64Process2 declaration

The previous patch is accidentally missing the declaration of
IsWow64Process2.  Add it belatedly.

Fixes: 1865a41cb383 ("Cygwin: suppress FAST_CWD warnings on ARM64")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: suppress FAST_CWD warnings on ARM64
Jeremy Drake [Wed, 19 May 2021 09:43:48 +0000 (11:43 +0200)]
Cygwin: suppress FAST_CWD warnings on ARM64

The old check was insufficient: new insider preview builds of Windows
allow running x86_64 process on ARM64.  The IsWow64Process2 function
seems to be the intended way to figure this situation out.

3 years agoCygwin: Handle virtual drives as non-symlinks
Jeremy Drake [Wed, 19 May 2021 12:40:23 +0000 (14:40 +0200)]
Cygwin: Handle virtual drives as non-symlinks

This avoids MAX_PATH-related problems in native tools in case the
virtual drive points to a deep directory

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: POSIX message queues: simplify sync object creation
Corinna Vinschen [Wed, 12 May 2021 09:04:44 +0000 (11:04 +0200)]
Cygwin: POSIX message queues: simplify sync object creation

Introduce new inline function mq_ipc_init to create all three
required sync objects.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: Use parallel make on AppVeyor
Jon Turney [Sat, 1 May 2021 00:33:24 +0000 (01:33 +0100)]
Cygwin: Use parallel make on AppVeyor

We're bumping up against the 1hr free job duration limit on AppVeyor, so
use 'make -j$(nproc)' to allow things to build slightly faster.

Restructure the way build_script: is written in YAML, so it's slightly less
repetitive and easier to add that.

Also skip 'make check' on x86, since it currently just hangs. :(

3 years agoGet rid of relative include paths in strace.cc
Jon Turney [Sun, 9 May 2021 15:03:49 +0000 (16:03 +0100)]
Get rid of relative include paths in strace.cc

3 years agoMove source files used in utils/mingw/ into that subdirectory
Jon Turney [Tue, 27 Apr 2021 22:41:07 +0000 (23:41 +0100)]
Move source files used in utils/mingw/ into that subdirectory

Move all the source files used in utils/mingw/ into that subdirectory,
so the built objects are in the expected place.

(path.cc requires some more unpicking, and even then there is genuinely
some shared code, so use a trivial file which includes the real path.cc
so the object file is generated where expected)

3 years agoUnpick cygpath TESTSUITE
Jon Turney [Wed, 28 Apr 2021 13:54:47 +0000 (14:54 +0100)]
Unpick cygpath TESTSUITE

Rather than having testsuite.h do various things, depending on defines,
just have it do one thing, and then explicitly redirect to test stubs in
path.cc when building test.

3 years agoCygwin: fetch Windows directory on all platforms and use throughout
Corinna Vinschen [Fri, 7 May 2021 21:05:24 +0000 (23:05 +0200)]
Cygwin: fetch Windows directory on all platforms and use throughout

Rather than fetching the system Windows directory at dll init time
only on 32 bit, fetch it on all platforms.  Store as WCHAR and
UNICODE_STRING.  Use where appropriate to simplify code.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: path_conv: Rework handling native symlinks as inner path components
Corinna Vinschen [Fri, 7 May 2021 14:07:03 +0000 (16:07 +0200)]
Cygwin: path_conv: Rework handling native symlinks as inner path components

commit 456c3a46386f was only going half-way.  It handled symlinks and
junction points as inner path components and made realpath return the
correct path, but it ignored drive letter substitution, i. e., virtual
drives created with, e. g.

  subst X: C:\foo\bar

It was also too simple.  Just returning an error code from
symlink_info::check puts an unnecessary onus on the symlink evaluation
loop in path_conv::check.

Rework the code to use GetFinalPathNameByHandle, and only do this after
checking the current file for being a symlink failed.

If the final path returned by GetFinalPathNameByHandle is not the same
as the incoming path, replace the incoming path with the POSIXified
final path.  This also short-circuits path evaluation, because
path_conv::check doesn't have to recurse over the inner path components
multiple times if all symlinks are of a native type, while still getting
the final path as end result.

Virtual drives are now handled like symlinks.  This is a necessary change
from before to make sure virtual drives are handled identically across
different access methods.  An example is realpath(1) from coreutils.  It
doesn't call readlink(2), but iterates over all path components using
lstat/readlink calls.  Both methods should result in the same real path.

Fixes: 456c3a46386f ("path_conv: Try to handle native symlinks more sanely")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: revert handwritten tags/ctags target, take 2
Corinna Vinschen [Thu, 6 May 2021 11:35:26 +0000 (13:35 +0200)]
Cygwin: revert handwritten tags/ctags target, take 2

Fix accidental checkin of the wrong test version

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: revert handwritten tags/ctags target
Corinna Vinschen [Thu, 6 May 2021 09:12:46 +0000 (11:12 +0200)]
Cygwin: revert handwritten tags/ctags target

Converting to automake dropped the former, handwritten tags/ctags
target.  This leads to a couple of problems:

- For no good reason the tags file gets written to the builddir
  instead of to the srcdir where it's needed.

- `make tags' requires etags to exist, rather than checking if it
  exists and skipping it.

- Adding the extra ctags arguments to AM_CTAGSFLAGS still results
  in a shortened tags file.

(Temporary?) solution: Revert the old tags/ctags rules and silence
the automake warnings.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: autogen.sh: Allow running from any directory
Corinna Vinschen [Thu, 6 May 2021 08:56:20 +0000 (10:56 +0200)]
Cygwin: autogen.sh: Allow running from any directory

autogen.sh expects to run from within the winsup dir, so
set CWD accordingly before running autotools.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoNano-malloc: Fix for unwanted external heap fragmentation
Ola Olsson [Mon, 26 Apr 2021 08:57:02 +0000 (10:57 +0200)]
Nano-malloc: Fix for unwanted external heap fragmentation

The only reason why it is tough for us to use nano malloc
is because of the small shortcoming where nano_malloc()
splits a bigger chunk from the free list into two pieces
while handing back the second one (the tail) to the user.
This is error prone and especially bad for smaller heaps,
where nano malloc is supposed to be superior. The normal
malloc doesn't have this issue and we need to use it even
though it costs us ~2k bytes compared to nano-malloc.

The problem arise especially after giving back _every_
malloced memory to the heap and then starting to exercise
the heap again by allocating something small. This small
item might split the whole heap in two equally big parts
depending on how the heap has been exercised before.

I have uploaded the smallest possible application
(only tested on ST and Nordic devices) to show the issue
while the real customer applications are far more complicated:
https://drive.google.com/file/d/1kfSC2KOm3Os3mI7EBd-U0j63qVs8xMbt/view?usp=sharing

The application works like the following pseudo code,
where we assume a heap of 100 bytes
(I haven't taken padding and other nitty and gritty
details into account. Everything to simplify understanding):

void *ptr = malloc(52); // We get 52 bytes and we have
                        // 48 bytes to use.
free(ptr); // Hand back the 52 bytes to nano_malloc
           // This is the magic line that shows the issue of
           // nano_malloc
ptr = malloc(1); // Nano malloc will split the 52 bytes
                 // in the free list and hand you a pointer
                 // somewhere in the
                 // middle of the heap.
ptr2 = malloc(52); // Out of memory...

I have done a fix which hands back the first part of the
splitted chunk. Once this is fixed we obviously
have the 1 byte placed in position 0 of the heap instead
of somewhere in the middle.

However, this won't let us malloc 52 new bytes even though
we potentially have 99 bytes left to use in the heap. The
reason is that when we try to do the allocation,
nano-malloc looks into the free list and sees a 51 byte
chunk to be used.
This is not big enough so nano-malloc decides to call
sbrk for _another_ 52 bytes which is not possible since
there is only 48 bytes left to ask for.

The solution for this problem is to check if the last
item in the free list is adjacent to sbrk(0). If it is,
as it is in this case, we can just ask sbrk for the
remainder of what is needed. In this case 1 byte.

NB! I have only tested the solution on our ST device.

3 years agoCygwin: Ensure toollibdir exists before installing a link there
Jon Turney [Fri, 30 Apr 2021 17:14:55 +0000 (18:14 +0100)]
Cygwin: Ensure toollibdir exists before installing a link there

This helps 'make install -j2' work.

3 years agoformat_proc_swaps: ensure space between fields for clarity
Brian Inglis [Fri, 30 Apr 2021 13:19:20 +0000 (07:19 -0600)]
format_proc_swaps: ensure space between fields for clarity

page/swap space name >= 40 or size/used >= 8 leaves no space between fields;
ensure a space after name and add extra tabs after size and used fields;
output appears like Linux 5.8 after changes to mm/swapfile(swap_show);

proc-swaps-space-before.log:
==> /proc/swaps <==
Filename Type Size Used Priority
/mnt/c/pagefile.sys                     file            11567748292920  0
/mnt/d/pagefile.sys                     file            12582912205960  0

proc-swaps-space-after.log:
==> /proc/swaps <==
Filename Type Size Used Priority
/mnt/c/pagefile.sys file 11567748 241024 0
/mnt/d/pagefile.sys file 12582912 182928 0

3 years agoCygwin: mq_open: set filesize using ftruncate
Corinna Vinschen [Fri, 30 Apr 2021 16:15:20 +0000 (18:15 +0200)]
Cygwin: mq_open: set filesize using ftruncate

ftruncate is leaner than lseek/write.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: CI configuration update
Jon Turney [Tue, 27 Oct 2020 16:29:45 +0000 (16:29 +0000)]
Cygwin: CI configuration update

Install autoconf and automake, and run winsup/autogen.sh, and don't have
it silently ignore failures.

On AppVeyor:
- use latest VM image, to reduce time spent installing updates.
- run the testsuite, but ignore the result, as some tests don't work
correctly.
- hardcode the python-lxml and python-ply packages to install, so we get
ones for the right python.
- install texlive collections now needed to build documentation.

On github:
- Use a copr for cocom, since RPMSphere's package updates don't track
fedora:latest very efficently.

3 years agoCygwin: POSIX mq: avoid double calls to ipc_mutex_unlock
Corinna Vinschen [Fri, 30 Apr 2021 08:30:21 +0000 (10:30 +0200)]
Cygwin: POSIX mq: avoid double calls to ipc_mutex_unlock

_mq_send as well as _mq_receive call ipc_mutex_unlock twice in case
of success, after having introduced __try/__except blocks.

Fixes: 3f3bd10104550 ("* Throughout, use __try/__except/__endtry blocks, rather than myfault handler.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: POSIX mq: only allo priority up to MQ_PRIO_MAX - 1
Corinna Vinschen [Thu, 29 Apr 2021 18:04:24 +0000 (20:04 +0200)]
Cygwin: POSIX mq: only allo priority up to MQ_PRIO_MAX - 1

POSIX requires that message priorities range from 0 (low) to
sysconf(_SC_MQ_PRIO_MAX) - 1 (high).  Cygwin's mq_send erroneously
allowed a message priority of sysconf(_SC_MQ_PRIO_MAX).  Fix it.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: FAQ: building-cygwin: accomodate autoconf changes
Corinna Vinschen [Thu, 29 Apr 2021 10:07:00 +0000 (12:07 +0200)]
Cygwin: FAQ: building-cygwin: accomodate autoconf changes

- also, rephrase slightly for better readability and
  remove questionable old cruft

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: automake: change @INCLUDES@ to @AM_CPPFLAGS@ to avoid warnings
Corinna Vinschen [Thu, 29 Apr 2021 09:23:11 +0000 (11:23 +0200)]
Cygwin: automake: change @INCLUDES@ to @AM_CPPFLAGS@ to avoid warnings

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: automake: fix warning in terms of the `ps' target
Corinna Vinschen [Thu, 29 Apr 2021 08:59:29 +0000 (10:59 +0200)]
Cygwin: automake: fix warning in terms of the `ps' target

We are building a ps executable, but the rule to build the target
collides with an auto-generated, documentation-related `ps' rule.

Work around that by naming the executable "cygps" at build time
and use a transform rule to rename it at installation time.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: specify toollibdir toolincludedir in terms of tooldir
Jon Turney [Wed, 28 Apr 2021 09:46:02 +0000 (11:46 +0200)]
Cygwin: specify toollibdir toolincludedir in terms of tooldir

Specify toollibdir and toolincludedir in terms of tooldir, so the
install location is correct if tooldir is the default
($(exec_prefix)/$(target_alias)), or explicitly specified on the 'make'
command line.

3 years agoCygwin: drop all generated autotools files
Corinna Vinschen [Wed, 28 Apr 2021 10:03:52 +0000 (12:03 +0200)]
Cygwin: drop all generated autotools files

- add autotool files generated under winsup to .gitignore

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoformat_proc_cpuinfo: add v_spec_ctrl, bus_lock_detect
Brian Inglis [Tue, 27 Apr 2021 23:28:52 +0000 (17:28 -0600)]
format_proc_cpuinfo: add v_spec_ctrl, bus_lock_detect

Linux 5.12 Frozen Wasteland added features and changes:
add AMD 0x8000000a EDX:20 v_spec_ctrl virtual speculation control support
add Intel 0x00000007 ECX:24 bus_lock_detect bus lock detect debug exception

3 years agoCygwin: tty.h: devices.h is a local header, not a system header
Corinna Vinschen [Tue, 27 Apr 2021 19:25:29 +0000 (21:25 +0200)]
Cygwin: tty.h: devices.h is a local header, not a system header

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: Use automake (v5)
Jon Turney [Tue, 6 Oct 2020 15:11:54 +0000 (16:11 +0100)]
Cygwin: Use automake (v5)

v2:
* Include tzmap.h in BUILT_SOURCES
* Make per-file flags appear after user-supplied CXXFLAGS, so they can
override optimization level.
* Correct .o files used to define symbols exported by libm.a
* Drop gcrt0.o mistakenly included in libgmon.a
* Add missing line continuations in GMON_FILES value

v3:
* use per-file flags for .c compilation
* override C{XX,}FLAGS, as they are set on the command line by top-level make

v4:
* Drop -Wno-error=write-strings from path_testsuite CXXFLAGS

v5:
* Update for changes in master
- Add -fno-threadsafe-statics to CXX flags
- Add hypotl.cc
- Remove fenv.cc (in favour of newlib), add fenv.c stub
- Add proc.5 manpage rules

3 years agoCygwin: connect: implement resetting a connected DGRAM socket
Ken Brown [Fri, 23 Apr 2021 22:17:57 +0000 (18:17 -0400)]
Cygwin: connect: implement resetting a connected DGRAM socket

Following POSIX and Linux, allow a connected DGRAM socket's connection
to be reset (so that the socket becomes unconnected).  This is done by
calling connect and specifing an address whose family is AF_UNSPEC.

3 years agoCygwin: connect: set connect state for DGRAM sockets
Ken Brown [Fri, 23 Apr 2021 18:40:07 +0000 (14:40 -0400)]
Cygwin: connect: set connect state for DGRAM sockets

When connect is called on a DGRAM socket, the call to Winsock's
connect can immediately return successfully rather than failing with
WSAEWOULDBLOCK.  Set the connect state to "connected" in this case.

Previously the connect state remained "connect_pending" after the
successful connection.

3 years agobfin: add myself as maintainer
Mike Frysinger [Sun, 25 Apr 2021 17:23:07 +0000 (13:23 -0400)]
bfin: add myself as maintainer

3 years agoCygwin: pty: Add missing guard for close_pseudoconsole().
Takashi Yano [Wed, 21 Apr 2021 03:07:31 +0000 (12:07 +0900)]
Cygwin: pty: Add missing guard for close_pseudoconsole().

- This patch adds a missing mutex guard for close_pseudoconsole()
  call when GDB exits.

3 years agoCygwin: pty: Fix fallback processing in setup_pseudoconsole().
Takashi Yano [Wed, 21 Apr 2021 03:06:43 +0000 (12:06 +0900)]
Cygwin: pty: Fix fallback processing in setup_pseudoconsole().

- Currently, the fallback processing in setup_pseudoconsole()
  when helper process error occurs does not work properly.
  This patch fixes the issue.

3 years agoCygwin: pty: Additional race issue fix regarding pseudo console.
Takashi Yano [Wed, 21 Apr 2021 03:06:00 +0000 (12:06 +0900)]
Cygwin: pty: Additional race issue fix regarding pseudo console.

- In commit bb93c6d7, the race issue was not completely fixed. In
  the pseudo console inheritance, if the destination process to
  which the ownership of pseudo console switches, is found but exits
  before switching, the inheritance fails. Currently, this extremely
  rarely happens. This patch fixes the issue.

3 years agoCygwin: skip native symlink check in Windows dir under WOW64
Corinna Vinschen [Wed, 21 Apr 2021 15:32:06 +0000 (17:32 +0200)]
Cygwin: skip native symlink check in Windows dir under WOW64

Commit 456c3a46386f added a workaround when handling paths with native
symlinks as inner path components.  This patch introduced a problem for
paths handled by the WOW64 File System Redirector (FSR).

Fix this problem by not performing the new code from commit 456c3a46386f
for paths under the Windows directory.  Only do this in WOW64.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agofix some Arm FP routines not checking if floating point is enabled
Ties Stuij [Wed, 21 Apr 2021 12:48:03 +0000 (13:48 +0100)]
fix some Arm FP routines not checking if floating point is enabled

A lot of the Arm FP routines check for the availability of floating point by way
of `(__ARM_FP & 0x4)`. However some do not. This patch remedies this.

3 years agoCygwin: add 3.2.1 release file and add fixes up to this point
Corinna Vinschen [Tue, 20 Apr 2021 08:46:01 +0000 (10:46 +0200)]
Cygwin: add 3.2.1 release file and add fixes up to this point

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: pty: Make rlwrap work with cmd.exe.
Takashi Yano [Mon, 19 Apr 2021 11:51:53 +0000 (20:51 +0900)]
Cygwin: pty: Make rlwrap work with cmd.exe.

- After the commit 919dea66, "rlwrap cmd" fails to start pseudo
  console. This patch fixes the issue.

3 years agoCygwin: pty: Fix race issue in inheritance of pseudo console.
Takashi Yano [Mon, 19 Apr 2021 10:30:46 +0000 (19:30 +0900)]
Cygwin: pty: Fix race issue in inheritance of pseudo console.

- If multiple non-cygwin processes are started/ended simultaneously,
  inheritance of pseudo console sometimes fails. This patch fixes
  the issue.

  Addresses:
    https://cygwin.com/pipermail/cygwin/2021-April/248292.html

3 years agoCygwin: console: Fix race issue regarding cons_master_thread().
Takashi Yano [Mon, 19 Apr 2021 10:30:45 +0000 (19:30 +0900)]
Cygwin: console: Fix race issue regarding cons_master_thread().

- With this patch, the race issue regarding starting/stopping
  cons_master_thread() introduced by commit ff4440fc is fixed.

  Addresses:
    https://cygwin.com/pipermail/cygwin/2021-April/248292.html

3 years agoscanf: allow hex float input per POSIX
Corinna Vinschen [Mon, 19 Apr 2021 19:59:56 +0000 (21:59 +0200)]
scanf: allow hex float input per POSIX

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: console: Fix a bug in the code to fix tab position.
Takashi Yano [Mon, 19 Apr 2021 10:31:51 +0000 (19:31 +0900)]
Cygwin: console: Fix a bug in the code to fix tab position.

- With this patch, a bug in the code to fix tab position after
  resizing window is fixed.

3 years agoCygwin: path_conv: Try to handle native symlinks more sanely
Corinna Vinschen [Mon, 19 Apr 2021 12:49:14 +0000 (14:49 +0200)]
Cygwin: path_conv: Try to handle native symlinks more sanely

For local paths, add a check if the inner path components contain native
symlinks or junctions.  Compare the incoming path with the path returned
by NtQueryInformationFile(FileNameInformation).  If they differ, there
must be at least one native symlink or junction in the path.  If so,
treat the currently evaluated file as non-existant.  This forces
path_conv::check to backtrack inner path components until we eliminated
all native symlinks or junctions and have a normalized path.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: take hypotl function from Mingw-w64
Corinna Vinschen [Mon, 19 Apr 2021 10:37:44 +0000 (12:37 +0200)]
Cygwin: take hypotl function from Mingw-w64

The simple newlib hypotl for real long double architectures is too
simple at this point.  It's implemented as a real call to sqrtl(x^2+y^2).
This has a fatal tendency to overflow for big input numbers.  Hypotl
isn't supposed to do that if the result would still be valid in range of
long double.

Given the complexity of implementing hypotl for various architectures,
we just take the hypotl function from Mingw-w64, which is in the public
domain.

Even though this hypotl is an architecture-independent implementation,
we can't use it for newlib yet, unfortunately, because it requires logbl
under the hood.  Logbl is yet another function missing in newlib for
real long double architectures.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agofenv: fix up stub file comment, drop symlinks from description
David Macek [Wed, 7 Apr 2021 08:49:00 +0000 (10:49 +0200)]
fenv: fix up stub file comment, drop symlinks from description

also slightly fixed up formatting

3 years agoCygwin: fix fenv.h includes
Corinna Vinschen [Tue, 6 Apr 2021 09:51:21 +0000 (11:51 +0200)]
Cygwin: fix fenv.h includes

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: don't export _feinitialise from newlib
Corinna Vinschen [Wed, 24 Mar 2021 10:06:58 +0000 (11:06 +0100)]
Cygwin: don't export _feinitialise from newlib

Use the more official fesetenv(FE_DFL_ENV) from _dll_crt0, thus
allowing to drop the _feinitialise declaration from fenv.h.

Provide a no-op _feinitialise in Cygwin as exportable symbol for really
old applications when _feinitialise was called from mainCRTStartup in
crt0.o.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agofenv: drop Cygwin-specific implementation in favor of newlib code
Corinna Vinschen [Wed, 24 Mar 2021 09:58:56 +0000 (10:58 +0100)]
fenv: drop Cygwin-specific implementation in favor of newlib code

Drop the Cygwin-specific fenv.cc and fenv.h file and use the equivalent
newlib functionality now, so we have at least one example of a user for
this new mechanism.

fenv.c: allow _feinitialise to be called from Cygwin startup code

fenv.h: add declarations for fegetprec and fesetprec for Cygwin only.
        Fix a comment.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agofenv: move shared x86 fenv.c to libm/machine/shared_x86
Corinna Vinschen [Wed, 24 Mar 2021 09:51:20 +0000 (10:51 +0100)]
fenv: move shared x86 fenv.c to libm/machine/shared_x86

Include this file from both sharing architectures, i386 and x86_64.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agofenv: Move shared x86 sys/fenv.h from x86_64 to shared_x86
Corinna Vinschen [Wed, 24 Mar 2021 09:48:34 +0000 (10:48 +0100)]
fenv: Move shared x86 sys/fenv.h from x86_64 to shared_x86

drop matching symlink in i386

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agofenv: add missing declarations to x86 fenv.h
Corinna Vinschen [Wed, 24 Mar 2021 09:44:00 +0000 (10:44 +0100)]
fenv: add missing declarations to x86 fenv.h

feenableexcept, fedisableexcept and fegetexcept were
accidentally missing in the x86 fenv.h

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoconfigure.host: define shared ix86 and x86_64 directory
Corinna Vinschen [Wed, 24 Mar 2021 09:35:28 +0000 (10:35 +0100)]
configure.host: define shared ix86 and x86_64 directory

Add a directory libc/machine/shared_x86 to share header files
between ix86 and x86_64 architectures.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoAdd build mechanism to share common header files between machines
Corinna Vinschen [Wed, 24 Mar 2021 09:32:50 +0000 (10:32 +0100)]
Add build mechanism to share common header files between machines

So far the build mechanism in newlib only allowed to either define
machine-specific headers, or headers shared between all machines.
In some cases, architectures are sufficiently alike to share header
files between them, but not with other architectures.  A good example
is ix86 vs. x86_64, which share certain traits with each other, but
not with other architectures.

Introduce a new configure variable called "shared_machine_dir".  This
dir can then be used for headers shared between architectures.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoRISC-V: Using SYS_clock_gettime64 for rv32 libgloss.
Kito Cheng [Tue, 13 Apr 2021 09:33:03 +0000 (17:33 +0800)]
RISC-V: Using SYS_clock_gettime64 for rv32 libgloss.

 - RISC-V 32 bits linux/glibc didn't provide gettimeofday anymore
   after upstream, because RV32 didn't have backward compatible issue,
   so RV32 only support 64 bits time related system call.

 - So using clock_gettime64 call instead for rv32 libgloss.

3 years agoCygwin: select: set_bits: fix return value
Ken Brown [Wed, 7 Apr 2021 15:43:27 +0000 (11:43 -0400)]
Cygwin: select: set_bits: fix return value

If a socket descriptor is set to ready for reading on a failed
connect, increment the return value.

3 years agoCygwin: select: Fix FD_CLOSE handling
Corinna Vinschen [Tue, 6 Apr 2021 19:35:43 +0000 (21:35 +0200)]
Cygwin: select: Fix FD_CLOSE handling

An FD_CLOSE event sets a socket descriptor ready for writing.
This is incorrect if the FD_CLOSE is a result of shutdown(SHUT_RD).
Only set the socket descriptor ready for writing if the FD_CLOSE
is indicating an connection abort or reset error condition.

This requires to tweak fhandler_socket_wsock::evaluate_events.
FD_CLOSE in conjunction with FD_ACCEPT/FD_CONNECT special cases
a shutdown condition by setting an error code.  This is correct
for accept/connect, but not for select.  In this case, make sure
to return with an error code only if FD_CLOSE indicates a
connection error.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: select: don't set ready for exception on socket shutdown
Corinna Vinschen [Tue, 6 Apr 2021 19:26:33 +0000 (21:26 +0200)]
Cygwin: select: don't set ready for exception on socket shutdown

So far select wrongly sets the descriptor as ready for exception
when a shutdown occurs.  This is entirely non-standard.  Only set
this bit on an out-of-band event.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: pty: Use atexit() instead of hooking exit() for GDB.
Takashi Yano [Tue, 6 Apr 2021 00:40:13 +0000 (09:40 +0900)]
Cygwin: pty: Use atexit() instead of hooking exit() for GDB.

- This patch utilizes atexit() instead of hooking exit() to clean
  up pseudo console stuff when debugging non-cygwin app using GDB.

3 years agoCygwin: pty: Use find_exec() rather than path_conv::check().
Takashi Yano [Mon, 5 Apr 2021 08:32:13 +0000 (17:32 +0900)]
Cygwin: pty: Use find_exec() rather than path_conv::check().

- With this patch, find_exec() rather than path_conv::check() is used
  in order to enable searching executable file in the path.

3 years agoCygwin: fhandler: Rename handles from XXX_cyg/XXX to XXX/XXX_nat.
Takashi Yano [Mon, 5 Apr 2021 08:30:41 +0000 (17:30 +0900)]
Cygwin: fhandler: Rename handles from XXX_cyg/XXX to XXX/XXX_nat.

- Currently, functions/variables regarding the handles for cygwin
  apps are with "_cyg", and those of handles for non-cygwin apps
  are without "_cyg", such as get_handle_cyg() and get_handle().
  This patch renames these to the names without "_nat" and with
  "_nat" respectively, such as get_handle() and get_handle_nat().

3 years agoCygwin: bump DLL version to 3.2.1
Corinna Vinschen [Mon, 29 Mar 2021 19:00:09 +0000 (21:00 +0200)]
Cygwin: bump DLL version to 3.2.1

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: add "app execution aliases" treatment to release notes cygwin-3_2_0-release
Corinna Vinschen [Tue, 23 Mar 2021 15:54:23 +0000 (16:54 +0100)]
Cygwin: add "app execution aliases" treatment to release notes

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: Treat Windows Store's "app execution aliases" as symbolic links
Johannes Schindelin [Mon, 22 Mar 2021 15:51:41 +0000 (16:51 +0100)]
Cygwin: Treat Windows Store's "app execution aliases" as symbolic links

When the Windows Store version of Python is installed, so-called "app
execution aliases" are put into the `PATH`. These are reparse points
under the hood, with an undocumented format.

We do know a bit about this format, though, as per the excellent analysis:
https://www.tiraniddo.dev/2019/09/overview-of-windows-execution-aliases.html

The first 4 bytes is the reparse tag, in this case it's
0x8000001B which is documented in the Windows SDK as
IO_REPARSE_TAG_APPEXECLINK. Unfortunately there doesn't seem to
be a corresponding structure, but with a bit of reverse
engineering we can work out the format is as follows:

Version: <4 byte integer>
Package ID: <NUL Terminated Unicode String>
Entry Point: <NUL Terminated Unicode String>
Executable: <NUL Terminated Unicode String>
Application Type: <NUL Terminated Unicode String>

Let's treat them as symbolic links. For example, in this developer's
setup, this will result in the following nice output:

$ cd $LOCALAPPDATA/Microsoft/WindowsApps/

$ ls -l python3.exe
lrwxrwxrwx 1 me 4096 105 Aug 23  2020 python3.exe -> '/c/Program Files/WindowsApps/PythonSoftwareFoundation.Python.3.7_3.7.2544.0_x64__qbz5n2kfra8p0/python.exe'

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
3 years agoCygwin: Allow executing Windows Store's "app execution aliases"
Johannes Schindelin [Mon, 22 Mar 2021 15:51:48 +0000 (16:51 +0100)]
Cygwin: Allow executing Windows Store's "app execution aliases"

The Windows Store version of Python (and apparently other Windows Store
applications) install a special reparse point called "app execution
alias" into the user's `PATH`.

These applications can be executed without any problem, but they cannot
be read as if they were files. This trips up Cygwin's beautiful logic that
tries to determine whether we're about to execute a Cygwin executable or
not: instead of executing the application, it will fail, saying
"Permission denied".

Let's detect this situation (`NtOpenFile()` helpfully says that this
operation is not supported on this reparse point type), and simply skip
the logic: Windows Store apps are not Cygwin executables (and even if
they were, it is unlikely that they would come with a compatible
`cygwin1.dll` or `msys-2.0.dll`).

This fixes https://github.com/msys2/MSYS2-packages/issues/1943

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
3 years agoCygwin: pty: Rename input/output named pipes.
Takashi Yano via Cygwin-patches [Tue, 23 Mar 2021 11:50:28 +0000 (20:50 +0900)]
Cygwin: pty: Rename input/output named pipes.

- Currently, names of output pipes are "pty%d-to-master" and "pty%d-
  to-master-cyg" and names of input pipes are "pty%d-to-slave" and
  "pty%d-from-master". With this patch, these pipes are renamed to
  "pty%d-to-master-nat", "pty%d-to-master", "pty%d-from-master-nat"
  and "pty%d-from-master" respectively.

3 years agoCygwin: pty: Transfer input only if the stdin is a pty.
Takashi Yano via Cygwin-patches [Tue, 9 Mar 2021 03:23:34 +0000 (12:23 +0900)]
Cygwin: pty: Transfer input only if the stdin is a pty.

- The commit 12325677f73a did not fix enough. With this patch, more
  transfer_input() calls are skipped if stdin is redirected or piped.

3 years agoCygwin: update release notes for 3.2.0, part 5
Corinna Vinschen [Tue, 9 Mar 2021 10:07:31 +0000 (11:07 +0100)]
Cygwin: update release notes for 3.2.0, part 5

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: update release notes for 3.2.0, part 4
Corinna Vinschen [Tue, 9 Mar 2021 09:06:03 +0000 (10:06 +0100)]
Cygwin: update release notes for 3.2.0, part 4

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: pty: Transfer input for native app only if the stdin is pcon.
Takashi Yano via Cygwin-patches [Mon, 8 Mar 2021 14:55:10 +0000 (23:55 +0900)]
Cygwin: pty: Transfer input for native app only if the stdin is pcon.

- Currently, transfer input is triggered even if the stdin of native
  app is not a pseudo console. With this patch it is triggered only
  if the stdin is a pseudo console.

3 years agoCygwin: update release notes for 3.2.0
Ken Brown [Mon, 8 Mar 2021 14:51:32 +0000 (09:51 -0500)]
Cygwin: update release notes for 3.2.0

3 years agoCygwin: pty: Attach to stub process when non-cygwin app inherits pcon.
Takashi Yano via Cygwin-patches [Mon, 8 Mar 2021 13:14:58 +0000 (22:14 +0900)]
Cygwin: pty: Attach to stub process when non-cygwin app inherits pcon.

- If two non-cygwin apps are started simultaneously, attaching to
  pseudo console sometimes fails. This is because the second app
  trys to attach to the process not started yet. This patch avoids
  the issue by attaching to the stub process rather than the other
  non-cygwin app.

3 years agoCygwin: update release notes for 3.2.0, part 2
Corinna Vinschen [Mon, 8 Mar 2021 10:38:27 +0000 (11:38 +0100)]
Cygwin: update release notes for 3.2.0, part 2

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: update release notes for 3.2.0
Corinna Vinschen [Mon, 8 Mar 2021 10:34:46 +0000 (11:34 +0100)]
Cygwin: update release notes for 3.2.0

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: console, pty: Stop ignoring Ctrl-C by IGNBRK.
Takashi Yano via Cygwin-patches [Sun, 7 Mar 2021 01:41:11 +0000 (10:41 +0900)]
Cygwin: console, pty: Stop ignoring Ctrl-C by IGNBRK.

- Perhaps current code misunderstand meaning of the IGNBRK. As far
  as I investigated, IGNBRK is concerned with break signal in serial
  port but there is no evidence that it has effect to ignore Ctrl-C.
  This patch stops ignoring Ctrl-C by IGNBRK for non-cygwin apps.

3 years agoCygwin: pty: Discard input already accepted on interrupt.
Takashi Yano via Cygwin-patches [Fri, 5 Mar 2021 09:01:50 +0000 (18:01 +0900)]
Cygwin: pty: Discard input already accepted on interrupt.

- Currently, input already accepted is not discarded on interrupt
  by VINTR, VQUIT and VSUSP keys. This patch fixes the issue.

3 years agoRevert "Cygwin: Make sure newer apps get uname_x even when loading uname dynamically"
Corinna Vinschen [Sun, 7 Mar 2021 11:17:57 +0000 (12:17 +0100)]
Revert "Cygwin: Make sure newer apps get uname_x even when loading uname dynamically"

This reverts commit 532b91d24e9496c7988b2b1dda7fc0e8b161f782.

It turned out that this patch has undesired side effects.  To wit, if a
newer, post-uname_x executable was linked against or loading an older,
pre-uname_x DLL, and this DLL called uname.  This call would jump into
the old uname with the old struct utsname as parameter, but given the
newer executable it would get redirected to uname_x.  uname_x in turn
would overwrite stack memory it should leave well alone, given it
expects the newer, larger struct utsname.

For the entire discussion see the thread starting at
https://cygwin.com/pipermail/cygwin/2021-February/247870.html
and continuing in March at
https://cygwin.com/pipermail/cygwin/2021-March/247930.html
For a description where we're coming from, see
https://cygwin.com/pipermail/cygwin/2021-March/247959.html

While we *could* make the scenario in question work by patching dlsym,
the problem would actually be the same, just for dynamic loading.  In
the end, we're missing the information, which Cygwin version has been
used when building DLLs.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoRegenerate lib/posix/Makefile.in
Jeff Johnston [Fri, 5 Mar 2021 20:23:24 +0000 (15:23 -0500)]
Regenerate lib/posix/Makefile.in

3 years agoCygwin: console: Fix restoring console mode failure.
Takashi Yano via Cygwin-patches [Thu, 4 Mar 2021 10:11:08 +0000 (19:11 +0900)]
Cygwin: console: Fix restoring console mode failure.

- Restoring console mode fails in the following scenario.
   1) Start cygwin shell in command prompt.
   2) Run 'exec chcp.com'.
  This patch fixes the issue.

3 years agoCygwin: pty: Fix a race issue in startup of pseudo console.
Takashi Yano via Cygwin-patches [Thu, 4 Mar 2021 08:56:34 +0000 (17:56 +0900)]
Cygwin: pty: Fix a race issue in startup of pseudo console.

- If two non-cygwin apps are started simultaneously and this is the
  first execution of non-cygwin apps in the pty, these occasionally
  hang up. The cause is the race issue between term_has_pcon_cap(),
  reset_switch_to_pcon() and setup_pseudoconsole(). This patch fixes
  the issue.

3 years agoCygwin: simplify linkat with AT_EMPTY_PATH
Ken Brown [Thu, 25 Feb 2021 12:54:10 +0000 (07:54 -0500)]
Cygwin: simplify linkat with AT_EMPTY_PATH

linkat(olddirfd, oldpath, oldname, newdirfd, newname, AT_EMPTY_PATH)
is supposed to create a link to the file referenced by olddirfd if
oldname is the empty string.  Currently this is done via the /proc
filesystem by converting the call to

  linkat(AT_FDCWD, "/proc/self/fd/<olddirfd>", newdirfd, newname,
         AT_SYMLINK_FOLLOW),

which ultimately leads to a call to the appropriate fhandler's link
method.  Simplify this by using cygheap_fdget to obtain the fhandler
directly.

3 years agoCygwin: fix linkat(2) on sockets that are not socket files
Ken Brown [Wed, 24 Feb 2021 15:43:15 +0000 (10:43 -0500)]
Cygwin: fix linkat(2) on sockets that are not socket files

If linkat(2) is called with AT_EMPTY_PATH on an AF_LOCAL or
AF_UNIX socket that is not a socket file, the current code calls
fhandler_disk_file::link in most cases.  The latter expects to be
operating on a disk file and uses the socket's io_handle, which
is not a file handle.

Fix this by calling fhandler_disk_file::link only if the
fhandler_socket object is a file (determined by testing
dev().isfs()).

Also fix the case of a socket file opened with O_PATH by setting
the fhandler_disk_file's io_handle.

3 years agoCygwin: fix facl on sockets that are not socket files
Ken Brown [Mon, 22 Feb 2021 15:13:09 +0000 (10:13 -0500)]
Cygwin: fix facl on sockets that are not socket files

If facl(2) is called on an AF_LOCAL or AF_UNIX socket that is not a
socket file, the current code calls fhandler_disk_file::facl in most
cases.  The latter expects to be operating on a disk file and uses the
socket's io_handle, which is not a file handle.

Fix this by calling fhandler_disk_file::facl only if the
fhandler_socket object is a file (determined by testing dev().isfs()).

3 years agoCygwin: fix fchown on sockets that are not socket files
Ken Brown [Mon, 22 Feb 2021 14:50:34 +0000 (09:50 -0500)]
Cygwin: fix fchown on sockets that are not socket files

If fchown(2) is called on an AF_LOCAL or AF_UNIX socket that is not a
socket file, the current code calls fhandler_disk_file::fchown in most
cases.  The latter expects to be operating on a disk file and uses the
socket's io_handle, which is not a file handle.

Fix this by calling fhandler_disk_file::fchown only if the
fhandler_socket object is a file (determined by testing dev().isfs()).

3 years agoCygwin: fix fchmod on sockets that are not socket files
Ken Brown [Mon, 22 Feb 2021 14:34:36 +0000 (09:34 -0500)]
Cygwin: fix fchmod on sockets that are not socket files

If fchmod(2) is called on an AF_LOCAL or AF_UNIX socket that is not a
socket file, the current code calls fhandler_disk_file::fchmod in most
cases.  The latter expects to be operating on a disk file and uses the
socket's io_handle, which is not a file handle.

Fix this by calling fhandler_disk_file::fchmod only if the
fhandler_socket object is a file (determined by testing dev().isfs()).

3 years agoCygwin: fix fstatvfs on sockets that are not socket files
Ken Brown [Mon, 22 Feb 2021 14:21:00 +0000 (09:21 -0500)]
Cygwin: fix fstatvfs on sockets that are not socket files

If fstatvfs(2) is called on an AF_LOCAL or AF_UNIX socket that is not
a socket file, the current code calls fhandler_disk_file::fstatvfs in
most cases.  The latter expects to be operating on a disk file and
uses the socket's io_handle, which is not a file handle.

Fix this by calling fhandler_disk_file::fstatvfs only if the
fhandler_socket object is a socket file (determined by testing
dev().isfs()).

3 years agoCygwin: fix fstat on sockets that are not socket files
Ken Brown [Mon, 22 Feb 2021 14:08:04 +0000 (09:08 -0500)]
Cygwin: fix fstat on sockets that are not socket files

If fstat(2) is called on an AF_LOCAL or AF_UNIX socket that is not a
socket file, the current code calls fstat_fs.  The latter expects to
be operating on a disk file and uses the socket's io_handle, which is
not a file handle.

Fix this by calling fstat_fs only if the fhandler_socket object is a
file (determined by testing dev().isfs()).

3 years agoRISC-V: Fix optimized strcmp on big endian
Marcus Comstedt [Tue, 23 Feb 2021 21:31:17 +0000 (22:31 +0100)]
RISC-V: Fix optimized strcmp on big endian

3 years agoSet __IEEE_BIG_ENDIAN for big endian RISC-V
Marcus Comstedt [Tue, 23 Feb 2021 21:31:16 +0000 (22:31 +0100)]
Set __IEEE_BIG_ENDIAN for big endian RISC-V

3 years agoCygwin: facl: fail with EBADF on files opened with O_PATH
Ken Brown [Tue, 23 Feb 2021 22:07:00 +0000 (17:07 -0500)]
Cygwin: facl: fail with EBADF on files opened with O_PATH

This is in the spirit of the Linux requirement that file operations
like fchmod(2), fchown(2), and fgetxattr(2) fail with EBADF on files
opened with O_PATH.

3 years agoCygwin: AF_UNIX: allow opening with the O_PATH flag
Ken Brown [Tue, 23 Feb 2021 16:48:46 +0000 (11:48 -0500)]
Cygwin: AF_UNIX: allow opening with the O_PATH flag

This was done for the fhandler_socket_local class in commits
3a2191653a141437d374, and 477121317d, but the fhandler_socket_unix
class was overlooked.

3 years agoBump config.guess and config.sub
Kito Cheng [Tue, 23 Feb 2021 08:14:36 +0000 (16:14 +0800)]
Bump config.guess and config.sub

Hi:

RISC-V has added big-endian support recently, which require config.*
stuff update, and we'll send further patch for fix big-endian build,
so I believe this fundamental change should upstream first.

Import upstream 2021-01-25.
Upstream sha1 6faca61810d335c7837f320733fe8e15a1431fc2

3 years agoCygwin: console: Prevent NULL pointer access in close().
Takashi Yano via Cygwin-patches [Mon, 22 Feb 2021 13:30:17 +0000 (22:30 +0900)]
Cygwin: console: Prevent NULL pointer access in close().

- There seems to be a case that shared_console_info is not set yet
  when close() is called. This patch adds guard for such case.

3 years agoCygwin: pty: Fix segfault caused when tcflush() is called.
Takashi Yano via Cygwin-patches [Sat, 20 Feb 2021 22:45:16 +0000 (07:45 +0900)]
Cygwin: pty: Fix segfault caused when tcflush() is called.

- After commit 253352e796ff9ec9a447e5375f5bc3e2b92b5293, mc (midnight
  commander) crashes with segfault if the shell is bash. This is due
  to NULL pointer access in read(). This patch fixes the issue.
  Addresses::
    https://cygwin.com/pipermail/cygwin/2021-February/247870.html

3 years agoCygwin: FIFO: temporarily keep a conv_handle in syscalls.cc:open
Ken Brown [Tue, 9 Feb 2021 17:11:02 +0000 (12:11 -0500)]
Cygwin: FIFO: temporarily keep a conv_handle in syscalls.cc:open

When a FIFO is opened, syscalls.cc:open always calls fstat on the
newly-created fhandler_fifo.  This results from a call to
device_access_denied.

To speed-up this fstat call, and therefore the open(2) call, use
PC_KEEP_HANDLE when the fhandler is created.  The resulting
conv_handle is retained until after the fstat call if the fhandler is
a FIFO; otherwise, it is closed immediately.

3 years agoCygwin: fstat_helper: always use handle in call to get_file_attribute
Ken Brown [Thu, 11 Feb 2021 02:15:20 +0000 (21:15 -0500)]
Cygwin: fstat_helper: always use handle in call to get_file_attribute

Previously, the call to get_file_attribute for FIFOs set the first
argument to NULL instead of the handle h returned by get_stat_handle,
thereby forcing the file to be opened for fetching the security
descriptor in get_file_sd().  This was done because h might have been
a pipe handle rather than a file handle, and its permissions would not
necessarily reflect those of the file.

That situation can no longer occur with the new fhandler_fifo::fstat
introduced in the previous commit.

3 years agoCygwin: define fhandler_fifo::fstat
Ken Brown [Thu, 18 Feb 2021 15:18:41 +0000 (10:18 -0500)]
Cygwin: define fhandler_fifo::fstat

Previously fstat on a FIFO would call fhandler_base::fstat.

The latter is not appropriate if fhandler_fifo::open has already been
called (and O_PATH is not set), for the following reason.  If a FIFO
has been opened as a writer or duplexer, then it has an io_handle that
is a pipe handle rather than a file handle.  fhandler_base::fstat will
use this handle and potentially return incorrect results.  If the FIFO
has been opened as a reader, then it has no io_handle, and a call to
fhandler_base::fstat will lead to a call to fhandler_base::open.
Opening the fhandler a second time can change it in undesired ways;
for example, it can modify the flags and status_flags.

The new fhandler_fifo::fstat avoids these problems by creating an
fhandler_disk_file and calling its fstat method in case
fhandler_fifo::open has already been called and O_PATH is not set.

3 years agoCygwin: realpath: fix cygwin installation dir being access via junction
Corinna Vinschen [Fri, 19 Feb 2021 17:15:58 +0000 (18:15 +0100)]
Cygwin: realpath: fix cygwin installation dir being access via junction

Consider this case:

- Cygwin installed in C:\cygwin64

- mklink /j D:\cygwin64 C:\cygwin64

- create testcase calling

    realpath("/", result);
    printf ("%s\n", result);

- start cmd

    >C:\cygwin64\bin\bash -lc <path-to-testcase>
    /
    >D\cygwin64\bin\bash -lc <path-to-testcase>
    /cygdrive/c/cygwin64

This scenario circumventing the mount point handling which is automated
in terms of /, depending on the path returned from GetModuleFileNameW
for the Cygwin DLL.  When calling D:\cygwin64\bin\bash the dir returned
from GetModuleFileNameW is D:\cygwin64\bin, thus root is D:\cygwin64.

However, junctions are treated as symlinks in Cygwin which explains why
the path gets converted to a cygdrive path.

Fix this by calling GetFinalPathNameByHandleW on the result from
GetModuleFileNameW to get the correct root path, even if accessed via
a junction point.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: default to O_BINARY in fhandler_base::reset_to_open_binmode()
Corinna Vinschen [Fri, 19 Feb 2021 17:12:37 +0000 (18:12 +0100)]
Cygwin: default to O_BINARY in fhandler_base::reset_to_open_binmode()

This only affects the very seldom bordercase of apps calling setmode(fd,
0) on fhandlers not calling fhandler_base::set_open_status().  All
fhandlers not calling set_open_status() are binary mode only, but the
way reset_to_open_binmode worked, calling setmode(fd, 0) would have
"reset" their open flags to O_TEXT accidentally.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This page took 0.070784 seconds and 5 git commands to generate.