if (r == 0) {
/* devmapper might say that the device exists, but the devlink might not yet have been
* created. Check and wait for the udev event in that case. */
- r = device_wait_for_devlink(node, "block", usec_add(now(CLOCK_MONOTONIC), 100 * USEC_PER_MSEC), NULL);
+ r = device_wait_for_devlink(node, "block", 100 * USEC_PER_MSEC, NULL);
/* Fallback to activation with a unique device if it's taking too long */
if (r == -ETIMEDOUT)
break;
sd_device *_device,
const char *devlink,
const char *subsystem,
- usec_t deadline,
+ usec_t timeout_usec,
sd_device **ret) {
_cleanup_(sd_device_monitor_unrefp) sd_device_monitor *monitor = NULL;
- _cleanup_(sd_event_source_unrefp) sd_event_source *timeout_source = NULL;
_cleanup_(sd_event_unrefp) sd_event *event = NULL;
/* Ensure that if !_device && devlink, device gets unrefd on errors since it will be new */
_cleanup_(sd_device_unrefp) sd_device *device = sd_device_ref(_device);
if (r < 0)
return log_error_errno(r, "Failed to start device monitor: %m");
- if (deadline != USEC_INFINITY) {
- r = sd_event_add_time(
- event, &timeout_source,
- CLOCK_MONOTONIC, deadline, 0,
+ if (timeout_usec != USEC_INFINITY) {
+ r = sd_event_add_time_relative(
+ event, NULL,
+ CLOCK_MONOTONIC, timeout_usec, 0,
NULL, INT_TO_PTR(-ETIMEDOUT));
if (r < 0)
return log_error_errno(r, "Failed to add timeout event source: %m");
}
- /* Check again, maybe things changed. Udev will re-read the db if the device wasn't initialized
- * yet. */
+ /* Check again, maybe things changed. Udev will re-read the db if the device wasn't initialized yet. */
if (!device && devlink) {
r = sd_device_new_from_devname(&device, devlink);
if (r < 0 && !ERRNO_IS_DEVICE_ABSENT(r))
return 0;
}
-int device_wait_for_initialization(sd_device *device, const char *subsystem, usec_t deadline, sd_device **ret) {
- return device_wait_for_initialization_internal(device, NULL, subsystem, deadline, ret);
+int device_wait_for_initialization(sd_device *device, const char *subsystem, usec_t timeout_usec, sd_device **ret) {
+ return device_wait_for_initialization_internal(device, NULL, subsystem, timeout_usec, ret);
}
-int device_wait_for_devlink(const char *devlink, const char *subsystem, usec_t deadline, sd_device **ret) {
- return device_wait_for_initialization_internal(NULL, devlink, subsystem, deadline, ret);
+int device_wait_for_devlink(const char *devlink, const char *subsystem, usec_t timeout_usec, sd_device **ret) {
+ return device_wait_for_initialization_internal(NULL, devlink, subsystem, timeout_usec, ret);
}
int device_is_renaming(sd_device *dev) {
return udev_parse_config_full(NULL, NULL, NULL, NULL, NULL);
}
-int device_wait_for_initialization(sd_device *device, const char *subsystem, usec_t deadline, sd_device **ret);
-int device_wait_for_devlink(const char *path, const char *subsystem, usec_t deadline, sd_device **ret);
+int device_wait_for_initialization(sd_device *device, const char *subsystem, usec_t timeout_usec, sd_device **ret);
+int device_wait_for_devlink(const char *path, const char *subsystem, usec_t timeout_usec, sd_device **ret);
int device_is_renaming(sd_device *dev);
bool device_for_action(sd_device *dev, sd_device_action_t action);