]>
Commit | Line | Data |
---|---|---|
5cb5a6ff LP |
1 | /*-*- Mode: C; c-basic-offset: 8 -*-*/ |
2 | ||
3 | #include "name.h" | |
4 | #include "device.h" | |
5 | #include "strv.h" | |
6 | ||
034c6ed7 LP |
7 | static void device_done(Name *n) { |
8 | Device *d = DEVICE(n); | |
9 | ||
10 | assert(d); | |
11 | strv_free(d->sysfs); | |
12 | } | |
13 | ||
5cb5a6ff LP |
14 | static void device_dump(Name *n, FILE *f, const char *prefix) { |
15 | ||
16 | static const char* const state_table[_DEVICE_STATE_MAX] = { | |
17 | [DEVICE_DEAD] = "dead", | |
18 | [DEVICE_AVAILABLE] = "available" | |
19 | }; | |
20 | ||
21 | Device *s = DEVICE(n); | |
22 | ||
23 | assert(s); | |
24 | ||
25 | fprintf(f, | |
26 | "%sDevice State: %s\n", | |
27 | prefix, state_table[s->state]); | |
28 | } | |
29 | ||
30 | static NameActiveState device_active_state(Name *n) { | |
31 | return DEVICE(n)->state == DEVICE_DEAD ? NAME_INACTIVE : NAME_ACTIVE; | |
32 | } | |
33 | ||
5cb5a6ff LP |
34 | const NameVTable device_vtable = { |
35 | .suffix = ".device", | |
36 | ||
034c6ed7 LP |
37 | .init = name_load_fragment_and_dropin, |
38 | .done = device_done, | |
5cb5a6ff LP |
39 | .dump = device_dump, |
40 | ||
034c6ed7 | 41 | .active_state = device_active_state |
5cb5a6ff | 42 | }; |