diff options
author | Lennart Poettering <lennart@poettering.net> | 2010-01-23 01:52:57 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2010-01-23 01:52:57 +0100 |
commit | 5cb5a6ffc33667c93e9bc3572534dcaa684046e3 (patch) | |
tree | 51e8b6260d56027c4d610ff6db5882737101a809 /device.c | |
parent | cd2dbd7df9f1b8c46386b2898523aec3dd4578fd (diff) |
first attempt in implementinging execution logic
Diffstat (limited to 'device.c')
-rw-r--r-- | device.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/device.c b/device.c new file mode 100644 index 0000000000..79847c46b7 --- /dev/null +++ b/device.c @@ -0,0 +1,47 @@ +/*-*- Mode: C; c-basic-offset: 8 -*-*/ + +#include "name.h" +#include "device.h" +#include "strv.h" + +static void device_dump(Name *n, FILE *f, const char *prefix) { + + static const char* const state_table[_DEVICE_STATE_MAX] = { + [DEVICE_DEAD] = "dead", + [DEVICE_AVAILABLE] = "available" + }; + + Device *s = DEVICE(n); + + assert(s); + + fprintf(f, + "%sDevice State: %s\n", + 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); +} + +const NameVTable device_vtable = { + .suffix = ".device", + + .load = name_load_fragment_and_dropin, + .dump = device_dump, + + .start = NULL, + .stop = NULL, + .reload = NULL, + + .active_state = device_active_state, + + .free_hook = device_free_hook +}; |