aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-09-05 11:30:34 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-09-05 11:30:34 +0000
commitbeffd43d8e393b68787a00d9c6078a2b367afd01 (patch)
tree485a6f36aa57e182801babc1365f128bfaa52f5e /libbb
parent7e0fbf9c26350a819661241bc925cb88f26bb992 (diff)
downloadbusybox-w32-beffd43d8e393b68787a00d9c6078a2b367afd01.tar.gz
busybox-w32-beffd43d8e393b68787a00d9c6078a2b367afd01.tar.bz2
busybox-w32-beffd43d8e393b68787a00d9c6078a2b367afd01.zip
busybox --install -s: prevent puzzling "/bin/busybox: Invalid argument" message
libbb: comment out realpath, add readlink which doesn't warn
Diffstat (limited to 'libbb')
-rw-r--r--libbb/xreadlink.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/libbb/xreadlink.c b/libbb/xreadlink.c
index 18a8b9467..4d87b944d 100644
--- a/libbb/xreadlink.c
+++ b/libbb/xreadlink.c
@@ -10,8 +10,7 @@
10 * NOTE: This function returns a malloced char* that you will have to free 10 * NOTE: This function returns a malloced char* that you will have to free
11 * yourself. You have been warned. 11 * yourself. You have been warned.
12 */ 12 */
13 13char *xmalloc_readlink(const char *path)
14char *xmalloc_readlink_or_warn(const char *path)
15{ 14{
16 enum { GROWBY = 80 }; /* how large we will grow strings by */ 15 enum { GROWBY = 80 }; /* how large we will grow strings by */
17 16
@@ -20,20 +19,30 @@ char *xmalloc_readlink_or_warn(const char *path)
20 19
21 do { 20 do {
22 buf = xrealloc(buf, bufsize += GROWBY); 21 buf = xrealloc(buf, bufsize += GROWBY);
23 readsize = readlink(path, buf, bufsize); /* 1st try */ 22 readsize = readlink(path, buf, bufsize);
24 if (readsize == -1) { 23 if (readsize == -1) {
25 bb_perror_msg("%s", path);
26 free(buf); 24 free(buf);
27 return NULL; 25 return NULL;
28 } 26 }
29 } 27 } while (bufsize < readsize + 1);
30 while (bufsize < readsize + 1);
31 28
32 buf[readsize] = '\0'; 29 buf[readsize] = '\0';
33 30
34 return buf; 31 return buf;
35} 32}
36 33
34char *xmalloc_readlink_or_warn(const char *path)
35{
36 char *buf = xmalloc_readlink(path);
37 if (!buf) {
38 /* EINVAL => "file: Invalid argument" => puzzled user */
39 bb_error_msg("%s: cannot read link (not a symlink?)", path);
40 }
41 return buf;
42}
43
44/* UNUSED */
45#if 0
37char *xmalloc_realpath(const char *path) 46char *xmalloc_realpath(const char *path)
38{ 47{
39#if defined(__GLIBC__) && !defined(__UCLIBC__) 48#if defined(__GLIBC__) && !defined(__UCLIBC__)
@@ -46,3 +55,4 @@ char *xmalloc_realpath(const char *path)
46 return xstrdup(realpath(path, buf)); 55 return xstrdup(realpath(path, buf));
47#endif 56#endif
48} 57}
58#endif