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>
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.
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>
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>
commit 456c3a4638 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: 456c3a4638 ("path_conv: Try to handle native symlinks more sanely")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
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>
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
_mq_send as well as _mq_receive call ipc_mutex_unlock twice in case
of success, after having introduced __try/__except blocks.
Fixes: 3f3bd10104 ("* Throughout, use __try/__except/__endtry blocks, rather than myfault handler.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
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>
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.
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
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
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.
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.
- 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.
Commit 456c3a4638 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 456c3a4638
for paths under the Windows directory. Only do this in WOW64.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
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>
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>
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>
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>
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>
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>
- 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().
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>
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>
- 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.
- 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.