diff options
author | Lennart Poettering <lennart@poettering.net> | 2010-02-01 03:33:24 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2010-02-01 03:33:24 +0100 |
commit | ea4309869e75497ba6a97c540646cb66a157a4d9 (patch) | |
tree | 8a00d7d42718d74e1b88ecb6e074ce9eb1b8a3fd /unit.c | |
parent | b9f880f4f4903f5dd8198fc1e2e920a9850ac86e (diff) |
add basic (and not very useful) D-Bus support
Diffstat (limited to 'unit.c')
-rw-r--r-- | unit.c | 36 |
1 files changed, 27 insertions, 9 deletions
@@ -707,7 +707,7 @@ int unit_watch_fd(Unit *u, int fd, uint32_t events, Watch *w) { assert(u); assert(fd >= 0); assert(w); - assert(w->type == WATCH_INVALID || (w->type == WATCH_FD && w->fd == fd && w->unit == u)); + assert(w->type == WATCH_INVALID || (w->type == WATCH_FD && w->fd == fd && w->data.unit == u)); zero(ev); ev.data.ptr = w; @@ -721,7 +721,7 @@ int unit_watch_fd(Unit *u, int fd, uint32_t events, Watch *w) { w->fd = fd; w->type = WATCH_FD; - w->unit = u; + w->data.unit = u; return 0; } @@ -733,12 +733,13 @@ void unit_unwatch_fd(Unit *u, Watch *w) { if (w->type == WATCH_INVALID) return; - assert(w->type == WATCH_FD && w->unit == u); + assert(w->type == WATCH_FD); + assert(w->data.unit == u); assert_se(epoll_ctl(u->meta.manager->epoll_fd, EPOLL_CTL_DEL, w->fd, NULL) >= 0); w->fd = -1; w->type = WATCH_INVALID; - w->unit = NULL; + w->data.unit = NULL; } int unit_watch_pid(Unit *u, pid_t pid) { @@ -762,7 +763,7 @@ int unit_watch_timer(Unit *u, usec_t delay, Watch *w) { assert(u); assert(w); - assert(w->type == WATCH_INVALID || (w->type == WATCH_TIMER && w->unit == u)); + assert(w->type == WATCH_INVALID || (w->type == WATCH_TIMER && w->data.unit == u)); /* This will try to reuse the old timer if there is one */ @@ -806,13 +807,13 @@ int unit_watch_timer(Unit *u, usec_t delay, Watch *w) { w->fd = fd; w->type = WATCH_TIMER; - w->unit = u; + w->data.unit = u; return 0; fail: if (ours) - assert_se(close_nointr(fd) == 0); + close_nointr_nofail(fd); return -errno; } @@ -824,14 +825,14 @@ void unit_unwatch_timer(Unit *u, Watch *w) { if (w->type == WATCH_INVALID) return; - assert(w->type == WATCH_TIMER && w->unit == u); + assert(w->type == WATCH_TIMER && w->data.unit == u); assert_se(epoll_ctl(u->meta.manager->epoll_fd, EPOLL_CTL_DEL, w->fd, NULL) >= 0); assert_se(close_nointr(w->fd) == 0); w->fd = -1; w->type = WATCH_INVALID; - w->unit = NULL; + w->data.unit = NULL; } bool unit_job_is_applicable(Unit *u, JobType j) { @@ -1004,6 +1005,23 @@ char *unit_name_escape_path(const char *prefix, const char *path, const char *su return r; } +char *unit_dbus_path(Unit *u) { + char *p, *e; + + assert(u); + + if (!(e = bus_path_escape(unit_id(u)))) + return NULL; + + if (asprintf(&p, "/org/freedesktop/systemd1/unit/%s", e) < 0) { + free(e); + return NULL; + } + + free(e); + return p; +} + static const char* const unit_type_table[_UNIT_TYPE_MAX] = { [UNIT_SERVICE] = "service", [UNIT_TIMER] = "timer", |