Commit Graph

13898 Commits

Author SHA1 Message Date
Corinna Vinschen 3f2d03a780 Cygwin: remove warnings from testsuite build
- drop unused variable
- remove deprectated usage of std::pointer_to_unary_function.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-01-19 15:11:32 +01:00
Corinna Vinschen d45261f62a Cygwin: replace all `fgrep' with `grep -F'
Unfortunately fgrep is now deprecated in a very pushy way.
Make sure to use grep -F instead all around, even in docs
and comments/

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-01-18 10:53:25 +01:00
Corinna Vinschen 70b27cee0c Cygwin: copy doc changes from commit 241b50a7ab to release notes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-01-17 12:39:50 +01:00
Jon Turney 07cccc74a5
Cygwin: Update documentation for cygwin_stackdump 2024-01-16 14:07:08 +00:00
Jon Turney aa8224826c
Cygwin: Treat api_fatal() similarly to a core-dumping signal
Provide the same debugging opportunities for api_fatal() as we do for a
core-dumping signal:

1) Break into any attached debugger
2) Start JIT debugger (if configured) (keeping these under DEBUGGING doesn't seem helpful)
3) Write a coredump (if rlim_core > 1MB)
4) Write a stackdump (if that failed, or 0 < rlim_core <= 1MB)
2024-01-16 14:07:07 +00:00
Jon Turney a83b93e662
Cygwin: Define and use __WCOREFLAG
Also fix a typo in description of exit status
2024-01-16 14:07:06 +00:00
Jon Turney b7868e7410
Cygwin: Disable writing core dumps by default.
Change the default core limit from unlimited to 0 (disabled)
2024-01-16 14:07:05 +00:00
Jon Turney 91457377d6
Cygwin: Make 'ulimit -c' control writing a coredump
Pre-format a command to be executed on a fatal error to run 'dumper'
(using an absolute path).

Factor out executing a pre-formatted command, so we can use that for
invoking the JIT debugger in try_to_debug() (if error_start is present
in the CYGWIN env var) and to invoke dumper when a fatal error occurs.

On a fatal error, if the core file size limit is greater than 1MB,
invoke dumper to write a core dump. Otherwise, if that limit is greater
than 0, write a .stackdump file, as previously.

Adjust and clarify the associated documentation.

Also: Fix so that the error_start JIT debugger is now invoked, even when
ulimit -c is zero.

Also: Fix uses of console_printf() inside exec_prepared_command(). It's
output is written via the Windows console device, so needs to use
Windows-style line endings.

Also: consistently return non-zero from try_to_debug() if we debugged.

Future work: Truncate or remove the file written, if it exceeds the
maximum size set by the ulimit.

Future work: Using the words "fatal error" could probably be improved
on. This means exiting on one of the "certain signals whose default
action is to cause the process to terminate and produce a core dump
file".
2024-01-16 14:07:03 +00:00
Christian Franke d8c0fb090c Cygwin: introduce close_range(2)
This function closes or sets the close-on-exec flag for a specified
range of file descriptors.  It is available on FreeBSD and Linux.

Signed-off-by: Christian Franke <christian.franke@t-online.de>
2024-01-15 12:52:56 +01:00
Corinna Vinschen 4ecfb5b729 Cygwin: api docs: add missing fallocate
Also add notes in terms of fallocate quirks.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-01-15 11:04:29 +01:00
Jon Turney 241b50a7ab
Cygwin: Clarifications in 3.5 changes doc 2024-01-12 13:40:28 +00:00
Corinna Vinschen 5edd189d1c Cygwin: path.cc: fix comment starting with // but ending in */
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-01-11 13:21:54 +01:00
Jon Turney d11629ddb3
Cygwin: Fix a stray '\n' in cygcheck manpage
Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2024-01-10 16:43:13 +00:00
Corinna Vinschen 94d871eeac Cygwin: check remote drives for being SSDs as well
This enables automatic sparse file support for remote SSDs.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-01-08 11:45:13 +01:00
Corinna Vinschen 0737bda6ff Cygwin: fallocate(2): fix debug output
Fixes: e01c50c7b0 ("Cygwin: introduce fallocate(2)")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-12-05 22:20:48 +01:00
Corinna Vinschen 7f88c8e0b3 Cygwin: fallocate(2): fix offset and length sanity check
- len must not be <= 0
- offset + len must not exceed off_t (max. file size)

Fixes: e01c50c7b0 ("Cygwin: introduce fallocate(2)")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-12-05 22:20:42 +01:00
Corinna Vinschen 295bef07d6 Cygwin: posix_fallocate(3): fix offset and length sanity check
- len must not be <= 0
- offset + len must not exceed off_t (max. file size)

Fixes: 7636b58590 ("* autoload.cc (NtSetInformationFile): Define.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-12-05 22:19:05 +01:00
Corinna Vinschen c0d2f38742 Cygwin: fallocate(2): drop useless zeroing pointer
The out pointer is only used if data_chunk_count is > 0,
so there's no reason to set it to NULL in the error case.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-12-04 10:20:55 +01:00
Corinna Vinschen 10da646880 Cygwin: drop stray fs_info::check_ssd declaration
This is just a leftover from development

Fixes: 8b01c5d690 ("Cygwin: fs_info: check for SSD")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-12-01 09:56:05 +01:00
Corinna Vinschen cb21f8bc56 Cygwin: doc: add missing change to posix_spawnp
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-30 22:38:59 +01:00
Corinna Vinschen 832e91422c Cygwin: sparse support: enable automatic sparsifying of files on SSDs
Given that SSDs don't have a seek penalty, we can enable
automatic sparsifying of files on SSDs, even if the "sparse"
mount option is not set.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-30 22:37:35 +01:00
Corinna Vinschen 8b01c5d690 Cygwin: fs_info: check for SSD
During fs_info::update, check for the file being on an SSD.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-30 22:37:35 +01:00
Corinna Vinschen 61f49ada90 Cygwin: ntdll.h: add missing NtQueryVolumeInformationFile definitions
In preparation of using the FileFsSectorSizeInformation info class,
add a couple of missing definitions.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-30 22:37:35 +01:00
Corinna Vinschen f816787c57 Cygwin: ntdll.h: add missing POBJECT_NAME_INFORMATION
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-30 22:37:35 +01:00
Corinna Vinschen 013de6b097 Cygwin: revert autoloading of DiscardVirtualMemory
Commit a3ae2a7348 ("Cygwin: don't autoload some kernel32 functions")
erroneously removed DiscardVirtualMemory from the list of autloaded
functions.  DiscardVirtualMemory is not available on Windows 8.1.

Fixes: a3ae2a7348 ("Cygwin: don't autoload some kernel32 functions")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-30 22:37:35 +01:00
Jon Turney 127166f707
Cygwin: Add '--names-only' flag to cygcheck
Add '--names-only' flag to cygcheck, to output just the bare package
names.
2023-11-29 14:34:10 +00:00
Corinna Vinschen 65831f88d6 Cygwin: fallocate(2): handle FALLOC_FL_PUNCH_HOLE and FALLOC_FL_ZERO_RANGE
Split fhandler_disk_file::fallocate into multiple methods, each
implementing a different aspect of fallocate(2), thus adding
FALLOC_FL_PUNCH_HOLE and FALLOC_FL_ZERO_RANGE handling.

For more correctly implementing posix_fallocate(3) semantics, make
sure to re-allocate holes in the given range if the file is sparse.

While at it, change the way checking when to make a file sparse.
The rule is now, make file sparse if the hole created by the action
spans at least one sparse block, taking the allocation granularity
of sparse files into account.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-28 10:55:38 +01:00
Corinna Vinschen f64f3eced8 Cygwin: pwrite(2): sparsify file
write(2) sparsifies a file after an lseek far enough beyond EOF.

Let pwrite(2) sparsify as well if offset is far enough beyond EOF.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-28 10:55:38 +01:00
Corinna Vinschen 114f89caff Cygwin: fallocate(2): fix evaluating return value
fallocate is not supposed to return an errno code, it has to
return -1 and set errno.

Fixes: dd90ede40510 ("Cygwin: introduce fallocate(2)")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-28 10:55:38 +01:00
Corinna Vinschen 7f9caa4a36 Cygwin: open(2): reset sparseness on O_TRUNCated files
open(2) implements O_TRUNC by just reducing the size of the file
to 0, to make sure EAs stay available.

Turns out, file sparseness is not removed this way either, so add
code to do just that.

Fixes: 603ef545bd ("* fhandler.cc (fhandler_base::open): Never open files with  FILE_OVERWITE/FILE_OVERWRITE_IF.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-28 10:55:33 +01:00
Corinna Vinschen e01c50c7b0 Cygwin: introduce fallocate(2)
First cut of the new, Linux-specific fallocate(2) function.
Do not add any functionality yet, except of basic handling
of FALLOC_FL_KEEP_SIZE.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-28 10:52:05 +01:00
Corinna Vinschen 23e9b5cf3c Cygwin: fcntl.h: Use cdefs.h macros
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-28 10:52:05 +01:00
Corinna Vinschen f3554bf890 Cygwin: fhandler: rename ftruncate method to fallocate
also, take mode flags parameter instead of just a bool.
Introduce __FALLOC_FL_TRUNCATE mode flag as internal flag to
indictae being called from ftruncate(2).

This is in preparation of an upcoming change introducing the
Linx-specific fallocate(2) call.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-28 10:52:05 +01:00
Corinna Vinschen fedd7fae77 Cygwin: posix_fallocate: return ENODEV
The fhandler method ftruncate returns either EISDIR if it has been
called on directories, or EINVAL if called on files other than
regular files.  This matches what ftruncate(2) is supposed to return,
but it doesn't match posix_fallocate(3), which is supposed to return
ENODEV in both cases.

To accomplish that, return ENODEV from fhandler_base::ftruncate()
and convert it to EINVAL in ftruncate(2). In posix_fallocate(3),
convert EISDIR to ENODEV.

Fixes: 7636b58590 ("* autoload.cc (NtSetInformationFile): Define.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-28 10:51:47 +01:00
Corinna Vinschen d5dcb484c7 Cygwin: lseek: check for file sparseness, not for mount point sparseness
The code introducing the lseek(2) code for the GNU extensions
SEEK_DATA and SEEK_HOLE accidentally checks if the mount point
has the "sparse" flag set and, if not, emulates SEEK_DATA/SEEK_HOLE
per the Linux specs.

However, the mount point "sparse" flag only determines whether
files should be made sparse or not.  Files may be sparse independently
of that, obviously.

Fix that by checking for the FILE_ATTRIBUTE_SPARSE_FILE attribute
instead.

Fixes: edfa581d3c ("Cygwin: lseek: implement SEEK_DATA and SEEK_HOLE for files")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-25 18:07:23 +01:00
Christian Franke 3ef4bb1861 Cygwin: /dev/disk: Append '#N' if the same name appears more than once
No longer drop ranges of identical link names.  Append '#0, #1, ...'
to each name instead.  Enhance charset allowed in label names.
No longer ignore null volume serial numbers.

Signed-off-by: Christian Franke <christian.franke@t-online.de>
2023-11-21 19:40:37 +01:00
Christian Franke d36b4f3f06 Cygwin: /dev/disk/by-uuid: Fix NTFS serial number print format
Signed-off-by: Christian Franke <christian.franke@t-online.de>
2023-11-20 20:59:12 +01:00
Christian Franke 643275ed18 Cygwin: Document /dev/disk/by-* subdirectories
Signed-off-by: Christian Franke <christian.franke@t-online.de>
2023-11-17 20:37:29 +01:00
Christian Franke 41e13e4d9d Cygwin: Add /dev/disk/by-label and /dev/disk/by-uuid symlinks
The new directories '/dev/disk/by-label' and '/dev/disk/by-uuid'
provide symlinks for each disk related volume label and serial
number:
'VOLUME_LABEL' -> '../../sdXN'
'VOLUME_SERIAL' -> '../../sdXN'

Signed-off-by: Christian Franke <christian.franke@t-online.de>
2023-11-17 17:09:42 +01:00
Christian Franke 2cc109be1d Cygwin: Add /dev/disk/by-drive and /dev/disk/by-voluuid symlinks
The new directory '/dev/disk/by-drive' provides symlinks for each
disk related drive letter:
'x' -> '../../sdXN'
The new directory '/dev/disk/by-voluuid' provides symlinks for each
disk related storage volume:
'MBR_SERIAL-OFFSET' -> '../../sdXN'
'VOLUME_GUID' -> '../../sdXN'
Both directories provide Windows specific information and do not
exist on Linux.

Signed-off-by: Christian Franke <christian.franke@t-online.de>
2023-11-17 13:10:20 +01:00
Corinna Vinschen 324ace778f Cygwin: rand(3): implement in terms of random(3)
This makes rand(3) ISO C compliant and adds locking to avoid
race conditions.

Reported-by: Bruno Haible <bruno@clisp.org>
Fixes: 8a0efa53e4 ("import newlib-2000-02-17 snapshot")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-14 17:52:48 +01:00
Mark Geisert c4008b8bc0 Fix profiler error() definition and usage
Minor updates to profiler and gmondump, which share some code:
- fix operation of error() so it actually works as intended
- resize 4K-size auto buffer reservations to BUFSIZ (==1K)
- remove trailing '\n' from 2nd arg on error() calls everywhere
- provide consistent annotation of Windows error number displays

Fixes: 9887fb27f6126 ("Cygwin: New tool: profiler")
Fixes: 087a3d76d7335 ("Cygwin: New tool: gmondump")
Signed-off-by: Mark Geisert <mark@maxrnd.com>
2023-11-14 11:48:11 +01:00
Corinna Vinschen d223f09590 Add release text for random(3) fix
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-13 20:01:54 +01:00
Corinna Vinschen e9c4a281e5 Cygwin: random: drop unused function srandomdev()
Also drop includes only required for srandomdev().

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-13 19:50:15 +01:00
Corinna Vinschen 06e463223b Cygwin: random: make random(3) functions thread-safe
Add locking to the random(3) family of functions to gain
thread-safety per POSIX. Use NetBSD version of the file as
role-model.

Reported-by: Bruno Haible <bruno@clisp.org>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-13 19:49:06 +01:00
Christian Franke 7863c07a92 Cygwin: /dev/disk/by-id: Remove leading spaces from identify fields
Various drives align the serial number to the right of the fixed
length field.

Signed-off-by: Christian Franke <christian.franke@t-online.de>
2023-11-08 20:28:44 +01:00
Christian Franke 7236f22f71 Cygwin: Document /dev/disk/by-id and /dev/disk/by-partuuid
Signed-off-by: Christian Franke <christian.franke@t-online.de>
2023-11-07 16:15:12 +01:00
Christian Franke 1ebef73c59 Cygwin: Add /dev/disk/by-partuuid symlinks
The new directory '/dev/disk/by-partuuid' provides symlinks for each
MBR or GPT disk partition:
'MBR_SERIAL-OFFSET' -> '../../sdXN'
'GPT_GUID' -> '../../sdXN'

Signed-off-by: Christian Franke <christian.franke@t-online.de>
2023-11-07 13:12:04 +01:00
Christian Franke c8cf1933ba Cygwin: Add /dev/disk/by-id symlinks
The new directory '/dev/disk/by-id' provides symlinks for each
disk and its partitions:
'BUSTYPE-[VENDOR_]PRODUCT_SERIAL[-partN]' -> '../../sdX[N]'.
This is based on strings provided by STORAGE_DEVICE_DESCRIPTOR.
If this information is too short, a 128-bit hash of the
STORAGE_DEVICE_UNIQUE_IDENTIFIER raw data is added.
Administrator privileges are not required.

Signed-off-by: Christian Franke <christian.franke@t-online.de>
2023-11-05 17:01:43 +01:00
Corinna Vinschen 2ef627c46e Cygwin: let feraiseexcept actually raise an exception
The exception handling inside of Cygwin functions marked as SIGFE
covers exceptions and lets the library code handle them gracefully.
If these functions want to raise an exception, they have to send a
signal explicitely via raise(3).

That's not what we want in feraiseexcept(). It triggers a floating
point exception explicitely by calling the i387 op "fwait".  Being
marked as SIGFE, this exception will be suppressed and the normal
exception handling won't kick in.

Fix this by moving feraiseexcept into the NOSIGFE realm.

Fixes: 0f81b5d4bc ("* Makefile.in (DLL_OFILES): Add new fenv.o module.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-10-31 13:27:51 +01:00