From: Theodore Ts'o Date: Mon, 21 Apr 2008 23:22:49 +0000 (-0400) Subject: blkid: Keep cached filesystem information on EACCES and ENOENT errors X-Git-Tag: v1.40.9~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8bcaaabb1a023af4852dbf0dba76249982c62e40;p=thirdparty%2Fe2fsprogs.git 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" --- 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; }