summaryrefslogtreecommitdiff
path: root/src/core/snapshot.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-11-19 21:12:59 +0100
committerLennart Poettering <lennart@poettering.net>2013-11-20 20:52:36 +0100
commit718db96199eb307751264e4163555662c9a389fa (patch)
tree9ec8467596ba1acba76bb6273c7797baf68c1a00 /src/core/snapshot.c
parent3febea3a0b0a968ea281e7959c1654cbaf95c9bf (diff)
core: convert PID 1 to libsystemd-bus
This patch converts PID 1 to libsystemd-bus and thus drops the dependency on libdbus. The only remaining code using libdbus is a test case that validates our bus marshalling against libdbus' marshalling, and this dependency can be turned off. This patch also adds a couple of things to libsystem-bus, that are necessary to make the port work: - Synthesizing of "Disconnected" messages when bus connections are severed. - Support for attaching multiple vtables for the same interface on the same path. This patch also fixes the SetDefaultTarget() and GetDefaultTarget() bus calls which used an inappropriate signature. As a side effect we will now generate PropertiesChanged messages which carry property contents, rather than just invalidation information.
Diffstat (limited to 'src/core/snapshot.c')
-rw-r--r--src/core/snapshot.c24
1 files changed, 9 insertions, 15 deletions
diff --git a/src/core/snapshot.c b/src/core/snapshot.c
index d11239dff3..21e89ac996 100644
--- a/src/core/snapshot.c
+++ b/src/core/snapshot.c
@@ -189,7 +189,7 @@ _pure_ static const char *snapshot_sub_state_to_string(Unit *u) {
return snapshot_state_to_string(SNAPSHOT(u)->state);
}
-int snapshot_create(Manager *m, const char *name, bool cleanup, DBusError *e, Snapshot **_s) {
+int snapshot_create(Manager *m, const char *name, bool cleanup, sd_bus_error *e, Snapshot **_s) {
_cleanup_free_ char *n = NULL;
Unit *other, *u = NULL;
Iterator i;
@@ -200,20 +200,14 @@ int snapshot_create(Manager *m, const char *name, bool cleanup, DBusError *e, Sn
assert(_s);
if (name) {
- if (!unit_name_is_valid(name, false)) {
- dbus_set_error(e, BUS_ERROR_INVALID_NAME, "Unit name %s is not valid.", name);
- return -EINVAL;
- }
+ if (!unit_name_is_valid(name, false))
+ return sd_bus_error_setf(e, SD_BUS_ERROR_INVALID_ARGS, "Unit name %s is not valid.", name);
- if (unit_name_to_type(name) != UNIT_SNAPSHOT) {
- dbus_set_error(e, BUS_ERROR_UNIT_TYPE_MISMATCH, "Unit name %s lacks snapshot suffix.", name);
- return -EINVAL;
- }
+ if (unit_name_to_type(name) != UNIT_SNAPSHOT)
+ return sd_bus_error_setf(e, SD_BUS_ERROR_INVALID_ARGS, "Unit name %s lacks snapshot suffix.", name);
- if (manager_get_unit(m, name)) {
- dbus_set_error(e, BUS_ERROR_UNIT_EXISTS, "Snapshot %s exists already.", name);
- return -EEXIST;
- }
+ if (manager_get_unit(m, name))
+ sd_bus_error_setf(e, BUS_ERROR_UNIT_EXISTS, "Snapshot %s exists already.", name);
} else {
@@ -293,8 +287,8 @@ const UnitVTable snapshot_vtable = {
.no_gc = true,
.init = snapshot_init,
-
.load = snapshot_load,
+
.coldplug = snapshot_coldplug,
.dump = snapshot_dump,
@@ -309,5 +303,5 @@ const UnitVTable snapshot_vtable = {
.sub_state_to_string = snapshot_sub_state_to_string,
.bus_interface = "org.freedesktop.systemd1.Snapshot",
- .bus_message_handler = bus_snapshot_message_handler
+ .bus_vtable = bus_snapshot_vtable
};