X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fdevice.c;h=dc626d8189777f035c31212f1f68237de19d755d;hb=73608ed994efef7f00eac0b0275ab0f7bc218af5;hp=adc6cc1e275cf1d7a78392c03855f0174b63d153;hpb=e1ce2c2782015579f042d4d6963ed039333fb8c2;p=elogind.git diff --git a/src/device.c b/src/device.c index adc6cc1e2..dc626d818 100644 --- a/src/device.c +++ b/src/device.c @@ -32,7 +32,7 @@ static const UnitActiveState state_translation_table[_DEVICE_STATE_MAX] = { [DEVICE_DEAD] = UNIT_INACTIVE, - [DEVICE_AVAILABLE] = UNIT_ACTIVE + [DEVICE_PLUGGED] = UNIT_ACTIVE }; static void device_done(Unit *u) { @@ -53,7 +53,7 @@ static void device_set_state(Device *d, DeviceState state) { if (state != old_state) log_debug("%s changed %s -> %s", - UNIT(d)->meta.id, + d->meta.id, device_state_to_string(old_state), device_state_to_string(state)); @@ -67,7 +67,7 @@ static int device_coldplug(Unit *u) { assert(d->state == DEVICE_DEAD); if (d->sysfs) - device_set_state(d, DEVICE_AVAILABLE); + device_set_state(d, DEVICE_PLUGGED); return 0; } @@ -244,7 +244,7 @@ static int device_process_new_device(Manager *m, struct udev_device *dev, bool u goto fail; if (wants) { - FOREACH_WORD(w, l, wants, state) { + FOREACH_WORD_QUOTED(w, l, wants, state) { char *e; if (!(e = strndup(w, l))) { @@ -252,7 +252,7 @@ static int device_process_new_device(Manager *m, struct udev_device *dev, bool u 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) @@ -262,7 +262,7 @@ static int device_process_new_device(Manager *m, struct udev_device *dev, bool u 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); @@ -270,8 +270,12 @@ static int device_process_new_device(Manager *m, struct udev_device *dev, bool u return 0; fail: + + log_warning("Failed to load device unit: %s", strerror(-r)); + if (delete && u) unit_free(u); + return r; } @@ -439,7 +443,7 @@ fail: 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);