Commit Graph

35 Commits

Author SHA1 Message Date
Ron Yorston
94eb1c4dc6 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>
2021-10-09 01:47:12 +02:00
Denys Vlasenko
25a871fb40 libbb: deal with "declaration of 'link' shadows a global declaration" warning
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-06-25 18:51:00 +02:00
Denys Vlasenko
070aa61747 readlink,realpath: fix a case with a symplink, closes 11021
function                                             old     new   delta
xmalloc_realpath_coreutils                           125     201     +76

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-06-13 17:09:05 +02:00
Denys Vlasenko
bf7f103ffb whitespace fix
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-05-26 17:42:00 +02:00
Denys Vlasenko
747162109f realpath,readlink -f: coreutils compat, closes 11021
function                                             old     new   delta
xmalloc_realpath_coreutils                             -     121    +121

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-05-24 17:31:00 +02:00
Denys Vlasenko
ebe6d9d875 whitespace and comment format fixes, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-10-05 14:40:24 +02:00
Denys Vlasenko
c50493854a libbb: fix a bad check for uclibc >= 0.9.31
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-03-16 20:53:40 +01:00
Michael Tokarev
9f4f60183b do not fail build if MAXSYMLINKS isn't defined
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>
2013-12-16 03:41:30 +01:00
Mike Frysinger
af9e70b8cb readlink: uClibc supports automatic allocation too now
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2013-03-12 11:14:24 -04:00
Denys Vlasenko
0ef64bdb40 *: make GNU licensing statement forms more regular
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>
2010-08-16 20:14:46 +02:00
Jérémie Koenig
fbedacfc8c Hurd compat fixes. Mostly dealing with absent PATH_MAX
Signed-off-by: Jérémie Koenig <jk@jk.fr.eu.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-03-26 19:08:53 +01:00
Denis Vlasenko
3a014b85dc ls: make readlink error to not disrupt output (try ls -l /proc/self/fd).
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
2009-03-21 19:11:23 +00:00
Denis Vlasenko
db12d1d733 Fix forgotten license comments 2008-12-07 00:52:58 +00:00
Denis Vlasenko
defc1ea340 *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on
text    data     bss     dec     hex filename
 808035     611    6868  815514   c719a busybox_old
 804472     611    6868  811951   c63af busybox_unstripped
2008-06-27 02:52:20 +00:00
Denis Vlasenko
a1767a1f5d dos2unix: do not destroy symlinks and mode of the file being converted. 2008-06-14 04:28:41 +00:00
Denis Vlasenko
d031b203c7 syslogd: support "symlink to symlink" for /dev/log; reduce stack usage
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
2007-11-10 01:28:19 +00:00
Bernhard Reutner-Fischer
9bd8d0c23e - commentary fixes
- 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
2007-11-08 21:11:43 +00:00
Paul Fox
599bbfbd9b xmalloc_follow_symlinks() -- fix ELOOP issue with absolute paths,
return full path in cases where path doesn't resolve to a link. 
change name to better differentiate from xmalloc_readlink().
2007-11-08 20:00:36 +00:00
Denis Vlasenko
abbd363261 xreadlink: code shrink
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
2007-11-08 17:40:23 +00:00
Paul Fox
459a2ba1ef new xmalloc_readlink_follow() routine to fully expand trailing symlinks
to get to a "real" file (or directory).
2007-11-08 01:11:41 +00:00
Denis Vlasenko
b68979aefa insmod: code shrink, stop exporting insmod_ng_main.
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
2007-11-02 23:31:10 +00:00
Denis Vlasenko
beffd43d8e busybox --install -s: prevent puzzling "/bin/busybox: Invalid argument" message
libbb: comment out realpath, add readlink which doesn't warn
2007-09-05 11:30:34 +00:00
Denis Vlasenko
6ca0444420 syslogd: fix "readpath bug" by using readlink instead
libbb: rename xgetcwd and xreadlink
2007-02-11 16:19:28 +00:00
Denis Vlasenko
218f2f4882 accumulated post-1.4.0 fixes 2007-01-24 22:02:01 +00:00
Denis Vlasenko
a9b60e93ee new libbb func: xmalloc_realpath (+ use it where makes sense)
syslogd, logread: add debugging code (disabled)
syslogs: drastically smaller bss; fix "-C n" behaviour
2007-01-04 17:59:59 +00:00
"Robert P. J. Day"
63fc1a9e08 Standardize on the vi editing directives being on the first line. 2006-07-02 19:47:05 +00:00
Rob Landley
bc68cd14cc Patch from Denis Vlasenko turning static const int (which gets emitted into
the busybox binary) into enums (which don't).
2006-03-10 19:22:06 +00:00
Rob Landley
dfba741457 Robert P. Day removed 8 gazillion occurrences of "extern" on function
definitions.  (That should only be on prototypes.)
2006-03-06 20:47:33 +00:00
Tim Riker
c1ef7bdd8d just whitespace 2006-01-25 00:08:53 +00:00
Glenn L McGrath
18bbd9bf3b Patch from Tito to fix memory leak upon error. 2004-08-11 03:50:30 +00:00
Eric Andersen
c7bda1ce65 Remove trailing whitespace. Update copyright to include 2004. 2004-03-15 08:29:22 +00:00
Manuel Novoa III
cad5364599 Major coreutils update. 2003-03-19 09:13:01 +00:00
Robert Griebl
d378c3149c Applied vodz' patches #49 and #50 (with a small correction in runshell.c)
#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.
2002-07-19 00:05:54 +00:00
Eric Andersen
28355a36da Per some comments from Lars Kellogg-Stedman <lars@larsshack.org>,
make xreadlink() return NULL on failure, and make sure everyone
uses the interface correctly.
 -Erik
2001-05-07 17:48:28 +00:00
Mark Whitley
8a633268ef Made new xreadlink function for libbb and changed applets to use it instead of
readlink(2).
2001-04-30 18:17:00 +00:00