X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=device.c;h=b8bab4b02d9b92aa993d40762a9dee2d04174c44;hb=c9b97d2a838899d00004fbfbd3f8c2e6932c89a0;hp=79847c46b7cea39eeb25ddc5be18adca80da384d;hpb=5cb5a6ffc33667c93e9bc3572534dcaa684046e3;p=elogind.git diff --git a/device.c b/device.c index 79847c46b..b8bab4b02 100644 --- a/device.c +++ b/device.c @@ -1,17 +1,24 @@ /*-*- Mode: C; c-basic-offset: 8 -*-*/ -#include "name.h" +#include "unit.h" #include "device.h" #include "strv.h" -static void device_dump(Name *n, FILE *f, const char *prefix) { +static void device_done(Unit *u) { + Device *d = DEVICE(u); + + assert(d); + strv_free(d->sysfs); +} + +static void device_dump(Unit *u, FILE *f, const char *prefix) { static const char* const state_table[_DEVICE_STATE_MAX] = { [DEVICE_DEAD] = "dead", [DEVICE_AVAILABLE] = "available" }; - Device *s = DEVICE(n); + Device *s = DEVICE(u); assert(s); @@ -20,28 +27,16 @@ static void device_dump(Name *n, FILE *f, const char *prefix) { prefix, state_table[s->state]); } -static NameActiveState device_active_state(Name *n) { - return DEVICE(n)->state == DEVICE_DEAD ? NAME_INACTIVE : NAME_ACTIVE; -} - -static void device_free_hook(Name *n) { - Device *d = DEVICE(n); - - assert(d); - strv_free(d->sysfs); +static UnitActiveState device_active_state(Unit *u) { + return DEVICE(u)->state == DEVICE_DEAD ? UNIT_INACTIVE : UNIT_ACTIVE; } -const NameVTable device_vtable = { +const UnitVTable device_vtable = { .suffix = ".device", - .load = name_load_fragment_and_dropin, + .init = unit_load_fragment_and_dropin, + .done = device_done, .dump = device_dump, - .start = NULL, - .stop = NULL, - .reload = NULL, - - .active_state = device_active_state, - - .free_hook = device_free_hook + .active_state = device_active_state };