Even with the commit 3a4c740f59, SNDCTL_DSP_GET[IO]SPACE ioctl()
does not return the fragment set by SNDCTL_DSP_SETFRAGMENT if it
is issued before read()/write(). This patch fixes the issue.
Fixes: 3a4c740f59 ("Cygwin: dsp: Implement SNDCTL_DSP_SETFRAGMENT ioctl().")
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
Handle [=x=] expressions in range brackets. Use the new
is_unicode_equiv() function to perform the check.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Handle [=x=] expressions in range brackets. Use the new
is_unicode_equiv() function to perform the check.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
is_unicode_equiv compares two UTF-32 values and returns 1 if
both are member of the same Unicode equivalence class, 0 otherwise.
Note that this function only works with precomposed characters
per Unicode normalization form C. It doesn't handle decomposed
characters, just like its counterpart in glibc. I.e., equivalence
class comparison using decomposed chars won't work. Example:
fnmatch("[=n=]", "ñ") == 0
fnmatch("[=ñ=]", "n") == 0
but
fnmatch("[=n=]", "n\x0303") == 1
fnmatch("[=n\x0303=]", "n") == 1
fnmatch("[=n\x0303=]", "n\x0303") == 1
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Handle [:<character-class>:] expressions in range brackets.
TODO: Collating symbols [.<collsym>'.] and Equivalence class
expressions [=<equiv-class>=] are recognized but skipped as if
they are not present at all.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Handle [:<character-class>:] expressions in range brackets.
TODO: Collating symbols [.<collsym>'.] and Equivalence class
expressions [=<equiv-class>=] are recognized but skipped as if
they are not present at all.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
- call mbrtowi instead of mbrtowc
- drop Cygwin-only surrogate handling from wgetnext and xmbrtowc since
it's encapsulated in mbrtowi.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
So far the input to __collate_range_cmp was handled as a wchar_t.
Change that to handle it as wint_t holding a UTF-32 value and
add creating surrogate pairs for the call to wcscoll.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Given how UTF-16 isn't capable to hold all Unicode chars in a single
wchar_t, we need a function returning a wint_t value representing
a UTF-32 value for comparison functions. Fortunately the important
wide character functions like towupper/towlower, isw<class>, iswctype,
etc, already take wint_t values and newlib handles them as UTF-32.
If only we had switched wchar_t to 32 bit way back when... sigh.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Avoid the mistake fixed in the preceeding commit by passing
the mode_t argument by reference. This also affects a couple
other functions calling get_posix_access in turn.
Fixes: bc444e5aa4 ("Reapply POSIX ACL changes.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
commit bc444e5aa4 introduced a call to get_posix_access()
with a NULL pointer for the mode_t parameter because the value
is not needed later on... entirely ignoring the fact that the
mode_t bits are checked for the object being a directory.
In turn, the get_posix_access() call never checked for default
ACEs and returned only the standard ACEs. Thus, every chmod call
on a directory dropped the default ACEs from its permissions, as
well as the default NULL deny-ACE used to store specific bits.
It got also impossible to set the sgid bit on directories.
Fixes: bc444e5aa4 ("Reapply POSIX ACL changes.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Older coreutils created directories with mode bits filtered through
umask. Newer coreutils creates directories with full permissions,
0777 by default.
This new coreutils behaviour uncovered the fact that default ACEs for
newly created directories were not filtered by umask starting with
commit bc444e5aa4.
Fix it by applying umask on the default ACEs.
Fixes: bc444e5aa4 ("Reapply POSIX ACL change.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Previously, SNDCTL_DSP_SETFRAGMENT was just a fake. In this patch,
it has been implemented to allow latency control in some apps.
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
fhandler_dev_dsp (OSS) has a problem that waitforallsent(), which is
called from close(), falls into infinite loop if another thread calls
write() accidentally after close(). This patch fixes the issue.
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
The list of invalid chars for server names differs from the
list of invalid chars for share names. Apart from that,
we don't allow control chars in both kinds of names.
Fixes: 6338d2f24a ("Cygwin: mount: allow any valid character in UNC paths")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
The current code only allows server and share names to
start with ASCII chars [a-zA-Z0-9],, which is not correct.
Rather, check for a valid share character.
Fixes: 1fd5e000ac ("import winsup-2000-02-17 snapshot")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
The commit af8a7c13b5 has a problem that fsync returns EINVAL for
block device. This patch treats block devices as a special case.
https://cygwin.com/pipermail/cygwin/2023-January/252916.html
Fixes: af8a7c13b5 ("Cygwin: fsync: Return EINVAL for special files.")
Reported-by: Yano Ray <yanorei@hotmail.co.jp>
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
Previously, fhandler_dev_dsp (OSS) has a problem that fcntl() does
not take effect at all. This patch fixes the issue.
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Eventually move user heap initialization to memory_init.
The call order is not changed. Drop a now useless comment.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
The new loop in open_shared has a subtil performance problem.
Next_address is bumped only if mapping at this address
failed. Every subsequent call to open_shared has a high probability
having to call MapViewOfFileEx twice, because next_address is still
set to the address of the last successful mapping.
Avoid this by bumping next_address every time.
While at it, fix a comment.
Fixes: dc0fe7742b ("Cygwin: open_shared: try harder allocating a shared region")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
With the previous commit 9ddd48ee1b ("Cygwin: /proc/<PID>/maps:
print real shared region addresses"), the real addresses of
the standard shared regions (cygwin, user, myself, shared console)
are read from the printed process itself. We don't need fixed
addresses anymore, so drop the definitions and simplify open_shared.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
So far, the addresses printed for the shared regions of a process
were faked. The assumption was that the shared regions are always
in the same place in all processes, so we just printed the addresses
of the current process. This is no safe bet. The only safe bet is
the address of the cygheap. So keep track of the addresses in the
cygheap and read the addresses from the cygheap of the observed
processes. Add output for the shared console.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
For fixed regions (cygwin/user/myself/shared console), try fixed
address first. Fallback to non-fixed region. Don't even try fixed
address if the Cygwin DLL gets dynamically loaded.
For non-fixed regions, try to allocate in a loop within the area
from SHARED_REGIONS_ADDRESS_LOW to SHARED_REGIONS_ADDRESS_HIGH.
Fixes: 60675f1a7e ("Cygwin: decouple shared mem regions from Cygwin DLL")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Fix comments accordingly.
This is in preparation for a change in open_shared, handling shared
regions more cleanly.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
For ages, open_shared uses the shared_locations parameter as
output to indicate if the mapping for a shared region has been
created or just opened. Split this into two parameters. Use
the shared_locations parameter as input only, return the creation
state of the mapping in a bool reference parameter.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
The number of args multiplied by 4 was only required for
32 bit x86 to construct the symbol name correctly. Drop it.
In the assembler code, split the numerical values for "notimp"
and "err" into half words for cleaner layout.
Fix description accordingly.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
vmstat from proc-ps-4.0.x prints "Unable to create system stat structure"
if the /proc/cpuinfo output fails to contain topology info. While
Linux always prints topology info if the kernel has been built with
CONFIG_SMP, Cygwin only prints topology info if the CPU is known to
be multi-core (i. e., the HT feature flag is set).
Fix that by printing topology info all the time, even for single-core
CPUs.
Fixes: e0d48debed ("Fix /proc/cpuinfo topology and cache size info")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
So far the capability bits were stored in the .cygwin_dll_common
R/W section because we overwrite the is_server bit. Just don't.
Move the bit to class wincapc instead and define all wincaps
bitfields const.
Fixes: 8937c103ed ("* wincap.cc (all wincaps): Store in .cygwin_dll_common section same as wincap. Add comment to explain why.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
_pinfo::ctty has two special values other than the device id of
the allocated ctty:
-1: CTTY is not initialized yet. Can be associated with the TTY
which is associated with the session leader.
-2: CTTY has been released by setsid(). Can be associate only with
new TTY which is not associated with any other session as CTTY,
but cannot be associate with the TTYs already associated with
other sessions.
This patch adds the comments in some source files.
Suggested-by: Corinna Vinschen <corinna@vinschen.de>
Signedoff-by: Takashi Yano <takashi.yano@nifty.ne.jp>
The commit 25c4ad6ea5 did not fix the CTTY behavior enough. For
example, in the following test case, TTY will be associated as
a CTTY on the second open() call even though the TTY is already
CTTY of another session. This patch fixes the issue.
#include <unistd.h>
#include <sys/fcntl.h>
int main()
{
if (fork () == 0) {
char *tty = ttyname(0);
int fd;
setsid();
fd = open(tty, O_RDWR);
close(fd);
fd = open(tty, O_RDWR);
usleep (60000000L);
}
return 0;
}
Fixes: 25c4ad6ea5 ("Cygwin: pinfo: Align CTTY behavior to the
statement of POSIX.")
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
After the commit 30add3e6b3, the problem:
https://cygwin.com/pipermail/cygwin/2022-December/252759.html
occurs rarely. It seems that myself_pinfo should be initialized
where the timing before child_copy() and after cygheap allocation.
This patch moves the initialization there.
Fixes: 30add3e6b3 ("Cygwin: exec: don't access cygheap before it's
initialized")
Reported-by: Brian Inglis <Brian.Inglis@Shaw.ca>
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
The code computing the mask of pending signals used the per-queued
signal TLS pointer without checking it for NULL. Fix this by using
the process-wide signal mask in that case.
Fixes: 195169186b ("Cygwin: wait_sig: allow to compute process-wide mask of pending signals")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Since 4e7817498e, we're just running the tests against the installed
DLL. We're arranging to put the build directory on the path, but since
it doesn't contain cygwin1.dll (since it's built with a different name
and renamed on installation), that doesn't have any effect.
Arrange to place the just-built DLL into a directory which the testsuite
can place on it's path (while running the test, but not while compiling
it).
Also fix any remaining references to cygwin0.dll in testsuite,
documentation and comments.
Fixes: 4e7817498e ("Cygwin: Makefile: Drop all the "test dll" considerations")
The code generating the signal info in _pinfo::siginfo() and in
commune_process() are doing the same thing. Create a local static
function commune_process_siginfo() to have the code in one place
only. Remove a useless sigpending() call.
Fixes: 9a3c058f66 ("Cygwin: /proc/<PID>/status: Fill SigPnd, SigBlk and SigIgn values with life")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>