aboutsummaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2019-03-06 10:05:06 +0000
committerRon Yorston <rmy@pobox.com>2019-03-06 10:05:06 +0000
commit5c5197df8668ba58ec7799ccc418d124a6c6a49e (patch)
treeb2cf42a770934c7adba484b5abe5e5e04e76fbff /coreutils
parent8ebe81483b8759c36c9aa5015044d8e3d2c50fd5 (diff)
downloadbusybox-w32-5c5197df8668ba58ec7799ccc418d124a6c6a49e.tar.gz
busybox-w32-5c5197df8668ba58ec7799ccc418d124a6c6a49e.tar.bz2
busybox-w32-5c5197df8668ba58ec7799ccc418d124a6c6a49e.zip
win32: implement readlink(2)
Provide an implementation of readlink(2) based on code from Git for Windows. This version only supports symbolic links, not mount points, as the latter seem to work well enough as-is. With this change the ls and stat applets can display the targets of symbolic links. The readlink applet has been enabled in the default configuration.
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/ls.c2
-rw-r--r--coreutils/stat.c4
2 files changed, 3 insertions, 3 deletions
diff --git a/coreutils/ls.c b/coreutils/ls.c
index c5402de30..6be3eb291 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -492,7 +492,7 @@ 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 ENABLE_PLATFORM_POSIX || ENABLE_FEATURE_READLINK2
496 if (opt & OPT_l) 496 if (opt & OPT_l)
497 if (S_ISLNK(dn->dn_mode)) 497 if (S_ISLNK(dn->dn_mode))
498 lpath = xmalloc_readlink_or_warn(dn->fullname); 498 lpath = xmalloc_readlink_or_warn(dn->fullname);
diff --git a/coreutils/stat.c b/coreutils/stat.c
index 32bc5e2d3..cf13af0b6 100644
--- a/coreutils/stat.c
+++ b/coreutils/stat.c
@@ -317,7 +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 ENABLE_PLATFORM_POSIX || ENABLE_FEATURE_READLINK2
321 if (S_ISLNK(statbuf->st_mode)) { 321 if (S_ISLNK(statbuf->st_mode)) {
322 char *linkname = xmalloc_readlink_or_warn(filename); 322 char *linkname = xmalloc_readlink_or_warn(filename);
323 if (linkname == NULL) 323 if (linkname == NULL)
@@ -712,7 +712,7 @@ static bool do_stat(const char *filename, const char *format)
712 gw_ent = getgrgid(statbuf.st_gid); 712 gw_ent = getgrgid(statbuf.st_gid);
713 pw_ent = getpwuid(statbuf.st_uid); 713 pw_ent = getpwuid(statbuf.st_uid);
714 714
715#if !ENABLE_PLATFORM_MINGW32 715#if ENABLE_PLATFORM_POSIX || ENABLE_FEATURE_READLINK2
716 if (S_ISLNK(statbuf.st_mode)) 716 if (S_ISLNK(statbuf.st_mode))
717 linkname = xmalloc_readlink_or_warn(filename); 717 linkname = xmalloc_readlink_or_warn(filename);
718 if (linkname) { 718 if (linkname) {