aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2018-04-10 21:52:58 +0100
committerRon Yorston <rmy@pobox.com>2018-04-10 21:52:58 +0100
commit0038f9d39a306c3c7860756f03102de217dc5cd9 (patch)
tree4ce098f303e70d397d31683bdd37874a87b817b5
parent072edb130eaabd50961df71156c3ca7d0773d690 (diff)
downloadbusybox-w32-0038f9d39a306c3c7860756f03102de217dc5cd9.tar.gz
busybox-w32-0038f9d39a306c3c7860756f03102de217dc5cd9.tar.bz2
busybox-w32-0038f9d39a306c3c7860756f03102de217dc5cd9.zip
ls, stat: don't try to read symlinks
Currently the WIN32 emulation of readlink(2) fails with ENOSYS. This causes ugly error messages in ls and stat. Don't even try calling readlink(2) and skip any code that uses the name it doesn't return.
-rw-r--r--coreutils/ls.c2
-rw-r--r--coreutils/stat.c8
2 files changed, 10 insertions, 0 deletions
diff --git a/coreutils/ls.c b/coreutils/ls.c
index 4cc9517b1..b0c543d28 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -492,9 +492,11 @@ static NOINLINE unsigned display_single(const struct dnode *dn)
492 /* Do readlink early, so that if it fails, error message 492 /* Do readlink early, so that if it fails, error message
493 * does not appear *inside* the "ls -l" line */ 493 * does not appear *inside* the "ls -l" line */
494 lpath = NULL; 494 lpath = NULL;
495#if !ENABLE_PLATFORM_MINGW32
495 if (opt & OPT_l) 496 if (opt & OPT_l)
496 if (S_ISLNK(dn->dn_mode)) 497 if (S_ISLNK(dn->dn_mode))
497 lpath = xmalloc_readlink_or_warn(dn->fullname); 498 lpath = xmalloc_readlink_or_warn(dn->fullname);
499#endif
498 500
499 if (opt & OPT_i) /* show inode# */ 501 if (opt & OPT_i) /* show inode# */
500 column += printf("%7"LL_FMT"u ", (long long) dn->dn_ino); 502 column += printf("%7"LL_FMT"u ", (long long) dn->dn_ino);
diff --git a/coreutils/stat.c b/coreutils/stat.c
index 2944cdfcb..43fad2324 100644
--- a/coreutils/stat.c
+++ b/coreutils/stat.c
@@ -317,6 +317,7 @@ static void FAST_FUNC print_stat(char *pformat, const char m,
317 printfs(pformat, filename); 317 printfs(pformat, filename);
318 } else if (m == 'N') { 318 } else if (m == 'N') {
319 strcatc(pformat, 's'); 319 strcatc(pformat, 's');
320#if !ENABLE_PLATFORM_MINGW32
320 if (S_ISLNK(statbuf->st_mode)) { 321 if (S_ISLNK(statbuf->st_mode)) {
321 char *linkname = xmalloc_readlink_or_warn(filename); 322 char *linkname = xmalloc_readlink_or_warn(filename);
322 if (linkname == NULL) 323 if (linkname == NULL)
@@ -326,6 +327,9 @@ static void FAST_FUNC print_stat(char *pformat, const char m,
326 } else { 327 } else {
327 printf(pformat, filename); 328 printf(pformat, filename);
328 } 329 }
330#else
331 printf(pformat, filename);
332#endif
329 } else if (m == 'd') { 333 } else if (m == 'd') {
330 strcat(pformat, "llu"); 334 strcat(pformat, "llu");
331 printf(pformat, (unsigned long long) statbuf->st_dev); 335 printf(pformat, (unsigned long long) statbuf->st_dev);
@@ -708,6 +712,7 @@ static bool do_stat(const char *filename, const char *format)
708 gw_ent = getgrgid(statbuf.st_gid); 712 gw_ent = getgrgid(statbuf.st_gid);
709 pw_ent = getpwuid(statbuf.st_uid); 713 pw_ent = getpwuid(statbuf.st_uid);
710 714
715#if !ENABLE_PLATFORM_MINGW32
711 if (S_ISLNK(statbuf.st_mode)) 716 if (S_ISLNK(statbuf.st_mode))
712 linkname = xmalloc_readlink_or_warn(filename); 717 linkname = xmalloc_readlink_or_warn(filename);
713 if (linkname) { 718 if (linkname) {
@@ -716,6 +721,9 @@ static bool do_stat(const char *filename, const char *format)
716 } else { 721 } else {
717 printf(" File: '%s'\n", filename); 722 printf(" File: '%s'\n", filename);
718 } 723 }
724#else
725 printf(" File: '%s'\n", filename);
726#endif
719 727
720 printf(" Size: %-10llu\tBlocks: %-10llu IO Block: %-6lu %s\n" 728 printf(" Size: %-10llu\tBlocks: %-10llu IO Block: %-6lu %s\n"
721 "Device: %llxh/%llud\tInode: %-10llu Links: %-5lu", 729 "Device: %llxh/%llud\tInode: %-10llu Links: %-5lu",