aboutsummaryrefslogtreecommitdiff
path: root/winsup/cygwin/local_includes
AgeCommit message (Collapse)AuthorFilesLines
2024-12-12Cygwin: sched_setscheduler: accept SCHED_BATCHChristian Franke1-2/+2
Add SCHED_BATCH to <sys/sched.h>. SCHED_BATCH is similar to SCHED_OTHER, except that the nice value is mapped to a one step lower Windows priority. Rework the mapping functions to ease the addition of this functionality. Signed-off-by: Christian Franke <christian.franke@t-online.de>
2024-12-10Cygwin: path_conv: allow NULL handle in init_reopen_attr()Corinna Vinschen1-1/+1
init_reopen_attr() doesn't guard against a NULL handle. However, there are scenarios calling functions deliberately with a NULL handle, for instance, av::setup() calling check_file_access() only if opening the file did NOT succeed. So check for a NULL handle in init_reopen_attr() and if so, use the name based approach filling the OBJECT_ATTRIBUTES struct, just as in the has_buggy_reopen() case. Fixes: 4c9d01fdad2a ("* mount.h (class fs_info): Add has_buggy_reopen flag and accessor methods.") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-12-08Cygwin: _cygtls: Remove _cygtls::spinningTakashi Yano1-1/+0
There seems to be no rationale reason for _cygtls::spinning to exist, so it has been removed. _cygtls::spinning was introduced in the commit edc4f86ad282A, and this flag means that another thread is waiting to acquire _cygtls::stacklock. It is checked in the sig thread in _cygtls:: interrupt_now(), and if spinning is true, the interrupt will be delayed. However, in this case, _cygtls::incyg is also set, so it is supposed to be covered by _cygtls::incyg flag and does not seem to add any value. If some problems happen in the signal handling, it might be a good idea to revert this commit and check if the issue will be fixed. Reviewed-by: Corinna Vinschen <corinna@vinschen.de> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-12-06Cygwin: signal: Introduce a lock for the signal queueTakashi Yano1-1/+1
Currently, the signal queue is touched by the thread sig as well as other threads that call sigaction_worker(). This potentially has a possibility to destroy the signal queue chain. A possible worst result may be a self-loop chain which causes infinite loop. With this patch, lock()/unlock() are introduce to avoid such a situation. Fixes: 474048c26edf ("* sigproc.cc (pending_signals::add): Just index directly into signal array rather than treating the array as a heap.") Suggested-by: Corinna Vinschen <corinna@vinschen.de> Reviewed-by: Corinna Vinschen <corinna@vinschen.de> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-12-06Cygwin: signal: Remove queue entry from the queue chain when clearedTakashi Yano1-1/+2
The queue is cleaned up by removing the entries having si_signo == 0 while processing the queued signals, however, sigpacket::process() may set si_signo in the queue to 0 of the entry already processed but not succeed by calling sig_clear(). This patch ensures the sig_clear() to remove the entry from the queue chain. For this purpose, the pointer prev has been added to the sigpacket. This is to handle the following case appropriately. Consider the queued signal chain of: A->B->C->D without pointer prev. Assume that the pointer 'q' and 'qnext' point to C, and process() is processing C. If B is cleared in process(), A->next should be set to to C in sigpacket::clear(). Then, if process() for C succeeds, C should be removed from the queue, so A->next should be set to D. However, we cannot do that because we do not have the pointer to A in the while loop in wait_sig(). With the pointer prev, we can easily access A and C in sigpacket::clear() as well as A and D in the while loop in wait_sig() using the pointer prev and next without pursuing the chain. Addresses: https://cygwin.com/pipermail/cygwin/2024-November/256744.html Fixes: 9d2155089e87 ("(wait_sig): Define variable q to be the start of the signal queue. Just iterate through sigq queue, deleting processed or zeroed signals") Reported-by: Christian Franke <Christian.Franke@t-online.de> Reviewed-by: Corinna Vinschen <corinna@vinschen.de> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-12-05Cygwin: cygtls: add volatile qualifier to spinningCorinna Vinschen1-1/+1
Given that spinning is only checked once at the start of a _cygtls::interrupt_now() which is called in a loop, it's probably not necessary to mark _cygtls::spinning as volatile. However, spinning is changed from assembler code and we don't want the compiler to make funny assumptions, so, better safe than sorry. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-12-04Cygwin: sched_setscheduler: accept SCHED_OTHER, SCHED_FIFO and SCHED_RRChristian Franke2-2/+4
If SCHED_OTHER is selected, set the Windows priority according to the nice value. If SCHED_FIFO or SCHED_RR is selected, preserve the nice value and set the Windows priority according to the sched_priority parameter. Signed-off-by: Christian Franke <christian.franke@t-online.de>
2024-12-03Cygwin: cygtls: Prompt system to switch tasks explicitly in lock()Takashi Yano1-4/+15
This patch calls Sleep(0) in the wait loop in lock() to increase the chance of being unlocked in other threads. The lock(), unlock() and locked() are moved from sigfe.s to cygtls.h so that allows inline expansion. Addresses: https://cygwin.com/pipermail/cygwin/2024-November/256744.html Fixes: 61522196c715 ("* Merge in cygwin-64bit-branch.") Reported-by: Christian Franke <Christian.Franke@t-online.de> Reviewed-by: Corinna Vinschen <corinna@vinschen.de> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-11-29Cygwin: fcwd_access_t::SetVersionFromPointer: drop declarationCorinna Vinschen1-1/+0
This method has been removed when we stopped supporting older Windows versions and only one supported FAST_CWD structure remained. Belatedly drop the declaration as well. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-11-28Cygwin: cache IsWow64Process2 host arch in wincap.Jeremy Drake1-0/+4
This was already used in the FAST_CWD check, and could be used in a couple other places. I found the "emulated"/process value returned from the function largely useless, so I did not cache it. It is useless because, as the docs say, it is set to IMAGE_FILE_MACHINE_UNKNOWN (0) if the process is not running under WOW64, but Microsoft also doesn't consider x64-on-ARM64 to be WOW64, so it is set to 0 regardless if the process is ARM64 or x64. You can tell the difference via GetProcessInformation(ProcessMachineTypeInfo), but for the current process even that's overkill: what we really want to know is the IMAGE_FILE_MACHINE_* constant for the Cygwin dll itself, which is conveniently located in memory already, so cache that in wincap also for easy comparisons. Signed-off-by: Jeremy Drake <cygwin@jdrake.com>
2024-11-28Cygwin: signal: Fix another deadlock between main and sig threadTakashi Yano1-1/+3
In _cygtls::handle_SIGCONT(), the sig thread waits for the main thread to process the signal without unlocking the TLS area. This causes a deadlock if the main thread tries to acquire a lock for the TLS area in the meantime. With this patch, unlock the TLS before calling yield() in handle_SIGCONT(). Addresses: https://cygwin.com/pipermail/cygwin/2024-November/256744.html Fixes: 26158dc3e9c2("* exceptions.cc (sigpacket::process): Lock _cygtls area of thread before accessing it.") Reported-by: Christian Franke <Christian.Franke@t-online.de> Reviewed-by: Corinna Vinschen <corinna@vinschen.de> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-11-27Cygwin: setpriority, sched_setparam: fail if Windows sets a lower priorityChristian Franke1-0/+1
Windows silently sets a lower priority than requested if the new priority requires administrator privileges. Revert to previous priority and fail with EACCES or EPERM in this case. Signed-off-by: Christian Franke <christian.franke@t-online.de>
2024-11-23Cygwin: cygtls: rename sig to current_sigCorinna Vinschen1-1/+1
The currently handled signal in a thread is called _cygtls::sig. The variable name "sig" is used pretty often in the Cygwin source. This makes it tricky to distinguish the currently handled signal from any other usage of "sig". Therefore, rename _cygtls::sig to _cygtls::current_sig Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-11-06Cygwin: console: Re-fix open() failure on exec() by console ownerTakashi Yano1-9/+10
Previous fix (commit df0953aa298c) fixes only a part of the problem. Since exec() overrides the cygwin pid of the caller process, it makes console owner handling complex. This patch makes console use Windows pid as the owner pid (con.owner) instead of cygwin pid to make the handling simpler. Fixes: df0953aa298c ("Cygwin: console: Fix open() failure when the console owner calls exec().") Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-11-01Cygwin: pipe: Switch pipe mode to blocking mode by defaultTakashi Yano2-43/+2
Previously, cygwin read pipe used non-blocking mode although non- cygwin app uses blocking-mode by default. Despite this requirement, if a cygwin app is executed from a non-cygwin app and the cygwin app exits, read pipe remains on non-blocking mode because of the commit fc691d0246b9. Due to this behaviour, the non-cygwin app cannot read the pipe correctly after that. Similarly, if a non- cygwin app is executed from a cygwin app and the non-cygwin app exits, the read pipe mode remains on blocking mode although cygwin read pipe should be non-blocking mode. These bugs were provoked by pipe mode toggling between cygwin and non-cygwin apps. To make management of pipe mode simpler, this patch has re-designed the pipe implementation. In this new implementation, both read and write pipe basically use only blocking mode and the behaviour corresponding to the pipe mode is simulated in raw_read() and raw_write(). Only when NtQueryInformationFile (FilePipeLocalInformation) fails for some reasons, the raw_read()/ raw_write() cannot simulate non-blocking access. Therefore, the pipe mode is temporarily changed to non-blocking mode. Moreover, because the fact that NtSetInformationFile() in set_pipe_non_blocking(true) fails with STATUS_PIPE_BUSY if the pipe is not empty has been found, query handle is not necessary anymore. This allows the implementation much simpler than before. Addresses: https://github.com/git-for-windows/git/issues/5115 Fixes: fc691d0246b9 ("Cygwin: pipe: Make sure to set read pipe non-blocking for cygwin apps."); Reported-by: isaacag, Johannes Schindelin <Johannes.Schindelin@gmx.de> Reviewed-by: Corinna Vinschen <corinna@vinschen.de>, Ken Brown <kbrown@cornell.edu> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-10-31Cygwin: console: Inherit pcon hand over from parent ptyTakashi Yano2-0/+5
There was a long-standing issue that pseudo console ownership could not hand over from the process whose ctty is /dev/cons* rather than /dev/pty*. This problem happens when a cygwin app starts non-cygwin app in a pty, then the non-cygwin app starts multiple cygwin apps, and the non-cygwin app ends before the second cygwin apps end. In this case, the stub process of the non-cygwin app hands over the ownership of pcon to one of the second cygwin apps, however, this app does not hand over the ownership of pcon to another second cygwin app. This is due to the fact that the hand-over feature is implemented only in fhandler_pty_slave but not in fhandler_console. With this patch, the second cygwin apps check if their console device is inside a pseudo console, and if so, it tries to hand over the ownership of the pseudo console to anther process that is attached to the same pseudo console. Addresses: https://cygwin.com/pipermail/cygwin/2024-February/255388.html Fixes: 253352e796ff ("Cygwin: pty: Allow multiple apps to enable pseudo console simultaneously.") Reported-by: lmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>, Hossein Nourikhah <hossein@libreoffice.org> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-08-31Cygwin: console: Disable cons_master_thread in win32-input-modeTakashi Yano1-0/+2
When win32-input-mode (which is supported by Windows Termainal) is set by "\033[?9001h", cons_master_thread does not work properly and consumes larger and larger memory space. This is because sending event by WriteConsoleInput() is translated into the sequence that is used by win32-input-mode. Due to this behaviour, write-back of the INPUT_RECORDs does not work as expected. With this patch, cons_master_thread is disabled on win32-input-mode where the signal keys such as Ctrl-C, Ctrl-Z etc. never comes. Addresses: https://cygwin.com/pipermail/cygwin/2024-August/256380.html Fixes: ff4440fcf768 ("Cygwin: console: Introduce new thread which handles input signal.") Reported-by: Adamyg Mob <adamyg.mob@gmail.com> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-08-18Cygwin: pipe: improve writing when pipe buffer is almost fullCorinna Vinschen1-0/+5
So far fhandler_pipe_fifo::raw_write always returns -1/EINTR if a signal arrived. Linux does not do that if there's still space left in the pipe buffer. The Linux buffer handling can't be emulated by Cygwin, but we can do something similar which makes it much more likely to still write successfully even if the buffer is almost full. Utilize pipe_data_available to return valid pipe buffer usage to raw_write, allowing a more sophisticated way to fill the buffer while maintaining comaptibility with non-Cygwin pipes. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-08-06Cygwin: Fix warning about narrowing conversions in tape optionsJon Turney1-1/+1
Fix a gcc 12 warning about a narrowing conversion in case labels for tape options. > In file included from /wip/cygwin/src/winsup/cygwin/include/sys/mtio.h:14, > from ../../../../src/winsup/cygwin/fhandler/tape.cc:13: > ../../../../src/winsup/cygwin/fhandler/tape.cc: In member function ‘int mtinfo_drive::set_options(HANDLE, int32_t)’: > ../../../../src/winsup/cygwin/fhandler/tape.cc:965:12: error: narrowing conversion of ‘4026531840’ from ‘unsigned int’ to ‘int’ [-Wnarrowing] Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2024-08-06Cygwin: Fix warnings about narrowing conversions of NTSTATUS constantsJon Turney1-1/+1
Fix warnings with gcc 12 about narrowing conversions of NTSTATUS constants when used as case labels, e.g: > ../../../../src/winsup/cygwin/exceptions.cc: In static member function ‘static int exception::handle(EXCEPTION_RECORD*, void*, CONTEXT*, PDISPATCHER_CONTEXT)’: > ../../../../src/winsup/cygwin/exceptions.cc:670:10: error: narrowing conversion of ‘-1073741682’ from ‘NTSTATUS’ {aka ‘int’} to ‘unsigned int’ [-Wnarrowing] See also: c5bdf60ac46401a51a7e974333d9622966e22d67 Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2024-08-06Cygwin: Suppress array-bounds warning from NtCurrentTeb()Jon Turney1-0/+3
This disables a warning seen with gcc 12 caused by intrinsics used by the inline implementation of NtCurrentTeb() inside w32api headers. > In function ‘long long unsigned int __readgsqword(unsigned int)’, > inlined from ‘_TEB* NtCurrentTeb()’ at /usr/include/w32api/winnt.h:10020:86, > [...] > /usr/include/w32api/psdk_inc/intrin-impl.h:838:1: error: array subscript 0 is outside array bounds of ‘long long unsigned int [0]’ [-Werror=array-bounds] See also: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523#c6 Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2024-07-09Cygwin: console: Fix race issue on allocating console simultaneously.Takashi Yano3-11/+10
Previously, if two or more processes request to allocate a console at the same time, the same device number could be accidentally allocated. This patch fixes the issue by creating a named mutex (input_mutex) and checking if GetLastError() is ERROR_ALREADY_EXIST or not to ensure the unit number will be allocated in an atomic way. Thanks to this, EnumWindow() is not necessary anymore to scan console units. This also makes minor device numbers unique and console devices visible across sessions. This disallows duplicated device number for different sessions, so the MAX_CONS_DEV has been increased from 64 to 128. Additionally, the console allocation and scanning will be faster as a side effect of eliminating EnumWindows(). Fixes: 3721a756b0d8 ("Cygwin: console: Make the console accessible from other terminals.") Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-06-28Cygwin: dsp: Fix incorrect openflags when opening multiple /dev/dspTakashi Yano1-3/+4
Previously, the following steps failed with error: 1) Open /dev/dsp with O_RDONLY 2) Open /dev/dsp with O_WRONLY 3) Issue SNDCTL_DSP_GETOSPACE ioctl() for 2) This is because IS_WRITE() returns false for 2) due to incorrect openflags handling in archetype instance. This patch fixes the issue by adding open_setup() to fhandler_dev_dsp to set openflags correctly for each instance. Fixes: 92ddb7429065 ("* fhandler_dsp.cc (fhandler_dev_dsp::open): Remove archetype handling.") Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-06-02Cygwin: pthread: Fix a race issue introduced by the commit 2c5433e5da82Takashi Yano1-1/+1
To avoid race issues, pthread::once() uses pthread_mutex. This caused the handle leak which was fixed by the commit 2c5433e5da82. However, this fix introduced another race issue, i.e., the mutex may be used after it is destroyed. This patch fixes the issue. Special thanks to Bruno Haible for discussing how to fix this. Addresses: https://cygwin.com/pipermail/cygwin/2024-May/255987.html Reported-by: Bruno Haible <bruno@clisp.org> Fixes: 2c5433e5da82 ("Cygwin: pthread: Fix handle leak in pthread_once.") Reviewed-by: Ken Brown <kbrown@cornell.edu> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-04-02Cygwin: fhandler_virtual: move fileid to path_conv memberCorinna Vinschen2-1/+11
Commit 80f722e97cf7 ("Cygwin: opendir(3): move ENOTDIR check into main function") introduced a bug in fhandler_virtual handling. While the assertion that path_conv::check() already calls exists() and sets FILE_ATTRIBUTE_DIRECTORY accordingly, the exists() function is called on a fhandler_virtual object created for just this code snippet. The side effect of this is that the fileid member in the calling fhandler_virtual object is not set after path_conv::check(). Move the fhandler_virtual::fileid member to path_conv::_virt_fileid and create matching path_conv::virt_fileid() and fhandler_virtual::fileid() methods. Let path_conv::check() propagate the fileid set in the local fhandler_virtual::exists() call to its own _virt_fileid. Use new fhandler_virtual::fileid() method throughout. Fixes: 80f722e97cf7 ("Cygwin: opendir(3): move ENOTDIR check into main function") Reported-by: Bruce Jerrick <bmj001@gmail.com> Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-03-20Cygwin: // and //server: switch to Network DiscoveryCorinna Vinschen1-0/+1
SMBv1 is ultimately deprecated since Novemer 2023. It's also not installed by default on latest Windows versions. Drop using the WNet (SMBv1) API in favor of using Network Discovery. Given there's no documented Win32 API for that, the code now uses the Shell API. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-03-19Cygwin: dirent.h: fix a commentCorinna Vinschen1-1/+1
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-03-12Cygwin: pipe: Make sure to set read pipe non-blocking for cygwin apps.Takashi Yano1-0/+3
If pipe reader is a non-cygwin app first, and cygwin process reads the same pipe after that, the pipe has been set to bclocking mode for the cygwin app. However, the commit 9e4d308cd592 assumes the pipe for cygwin process always is non-blocking mode. With this patch, the pipe mode is reset to non-blocking when cygwin app is started. Addresses: https://cygwin.com/pipermail/cygwin/2024-March/255644.html Fixes: 9e4d308cd592 ("Cygwin: pipe: Adopt FILE_SYNCHRONOUS_IO_NONALERT flag for read pipe.") Reported-by: wh <wh9692@protonmail.com> Reviewed-by: Corinna Vinschen <corinna@vinschen.de> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-03-11Cygwin: getgrent: don't skip SAM-only builtin-accountsCorinna Vinschen1-0/+4
Since commit 15e82eef3a40b ("Cygwin: getgrent: fix local SAM enumeration on domain member machines") we skip enumerating local BUILTIN accounts if we also enumerate AD. However, there are two local accounts which are only available in local SAM, not in AD. Don't skip enumerating those. Fixes: 15e82eef3a40b ("Cygwin: getgrent: fix local SAM enumeration on domain member machines") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-03-08Cygwin: try to avoid recalling offline filesCorinna Vinschen3-1/+30
Chances are high that Cygwin recalls offline files from remote storage, even if the file is only accessed during stat(2) or readdir(3). To avoid this - make sure Cygwin is placeholder-aware, - open files in path_conv handling, as well as in stat(2)/readdir(3) scenarios with FILE_OPEN_NO_RECALL, and - during symlink checking or testing for executablility, don't even try to open the file if one of the OFFLINE attributes is set. Reported-by: Marcin Wisnicki <mwisnicki@gmail.com> Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-03-06Cygwin: pipe: Simplify chhecking procedure of query_hdl.Takashi Yano1-4/+1
This patch eliminates verbose NtQueryObject() calls in the procedure to get query_hdl by storing pipe name into fhandler_base::pc when the pipe is created. fhandler_pipe::temporary_query_hdl() uses the storedpipe name rather than the name retrieved by NtQueryObject(). Suggested-by: Corinna Vinschen <corinna@vinschen.de> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-03-01Cygwin: cygheap: compute bucket instead of looping over itCorinna Vinschen1-1/+1
Start at index 0 and use 32 bytes as minimal allocation size. Reduce NBUCKETS, we don't have such big objects on the cygheap anyway. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-02-26Cygwin: errmap[]: update comments using current winerror.hChristian Franke1-850/+851
Signed-off-by: Christian Franke <christian.franke@t-online.de>
2024-02-26Cygwin: errmap[]: add error numbers to /* ERROR_... */ commentsChristian Franke1-1357/+1357
Signed-off-by: Christian Franke <christian.franke@t-online.de>
2024-02-26Cygwin: errmap[]: reduce value size from 32 to 8 bitsChristian Franke1-1/+1
Overflow would be detected at compile time. Signed-off-by: Christian Franke <christian.franke@t-online.de>
2024-02-26Cygwin: introduce constexpr errmap_size and errmap[] consistency checksChristian Franke1-1/+10
Use constexpr instead of const for errmap[] to allow static_assert checks on its values. Signed-off-by: Christian Franke <christian.franke@t-online.de>
2024-02-24Cygwin: Map ERROR_NO_SUCH_DEVICE and ERROR_MEDIA_CHANGED to ENODEVChristian Franke1-2/+2
If a removable (USB) device is disconnected after opening its raw device, R/W attempts fail with ERROR_NO_SUCH_DEVICE(433). If the raw device of a partition is used, ERROR_MEDIA_CHANGED(1110) is returned instead. Both are mapped to ENODEV(19) because <errno.h> does not offer a value which better matches ERROR_MEDIA_CHANGED. Signed-off-by: Christian Franke <christian.franke@t-online.de>
2024-02-16Cygwin: console: Fix a bug that 64th console cannot be handled.Takashi Yano1-2/+3
Fixes: 930e553da8e9 ("Cygwin: console: Unify EnumWindows() callback functions."); Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-02-14Cygwin: console: Unify EnumWindows() callback functions.Takashi Yano1-0/+15
Previously, three similar callback fuctions were used in console code. This patch unifies these functions to ease maintenance cost. Fixes: 8aad3a7edeb2 ("Cygwin: console: Fix a problem that minor ID is incorrect in ConEmu.") Suggested-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-01-31Cygwin: posix_getdents: implement per SUS Base Specifications Issue 8 draftCorinna Vinschen1-0/+14
- Basically maintain a hidden DIR* inside fhandlers. - lseek has to be tweaked to allow basic seeking on the directory descriptor. - the current implementation does not keep the dir positions between duplicated descriptor in sync. In fact, every descriptor keeps its own copy of the DIR* and after dup/fork/exec, the directory position is reset to 0, i. e., to the start of the directory, as if rewinddir() has been called on the new descriptors. While this behaviour isn't yet covered by the Issue 8 draft, a bug report along these lines exists and will probably be picked up for TC1. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-01-31Cygwin: devices.h: drop useless mode checkCorinna Vinschen1-4/+1
use IFTODT to generate type from mode. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-01-31Cygwin: dirent.h: make definition of struct __DIR opaqueCorinna Vinschen1-0/+30
The content of DIR should never have been exposed into userspace. Move struct __DIR to local dirent.h and only keep forward declaration in exported dirent.h. This allows to tweak the structure in future, for instance, to add thread-safety. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-01-31Cygwin: files: slightly simplify suffix handlingCorinna Vinschen1-2/+1
- drop appending .exe.lnk to files - drop exe_suffixes, it's the same as stat_suffixes for a long time Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-01-16Cygwin: Treat api_fatal() similarly to a core-dumping signalJon Turney1-0/+1
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-16Cygwin: Make 'ulimit -c' control writing a coredumpJon Turney1-0/+1
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".
2023-12-01Cygwin: drop stray fs_info::check_ssd declarationCorinna Vinschen1-2/+0
This is just a leftover from development Fixes: 8b01c5d6903f ("Cygwin: fs_info: check for SSD") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-30Cygwin: sparse support: enable automatic sparsifying of files on SSDsCorinna Vinschen1-2/+2
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-30Cygwin: fs_info: check for SSDCorinna Vinschen1-0/+4
During fs_info::update, check for the file being on an SSD. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-30Cygwin: ntdll.h: add missing NtQueryVolumeInformationFile definitionsCorinna Vinschen1-0/+27
In preparation of using the FileFsSectorSizeInformation info class, add a couple of missing definitions. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-30Cygwin: ntdll.h: add missing POBJECT_NAME_INFORMATIONCorinna Vinschen1-1/+1
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>