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 #define BUS_SWAP_INTERFACE \
29 " <interface name=\"org.freedesktop.systemd1.Swap\">\n" \
30 " <property name=\"What\" type=\"s\" access=\"read\"/>\n" \
31 " <property name=\"Priority\" type=\"i\" access=\"read\"/>\n" \
34 #define INTROSPECTION \
35 DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE \
39 BUS_PROPERTIES_INTERFACE \
40 BUS_INTROSPECTABLE_INTERFACE \
43 const char bus_swap_interface[] = BUS_SWAP_INTERFACE;
45 static int bus_swap_append_priority(Manager *m, DBusMessageIter *i, const char *property, void *data) {
54 if (s->from_proc_swaps)
55 j = s->parameters_proc_swaps.priority;
56 else if (s->from_fragment)
57 j = s->parameters_fragment.priority;
58 else if (s->from_etc_fstab)
59 j = s->parameters_etc_fstab.priority;
63 if (!dbus_message_iter_append_basic(i, DBUS_TYPE_INT32, &j))
69 DBusHandlerResult bus_swap_message_handler(Unit *u, DBusConnection *c, DBusMessage *message) {
70 const BusProperty properties[] = {
72 { "org.freedesktop.systemd1.Swap", "What", bus_property_append_string, "s", u->swap.what },
73 { "org.freedesktop.systemd1.Swap", "Priority", bus_swap_append_priority, "i", u },
74 { NULL, NULL, NULL, NULL, NULL }
77 return bus_default_message_handler(u->meta.manager, c, message, INTROSPECTION, properties);