b68979aefa
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
60 lines
1.2 KiB
C
60 lines
1.2 KiB
C
/* vi: set sw=4 ts=4: */
|
|
/*
|
|
* xreadlink.c - safe implementation of readlink.
|
|
* Returns a NULL on failure...
|
|
*/
|
|
|
|
#include "libbb.h"
|
|
|
|
/*
|
|
* NOTE: This function returns a malloced char* that you will have to free
|
|
* yourself. You have been warned.
|
|
*/
|
|
char *xmalloc_readlink(const char *path)
|
|
{
|
|
enum { GROWBY = 80 }; /* how large we will grow strings by */
|
|
|
|
char *buf = NULL;
|
|
int bufsize = 0, readsize = 0;
|
|
|
|
do {
|
|
bufsize += GROWBY;
|
|
buf = xrealloc(buf, bufsize);
|
|
readsize = readlink(path, buf, bufsize);
|
|
if (readsize == -1) {
|
|
free(buf);
|
|
return NULL;
|
|
}
|
|
} while (bufsize < readsize + 1);
|
|
|
|
buf[readsize] = '\0';
|
|
|
|
return buf;
|
|
}
|
|
|
|
char *xmalloc_readlink_or_warn(const char *path)
|
|
{
|
|
char *buf = xmalloc_readlink(path);
|
|
if (!buf) {
|
|
/* EINVAL => "file: Invalid argument" => puzzled user */
|
|
bb_error_msg("%s: cannot read link (not a symlink?)", path);
|
|
}
|
|
return buf;
|
|
}
|
|
|
|
/* UNUSED */
|
|
#if 0
|
|
char *xmalloc_realpath(const char *path)
|
|
{
|
|
#if defined(__GLIBC__) && !defined(__UCLIBC__)
|
|
/* glibc provides a non-standard extension */
|
|
return realpath(path, NULL);
|
|
#else
|
|
char buf[PATH_MAX+1];
|
|
|
|
/* on error returns NULL (xstrdup(NULL) ==NULL) */
|
|
return xstrdup(realpath(path, buf));
|
|
#endif
|
|
}
|
|
#endif
|