diff options
author | Ron Yorston <rmy@pobox.com> | 2021-02-12 14:02:28 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2021-02-12 14:02:28 +0000 |
commit | e86a3ddd8b60eb0720874f5b9679446d12a1ac41 (patch) | |
tree | f35332dccaec68bfd182f705dcec0b2297d3a578 | |
parent | 90f35327c2f31b7e4d938bf4d54e5526e53daee0 (diff) | |
download | busybox-w32-e86a3ddd8b60eb0720874f5b9679446d12a1ac41.tar.gz busybox-w32-e86a3ddd8b60eb0720874f5b9679446d12a1ac41.tar.bz2 busybox-w32-e86a3ddd8b60eb0720874f5b9679446d12a1ac41.zip |
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.
-rw-r--r-- | Config.in | 10 | ||||
-rw-r--r-- | configs/mingw32_defconfig | 1 | ||||
-rw-r--r-- | configs/mingw64_defconfig | 1 | ||||
-rw-r--r-- | coreutils/ls.c | 2 | ||||
-rw-r--r-- | coreutils/stat.c | 7 | ||||
-rw-r--r-- | include/mingw.h | 4 | ||||
-rw-r--r-- | libbb/xreadlink.c | 2 | ||||
-rw-r--r-- | win32/mingw.c | 4 |
8 files changed, 1 insertions, 30 deletions
@@ -492,16 +492,6 @@ config FEATURE_EXTRA_FILE_DATA | |||
492 | determine the ownership of files so that, for example, 'ls' can | 492 | determine the ownership of files so that, for example, 'ls' can |
493 | distinguish files belonging to the current user. | 493 | distinguish files belonging to the current user. |
494 | 494 | ||
495 | config FEATURE_READLINK2 | ||
496 | bool "Read the contents of symbolic links (1.1 kb)" | ||
497 | default y | ||
498 | depends on PLATFORM_MINGW32 | ||
499 | help | ||
500 | Implement the readlink(2) system call to allow applets to read | ||
501 | the contents of symbolic links. With this feature ls and stat | ||
502 | can display the target of symbolic links and it makes sense to | ||
503 | enable the readlink applet. | ||
504 | |||
505 | comment 'Build Options' | 495 | comment 'Build Options' |
506 | 496 | ||
507 | config STATIC | 497 | 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 | |||
55 | CONFIG_SKIP_ANSI_EMULATION_DEFAULT=2 | 55 | CONFIG_SKIP_ANSI_EMULATION_DEFAULT=2 |
56 | CONFIG_FEATURE_IMPROVED_COLOUR_MAPPING=y | 56 | CONFIG_FEATURE_IMPROVED_COLOUR_MAPPING=y |
57 | CONFIG_FEATURE_EXTRA_FILE_DATA=y | 57 | CONFIG_FEATURE_EXTRA_FILE_DATA=y |
58 | CONFIG_FEATURE_READLINK2=y | ||
59 | 58 | ||
60 | # | 59 | # |
61 | # Build Options | 60 | # 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 | |||
55 | CONFIG_SKIP_ANSI_EMULATION_DEFAULT=2 | 55 | CONFIG_SKIP_ANSI_EMULATION_DEFAULT=2 |
56 | CONFIG_FEATURE_IMPROVED_COLOUR_MAPPING=y | 56 | CONFIG_FEATURE_IMPROVED_COLOUR_MAPPING=y |
57 | CONFIG_FEATURE_EXTRA_FILE_DATA=y | 57 | CONFIG_FEATURE_EXTRA_FILE_DATA=y |
58 | CONFIG_FEATURE_READLINK2=y | ||
59 | 58 | ||
60 | # | 59 | # |
61 | # Build Options | 60 | # 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) | |||
495 | /* Do readlink early, so that if it fails, error message | 495 | /* Do readlink early, so that if it fails, error message |
496 | * does not appear *inside* the "ls -l" line */ | 496 | * does not appear *inside* the "ls -l" line */ |
497 | lpath = NULL; | 497 | lpath = NULL; |
498 | #if ENABLE_PLATFORM_POSIX || ENABLE_FEATURE_READLINK2 | ||
499 | if (opt & OPT_l) | 498 | if (opt & OPT_l) |
500 | if (S_ISLNK(dn->dn_mode)) | 499 | if (S_ISLNK(dn->dn_mode)) |
501 | lpath = xmalloc_readlink_or_warn(dn->fullname); | 500 | lpath = xmalloc_readlink_or_warn(dn->fullname); |
502 | #endif | ||
503 | 501 | ||
504 | if (opt & OPT_i) /* show inode# */ | 502 | if (opt & OPT_i) /* show inode# */ |
505 | #if !ENABLE_FEATURE_EXTRA_FILE_DATA | 503 | #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, | |||
314 | struct passwd *pw_ent; | 314 | struct passwd *pw_ent; |
315 | struct group *gw_ent; | 315 | struct group *gw_ent; |
316 | 316 | ||
317 | #if ENABLE_PLATFORM_POSIX || ENABLE_FEATURE_READLINK2 | ||
318 | if (m == 'n') { | 317 | if (m == 'n') { |
319 | printfs(pformat, filename); | 318 | printfs(pformat, filename); |
320 | } else if (m == 'N') { | 319 | } else if (m == 'N') { |
@@ -328,10 +327,6 @@ static void FAST_FUNC print_stat(char *pformat, const char m, | |||
328 | } else { | 327 | } else { |
329 | printf(pformat, filename); | 328 | printf(pformat, filename); |
330 | } | 329 | } |
331 | #else | ||
332 | if (m == 'n' || m == 'N') { | ||
333 | printfs(pformat, filename); | ||
334 | #endif | ||
335 | } else if (m == 'd') { | 330 | } else if (m == 'd') { |
336 | strcat(pformat, "llu"); | 331 | strcat(pformat, "llu"); |
337 | printf(pformat, (unsigned long long) statbuf->st_dev); | 332 | printf(pformat, (unsigned long long) statbuf->st_dev); |
@@ -715,10 +710,8 @@ static bool do_stat(const char *filename, const char *format) | |||
715 | gw_ent = getgrgid(statbuf.st_gid); | 710 | gw_ent = getgrgid(statbuf.st_gid); |
716 | pw_ent = getpwuid(statbuf.st_uid); | 711 | pw_ent = getpwuid(statbuf.st_uid); |
717 | 712 | ||
718 | #if ENABLE_PLATFORM_POSIX || ENABLE_FEATURE_READLINK2 | ||
719 | if (S_ISLNK(statbuf.st_mode)) | 713 | if (S_ISLNK(statbuf.st_mode)) |
720 | linkname = xmalloc_readlink_or_warn(filename); | 714 | linkname = xmalloc_readlink_or_warn(filename); |
721 | #endif | ||
722 | if (linkname) { | 715 | if (linkname) { |
723 | printf(" File: '%s' -> '%s'\n", filename, linkname); | 716 | printf(" File: '%s' -> '%s'\n", filename, linkname); |
724 | free(linkname); | 717 | 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; | |||
433 | ssize_t mingw_read(int fd, void *buf, size_t count); | 433 | ssize_t mingw_read(int fd, void *buf, size_t count); |
434 | int mingw_close(int fd); | 434 | int mingw_close(int fd); |
435 | int pipe(int filedes[2]); | 435 | int pipe(int filedes[2]); |
436 | #if ENABLE_FEATURE_READLINK2 | ||
437 | ssize_t readlink(const char *pathname, char *buf, size_t bufsiz); | 436 | ssize_t readlink(const char *pathname, char *buf, size_t bufsiz); |
438 | #else | ||
439 | NOIMPL(readlink,const char *path UNUSED_PARAM, char *buf UNUSED_PARAM, size_t bufsiz UNUSED_PARAM); | ||
440 | #endif | ||
441 | NOIMPL(setgid,gid_t gid UNUSED_PARAM); | 437 | NOIMPL(setgid,gid_t gid UNUSED_PARAM); |
442 | NOIMPL(setegid,gid_t gid UNUSED_PARAM); | 438 | NOIMPL(setegid,gid_t gid UNUSED_PARAM); |
443 | NOIMPL(setsid,void); | 439 | 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) | |||
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 || (ENABLE_PLATFORM_MINGW32 && errno == ENOSYS)) | 67 | if (errno == EINVAL || errno == ENOENT) |
68 | return buf; | 68 | return buf; |
69 | goto free_buf_ret_null; | 69 | goto free_buf_ret_null; |
70 | } | 70 | } |
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 @@ | |||
4 | #if ENABLE_FEATURE_EXTRA_FILE_DATA | 4 | #if ENABLE_FEATURE_EXTRA_FILE_DATA |
5 | #include <aclapi.h> | 5 | #include <aclapi.h> |
6 | #endif | 6 | #endif |
7 | #if ENABLE_FEATURE_READLINK2 | ||
8 | #include <ntdef.h> | 7 | #include <ntdef.h> |
9 | #endif | ||
10 | 8 | ||
11 | #if defined(__MINGW64_VERSION_MAJOR) | 9 | #if defined(__MINGW64_VERSION_MAJOR) |
12 | #if ENABLE_GLOBBING | 10 | #if ENABLE_GLOBBING |
@@ -1146,7 +1144,6 @@ char *realpath(const char *path, char *resolved_path) | |||
1146 | return NULL; | 1144 | return NULL; |
1147 | } | 1145 | } |
1148 | 1146 | ||
1149 | #if ENABLE_FEATURE_READLINK2 | ||
1150 | static wchar_t *normalize_ntpath(wchar_t *wbuf) | 1147 | static wchar_t *normalize_ntpath(wchar_t *wbuf) |
1151 | { | 1148 | { |
1152 | int i; | 1149 | int i; |
@@ -1206,7 +1203,6 @@ ssize_t readlink(const char *pathname, char *buf, size_t bufsiz) | |||
1206 | errno = err_win_to_posix(); | 1203 | errno = err_win_to_posix(); |
1207 | return -1; | 1204 | return -1; |
1208 | } | 1205 | } |
1209 | #endif | ||
1210 | 1206 | ||
1211 | const char *get_busybox_exec_path(void) | 1207 | const char *get_busybox_exec_path(void) |
1212 | { | 1208 | { |