Skip to contentSkip to conversation

Adapt _rename_dev_node for udev

PATCH New Peter Rajnoha 1 participant 1 message May 25, 2009

lore
Share & tools
lore
#0 lore raw

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

libdm/libdm-common.c +4 -0
index ef249dc..90dd031 100644
@@ -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) {