]> git.ipfire.org Git - people/ms/systemd.git/blame - device.c
add new manager initializer callbacks to per-unit type vtable
[people/ms/systemd.git] / device.c
CommitLineData
5cb5a6ff
LP
1/*-*- Mode: C; c-basic-offset: 8 -*-*/
2
87f0e418 3#include "unit.h"
5cb5a6ff
LP
4#include "device.h"
5#include "strv.h"
6
87f0e418
LP
7static void device_done(Unit *u) {
8 Device *d = DEVICE(u);
034c6ed7
LP
9
10 assert(d);
11 strv_free(d->sysfs);
12}
13
87f0e418 14static void device_dump(Unit *u, FILE *f, const char *prefix) {
5cb5a6ff
LP
15
16 static const char* const state_table[_DEVICE_STATE_MAX] = {
17 [DEVICE_DEAD] = "dead",
18 [DEVICE_AVAILABLE] = "available"
19 };
20
87f0e418 21 Device *s = DEVICE(u);
5cb5a6ff
LP
22
23 assert(s);
24
25 fprintf(f,
26 "%sDevice State: %s\n",
27 prefix, state_table[s->state]);
28}
29
87f0e418
LP
30static UnitActiveState device_active_state(Unit *u) {
31 return DEVICE(u)->state == DEVICE_DEAD ? UNIT_INACTIVE : UNIT_ACTIVE;
5cb5a6ff
LP
32}
33
87f0e418 34const UnitVTable device_vtable = {
5cb5a6ff
LP
35 .suffix = ".device",
36
87f0e418 37 .init = unit_load_fragment_and_dropin,
034c6ed7 38 .done = device_done,
5cb5a6ff
LP
39 .dump = device_dump,
40
034c6ed7 41 .active_state = device_active_state
5cb5a6ff 42};