1 /*-*- Mode: C; c-basic-offset: 8 -*-*/
4 This file is part of systemd.
6 Copyright 2010 Lennart Poettering
7 Copyright 2010 Maarten Lankhorst
9 systemd is free software; you can redistribute it and/or modify it
10 under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 systemd is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with systemd; If not, see <http://www.gnu.org/licenses/>.
25 #include "dbus-unit.h"
26 #include "dbus-swap.h"
28 static const char introspection[] =
29 DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE
32 BUS_PROPERTIES_INTERFACE
33 " <interface name=\"org.freedesktop.systemd1.Swap\">"
34 " <property name=\"What\" type=\"s\" access=\"read\"/>"
35 " <property name=\"Priority\" type=\"i\" access=\"read\"/>"
37 BUS_INTROSPECTABLE_INTERFACE
40 static int bus_swap_append_priority(Manager *m, DBusMessageIter *i, const char *property, void *data) {
49 if (s->from_proc_swaps)
50 j = s->parameters_proc_swaps.priority;
51 else if (s->from_fragment)
52 j = s->parameters_fragment.priority;
53 else if (s->from_etc_fstab)
54 j = s->parameters_etc_fstab.priority;
58 if (!dbus_message_iter_append_basic(i, DBUS_TYPE_INT32, &j))
64 DBusHandlerResult bus_swap_message_handler(Unit *u, DBusMessage *message) {
65 const BusProperty properties[] = {
67 { "org.freedesktop.systemd1.Swap", "What", bus_property_append_string, "s", u->swap.what },
68 { "org.freedesktop.systemd1.Swap", "Priority", bus_swap_append_priority, "i", u },
69 { NULL, NULL, NULL, NULL, NULL }
72 return bus_default_message_handler(u->meta.manager, message, introspection, properties);