#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: fsmagic.c,v 1.67 2013/03/17 15:43:20 christos Exp $")
+FILE_RCSID("@(#)$File: fsmagic.c,v 1.68 2013/05/28 21:24:31 christos Exp $")
#endif /* lint */
#include "magic.h"
if (ret) {
if (ms->flags & MAGIC_ERROR) {
- file_error(ms, errno, "cannot stat `%s'", fn);
+ file_error(ms, errno, "cannot stat");
return -1;
}
- if (file_printf(ms, "cannot open `%s' (%s)",
- fn, strerror(errno)) == -1)
+ if (file_printf(ms, "cannot open (%s)", strerror(errno)) == -1)
return -1;
- ms->event_flags |= EVENT_HAD_ERR;
- return -1;
+ return 0;
}
ret = 1;
if (handle_mime(ms, mime, "symlink") == -1)
return -1;
} else if (file_printf(ms,
- "%sunreadable symlink `%s' (%s)", COMMA, fn,
+ "%sunreadable symlink (%s)", COMMA,
strerror(errno)) == -1)
return -1;
break;
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: magic.c,v 1.78 2013/01/07 18:20:19 christos Exp $")
+FILE_RCSID("@(#)$File: magic.c,v 1.79 2013/09/03 08:54:47 christos Exp $")
#endif /* lint */
#include "magic.h"
pos = lseek(fd, (off_t)0, SEEK_CUR);
} else {
int flags = O_RDONLY|O_BINARY;
+ int okstat = stat(inname, &sb) == 0;
- if (stat(inname, &sb) == 0 && S_ISFIFO(sb.st_mode)) {
+ if (okstat && S_ISFIFO(sb.st_mode)) {
#ifdef O_NONBLOCK
flags |= O_NONBLOCK;
#endif
errno = 0;
if ((fd = open(inname, flags)) < 0) {
- if (unreadable_info(ms, sb.st_mode, inname) == -1)
+ if (okstat &&
+ unreadable_info(ms, sb.st_mode, inname) == -1)
goto done;
rv = 0;
goto done;
} else {
if ((nbytes = read(fd, (char *)buf, HOWMANY)) == -1) {
- file_error(ms, errno, "cannot read `%s'", inname);
+ file_error(ms, errno, "cannot read");
goto done;
}
}