summaryrefslogtreecommitdiff
path: root/device.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-04-10 17:53:17 +0200
committerLennart Poettering <lennart@poettering.net>2010-04-10 18:00:34 +0200
commite537352b9bfffe6f6286483bff2c7601c78407e3 (patch)
treebe1a46883f8a1bc6b666bd680adda2d309979c15 /device.c
parent108736d0d34d7b74a61a6ac7b99d4d4fec81ce09 (diff)
mount: implement mounting properly
This also includes code that writes utmp/wtmp records when applicable, making use the mount infrastructure to detct when those files are accessible. Finally, this also introduces a --dump-configuration-items switch.
Diffstat (limited to 'device.c')
-rw-r--r--device.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/device.c b/device.c
index 39375a4258..0a7c967fab 100644
--- a/device.c
+++ b/device.c
@@ -42,20 +42,29 @@ static void device_done(Unit *u) {
Device *d = DEVICE(u);
assert(d);
+
free(d->sysfs);
+ d->sysfs = NULL;
+}
+
+static void device_init(Unit *u) {
+ Device *d = DEVICE(u);
+
+ assert(d);
+ assert(u->meta.load_state == UNIT_STUB);
+
+ d->state = 0;
}
static void device_set_state(Device *d, DeviceState state) {
DeviceState old_state;
assert(d);
- if (state == d->state)
- return;
-
old_state = d->state;
d->state = state;
- log_debug("%s changed %s → %s", unit_id(UNIT(d)), state_string_table[old_state], state_string_table[state]);
+ if (state != old_state)
+ log_debug("%s changed %s → %s", unit_id(UNIT(d)), state_string_table[old_state], state_string_table[state]);
unit_notify(UNIT(d), state_translation_table[old_state], state_translation_table[state]);
}
@@ -231,15 +240,16 @@ static int device_process_new_device(Manager *m, struct udev_device *dev, bool u
if ((r = device_add_escaped_name(u, sysfs, true)) < 0)
goto fail;
+ unit_add_to_load_queue(u);
+ } else
+ delete = false;
+
+ if (!(DEVICE(u)->sysfs))
if (!(DEVICE(u)->sysfs = strdup(sysfs))) {
r = -ENOMEM;
goto fail;
}
- unit_add_to_load_queue(u);
- } else
- delete = false;
-
if (dn)
if ((r = device_add_escaped_name(u, dn, true)) < 0)
goto fail;
@@ -460,7 +470,8 @@ fail:
const UnitVTable device_vtable = {
.suffix = ".device",
- .init = unit_load_fragment_and_dropin_optional,
+ .init = device_init,
+ .load = unit_load_fragment_and_dropin_optional,
.done = device_done,
.coldplug = device_coldplug,