From: Johannes Schindelin <johannes.schindelin@gmx.de>
To: cygwin-patches@cygwin.com
Subject: [PATCH] fchmodat/fstatat: fix regression with empty `pathname`
Date: Tue, 27 Jun 2023 22:51:30 +0200 (CEST) [thread overview]
Message-ID: <c985ab15b28da4fe6f28da4e20236bc0feb484bd.1687898935.git.johannes.schindelin@gmx.de> (raw)
In 4b8222983f (Cygwin: fix errno values set by readlinkat, 2023-04-18)
the code of `readlinkat()` was adjusted to align the `errno` with Linux'
behavior.
To accommodate for that, the `gen_full_path_at()` function was modified,
and the caller was adjusted to expect either `ENOENT` or `ENOTDIR` in
the case of an empty `pathname`, not just `ENOENT`.
However, `readlinkat()` is not the only caller of that helper function.
And while most other callers simply propagate the `errno` produced by
`gen_full_path_at()`, two other callers also want to special-case empty
`pathnames` much like `readlinkat()`: `fchmodat()` and `fstatat()`.
Therefore, these two callers need to be changed to expect `ENOTDIR` in
case of an empty `pathname`, too.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
Published-As: https://github.com/dscho/msys2-runtime/releases/tag/fix-tar-xf-with-symlinks-cygwin-v1
Fetch-It-Via: git fetch https://github.com/dscho/msys2-runtime fix-tar-xf-with-symlinks-cygwin-v1
I noticed this issue when one of my workflows failed consistently
while trying to untar an archive containing a symbolic link and
claiming this:
Cannot change mode to rwxr-xr-x: Not a directory
With this here fix, things start working as expected again.
winsup/cygwin/syscalls.cc | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 73343ecc1f..c1889aec91 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -4580,7 +4580,7 @@ fchownat (int dirfd, const char *pathname, uid_t uid, gid_t gid, int flags)
int res = gen_full_path_at (path, dirfd, pathname);
if (res)
{
- if (!(errno == ENOENT && (flags & AT_EMPTY_PATH)))
+ if (!((errno == ENOENT || errno == ENOTDIR) && (flags & AT_EMPTY_PATH)))
__leave;
/* pathname is an empty string. Operate on dirfd. */
if (dirfd == AT_FDCWD)
@@ -4625,7 +4625,7 @@ fstatat (int dirfd, const char *__restrict pathname, struct stat *__restrict st,
int res = gen_full_path_at (path, dirfd, pathname);
if (res)
{
- if (!(errno == ENOENT && (flags & AT_EMPTY_PATH)))
+ if (!((errno == ENOENT || errno == ENOTDIR) && (flags & AT_EMPTY_PATH)))
__leave;
/* pathname is an empty string. Operate on dirfd. */
if (dirfd == AT_FDCWD)
base-commit: 4c7d0dfec5793cbf5cf3930b91f930479126d8ce
--
2.41.0.windows.1
next reply other threads:[~2023-06-27 20:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-27 20:51 Johannes Schindelin [this message]
2023-06-28 18:45 ` Jeremy Drake
2023-07-04 15:50 ` Johannes Schindelin
2023-07-03 10:54 ` Corinna Vinschen
2023-07-04 15:45 ` Johannes Schindelin
2023-07-04 18:38 ` Corinna Vinschen
2023-07-12 11:50 ` Corinna Vinschen
2023-07-04 15:34 ` [PATCH v2] " Johannes Schindelin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c985ab15b28da4fe6f28da4e20236bc0feb484bd.1687898935.git.johannes.schindelin@gmx.de \
--to=johannes.schindelin@gmx.de \
--cc=cygwin-patches@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).