static const UnitActiveState state_translation_table[_DEVICE_STATE_MAX] = {
[DEVICE_DEAD] = UNIT_INACTIVE,
- [DEVICE_AVAILABLE] = UNIT_ACTIVE
+ [DEVICE_PLUGGED] = UNIT_ACTIVE
};
+static void device_init(Unit *u) {
+ Device *d = DEVICE(u);
+
+ assert(d);
+ assert(d->meta.load_state == UNIT_STUB);
+
+ d->meta.job_timeout = DEFAULT_TIMEOUT_USEC;
+}
+
static void device_done(Unit *u) {
Device *d = DEVICE(u);
assert(d->state == DEVICE_DEAD);
if (d->sysfs)
- device_set_state(d, DEVICE_AVAILABLE);
+ device_set_state(d, DEVICE_PLUGGED);
return 0;
}
goto fail;
if (wants) {
- FOREACH_WORD(w, l, wants, state) {
+ FOREACH_WORD_QUOTED(w, l, wants, state) {
char *e;
if (!(e = strndup(w, l))) {
goto fail;
}
- r = unit_add_dependency_by_name(u, UNIT_WANTS, NULL, e, true);
+ r = unit_add_dependency_by_name(u, UNIT_WANTS, e, NULL, true);
free(e);
if (r < 0)
if (update_state) {
manager_dispatch_load_queue(u->meta.manager);
- device_set_state(DEVICE(u), DEVICE_AVAILABLE);
+ device_set_state(DEVICE(u), DEVICE_PLUGGED);
}
unit_add_to_dbus_queue(u);
return 0;
fail:
+
+ log_warning("Failed to load device unit: %s", strerror(-r));
+
if (delete && u)
unit_free(u);
+
return r;
}
static const char* const device_state_table[_DEVICE_STATE_MAX] = {
[DEVICE_DEAD] = "dead",
- [DEVICE_AVAILABLE] = "available"
+ [DEVICE_PLUGGED] = "plugged"
};
DEFINE_STRING_TABLE_LOOKUP(device_state, DeviceState);
.no_snapshots = true,
.no_isolate = true,
+ .init = device_init,
+
.load = unit_load_fragment_and_dropin_optional,
.done = device_done,
.coldplug = device_coldplug,