aboutsummaryrefslogtreecommitdiff
path: root/libbb/xreadlink.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* win32: replace readlink(2)Ron Yorston2023-08-211-0/+2
| | | | | | | | | | | | | | | The Windows implementation of readlink(2) has caused problems in the past. As, for example, with commit c29dc205d2 (win32: fix implementation of readlink(2)). Most uses of readlink(2) in BusyBox are actually calls to the (considerably more convenient) library function xmalloc_readlink(). Implement a Windows version of that and used it instead of readlink(2). This improves the handling of symbolic links (and similar reparse points) in CJK and UTF-8 code pages. Saves 48-80 bytes.
* realpath: improved support for Windows pathsRon Yorston2021-10-131-0/+34
| | | | | | | | | | | | | | | | Upstream commit 94eb1c4dc (libbb: better coreutils compatibility for realpath) made some changes to xmalloc_realpath_coreutils(). This now needs to be updated to handle Windows paths. - Expose the macro is_unc_path() and part of the recent change to bb_get_last_path_component_nostrip() as a separate funtion, get_last_slash(); - Convert a couple of errors relating to network filesystems to ENOENT; - Adjust xmalloc_realpath_coreutils() to handle Windows directory separators, relative paths and UNC paths.
* Merge branch 'busybox' into mergeRon Yorston2021-10-131-30/+45
|\
| * libbb: better coreutils compatibility for realpathRon Yorston2021-10-091-30/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | win32: rename is_absolute_path()Ron Yorston2021-10-121-1/+1
| | | | | | | | | | As the comment pointed out is_absolute_path() was misnamed. Rename it to is_relative_path() and change the sense of all tests.
* | win32: better handling of nested symlinksRon Yorston2021-08-121-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Our realpath(3) implementation uses xmalloc_follow_symlinks() to expand symlinks. This detects when symlinks are too deeply nested but didn't set errno, so anything calling realpath(3) was unable to say what had gone wrong. (For example, 'ls -L' or 'stat -L'.) Set errno to ELOOP. This then leads to the problem that Windows doesn't know about ELOOP so reports 'Unknown error'. Add a replacement for strerror(3) which returns a sensible message. Costs 96 bytes.
* | libbb: fix detection of relative paths in xreadlink.csymlinkRon Yorston2021-03-011-0/+4
| | | | | | | | | | | | In xmalloc_follow_symlinks() the code to detect relative paths needs to be altered for WIN32. We don't want C:/path to be treated as a relative path.
* | Fix `xmalloc_readlink()` againRon Yorston2021-03-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In e86a3ddd8 (win32: make readlink(2) implementation unconditional, 2021-02-12), we removed the special casing of `errno == ENOSYS` when trying to follow symlinks. However, that handling really was necessary: - When we followed a symlink, and found a non-symlink, and then called `readlink()` with that non-symlink, we got `errno == ENOSYS` on Windows (translated from `ERROR_NOT_A_REPARSE_POINT`), and we did want to stop the loop and return the current path in that case. (Noted by Johannes Schindelin.) - When readlink() called DeviceIoControl() for files on certain filesystems (e.g. FAT or a CDROM) it returned `errno == ENOSYS` (translated from ERROR_INVALID_FUNCTION). Revert the part of the patch which handled `ENOSYS` on Windows.
* | win32: make readlink(2) implementation unconditionalRon Yorston2021-02-121-1/+1
| | | | | | | | | | | | | | 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.
* | Merge branch 'busybox' into mergeRon Yorston2019-08-161-0/+29
|\|
| * libbb: deal with "declaration of 'link' shadows a global declaration" warningDenys Vlasenko2019-06-251-7/+7
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * readlink,realpath: fix a case with a symplink, closes 11021Denys Vlasenko2019-06-131-0/+29
| | | | | | | | | | | | | | function old new delta xmalloc_realpath_coreutils 125 201 +76 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox'Ron Yorston2018-07-251-0/+30
|\|
| * whitespace fixDenys Vlasenko2018-05-261-1/+1
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * realpath,readlink -f: coreutils compat, closes 11021Denys Vlasenko2018-05-241-0/+30
| | | | | | | | | | | | | | function old new delta xmalloc_realpath_coreutils - 121 +121 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2017-11-031-1/+0
|\|
| * whitespace and comment format fixes, no code changesDenys Vlasenko2017-10-051-1/+0
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2014-05-061-4/+7
|\| | | | | | | | | | | | | Conflicts: debianutils/which.c editors/vi.c libbb/executable.c
| * libbb: fix a bad check for uclibc >= 0.9.31Denys Vlasenko2014-03-161-4/+7
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2014-01-021-0/+6
|\| | | | | | | | | | | Conflicts: archival/Config.src shell/ash.c
| * do not fail build if MAXSYMLINKS isn't definedMichael Tokarev2013-12-161-0/+6
| | | | | | | | | | | | | | This is needed for, eg, hurd, which is known to have no constraints. Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2013-03-191-1/+2
|\|
| * readlink: uClibc supports automatic allocation too nowMike Frysinger2013-03-121-1/+2
| | | | | | | | Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* | Merge branch 'origin/master' (early part)Nguyễn Thái Ngọc Duy2010-09-141-1/+1
|\|
| * *: make GNU licensing statement forms more regularDenys Vlasenko2010-08-161-1/+1
| | | | | | | | | | | | | | This change retains "or later" state! No licensing _changes_ here, only form is adjusted (article, space between "GPL" and "v2" and so on). Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | win32: xmalloc_follow_symlinks: support ENOSYS by mingw portNguyễn Thái Ngọc Duy2010-09-101-1/+1
|/
* Hurd compat fixes. Mostly dealing with absent PATH_MAXJérémie Koenig2010-03-261-4/+2
| | | | | Signed-off-by: Jérémie Koenig <jk@jk.fr.eu.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ls: make readlink error to not disrupt output (try ls -l /proc/self/fd).Denis Vlasenko2009-03-211-1/+5
| | | | | | | | | | | libbb: make xmalloc_readlink_or_warn warning more specific. function old new delta xmalloc_readlink_or_warn 33 61 +28 showfiles 1495 1460 -35 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 28/-35) Total: -7 bytes
* Fix forgotten license commentsDenis Vlasenko2008-12-071-2/+4
|
* *: introduce and use FAST_FUNC: regparm on i386, otherwise no-onDenis Vlasenko2008-06-271-4/+4
| | | | | | | text data bss dec hex filename 808035 611 6868 815514 c719a busybox_old 804472 611 6868 811951 c63af busybox_unstripped
* dos2unix: do not destroy symlinks and mode of the file being converted.Denis Vlasenko2008-06-141-1/+0
|
* syslogd: support "symlink to symlink" for /dev/log; reduce stack usageDenis Vlasenko2007-11-101-1/+1
| | | | | | | | | | | | function old new delta create_socket - 134 +134 syslogd_main 1132 865 -267 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/1 up/down: 134/-267) Total: -133 bytes text data bss dec hex filename 775603 974 9420 785997 bfe4d busybox_old 775445 974 9420 785839 bfdaf busybox_unstripped
* - commentary fixesBernhard Reutner-Fischer2007-11-081-11/+11
| | | | | | | - use common exit sequence for failure path: text data bss dec hex filename 308 0 0 308 134 libbb/xreadlink.o.pgf 296 0 0 296 128 libbb/xreadlink.o
* xmalloc_follow_symlinks() -- fix ELOOP issue with absolute paths,Paul Fox2007-11-081-15/+22
| | | | | return full path in cases where path doesn't resolve to a link. change name to better differentiate from xmalloc_readlink().
* xreadlink: code shrinkDenis Vlasenko2007-11-081-17/+18
| | | | | | | | | | udhcp: add missing tryagain member to client_config function old new delta xmalloc_readlink_follow 169 154 -15 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-15) Total: -15 bytes
* new xmalloc_readlink_follow() routine to fully expand trailing symlinksPaul Fox2007-11-081-0/+45
| | | | to get to a "real" file (or directory).
* insmod: code shrink, stop exporting insmod_ng_main.Denis Vlasenko2007-11-021-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta add_ksymoops_symbols - 421 +421 static.section_names 20 40 +20 lsmod_main 425 424 -1 set_tainted 153 150 -3 main_opts 4 - -4 obj_symbol_patch 47 42 -5 obj_string_patch 144 139 -5 already_loaded 144 138 -6 check_dep 348 341 -7 append_option 75 68 -7 obj_allocate_commons 515 501 -14 new_process_module_arguments 1039 1018 -21 arch_new_symbol 31 9 -22 check_module_name_match 85 61 -24 obj_create_alloced_section 164 136 -28 include_conf 930 902 -28 modprobe_main 1643 1535 -108 obj_load 924 777 -147 insmod_ng_main 245 - -245 insmod_main 4122 3794 -328 ------------------------------------------------------------------------------ (add/remove: 1/2 grow/shrink: 1/16 up/down: 441/-1003) Total: -562 bytes text data bss dec hex filename 776020 974 9420 786414 bffee busybox_old 775384 974 9420 785778 bfd72 busybox_unstripped
* busybox --install -s: prevent puzzling "/bin/busybox: Invalid argument" messageDenis Vlasenko2007-09-051-6/+16
| | | | | libbb: comment out realpath, add readlink which doesn't warn
* syslogd: fix "readpath bug" by using readlink insteadDenis Vlasenko2007-02-111-1/+1
| | | | libbb: rename xgetcwd and xreadlink
* accumulated post-1.4.0 fixesDenis Vlasenko2007-01-241-1/+1
|
* new libbb func: xmalloc_realpath (+ use it where makes sense)Denis Vlasenko2007-01-041-4/+14
| | | | | syslogd, logread: add debugging code (disabled) syslogs: drastically smaller bss; fix "-C n" behaviour
* Standardize on the vi editing directives being on the first line."Robert P. J. Day"2006-07-021-0/+1
|
* Patch from Denis Vlasenko turning static const int (which gets emitted intoRob Landley2006-03-101-1/+1
| | | | the busybox binary) into enums (which don't).
* Robert P. Day removed 8 gazillion occurrences of "extern" on functionRob Landley2006-03-061-1/+1
| | | | definitions. (That should only be on prototypes.)
* just whitespaceTim Riker2006-01-251-1/+1
|
* Patch from Tito to fix memory leak upon error.Glenn L McGrath2004-08-111-2/+3
|
* Remove trailing whitespace. Update copyright to include 2004.Eric Andersen2004-03-151-4/+4
|
* Major coreutils update.Manuel Novoa III2003-03-191-1/+1
|
* Applied vodz' patches #49 and #50 (with a small correction in runshell.c)Robert Griebl2002-07-191-2/+1
| | | | | | | | | #49: I found one memory overflow and memory leak in "ln" applet. Last patch reduced also 54 bytes. ;) #50: I found bug in loginutils/Makefile.in. New patch have also new function to libbb and aplied this to applets and other cosmetic changes.
* Per some comments from Lars Kellogg-Stedman <lars@larsshack.org>,Eric Andersen2001-05-071-3/+6
| | | | | | make xreadlink() return NULL on failure, and make sure everyone uses the interface correctly. -Erik