#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: fsmagic.c,v 1.78 2018/09/09 20:33:28 christos Exp $")
+FILE_RCSID("@(#)$File: fsmagic.c,v 1.79 2018/10/02 00:38:33 christos Exp $")
#endif /* lint */
#include "magic.h"
buf[nch] = '\0'; /* readlink(2) does not do this */
/* If broken symlink, say so and quit early. */
+#ifdef __linux__
+ /*
+ * linux procfs/devfs makes symlinks like pipe:[3515864880]
+ * that we can't stat their readlink output, so stat the
+ * original filename instead.
+ */
+ if (stat(fn, &tstatbuf) < 0)
+ return bad_link(ms, errno, buf);
+#else
if (*buf == '/') {
if (stat(buf, &tstatbuf) < 0)
return bad_link(ms, errno, buf);
if (stat(tmp, &tstatbuf) < 0)
return bad_link(ms, errno, buf);
}
+#endif
/* Otherwise, handle it. */
if ((ms->flags & MAGIC_SYMLINK) != 0) {