#include <sys/epoll.h>
#include <libudev.h>
-#include "unit.h"
-#include "device.h"
#include "strv.h"
#include "log.h"
#include "unit-name.h"
#include "def.h"
#include "path-util.h"
#include "udev-util.h"
+#include "unit.h"
+#include "swap.h"
+#include "device.h"
static const UnitActiveState state_translation_table[_DEVICE_STATE_MAX] = {
[DEVICE_DEAD] = UNIT_INACTIVE,
FOREACH_WORD_QUOTED(w, l, wants, state) {
_cleanup_free_ char *n = NULL;
char e[l+1];
+ Unit *other;
memcpy(e, w, l);
e[l] = 0;
r = unit_add_dependency_by_name(u, UNIT_WANTS, n, NULL, true);
if (r < 0)
goto fail;
+
+ other = manager_get_unit(u->manager, n);
+ if (!other || !unit_can_start(other))
+ continue;
+
+ r = manager_add_job(u->manager, JOB_START, other, JOB_REPLACE, true, NULL, NULL);
+ if (r < 0)
+ log_warning("Failed to add job %s/%s, ignoring: %s.",
+ other->id, job_type_to_string(JOB_START), strerror(-r));
}
}
}
m->udev_monitor = NULL;
}
- if (m->udev) {
- udev_unref(m->udev);
- m->udev = NULL;
- }
-
hashmap_free(m->devices_by_sysfs);
m->devices_by_sysfs = NULL;
}
assert(m);
- if (!m->udev) {
- m->udev = udev_new();
- if (!m->udev)
- return -ENOMEM;
-
+ if (!m->udev_monitor) {
m->udev_monitor = udev_monitor_new_from_netlink(m->udev, "udev");
if (!m->udev_monitor) {
r = -ENOMEM;
r = device_process_removed_device(m, dev);
if (r < 0)
log_error("Failed to process device remove event: %s", strerror(-r));
+
+ r = swap_process_removed_device(m, dev);
+ if (r < 0)
+ log_error("Failed to process swap device remove event: %s", strerror(-r));
+
} else {
r = device_process_new_device(m, dev);
if (r < 0)
log_error("Failed to process device new event: %s", strerror(-r));
+ r = swap_process_new_device(m, dev);
+ if (r < 0)
+ log_error("Failed to process swap device new event: %s", strerror(-r));
+
manager_dispatch_load_queue(m);
device_set_path_plugged(m, dev);