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

[lvm-devel] [PATCH 8/9] Adapt _rename_dev_node for udev



This one is for _rename_dev_node -- if udev renames the node, this
code won't overwrite it once again. Also, if udev has done the
rename already, the old node does not exist anymore, so we have to
detect this somehow.

Peter


diff --git a/libdm/libdm-common.c b/libdm/libdm-common.c
index ef249dc..90dd031 100644
--- a/libdm/libdm-common.c
+++ b/libdm/libdm-common.c
@@ -350,6 +350,10 @@ static int _rename_dev_node(const char *old_name, const char *new_name)
 				  "is already present", newpath);
 			return 0;
 		}
+		else if (stat(oldpath, &info) < 0 &&
+			 errno == ENOENT)
+			/* udev should have done this already */
+			return 1;
 
 		if (unlink(newpath) < 0) {
 			if (errno == EPERM) {


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