Because udev operates asynchronously, we found errors which were
caused by a previous command (eg. sfdisk or pvremove) creating
or removing a device, and that change not having happened by the
time the next command was run.
This patch adds calls to '/sbin/udevadm settle' after any commands
which can add or remove device nodes.
If udev is not being used or not available, this should have no
effect. The command fails and this is silently ignored.
extern int device_name_translation (char *device, const char *func);
+extern void udev_settle (void);
+
extern int verbose;
/*-- in proto.c --*/
device[5] = 's'; /* Restore original device name. */
goto error;
}
+
+/* LVM and other commands aren't synchronous, especially when udev is
+ * involved. eg. You can create or remove some device, but the /dev
+ * device node won't appear until some time later. This means that
+ * you get an error if you run one command followed by another.
+ * Use 'udevadm settle' after certain commands, but don't be too
+ * fussed if it fails.
+ */
+void
+udev_settle (void)
+{
+ command (NULL, NULL, "/sbin/udevadm", "settle", NULL);
+}
}
free (err);
+
+ udev_settle ();
+
return 0;
}
}
free (err);
+
+ udev_settle ();
+
return 0;
}
}
free (err);
+
+ udev_settle ();
+
return 0;
}
}
free_strings (xs);
+ udev_settle ();
+
/* There, that was easy, sorry about your data. */
return 0;
}
}
free (err);
+
+ udev_settle ();
+
return 0;
}
}
free (err);
+
+ udev_settle ();
+
return 0;
}
}
free (err);
+
+ udev_settle ();
+
return 0;
}
}
free (err);
+
+ udev_settle ();
+
return 0;
}
return -1;
}
+ udev_settle ();
+
return 0;
}
free (err);
+ udev_settle ();
+
return out; /* caller frees */
}