diff options
author | Ron Yorston <rmy@pobox.com> | 2021-03-01 09:31:21 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2021-03-01 09:31:21 +0000 |
commit | 3c44f5cae158ff4ffd03a4c319777ae88a60bcb9 (patch) | |
tree | e727f576233657072eac4c993e3c7a7fdf9ca96e | |
parent | 367f583cffcabdeebc3c27a42eba1926b5ea9819 (diff) | |
download | busybox-w32-3c44f5cae158ff4ffd03a4c319777ae88a60bcb9.tar.gz busybox-w32-3c44f5cae158ff4ffd03a4c319777ae88a60bcb9.tar.bz2 busybox-w32-3c44f5cae158ff4ffd03a4c319777ae88a60bcb9.zip |
Fix `xmalloc_readlink()` again
In e86a3ddd8 (win32: make readlink(2) implementation unconditional,
2021-02-12), we removed the special casing of `errno == ENOSYS` when
trying to follow symlinks. However, that handling really was necessary:
- When we followed a symlink, and found a non-symlink, and then called
`readlink()` with that non-symlink, we got `errno == ENOSYS` on
Windows (translated from `ERROR_NOT_A_REPARSE_POINT`), and we did
want to stop the loop and return the current path in that case.
(Noted by Johannes Schindelin.)
- When readlink() called DeviceIoControl() for files on certain
filesystems (e.g. FAT or a CDROM) it returned `errno == ENOSYS`
(translated from ERROR_INVALID_FUNCTION).
Revert the part of the patch which handled `ENOSYS` on Windows.
-rw-r--r-- | libbb/xreadlink.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libbb/xreadlink.c b/libbb/xreadlink.c index a18dd0748..ca53e12d3 100644 --- a/libbb/xreadlink.c +++ b/libbb/xreadlink.c | |||
@@ -64,7 +64,7 @@ char* FAST_FUNC xmalloc_follow_symlinks(const char *path) | |||
64 | linkpath = xmalloc_readlink(buf); | 64 | linkpath = xmalloc_readlink(buf); |
65 | if (!linkpath) { | 65 | if (!linkpath) { |
66 | /* not a symlink, or doesn't exist */ | 66 | /* not a symlink, or doesn't exist */ |
67 | if (errno == EINVAL || errno == ENOENT) | 67 | if (errno == EINVAL || errno == ENOENT || (ENABLE_PLATFORM_MINGW32 && errno == ENOSYS)) |
68 | return buf; | 68 | return buf; |
69 | goto free_buf_ret_null; | 69 | goto free_buf_ret_null; |
70 | } | 70 | } |