From e86a3ddd8b60eb0720874f5b9679446d12a1ac41 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Fri, 12 Feb 2021 14:02:28 +0000 Subject: win32: make readlink(2) implementation unconditional There doesn't seem to be much advantage in having readlink(2) as a configuration option. Making it unconditional reduces divergence from upstream and allows the removal of a check for ENOSYS that's been in busybox-w32 since the start. --- Config.in | 10 ---------- configs/mingw32_defconfig | 1 - configs/mingw64_defconfig | 1 - coreutils/ls.c | 2 -- coreutils/stat.c | 7 ------- include/mingw.h | 4 ---- libbb/xreadlink.c | 2 +- win32/mingw.c | 4 ---- 8 files changed, 1 insertion(+), 30 deletions(-) diff --git a/Config.in b/Config.in index 356bc6d5a..da8a72a8e 100644 --- a/Config.in +++ b/Config.in @@ -492,16 +492,6 @@ config FEATURE_EXTRA_FILE_DATA determine the ownership of files so that, for example, 'ls' can distinguish files belonging to the current user. -config FEATURE_READLINK2 - bool "Read the contents of symbolic links (1.1 kb)" - default y - depends on PLATFORM_MINGW32 - help - Implement the readlink(2) system call to allow applets to read - the contents of symbolic links. With this feature ls and stat - can display the target of symbolic links and it makes sense to - enable the readlink applet. - comment 'Build Options' config STATIC diff --git a/configs/mingw32_defconfig b/configs/mingw32_defconfig index f245141f3..4edf90df3 100644 --- a/configs/mingw32_defconfig +++ b/configs/mingw32_defconfig @@ -55,7 +55,6 @@ CONFIG_FEATURE_EURO=y CONFIG_SKIP_ANSI_EMULATION_DEFAULT=2 CONFIG_FEATURE_IMPROVED_COLOUR_MAPPING=y CONFIG_FEATURE_EXTRA_FILE_DATA=y -CONFIG_FEATURE_READLINK2=y # # Build Options diff --git a/configs/mingw64_defconfig b/configs/mingw64_defconfig index 3ac1f7703..ff73f9a51 100644 --- a/configs/mingw64_defconfig +++ b/configs/mingw64_defconfig @@ -55,7 +55,6 @@ CONFIG_FEATURE_EURO=y CONFIG_SKIP_ANSI_EMULATION_DEFAULT=2 CONFIG_FEATURE_IMPROVED_COLOUR_MAPPING=y CONFIG_FEATURE_EXTRA_FILE_DATA=y -CONFIG_FEATURE_READLINK2=y # # Build Options diff --git a/coreutils/ls.c b/coreutils/ls.c index e891a67ce..67f6c8c56 100644 --- a/coreutils/ls.c +++ b/coreutils/ls.c @@ -495,11 +495,9 @@ static NOINLINE unsigned display_single(const struct dnode *dn) /* Do readlink early, so that if it fails, error message * does not appear *inside* the "ls -l" line */ lpath = NULL; -#if ENABLE_PLATFORM_POSIX || ENABLE_FEATURE_READLINK2 if (opt & OPT_l) if (S_ISLNK(dn->dn_mode)) lpath = xmalloc_readlink_or_warn(dn->fullname); -#endif if (opt & OPT_i) /* show inode# */ #if !ENABLE_FEATURE_EXTRA_FILE_DATA diff --git a/coreutils/stat.c b/coreutils/stat.c index 1e93dce80..96cbf6dc6 100644 --- a/coreutils/stat.c +++ b/coreutils/stat.c @@ -314,7 +314,6 @@ static void FAST_FUNC print_stat(char *pformat, const char m, struct passwd *pw_ent; struct group *gw_ent; -#if ENABLE_PLATFORM_POSIX || ENABLE_FEATURE_READLINK2 if (m == 'n') { printfs(pformat, filename); } else if (m == 'N') { @@ -328,10 +327,6 @@ static void FAST_FUNC print_stat(char *pformat, const char m, } else { printf(pformat, filename); } -#else - if (m == 'n' || m == 'N') { - printfs(pformat, filename); -#endif } else if (m == 'd') { strcat(pformat, "llu"); printf(pformat, (unsigned long long) statbuf->st_dev); @@ -715,10 +710,8 @@ static bool do_stat(const char *filename, const char *format) gw_ent = getgrgid(statbuf.st_gid); pw_ent = getpwuid(statbuf.st_uid); -#if ENABLE_PLATFORM_POSIX || ENABLE_FEATURE_READLINK2 if (S_ISLNK(statbuf.st_mode)) linkname = xmalloc_readlink_or_warn(filename); -#endif if (linkname) { printf(" File: '%s' -> '%s'\n", filename, linkname); free(linkname); diff --git a/include/mingw.h b/include/mingw.h index 236c955d8..713205ef9 100644 --- a/include/mingw.h +++ b/include/mingw.h @@ -433,11 +433,7 @@ ssize_t mingw_open_read_close(const char *fn, void *buf, size_t size) FAST_FUNC; ssize_t mingw_read(int fd, void *buf, size_t count); int mingw_close(int fd); int pipe(int filedes[2]); -#if ENABLE_FEATURE_READLINK2 ssize_t readlink(const char *pathname, char *buf, size_t bufsiz); -#else -NOIMPL(readlink,const char *path UNUSED_PARAM, char *buf UNUSED_PARAM, size_t bufsiz UNUSED_PARAM); -#endif NOIMPL(setgid,gid_t gid UNUSED_PARAM); NOIMPL(setegid,gid_t gid UNUSED_PARAM); NOIMPL(setsid,void); diff --git a/libbb/xreadlink.c b/libbb/xreadlink.c index ca53e12d3..a18dd0748 100644 --- a/libbb/xreadlink.c +++ b/libbb/xreadlink.c @@ -64,7 +64,7 @@ char* FAST_FUNC xmalloc_follow_symlinks(const char *path) linkpath = xmalloc_readlink(buf); if (!linkpath) { /* not a symlink, or doesn't exist */ - if (errno == EINVAL || errno == ENOENT || (ENABLE_PLATFORM_MINGW32 && errno == ENOSYS)) + if (errno == EINVAL || errno == ENOENT) return buf; goto free_buf_ret_null; } diff --git a/win32/mingw.c b/win32/mingw.c index 474d9cdc6..15529ed58 100644 --- a/win32/mingw.c +++ b/win32/mingw.c @@ -4,9 +4,7 @@ #if ENABLE_FEATURE_EXTRA_FILE_DATA #include #endif -#if ENABLE_FEATURE_READLINK2 #include -#endif #if defined(__MINGW64_VERSION_MAJOR) #if ENABLE_GLOBBING @@ -1146,7 +1144,6 @@ char *realpath(const char *path, char *resolved_path) return NULL; } -#if ENABLE_FEATURE_READLINK2 static wchar_t *normalize_ntpath(wchar_t *wbuf) { int i; @@ -1206,7 +1203,6 @@ ssize_t readlink(const char *pathname, char *buf, size_t bufsiz) errno = err_win_to_posix(); return -1; } -#endif const char *get_busybox_exec_path(void) { -- cgit v1.2.3-55-g6feb