diff options
author | Ron Yorston | 2021-07-31 13:51:57 +0100 |
---|---|---|
committer | Denys Vlasenko | 2021-10-09 01:47:12 +0200 |
commit | 94eb1c4dc6556932e1a12a0ce7734512ac95985e (patch) | |
tree | 610126c63688ebd23617d011912f8d6dd6972973 /include/libbb.h | |
parent | 86ba007b84ae1ebe35e88c57e023caac3d2d9903 (diff) | |
download | busybox-94eb1c4dc6556932e1a12a0ce7734512ac95985e.zip busybox-94eb1c4dc6556932e1a12a0ce7734512ac95985e.tar.gz |
libbb: better coreutils compatibility for realpath
Add some tests which coreutils realpath pass but BusyBox realpath
fails (bar one). Adjust xmalloc_realpath_coreutils() so the tests
pass:
- Expand symbolic links before testing whether the last path component
exists.
- When the link target is a relative path canonicalize it by passing
it through xmalloc_realpath_coreutils() as already happens for
absolute paths.
- Ignore trailing slashes when finding the last path component and
correctly handle the case where the only slash is at the start of
the path. This requires ignoring superfluous leading slashes.
- Undo all changes to the path so error messages from the caller show
the original filename.
function old new delta
xmalloc_realpath_coreutils 214 313 +99
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'include/libbb.h')
-rw-r--r-- | include/libbb.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/include/libbb.h b/include/libbb.h index b72576f..296417d 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -578,7 +578,7 @@ DIR *xopendir(const char *path) FAST_FUNC; DIR *warn_opendir(const char *path) FAST_FUNC; char *xmalloc_realpath(const char *path) FAST_FUNC RETURNS_MALLOC; -char *xmalloc_realpath_coreutils(const char *path) FAST_FUNC RETURNS_MALLOC; +char *xmalloc_realpath_coreutils(char *path) FAST_FUNC RETURNS_MALLOC; char *xmalloc_readlink(const char *path) FAST_FUNC RETURNS_MALLOC; char *xmalloc_readlink_or_warn(const char *path) FAST_FUNC RETURNS_MALLOC; /* !RETURNS_MALLOC: it's a realloc-like function */ |