summaryrefslogtreecommitdiffstats
path: root/winsup
Commit message (Collapse)AuthorAgeFilesLines
...
* Cygwin: pty: Fix segfault caused when tcflush() is called.Takashi Yano via Cygwin-patches2021-02-221-2/+5
| | | | | | | | - After commit 253352e796ff9ec9a447e5375f5bc3e2b92b5293, mc (midnight commander) crashes with segfault if the shell is bash. This is due to NULL pointer access in read(). This patch fixes the issue. Addresses:: https://cygwin.com/pipermail/cygwin/2021-February/247870.html
* Cygwin: FIFO: temporarily keep a conv_handle in syscalls.cc:openKen Brown2021-02-191-3/+19
| | | | | | | | | | | When a FIFO is opened, syscalls.cc:open always calls fstat on the newly-created fhandler_fifo. This results from a call to device_access_denied. To speed-up this fstat call, and therefore the open(2) call, use PC_KEEP_HANDLE when the fhandler is created. The resulting conv_handle is retained until after the fstat call if the fhandler is a FIFO; otherwise, it is closed immediately.
* Cygwin: fstat_helper: always use handle in call to get_file_attributeKen Brown2021-02-191-2/+1
| | | | | | | | | | | | Previously, the call to get_file_attribute for FIFOs set the first argument to NULL instead of the handle h returned by get_stat_handle, thereby forcing the file to be opened for fetching the security descriptor in get_file_sd(). This was done because h might have been a pipe handle rather than a file handle, and its permissions would not necessarily reflect those of the file. That situation can no longer occur with the new fhandler_fifo::fstat introduced in the previous commit.
* Cygwin: define fhandler_fifo::fstatKen Brown2021-02-192-0/+24
| | | | | | | | | | | | | | | | | | Previously fstat on a FIFO would call fhandler_base::fstat. The latter is not appropriate if fhandler_fifo::open has already been called (and O_PATH is not set), for the following reason. If a FIFO has been opened as a writer or duplexer, then it has an io_handle that is a pipe handle rather than a file handle. fhandler_base::fstat will use this handle and potentially return incorrect results. If the FIFO has been opened as a reader, then it has no io_handle, and a call to fhandler_base::fstat will lead to a call to fhandler_base::open. Opening the fhandler a second time can change it in undesired ways; for example, it can modify the flags and status_flags. The new fhandler_fifo::fstat avoids these problems by creating an fhandler_disk_file and calling its fstat method in case fhandler_fifo::open has already been called and O_PATH is not set.
* Cygwin: realpath: fix cygwin installation dir being access via junctionCorinna Vinschen2021-02-191-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Consider this case: - Cygwin installed in C:\cygwin64 - mklink /j D:\cygwin64 C:\cygwin64 - create testcase calling realpath("/", result); printf ("%s\n", result); - start cmd >C:\cygwin64\bin\bash -lc <path-to-testcase> / >D\cygwin64\bin\bash -lc <path-to-testcase> /cygdrive/c/cygwin64 This scenario circumventing the mount point handling which is automated in terms of /, depending on the path returned from GetModuleFileNameW for the Cygwin DLL. When calling D:\cygwin64\bin\bash the dir returned from GetModuleFileNameW is D:\cygwin64\bin, thus root is D:\cygwin64. However, junctions are treated as symlinks in Cygwin which explains why the path gets converted to a cygdrive path. Fix this by calling GetFinalPathNameByHandleW on the result from GetModuleFileNameW to get the correct root path, even if accessed via a junction point. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: default to O_BINARY in fhandler_base::reset_to_open_binmode()Corinna Vinschen2021-02-191-1/+2
| | | | | | | | | | This only affects the very seldom bordercase of apps calling setmode(fd, 0) on fhandlers not calling fhandler_base::set_open_status(). All fhandlers not calling set_open_status() are binary mode only, but the way reset_to_open_binmode worked, calling setmode(fd, 0) would have "reset" their open flags to O_TEXT accidentally. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: console: Add support for FLUSHO and Ctrl-O.Takashi Yano via Cygwin-patches2021-02-191-0/+11
| | | | - With this patch, FLUSHO and Ctrl-O (VDISCARD) get working.
* Cygwin: pty: Make FLUSHO and Ctrl-O work.Takashi Yano via Cygwin-patches2021-02-195-6/+19
| | | | | - Previously, FLUSHO feature was implemented incompletely. With this patch, FLUSHO and Ctrl-O (VDISCARD) get working.
* Cygwin: pty: Make tty setting NOFLSH work.Takashi Yano via Cygwin-patches2021-02-191-1/+2
| | | | - With this patch, "stty noflsh" gets working in pty.
* Cygwin: pty: Reflect tty settings to pseudo console mode.Takashi Yano via Cygwin-patches2021-02-191-0/+27
| | | | | - With this patch, tty setting such as echo, icanon, isig and onlcr are reflected to pseudo console mode.
* Cygwin: Add console fix regarding Ctrl-Z etc. to release notes.Takashi Yano via Cygwin-patches2021-02-192-0/+13
|
* Cygwin: console: Fix handling of Ctrl-S in Win7.Takashi Yano via Cygwin-patches2021-02-195-246/+98
| | | | | | | - If ENABLE_LINE_INPUT is set, Ctrl-S is handled by Windows if the OS is Windows 7. This conflicts with Ctrl-S handling in cygwin console code. This patch unsets ENABLE_LINE_INPUT flag in cygwin and set it when native app is executed.
* Cygwin: console: Fix SIGWINCH handling in Win7.Takashi Yano via Cygwin-patches2021-02-191-0/+15
| | | | | | | | - If ENABLE_VIRTUAL_TERMINAL_INPUT is not set, changing window height does not generate WINDOW_BUFFER_SIZE_EVENT. This happens if console is in the legacy mode. Therefore, with this patch, the windows size is checked every time in cons_master_thread() if the cosole is in the legacy mode.
* cpuinfo: add AVX features; move SME, SEV/_ES featuresBrian Inglis2021-02-181-21/+23
| | | | | | | Linux 5.11 💕 Valentine's Day Edition 💕 added features and changes: add Intel 0x00000007 EDX:23 avx512_fp16 and 0x00000007:1 EAX:4 avx_vnni; group scattered AMD 0x8000001f EAX Secure Mem/Encrypted Virt features at end: 0 sme, 1 sev, 3 sev_es (more to come not yet displayed)
* cpuinfo: fix check for cpuid 0x80000007 supportBrian Inglis2021-02-181-1/+1
|
* Cygwin: console: Introduce new thread which handles input signal.Takashi Yano via Cygwin-patches2021-02-173-2/+181
| | | | | | | | | | | | | | - Currently, Ctrl-Z, Ctrl-\ and SIGWINCH does not work in console if the process does not call read() or select(). This is because these are processed in process_input_message() which is called from read() or select(). This is a long standing issue of console. Addresses: https://cygwin.com/pipermail/cygwin/2020-May/244898.html https://cygwin.com/pipermail/cygwin/2021-February/247779.html With this patch, new thread which handles only input signals is introduced so that Crtl-Z, etc. work without calling read() or select(). Ctrl-S and Ctrl-Q are also handled in this thread.
* winsup/doc/posix.xml: add note for getrlimit, setrlimit, xrefs to notesBrian Inglis2021-02-161-44/+57
| | | | | | change notes to see "Implementation Notes" to xref to std-notes; add xref to std-notes to getrlimit, setrlimit; add note to document limitations of getrlimit, setrlimit resources support
* Cygwin: console: Abort read() on signal if SA_RESTART is not set.Takashi Yano via Cygwin-patches2021-02-154-4/+6
| | | | | | | - Currently, console read() keeps reading after SIGWINCH is sent even if SA_RESTART flag is not set. With this patch, read() returns EINTR on SIGWINCH if SA_RESTART flag is not set. The same problem for SIGQUIT and SIGTSTP has also been fixed.
* Cygwin: pty: Fix a bug in input transfer for GDB.Takashi Yano via Cygwin-patches2021-02-151-2/+3
| | | | | - With this patch, not only NL but also CR is treated as a line end in the code checking if input transfer is necessary.
* Cygwin: pty: Reduce unecessary input transfer.Takashi Yano via Cygwin-patches2021-02-125-199/+376
| | | | | | | - Currently, input transfer is performed every time one line is read(), if the non-cygwin app is running in the background. With this patch, transfer is triggered by setpgid() rather than read() so that the unnecessary input transfer can be reduced much in that situation.
* Cygwin: only export tmpfile64 on 32 bitCorinna Vinschen2021-02-121-0/+2
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: Have tmpfile(3) use O_TMPFILEMark Geisert2021-02-122-0/+23
| | | | | | | | | | Per discussion on cygwin-developers, a Cygwin tmpfile(3) implementation has been added to syscalls.cc. This overrides the one supplied by newlib. Then the open(2) flag O_TMPFILE was added to the open call that tmpfile internally makes. This v2 patch removes O_CREAT from open() call as O_TMPFILE obviates it. Note that open() takes a directory's path but returns an fd to a file.
* Cygwin: fhandler: clean up 'copyto' logicCorinna Vinschen2021-02-103-197/+197
| | | | | | | | | | | | | | | | | Analyzing the fhandler::copyto logic shows that the fhandler_base::reset method was only called from copyto anyway. Trying to convert reset to a protected method uncovered that the copyto method is actually thought upside down from an object oriented POV. Rather than calling copyto, manipulating the object given as parameter, rename the method to copy_from, which manipulates the calling object itself with data from the object given as parameter. Eventually make reset a protected method and rename it to _copy_from_reset_helper to clarify it's only called from copy_from. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: check path_conv_handle for NULL before trying to dup itCorinna Vinschen2021-02-101-3/+4
| | | | | | | | path_conv_handle::dup calls DuplicateHandle unconditionally, but we only have a handle in some cases. Check handle for being non-NULL before calling DuplicateHandle. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: drop path_conv::reset_conv_handleCorinna Vinschen2021-02-103-3/+2
| | | | | | | | | | path_conv::reset_conv_handle is only called after fhandler::copyto has been called. This duplicated the path_conv_handle if there was one, so just setting the conv handle to NULL potentially produces a handle leak. Replace reset_conv_handle calls with calls to close_conv_handle and drop the reset_conv_handle method. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: don't copy path_conv in fhandler_base::resetCorinna Vinschen2021-02-101-1/+0
| | | | | | | | | | | | There's a slim chance that duplicating fhandlers may end up duplicating path_conv_handle handles twice ending up with a handle leak, due to fhandler_base::reset calling path_conv::operator<< after the only caller, fhandler::copyto, already called path_conv::operator=. Just drop the call which basically duplicates what path_conv::operator= already did. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Revert "Cygwin: fstat_helper: always use handle in call to get_file_attribute"Ken Brown2021-02-091-4/+3
| | | | | | | | | | | | This reverts commit 76dca77f049271e2529c25de8a396e65dbce615d. That commit was based on the incorrect assumption that get_stat_handle, when called on a FIFO in fstat_helper, would always return a handle that is safe to use for getting the file information. That assumption is true in many cases but not all. For example, if the call to fstat_helper arises from a call to fstat(2) on a FIFO that has been opened for writing, then get_stat_handle will return a pipe handle instead of a file handle.
* Cygwin: drop ftw.h in favor of new newlib ftw.hCorinna Vinschen2021-02-091-63/+0
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* fhandler_serial.cc: MARK and SPACE parity for serial portMarek Smetana2021-02-022-1/+11
|
* Cygwin: recognize native Windows AF_UNIX sockets as reparse pointsKen Brown2021-02-011-0/+4
| | | | | | | | | | | | | Allow check_reparse_point_target to recognize reparse points with reparse tag IO_REPARSE_TAG_AF_UNIX. These are used in recent versions of Windows 10 to represent AF_UNIX sockets. check_reparse_point_target now returns PATH_REP on files of this type, so that they are treated as known reparse points (but not as sockets). This allows tools like 'rm', 'ls', etc. to operate on these files. Addresses: https://cygwin.com/pipermail/cygwin/2020-September/246362.html https://cygwin.com/pipermail/cygwin/2021-January/247666.html
* Cygwin: include/cygwin/limits.h: new headerKen Brown2021-02-012-47/+98
| | | | | | | | | | | | | | | | The new header defines some Cygwin-specific limits, using private names. It is included by include/limits.h. For example, we now have #define __OPEN_MAX 3200 in include/cygwin/limits.h and #define OPEN_MAX __OPEN_MAX in include/limits.h. The purpose is to hide implementation details from users who view <limits.h>.
* Cygwin: remove the OPEN_MAX_MAX macroKen Brown2021-02-017-17/+14
| | | | | | | Replace all occurrences of OPEN_MAX_MAX by OPEN_MAX, and define the latter to be 3200, which was the value of the former. In view of the recent change to getdtablesize, there is no longer a need to distinguish between these two macros.
* Cygwin: sysconf, getrlimit: don't call getdtablesizeKen Brown2021-02-012-14/+2
| | | | | | Now that getdtablesize always returns OPEN_MAX_MAX, we can simplify sysconf(_SC_OPEN_MAX) and getrlimit(RLIMIT_NOFILE) to just use that same constant instead of calling getdtablesize.
* Cygwin: getdtablesize: always return OPEN_MAX_MAXKen Brown2021-02-011-1/+1
| | | | | | | | | | | | | | | | | | According to the Linux man page for getdtablesize(3), the latter is supposed to return "the maximum number of files a process can have open, one more than the largest possible value for a file descriptor." The constant OPEN_MAX_MAX is the only limit enforced by Cygwin, so we now return that. Previously getdtablesize returned the current size of cygheap->fdtab, Cygwin's internal file descriptor table. But this is a dynamically growing table, and its current size does not reflect an actual limit on the number of open files. With this change, gnulib now reports that getdtablesize and fcntl(F_DUPFD) work on Cygwin. Packages like GNU tar that use the corresponding gnulib modules will no longer use gnulib replacements on Cygwin.
* Cygwin: exceptions.cc: Suspend all threads in sig_handle_tty_stop().Takashi Yano via Cygwin-patches2021-02-011-0/+2
| | | | | | | - Currently, thread created by pthread_create() is not suspended by the signal SIGTSTP. For example, even if a process with a thread is suspended by Ctrl-Z, the thread continues running. This patch fixes the issue.
* Cygwin: console: Align the behaviour against signal with pty.Takashi Yano via Cygwin-patches2021-02-011-1/+2
| | | | | | | | - Currently, read() returns -1 with EINTR if the process is suspended by Ctrl-Z and resumed by fg command, while pty continues to read. For example, xxd command stops with error "Interrupted system call" after Ctrl-Z and fg. This patch aligns the behaviour with pty (and Linux).
* Cygwin: pty: Make slave read() thread-safe.Takashi Yano via Cygwin-patches2021-02-011-0/+6
| | | | | - Currently slave read() is somehow not thread-safe. This patch fixes the issue.
* Cygwin: console: Make read() thread-safe.Takashi Yano via Cygwin-patches2021-02-013-5/+18
| | | | | - Currently read() is somehow not thread-safe. This patch fixes the issue.
* Cygwin: fchmodat: add limited support for AT_SYMLINK_NOFOLLOWKen Brown2021-01-291-5/+15
| | | | | | | | | | | | Allow fchmodat with the AT_SYMLINK_NOFOLLOW flag to succeed on non-symlinks. Previously it always failed, as it does on Linux. But POSIX permits it to succeed on non-symlinks even if it fails on symlinks. The reason for following POSIX rather than Linux is to make gnulib report that fchmodat works on Cygwin. This improves the efficiency of packages like GNU tar that use gnulib's fchmodat module. Previously such packages would use a gnulib replacement for fchmodat on Cygwin.
* Cygwin: pty: Allow multiple apps to enable pseudo console simultaneously.Takashi Yano via Cygwin-patches2021-01-286-93/+314
| | | | | | | - After commit bb428520, there has been the disadvantage: 7) Pseudo console cannot be activated if it is already activated for another process on same pty. This patch clears this disadvantage.
* Cygwin: pty: Make apps using console APIs be able to debug with gdb.Takashi Yano via Cygwin-patches2021-01-286-42/+279
| | | | | | | | | | - After commit bb428520, there has been the disadvantage: 2) The apps which use console API cannot be debugged with gdb. This is because pseudo console is not activated since gdb uses CreateProcess() rather than exec(). Even with this limitation, attaching gdb to native app, in which pseudo console is already activated, works. This patch clears this disadvantage.
* Cygwin: pty: Keep code page between non-cygwin apps.Takashi Yano via Cygwin-patches2021-01-283-0/+11
| | | | | | | | | - After commit bb428520, there has been the disadvantage: 4) Code page cannot be changed by chcp.com. Acctually, chcp works itself and changes code page of its own pseudo console. However, since pseudo console is recreated for another process, it cannot inherit the code page. This patch clears this disadvantage.
* Cygwin: pty: Inherit typeahead data between two input pipes.Takashi Yano via Cygwin-patches2021-01-285-147/+504
| | | | | | | | | | | | | | | - PTY has a problem that the key input, which is typed during windows native app is running, disappears when it returns to shell. This is beacuse pty has two input pipes, one is for cygwin apps and the other one is for native windows apps. The key input during windows native program is running is sent to the second input pipe while cygwin shell reads input from the first input pipe. This issue had been fixed once by commit 29431fcb, however, the new implementation of pseudo console support by commit bb428520 could not inherit this feature. This patch realize transfering input data between these two pipes bidirectionally by utilizing cygwin-console-helper process. The helper process is launched prior to starting the non-cygwin app, however, exits immediately unlike previous implementation.
* Cygwin: Align *utime*() with POSIX/glibcCorinna Vinschen2021-01-262-5/+5
| | | | | | Followup to previous patch, this time matching definitions in Cygwin Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: chown: make sure ctime gets updated when necessaryKen Brown2021-01-251-5/+8
| | | | | | | | | | | | Following POSIX, ensure that ctime is updated if chown succeeds, unless the new owner is specified as (uid_t)-1 and the new group is specified as (gid_t)-1. Previously, ctime was unchanged whenever the owner and group were both unchanged. Aside from POSIX compliance, this fix makes gnulib report that chown works on Cygwin. This improves the efficiency of packages like GNU tar that use gnulib's chown module. Previously such packages would use a gnulib replacement for chown on Cygwin.
* syscalls.cc: Deduplicate removeBen Wijen2021-01-251-13/+4
| | | | | The remove code is already in the _remove_r function. So, just call the _remove_r function.
* Cygwin: console: Add missing guard regarding attach_mutex.Takashi Yano via Cygwin-patches2021-01-251-0/+27
| | | | | - The commit a5333345 did not fix the problem enough. This patch provides additional guard for the issue.
* syscalls.cc: unlink_nt: Try FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTEBen Wijen2021-01-254-39/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | I think we don't need an extra flag as we can utilize: access & FILE_WRITE_ATTRIBUTES What do you think? Ben Wijen (1): syscalls.cc: unlink_nt: Try FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE winsup/cygwin/ntdll.h | 3 ++- winsup/cygwin/syscalls.cc | 22 +++++++-------- winsup/cygwin/wincap.cc | 11 ++++++++ winsup/cygwin/wincap.h | 56 ++++++++++++++++++++------------------- 4 files changed, 53 insertions(+), 39 deletions(-) -- 2.30.0 >From 2d0ff6fec10d03c24d11c747852018b7bc1136ac Mon Sep 17 00:00:00 2001 In-Reply-To: <20210122105201.GD810271@calimero.vinschen.de> References: <20210122105201.GD810271@calimero.vinschen.de> From: Ben Wijen <ben@wijen.net> Date: Tue, 17 Dec 2019 15:15:25 +0100 Subject: [PATCH v3 1/8] syscalls.cc: unlink_nt: Try FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE Implement wincap.has_posix_unlink_semantics_with_ignore_readonly and when set skip setting/clearing of READONLY attribute and instead use FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE
* Cygwin: ptsname_r: always return an error number on failureKen Brown2021-01-222-1/+4
| | | | | | | | | | | | Return EBADF on a bad file descriptor. Previously 0 was returned, in violation of the requirement in https://man7.org/linux/man-pages/man3/ptsname_r.3.html that an error number should be returned on failure. We are intentionally deviating from Linux, on which ENOTTY is returned. Addresses: https://lists.gnu.org/archive/html/bug-gnulib/2021-01/msg00245.html
* Cygwin: normalize_posix_path: fix error handling when .. is encounteredKen Brown2021-01-222-1/+7
| | | | | | | | | | When .. is in the source path and the path prefix exists but is not a directory, return ENOTDIR instead of ENOENT. This fixes a POSIX compliance issue for realpath(3): https://pubs.opengroup.org/onlinepubs/9699919799/functions/realpath.html Addresses: https://lists.gnu.org/archive/html/bug-gnulib/2021-01/msg00214.html