diff options
author | Lennart Poettering <lennart@poettering.net> | 2010-01-21 02:59:12 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2010-01-21 02:59:12 +0100 |
commit | e094e853a047e10f0d2989eed76b6aa430e3ea1a (patch) | |
tree | 29acb378f3f659399c474ba516ca02ae6051a59d /name.c | |
parent | 1ffba6fe82d65f2a87b53a21c7927bca8176038c (diff) |
make sure impact of transactions is minimized
Diffstat (limited to 'name.c')
-rw-r--r-- | name.c | 64 |
1 files changed, 63 insertions, 1 deletions
@@ -226,7 +226,6 @@ void name_free(Name *name) { } bool name_is_ready(Name *name) { - assert(name); if (name->meta.state != NAME_LOADED) @@ -291,6 +290,69 @@ bool name_is_ready(Name *name) { return false; } +bool name_is_dead(Name *name) { + assert(name); + + if (name->meta.state != NAME_LOADED) + return true; + assert(name->meta.type < _NAME_TYPE_MAX); + + switch (name->meta.type) { + case NAME_SERVICE: { + Service *s = SERVICE(name); + + return + s->state == SERVICE_DEAD || + s->state == SERVICE_MAINTAINANCE; + } + + case NAME_TIMER: + return TIMER(name)->state == TIMER_DEAD; + + case NAME_SOCKET: { + Socket *s = SOCKET(name); + + return + s->state == SOCKET_DEAD || + s->state == SOCKET_MAINTAINANCE; + } + + case NAME_MILESTONE: + return MILESTONE(name)->state == MILESTONE_DEAD; + + case NAME_DEVICE: + return DEVICE(name)->state == DEVICE_DEAD; + + case NAME_MOUNT: { + Mount *a = MOUNT(name); + + return + a->state == AUTOMOUNT_DEAD || + a->state == AUTOMOUNT_MAINTAINANCE; + } + + case NAME_AUTOMOUNT: { + Automount *a = AUTOMOUNT(name); + + return + a->state == AUTOMOUNT_DEAD || + a->state == AUTOMOUNT_MAINTAINANCE; + } + + case NAME_SNAPSHOT: + return SNAPSHOT(name)->state == SNAPSHOT_DEAD; + + + case _NAME_TYPE_MAX: + case _NAME_TYPE_INVALID: + ; + } + + assert_not_reached("Unknown name type."); + return false; +} + + static int ensure_in_set(Set **s, void *data) { int r; |