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
This commit is contained in:
Denis Vlasenko
2009-03-21 19:11:23 +00:00
parent 05af832097
commit 3a014b85dc
2 changed files with 106 additions and 106 deletions

View File

@ -91,7 +91,11 @@ char* FAST_FUNC 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);
const char *errmsg = "not a symlink";
int err = errno;
if (err != EINVAL)
errmsg = strerror(err);
bb_error_msg("%s: cannot read link: %s", path, errmsg);
}
return buf;
}