[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[lvm-devel] dev-io.c: give a better diagnostic upon failed stat



The main change here is to report strerror(errno) upon stat failure:
i.e., the s/log_error/log_sys_error/ part.  Also made the "device changed"
diagnostic more definite.  Ok to commit?

    Use log_sys_error after failed stat to report strerror(errno).
    Use a slightly different diagnostic to report mismatched device number.

---
 lib/device/dev-io.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/lib/device/dev-io.c b/lib/device/dev-io.c
index 9406903..54ae88e 100644
--- a/lib/device/dev-io.c
+++ b/lib/device/dev-io.c
@@ -359,10 +359,15 @@ int dev_open_flags(struct device *dev, int flags, int direct, int quiet)
 		return 0;
 	}

-	if (!(dev->flags & DEV_REGULAR) &&
-	    ((stat(name, &buf) < 0) || (buf.st_rdev != dev->dev))) {
-		log_error("%s: stat failed: Has device name changed?", name);
-		return 0;
+	if (!(dev->flags & DEV_REGULAR)) {
+		if (stat(name, &buf) < 0) {
+			log_sys_error("%s: stat failed", name);
+			return 0;
+		}
+		if (buf.st_rdev != dev->dev) {
+			log_error("%s: device changed", name);
+			return 0;
+		}
 	}

 #ifdef O_DIRECT_SUPPORT


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]