dbus-unit.h \
dbus-job.c \
dbus-job.h \
+ dbus-service.c \
+ dbus-service.h \
+ dbus-socket.c \
+ dbus-socket.h \
+ dbus-target.c \
+ dbus-target.h \
+ dbus-mount.c \
+ dbus-mount.h \
+ dbus-automount.c \
+ dbus-autpmount.h \
+ dbus-snapshot.c \
+ dbus-snapshot.h \
+ dbus-device.c \
+ dbus-device.h \
+ dbus-execute.c \
+ dbus-execute.h \
cgroup.c \
cgroup.h \
mount-setup.c \
#include "load-fragment.h"
#include "load-dropin.h"
#include "unit-name.h"
+#include "dbus-automount.h"
static const UnitActiveState state_translation_table[_AUTOMOUNT_STATE_MAX] = {
[AUTOMOUNT_DEAD] = UNIT_INACTIVE,
.fd_event = automount_fd_event,
+ .bus_message_handler = bus_automount_message_handler,
+
.shutdown = automount_shutdown
};
--- /dev/null
+/*-*- Mode: C; c-basic-offset: 8 -*-*/
+
+/***
+ This file is part of systemd.
+
+ Copyright 2010 Lennart Poettering
+
+ systemd is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ systemd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include "dbus-unit.h"
+#include "dbus-automount.h"
+
+static const char introspection[] =
+ DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE
+ "<node>"
+ BUS_UNIT_INTERFACE
+ BUS_PROPERTIES_INTERFACE
+ " <interface name=\"org.freedesktop.systemd1.Automount\">"
+ " <property name=\"Where\" type=\"s\" access=\"read\"/>"
+ " </interface>"
+ BUS_INTROSPECTABLE_INTERFACE
+ "</node>";
+
+DBusHandlerResult bus_automount_message_handler(Unit *u, DBusMessage *message) {
+ const BusProperty properties[] = {
+ BUS_UNIT_PROPERTIES,
+ { "org.freedesktop.systemd1.Automount", "Where", bus_property_append_string, "s", u->automount.where },
+ { NULL, NULL, NULL, NULL, NULL }
+ };
+
+ return bus_default_message_handler(u->meta.manager, message, introspection, properties);
+}
--- /dev/null
+/*-*- Mode: C; c-basic-offset: 8 -*-*/
+
+#ifndef foodbusautomounthfoo
+#define foodbusautomounthfoo
+
+/***
+ This file is part of systemd.
+
+ Copyright 2010 Lennart Poettering
+
+ systemd is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ systemd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <dbus/dbus.h>
+
+#include "unit.h"
+
+DBusHandlerResult bus_automount_message_handler(Unit *u, DBusMessage *message);
+
+#endif
--- /dev/null
+/*-*- Mode: C; c-basic-offset: 8 -*-*/
+
+/***
+ This file is part of systemd.
+
+ Copyright 2010 Lennart Poettering
+
+ systemd is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ systemd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include "dbus-unit.h"
+#include "dbus-device.h"
+
+static const char introspection[] =
+ DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE
+ "<node>"
+ BUS_UNIT_INTERFACE
+ BUS_PROPERTIES_INTERFACE
+ " <interface name=\"org.freedesktop.systemd1.Device\">"
+ " <property name=\"SysFSPath\" type=\"s\" access=\"read\"/>"
+ " </interface>"
+ BUS_INTROSPECTABLE_INTERFACE
+ "</node>";
+
+DBusHandlerResult bus_device_message_handler(Unit *u, DBusMessage *message) {
+ const BusProperty properties[] = {
+ BUS_UNIT_PROPERTIES,
+ { "org.freedesktop.systemd1.Device", "SysFSPath", bus_property_append_string, "s", u->device.sysfs },
+ { NULL, NULL, NULL, NULL, NULL }
+ };
+
+ return bus_default_message_handler(u->meta.manager, message, introspection, properties);
+}
--- /dev/null
+/*-*- Mode: C; c-basic-offset: 8 -*-*/
+
+#ifndef foodbusdevicehfoo
+#define foodbusdevicehfoo
+
+/***
+ This file is part of systemd.
+
+ Copyright 2010 Lennart Poettering
+
+ systemd is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ systemd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <dbus/dbus.h>
+
+#include "unit.h"
+
+DBusHandlerResult bus_device_message_handler(Unit *u, DBusMessage *message);
+
+#endif
--- /dev/null
+/*-*- Mode: C; c-basic-offset: 8 -*-*/
+
+/***
+ This file is part of systemd.
+
+ Copyright 2010 Lennart Poettering
+
+ systemd is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ systemd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <errno.h>
+#include <dbus/dbus.h>
+
+#include "dbus-execute.h"
+
+DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_execute_append_input, exec_input, ExecInput);
+DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_execute_append_output, exec_output, ExecOutput);
--- /dev/null
+/*-*- Mode: C; c-basic-offset: 8 -*-*/
+
+#ifndef foodbusexecutehfoo
+#define foodbusexecutehfoo
+
+/***
+ This file is part of systemd.
+
+ Copyright 2010 Lennart Poettering
+
+ systemd is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ systemd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <dbus/dbus.h>
+
+#include "manager.h"
+
+#define BUS_EXEC_CONTEXT_INTERFACE \
+ " <property name=\"Environment\" type=\"as\" access=\"read\"/>" \
+ " <property name=\"UMask\" type=\"u\" access=\"read\"/>" \
+ " <property name=\"WorkingDirectory\" type=\"s\" access=\"read\"/>" \
+ " <property name=\"RootDirectory\" type=\"s\" access=\"read\"/>" \
+ " <property name=\"CPUSchedulingResetOnFork\" type=\"b\" access=\"read\"/>" \
+ " <property name=\"NonBlocking\" type=\"b\" access=\"read\"/>" \
+ " <property name=\"StandardInput\" type=\"s\" access=\"read\"/>" \
+ " <property name=\"StandardOutput\" type=\"s\" access=\"read\"/>" \
+ " <property name=\"StandardError\" type=\"s\" access=\"read\"/>" \
+ " <property name=\"TTYPath\" type=\"s\" access=\"read\"/>" \
+ " <property name=\"SyslogPriority\" type=\"i\" access=\"read\"/>" \
+ " <property name=\"SyslogIdentifier\" type=\"s\" access=\"read\"/>" \
+ " <property name=\"SecureBits\" type=\"i\" access=\"read\"/>" \
+ " <property name=\"CapabilityBoundingSetDrop\" type=\"t\" access=\"read\"/>" \
+ " <property name=\"User\" type=\"s\" access=\"read\"/>" \
+ " <property name=\"Group\" type=\"s\" access=\"read\"/>" \
+ " <property name=\"SupplementaryGroups\" type=\"as\" access=\"read\"/>"
+
+#define BUS_EXEC_CONTEXT_PROPERTIES(interface, context) \
+ { interface, "Environment", bus_property_append_strv, "as", (context).environment }, \
+ { interface, "UMask", bus_property_append_mode, "u", &(context).umask }, \
+ /* RLimits */ \
+ { interface, "WorkingDirectory", bus_property_append_string, "s", (context).working_directory }, \
+ { interface, "RootDirectory", bus_property_append_string, "s", (context).root_directory }, \
+ /* OOM Adjust */ \
+ /* Nice */ \
+ /* IOPrio */ \
+ /* CPUSchedPolicy */ \
+ /* CPUSchedPriority */ \
+ /* CPUAffinity */ \
+ /* TimerSlackNS */ \
+ { interface, "CPUSchedulingResetOnFork", bus_property_append_bool, "b", &(context).cpu_sched_reset_on_fork }, \
+ { interface, "NonBlocking", bus_property_append_bool, "b", &(context).non_blocking }, \
+ { interface, "StandardInput", bus_execute_append_input, "s", &(context).std_input }, \
+ { interface, "StandardOutput", bus_execute_append_output, "s", &(context).std_output }, \
+ { interface, "StandardError", bus_execute_append_output, "s", &(context).std_error }, \
+ { interface, "TTYPath", bus_property_append_string, "s", (context).tty_path }, \
+ { interface, "SyslogPriority", bus_property_append_int, "i", &(context).syslog_priority }, \
+ { interface, "SyslogIdentifier", bus_property_append_string, "s", (context).syslog_identifier }, \
+ /* CAPABILITIES */ \
+ { interface, "SecureBits", bus_property_append_int, "i", &(context).secure_bits }, \
+ { interface, "CapabilityBoundingSetDrop", bus_property_append_uint64, "t", &(context).capability_bounding_set_drop }, \
+ { interface, "User", bus_property_append_string, "s", (context).user }, \
+ { interface, "Group", bus_property_append_string, "s", (context).group }, \
+ { interface, "SupplementaryGroups", bus_property_append_strv, "as", (context).supplementary_groups }
+
+int bus_execute_append_output(Manager *m, DBusMessageIter *i, const char *property, void *data);
+int bus_execute_append_input(Manager *m, DBusMessageIter *i, const char *property, void *data);
+
+#endif
#include "dbus.h"
#include "log.h"
+#include "dbus-job.h"
static const char introspection[] =
DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE
BUS_INTROSPECTABLE_INTERFACE
"</node>";
-DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_job_append_state, job_state, JobState);
-DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_job_append_type, job_type, JobType);
+static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_job_append_state, job_state, JobState);
+static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_job_append_type, job_type, JobType);
static int bus_job_append_unit(Manager *m, DBusMessageIter *i, const char *property, void *data) {
Job *j = data;
--- /dev/null
+/*-*- Mode: C; c-basic-offset: 8 -*-*/
+
+#ifndef foodbusjobhfoo
+#define foodbusjobhfoo
+
+/***
+ This file is part of systemd.
+
+ Copyright 2010 Lennart Poettering
+
+ systemd is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ systemd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <dbus/dbus.h>
+
+void bus_job_send_change_signal(Job *j);
+void bus_job_send_removed_signal(Job *j);
+
+extern const DBusObjectPathVTable bus_job_vtable;
+
+#endif
#include "dbus.h"
#include "log.h"
+#include "dbus-manager.h"
#define INTROSPECTION_BEGIN \
DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE \
"<node>" \
- " <interface name=\"org.freedesktop.systemd1\">" \
+ " <interface name=\"org.freedesktop.systemd1.Manager\">" \
" <method name=\"GetUnit\">" \
" <arg name=\"name\" type=\"s\" direction=\"in\"/>" \
" <arg name=\"unit\" type=\"o\" direction=\"out\"/>" \
" <method name=\"Subscribe\"/>" \
" <method name=\"Unsubscribe\"/>" \
" <method name=\"Dump\"/>" \
+ " <method name=\"CreateSnapshot\">" \
+ " <arg name=\"name\" type=\"s\" direction=\"in\"/>" \
+ " <arg nane=\"cleanup\" type=\"b\" direction=\"in\"/>" \
+ " <arg name=\"unit\" type=\"o\" direction=\"out\"/>" \
+ " </method>" \
" <signal name=\"UnitNew\">" \
" <arg name=\"id\" type=\"s\"/>" \
" <arg name=\"unit\" type=\"o\"/>" \
#define INTROSPECTION_END \
"</node>"
-DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_manager_append_running_as, manager_running_as, ManagerRunningAs);
+static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_manager_append_running_as, manager_running_as, ManagerRunningAs);
static int bus_manager_append_log_target(Manager *m, DBusMessageIter *i, const char *property, void *data) {
const char *t;
Manager *m = data;
const BusProperty properties[] = {
- { "org.freedesktop.systemd1", "Version", bus_property_append_string, "s", PACKAGE_VERSION },
- { "org.freedesktop.systemd1", "RunningAs", bus_manager_append_running_as, "s", &m->running_as },
- { "org.freedesktop.systemd1", "BootTimestamp", bus_property_append_uint64, "t", &m->boot_timestamp },
- { "org.freedesktop.systemd1", "LogLevel", bus_manager_append_log_level, "s", NULL },
- { "org.freedesktop.systemd1", "LogTarget", bus_manager_append_log_target, "s", NULL },
+ { "org.freedesktop.systemd1.Manager", "Version", bus_property_append_string, "s", PACKAGE_STRING },
+ { "org.freedesktop.systemd1.Manager", "RunningAs", bus_manager_append_running_as, "s", &m->running_as },
+ { "org.freedesktop.systemd1.Manager", "BootTimestamp", bus_property_append_uint64, "t", &m->boot_timestamp },
+ { "org.freedesktop.systemd1.Manager", "LogLevel", bus_manager_append_log_level, "s", NULL },
+ { "org.freedesktop.systemd1.Manager", "LogTarget", bus_manager_append_log_target, "s", NULL },
{ NULL, NULL, NULL, NULL, NULL }
};
dbus_message_get_member(message),
dbus_message_get_path(message));
- if (dbus_message_is_method_call(message, "org.freedesktop.systemd1", "GetUnit")) {
+ if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "GetUnit")) {
const char *name;
Unit *u;
DBUS_TYPE_INVALID))
goto oom;
- } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1", "LoadUnit")) {
+ } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "LoadUnit")) {
const char *name;
Unit *u;
DBUS_TYPE_INVALID))
goto oom;
- } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1", "ClearJobs")) {
+ } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "ClearJobs")) {
manager_clear_jobs(m);
if (!(reply = dbus_message_new_method_return(message)))
goto oom;
- } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1", "ListUnits")) {
+ } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "ListUnits")) {
DBusMessageIter iter, sub;
Iterator i;
Unit *u;
if (!dbus_message_iter_close_container(&iter, &sub))
goto oom;
- } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1", "ListJobs")) {
+ } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "ListJobs")) {
DBusMessageIter iter, sub;
Iterator i;
Job *j;
if (!dbus_message_iter_close_container(&iter, &sub))
goto oom;
- } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1", "Subscribe")) {
+ } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "Subscribe")) {
char *client;
if (!(client = strdup(dbus_message_get_sender(message))))
if (!(reply = dbus_message_new_method_return(message)))
goto oom;
- } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1", "Unsubscribe")) {
+ } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "Unsubscribe")) {
char *client;
if (!(client = set_remove(m->subscribed, (char*) dbus_message_get_sender(message))))
if (!(reply = dbus_message_new_method_return(message)))
goto oom;
- } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1", "Dump")) {
+ } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "Dump")) {
FILE *f;
char *dump = NULL;
size_t size;
}
free(dump);
+ } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "CreateSnapshot")) {
+ const char *name;
+ dbus_bool_t cleanup;
+ Snapshot *s;
+
+ if (!dbus_message_get_args(
+ message,
+ &error,
+ DBUS_TYPE_STRING, &name,
+ DBUS_TYPE_BOOLEAN, &cleanup,
+ DBUS_TYPE_INVALID))
+ return bus_send_error_reply(m, message, &error, -EINVAL);
+
+ if (name && name[0] == 0)
+ name = NULL;
+
+ if ((r = snapshot_create(m, name, cleanup, &s)) < 0)
+ return bus_send_error_reply(m, message, NULL, r);
+
+ if (!(reply = dbus_message_new_method_return(message)))
+ goto oom;
+
+ if (!(path = unit_dbus_path(UNIT(s))))
+ goto oom;
+
+ if (!dbus_message_append_args(
+ reply,
+ DBUS_TYPE_OBJECT_PATH, &path,
+ DBUS_TYPE_INVALID))
+ goto oom;
} else if (dbus_message_is_method_call(message, "org.freedesktop.DBus.Introspectable", "Introspect")) {
char *introspection = NULL;
--- /dev/null
+/*-*- Mode: C; c-basic-offset: 8 -*-*/
+
+#ifndef foodbusmanagerhfoo
+#define foodbusmanagerhfoo
+
+/***
+ This file is part of systemd.
+
+ Copyright 2010 Lennart Poettering
+
+ systemd is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ systemd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <dbus/dbus.h>
+
+extern const DBusObjectPathVTable bus_manager_vtable;
+
+#endif
--- /dev/null
+/*-*- Mode: C; c-basic-offset: 8 -*-*/
+
+/***
+ This file is part of systemd.
+
+ Copyright 2010 Lennart Poettering
+
+ systemd is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ systemd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include "dbus-unit.h"
+#include "dbus-mount.h"
+#include "dbus-execute.h"
+
+static const char introspection[] =
+ DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE
+ "<node>"
+ BUS_UNIT_INTERFACE
+ BUS_PROPERTIES_INTERFACE
+ " <interface name=\"org.freedesktop.systemd1.Mount\">"
+ " <property name=\"Where\" type=\"s\" access=\"read\"/>"
+ " <property name=\"TimeoutUSec\" type=\"t\" access=\"read\"/>"
+ BUS_EXEC_CONTEXT_INTERFACE
+ " <property name=\"KillMode\" type=\"s\" access=\"read\"/>"
+ " <property name=\"ControlPID\" type=\"u\" access=\"read\"/>"
+ " </interface>"
+ BUS_INTROSPECTABLE_INTERFACE
+ "</node>";
+
+DBusHandlerResult bus_mount_message_handler(Unit *u, DBusMessage *message) {
+ const BusProperty properties[] = {
+ BUS_UNIT_PROPERTIES,
+ { "org.freedesktop.systemd1.Mount", "Where", bus_property_append_string, "s", u->mount.where },
+ /* Where, Options, fstype */
+ { "org.freedesktop.systemd1.Mount", "TimeoutUSec", bus_property_append_usec, "t", &u->mount.timeout_usec },
+ /* ExecCommand */
+ BUS_EXEC_CONTEXT_PROPERTIES("org.freedesktop.systemd1.Mount", u->mount.exec_context),
+ { "org.freedesktop.systemd1.Mount", "KillMode", bus_unit_append_kill_mode, "s", &u->mount.kill_mode },
+ { "org.freedesktop.systemd1.Mount", "ControlPID", bus_property_append_pid, "u", &u->mount.control_pid },
+ { NULL, NULL, NULL, NULL, NULL }
+ };
+
+ return bus_default_message_handler(u->meta.manager, message, introspection, properties);
+}
--- /dev/null
+/*-*- Mode: C; c-basic-offset: 8 -*-*/
+
+#ifndef foodbusmounthfoo
+#define foodbusmounthfoo
+
+/***
+ This file is part of systemd.
+
+ Copyright 2010 Lennart Poettering
+
+ systemd is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ systemd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <dbus/dbus.h>
+
+#include "unit.h"
+
+DBusHandlerResult bus_mount_message_handler(Unit *u, DBusMessage *message);
+
+#endif
--- /dev/null
+/*-*- Mode: C; c-basic-offset: 8 -*-*/
+
+/***
+ This file is part of systemd.
+
+ Copyright 2010 Lennart Poettering
+
+ systemd is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ systemd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <errno.h>
+
+#include "dbus-unit.h"
+#include "dbus-execute.h"
+#include "dbus-service.h"
+
+static const char introspection[] =
+ DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE
+ "<node>"
+ BUS_UNIT_INTERFACE
+ BUS_PROPERTIES_INTERFACE
+ " <interface name=\"org.freedesktop.systemd1.Service\">"
+ " <property name=\"Type\" type=\"s\" access=\"read\"/>"
+ " <property name=\"Restart\" type=\"s\" access=\"read\"/>"
+ " <property name=\"PIDFile\" type=\"s\" access=\"read\"/>"
+ " <property name=\"RestartUSec\" type=\"t\" access=\"read\"/>"
+ " <property name=\"TimeoutUSec\" type=\"t\" access=\"read\"/>"
+ BUS_EXEC_CONTEXT_INTERFACE
+ " <property name=\"PermissionsStartOnly\" type=\"b\" access=\"read\"/>"
+ " <property name=\"RootDirectoryStartOnly\" type=\"b\" access=\"read\"/>"
+ " <property name=\"ValidNoProcess\" type=\"b\" access=\"read\"/>"
+ " <property name=\"KillMode\" type=\"s\" access=\"read\"/>"
+ " <property name=\"MainPID\" type=\"u\" access=\"read\"/>"
+ " <property name=\"ControlPID\" type=\"u\" access=\"read\"/>"
+ " <property name=\"SysVPath\" type=\"s\" access=\"read\"/>"
+ " <property name=\"BusName\" type=\"s\" access=\"read\"/>"
+ " </interface>"
+ BUS_INTROSPECTABLE_INTERFACE
+ "</node>";
+
+static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_service_append_type, service_type, ServiceType);
+static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_service_append_restart, service_restart, ServiceRestart);
+
+DBusHandlerResult bus_service_message_handler(Unit *u, DBusMessage *message) {
+ const BusProperty properties[] = {
+ BUS_UNIT_PROPERTIES,
+ { "org.freedesktop.systemd1.Service", "Type", bus_service_append_type, "s", &u->service.type },
+ { "org.freedesktop.systemd1.Service", "Restart", bus_service_append_restart, "s", &u->service.restart },
+ { "org.freedesktop.systemd1.Service", "PIDFile", bus_property_append_string, "s", u->service.pid_file },
+ { "org.freedesktop.systemd1.Service", "RestartUSec", bus_property_append_usec, "t", &u->service.restart_usec },
+ { "org.freedesktop.systemd1.Service", "TimeoutUSec", bus_property_append_usec, "t", &u->service.timeout_usec },
+ /* ExecCommand */
+ BUS_EXEC_CONTEXT_PROPERTIES("org.freedesktop.systemd1.Service", u->service.exec_context),
+ { "org.freedesktop.systemd1.Service", "PermissionsStartOnly", bus_property_append_bool, "b", &u->service.permissions_start_only },
+ { "org.freedesktop.systemd1.Service", "RootDirectoryStartOnly", bus_property_append_bool, "b", &u->service.root_directory_start_only },
+ { "org.freedesktop.systemd1.Service", "ValidNoProcess", bus_property_append_bool, "b", &u->service.valid_no_process },
+ { "org.freedesktop.systemd1.Service", "KillMode", bus_unit_append_kill_mode, "s", &u->service.kill_mode },
+ /* MainExecStatus */
+ { "org.freedesktop.systemd1.Service", "MainPID", bus_property_append_pid, "u", &u->service.main_pid },
+ { "org.freedesktop.systemd1.Service", "ControlPID", bus_property_append_pid, "u", &u->service.control_pid },
+ { "org.freedesktop.systemd1.Service", "SysVPath", bus_property_append_string, "s", u->service.sysv_path },
+ { "org.freedesktop.systemd1.Service", "BusName", bus_property_append_string, "s", u->service.bus_name },
+ { NULL, NULL, NULL, NULL, NULL }
+ };
+
+ return bus_default_message_handler(u->meta.manager, message, introspection, properties);
+}
--- /dev/null
+/*-*- Mode: C; c-basic-offset: 8 -*-*/
+
+#ifndef foodbusservicehfoo
+#define foodbusservicehfoo
+
+/***
+ This file is part of systemd.
+
+ Copyright 2010 Lennart Poettering
+
+ systemd is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ systemd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <dbus/dbus.h>
+
+#include "unit.h"
+
+DBusHandlerResult bus_service_message_handler(Unit *u, DBusMessage *message);
+
+#endif
--- /dev/null
+/*-*- Mode: C; c-basic-offset: 8 -*-*/
+
+/***
+ This file is part of systemd.
+
+ Copyright 2010 Lennart Poettering
+
+ systemd is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ systemd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include "dbus-unit.h"
+#include "dbus-snapshot.h"
+
+static const char introspection[] =
+ DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE
+ "<node>"
+ BUS_UNIT_INTERFACE
+ BUS_PROPERTIES_INTERFACE
+ " <interface name=\"org.freedesktop.systemd1.Snapshot\">"
+ " <method name=\"Remove\"/>"
+ " <property name=\"Cleanup\" type=\"b\" access=\"read\"/>"
+ " </interface>"
+ BUS_INTROSPECTABLE_INTERFACE
+ "</node>";
+
+DBusHandlerResult bus_snapshot_message_handler(Unit *u, DBusMessage *message) {
+ const BusProperty properties[] = {
+ BUS_UNIT_PROPERTIES,
+ { "org.freedesktop.systemd1.Snapshot", "Cleanup", bus_property_append_bool, "b", &u->snapshot.cleanup },
+ { NULL, NULL, NULL, NULL, NULL }
+ };
+
+ DBusMessage *reply = NULL;
+ DBusError error;
+
+ dbus_error_init(&error);
+
+ if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Snapshot", "Remove")) {
+
+ snapshot_remove(SNAPSHOT(u));
+
+ if (!(reply = dbus_message_new_method_return(message)))
+ goto oom;
+
+ } else
+ return bus_default_message_handler(u->meta.manager, message, introspection, properties);
+
+ if (reply) {
+ if (!dbus_connection_send(u->meta.manager->api_bus, reply, NULL))
+ goto oom;
+
+ dbus_message_unref(reply);
+ }
+
+ return DBUS_HANDLER_RESULT_HANDLED;
+
+oom:
+ if (reply)
+ dbus_message_unref(reply);
+
+ dbus_error_free(&error);
+
+ return DBUS_HANDLER_RESULT_NEED_MEMORY;
+}
--- /dev/null
+/*-*- Mode: C; c-basic-offset: 8 -*-*/
+
+#ifndef foodbussnapshothfoo
+#define foodbussnapshothfoo
+
+/***
+ This file is part of systemd.
+
+ Copyright 2010 Lennart Poettering
+
+ systemd is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ systemd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <dbus/dbus.h>
+
+#include "unit.h"
+
+DBusHandlerResult bus_snapshot_message_handler(Unit *u, DBusMessage *message);
+
+#endif
--- /dev/null
+/*-*- Mode: C; c-basic-offset: 8 -*-*/
+
+/***
+ This file is part of systemd.
+
+ Copyright 2010 Lennart Poettering
+
+ systemd is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ systemd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include "dbus-unit.h"
+#include "dbus-socket.h"
+#include "dbus-execute.h"
+
+static const char introspection[] =
+ DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE
+ "<node>"
+ BUS_UNIT_INTERFACE
+ BUS_PROPERTIES_INTERFACE
+ " <interface name=\"org.freedesktop.systemd1.Socket\">"
+ " <property name=\"BindIPv6Only\" type=\"b\" access=\"read\"/>"
+ " <property name=\"Backlog\" type=\"u\" access=\"read\"/>"
+ " <property name=\"TimeoutUSec\" type=\"t\" access=\"read\"/>"
+ BUS_EXEC_CONTEXT_INTERFACE
+ " <property name=\"KillMode\" type=\"s\" access=\"read\"/>"
+ " <property name=\"ControlPID\" type=\"u\" access=\"read\"/>"
+ " <property name=\"BindToDevice\" type=\"s\" access=\"read\"/>"
+ " <property name=\"DirectoryMode\" type=\"u\" access=\"read\"/>"
+ " <property name=\"SocketMode\" type=\"u\" access=\"read\"/>"
+ " <property name=\"Accept\" type=\"b\" access=\"read\"/>"
+ " </interface>"
+ BUS_INTROSPECTABLE_INTERFACE
+ "</node>";
+
+DBusHandlerResult bus_socket_message_handler(Unit *u, DBusMessage *message) {
+ const BusProperty properties[] = {
+ BUS_UNIT_PROPERTIES,
+ { "org.freedesktop.systemd1.Socket", "BindIPv6Only", bus_property_append_bool, "b", &u->socket.bind_ipv6_only },
+ { "org.freedesktop.systemd1.Socket", "Backlog", bus_property_append_unsigned, "u", &u->socket.backlog },
+ { "org.freedesktop.systemd1.Socket", "TimeoutUSec", bus_property_append_usec, "t", &u->socket.timeout_usec },
+ /* ExecCommand */
+ BUS_EXEC_CONTEXT_PROPERTIES("org.freedesktop.systemd1.Socket", u->socket.exec_context),
+ { "org.freedesktop.systemd1.Socket", "KillMode", bus_unit_append_kill_mode, "s", &u->socket.kill_mode },
+ { "org.freedesktop.systemd1.Socket", "ControlPID", bus_property_append_pid, "u", &u->socket.control_pid },
+ { "org.freedesktop.systemd1.Socket", "BindToDevice", bus_property_append_string, "s", u->socket.bind_to_device },
+ { "org.freedesktop.systemd1.Socket", "DirectoryMode", bus_property_append_mode, "u", &u->socket.directory_mode },
+ { "org.freedesktop.systemd1.Socket", "SocketMode", bus_property_append_mode, "u", &u->socket.socket_mode },
+ { "org.freedesktop.systemd1.Socket", "Accept", bus_property_append_bool, "b", &u->socket.accept },
+ { NULL, NULL, NULL, NULL, NULL }
+ };
+
+ return bus_default_message_handler(u->meta.manager, message, introspection, properties);
+}
--- /dev/null
+/*-*- Mode: C; c-basic-offset: 8 -*-*/
+
+#ifndef foodbussockethfoo
+#define foodbussockethfoo
+
+/***
+ This file is part of systemd.
+
+ Copyright 2010 Lennart Poettering
+
+ systemd is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ systemd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <dbus/dbus.h>
+
+#include "unit.h"
+
+DBusHandlerResult bus_socket_message_handler(Unit *u, DBusMessage *message);
+
+#endif
--- /dev/null
+/*-*- Mode: C; c-basic-offset: 8 -*-*/
+
+/***
+ This file is part of systemd.
+
+ Copyright 2010 Lennart Poettering
+
+ systemd is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ systemd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include "dbus-unit.h"
+#include "dbus-target.h"
+
+static const char introspection[] =
+ DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE
+ "<node>"
+ BUS_UNIT_INTERFACE
+ BUS_PROPERTIES_INTERFACE
+ " <interface name=\"org.freedesktop.systemd1.Target\">"
+ " </interface>"
+ BUS_INTROSPECTABLE_INTERFACE
+ "</node>";
+
+DBusHandlerResult bus_target_message_handler(Unit *u, DBusMessage *message) {
+ const BusProperty properties[] = {
+ BUS_UNIT_PROPERTIES,
+ { NULL, NULL, NULL, NULL, NULL }
+ };
+
+ return bus_default_message_handler(u->meta.manager, message, introspection, properties);
+}
--- /dev/null
+/*-*- Mode: C; c-basic-offset: 8 -*-*/
+
+#ifndef foodbustargethfoo
+#define foodbustargethfoo
+
+/***
+ This file is part of systemd.
+
+ Copyright 2010 Lennart Poettering
+
+ systemd is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ systemd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <dbus/dbus.h>
+
+#include "unit.h"
+
+DBusHandlerResult bus_target_message_handler(Unit *u, DBusMessage *message);
+
+#endif
#include "dbus.h"
#include "log.h"
+#include "dbus-unit.h"
-static const char introspection[] =
- DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE
- "<node>"
- " <interface name=\"org.freedesktop.systemd1.Unit\">"
- " <method name=\"Start\">"
- " <arg name=\"mode\" type=\"s\" direction=\"in\"/>"
- " <arg name=\"job\" type=\"o\" direction=\"out\"/>"
- " </method>"
- " <method name=\"Stop\">"
- " <arg name=\"mode\" type=\"s\" direction=\"in\"/>"
- " <arg name=\"job\" type=\"o\" direction=\"out\"/>"
- " </method>"
- " <method name=\"Restart\">"
- " <arg name=\"mode\" type=\"s\" direction=\"in\"/>"
- " <arg name=\"job\" type=\"o\" direction=\"out\"/>"
- " </method>"
- " <method name=\"Reload\">"
- " <arg name=\"mode\" type=\"s\" direction=\"in\"/>"
- " <arg name=\"job\" type=\"o\" direction=\"out\"/>"
- " </method>"
- " <signal name=\"Changed\"/>"
- " <property name=\"Id\" type=\"s\" access=\"read\"/>"
- " <property name=\"Description\" type=\"s\" access=\"read\"/>"
- " <property name=\"LoadState\" type=\"s\" access=\"read\"/>"
- " <property name=\"ActiveState\" type=\"s\" access=\"read\"/>"
- " <property name=\"SubState\" type=\"s\" access=\"read\"/>"
- " <property name=\"FragmentPath\" type=\"s\" access=\"read\"/>"
- " <property name=\"ActiveEnterTimestamp\" type=\"t\" access=\"read\"/>"
- " <property name=\"ActiveExitTimestamp\" type=\"t\" access=\"read\"/>"
- " <property name=\"CanReload\" type=\"b\" access=\"read\"/>"
- " <property name=\"CanStart\" type=\"b\" access=\"read\"/>"
- " <property name=\"Job\" type=\"(uo)\" access=\"read\"/>"
- " </interface>"
- BUS_PROPERTIES_INTERFACE
- BUS_INTROSPECTABLE_INTERFACE
- "</node>";
-
-static int bus_unit_append_description(Manager *m, DBusMessageIter *i, const char *property, void *data) {
+int bus_unit_append_names(Manager *m, DBusMessageIter *i, const char *property, void *data) {
+ char *t;
+ Iterator j;
+ DBusMessageIter sub;
+ Unit *u = data;
+
+ if (!dbus_message_iter_open_container(i, DBUS_TYPE_ARRAY, "s", &sub))
+ return -ENOMEM;
+
+ SET_FOREACH(t, u->meta.names, j)
+ if (!dbus_message_iter_append_basic(&sub, DBUS_TYPE_STRING, &t))
+ return -ENOMEM;
+
+ if (!dbus_message_iter_close_container(i, &sub))
+ return -ENOMEM;
+
+ return 0;
+}
+
+int bus_unit_append_description(Manager *m, DBusMessageIter *i, const char *property, void *data) {
Unit *u = data;
const char *d;
DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_unit_append_load_state, unit_load_state, UnitLoadState);
-static int bus_unit_append_active_state(Manager *m, DBusMessageIter *i, const char *property, void *data) {
+int bus_unit_append_active_state(Manager *m, DBusMessageIter *i, const char *property, void *data) {
Unit *u = data;
const char *state;
return 0;
}
-static int bus_unit_append_sub_state(Manager *m, DBusMessageIter *i, const char *property, void *data) {
+int bus_unit_append_sub_state(Manager *m, DBusMessageIter *i, const char *property, void *data) {
Unit *u = data;
const char *state;
return 0;
}
-static int bus_unit_append_can_reload(Manager *m, DBusMessageIter *i, const char *property, void *data) {
+int bus_unit_append_can_start(Manager *m, DBusMessageIter *i, const char *property, void *data) {
Unit *u = data;
dbus_bool_t b;
assert(property);
assert(u);
- b = unit_can_reload(u);
+ b = unit_can_start(u);
if (!dbus_message_iter_append_basic(i, DBUS_TYPE_BOOLEAN, &b))
return -ENOMEM;
return 0;
}
-static int bus_unit_append_can_start(Manager *m, DBusMessageIter *i, const char *property, void *data) {
+int bus_unit_append_can_reload(Manager *m, DBusMessageIter *i, const char *property, void *data) {
Unit *u = data;
dbus_bool_t b;
assert(property);
assert(u);
- b = unit_can_start(u);
+ b = unit_can_reload(u);
if (!dbus_message_iter_append_basic(i, DBUS_TYPE_BOOLEAN, &b))
return -ENOMEM;
return 0;
}
-static int bus_unit_append_job(Manager *m, DBusMessageIter *i, const char *property, void *data) {
+int bus_unit_append_job(Manager *m, DBusMessageIter *i, const char *property, void *data) {
Unit *u = data;
DBusMessageIter sub;
char *p;
return 0;
}
-static DBusHandlerResult bus_unit_message_dispatch(Unit *u, DBusMessage *message) {
+int bus_unit_append_default_cgroup(Manager *m, DBusMessageIter *i, const char *property, void *data) {
+ Unit *u = data;
+ char *t;
+ CGroupBonding *cgb;
+ bool success;
- const BusProperty properties[] = {
- { "org.freedesktop.systemd1.Unit", "Id", bus_property_append_string, "s", u->meta.id },
- { "org.freedesktop.systemd1.Unit", "Description", bus_unit_append_description, "s", u },
- { "org.freedesktop.systemd1.Unit", "LoadState", bus_unit_append_load_state, "s", &u->meta.load_state },
- { "org.freedesktop.systemd1.Unit", "ActiveState", bus_unit_append_active_state, "s", u },
- { "org.freedesktop.systemd1.Unit", "SubState", bus_unit_append_sub_state, "s", u },
- { "org.freedesktop.systemd1.Unit", "FragmentPath", bus_property_append_string, "s", u->meta.fragment_path },
- { "org.freedesktop.systemd1.Unit", "ActiveEnterTimestamp", bus_property_append_uint64, "t", &u->meta.active_enter_timestamp },
- { "org.freedesktop.systemd1.Unit", "ActiveExitTimestamp", bus_property_append_uint64, "t", &u->meta.active_exit_timestamp },
- { "org.freedesktop.systemd1.Unit", "CanReload", bus_unit_append_can_reload, "b", u },
- { "org.freedesktop.systemd1.Unit", "CanStart", bus_unit_append_can_start, "b", u },
- { "org.freedesktop.systemd1.Unit", "Job", bus_unit_append_job, "(uo)", u },
- { NULL, NULL, NULL, NULL, NULL }
- };
+ assert(m);
+ assert(i);
+ assert(property);
+ assert(u);
+
+ if ((cgb = unit_get_default_cgroup(u))) {
+ if (!(t = cgroup_bonding_to_string(cgb)))
+ return -ENOMEM;
+ } else
+ t = (char*) "";
+ success = dbus_message_iter_append_basic(i, DBUS_TYPE_STRING, &t);
+
+ if (cgb)
+ free(t);
+
+ return success ? 0 : -ENOMEM;
+}
+
+int bus_unit_append_cgroups(Manager *m, DBusMessageIter *i, const char *property, void *data) {
+ Unit *u = data;
+ CGroupBonding *cgb;
+ DBusMessageIter sub;
+
+ if (!dbus_message_iter_open_container(i, DBUS_TYPE_ARRAY, "s", &sub))
+ return -ENOMEM;
+
+ LIST_FOREACH(by_unit, cgb, u->meta.cgroup_bondings) {
+ char *t;
+ bool success;
+
+ if (!(t = cgroup_bonding_to_string(cgb)))
+ return -ENOMEM;
+
+ success = dbus_message_iter_append_basic(&sub, DBUS_TYPE_STRING, &t);
+ free(t);
+
+ if (!success)
+ return -ENOMEM;
+ }
+
+ if (!dbus_message_iter_close_container(i, &sub))
+ return -ENOMEM;
+
+ return 0;
+}
+
+DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_unit_append_kill_mode, kill_mode, KillMode);
+
+static DBusHandlerResult bus_unit_message_dispatch(Unit *u, DBusMessage *message) {
DBusMessage *reply = NULL;
Manager *m = u->meta.manager;
DBusError error;
job_type = JOB_RELOAD;
else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Unit", "Restart"))
job_type = JOB_RESTART;
+ else if (UNIT_VTABLE(u)->bus_message_handler)
+ return UNIT_VTABLE(u)->bus_message_handler(u, message);
else
- return bus_default_message_handler(u->meta.manager, message, introspection, properties);
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
if (job_type != _JOB_TYPE_INVALID) {
const char *smode;
--- /dev/null
+/*-*- Mode: C; c-basic-offset: 8 -*-*/
+
+#ifndef foodbusunithfoo
+#define foodbusunithfoo
+
+/***
+ This file is part of systemd.
+
+ Copyright 2010 Lennart Poettering
+
+ systemd is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ systemd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <dbus/dbus.h>
+
+#include "manager.h"
+
+#define BUS_UNIT_INTERFACE \
+ " <interface name=\"org.freedesktop.systemd1.Unit\">" \
+ " <method name=\"Start\">" \
+ " <arg name=\"mode\" type=\"s\" direction=\"in\"/>" \
+ " <arg name=\"job\" type=\"o\" direction=\"out\"/>" \
+ " </method>" \
+ " <method name=\"Stop\">" \
+ " <arg name=\"mode\" type=\"s\" direction=\"in\"/>" \
+ " <arg name=\"job\" type=\"o\" direction=\"out\"/>" \
+ " </method>" \
+ " <method name=\"Restart\">" \
+ " <arg name=\"mode\" type=\"s\" direction=\"in\"/>" \
+ " <arg name=\"job\" type=\"o\" direction=\"out\"/>" \
+ " </method>" \
+ " <method name=\"Reload\">" \
+ " <arg name=\"mode\" type=\"s\" direction=\"in\"/>" \
+ " <arg name=\"job\" type=\"o\" direction=\"out\"/>" \
+ " </method>" \
+ " <signal name=\"Changed\"/>" \
+ " <property name=\"Id\" type=\"s\" access=\"read\"/>" \
+ " <property name=\"Names\" type=\"as\" access=\"read\"/>" \
+ " <property name=\"Description\" type=\"s\" access=\"read\"/>" \
+ " <property name=\"LoadState\" type=\"s\" access=\"read\"/>" \
+ " <property name=\"ActiveState\" type=\"s\" access=\"read\"/>" \
+ " <property name=\"SubState\" type=\"s\" access=\"read\"/>" \
+ " <property name=\"FragmentPath\" type=\"s\" access=\"read\"/>" \
+ " <property name=\"ActiveEnterTimestamp\" type=\"t\" access=\"read\"/>" \
+ " <property name=\"ActiveExitTimestamp\" type=\"t\" access=\"read\"/>" \
+ " <property name=\"CanReload\" type=\"b\" access=\"read\"/>" \
+ " <property name=\"CanStart\" type=\"b\" access=\"read\"/>" \
+ " <property name=\"Job\" type=\"(uo)\" access=\"read\"/>" \
+ " <property name=\"RecursiveStop\" type=\"b\" access=\"read\"/>" \
+ " <property name=\"StopWhenUneeded\" type=\"b\" access=\"read\"/>" \
+ " <property name=\"DefaultControlGroup\" type=\"s\" access=\"read\"/>" \
+ " <property name=\"ControlGroups\" type=\"as\" access=\"read\"/>" \
+ " </interface>"
+
+#define BUS_UNIT_PROPERTIES \
+ { "org.freedesktop.systemd1.Unit", "Id", bus_property_append_string, "s", u->meta.id }, \
+ { "org.freedesktop.systemd1.Unit", "Names", bus_unit_append_names, "as", u }, \
+ { "org.freedesktop.systemd1.Unit", "Description", bus_unit_append_description, "s", u }, \
+ { "org.freedesktop.systemd1.Unit", "LoadState", bus_unit_append_load_state, "s", &u->meta.load_state }, \
+ { "org.freedesktop.systemd1.Unit", "ActiveState", bus_unit_append_active_state, "s", u }, \
+ { "org.freedesktop.systemd1.Unit", "SubState", bus_unit_append_sub_state, "s", u }, \
+ { "org.freedesktop.systemd1.Unit", "FragmentPath", bus_property_append_string, "s", u->meta.fragment_path }, \
+ { "org.freedesktop.systemd1.Unit", "ActiveEnterTimestamp", bus_property_append_uint64, "t", &u->meta.active_enter_timestamp }, \
+ { "org.freedesktop.systemd1.Unit", "ActiveExitTimestamp", bus_property_append_uint64, "t", &u->meta.active_exit_timestamp }, \
+ { "org.freedesktop.systemd1.Unit", "CanStart", bus_unit_append_can_start, "b", u }, \
+ { "org.freedesktop.systemd1.Unit", "CanReload", bus_unit_append_can_reload, "b", u }, \
+ { "org.freedesktop.systemd1.Unit", "Job", bus_unit_append_job, "(uo)", u }, \
+ { "org.freedesktop.systemd1.Unit", "RecursiveStop", bus_property_append_bool, "b", &u->meta.recursive_stop }, \
+ { "org.freedesktop.systemd1.Unit", "StopWhenUneeded", bus_property_append_bool, "b", &u->meta.stop_when_unneeded }, \
+ { "org.freedesktop.systemd1.Unit", "DefaultControlGroup", bus_unit_append_default_cgroup, "s", u }, \
+ { "org.freedesktop.systemd1.Unit", "ControlGroups", bus_unit_append_cgroups, "as", u }
+
+int bus_unit_append_names(Manager *m, DBusMessageIter *i, const char *property, void *data);
+int bus_unit_append_description(Manager *m, DBusMessageIter *i, const char *property, void *data);
+int bus_unit_append_load_state(Manager *m, DBusMessageIter *i, const char *property, void *data);
+int bus_unit_append_active_state(Manager *m, DBusMessageIter *i, const char *property, void *data);
+int bus_unit_append_sub_state(Manager *m, DBusMessageIter *i, const char *property, void *data);
+int bus_unit_append_can_start(Manager *m, DBusMessageIter *i, const char *property, void *data);
+int bus_unit_append_can_reload(Manager *m, DBusMessageIter *i, const char *property, void *data);
+int bus_unit_append_job(Manager *m, DBusMessageIter *i, const char *property, void *data);
+int bus_unit_append_default_cgroup(Manager *m, DBusMessageIter *i, const char *property, void *data);
+int bus_unit_append_cgroups(Manager *m, DBusMessageIter *i, const char *property, void *data);
+int bus_unit_append_kill_mode(Manager *m, DBusMessageIter *i, const char *property, void *data);
+
+void bus_unit_send_change_signal(Unit *u);
+void bus_unit_send_removed_signal(Unit *u);
+
+extern const DBusObjectPathVTable bus_unit_vtable;
+
+#endif
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <dbus/dbus.h>
-
#include <sys/epoll.h>
#include <sys/timerfd.h>
#include <errno.h>
#include <unistd.h>
+#include <dbus/dbus.h>
#include "dbus.h"
#include "log.h"
#include "strv.h"
#include "cgroup.h"
+#include "dbus-unit.h"
+#include "dbus-job.h"
+#include "dbus-manager.h"
static void api_bus_dispatch_status(DBusConnection *bus, DBusDispatchStatus status, void *data) {
Manager *m = data;
assert(property);
assert(data);
+ /* Let's ensure that pid_t is actually 64bit, and hence this
+ * function can be used for usec_t */
+ assert_cc(sizeof(uint64_t) == sizeof(usec_t));
+
if (!dbus_message_iter_append_basic(i, DBUS_TYPE_UINT64, data))
return -ENOMEM;
assert(property);
assert(data);
+ /* Let's ensure that pid_t and mode_t is actually 32bit, and
+ * hence this function can be used for pid_t/mode_t */
+ assert_cc(sizeof(uint32_t) == sizeof(pid_t));
+ assert_cc(sizeof(uint32_t) == sizeof(mode_t));
+ assert_cc(sizeof(uint32_t) == sizeof(unsigned));
+
if (!dbus_message_iter_append_basic(i, DBUS_TYPE_UINT32, data))
return -ENOMEM;
return 0;
}
+
+int bus_property_append_int32(Manager *m, DBusMessageIter *i, const char *property, void *data) {
+ assert(m);
+ assert(i);
+ assert(property);
+ assert(data);
+
+ assert_cc(sizeof(int32_t) == sizeof(int));
+
+ if (!dbus_message_iter_append_basic(i, DBUS_TYPE_INT32, data))
+ return -ENOMEM;
+
+ return 0;
+}
void bus_watch_event(Manager *m, Watch *w, int events);
void bus_timeout_event(Manager *m, Watch *w, int events);
+int bus_query_pid(Manager *m, const char *name);
+
DBusHandlerResult bus_default_message_handler(Manager *m, DBusMessage *message, const char* introspection, const BusProperty *properties);
DBusHandlerResult bus_send_error_reply(Manager *m, DBusMessage *message, DBusError *bus_error, int error);
-int bus_query_pid(Manager *m, const char *name);
-
int bus_property_append_string(Manager *m, DBusMessageIter *i, const char *property, void *data);
int bus_property_append_strv(Manager *m, DBusMessageIter *i, const char *property, void *data);
int bus_property_append_bool(Manager *m, DBusMessageIter *i, const char *property, void *data);
+int bus_property_append_int32(Manager *m, DBusMessageIter *i, const char *property, void *data);
int bus_property_append_uint32(Manager *m, DBusMessageIter *i, const char *property, void *data);
int bus_property_append_uint64(Manager *m, DBusMessageIter *i, const char *property, void *data);
-extern const DBusObjectPathVTable bus_manager_vtable;
-extern const DBusObjectPathVTable bus_job_vtable;
-extern const DBusObjectPathVTable bus_unit_vtable;
-
-void bus_unit_send_change_signal(Unit *u);
-void bus_unit_send_removed_signal(Unit *u);
-
-void bus_job_send_change_signal(Job *j);
-void bus_job_send_removed_signal(Job *j);
+#define bus_property_append_int bus_property_append_int32
+#define bus_property_append_pid bus_property_append_uint32
+#define bus_property_append_mode bus_property_append_uint32
+#define bus_property_append_unsigned bus_property_append_uint32
+#define bus_property_append_usec bus_property_append_uint64
-#define DEFINE_BUS_PROPERTY_APPEND_ENUM(function,name,type) \
- static int function(Manager *m, DBusMessageIter *i, const char *property, void *data) { \
+#define DEFINE_BUS_PROPERTY_APPEND_ENUM(function,name,type) \
+ int function(Manager *m, DBusMessageIter *i, const char *property, void *data) { \
const char *value; \
type *field = data; \
\
#include "strv.h"
#include "log.h"
#include "unit-name.h"
+#include "dbus-device.h"
static const UnitActiveState state_translation_table[_DEVICE_STATE_MAX] = {
[DEVICE_DEAD] = UNIT_INACTIVE,
.active_state = device_active_state,
.sub_state_to_string = device_sub_state_to_string,
+ .bus_message_handler = bus_device_message_handler,
+
.enumerate = device_enumerate,
.shutdown = device_shutdown
};
#include "load-fragment.h"
#include "load-dropin.h"
#include "log.h"
+#include "dbus-job.h"
Job* job_new(Manager *m, JobType type, Unit *unit) {
Job *j;
#include "mount-setup.h"
#include "utmp-wtmp.h"
#include "unit-name.h"
+#include "dbus-unit.h"
+#include "dbus-job.h"
static int enable_special_signals(Manager *m) {
char fd;
#include "strv.h"
#include "mount-setup.h"
#include "unit-name.h"
+#include "mount.h"
+#include "dbus-mount.h"
static const UnitActiveState state_translation_table[_MOUNT_STATE_MAX] = {
[MOUNT_DEAD] = UNIT_INACTIVE,
.sigchld_event = mount_sigchld_event,
.timer_event = mount_timer_event,
+ .bus_message_handler = bus_mount_message_handler,
+
.enumerate = mount_enumerate,
.shutdown = mount_shutdown
};
#include "log.h"
#include "strv.h"
#include "unit-name.h"
+#include "dbus-service.h"
#define COMMENTS "#;\n"
#define NEWLINES "\n\r"
.bus_name_owner_change = service_bus_name_owner_change,
.bus_query_pid_done = service_bus_query_pid_done,
+ .bus_message_handler = bus_service_message_handler,
+
.enumerate = service_enumerate
};
#include "load-fragment.h"
#include "strv.h"
#include "unit-name.h"
+#include "dbus-socket.h"
static const UnitActiveState state_translation_table[_SOCKET_STATE_MAX] = {
[SOCKET_DEAD] = UNIT_INACTIVE,
.fd_event = socket_fd_event,
.sigchld_event = socket_sigchld_event,
- .timer_event = socket_timer_event
+ .timer_event = socket_timer_event,
+
+ .bus_message_handler = bus_socket_message_handler
};
using DBus;
-[DBus (name = "org.freedesktop.systemd1")]
+[DBus (name = "org.freedesktop.systemd1.Manager")]
public interface Manager : DBus.Object {
public struct UnitInfo {
public abstract string description { owned get; }
public abstract string load_state { owned get; }
public abstract string active_state { owned get; }
+ public abstract string sub_state { owned get; }
public abstract string fragment_path { owned get; }
public abstract uint64 active_enter_timestamp { owned get; }
public abstract uint64 active_exit_timestamp { owned get; }
- public abstract bool can_reload { owned get; }
public abstract bool can_start { owned get; }
+ public abstract bool can_reload { owned get; }
public abstract JobLink job { owned get; /* FIXME: this setter is a temporary fix to make valac not segfault */ set; }
+ public abstract bool recursive_stop { owned get; }
+ public abstract bool stop_when_unneeded { owned get; }
+ public abstract string default_control_group { owned get; }
public abstract ObjectPath start(string mode) throws DBus.Error;
public abstract ObjectPath stop(string mode) throws DBus.Error;
#include "target.h"
#include "load-fragment.h"
#include "log.h"
+#include "dbus-target.h"
static const UnitActiveState state_translation_table[_TARGET_STATE_MAX] = {
[TARGET_DEAD] = UNIT_INACTIVE,
.stop = target_stop,
.active_state = target_active_state,
- .sub_state_to_string = target_sub_state_to_string
+ .sub_state_to_string = target_sub_state_to_string,
+
+ .bus_message_handler = bus_target_message_handler
};
#include "log.h"
#include "unit-name.h"
#include "specifier.h"
+#include "dbus-unit.h"
const UnitVTable * const unit_vtable[_UNIT_TYPE_MAX] = {
[UNIT_SERVICE] = &service_vtable,
/* Called whenever a bus PID lookup finishes */
void (*bus_query_pid_done)(Unit *u, const char *name, pid_t pid);
+ /* Called for each message received on the bus */
+ DBusHandlerResult (*bus_message_handler)(Unit *u, DBusMessage *message);
+
/* This is called for each unit type and should be used to
* enumerate existing devices and load them. However,
* everything that is loaded here should still stay in