[PATCH] Cygwin: ptsname_r: always return an error number on failure

2021-01-20 Thread Ken Brown via Cygwin-patches
Following Linux, return ENOTTY on a bad file descriptor and also set errno to ENOTTY. Previously 0 was returned and errno was set to EBADF. Returning 0 violates the requirement in https://man7.org/linux/man-pages/man3/ptsname_r.3.html that an error number should be returned on failure. (That man

[PATCH v2 6/8] syscalls.cc: Expose shallow-pathconv unlink_nt

2021-01-20 Thread Ben Wijen
Not having to query file information improves unlink speed. --- winsup/cygwin/syscalls.cc | 78 ++- 1 file changed, 52 insertions(+), 26 deletions(-) diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index ab0c4c2d6..b5ab6ac5e 100644 --- a/wins

[PATCH v2 8/8] fhandler_disk_file.cc: Use path_conv's IndexNumber

2021-01-20 Thread Ben Wijen
path_conv already knows the IndexNumber, so just use it. This commit also fixes the potential handle leak. --- winsup/cygwin/fhandler_disk_file.cc | 24 ++-- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fha

[PATCH v2 7/8] dir.cc: Try unlink_nt first

2021-01-20 Thread Ben Wijen
Speedup deletion of directories. --- winsup/cygwin/dir.cc | 12 ++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/winsup/cygwin/dir.cc b/winsup/cygwin/dir.cc index 7762557d6..470f83aee 100644 --- a/winsup/cygwin/dir.cc +++ b/winsup/cygwin/dir.cc @@ -22,6 +22,8 @@ details.

[PATCH v2 5/8] path.cc: Allow to skip filesystem checks

2021-01-20 Thread Ben Wijen
When file attributes are of no concern, there is no point to query them. This can greatly speedup code which doesn't need it. The idea is to have a shallow path conversion with only minimal information. The upcoming unlink_nt for example, first tries a path without filesystem checks, then - if ne

[PATCH v2 4/8] syscalls.cc: Implement non-path_conv dependent _unlink_nt

2021-01-20 Thread Ben Wijen
Implement _unlink_nt: wich does not depend on patch_conv --- winsup/cygwin/fhandler_disk_file.cc | 4 +- winsup/cygwin/forkable.cc | 4 +- winsup/cygwin/syscalls.cc | 211 ++-- 3 files changed, 200 insertions(+), 19 deletions(-) diff --git a/winsup/

[PATCH v2 3/8] Cygwin: Move post-dir unlink check

2021-01-20 Thread Ben Wijen
Move post-dir unlink check from fhandler_disk_file::rmdir to _unlink_nt_post_dir_check If a directory is not removed through fhandler_disk_file::rmdir we can now make sure the post dir check is performed. --- winsup/cygwin/fhandler_disk_file.cc | 20 winsup/cygwin/syscalls.cc

[PATCH v2 2/8] syscalls.cc: Deduplicate remove

2021-01-20 Thread Ben Wijen
The remove code is already in the _remove_r function. So, just call the _remove_r function. --- winsup/cygwin/syscalls.cc | 17 - 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index 2e50ad7d5..54b065733 100644 -

[PATCH v2 1/8] syscalls.cc: unlink_nt: Try FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE

2021-01-20 Thread Ben Wijen
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 --- winsup/cygwin/ntdll.h | 3 ++- winsup/cygwin/syscalls.cc | 14 +- winsup/cygwin/wincap.cc | 11 +++

[PATCH v2 0/8] Improve rm speed

2021-01-20 Thread Ben Wijen
Hi, I think I got all remarks, please let me know if I missed something. I'm still thinking on a better way to use fs_info::update cache, but it requires more testing. Thank you, Ben Wijen (8): syscalls.cc: unlink_nt: Try FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE syscalls.cc: Deduplicate

[PATCH] Cygwin: normalize_posix_path: fix error handling when .. is encountered

2021-01-20 Thread Ken Brown via Cygwin-patches
When .. is in the source path and the path prefix exists but is not a directory, return ENOTDIR instead of ENOENT. This fixes a failing gnulib test of realpath(3). Addresses: https://lists.gnu.org/archive/html/bug-gnulib/2021-01/msg00214.html --- winsup/cygwin/path.cc | 4 +++- winsup/cygw

Re: [PATCH] Cygwin: pty: Reduce buffer size in get_console_process_id().

2021-01-20 Thread Corinna Vinschen via Cygwin-patches
On Jan 20 19:40, Takashi Yano via Cygwin-patches wrote: > On Wed, 20 Jan 2021 10:50:24 +0100 > Corinna Vinschen wrote: > > On Jan 20 09:57, Takashi Yano via Cygwin-patches wrote: > > > - The buffer used in get_console_process_id(), introduced by commit > > > 72770148, is too large and ERROR_NOT_E

Re: [PATCH] Cygwin: pty: Reduce buffer size in get_console_process_id().

2021-01-20 Thread Takashi Yano via Cygwin-patches
On Wed, 20 Jan 2021 10:50:24 +0100 Corinna Vinschen wrote: > On Jan 20 09:57, Takashi Yano via Cygwin-patches wrote: > > - The buffer used in get_console_process_id(), introduced by commit > > 72770148, is too large and ERROR_NOT_ENOUGH_MEMORY occurs in Win7. > > Huh, funny! Will we ever be hap

Re: [PATCH] Cygwin: console: Fix "Bad file descriptor" error in script command.

2021-01-20 Thread Corinna Vinschen via Cygwin-patches
On Jan 20 18:16, Takashi Yano via Cygwin-patches wrote: > - After the commit 72770148, script command exits occasionally with > the error "Bad file descriptor" if it is started in console on Win7 > and non-cygwin process is executed. This patch fixes the issue. > --- > winsup/cygwin/fhandler_c

Re: [PATCH] Cygwin: pty: Reduce buffer size in get_console_process_id().

2021-01-20 Thread Corinna Vinschen via Cygwin-patches
On Jan 20 09:57, Takashi Yano via Cygwin-patches wrote: > - The buffer used in get_console_process_id(), introduced by commit > 72770148, is too large and ERROR_NOT_ENOUGH_MEMORY occurs in Win7. Huh, funny! Will we ever be happy with just 8192 processes per console? :) > Therefore, the buffe

[PATCH] Cygwin: console: Fix "Bad file descriptor" error in script command.

2021-01-20 Thread Takashi Yano via Cygwin-patches
- After the commit 72770148, script command exits occasionally with the error "Bad file descriptor" if it is started in console on Win7 and non-cygwin process is executed. This patch fixes the issue. --- winsup/cygwin/fhandler_console.cc | 10 ++-- winsup/cygwin/select.cc | 95 ++