From 8bcaaabb1a023af4852dbf0dba76249982c62e40 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Mon, 21 Apr 2008 19:22:49 -0400 Subject: [PATCH] blkid: Keep cached filesystem information on EACCES and ENOENT errors When a nonprivileged user uses the blkid command, we want to keep the cached filesystem information, and opening a device file could result in an EACCESS or ENOENT (if an intervening directory is mode 700). We were previously testing for EPERM, which was really the wrong error code to be testing against. Addresses-Launchpad-Bug: #220275 Signed-off-by: "Theodore Ts'o" --- lib/blkid/probe.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/blkid/probe.c b/lib/blkid/probe.c index 4a5c7e770..496420984 100644 --- a/lib/blkid/probe.c +++ b/lib/blkid/probe.c @@ -1227,7 +1227,12 @@ blkid_dev blkid_verify(blkid_cache cache, blkid_dev dev) if (((probe.fd = open(dev->bid_name, O_RDONLY)) < 0) || (fstat(probe.fd, &st) < 0)) { if (probe.fd >= 0) close(probe.fd); - if (errno != EPERM) { + if ((errno != EPERM) && (errno != EACCES) && + (errno != ENOENT)) { + DBG(DEBUG_PROBE, + printf("blkid_verify: error %s (%d) while " + "opening %s\n", strerror(errno), errno, + dev->bid_name)); blkid_free_dev(dev); return NULL; } -- 2.47.2