4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-02-28 12:05:47 +08:00

21933 Commits

Author SHA1 Message Date
Corinna Vinschen
82b541a475 Cygwin: fix gcc-15 const warnings
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-02-27 15:29:10 +01:00
Corinna Vinschen
d4a5c2be8b Cygwin: fhandler_netdrive: fix character conversion required for NFS shares
While filenames on NFS shares are converted internally to a widechar
representation of the input bytes treated as the default system ANSI
codepage (CP_ACP), this doesn't hold for share names.  The names
returned by WNetEnumResourceW are just the original bytes dropped
verbatim into WCHAR.

The original conversion from 7db1c6fc4e2a ("Cygwin: //server: revert
to using WNet and support NFS shares") was erroneous in that it
treated the bytes as ISO-8859-1, not as CP_ACP codepoints.

Fix the conversion to convert from CP_ACP to widechar.  Use a tmp_pathbuf
buffer for the new widechar string instead of malloc/free.  Extend the
comment, better explaining the encoding difference between files and
shares.

Fixes: 7db1c6fc4e2a ("Cygwin: //server: revert to using WNet and support NFS shares")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-02-27 13:51:39 +01:00
Corinna Vinschen
dc094c7665 Cygwin: fix gcc-14 false positive warnings
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-02-27 12:17:23 +01:00
Corinna Vinschen
5e435a20b5 Cygwin: if_nametoindex: fix a 'use-after-free" uncovered by gcc-14
Fixes: b91d38db37d8 ("Cygwin: net: Make if_nametoindex, etc. consistent with if_nameindex.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-02-27 12:16:45 +01:00
Corinna Vinschen
caf4d02034 Cygwin: fix "-Werror=overloaded-virtual" errors since gcc-13
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-02-27 10:00:55 +01:00
Mark Geisert
2a2fd29916 Cygwin: Add spawn family of functions to docs
In the doc tree, add a new section "Other system interfaces[...]" that
lists the spawn family of functions, most of the exposed cygwin internal
functions that a user might have use for, and some other functions
duplicating Windows or DOS interfaces that might have some utility.
2025-02-27 10:00:19 +01:00
Corinna Vinschen
15b52ba69d Cygwin: fhandler_netdrive: support enumerating connected disks
Some providers don't implement share enumeration.  Allow to find
the server's connected resources in this case.  Enable this feature
for the WNNC_NET_DAV provider.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-02-26 20:15:18 +01:00
Corinna Vinschen
809c212093 Cygwin: fhandler_netdrive: try harder to find shares of weird providers
For some provider types, WNetGetResourceInformationW fails, namely
WNNC_NET_DAV.  When that happens, try to find the server's provider
by enumerating all WNet containers from the top.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-02-26 20:12:09 +01:00
Corinna Vinschen
323729f654 Cygwin: fhandler_netdrive: rework share enumeration
- As before, first try NFS for dotted names, but additionally check if
  the NFS profvider is installed.
- Next try *any* provider (i.e. provider = 0). Move the necessary
  heuristics into thread_netdrive_wnet with lots of comments.
- Last, but not least, if the server was already tried for NFS,
  but WNetGetResourceInformationW returns WNNC_NET_MS_NFS again
  when trying any provider, bail out and retry with SMB, since
  many NFS servers could be SMB servers as well.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-02-26 15:37:56 +01:00
Corinna Vinschen
230f4802ed Cygwin: pipes: fix error handling when creating a pipe
The nt_create() function returns a Windows error code, but
it only calls NT functions.  In one case, it returns the
Windows error code without converting the NT status code
to a Windows error code first.

To fix this mess, change nt_create() to a function returning
the NT status code directly. Let the (only) caller handle
the conversion from NT status code to errno value.

Reported-by: "knut st. osmundsen" <bird-cygwin@anduin.net>
Fixes: f56206cd86b9 ("Cygwin: fhandler_pipe: fix permission problem")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-02-26 09:45:04 +01:00
Corinna Vinschen
2164981d26 Cygwin: document posix_close
Reported-by: Christian Franke <Christian.Franke@t-online.de>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-02-26 09:45:04 +01:00
Corinna Vinschen
4bcc6adec7 Cygwin: pipe_data_available: drop special casing select
After 11a84cc757ef ("Cygwin: fix SSH hangs"), select returns
writability if any number of bytes are left in the buffer.
Thus, the reason for pipe_data_available() to return PIPE_BUF
when called from select() is gone, and we can drop special casing
select().

So together with 11a84cc757ef ("Cygwin: fix SSH hangs"), this
patch essentially reverts 555afcb2f3a6 ("Cygwin: select: set pipe
writable only if PIPE_BUF bytes left")

Rather than reverting the flag parameter to a bool, keep a mode
argument set to PDA_READ or PDA_WRITE.  If we can't evaluate
the number of bytes left, just return 1 to select(), as for any
other caller.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-02-25 10:29:29 +01:00
Johannes Schindelin
11a84cc757 Cygwin: fix SSH hangs
It was reported in https://github.com/git-for-windows/git/issues/5199
that as of v3.5.4, cloning or fetching via SSH is hanging indefinitely.

Bisecting the problem points to 555afcb2f3 (Cygwin: select: set pipe
writable only if PIPE_BUF bytes left, 2024-08-18). That commit's
intention seems to look at the write buffer, and only report the pipe as
writable if there are more than one page (4kB) available.

However, the number that is looked up is the number of bytes that are
already in the buffer, ready to be read, and further analysis
shows that in the scenario described in the report, the number of
available bytes is substantially below `PIPE_BUF`, but as long as they
are not handled, there is apparently a dead-lock.

Since the old logic worked, and the new logic causes a dead-lock, let's
essentially revert 555afcb2f3a6 ("Cygwin: select: set pipe writable only if
PIPE_BUF bytes left").

Note: This is not a straight revert, as the code in question has been
modified subsequently, and trying to revert the original commit would
cause merge conflicts. Therefore, the diff looks very different from the
reverse diff of the commit whose logic is reverted.

Fixes: 555afcb2f3a6 ("Cygwin: select: set pipe writable only if PIPE_BUF bytes left")
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2025-02-24 22:33:44 +01:00
Christian Franke
78ff40d78e Cygwin: FAQ: Add section about sparse files
Signed-off-by: Christian Franke <christian.franke@t-online.de>
2025-02-24 18:12:00 +01:00
Corinna Vinschen
7aae9f323a Cygwin: fhandler_netdrive: use correct thread names
Fix the cygthread names used for debugging when calling the
thread_netdrive_wnet thread, so they actually show the provider
getting enumerated.

Fixes: 7db1c6fc4e2a ("Cygwin: //server: revert to using WNet and support NFS shares")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-02-24 16:52:27 +01:00
Corinna Vinschen
01bcd7d29e Cygwin: fhandler_netdrive: skip enumerating WebDAV shares
So far there's no known way to enumerate connected WebDAV resources.
WNetGetResourceInformationW/WNetOpenEnumW both return ERROR_BAD_NET_NAME.

Windows Explorer also shows an error dialog when trying to open a
Nextcloud instance to see the shares.

However, `net use' enumerates the connected cloud shares, so
there must be a way to do this.

For the time being, we just don't even try to enumerate WebDAV
shares and return an empty list.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-02-24 16:42:01 +01:00
Corinna Vinschen
7124d1c23d Cygwin: fhandler_netdrive: don't enumerate NFS shares on WebDAV server
WebDAV resources trigger the code trying to enumerate NFS shares
on the server.  Disable this by checking for an at-sign as well.

Fixes: 8cebbb2b42bf ("Cygwin: fhandler_netdrive::exists: handle WebDAV URLs")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-02-24 16:35:46 +01:00
Corinna Vinschen
5f9cc2a6ab Cygwin: winsup/doc/posix.xml: add posix_close doc
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-02-24 12:27:55 +01:00
Corinna Vinschen
004e95cf35 Cygwin: winsup/doc/posix.xml: add missing POSIX.1e functions to docs
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-02-24 11:49:00 +01:00
Brian Inglis
117feceea9 Cygwin: winsup/doc/posix.xml: SUS V5 POSIX 2024 combine multiple notes
Combine multiple notes after an entry separated by hyphen ") (" -> " - "

Signed-off-by: Brian Inglis <Brian.Inglis@SystematicSW.ab.ca>
2025-02-24 11:42:11 +01:00
Brian Inglis
8fd4966195 Cygwin: winsup/doc/posix.xml: move wrongly sorted entries
Fix some entries not in sorting order.

Signed-off-by: Brian Inglis <Brian.Inglis@SystematicSW.ab.ca>
2025-02-24 11:41:17 +01:00
Brian Inglis
32b39f2b02 Cygwin: winsup/doc/posix.xml: SUS V5 POSIX 2024 move or remove dropped entries
Move entries no longer in POSIX from the SUS/POSIX section to
Deprecated Interfaces section and mark with (SUSv4).
Remove entries no longer in POSIX from the NOT Implemented section.

Signed-off-by: Brian Inglis <Brian.Inglis@SystematicSW.ab.ca>
2025-02-24 11:39:40 +01:00
Brian Inglis
1e58e7d5d5 Cygwin: winsup/doc/posix.xml: SUS V5 POSIX 2024 not implemented new additions
Add unavailable POSIX additions to Not Implemented section.

Signed-off-by: Brian Inglis <Brian.Inglis@SystematicSW.ab.ca>
2025-02-24 11:34:37 +01:00
Brian Inglis
3dc2707bf9 Cygwin: winsup/doc/posix.xml: SUS V5 POSIX 2024 new additions available
Add POSIX new additions available as header macros and inline functions,
or exported by Cygwin distro DLL or library packages

Signed-off-by: Brian Inglis <Brian.Inglis@SystematicSW.ab.ca>
2025-02-24 11:28:49 +01:00
Brian Inglis
b1eb09167a Cygwin: winsup/doc/posix.xml: SUS V5 POSIX 2024 TOG Issue 8 ISO 9945 move new POSIX
Update anchor id and description to current version, year, issue, etc.
Move new POSIX entries in other sections to the SUS/POSIX section.

Signed-off-by: Brian Inglis <Brian.Inglis@SystematicSW.ab.ca>
2025-02-24 10:12:08 +01:00
Corinna Vinschen
8cebbb2b42 Cygwin: fhandler_netdrive::exists: handle WebDAV URLs
WebDAV URLs may contain an at-sign followed by a port number or SSL.
This will throw GetAddrInfoW, so remove the at-sign prior to calling
GetAddrInfoW.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-02-21 21:56:03 +01:00
Christian Franke
5e16fd9887 Cygwin: sched_setscheduler: Fix crash if pid of other process is used
Add missing PID_MAP_RW to allow changes of _pinfo::sched_policy.

Fixes: 48b189245a13 ("Cygwin: sched_setscheduler: accept SCHED_OTHER, SCHED_FIFO and SCHED_RR")
Signed-off-by: Christian Franke <christian.franke@t-online.de>
2025-02-21 21:25:17 +01:00
Dimitar Dimitrov
fee0d9bc19
pru: libgloss: Remove duplicate function declaration
Commit 8a8fb570d7c5310a03a34b3dd6f9f8bb35ee9f40 introduced a declaration
for "print", which conflicts with the incompatible declaration in
pru/putnumc.c.

Fix by removing the duplicate in pru/putnum.c, and rely on the
declaration in "glue.h".

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
2025-02-21 20:55:00 +02:00
Volodymyr Turanskyy
8c0250e429 Add check for clang to avoid unnecessary FPU directives
This improves compatibility with clang that does not support vfpxd and does not need these extra directives.

Change-Id: Id2027e622aef8457ac9c7e1d6715a9240ce8e3f0
2025-02-21 15:32:15 +00:00
Volodymyr Turanskyy
af2cd59ff8 Use .p2align 2 instead of .align 0
This is to improve compatibility with LLVM clang: .align 0 is a special case for GCC that is not handled by clang.

Change-Id: I855939a32294c74813ecce7275a362265dbc3b1a
2025-02-21 15:17:22 +00:00
Volodymyr Turanskyy
214d0b65dd libgloss: arm: Clean up assembly syntax for clang compatibility
* Use mrc p15 co-processor instruction syntax.
* Align register_names so that we can use ADR rather than ADRL.

Change-Id: I005cd5a1fc55ec8eba90929c6c70d6a202b0746d
2025-02-21 15:04:24 +00:00
Corinna Vinschen
8cc55d819b Cygwin: fhandler_netdrive::exists: fix new debug statement
The debug statement was wrong twice: Not only was it in the wrong
spot, it was also supposed to print the share name and missed to
add said argument.

Fixes: df307349a09e ("Cygwin: fhandler_netdrive::exists: add debug statement")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-02-21 10:51:51 +01:00
Corinna Vinschen
df307349a0 Cygwin: fhandler_netdrive::exists: add debug statement
Add a debug_printf printing the return code from GetAddrInfoW.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-02-20 20:28:01 +01:00
Roger Sayle
8a8fb570d7 Fix mips libgloss support
* glue.h (print): Provide prototype.
        * kill.c: Prototype _exit with noreturn attribute.
        * mips/cfe_mem.c (memtop): Change to a pointer type.
        (__libcfe_meminit): Add casts to avoid compilation
        warnings/errors.
        * mips/cma101.c: Prototype __cpu_timer_poll and __cpu_flush.
        (convertbcd): Update K&R-style function declaration.
        (time): Likewise.
        * mips/nullmon.c (get_mem_info): Likewise.
        * mips/syscalls.c: Declare struct s_mem and prototype get_mem_info.
        (sbrk): Update K&R-style function declaration.  Add casts to avoid
        compilation warnings/errors.
        * mips/test.c: Prototype outbyte and print. Fix return type of main.
        * print.c (print): Make ptr argument const char*.
        * putnum.c: Remove print prototype, which is now in glue.h.
        * write.c: Remove outbyte prototype, which is now in glue.h.

    Co-authored-by: Mike Frysinger  <vapier@gentoo.org>
2025-02-19 15:42:23 -05:00
Jeremy Drake via Cygwin-patches
78fb13d21f Cygwin: skip floppy drives in cygdrive_getmntent.
This was previously done, but was lost when the function was updated to
list all Windows mount points, not just drive letters.

Fixes: 04a5b072940cc ("Cygwin: expose all windows volume mount points.")
Signed-off-by: Jeremy Drake <cygwin@jdrake.com>
2025-02-19 20:11:40 +01:00
Jeremy Drake via Cygwin-patches
e49de2adea Cygwin: include network mounts in cygdrive_getmntent.
After migrating from GetLogicalDrives to Find(First|Next)VolumeW, mapped
network drives no longer showed up in getmntent output.  To fix that,
also iterate GetLogicalDriveStringsW when builing dos_drive_mappings,
and merge with volume mounts (skipping any volume mounts that are just
mounted on the root of a drive, and replacing the dos mounts in the
mapping for a volume which is mounted on both a drive root and a
directory).

Fixes: 04a5b072940cc ("Cygwin: expose all windows volume mount points.")
Addresses: https://cygwin.com/pipermail/cygwin/2025-February/257384.html
Signed-off-by: Jeremy Drake <cygwin@jdrake.com>
2025-02-19 09:53:14 +01:00
Corinna Vinschen
5790c180d1 Cygwin: pathnames.xml: sparse mount option is always set on SSDs
Reported by: Christian Franke <Christian.Franke@t-online.de>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-02-17 11:16:42 +01:00
Corinna Vinschen
ed18acfe8c strcasecmp family: cast character to unsigned when calling tolower
The strcasecmp family of functions (strcasecmp, strncasecmp,
strcasecmp_l, strncasecmp_l) call tolower on the incoming
character before comparison.  tolower takes an int as parameter.
All four strcasecmp functions neglect to cast the character to
unsigned before using it as parameter to tolower.  This tolower
is called with negative values if the incoming character is not
in the ASCII range.  This breaks case-insensitive comparison in
other singlebyte codesets like ISO-8859-1 with native characters.

Adding casts to unsigned char when calling tolower fixes it.

Reported-by: Bruno Haible <bruno@clisp.org>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-02-17 10:52:28 +01:00
Christian Franke
4dd859d01c unistd.h: enable SEEK_DATA and SEEK_HOLE also for POSIX-1.2024
https://pubs.opengroup.org/onlinepubs/9799919799/functions/lseek.html

Signed-off-by: Christian Franke <christian.franke@t-online.de>
2025-02-14 15:57:22 +01:00
Corinna Vinschen
fac7441835 Cygwin: lseek: fix an off-by-one condition in SEEK_DATA/SEEK_HOLE
The conditional checking if lseek should return ENXIO checks the
offset being bigger than the current filesize, but accidentally not
for being equal to the current filesize.

This can lead to an endless loop in newer versions of cp(1).

Fixes: edfa581d3c5a7 ("Cygwin: lseek: implement SEEK_DATA and SEEK_HOLE for files")
Reported-by: Christian Franke <Christian.Franke@t-online.de>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-02-14 15:10:01 +01:00
Corinna Vinschen
6363caef2d Cygwin: pathnames.xml: explain dir mounts since 3.6.0
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-02-14 12:24:03 +01:00
Corinna Vinschen
701cec0aa1 Cygwin: pathnames.xml: improve chapters mount-table and cygdrive
Fix case in example output of mount and a bunch of clumsy expressions
and descriptions in the cygdrive section.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-02-14 12:23:16 +01:00
Corinna Vinschen
9bcb273f41 Cygwin: new-features.xml: transfer 3.6.0 release message to docs
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-02-14 11:57:52 +01:00
Corinna Vinschen
b50c195218 Cygwin: new-features.xml: drop two dashes remaining from copy/paste
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-02-14 11:57:52 +01:00
Jeremy Drake via Cygwin-patches
93f390c798 Cygwin: 3.6.0: add release entries for my patches.
These are:
  04a5b07294 Cygwin: expose all windows volume mount points.
  0d113da235 Cygwin: /proc/<PID>/mount*: escape strings.
  7923059bff Cygwin: uname: add host machine tag to sysname.
  b091b47b9e cygthread: suspend thread before terminating.

Signed-off-by: Jeremy Drake <cygwin@jdrake.com>
2025-02-14 10:54:30 +01:00
Jeremy Drake via Cygwin-patches
d4497366b4 Cygwin: always output cygdrive mntents.
Previously, if there was an explicit mount entry for a drive letter
(say, C:), the output of the corresponding cygdrive mntent (like
/cygdrive/c) would be suppressed.  Once Windows directory mounts were
added to cygdrive mounts, the de-duplication code got more complicated.
Instead, always output the cygdrive mounts, under the cygdrive prefix.

Addresses: https://cygwin.com/pipermail/cygwin-patches/2025q1/013367.html
Signed-off-by: Jeremy Drake <cygwin@jdrake.com>
2025-02-13 15:12:09 +01:00
Jeremy Drake via Cygwin-patches
04a5b07294 Cygwin: expose all windows volume mount points.
They are exposed via the getmntent API and proc filesystem entries
dealing with mounts.  This allows things like `df` to show volumes
that are only mounted on directories, not on drive letters.

Addresses: https://cygwin.com/pipermail/cygwin/2025-February/257251.html
Signed-off-by: Jeremy Drake <cygwin@jdrake.com>
2025-02-13 15:12:09 +01:00
Jeremy Drake via Cygwin-patches
dcb963b672 Cygwin: store list of mounts for volumes in dos_drive_mappings.
The existing code only stored the first mount for each volume, but now
we store the complete list, and split it into a linked list.  This will
be used in a subsequent commit to populate cygdrive mount entries.

Signed-off-by: Jeremy Drake <cygwin@jdrake.com>
2025-02-13 15:12:09 +01:00
Alexey Lapshin
59891375d7 Protect strcat from accessing an unaligend long pointer
- related to Bug libc/32679
2025-02-12 10:25:24 +01:00
Jeff Johnston
a473f960e5 Protect strncat from accessing an unaligend long pointer
- fixes Bug libc/32679
2025-02-11 14:28:33 -05:00