89be67
diff --git a/src/fsmagic.c b/src/fsmagic.c
89be67
index 7200271..1ffe667 100644
89be67
--- a/src/fsmagic.c
89be67
+++ b/src/fsmagic.c
89be67
@@ -124,14 +124,12 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
89be67
 
89be67
 	if (ret) {
89be67
 		if (ms->flags & MAGIC_ERROR) {
89be67
-			file_error(ms, errno, "cannot stat `%s'", fn);
89be67
+			file_error(ms, errno, "cannot stat");
89be67
 			return -1;
89be67
 		}
89be67
-		if (file_printf(ms, "cannot open `%s' (%s)",
89be67
-		    fn, strerror(errno)) == -1)
89be67
+		if (file_printf(ms, "cannot open (%s)", strerror(errno)) == -1)
89be67
 			return -1;
89be67
-		ms->event_flags |= EVENT_HAD_ERR;
89be67
-		return -1;
89be67
+		return 0;
89be67
 	}
89be67
 
89be67
 	if (!mime) {
89be67
diff --git a/src/magic.c b/src/magic.c
89be67
index 2b61080..a184a35 100644
89be67
--- a/src/magic.c
89be67
+++ b/src/magic.c
89be67
@@ -417,8 +417,9 @@ file_or_fd(struct magic_set *ms, const char *inname, int fd)
89be67
 			ispipe = 1;
89be67
 	} else {
89be67
 		int flags = O_RDONLY|O_BINARY;
89be67
+		int okstat = stat(inname, &sb) == 0;
89be67
 
89be67
-		if (stat(inname, &sb) == 0 && S_ISFIFO(sb.st_mode)) {
89be67
+		if (okstat && S_ISFIFO(sb.st_mode)) {
89be67
 #ifdef O_NONBLOCK
89be67
 			flags |= O_NONBLOCK;
89be67
 #endif
89be67
@@ -427,7 +428,8 @@ file_or_fd(struct magic_set *ms, const char *inname, int fd)
89be67
 
89be67
 		errno = 0;
89be67
 		if ((fd = open(inname, flags)) < 0) {
89be67
-			if (unreadable_info(ms, sb.st_mode, inname) == -1)
89be67
+			if (okstat &&
89be67
+			    unreadable_info(ms, sb.st_mode, inname) == -1)
89be67
 				goto done;
89be67
 			rv = 0;
89be67
 			goto done;
89be67
@@ -462,7 +464,7 @@ file_or_fd(struct magic_set *ms, const char *inname, int fd)
89be67
 
89be67
 	} else {
89be67
 		if ((nbytes = read(fd, (char *)buf, HOWMANY)) == -1) {
89be67
-			file_error(ms, errno, "cannot read `%s'", inname);
89be67
+			file_error(ms, errno, "cannot read");
89be67
 			goto done;
89be67
 		}
89be67
 	}