From: Daniel Kochmański Date: Fri, 18 Sep 2015 16:18:06 +0000 (+0200) Subject: directories: don't break on broken symlinks X-Git-Url: http://git.pulsar-zone.net/?a=commitdiff_plain;h=22b647144c295fef6cb4f1ef24aa5205c2b5a6a0;p=ecl.git directories: don't break on broken symlinks ECL when asked for a truename of a broken symbolic link signalled an `file-error'. This isn't non-conformity, because spec doesn't specify such situation, but lead to annoying errors with DIRECTORIES when even irrelevant files were broken symlinks. New behavior is as follows - broken symlinks are treated as regular files (of :LINK kind) and no error is signalled. They aren't ignored due to a few corner cases related to PROBE-FILE, OPEN and such. Signed-off-by: Daniel Kochmański --- diff --git a/src/c/unixfsys.d b/src/c/unixfsys.d index 2fef60e..36e6fd4 100644 --- a/src/c/unixfsys.d +++ b/src/c/unixfsys.d @@ -361,8 +361,13 @@ file_truename(cl_object pathname, cl_object filename, int flags) FEcannot_open(filename); #ifdef HAVE_LSTAT } else if (kind == @':link' && (flags & FOLLOW_SYMLINKS)) { - /* The link might be a relative pathname. In that case we have - * to merge with the original pathname */ + /* The link might be a relative pathname. In that case + * we have to merge with the original pathname. On + * the other hand, if the link is broken – return file + * truename "as is". */ + struct stat filestatus; + if (safe_stat(filename->base_string.self, &filestatus) < 0) + @(return pathname kind); filename = si_readlink(filename); pathname = ecl_make_pathname(pathname->pathname.host, pathname->pathname.device,