Blame SOURCES/file-5.11-exit-code.patch

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