summaryrefslogtreecommitdiff
path: root/name.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-01-21 02:59:12 +0100
committerLennart Poettering <lennart@poettering.net>2010-01-21 02:59:12 +0100
commite094e853a047e10f0d2989eed76b6aa430e3ea1a (patch)
tree29acb378f3f659399c474ba516ca02ae6051a59d /name.c
parent1ffba6fe82d65f2a87b53a21c7927bca8176038c (diff)
make sure impact of transactions is minimized
Diffstat (limited to 'name.c')
-rw-r--r--name.c64
1 files changed, 63 insertions, 1 deletions
diff --git a/name.c b/name.c
index 340e8e424a..08194d05f4 100644
--- a/name.c
+++ b/name.c
@@ -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;