[systemd-commits] 5 commits - configure.ac src/automount.c src/automount.h src/cgroup.c src/dbus-automount.c src/dbus.c src/dbus-common.c src/dbus-common.h src/dbus-device.c src/dbus-execute.c src/dbus-execute.h src/dbus-job.c src/dbus-manager.c src/dbus-mount.c src/dbus-path.c src/dbus-service.c src/dbus-snapshot.c src/dbus-socket.c src/dbus-swap.c src/dbus-target.c src/dbus-timer.c src/dbus-unit.c src/dbus-unit.h src/device.c src/device.h src/hostname src/job.c src/load-dropin.c src/load-fragment.c src/load-fragment-gperf.gperf.m4 src/locale src/login src/main.c src/manager.c src/manager.h src/mount.c src/mount.h src/path.c src/path.h src/service.c src/service.h src/snapshot.c src/snapshot.h src/socket.c src/socket.h src/swap.c src/swap.h src/target.c src/target.h src/timedate src/timer.c src/timer.h src/unit.c src/unit.h
Michal Schmidt
michich at kemper.freedesktop.org
Mon Jan 16 04:35:52 PST 2012
configure.ac | 1
src/automount.c | 57 +--
src/automount.h | 2
src/cgroup.c | 10
src/dbus-automount.c | 18
src/dbus-common.c | 170 +++++----
src/dbus-common.h | 14
src/dbus-device.c | 17
src/dbus-execute.c | 63 +++
src/dbus-execute.h | 75 ----
src/dbus-job.c | 27 -
src/dbus-manager.c | 124 +++---
src/dbus-mount.c | 36 +
src/dbus-path.c | 25 -
src/dbus-service.c | 79 ++--
src/dbus-snapshot.c | 22 -
src/dbus-socket.c | 75 ++--
src/dbus-swap.c | 26 -
src/dbus-target.c | 8
src/dbus-timer.c | 23 -
src/dbus-unit.c | 132 +++++--
src/dbus-unit.h | 61 ---
src/dbus.c | 2
src/device.c | 29 -
src/device.h | 2
src/hostname/hostnamed.c | 22 -
src/job.c | 100 ++---
src/load-dropin.c | 16
src/load-fragment-gperf.gperf.m4 | 20 -
src/load-fragment.c | 72 +--
src/locale/localed.c | 192 +++++-----
src/login/logind-dbus.c | 37 +-
src/login/logind-seat-dbus.c | 31 -
src/login/logind-session-dbus.c | 77 ++--
src/login/logind-user-dbus.c | 46 +-
src/main.c | 16
src/manager.c | 257 +++++++------
src/manager.h | 12
src/mount.c | 157 ++++----
src/mount.h | 2
src/path.c | 55 +-
src/path.h | 2
src/service.c | 233 ++++++------
src/service.h | 2
src/snapshot.c | 25 -
src/snapshot.h | 2
src/socket.c | 131 +++----
src/socket.h | 2
src/swap.c | 113 +++---
src/swap.h | 2
src/target.c | 9
src/target.h | 2
src/timedate/timedated.c | 115 +++---
src/timer.c | 53 +-
src/timer.h | 2
src/unit.c | 721 +++++++++++++++++++--------------------
src/unit.h | 40 --
57 files changed, 1927 insertions(+), 1737 deletions(-)
New commits:
commit d200735e13c52dcfe36c0e066f9f6c2fbfb85a9c
Author: Michal Schmidt <mschmidt at redhat.com>
Date: Mon Jan 16 00:23:59 2012 +0100
dbus: more efficient implementation of properties
The way the various properties[] arrays are initialized is inefficient:
- only the .data members change at runtime, yet the whole arrays of
properties with all the fields are constructed on the stack one by
one by the code.
- there's duplication, eg. the properties of "org.freedesktop.systemd1.Unit"
are repeated in several unit types.
Fix it by moving the information about properties into static const
sections. Instead of storing the .data directly in the property, store
a constant offset from a run-time base.
The small arrays of struct BusBoundProperties bind together the constant
information with the right runtime information (the base pointer).
On my system the code shrinks by 60 KB, data increases by 10 KB.
diff --git a/configure.ac b/configure.ac
index 194caa5..16365eb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -100,6 +100,7 @@ CC_CHECK_CFLAGS_APPEND([ \
-Wno-unused-parameter \
-Wno-missing-field-initializers \
-Wno-unused-result \
+ -Werror=overflow \
-Wp,-D_FORTIFY_SOURCE=2 \
-ffast-math \
-fno-common \
diff --git a/src/dbus-automount.c b/src/dbus-automount.c
index 62e8a5f..938768b 100644
--- a/src/dbus-automount.c
+++ b/src/dbus-automount.c
@@ -45,14 +45,19 @@
const char bus_automount_interface[] _introspect_("Automount") = BUS_AUTOMOUNT_INTERFACE;
+static const BusProperty bus_automount_properties[] = {
+ { "Where", bus_property_append_string, "s", offsetof(Automount, where), true },
+ { "DirectoryMode", bus_property_append_mode, "u", offsetof(Automount, directory_mode) },
+ { NULL, }
+};
+
DBusHandlerResult bus_automount_message_handler(Unit *u, DBusConnection *c, DBusMessage *message) {
Automount *am = AUTOMOUNT(u);
- const BusProperty properties[] = {
- BUS_UNIT_PROPERTIES,
- { "org.freedesktop.systemd1.Automount", "Where", bus_property_append_string, "s", am->where },
- { "org.freedesktop.systemd1.Automount", "DirectoryMode", bus_property_append_mode, "u", &am->directory_mode },
- { NULL, NULL, NULL, NULL, NULL }
+ const BusBoundProperties bps[] = {
+ { "org.freedesktop.systemd1.Unit", bus_unit_properties, u },
+ { "org.freedesktop.systemd1.Automount", bus_automount_properties, am },
+ { NULL, }
};
- return bus_default_message_handler(c, message, INTROSPECTION, INTERFACES_LIST, properties);
+ return bus_default_message_handler(c, message, INTROSPECTION, INTERFACES_LIST, bps);
}
diff --git a/src/dbus-common.c b/src/dbus-common.c
index 40754e1..50daedc 100644
--- a/src/dbus-common.c
+++ b/src/dbus-common.c
@@ -259,7 +259,7 @@ DBusHandlerResult bus_default_message_handler(
DBusMessage *message,
const char *introspection,
const char *interfaces,
- const BusProperty *properties) {
+ const BusBoundProperties *bound_properties) {
DBusError error;
DBusMessage *reply = NULL;
@@ -278,9 +278,12 @@ DBusHandlerResult bus_default_message_handler(
if (!dbus_message_append_args(reply, DBUS_TYPE_STRING, &introspection, DBUS_TYPE_INVALID))
goto oom;
- } else if (dbus_message_is_method_call(message, "org.freedesktop.DBus.Properties", "Get") && properties) {
+ } else if (dbus_message_is_method_call(message, "org.freedesktop.DBus.Properties", "Get") && bound_properties) {
const char *interface, *property;
+ const BusBoundProperties *bp;
const BusProperty *p;
+ void *data;
+ DBusMessageIter iter, sub;
if (!dbus_message_get_args(
message,
@@ -290,43 +293,51 @@ DBusHandlerResult bus_default_message_handler(
DBUS_TYPE_INVALID))
return bus_send_error_reply(c, message, &error, -EINVAL);
- for (p = properties; p->property; p++)
- if (streq(p->interface, interface) && streq(p->property, property))
- break;
+ for (bp = bound_properties; bp->interface; bp++) {
+ if (!streq(bp->interface, interface))
+ continue;
- if (p->property) {
- DBusMessageIter iter, sub;
+ for (p = bp->properties; p->property; p++)
+ if (streq(p->property, property))
+ goto get_prop;
+ }
- if (!(reply = dbus_message_new_method_return(message)))
- goto oom;
+ /* no match */
+ if (!nulstr_contains(interfaces, interface))
+ dbus_set_error_const(&error, DBUS_ERROR_UNKNOWN_INTERFACE, "Unknown interface");
+ else
+ dbus_set_error_const(&error, DBUS_ERROR_UNKNOWN_PROPERTY, "Unknown property");
- dbus_message_iter_init_append(reply, &iter);
+ return bus_send_error_reply(c, message, &error, -EINVAL);
- if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT, p->signature, &sub))
- goto oom;
-
- if ((r = p->append(&sub, property, (void*) p->data)) < 0) {
+get_prop:
+ reply = dbus_message_new_method_return(message);
+ if (!reply)
+ goto oom;
- if (r == -ENOMEM)
- goto oom;
+ dbus_message_iter_init_append(reply, &iter);
- dbus_message_unref(reply);
- return bus_send_error_reply(c, message, NULL, r);
- }
+ if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT, p->signature, &sub))
+ goto oom;
- if (!dbus_message_iter_close_container(&iter, &sub))
+ data = (char*)bp->base + p->offset;
+ if (p->indirect)
+ data = *(void**)data;
+ r = p->append(&sub, property, data);
+ if (r < 0) {
+ if (r == -ENOMEM)
goto oom;
- } else {
- if (!nulstr_contains(interfaces, interface))
- dbus_set_error_const(&error, DBUS_ERROR_UNKNOWN_INTERFACE, "Unknown interface");
- else
- dbus_set_error_const(&error, DBUS_ERROR_UNKNOWN_PROPERTY, "Unknown property");
- return bus_send_error_reply(c, message, &error, -EINVAL);
+ dbus_message_unref(reply);
+ return bus_send_error_reply(c, message, NULL, r);
}
- } else if (dbus_message_is_method_call(message, "org.freedesktop.DBus.Properties", "GetAll") && properties) {
+ if (!dbus_message_iter_close_container(&iter, &sub))
+ goto oom;
+
+ } else if (dbus_message_is_method_call(message, "org.freedesktop.DBus.Properties", "GetAll") && bound_properties) {
const char *interface;
+ const BusBoundProperties *bp;
const BusProperty *p;
DBusMessageIter iter, sub, sub2, sub3;
@@ -350,36 +361,46 @@ DBusHandlerResult bus_default_message_handler(
if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "{sv}", &sub))
goto oom;
- for (p = properties; p->property; p++) {
- if (interface[0] && !streq(p->interface, interface))
+ for (bp = bound_properties; bp->interface; bp++) {
+ if (interface[0] && !streq(bp->interface, interface))
continue;
- if (!dbus_message_iter_open_container(&sub, DBUS_TYPE_DICT_ENTRY, NULL, &sub2) ||
- !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &p->property) ||
- !dbus_message_iter_open_container(&sub2, DBUS_TYPE_VARIANT, p->signature, &sub3))
- goto oom;
+ for (p = bp->properties; p->property; p++) {
+ void *data;
- if ((r = p->append(&sub3, p->property, (void*) p->data)) < 0) {
-
- if (r == -ENOMEM)
+ if (!dbus_message_iter_open_container(&sub, DBUS_TYPE_DICT_ENTRY, NULL, &sub2) ||
+ !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &p->property) ||
+ !dbus_message_iter_open_container(&sub2, DBUS_TYPE_VARIANT, p->signature, &sub3))
goto oom;
- dbus_message_unref(reply);
- return bus_send_error_reply(c, message, NULL, r);
- }
+ data = (char*)bp->base + p->offset;
+ if (p->indirect)
+ data = *(void**)data;
+ r = p->append(&sub3, p->property, data);
+ if (r < 0) {
+ if (r == -ENOMEM)
+ goto oom;
- if (!dbus_message_iter_close_container(&sub2, &sub3) ||
- !dbus_message_iter_close_container(&sub, &sub2))
- goto oom;
+ dbus_message_unref(reply);
+ return bus_send_error_reply(c, message, NULL, r);
+ }
+
+ if (!dbus_message_iter_close_container(&sub2, &sub3) ||
+ !dbus_message_iter_close_container(&sub, &sub2))
+ goto oom;
+ }
}
if (!dbus_message_iter_close_container(&iter, &sub))
goto oom;
- } else if (dbus_message_is_method_call(message, "org.freedesktop.DBus.Properties", "Set") && properties) {
+ } else if (dbus_message_is_method_call(message, "org.freedesktop.DBus.Properties", "Set") && bound_properties) {
const char *interface, *property;
DBusMessageIter iter;
+ const BusBoundProperties *bp;
const BusProperty *p;
+ DBusMessageIter sub;
+ char *sig;
if (!dbus_message_iter_init(message, &iter) ||
dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
@@ -398,45 +419,52 @@ DBusHandlerResult bus_default_message_handler(
dbus_message_iter_has_next(&iter))
return bus_send_error_reply(c, message, NULL, -EINVAL);
- for (p = properties; p->property; p++)
- if (streq(p->interface, interface) && streq(p->property, property))
- break;
+ for (bp = bound_properties; bp->interface; bp++) {
+ if (!streq(bp->interface, interface))
+ continue;
- if (p->set) {
- DBusMessageIter sub;
- char *sig;
+ for (p = bp->properties; p->property; p++)
+ if (streq(p->property, property))
+ goto set_prop;
+ }
- dbus_message_iter_recurse(&iter, &sub);
+ /* no match */
+ if (!nulstr_contains(interfaces, interface))
+ dbus_set_error_const(&error, DBUS_ERROR_UNKNOWN_INTERFACE, "Unknown interface");
+ else
+ dbus_set_error_const(&error, DBUS_ERROR_UNKNOWN_PROPERTY, "Unknown property");
- if (!(sig = dbus_message_iter_get_signature(&sub)))
- goto oom;
+ return bus_send_error_reply(c, message, &error, -EINVAL);
- if (!streq(sig, p->signature)) {
- dbus_free(sig);
- return bus_send_error_reply(c, message, NULL, -EINVAL);
- }
+set_prop:
+ if (!p->set) {
+ dbus_set_error_const(&error, DBUS_ERROR_PROPERTY_READ_ONLY, "Property read-only");
+ return bus_send_error_reply(c, message, &error, -EINVAL);
+ }
+ dbus_message_iter_recurse(&iter, &sub);
+
+ sig = dbus_message_iter_get_signature(&sub);
+ if (!sig)
+ goto oom;
+
+ if (!streq(sig, p->signature)) {
dbus_free(sig);
+ return bus_send_error_reply(c, message, NULL, -EINVAL);
+ }
- if ((r = p->set(&sub, property)) < 0) {
- if (r == -ENOMEM)
- goto oom;
- return bus_send_error_reply(c, message, NULL, r);
- }
+ dbus_free(sig);
- if (!(reply = dbus_message_new_method_return(message)))
+ r = p->set(&sub, property);
+ if (r < 0) {
+ if (r == -ENOMEM)
goto oom;
- } else {
- if (p->property)
- dbus_set_error_const(&error, DBUS_ERROR_PROPERTY_READ_ONLY, "Property read-only");
- else if (!nulstr_contains(interfaces, interface))
- dbus_set_error_const(&error, DBUS_ERROR_UNKNOWN_INTERFACE, "Unknown interface");
- else
- dbus_set_error_const(&error, DBUS_ERROR_UNKNOWN_PROPERTY, "Unknown property");
-
- return bus_send_error_reply(c, message, &error, -EINVAL);
+ return bus_send_error_reply(c, message, NULL, r);
}
+ reply = dbus_message_new_method_return(message);
+ if (!reply)
+ goto oom;
} else {
const char *interface = dbus_message_get_interface(message);
diff --git a/src/dbus-common.h b/src/dbus-common.h
index acd9208..c3499b9 100644
--- a/src/dbus-common.h
+++ b/src/dbus-common.h
@@ -96,14 +96,22 @@ typedef int (*BusPropertyCallback)(DBusMessageIter *iter, const char *property,
typedef int (*BusPropertySetCallback)(DBusMessageIter *iter, const char *property);
typedef struct BusProperty {
- const char *interface; /* interface of the property */
const char *property; /* name of the property */
BusPropertyCallback append; /* Function that is called to serialize this property */
const char *signature;
- const void *data; /* The data of this property */
+ const uint16_t offset; /* Offset from BusBoundProperties::base address to the property data.
+ * uint16_t is sufficient, because we have no structs too big.
+ * -Werror=overflow will catch it if this does not hold. */
+ bool indirect; /* data is indirect, ie. not base+offset, but *(base+offset) */
BusPropertySetCallback set; /* Optional: Function that is called to set this property */
} BusProperty;
+typedef struct BusBoundProperties {
+ const char *interface; /* interface of the properties */
+ const BusProperty *properties; /* array of properties, ended by a NULL-filled element */
+ const void *const base; /* base pointer to which the offset must be added to reach data */
+} BusBoundProperties;
+
DBusHandlerResult bus_send_error_reply(
DBusConnection *c,
DBusMessage *message,
@@ -115,7 +123,7 @@ DBusHandlerResult bus_default_message_handler(
DBusMessage *message,
const char *introspection,
const char *interfaces,
- const BusProperty *properties);
+ const BusBoundProperties *bound_properties);
int bus_property_append_string(DBusMessageIter *i, const char *property, void *data);
int bus_property_append_strv(DBusMessageIter *i, const char *property, void *data);
diff --git a/src/dbus-device.c b/src/dbus-device.c
index dd5d0e9..b39fb9d 100644
--- a/src/dbus-device.c
+++ b/src/dbus-device.c
@@ -47,13 +47,19 @@ const char bus_device_interface[] _introspect_("Device") = BUS_DEVICE_INTERFACE;
const char bus_device_invalidating_properties[] =
"SysFSPath\0";
+static const BusProperty bus_device_properties[] = {
+ { "SysFSPath", bus_property_append_string, "s", offsetof(Device, sysfs), true },
+ { NULL, }
+};
+
+
DBusHandlerResult bus_device_message_handler(Unit *u, DBusConnection *c, DBusMessage *message) {
Device *d = DEVICE(u);
- const BusProperty properties[] = {
- BUS_UNIT_PROPERTIES,
- { "org.freedesktop.systemd1.Device", "SysFSPath", bus_property_append_string, "s", d->sysfs },
- { NULL, NULL, NULL, NULL, NULL }
+ const BusBoundProperties bps[] = {
+ { "org.freedesktop.systemd1.Unit", bus_unit_properties, u },
+ { "org.freedesktop.systemd1.Device", bus_device_properties, d },
+ { NULL, }
};
- return bus_default_message_handler(c, message, INTROSPECTION, INTERFACES_LIST, properties);
+ return bus_default_message_handler(c, message, INTROSPECTION, INTERFACES_LIST, bps);
}
diff --git a/src/dbus-execute.c b/src/dbus-execute.c
index 201f6b5..caeaf77 100644
--- a/src/dbus-execute.c
+++ b/src/dbus-execute.c
@@ -355,3 +355,66 @@ int bus_execute_append_command(DBusMessageIter *i, const char *property, void *d
return 0;
}
+
+const BusProperty bus_exec_context_properties[] = {
+ { "Environment", bus_property_append_strv, "as", offsetof(ExecContext, environment), true },
+ { "EnvironmentFiles", bus_execute_append_env_files, "a(sb)", offsetof(ExecContext, environment_files), true },
+ { "UMask", bus_property_append_mode, "u", offsetof(ExecContext, umask) },
+ { "LimitCPU", bus_execute_append_rlimits, "t", 0 },
+ { "LimitFSIZE", bus_execute_append_rlimits, "t", 0 },
+ { "LimitDATA", bus_execute_append_rlimits, "t", 0 },
+ { "LimitSTACK", bus_execute_append_rlimits, "t", 0 },
+ { "LimitCORE", bus_execute_append_rlimits, "t", 0 },
+ { "LimitRSS", bus_execute_append_rlimits, "t", 0 },
+ { "LimitNOFILE", bus_execute_append_rlimits, "t", 0 },
+ { "LimitAS", bus_execute_append_rlimits, "t", 0 },
+ { "LimitNPROC", bus_execute_append_rlimits, "t", 0 },
+ { "LimitMEMLOCK", bus_execute_append_rlimits, "t", 0 },
+ { "LimitLOCKS", bus_execute_append_rlimits, "t", 0 },
+ { "LimitSIGPENDING", bus_execute_append_rlimits, "t", 0 },
+ { "LimitMSGQUEUE", bus_execute_append_rlimits, "t", 0 },
+ { "LimitNICE", bus_execute_append_rlimits, "t", 0 },
+ { "LimitRTPRIO", bus_execute_append_rlimits, "t", 0 },
+ { "LimitRTTIME", bus_execute_append_rlimits, "t", 0 },
+ { "WorkingDirectory", bus_property_append_string, "s", offsetof(ExecContext, working_directory), true },
+ { "RootDirectory", bus_property_append_string, "s", offsetof(ExecContext, root_directory), true },
+ { "OOMScoreAdjust", bus_execute_append_oom_score_adjust, "i", 0 },
+ { "Nice", bus_execute_append_nice, "i", 0 },
+ { "IOScheduling", bus_execute_append_ioprio, "i", 0 },
+ { "CPUSchedulingPolicy", bus_execute_append_cpu_sched_policy, "i", 0 },
+ { "CPUSchedulingPriority", bus_execute_append_cpu_sched_priority, "i", 0 },
+ { "CPUAffinity", bus_execute_append_affinity, "ay", 0 },
+ { "TimerSlackNSec", bus_execute_append_timer_slack_nsec, "t", 0 },
+ { "CPUSchedulingResetOnFork", bus_property_append_bool, "b", offsetof(ExecContext, cpu_sched_reset_on_fork) },
+ { "NonBlocking", bus_property_append_bool, "b", offsetof(ExecContext, non_blocking) },
+ { "StandardInput", bus_execute_append_input, "s", offsetof(ExecContext, std_input) },
+ { "StandardOutput", bus_execute_append_output, "s", offsetof(ExecContext, std_output) },
+ { "StandardError", bus_execute_append_output, "s", offsetof(ExecContext, std_error) },
+ { "TTYPath", bus_property_append_string, "s", offsetof(ExecContext, tty_path), true },
+ { "TTYReset", bus_property_append_bool, "b", offsetof(ExecContext, tty_reset) },
+ { "TTYVHangup", bus_property_append_bool, "b", offsetof(ExecContext, tty_vhangup) },
+ { "TTYVTDisallocate", bus_property_append_bool, "b", offsetof(ExecContext, tty_vt_disallocate) },
+ { "SyslogPriority", bus_property_append_int, "i", offsetof(ExecContext, syslog_priority) },
+ { "SyslogIdentifier", bus_property_append_string, "s", offsetof(ExecContext, syslog_identifier), true },
+ { "SyslogLevelPrefix", bus_property_append_bool, "b", offsetof(ExecContext, syslog_level_prefix) },
+ { "Capabilities", bus_execute_append_capabilities, "s", 0 },
+ { "SecureBits", bus_property_append_int, "i", offsetof(ExecContext, secure_bits) },
+ { "CapabilityBoundingSet", bus_execute_append_capability_bs, "t", offsetof(ExecContext, capability_bounding_set_drop) },
+ { "User", bus_property_append_string, "s", offsetof(ExecContext, user), true },
+ { "Group", bus_property_append_string, "s", offsetof(ExecContext, group), true },
+ { "SupplementaryGroups", bus_property_append_strv, "as", offsetof(ExecContext, supplementary_groups), true },
+ { "TCPWrapName", bus_property_append_string, "s", offsetof(ExecContext, tcpwrap_name), true },
+ { "PAMName", bus_property_append_string, "s", offsetof(ExecContext, pam_name), true },
+ { "ReadWriteDirectories", bus_property_append_strv, "as", offsetof(ExecContext, read_write_dirs), true },
+ { "ReadOnlyDirectories", bus_property_append_strv, "as", offsetof(ExecContext, read_only_dirs), true },
+ { "InaccessibleDirectories", bus_property_append_strv, "as", offsetof(ExecContext, inaccessible_dirs), true },
+ { "MountFlags", bus_property_append_ul, "t", offsetof(ExecContext, mount_flags) },
+ { "PrivateTmp", bus_property_append_bool, "b", offsetof(ExecContext, private_tmp) },
+ { "PrivateNetwork", bus_property_append_bool, "b", offsetof(ExecContext, private_network) },
+ { "SameProcessGroup", bus_property_append_bool, "b", offsetof(ExecContext, same_pgrp) },
+ { "KillMode", bus_execute_append_kill_mode, "s", offsetof(ExecContext, kill_mode) },
+ { "KillSignal", bus_property_append_int, "i", offsetof(ExecContext, kill_signal) },
+ { "UtmpIdentifier", bus_property_append_string, "s", offsetof(ExecContext, utmp_id), true },
+ { "ControlGroupModify", bus_property_append_bool, "b", offsetof(ExecContext, control_group_modify) },
+ { NULL, }
+};
diff --git a/src/dbus-execute.h b/src/dbus-execute.h
index 2e30679..4626acb 100644
--- a/src/dbus-execute.h
+++ b/src/dbus-execute.h
@@ -25,6 +25,7 @@
#include <dbus/dbus.h>
#include "manager.h"
+#include "dbus-common.h"
#define BUS_EXEC_STATUS_INTERFACE(prefix) \
" <property name=\"" prefix "StartTimestamp\" type=\"t\" access=\"read\"/>\n" \
@@ -98,78 +99,10 @@
#define BUS_EXEC_COMMAND_INTERFACE(name) \
" <property name=\"" name "\" type=\"a(sasbttuii)\" access=\"read\"/>\n"
-#define BUS_EXEC_CONTEXT_PROPERTIES(interface, context) \
- { interface, "Environment", bus_property_append_strv, "as", (context).environment }, \
- { interface, "EnvironmentFiles", bus_execute_append_env_files, "a(sb)", (context).environment_files }, \
- { interface, "UMask", bus_property_append_mode, "u", &(context).umask }, \
- { interface, "LimitCPU", bus_execute_append_rlimits, "t", &(context) }, \
- { interface, "LimitFSIZE", bus_execute_append_rlimits, "t", &(context) }, \
- { interface, "LimitDATA", bus_execute_append_rlimits, "t", &(context) }, \
- { interface, "LimitSTACK", bus_execute_append_rlimits, "t", &(context) }, \
- { interface, "LimitCORE", bus_execute_append_rlimits, "t", &(context) }, \
- { interface, "LimitRSS", bus_execute_append_rlimits, "t", &(context) }, \
- { interface, "LimitNOFILE", bus_execute_append_rlimits, "t", &(context) }, \
- { interface, "LimitAS", bus_execute_append_rlimits, "t", &(context) }, \
- { interface, "LimitNPROC", bus_execute_append_rlimits, "t", &(context) }, \
- { interface, "LimitMEMLOCK", bus_execute_append_rlimits, "t", &(context) }, \
- { interface, "LimitLOCKS", bus_execute_append_rlimits, "t", &(context) }, \
- { interface, "LimitSIGPENDING", bus_execute_append_rlimits, "t", &(context) }, \
- { interface, "LimitMSGQUEUE", bus_execute_append_rlimits, "t", &(context) }, \
- { interface, "LimitNICE", bus_execute_append_rlimits, "t", &(context) }, \
- { interface, "LimitRTPRIO", bus_execute_append_rlimits, "t", &(context) }, \
- { interface, "LimitRTTIME", bus_execute_append_rlimits, "t", &(context) }, \
- { interface, "WorkingDirectory", bus_property_append_string, "s", (context).working_directory }, \
- { interface, "RootDirectory", bus_property_append_string, "s", (context).root_directory }, \
- { interface, "OOMScoreAdjust", bus_execute_append_oom_score_adjust, "i", &(context) }, \
- { interface, "Nice", bus_execute_append_nice, "i", &(context) }, \
- { interface, "IOScheduling", bus_execute_append_ioprio, "i", &(context) }, \
- { interface, "CPUSchedulingPolicy", bus_execute_append_cpu_sched_policy, "i", &(context) }, \
- { interface, "CPUSchedulingPriority", bus_execute_append_cpu_sched_priority, "i", &(context) }, \
- { interface, "CPUAffinity", bus_execute_append_affinity,"ay", &(context) }, \
- { interface, "TimerSlackNSec", bus_execute_append_timer_slack_nsec, "t", &(context) }, \
- { 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, "TTYReset", bus_property_append_bool, "b", &(context).tty_reset }, \
- { interface, "TTYVHangup", bus_property_append_bool, "b", &(context).tty_vhangup }, \
- { interface, "TTYVTDisallocate", bus_property_append_bool, "b", &(context).tty_vt_disallocate }, \
- { interface, "SyslogPriority", bus_property_append_int, "i", &(context).syslog_priority }, \
- { interface, "SyslogIdentifier", bus_property_append_string, "s", (context).syslog_identifier }, \
- { interface, "SyslogLevelPrefix", bus_property_append_bool, "b", &(context).syslog_level_prefix }, \
- { interface, "Capabilities", bus_execute_append_capabilities, "s",&(context) }, \
- { interface, "SecureBits", bus_property_append_int, "i", &(context).secure_bits }, \
- { interface, "CapabilityBoundingSet", bus_execute_append_capability_bs, "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 }, \
- { interface, "TCPWrapName", bus_property_append_string, "s", (context).tcpwrap_name }, \
- { interface, "PAMName", bus_property_append_string, "s", (context).pam_name }, \
- { interface, "ReadWriteDirectories", bus_property_append_strv, "as", (context).read_write_dirs }, \
- { interface, "ReadOnlyDirectories", bus_property_append_strv, "as", (context).read_only_dirs }, \
- { interface, "InaccessibleDirectories", bus_property_append_strv, "as", (context).inaccessible_dirs }, \
- { interface, "MountFlags", bus_property_append_ul, "t", &(context).mount_flags }, \
- { interface, "PrivateTmp", bus_property_append_bool, "b", &(context).private_tmp }, \
- { interface, "PrivateNetwork", bus_property_append_bool, "b", &(context).private_network }, \
- { interface, "SameProcessGroup", bus_property_append_bool, "b", &(context).same_pgrp }, \
- { interface, "KillMode", bus_execute_append_kill_mode, "s", &(context).kill_mode }, \
- { interface, "KillSignal", bus_property_append_int, "i", &(context).kill_signal }, \
- { interface, "UtmpIdentifier", bus_property_append_string, "s", (context).utmp_id }, \
- { interface, "ControlGroupModify", bus_property_append_bool, "b", &(context).control_group_modify }
+extern const BusProperty bus_exec_context_properties[];
-#define BUS_EXEC_STATUS_PROPERTIES(interface, estatus, prefix) \
- { interface, prefix "StartTimestamp", bus_property_append_usec, "t", &(estatus).start_timestamp.realtime }, \
- { interface, prefix "StartTimestampMonotonic",bus_property_append_usec, "t", &(estatus).start_timestamp.monotonic }, \
- { interface, prefix "ExitTimestamp", bus_property_append_usec, "t", &(estatus).start_timestamp.realtime }, \
- { interface, prefix "ExitTimestampMonotonic", bus_property_append_usec, "t", &(estatus).start_timestamp.monotonic }, \
- { interface, prefix "PID", bus_property_append_pid, "u", &(estatus).pid }, \
- { interface, prefix "Code", bus_property_append_int, "i", &(estatus).code }, \
- { interface, prefix "Status", bus_property_append_int, "i", &(estatus).status }
-
-#define BUS_EXEC_COMMAND_PROPERTY(interface, command, name) \
- { interface, name, bus_execute_append_command, "a(sasbttttuii)", (command) }
+#define BUS_EXEC_COMMAND_PROPERTY(name, command, indirect) \
+ { name, bus_execute_append_command, "a(sasbttttuii)", (command), (indirect), NULL }
int bus_execute_append_output(DBusMessageIter *i, const char *property, void *data);
int bus_execute_append_input(DBusMessageIter *i, const char *property, void *data);
diff --git a/src/dbus-job.c b/src/dbus-job.c
index 82a23a8..ab6d610 100644
--- a/src/dbus-job.c
+++ b/src/dbus-job.c
@@ -85,15 +85,15 @@ static int bus_job_append_unit(DBusMessageIter *i, const char *property, void *d
return 0;
}
-static DBusHandlerResult bus_job_message_dispatch(Job *j, DBusConnection *connection, DBusMessage *message) {
- const BusProperty properties[] = {
- { "org.freedesktop.systemd1.Job", "Id", bus_property_append_uint32, "u", &j->id },
- { "org.freedesktop.systemd1.Job", "State", bus_job_append_state, "s", &j->state },
- { "org.freedesktop.systemd1.Job", "JobType", bus_job_append_type, "s", &j->type },
- { "org.freedesktop.systemd1.Job", "Unit", bus_job_append_unit, "(so)", j },
- { NULL, NULL, NULL, NULL, NULL }
- };
+static const BusProperty bus_job_properties[] = {
+ { "Id", bus_property_append_uint32, "u", offsetof(Job, id) },
+ { "State", bus_job_append_state, "s", offsetof(Job, state) },
+ { "JobType", bus_job_append_type, "s", offsetof(Job, type) },
+ { "Unit", bus_job_append_unit, "(so)", 0 },
+ { NULL, }
+};
+static DBusHandlerResult bus_job_message_dispatch(Job *j, DBusConnection *connection, DBusMessage *message) {
DBusMessage *reply = NULL;
if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Job", "Cancel")) {
@@ -102,8 +102,13 @@ static DBusHandlerResult bus_job_message_dispatch(Job *j, DBusConnection *connec
job_finish_and_invalidate(j, JOB_CANCELED);
- } else
- return bus_default_message_handler(connection, message, INTROSPECTION, INTERFACES_LIST, properties);
+ } else {
+ const BusBoundProperties bps[] = {
+ { "org.freedesktop.systemd1.Job", bus_job_properties, j },
+ { NULL, }
+ };
+ return bus_default_message_handler(connection, message, INTROSPECTION, INTERFACES_LIST, bps);
+ }
if (reply) {
if (!dbus_connection_send(connection, reply, NULL))
diff --git a/src/dbus-manager.c b/src/dbus-manager.c
index 710cbcb..6d272cb 100644
--- a/src/dbus-manager.c
+++ b/src/dbus-manager.c
@@ -491,46 +491,52 @@ static int bus_manager_send_unit_files_changed(Manager *m) {
return r;
}
-static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection, DBusMessage *message, void *data) {
- Manager *m = data;
+static const char systemd_property_string[] = PACKAGE_STRING "\0" DISTRIBUTION "\0" SYSTEMD_FEATURES;
- const BusProperty properties[] = {
- { "org.freedesktop.systemd1.Manager", "Version", bus_property_append_string, "s", PACKAGE_STRING },
- { "org.freedesktop.systemd1.Manager", "Distribution", bus_property_append_string, "s", DISTRIBUTION },
- { "org.freedesktop.systemd1.Manager", "Features", bus_property_append_string, "s", SYSTEMD_FEATURES },
- { "org.freedesktop.systemd1.Manager", "RunningAs", bus_manager_append_running_as, "s", &m->running_as },
- { "org.freedesktop.systemd1.Manager", "Tainted", bus_manager_append_tainted, "s", m },
- { "org.freedesktop.systemd1.Manager", "InitRDTimestamp", bus_property_append_uint64, "t", &m->initrd_timestamp.realtime },
- { "org.freedesktop.systemd1.Manager", "InitRDTimestampMonotonic", bus_property_append_uint64, "t", &m->initrd_timestamp.monotonic },
- { "org.freedesktop.systemd1.Manager", "StartupTimestamp", bus_property_append_uint64, "t", &m->startup_timestamp.realtime },
- { "org.freedesktop.systemd1.Manager", "StartupTimestampMonotonic", bus_property_append_uint64, "t", &m->startup_timestamp.monotonic },
- { "org.freedesktop.systemd1.Manager", "FinishTimestamp", bus_property_append_uint64, "t", &m->finish_timestamp.realtime },
- { "org.freedesktop.systemd1.Manager", "FinishTimestampMonotonic", bus_property_append_uint64, "t",&m->finish_timestamp.monotonic },
- { "org.freedesktop.systemd1.Manager", "LogLevel", bus_manager_append_log_level, "s", m, bus_manager_set_log_level },
- { "org.freedesktop.systemd1.Manager", "LogTarget", bus_manager_append_log_target, "s", m, bus_manager_set_log_target },
- { "org.freedesktop.systemd1.Manager", "NNames", bus_manager_append_n_names, "u", m },
- { "org.freedesktop.systemd1.Manager", "NJobs", bus_manager_append_n_jobs, "u", m },
- { "org.freedesktop.systemd1.Manager", "NInstalledJobs",bus_property_append_uint32, "u", &m->n_installed_jobs },
- { "org.freedesktop.systemd1.Manager", "NFailedJobs", bus_property_append_uint32, "u", &m->n_failed_jobs },
- { "org.freedesktop.systemd1.Manager", "Progress", bus_manager_append_progress, "d", m },
- { "org.freedesktop.systemd1.Manager", "Environment", bus_property_append_strv, "as", m->environment },
- { "org.freedesktop.systemd1.Manager", "ConfirmSpawn", bus_property_append_bool, "b", &m->confirm_spawn },
- { "org.freedesktop.systemd1.Manager", "ShowStatus", bus_property_append_bool, "b", &m->show_status },
- { "org.freedesktop.systemd1.Manager", "UnitPath", bus_property_append_strv, "as", m->lookup_paths.unit_path },
- { "org.freedesktop.systemd1.Manager", "NotifySocket", bus_property_append_string, "s", m->notify_socket },
- { "org.freedesktop.systemd1.Manager", "ControlGroupHierarchy", bus_property_append_string, "s", m->cgroup_hierarchy },
- { "org.freedesktop.systemd1.Manager", "MountAuto", bus_property_append_bool, "b", &m->mount_auto },
- { "org.freedesktop.systemd1.Manager", "SwapAuto", bus_property_append_bool, "b", &m->swap_auto },
- { "org.freedesktop.systemd1.Manager", "DefaultControllers", bus_property_append_strv, "as", m->default_controllers },
- { "org.freedesktop.systemd1.Manager", "DefaultStandardOutput", bus_manager_append_exec_output, "s", &m->default_std_output },
- { "org.freedesktop.systemd1.Manager", "DefaultStandardError", bus_manager_append_exec_output, "s", &m->default_std_error },
+static const BusProperty bus_systemd_properties[] = {
+ { "Version", bus_property_append_string, "s", 0 },
+ { "Distribution", bus_property_append_string, "s", sizeof(PACKAGE_STRING) },
+ { "Features", bus_property_append_string, "s", sizeof(PACKAGE_STRING) + sizeof(DISTRIBUTION) },
+ { NULL, }
+};
+
+static const BusProperty bus_manager_properties[] = {
+ { "RunningAs", bus_manager_append_running_as, "s", offsetof(Manager, running_as) },
+ { "Tainted", bus_manager_append_tainted, "s", 0 },
+ { "InitRDTimestamp", bus_property_append_uint64, "t", offsetof(Manager, initrd_timestamp.realtime) },
+ { "InitRDTimestampMonotonic", bus_property_append_uint64, "t", offsetof(Manager, initrd_timestamp.monotonic) },
+ { "StartupTimestamp", bus_property_append_uint64, "t", offsetof(Manager, startup_timestamp.realtime) },
+ { "StartupTimestampMonotonic", bus_property_append_uint64, "t", offsetof(Manager, startup_timestamp.monotonic) },
+ { "FinishTimestamp", bus_property_append_uint64, "t", offsetof(Manager, finish_timestamp.realtime) },
+ { "FinishTimestampMonotonic", bus_property_append_uint64, "t", offsetof(Manager, finish_timestamp.monotonic) },
+ { "LogLevel", bus_manager_append_log_level, "s", 0, 0, bus_manager_set_log_level },
+ { "LogTarget", bus_manager_append_log_target, "s", 0, 0, bus_manager_set_log_target },
+ { "NNames", bus_manager_append_n_names, "u", 0 },
+ { "NJobs", bus_manager_append_n_jobs, "u", 0 },
+ { "NInstalledJobs",bus_property_append_uint32, "u", offsetof(Manager, n_installed_jobs) },
+ { "NFailedJobs", bus_property_append_uint32, "u", offsetof(Manager, n_failed_jobs) },
+ { "Progress", bus_manager_append_progress, "d", 0 },
+ { "Environment", bus_property_append_strv, "as", offsetof(Manager, environment), true },
+ { "ConfirmSpawn", bus_property_append_bool, "b", offsetof(Manager, confirm_spawn) },
+ { "ShowStatus", bus_property_append_bool, "b", offsetof(Manager, show_status) },
+ { "UnitPath", bus_property_append_strv, "as", offsetof(Manager, lookup_paths.unit_path), true },
+ { "NotifySocket", bus_property_append_string, "s", offsetof(Manager, notify_socket), true },
+ { "ControlGroupHierarchy", bus_property_append_string, "s", offsetof(Manager, cgroup_hierarchy), true },
+ { "MountAuto", bus_property_append_bool, "b", offsetof(Manager, mount_auto) },
+ { "SwapAuto", bus_property_append_bool, "b", offsetof(Manager, swap_auto) },
+ { "DefaultControllers", bus_property_append_strv, "as", offsetof(Manager, default_controllers), true },
+ { "DefaultStandardOutput", bus_manager_append_exec_output, "s", offsetof(Manager, default_std_output) },
+ { "DefaultStandardError", bus_manager_append_exec_output, "s", offsetof(Manager, default_std_error) },
#ifdef HAVE_SYSV_COMPAT
- { "org.freedesktop.systemd1.Manager", "SysVConsole", bus_property_append_bool, "b", &m->sysv_console },
- { "org.freedesktop.systemd1.Manager", "SysVInitPath", bus_property_append_strv, "as", m->lookup_paths.sysvinit_path },
- { "org.freedesktop.systemd1.Manager", "SysVRcndPath", bus_property_append_strv, "as", m->lookup_paths.sysvrcnd_path },
+ { "SysVConsole", bus_property_append_bool, "b", offsetof(Manager, sysv_console) },
+ { "SysVInitPath", bus_property_append_strv, "as", offsetof(Manager, lookup_paths.sysvinit_path), true },
+ { "SysVRcndPath", bus_property_append_strv, "as", offsetof(Manager, lookup_paths.sysvrcnd_path), true },
#endif
- { NULL, NULL, NULL, NULL, NULL }
- };
+ { NULL, }
+};
+
+static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection, DBusMessage *message, void *data) {
+ Manager *m = data;
int r;
DBusError error;
@@ -1416,8 +1422,14 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
if (!reply)
goto oom;
- } else
- return bus_default_message_handler(connection, message, NULL, INTERFACES_LIST, properties);
+ } else {
+ const BusBoundProperties bps[] = {
+ { "org.freedesktop.systemd1.Manager", bus_systemd_properties, systemd_property_string },
+ { "org.freedesktop.systemd1.Manager", bus_manager_properties, m },
+ { NULL, }
+ };
+ return bus_default_message_handler(connection, message, NULL, INTERFACES_LIST, bps);
+ }
if (job_type != _JOB_TYPE_INVALID) {
const char *name, *smode, *old_name = NULL;
diff --git a/src/dbus-mount.c b/src/dbus-mount.c
index 60f1e92..17d29d6 100644
--- a/src/dbus-mount.c
+++ b/src/dbus-mount.c
@@ -135,23 +135,29 @@ static int bus_mount_append_type(DBusMessageIter *i, const char *property, void
return 0;
}
+static const BusProperty bus_mount_properties[] = {
+ { "Where", bus_property_append_string, "s", offsetof(Mount, where), true },
+ { "What", bus_mount_append_what, "s", 0 },
+ { "Options", bus_mount_append_options, "s", 0 },
+ { "Type", bus_mount_append_type, "s", 0 },
+ { "TimeoutUSec", bus_property_append_usec, "t", offsetof(Mount, timeout_usec) },
+ BUS_EXEC_COMMAND_PROPERTY("ExecMount", offsetof(Mount, exec_command[MOUNT_EXEC_MOUNT]), false),
+ BUS_EXEC_COMMAND_PROPERTY("ExecUnmount", offsetof(Mount, exec_command[MOUNT_EXEC_UNMOUNT]), false),
+ BUS_EXEC_COMMAND_PROPERTY("ExecRemount", offsetof(Mount, exec_command[MOUNT_EXEC_REMOUNT]), false),
+ { "ControlPID", bus_property_append_pid, "u", offsetof(Mount, control_pid) },
+ { "DirectoryMode", bus_property_append_mode, "u", offsetof(Mount, directory_mode) },
+ { NULL, }
+};
+
DBusHandlerResult bus_mount_message_handler(Unit *u, DBusConnection *c, DBusMessage *message) {
Mount *m = MOUNT(u);
- const BusProperty properties[] = {
- BUS_UNIT_PROPERTIES,
- { "org.freedesktop.systemd1.Mount", "Where", bus_property_append_string, "s", m->where },
- { "org.freedesktop.systemd1.Mount", "What", bus_mount_append_what, "s", u },
- { "org.freedesktop.systemd1.Mount", "Options", bus_mount_append_options, "s", u },
- { "org.freedesktop.systemd1.Mount", "Type", bus_mount_append_type, "s", u },
- { "org.freedesktop.systemd1.Mount", "TimeoutUSec", bus_property_append_usec, "t", &m->timeout_usec },
- BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Mount", m->exec_command+MOUNT_EXEC_MOUNT, "ExecMount"),
- BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Mount", m->exec_command+MOUNT_EXEC_UNMOUNT, "ExecUnmount"),
- BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Mount", m->exec_command+MOUNT_EXEC_REMOUNT, "ExecRemount"),
- BUS_EXEC_CONTEXT_PROPERTIES("org.freedesktop.systemd1.Mount", m->exec_context),
- { "org.freedesktop.systemd1.Mount", "ControlPID", bus_property_append_pid, "u", &m->control_pid },
- { "org.freedesktop.systemd1.Mount", "DirectoryMode", bus_property_append_mode, "u", &m->directory_mode },
- { NULL, NULL, NULL, NULL, NULL }
+
+ const BusBoundProperties bps[] = {
+ { "org.freedesktop.systemd1.Unit", bus_unit_properties, u },
+ { "org.freedesktop.systemd1.Mount", bus_mount_properties, m },
+ { "org.freedesktop.systemd1.Mount", bus_exec_context_properties, &m->exec_context },
+ { NULL, }
};
- return bus_default_message_handler(c, message, INTROSPECTION, INTERFACES_LIST, properties);
+ return bus_default_message_handler(c, message, INTROSPECTION, INTERFACES_LIST, bps );
}
diff --git a/src/dbus-path.c b/src/dbus-path.c
index 53a5b42..083ba9e 100644
--- a/src/dbus-path.c
+++ b/src/dbus-path.c
@@ -92,16 +92,21 @@ static int bus_path_append_unit(DBusMessageIter *i, const char *property, void *
return dbus_message_iter_append_basic(i, DBUS_TYPE_STRING, &t) ? 0 : -ENOMEM;
}
+static const BusProperty bus_path_properties[] = {
+ { "Unit", bus_path_append_unit, "s", 0 },
+ { "Paths", bus_path_append_paths, "a(ss)", 0 },
+ { "MakeDirectory", bus_property_append_bool, "b", offsetof(Path, make_directory) },
+ { "DirectoryMode", bus_property_append_mode, "u", offsetof(Path, directory_mode) },
+ { NULL, }
+};
+
DBusHandlerResult bus_path_message_handler(Unit *u, DBusConnection *c, DBusMessage *message) {
Path *p = PATH(u);
- const BusProperty properties[] = {
- BUS_UNIT_PROPERTIES,
- { "org.freedesktop.systemd1.Path", "Unit", bus_path_append_unit, "s", u },
- { "org.freedesktop.systemd1.Path", "Paths", bus_path_append_paths, "a(ss)", u },
- { "org.freedesktop.systemd1.Path", "MakeDirectory", bus_property_append_bool, "b", &p->make_directory },
- { "org.freedesktop.systemd1.Path", "DirectoryMode", bus_property_append_mode, "u", &p->directory_mode },
- { NULL, NULL, NULL, NULL, NULL }
+ const BusBoundProperties bps[] = {
+ { "org.freedesktop.systemd1.Unit", bus_unit_properties, u },
+ { "org.freedesktop.systemd1.Path", bus_path_properties, p },
+ { NULL, }
};
- return bus_default_message_handler(c, message, INTROSPECTION, INTERFACES_LIST, properties);
+ return bus_default_message_handler(c, message, INTROSPECTION, INTERFACES_LIST, bps);
}
diff --git a/src/dbus-service.c b/src/dbus-service.c
index 2157c2b..e1f6370 100644
--- a/src/dbus-service.c
+++ b/src/dbus-service.c
@@ -94,40 +94,56 @@ static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_service_append_type, service_type, Se
static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_service_append_restart, service_restart, ServiceRestart);
static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_service_append_notify_access, notify_access, NotifyAccess);
-DBusHandlerResult bus_service_message_handler(Unit *u, DBusConnection *connection, DBusMessage *message) {
- Service *s = SERVICE(u);
- const BusProperty properties[] = {
- BUS_UNIT_PROPERTIES,
- { "org.freedesktop.systemd1.Service", "Type", bus_service_append_type, "s", &s->type },
- { "org.freedesktop.systemd1.Service", "Restart", bus_service_append_restart, "s", &s->restart },
- { "org.freedesktop.systemd1.Service", "PIDFile", bus_property_append_string, "s", s->pid_file },
- { "org.freedesktop.systemd1.Service", "NotifyAccess", bus_service_append_notify_access, "s", &s->notify_access },
- { "org.freedesktop.systemd1.Service", "RestartUSec", bus_property_append_usec, "t", &s->restart_usec },
- { "org.freedesktop.systemd1.Service", "TimeoutUSec", bus_property_append_usec, "t", &s->timeout_usec },
- BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Service", s->exec_command[SERVICE_EXEC_START_PRE], "ExecStartPre"),
- BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Service", s->exec_command[SERVICE_EXEC_START], "ExecStart"),
- BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Service", s->exec_command[SERVICE_EXEC_START_POST], "ExecStartPost"),
- BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Service", s->exec_command[SERVICE_EXEC_RELOAD], "ExecReload"),
- BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Service", s->exec_command[SERVICE_EXEC_STOP], "ExecStop"),
- BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Service", s->exec_command[SERVICE_EXEC_STOP_POST], "ExecStopPost"),
- BUS_EXEC_CONTEXT_PROPERTIES("org.freedesktop.systemd1.Service", s->exec_context),
- { "org.freedesktop.systemd1.Service", "PermissionsStartOnly", bus_property_append_bool, "b", &s->permissions_start_only },
- { "org.freedesktop.systemd1.Service", "RootDirectoryStartOnly", bus_property_append_bool, "b", &s->root_directory_start_only },
- { "org.freedesktop.systemd1.Service", "RemainAfterExit", bus_property_append_bool, "b", &s->remain_after_exit },
- { "org.freedesktop.systemd1.Service", "GuessMainPID", bus_property_append_bool, "b", &s->guess_main_pid },
- BUS_EXEC_STATUS_PROPERTIES("org.freedesktop.systemd1.Service", s->main_exec_status, "ExecMain"),
- { "org.freedesktop.systemd1.Service", "MainPID", bus_property_append_pid, "u", &s->main_pid },
- { "org.freedesktop.systemd1.Service", "ControlPID", bus_property_append_pid, "u", &s->control_pid },
- { "org.freedesktop.systemd1.Service", "BusName", bus_property_append_string, "s", s->bus_name },
- { "org.freedesktop.systemd1.Service", "StatusText", bus_property_append_string, "s", s->status_text },
+static const BusProperty bus_exec_main_status_properties[] = {
+ { "ExecMainStartTimestamp", bus_property_append_usec, "t", offsetof(ExecStatus, start_timestamp.realtime) },
+ { "ExecMainStartTimestampMonotonic",bus_property_append_usec, "t", offsetof(ExecStatus, start_timestamp.monotonic) },
+ { "ExecMainExitTimestamp", bus_property_append_usec, "t", offsetof(ExecStatus, start_timestamp.realtime) },
+ { "ExecMainExitTimestampMonotonic", bus_property_append_usec, "t", offsetof(ExecStatus, start_timestamp.monotonic) },
+ { "ExecMainPID", bus_property_append_pid, "u", offsetof(ExecStatus, pid) },
+ { "ExecMainCode", bus_property_append_int, "i", offsetof(ExecStatus, code) },
+ { "ExecMainStatus", bus_property_append_int, "i", offsetof(ExecStatus, status) },
+ { NULL, }
+};
+
+static const BusProperty bus_service_properties[] = {
+ { "Type", bus_service_append_type, "s", offsetof(Service, type) },
+ { "Restart", bus_service_append_restart, "s", offsetof(Service, restart) },
+ { "PIDFile", bus_property_append_string, "s", offsetof(Service, pid_file), true },
+ { "NotifyAccess", bus_service_append_notify_access, "s", offsetof(Service, notify_access) },
+ { "RestartUSec", bus_property_append_usec, "t", offsetof(Service, restart_usec) },
+ { "TimeoutUSec", bus_property_append_usec, "t", offsetof(Service, timeout_usec) },
+ BUS_EXEC_COMMAND_PROPERTY("ExecStartPre", offsetof(Service, exec_command[SERVICE_EXEC_START_PRE]), true ),
+ BUS_EXEC_COMMAND_PROPERTY("ExecStart", offsetof(Service, exec_command[SERVICE_EXEC_START]), true ),
+ BUS_EXEC_COMMAND_PROPERTY("ExecStartPost", offsetof(Service, exec_command[SERVICE_EXEC_START_POST]), true ),
+ BUS_EXEC_COMMAND_PROPERTY("ExecReload", offsetof(Service, exec_command[SERVICE_EXEC_RELOAD]), true ),
+ BUS_EXEC_COMMAND_PROPERTY("ExecStop", offsetof(Service, exec_command[SERVICE_EXEC_STOP]), true ),
+ BUS_EXEC_COMMAND_PROPERTY("ExecStopPost", offsetof(Service, exec_command[SERVICE_EXEC_STOP_POST]), true ),
+ { "PermissionsStartOnly", bus_property_append_bool, "b", offsetof(Service, permissions_start_only) },
+ { "RootDirectoryStartOnly", bus_property_append_bool, "b", offsetof(Service, root_directory_start_only) },
+ { "RemainAfterExit", bus_property_append_bool, "b", offsetof(Service, remain_after_exit) },
+ { "GuessMainPID", bus_property_append_bool, "b", offsetof(Service, guess_main_pid) },
+ { "MainPID", bus_property_append_pid, "u", offsetof(Service, main_pid) },
+ { "ControlPID", bus_property_append_pid, "u", offsetof(Service, control_pid) },
+ { "BusName", bus_property_append_string, "s", offsetof(Service, bus_name), true },
+ { "StatusText", bus_property_append_string, "s", offsetof(Service, status_text), true },
#ifdef HAVE_SYSV_COMPAT
- { "org.freedesktop.systemd1.Service", "SysVRunLevels", bus_property_append_string, "s", s->sysv_runlevels },
- { "org.freedesktop.systemd1.Service", "SysVStartPriority", bus_property_append_int, "i", &s->sysv_start_priority },
- { "org.freedesktop.systemd1.Service", "SysVPath", bus_property_append_string, "s", s->sysv_path },
+ { "SysVRunLevels", bus_property_append_string, "s", offsetof(Service, sysv_runlevels), true },
+ { "SysVStartPriority", bus_property_append_int, "i", offsetof(Service, sysv_start_priority) },
+ { "SysVPath", bus_property_append_string, "s", offsetof(Service, sysv_path), true },
#endif
- { "org.freedesktop.systemd1.Service", "FsckPassNo", bus_property_append_int, "i", &s->fsck_passno },
- { NULL, NULL, NULL, NULL, NULL }
+ { "FsckPassNo", bus_property_append_int, "i", offsetof(Service, fsck_passno) },
+ { NULL, }
+};
+
+DBusHandlerResult bus_service_message_handler(Unit *u, DBusConnection *connection, DBusMessage *message) {
+ Service *s = SERVICE(u);
+ const BusBoundProperties bps[] = {
+ { "org.freedesktop.systemd1.Unit", bus_unit_properties, u },
+ { "org.freedesktop.systemd1.Service", bus_service_properties, s },
+ { "org.freedesktop.systemd1.Service", bus_exec_context_properties, &s->exec_context },
+ { "org.freedesktop.systemd1.Service", bus_exec_main_status_properties, &s->main_exec_status },
+ { NULL, }
};
- return bus_default_message_handler(connection, message, INTROSPECTION, INTERFACES_LIST, properties);
+ return bus_default_message_handler(connection, message, INTROSPECTION, INTERFACES_LIST, bps);
}
diff --git a/src/dbus-snapshot.c b/src/dbus-snapshot.c
index 0967034..e69388a 100644
--- a/src/dbus-snapshot.c
+++ b/src/dbus-snapshot.c
@@ -45,13 +45,13 @@
const char bus_snapshot_interface[] _introspect_("Snapshot") = BUS_SNAPSHOT_INTERFACE;
+static const BusProperty bus_snapshot_properties[] = {
+ { "Cleanup", bus_property_append_bool, "b", offsetof(Snapshot, cleanup) },
+ { NULL, }
+};
+
DBusHandlerResult bus_snapshot_message_handler(Unit *u, DBusConnection *c, DBusMessage *message) {
Snapshot *s = SNAPSHOT(u);
- const BusProperty properties[] = {
- BUS_UNIT_PROPERTIES,
- { "org.freedesktop.systemd1.Snapshot", "Cleanup", bus_property_append_bool, "b", &s->cleanup },
- { NULL, NULL, NULL, NULL, NULL }
- };
DBusMessage *reply = NULL;
DBusError error;
@@ -65,8 +65,14 @@ DBusHandlerResult bus_snapshot_message_handler(Unit *u, DBusConnection *c, DBusM
if (!(reply = dbus_message_new_method_return(message)))
goto oom;
- } else
- return bus_default_message_handler(c, message, INTROSPECTION, INTERFACES_LIST, properties);
+ } else {
+ const BusBoundProperties bps[] = {
+ { "org.freedesktop.systemd1.Unit", bus_unit_properties, u },
+ { "org.freedesktop.systemd1.Snapshot", bus_snapshot_properties, s },
+ { NULL, }
+ };
+ return bus_default_message_handler(c, message, INTROSPECTION, INTERFACES_LIST, bps);
+ }
if (reply) {
if (!dbus_connection_send(c, reply, NULL))
diff --git a/src/dbus-socket.c b/src/dbus-socket.c
index 9caed55..995b672 100644
--- a/src/dbus-socket.c
+++ b/src/dbus-socket.c
@@ -87,42 +87,47 @@ const char bus_socket_invalidating_properties[] =
static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_socket_append_bind_ipv6_only, socket_address_bind_ipv6_only, SocketAddressBindIPv6Only);
+static const BusProperty bus_socket_properties[] = {
+ { "BindIPv6Only", bus_socket_append_bind_ipv6_only, "s", offsetof(Socket, bind_ipv6_only) },
+ { "Backlog", bus_property_append_unsigned, "u", offsetof(Socket, backlog) },
+ { "TimeoutUSec", bus_property_append_usec, "t", offsetof(Socket, timeout_usec) },
+ BUS_EXEC_COMMAND_PROPERTY("ExecStartPre", offsetof(Socket, exec_command[SOCKET_EXEC_START_PRE]), true ),
+ BUS_EXEC_COMMAND_PROPERTY("ExecStartPost", offsetof(Socket, exec_command[SOCKET_EXEC_START_POST]), true ),
+ BUS_EXEC_COMMAND_PROPERTY("ExecStopPre", offsetof(Socket, exec_command[SOCKET_EXEC_STOP_PRE]), true ),
+ BUS_EXEC_COMMAND_PROPERTY("ExecStopPost", offsetof(Socket, exec_command[SOCKET_EXEC_STOP_POST]), true ),
+ { "ControlPID", bus_property_append_pid, "u", offsetof(Socket, control_pid) },
+ { "BindToDevice", bus_property_append_string, "s", offsetof(Socket, bind_to_device), true },
+ { "DirectoryMode", bus_property_append_mode, "u", offsetof(Socket, directory_mode) },
+ { "SocketMode", bus_property_append_mode, "u", offsetof(Socket, socket_mode) },
+ { "Accept", bus_property_append_bool, "b", offsetof(Socket, accept) },
+ { "KeepAlive", bus_property_append_bool, "b", offsetof(Socket, keep_alive) },
+ { "Priority", bus_property_append_int, "i", offsetof(Socket, priority) },
+ { "ReceiveBuffer", bus_property_append_size, "t", offsetof(Socket, receive_buffer) },
+ { "SendBuffer", bus_property_append_size, "t", offsetof(Socket, send_buffer) },
+ { "IPTOS", bus_property_append_int, "i", offsetof(Socket, ip_tos) },
+ { "IPTTL", bus_property_append_int, "i", offsetof(Socket, ip_ttl) },
+ { "PipeSize", bus_property_append_size, "t", offsetof(Socket, pipe_size) },
+ { "FreeBind", bus_property_append_bool, "b", offsetof(Socket, free_bind) },
+ { "Transparent", bus_property_append_bool, "b", offsetof(Socket, transparent) },
+ { "Broadcast", bus_property_append_bool, "b", offsetof(Socket, broadcast) },
+ { "PassCredentials",bus_property_append_bool, "b", offsetof(Socket, pass_cred) },
+ { "Mark", bus_property_append_int, "i", offsetof(Socket, mark) },
+ { "MaxConnections", bus_property_append_unsigned, "u", offsetof(Socket, max_connections) },
+ { "NConnections", bus_property_append_unsigned, "u", offsetof(Socket, n_connections) },
+ { "NAccepted", bus_property_append_unsigned, "u", offsetof(Socket, n_accepted) },
+ { "MessageQueueMaxMessages", bus_property_append_long, "x", offsetof(Socket, mq_maxmsg) },
+ { "MessageQueueMessageSize", bus_property_append_long, "x", offsetof(Socket, mq_msgsize) },
+ { NULL, }
+};
+
DBusHandlerResult bus_socket_message_handler(Unit *u, DBusConnection *c, DBusMessage *message) {
Socket *s = SOCKET(u);
- const BusProperty properties[] = {
- BUS_UNIT_PROPERTIES,
- { "org.freedesktop.systemd1.Socket", "BindIPv6Only", bus_socket_append_bind_ipv6_only, "s", &s->bind_ipv6_only },
- { "org.freedesktop.systemd1.Socket", "Backlog", bus_property_append_unsigned, "u", &s->backlog },
- { "org.freedesktop.systemd1.Socket", "TimeoutUSec", bus_property_append_usec, "t", &s->timeout_usec },
- BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Socket", s->exec_command[SOCKET_EXEC_START_PRE], "ExecStartPre"),
- BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Socket", s->exec_command[SOCKET_EXEC_START_POST], "ExecStartPost"),
- BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Socket", s->exec_command[SOCKET_EXEC_STOP_PRE], "ExecStopPre"),
- BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Socket", s->exec_command[SOCKET_EXEC_STOP_POST], "ExecStopPost"),
- BUS_EXEC_CONTEXT_PROPERTIES("org.freedesktop.systemd1.Socket", s->exec_context),
- { "org.freedesktop.systemd1.Socket", "ControlPID", bus_property_append_pid, "u", &s->control_pid },
- { "org.freedesktop.systemd1.Socket", "BindToDevice", bus_property_append_string, "s", s->bind_to_device },
- { "org.freedesktop.systemd1.Socket", "DirectoryMode", bus_property_append_mode, "u", &s->directory_mode },
- { "org.freedesktop.systemd1.Socket", "SocketMode", bus_property_append_mode, "u", &s->socket_mode },
- { "org.freedesktop.systemd1.Socket", "Accept", bus_property_append_bool, "b", &s->accept },
- { "org.freedesktop.systemd1.Socket", "KeepAlive", bus_property_append_bool, "b", &s->keep_alive },
- { "org.freedesktop.systemd1.Socket", "Priority", bus_property_append_int, "i", &s->priority },
- { "org.freedesktop.systemd1.Socket", "ReceiveBuffer", bus_property_append_size, "t", &s->receive_buffer },
- { "org.freedesktop.systemd1.Socket", "SendBuffer", bus_property_append_size, "t", &s->send_buffer },
- { "org.freedesktop.systemd1.Socket", "IPTOS", bus_property_append_int, "i", &s->ip_tos },
- { "org.freedesktop.systemd1.Socket", "IPTTL", bus_property_append_int, "i", &s->ip_ttl },
- { "org.freedesktop.systemd1.Socket", "PipeSize", bus_property_append_size, "t", &s->pipe_size },
- { "org.freedesktop.systemd1.Socket", "FreeBind", bus_property_append_bool, "b", &s->free_bind },
- { "org.freedesktop.systemd1.Socket", "Transparent", bus_property_append_bool, "b", &s->transparent },
- { "org.freedesktop.systemd1.Socket", "Broadcast", bus_property_append_bool, "b", &s->broadcast },
- { "org.freedesktop.systemd1.Socket", "PassCredentials",bus_property_append_bool, "b", &s->pass_cred },
- { "org.freedesktop.systemd1.Socket", "Mark", bus_property_append_int, "i", &s->mark },
- { "org.freedesktop.systemd1.Socket", "MaxConnections", bus_property_append_unsigned, "u", &s->max_connections },
- { "org.freedesktop.systemd1.Socket", "NConnections", bus_property_append_unsigned, "u", &s->n_connections },
- { "org.freedesktop.systemd1.Socket", "NAccepted", bus_property_append_unsigned, "u", &s->n_accepted },
- { "org.freedesktop.systemd1.Socket", "MessageQueueMaxMessages", bus_property_append_long,"x", &s->mq_maxmsg },
- { "org.freedesktop.systemd1.Socket", "MessageQueueMessageSize", bus_property_append_long,"x", &s->mq_msgsize },
- { NULL, NULL, NULL, NULL, NULL }
+ const BusBoundProperties bps[] = {
+ { "org.freedesktop.systemd1.Unit", bus_unit_properties, u },
+ { "org.freedesktop.systemd1.Socket", bus_socket_properties, s },
+ { "org.freedesktop.systemd1.Socket", bus_exec_context_properties, &s->exec_context },
+ { NULL, }
};
- return bus_default_message_handler(c, message, INTROSPECTION, INTERFACES_LIST, properties);
+ return bus_default_message_handler(c, message, INTROSPECTION, INTERFACES_LIST, bps);
}
diff --git a/src/dbus-swap.c b/src/dbus-swap.c
index 3002581..5ed33b5 100644
--- a/src/dbus-swap.c
+++ b/src/dbus-swap.c
@@ -84,18 +84,23 @@ static int bus_swap_append_priority(DBusMessageIter *i, const char *property, vo
return 0;
}
+static const BusProperty bus_swap_properties[] = {
+ { "What", bus_property_append_string, "s", offsetof(Swap, what), true },
+ { "Priority", bus_swap_append_priority, "i", 0 },
+ BUS_EXEC_COMMAND_PROPERTY("ExecActivate", offsetof(Swap, exec_command[SWAP_EXEC_ACTIVATE]), false),
+ BUS_EXEC_COMMAND_PROPERTY("ExecDeactivate", offsetof(Swap, exec_command[SWAP_EXEC_DEACTIVATE]), false),
+ { "ControlPID", bus_property_append_pid, "u", offsetof(Swap, control_pid) },
+ { NULL, }
+};
+
DBusHandlerResult bus_swap_message_handler(Unit *u, DBusConnection *c, DBusMessage *message) {
Swap *s = SWAP(u);
- const BusProperty properties[] = {
- BUS_UNIT_PROPERTIES,
- { "org.freedesktop.systemd1.Swap", "What", bus_property_append_string, "s", s->what },
- { "org.freedesktop.systemd1.Swap", "Priority", bus_swap_append_priority, "i", u },
- BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Swap", s->exec_command+SWAP_EXEC_ACTIVATE, "ExecActivate"),
- BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Swap", s->exec_command+SWAP_EXEC_DEACTIVATE, "ExecDeactivate"),
- BUS_EXEC_CONTEXT_PROPERTIES("org.freedesktop.systemd1.Swap", s->exec_context),
- { "org.freedesktop.systemd1.Swap", "ControlPID", bus_property_append_pid, "u", &s->control_pid },
- { NULL, NULL, NULL, NULL, NULL }
+ const BusBoundProperties bps[] = {
+ { "org.freedesktop.systemd1.Unit", bus_unit_properties, u },
+ { "org.freedesktop.systemd1.Swap", bus_swap_properties, s },
+ { "org.freedesktop.systemd1.Swap", bus_exec_context_properties, &s->exec_context },
+ { NULL, }
};
- return bus_default_message_handler(c, message, INTROSPECTION, INTERFACES_LIST, properties);
+ return bus_default_message_handler(c, message, INTROSPECTION, INTERFACES_LIST, bps);
}
diff --git a/src/dbus-target.c b/src/dbus-target.c
index 1e00f2d..55cf862 100644
--- a/src/dbus-target.c
+++ b/src/dbus-target.c
@@ -46,10 +46,10 @@
const char bus_target_interface[] _introspect_("Target") = BUS_TARGET_INTERFACE;
DBusHandlerResult bus_target_message_handler(Unit *u, DBusConnection *c, DBusMessage *message) {
- const BusProperty properties[] = {
- BUS_UNIT_PROPERTIES,
- { NULL, NULL, NULL, NULL, NULL }
+ const BusBoundProperties bps[] = {
+ { "org.freedesktop.systemd1.Unit", bus_unit_properties, u },
+ { NULL, }
};
- return bus_default_message_handler(c, message, INTROSPECTION, INTERFACES_LIST, properties);
+ return bus_default_message_handler(c, message, INTROSPECTION, INTERFACES_LIST, bps);
}
diff --git a/src/dbus-timer.c b/src/dbus-timer.c
index 0c4b4f3..0988b3e 100644
--- a/src/dbus-timer.c
+++ b/src/dbus-timer.c
@@ -113,15 +113,20 @@ static int bus_timer_append_unit(DBusMessageIter *i, const char *property, void
return dbus_message_iter_append_basic(i, DBUS_TYPE_STRING, &t) ? 0 : -ENOMEM;
}
+static const BusProperty bus_timer_properties[] = {
+ { "Unit", bus_timer_append_unit, "s", 0 },
+ { "Timers", bus_timer_append_timers, "a(stt)", 0 },
+ { "NextElapseUSec", bus_property_append_usec, "t", offsetof(Timer, next_elapse) },
+ { NULL, }
+};
+
DBusHandlerResult bus_timer_message_handler(Unit *u, DBusConnection *c, DBusMessage *message) {
Timer *t = TIMER(u);
- const BusProperty properties[] = {
- BUS_UNIT_PROPERTIES,
- { "org.freedesktop.systemd1.Timer", "Unit", bus_timer_append_unit, "s", u },
- { "org.freedesktop.systemd1.Timer", "Timers", bus_timer_append_timers, "a(stt)", u },
- { "org.freedesktop.systemd1.Timer", "NextElapseUSec", bus_property_append_usec, "t", &t->next_elapse },
- { NULL, NULL, NULL, NULL, NULL }
+ const BusBoundProperties bps[] = {
+ { "org.freedesktop.systemd1.Unit", bus_unit_properties, u },
+ { "org.freedesktop.systemd1.Timer", bus_timer_properties, t },
+ { NULL, }
};
- return bus_default_message_handler(c, message, INTROSPECTION, INTERFACES_LIST, properties);
+ return bus_default_message_handler(c, message, INTROSPECTION, INTERFACES_LIST, bps);
}
diff --git a/src/dbus-unit.c b/src/dbus-unit.c
index dc5321e..9591c58 100644
--- a/src/dbus-unit.c
+++ b/src/dbus-unit.c
@@ -29,6 +29,68 @@
const char bus_unit_interface[] _introspect_("Unit") = BUS_UNIT_INTERFACE;
+const BusProperty bus_unit_properties[] = {
+ { "Id", bus_property_append_string, "s", offsetof(Unit, id), true },
+ { "Names", bus_unit_append_names, "as", 0 },
+ { "Following", bus_unit_append_following, "s", 0 },
+ { "Requires", bus_unit_append_dependencies, "as", offsetof(Unit, dependencies[UNIT_REQUIRES]), true },
+ { "RequiresOverridable", bus_unit_append_dependencies, "as", offsetof(Unit, dependencies[UNIT_REQUIRES_OVERRIDABLE]), true },
+ { "Requisite", bus_unit_append_dependencies, "as", offsetof(Unit, dependencies[UNIT_REQUISITE]), true },
+ { "RequisiteOverridable", bus_unit_append_dependencies, "as", offsetof(Unit, dependencies[UNIT_REQUISITE_OVERRIDABLE]), true },
+ { "Wants", bus_unit_append_dependencies, "as", offsetof(Unit, dependencies[UNIT_WANTS]), true },
+ { "BindTo", bus_unit_append_dependencies, "as", offsetof(Unit, dependencies[UNIT_BIND_TO]), true },
+ { "RequiredBy", bus_unit_append_dependencies, "as", offsetof(Unit, dependencies[UNIT_REQUIRED_BY]), true },
+ { "RequiredByOverridable",bus_unit_append_dependencies, "as", offsetof(Unit, dependencies[UNIT_REQUIRED_BY_OVERRIDABLE]), true },
+ { "WantedBy", bus_unit_append_dependencies, "as", offsetof(Unit, dependencies[UNIT_WANTED_BY]), true },
+ { "BoundBy", bus_unit_append_dependencies, "as", offsetof(Unit, dependencies[UNIT_BOUND_BY]), true },
+ { "Conflicts", bus_unit_append_dependencies, "as", offsetof(Unit, dependencies[UNIT_CONFLICTS]), true },
+ { "ConflictedBy", bus_unit_append_dependencies, "as", offsetof(Unit, dependencies[UNIT_CONFLICTED_BY]), true },
+ { "Before", bus_unit_append_dependencies, "as", offsetof(Unit, dependencies[UNIT_BEFORE]), true },
+ { "After", bus_unit_append_dependencies, "as", offsetof(Unit, dependencies[UNIT_AFTER]), true },
+ { "OnFailure", bus_unit_append_dependencies, "as", offsetof(Unit, dependencies[UNIT_ON_FAILURE]), true },
+ { "Triggers", bus_unit_append_dependencies, "as", offsetof(Unit, dependencies[UNIT_TRIGGERS]), true },
+ { "TriggeredBy", bus_unit_append_dependencies, "as", offsetof(Unit, dependencies[UNIT_TRIGGERED_BY]), true },
+ { "PropagateReloadTo", bus_unit_append_dependencies, "as", offsetof(Unit, dependencies[UNIT_PROPAGATE_RELOAD_TO]), true },
+ { "PropagateReloadFrom", bus_unit_append_dependencies, "as", offsetof(Unit, dependencies[UNIT_PROPAGATE_RELOAD_FROM]), true },
+ { "Description", bus_unit_append_description, "s", 0 },
+ { "LoadState", bus_unit_append_load_state, "s", offsetof(Unit, load_state) },
+ { "ActiveState", bus_unit_append_active_state, "s", 0 },
+ { "SubState", bus_unit_append_sub_state, "s", 0 },
+ { "FragmentPath", bus_property_append_string, "s", offsetof(Unit, fragment_path), true },
+ { "UnitFileState", bus_unit_append_file_state, "s", 0 },
+ { "InactiveExitTimestamp",bus_property_append_usec, "t", offsetof(Unit, inactive_exit_timestamp.realtime) },
+ { "InactiveExitTimestampMonotonic", bus_property_append_usec, "t", offsetof(Unit, inactive_exit_timestamp.monotonic) },
+ { "ActiveEnterTimestamp", bus_property_append_usec, "t", offsetof(Unit, active_enter_timestamp.realtime) },
+ { "ActiveEnterTimestampMonotonic", bus_property_append_usec, "t", offsetof(Unit, active_enter_timestamp.monotonic) },
+ { "ActiveExitTimestamp", bus_property_append_usec, "t", offsetof(Unit, active_exit_timestamp.realtime) },
+ { "ActiveExitTimestampMonotonic", bus_property_append_usec, "t", offsetof(Unit, active_exit_timestamp.monotonic) },
+ { "InactiveEnterTimestamp", bus_property_append_usec, "t", offsetof(Unit, inactive_enter_timestamp.realtime) },
+ { "InactiveEnterTimestampMonotonic",bus_property_append_usec, "t", offsetof(Unit, inactive_enter_timestamp.monotonic) },
+ { "CanStart", bus_unit_append_can_start, "b", 0 },
+ { "CanStop", bus_unit_append_can_stop, "b", 0 },
+ { "CanReload", bus_unit_append_can_reload, "b", 0 },
+ { "CanIsolate", bus_unit_append_can_isolate, "b", 0 },
+ { "Job", bus_unit_append_job, "(uo)", 0 },
+ { "StopWhenUnneeded", bus_property_append_bool, "b", offsetof(Unit, stop_when_unneeded) },
+ { "RefuseManualStart", bus_property_append_bool, "b", offsetof(Unit, refuse_manual_start) },
+ { "RefuseManualStop", bus_property_append_bool, "b", offsetof(Unit, refuse_manual_stop) },
+ { "AllowIsolate", bus_property_append_bool, "b", offsetof(Unit, allow_isolate) },
+ { "DefaultDependencies", bus_property_append_bool, "b", offsetof(Unit, default_dependencies) },
+ { "OnFailureIsolate", bus_property_append_bool, "b", offsetof(Unit, on_failure_isolate) },
+ { "IgnoreOnIsolate", bus_property_append_bool, "b", offsetof(Unit, ignore_on_isolate) },
+ { "IgnoreOnSnapshot", bus_property_append_bool, "b", offsetof(Unit, ignore_on_snapshot) },
+ { "DefaultControlGroup", bus_unit_append_default_cgroup, "s", 0 },
+ { "ControlGroup", bus_unit_append_cgroups, "as", 0 },
+ { "ControlGroupAttributes", bus_unit_append_cgroup_attrs,"a(sss)", 0 },
+ { "NeedDaemonReload", bus_unit_append_need_daemon_reload, "b", 0 },
+ { "JobTimeoutUSec", bus_property_append_usec, "t", offsetof(Unit, job_timeout) },
+ { "ConditionTimestamp", bus_property_append_usec, "t", offsetof(Unit, condition_timestamp.realtime) },
+ { "ConditionTimestampMonotonic", bus_property_append_usec, "t", offsetof(Unit, condition_timestamp.monotonic) },
+ { "ConditionResult", bus_property_append_bool, "b", offsetof(Unit, condition_result) },
+ { "LoadError", bus_unit_append_load_error, "(ss)", 0 },
+ { NULL, }
+};
+
#define INVALIDATING_PROPERTIES \
"LoadState\0" \
"ActiveState\0" \
diff --git a/src/dbus-unit.h b/src/dbus-unit.h
index 6476c8a..5ae9d0c 100644
--- a/src/dbus-unit.h
+++ b/src/dbus-unit.h
@@ -25,6 +25,7 @@
#include <dbus/dbus.h>
#include "manager.h"
+#include "dbus-common.h"
#define BUS_UNIT_INTERFACE \
" <interface name=\"org.freedesktop.systemd1.Unit\">\n" \
@@ -126,65 +127,7 @@
BUS_GENERIC_INTERFACES_LIST \
"org.freedesktop.systemd1.Unit\0"
-#define BUS_UNIT_PROPERTIES \
- { "org.freedesktop.systemd1.Unit", "Id", bus_property_append_string, "s", u->id }, \
- { "org.freedesktop.systemd1.Unit", "Names", bus_unit_append_names, "as", u }, \
- { "org.freedesktop.systemd1.Unit", "Following", bus_unit_append_following, "s", u }, \
- { "org.freedesktop.systemd1.Unit", "Requires", bus_unit_append_dependencies, "as", u->dependencies[UNIT_REQUIRES] }, \
- { "org.freedesktop.systemd1.Unit", "RequiresOverridable", bus_unit_append_dependencies, "as", u->dependencies[UNIT_REQUIRES_OVERRIDABLE] }, \
- { "org.freedesktop.systemd1.Unit", "Requisite", bus_unit_append_dependencies, "as", u->dependencies[UNIT_REQUISITE] }, \
- { "org.freedesktop.systemd1.Unit", "RequisiteOverridable", bus_unit_append_dependencies, "as", u->dependencies[UNIT_REQUISITE_OVERRIDABLE] }, \
- { "org.freedesktop.systemd1.Unit", "Wants", bus_unit_append_dependencies, "as", u->dependencies[UNIT_WANTS] }, \
- { "org.freedesktop.systemd1.Unit", "BindTo", bus_unit_append_dependencies, "as", u->dependencies[UNIT_BIND_TO] }, \
- { "org.freedesktop.systemd1.Unit", "RequiredBy", bus_unit_append_dependencies, "as", u->dependencies[UNIT_REQUIRED_BY] }, \
- { "org.freedesktop.systemd1.Unit", "RequiredByOverridable",bus_unit_append_dependencies, "as", u->dependencies[UNIT_REQUIRED_BY_OVERRIDABLE] }, \
- { "org.freedesktop.systemd1.Unit", "WantedBy", bus_unit_append_dependencies, "as", u->dependencies[UNIT_WANTED_BY] }, \
- { "org.freedesktop.systemd1.Unit", "BoundBy", bus_unit_append_dependencies, "as", u->dependencies[UNIT_BOUND_BY] }, \
- { "org.freedesktop.systemd1.Unit", "Conflicts", bus_unit_append_dependencies, "as", u->dependencies[UNIT_CONFLICTS] }, \
- { "org.freedesktop.systemd1.Unit", "ConflictedBy", bus_unit_append_dependencies, "as", u->dependencies[UNIT_CONFLICTED_BY] }, \
- { "org.freedesktop.systemd1.Unit", "Before", bus_unit_append_dependencies, "as", u->dependencies[UNIT_BEFORE] }, \
- { "org.freedesktop.systemd1.Unit", "After", bus_unit_append_dependencies, "as", u->dependencies[UNIT_AFTER] }, \
- { "org.freedesktop.systemd1.Unit", "OnFailure", bus_unit_append_dependencies, "as", u->dependencies[UNIT_ON_FAILURE] }, \
- { "org.freedesktop.systemd1.Unit", "Triggers", bus_unit_append_dependencies, "as", u->dependencies[UNIT_TRIGGERS] }, \
- { "org.freedesktop.systemd1.Unit", "TriggeredBy", bus_unit_append_dependencies, "as", u->dependencies[UNIT_TRIGGERED_BY] }, \
- { "org.freedesktop.systemd1.Unit", "PropagateReloadTo", bus_unit_append_dependencies, "as", u->dependencies[UNIT_PROPAGATE_RELOAD_TO] }, \
- { "org.freedesktop.systemd1.Unit", "PropagateReloadFrom", bus_unit_append_dependencies, "as", u->dependencies[UNIT_PROPAGATE_RELOAD_FROM] }, \
- { "org.freedesktop.systemd1.Unit", "Description", bus_unit_append_description, "s", u }, \
- { "org.freedesktop.systemd1.Unit", "LoadState", bus_unit_append_load_state, "s", &u->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->fragment_path }, \
- { "org.freedesktop.systemd1.Unit", "UnitFileState", bus_unit_append_file_state, "s", u }, \
- { "org.freedesktop.systemd1.Unit", "InactiveExitTimestamp",bus_property_append_usec, "t", &u->inactive_exit_timestamp.realtime }, \
- { "org.freedesktop.systemd1.Unit", "InactiveExitTimestampMonotonic",bus_property_append_usec, "t", &u->inactive_exit_timestamp.monotonic }, \
- { "org.freedesktop.systemd1.Unit", "ActiveEnterTimestamp", bus_property_append_usec, "t", &u->active_enter_timestamp.realtime }, \
- { "org.freedesktop.systemd1.Unit", "ActiveEnterTimestampMonotonic", bus_property_append_usec, "t", &u->active_enter_timestamp.monotonic }, \
- { "org.freedesktop.systemd1.Unit", "ActiveExitTimestamp", bus_property_append_usec, "t", &u->active_exit_timestamp.realtime }, \
- { "org.freedesktop.systemd1.Unit", "ActiveExitTimestampMonotonic", bus_property_append_usec, "t", &u->active_exit_timestamp.monotonic }, \
- { "org.freedesktop.systemd1.Unit", "InactiveEnterTimestamp",bus_property_append_usec, "t", &u->inactive_enter_timestamp.realtime }, \
- { "org.freedesktop.systemd1.Unit", "InactiveEnterTimestampMonotonic",bus_property_append_usec,"t", &u->inactive_enter_timestamp.monotonic }, \
- { "org.freedesktop.systemd1.Unit", "CanStart", bus_unit_append_can_start, "b", u }, \
- { "org.freedesktop.systemd1.Unit", "CanStop", bus_unit_append_can_stop, "b", u }, \
- { "org.freedesktop.systemd1.Unit", "CanReload", bus_unit_append_can_reload, "b", u }, \
- { "org.freedesktop.systemd1.Unit", "CanIsolate", bus_unit_append_can_isolate, "b", u }, \
- { "org.freedesktop.systemd1.Unit", "Job", bus_unit_append_job, "(uo)", u }, \
- { "org.freedesktop.systemd1.Unit", "StopWhenUnneeded", bus_property_append_bool, "b", &u->stop_when_unneeded }, \
- { "org.freedesktop.systemd1.Unit", "RefuseManualStart", bus_property_append_bool, "b", &u->refuse_manual_start }, \
- { "org.freedesktop.systemd1.Unit", "RefuseManualStop", bus_property_append_bool, "b", &u->refuse_manual_stop }, \
- { "org.freedesktop.systemd1.Unit", "AllowIsolate", bus_property_append_bool, "b", &u->allow_isolate }, \
- { "org.freedesktop.systemd1.Unit", "DefaultDependencies", bus_property_append_bool, "b", &u->default_dependencies }, \
- { "org.freedesktop.systemd1.Unit", "OnFailureIsolate", bus_property_append_bool, "b", &u->on_failure_isolate }, \
- { "org.freedesktop.systemd1.Unit", "IgnoreOnIsolate", bus_property_append_bool, "b", &u->ignore_on_isolate }, \
- { "org.freedesktop.systemd1.Unit", "IgnoreOnSnapshot", bus_property_append_bool, "b", &u->ignore_on_snapshot }, \
- { "org.freedesktop.systemd1.Unit", "DefaultControlGroup", bus_unit_append_default_cgroup, "s", u }, \
- { "org.freedesktop.systemd1.Unit", "ControlGroup", bus_unit_append_cgroups, "as", u }, \
- { "org.freedesktop.systemd1.Unit", "ControlGroupAttributes", bus_unit_append_cgroup_attrs, "a(sss)", u }, \
- { "org.freedesktop.systemd1.Unit", "NeedDaemonReload", bus_unit_append_need_daemon_reload, "b", u }, \
- { "org.freedesktop.systemd1.Unit", "JobTimeoutUSec", bus_property_append_usec, "t", &u->job_timeout }, \
- { "org.freedesktop.systemd1.Unit", "ConditionTimestamp", bus_property_append_usec, "t", &u->condition_timestamp.realtime }, \
- { "org.freedesktop.systemd1.Unit", "ConditionTimestampMonotonic", bus_property_append_usec,"t", &u->condition_timestamp.monotonic }, \
- { "org.freedesktop.systemd1.Unit", "ConditionResult", bus_property_append_bool, "b", &u->condition_result }, \
- { "org.freedesktop.systemd1.Unit", "LoadError", bus_unit_append_load_error, "(ss)", u }
+extern const BusProperty bus_unit_properties[];
int bus_unit_append_names(DBusMessageIter *i, const char *property, void *data);
int bus_unit_append_following(DBusMessageIter *i, const char *property, void *data);
diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c
index f3b2c94..1340c29 100644
--- a/src/hostname/hostnamed.c
+++ b/src/hostname/hostnamed.c
@@ -280,18 +280,24 @@ static int bus_hostname_append_icon_name(DBusMessageIter *i, const char *propert
return bus_property_append_string(i, property, (void*) name);
}
+static const BusProperty bus_hostname_properties[] = {
+ { "Hostname", bus_property_append_string, "s", sizeof(data[0])*PROP_HOSTNAME, true },
+ { "StaticHostname", bus_property_append_string, "s", sizeof(data[0])*PROP_STATIC_HOSTNAME, true },
+ { "PrettyHostname", bus_property_append_string, "s", sizeof(data[0])*PROP_PRETTY_HOSTNAME, true },
+ { "IconName", bus_hostname_append_icon_name, "s", sizeof(data[0])*PROP_ICON_NAME, true },
+ { NULL, }
+};
+
+static const BusBoundProperties bps[] = {
+ { "org.freedesktop.hostname1", bus_hostname_properties, data },
+ { NULL, }
+};
+
static DBusHandlerResult hostname_message_handler(
DBusConnection *connection,
DBusMessage *message,
void *userdata) {
- const BusProperty properties[] = {
- { "org.freedesktop.hostname1", "Hostname", bus_property_append_string, "s", data[PROP_HOSTNAME]},
- { "org.freedesktop.hostname1", "StaticHostname", bus_property_append_string, "s", data[PROP_STATIC_HOSTNAME]},
- { "org.freedesktop.hostname1", "PrettyHostname", bus_property_append_string, "s", data[PROP_PRETTY_HOSTNAME]},
- { "org.freedesktop.hostname1", "IconName", bus_hostname_append_icon_name, "s", data[PROP_ICON_NAME]},
- { NULL, NULL, NULL, NULL, NULL }
- };
DBusMessage *reply = NULL, *changed = NULL;
DBusError error;
@@ -470,7 +476,7 @@ static DBusHandlerResult hostname_message_handler(
}
} else
- return bus_default_message_handler(connection, message, INTROSPECTION, INTERFACES_LIST, properties);
+ return bus_default_message_handler(connection, message, INTROSPECTION, INTERFACES_LIST, bps);
if (!(reply = dbus_message_new_method_return(message)))
goto oom;
diff --git a/src/locale/localed.c b/src/locale/localed.c
index c6b48de..d46d91e 100644
--- a/src/locale/localed.c
+++ b/src/locale/localed.c
@@ -129,8 +129,12 @@ static char *data[_PROP_MAX] = {
NULL
};
-static char *x11_layout = NULL, *x11_model = NULL, *x11_variant = NULL, *x11_options = NULL;
-static char *vc_keymap = NULL, *vc_keymap_toggle = NULL;
+typedef struct State {
+ char *x11_layout, *x11_model, *x11_variant, *x11_options;
+ char *vc_keymap, *vc_keymap_toggle;
+} State;
+
+static State state;
static usec_t remain_until = 0;
@@ -160,19 +164,19 @@ static void free_data_locale(void) {
}
static void free_data_x11(void) {
- free(x11_layout);
- free(x11_model);
- free(x11_variant);
- free(x11_options);
+ free(state.x11_layout);
+ free(state.x11_model);
+ free(state.x11_variant);
+ free(state.x11_options);
- x11_layout = x11_model = x11_variant = x11_options = NULL;
+ state.x11_layout = state.x11_model = state.x11_variant = state.x11_options = NULL;
}
static void free_data_vconsole(void) {
- free(vc_keymap);
- free(vc_keymap_toggle);
+ free(state.vc_keymap);
+ free(state.vc_keymap_toggle);
- vc_keymap = vc_keymap_toggle = NULL;
+ state.vc_keymap = state.vc_keymap_toggle = NULL;
}
static void simplify(void) {
@@ -248,8 +252,8 @@ static int read_data_vconsole(void) {
free_data_vconsole();
r = parse_env_file("/etc/vconsole.conf", NEWLINE,
- "KEYMAP", &vc_keymap,
- "KEYMAP_TOGGLE", &vc_keymap_toggle,
+ "KEYMAP", &state.vc_keymap,
+ "KEYMAP_TOGGLE", &state.vc_keymap_toggle,
NULL);
if (r < 0 && r != -ENOENT)
@@ -306,20 +310,20 @@ static int read_data_x11(void) {
if (strv_length(a) == 3) {
if (streq(a[1], "XkbLayout")) {
- free(x11_layout);
- x11_layout = a[2];
+ free(state.x11_layout);
+ state.x11_layout = a[2];
a[2] = NULL;
} else if (streq(a[1], "XkbModel")) {
- free(x11_model);
- x11_model = a[2];
+ free(state.x11_model);
+ state.x11_model = a[2];
a[2] = NULL;
} else if (streq(a[1], "XkbVariant")) {
- free(x11_variant);
- x11_variant = a[2];
+ free(state.x11_variant);
+ state.x11_variant = a[2];
a[2] = NULL;
} else if (streq(a[1], "XkbOptions")) {
- free(x11_options);
- x11_options = a[2];
+ free(state.x11_options);
+ state.x11_options = a[2];
a[2] = NULL;
}
}
@@ -505,12 +509,12 @@ static int write_data_vconsole(void) {
if (r < 0 && r != -ENOENT)
return r;
- if (isempty(vc_keymap))
+ if (isempty(state.vc_keymap))
l = strv_env_unset(l, "KEYMAP");
else {
char *s, **u;
- s = strappend("KEYMAP=", vc_keymap);
+ s = strappend("KEYMAP=", state.vc_keymap);
if (!s) {
strv_free(l);
return -ENOMEM;
@@ -526,12 +530,12 @@ static int write_data_vconsole(void) {
l = u;
}
- if (isempty(vc_keymap_toggle))
+ if (isempty(state.vc_keymap_toggle))
l = strv_env_unset(l, "KEYMAP_TOGGLE");
else {
char *s, **u;
- s = strappend("KEYMAP_TOGGLE=", vc_keymap_toggle);
+ s = strappend("KEYMAP_TOGGLE=", state.vc_keymap_toggle);
if (!s) {
strv_free(l);
return -ENOMEM;
@@ -567,10 +571,10 @@ static int write_data_x11(void) {
char *temp_path;
int r;
- if (isempty(x11_layout) &&
- isempty(x11_model) &&
- isempty(x11_variant) &&
- isempty(x11_options)) {
+ if (isempty(state.x11_layout) &&
+ isempty(state.x11_model) &&
+ isempty(state.x11_variant) &&
+ isempty(state.x11_options)) {
#ifdef TARGET_FEDORA
unlink("/etc/X11/xorg.conf.d/00-system-setup-keyboard.conf");
@@ -600,17 +604,17 @@ static int write_data_x11(void) {
" Identifier \"system-keyboard\"\n"
" MatchIsKeyboard \"on\"\n", f);
- if (!isempty(x11_layout))
- fprintf(f, " Option \"XkbLayout\" \"%s\"\n", x11_layout);
+ if (!isempty(state.x11_layout))
+ fprintf(f, " Option \"XkbLayout\" \"%s\"\n", state.x11_layout);
- if (!isempty(x11_model))
- fprintf(f, " Option \"XkbModel\" \"%s\"\n", x11_model);
+ if (!isempty(state.x11_model))
+ fprintf(f, " Option \"XkbModel\" \"%s\"\n", state.x11_model);
- if (!isempty(x11_variant))
- fprintf(f, " Option \"XkbVariant\" \"%s\"\n", x11_variant);
+ if (!isempty(state.x11_variant))
+ fprintf(f, " Option \"XkbVariant\" \"%s\"\n", state.x11_variant);
- if (!isempty(x11_options))
- fprintf(f, " Option \"XkbOptions\" \"%s\"\n", x11_options);
+ if (!isempty(state.x11_options))
+ fprintf(f, " Option \"XkbOptions\" \"%s\"\n", state.x11_options);
fputs("EndSection\n", f);
fflush(f);
@@ -742,13 +746,13 @@ static int convert_vconsole_to_x11(DBusConnection *connection) {
assert(connection);
- if (isempty(vc_keymap)) {
+ if (isempty(state.vc_keymap)) {
modified =
- !isempty(x11_layout) ||
- !isempty(x11_model) ||
- !isempty(x11_variant) ||
- !isempty(x11_options);
+ !isempty(state.x11_layout) ||
+ !isempty(state.x11_model) ||
+ !isempty(state.x11_variant) ||
+ !isempty(state.x11_options);
free_data_x11();
} else {
@@ -772,20 +776,20 @@ static int convert_vconsole_to_x11(DBusConnection *connection) {
if (r == 0)
break;
- if (!streq(vc_keymap, a[0])) {
+ if (!streq(state.vc_keymap, a[0])) {
strv_free(a);
continue;
}
- if (!streq_ptr(x11_layout, strnulldash(a[1])) ||
- !streq_ptr(x11_model, strnulldash(a[2])) ||
- !streq_ptr(x11_variant, strnulldash(a[3])) ||
- !streq_ptr(x11_options, strnulldash(a[4]))) {
+ if (!streq_ptr(state.x11_layout, strnulldash(a[1])) ||
+ !streq_ptr(state.x11_model, strnulldash(a[2])) ||
+ !streq_ptr(state.x11_variant, strnulldash(a[3])) ||
+ !streq_ptr(state.x11_options, strnulldash(a[4]))) {
- if (free_and_set(&x11_layout, strnulldash(a[1])) < 0 ||
- free_and_set(&x11_model, strnulldash(a[2])) < 0 ||
- free_and_set(&x11_variant, strnulldash(a[3])) < 0 ||
- free_and_set(&x11_options, strnulldash(a[4])) < 0) {
+ if (free_and_set(&state.x11_layout, strnulldash(a[1])) < 0 ||
+ free_and_set(&state.x11_model, strnulldash(a[2])) < 0 ||
+ free_and_set(&state.x11_variant, strnulldash(a[3])) < 0 ||
+ free_and_set(&state.x11_options, strnulldash(a[4])) < 0) {
strv_free(a);
fclose(f);
return -ENOMEM;
@@ -836,11 +840,11 @@ static int convert_x11_to_vconsole(DBusConnection *connection) {
assert(connection);
- if (isempty(x11_layout)) {
+ if (isempty(state.x11_layout)) {
modified =
- !isempty(vc_keymap) ||
- !isempty(vc_keymap_toggle);
+ !isempty(state.vc_keymap) ||
+ !isempty(state.vc_keymap_toggle);
free_data_x11();
} else {
@@ -868,13 +872,13 @@ static int convert_x11_to_vconsole(DBusConnection *connection) {
break;
/* Determine how well matching this entry is */
- if (streq_ptr(x11_layout, a[1]))
+ if (streq_ptr(state.x11_layout, a[1]))
/* If we got an exact match, this is best */
matching = 10;
else {
size_t x;
- x = strcspn(x11_layout, ",");
+ x = strcspn(state.x11_layout, ",");
/* We have multiple X layouts, look
* for an entry that matches our key
@@ -882,7 +886,7 @@ static int convert_x11_to_vconsole(DBusConnection *connection) {
* layout stripped off. */
if (x > 0 &&
strlen(a[1]) == x &&
- strncmp(x11_layout, a[1], x) == 0)
+ strncmp(state.x11_layout, a[1], x) == 0)
matching = 5;
else {
size_t w;
@@ -894,19 +898,19 @@ static int convert_x11_to_vconsole(DBusConnection *connection) {
w = strcspn(a[1], ",");
if (x > 0 && x == w &&
- memcmp(x11_layout, a[1], x) == 0)
+ memcmp(state.x11_layout, a[1], x) == 0)
matching = 1;
}
}
if (matching > 0 &&
- streq_ptr(x11_model, a[2])) {
+ streq_ptr(state.x11_model, a[2])) {
matching++;
- if (streq_ptr(x11_variant, a[3])) {
+ if (streq_ptr(state.x11_variant, a[3])) {
matching++;
- if (streq_ptr(x11_options, a[4]))
+ if (streq_ptr(state.x11_options, a[4]))
matching++;
}
}
@@ -931,12 +935,12 @@ static int convert_x11_to_vconsole(DBusConnection *connection) {
fclose(f);
- if (!streq_ptr(vc_keymap, new_keymap)) {
- free(vc_keymap);
- vc_keymap = new_keymap;
+ if (!streq_ptr(state.vc_keymap, new_keymap)) {
+ free(state.vc_keymap);
+ state.vc_keymap = new_keymap;
- free(vc_keymap_toggle);
- vc_keymap_toggle = NULL;
+ free(state.vc_keymap_toggle);
+ state.vc_keymap_toggle = NULL;
modified = true;
} else
@@ -1001,22 +1005,27 @@ static int append_locale(DBusMessageIter *i, const char *property, void *userdat
return r;
}
+static const BusProperty bus_locale_properties[] = {
+ { "Locale", append_locale, "as", 0 },
+ { "X11Layout", bus_property_append_string, "s", offsetof(State, x11_layout), true },
+ { "X11Model", bus_property_append_string, "s", offsetof(State, x11_model), true },
+ { "X11Variant", bus_property_append_string, "s", offsetof(State, x11_variant), true },
+ { "X11Options", bus_property_append_string, "s", offsetof(State, x11_options), true },
+ { "VConsoleKeymap", bus_property_append_string, "s", offsetof(State, vc_keymap), true },
+ { "VConsoleKeymapToggle", bus_property_append_string, "s", offsetof(State, vc_keymap_toggle), true },
+ { NULL, }
+};
+
+static const BusBoundProperties bps[] = {
+ { "org.freedesktop.locale1", bus_locale_properties, &state },
+ { NULL, }
+};
+
static DBusHandlerResult locale_message_handler(
DBusConnection *connection,
DBusMessage *message,
void *userdata) {
- const BusProperty properties[] = {
- { "org.freedesktop.locale1", "Locale", append_locale, "as", NULL },
- { "org.freedesktop.locale1", "X11Layout", bus_property_append_string, "s", x11_layout },
- { "org.freedesktop.locale1", "X11Model", bus_property_append_string, "s", x11_model },
- { "org.freedesktop.locale1", "X11Variant", bus_property_append_string, "s", x11_variant },
- { "org.freedesktop.locale1", "X11Options", bus_property_append_string, "s", x11_options },
- { "org.freedesktop.locale1", "VConsoleKeymap", bus_property_append_string, "s", vc_keymap },
- { "org.freedesktop.locale1", "VConsoleKeymapToggle", bus_property_append_string, "s", vc_keymap_toggle },
- { NULL, NULL, NULL, NULL, NULL }
- };
-
DBusMessage *reply = NULL, *changed = NULL;
DBusError error;
int r;
@@ -1169,15 +1178,15 @@ static DBusHandlerResult locale_message_handler(
if (isempty(keymap_toggle))
keymap_toggle = NULL;
- if (!streq_ptr(keymap, vc_keymap) ||
- !streq_ptr(keymap_toggle, vc_keymap_toggle)) {
+ if (!streq_ptr(keymap, state.vc_keymap) ||
+ !streq_ptr(keymap_toggle, state.vc_keymap_toggle)) {
r = verify_polkit(connection, message, "org.freedesktop.locale1.set-keyboard", interactive, &error);
if (r < 0)
return bus_send_error_reply(connection, message, &error, r);
- if (free_and_set(&vc_keymap, keymap) < 0 ||
- free_and_set(&vc_keymap_toggle, keymap_toggle) < 0)
+ if (free_and_set(&state.vc_keymap, keymap) < 0 ||
+ free_and_set(&state.vc_keymap_toggle, keymap_toggle) < 0)
goto oom;
r = write_data_vconsole();
@@ -1186,7 +1195,7 @@ static DBusHandlerResult locale_message_handler(
return bus_send_error_reply(connection, message, NULL, r);
}
- log_info("Changed virtual console keymap to '%s'", strempty(vc_keymap));
+ log_info("Changed virtual console keymap to '%s'", strempty(state.vc_keymap));
r = load_vconsole_keymap(connection, NULL);
if (r < 0)
@@ -1237,19 +1246,19 @@ static DBusHandlerResult locale_message_handler(
if (isempty(options))
options = NULL;
- if (!streq_ptr(layout, x11_layout) ||
- !streq_ptr(model, x11_model) ||
- !streq_ptr(variant, x11_variant) ||
- !streq_ptr(options, x11_options)) {
+ if (!streq_ptr(layout, state.x11_layout) ||
+ !streq_ptr(model, state.x11_model) ||
+ !streq_ptr(variant, state.x11_variant) ||
+ !streq_ptr(options, state.x11_options)) {
r = verify_polkit(connection, message, "org.freedesktop.locale1.set-keyboard", interactive, &error);
if (r < 0)
return bus_send_error_reply(connection, message, &error, r);
- if (free_and_set(&x11_layout, layout) < 0 ||
- free_and_set(&x11_model, model) < 0 ||
- free_and_set(&x11_variant, variant) < 0 ||
- free_and_set(&x11_options, options) < 0)
+ if (free_and_set(&state.x11_layout, layout) < 0 ||
+ free_and_set(&state.x11_model, model) < 0 ||
+ free_and_set(&state.x11_variant, variant) < 0 ||
+ free_and_set(&state.x11_options, options) < 0)
goto oom;
r = write_data_x11();
@@ -1258,7 +1267,7 @@ static DBusHandlerResult locale_message_handler(
return bus_send_error_reply(connection, message, NULL, r);
}
- log_info("Changed X11 keyboard layout to '%s'", strempty(x11_layout));
+ log_info("Changed X11 keyboard layout to '%s'", strempty(state.x11_layout));
changed = bus_properties_changed_new(
"/org/freedesktop/locale1",
@@ -1278,8 +1287,7 @@ static DBusHandlerResult locale_message_handler(
}
}
} else
- return bus_default_message_handler(connection, message, INTROSPECTION, INTERFACES_LIST, properties);
-
+ return bus_default_message_handler(connection, message, INTROSPECTION, INTERFACES_LIST, bps);
if (!(reply = dbus_message_new_method_return(message)))
goto oom;
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index efbc040..42dd54d 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -706,6 +706,20 @@ static int flush_devices(Manager *m) {
return trigger_device(m, NULL);
}
+static const BusProperty bus_login_manager_properties[] = {
+ { "ControlGroupHierarchy", bus_property_append_string, "s", offsetof(Manager, cgroup_path), true },
+ { "Controllers", bus_property_append_strv, "as", offsetof(Manager, controllers), true },
+ { "ResetControllers", bus_property_append_strv, "as", offsetof(Manager, reset_controllers), true },
+ { "NAutoVTs", bus_property_append_unsigned, "u", offsetof(Manager, n_autovts) },
+ { "KillOnlyUsers", bus_property_append_strv, "as", offsetof(Manager, kill_only_users), true },
+ { "KillExcludeUsers", bus_property_append_strv, "as", offsetof(Manager, kill_exclude_users), true },
+ { "KillUserProcesses", bus_property_append_bool, "b", offsetof(Manager, kill_user_processes) },
+ { "IdleHint", bus_manager_append_idle_hint, "b", 0 },
+ { "IdleSinceHint", bus_manager_append_idle_hint_since, "t", 0 },
+ { "IdleSinceHintMonotonic", bus_manager_append_idle_hint_since, "t", 0 },
+ { NULL, }
+};
+
static DBusHandlerResult manager_message_handler(
DBusConnection *connection,
DBusMessage *message,
@@ -713,20 +727,6 @@ static DBusHandlerResult manager_message_handler(
Manager *m = userdata;
- const BusProperty properties[] = {
- { "org.freedesktop.login1.Manager", "ControlGroupHierarchy", bus_property_append_string, "s", m->cgroup_path },
- { "org.freedesktop.login1.Manager", "Controllers", bus_property_append_strv, "as", m->controllers },
- { "org.freedesktop.login1.Manager", "ResetControllers", bus_property_append_strv, "as", m->reset_controllers },
- { "org.freedesktop.login1.Manager", "NAutoVTs", bus_property_append_unsigned, "u", &m->n_autovts },
- { "org.freedesktop.login1.Manager", "KillOnlyUsers", bus_property_append_strv, "as", m->kill_only_users },
- { "org.freedesktop.login1.Manager", "KillExcludeUsers", bus_property_append_strv, "as", m->kill_exclude_users },
- { "org.freedesktop.login1.Manager", "KillUserProcesses", bus_property_append_bool, "b", &m->kill_user_processes },
- { "org.freedesktop.login1.Manager", "IdleHint", bus_manager_append_idle_hint, "b", m },
- { "org.freedesktop.login1.Manager", "IdleSinceHint", bus_manager_append_idle_hint_since, "t", m },
- { "org.freedesktop.login1.Manager", "IdleSinceHintMonotonic", bus_manager_append_idle_hint_since, "t", m },
- { NULL, NULL, NULL, NULL, NULL }
- };
-
DBusError error;
DBusMessage *reply = NULL;
int r;
@@ -1426,8 +1426,13 @@ static DBusHandlerResult manager_message_handler(
}
free(introspection);
- } else
- return bus_default_message_handler(connection, message, NULL, INTERFACES_LIST, properties);
+ } else {
+ const BusBoundProperties bps[] = {
+ { "org.freedesktop.login1.Manager", bus_login_manager_properties, m },
+ { NULL, }
+ };
+ return bus_default_message_handler(connection, message, NULL, INTERFACES_LIST, bps);
+ }
if (reply) {
if (!dbus_connection_send(connection, reply, NULL))
diff --git a/src/login/logind-seat-dbus.c b/src/login/logind-seat-dbus.c
index a15689b..95ef5ff 100644
--- a/src/login/logind-seat-dbus.c
+++ b/src/login/logind-seat-dbus.c
@@ -207,22 +207,22 @@ static int get_seat_for_path(Manager *m, const char *path, Seat **_s) {
return 0;
}
+static const BusProperty bus_login_seat_properties[] = {
+ { "Id", bus_property_append_string, "s", offsetof(Seat, id), true },
+ { "ActiveSession", bus_seat_append_active, "(so)", 0 },
+ { "CanMultiSession", bus_seat_append_multi_session, "b", 0 },
+ { "Sessions", bus_seat_append_sessions, "a(so)", 0 },
+ { "IdleHint", bus_seat_append_idle_hint, "b", 0 },
+ { "IdleSinceHint", bus_seat_append_idle_hint_since, "t", 0 },
+ { "IdleSinceHintMonotonic", bus_seat_append_idle_hint_since, "t", 0 },
+ { NULL, }
+};
+
static DBusHandlerResult seat_message_dispatch(
Seat *s,
DBusConnection *connection,
DBusMessage *message) {
- const BusProperty properties[] = {
- { "org.freedesktop.login1.Seat", "Id", bus_property_append_string, "s", s->id },
- { "org.freedesktop.login1.Seat", "ActiveSession", bus_seat_append_active, "(so)", s },
- { "org.freedesktop.login1.Seat", "CanMultiSession", bus_seat_append_multi_session, "b", s },
- { "org.freedesktop.login1.Seat", "Sessions", bus_seat_append_sessions, "a(so)", s },
- { "org.freedesktop.login1.Seat", "IdleHint", bus_seat_append_idle_hint, "b", s },
- { "org.freedesktop.login1.Seat", "IdleSinceHint", bus_seat_append_idle_hint_since, "t", s },
- { "org.freedesktop.login1.Seat", "IdleSinceHintMonotonic", bus_seat_append_idle_hint_since, "t", s },
- { NULL, NULL, NULL, NULL, NULL }
- };
-
DBusError error;
DBusMessage *reply = NULL;
int r;
@@ -265,8 +265,13 @@ static DBusHandlerResult seat_message_dispatch(
reply = dbus_message_new_method_return(message);
if (!reply)
goto oom;
- } else
- return bus_default_message_handler(connection, message, INTROSPECTION, INTERFACES_LIST, properties);
+ } else {
+ const BusBoundProperties bps[] = {
+ { "org.freedesktop.login1.Seat", bus_login_seat_properties, s },
+ { NULL, }
+ };
+ return bus_default_message_handler(connection, message, INTROSPECTION, INTERFACES_LIST, bps);
+ }
if (reply) {
if (!dbus_connection_send(connection, reply, NULL))
diff --git a/src/login/logind-session-dbus.c b/src/login/logind-session-dbus.c
index cbd6d7f..dabb91c 100644
--- a/src/login/logind-session-dbus.c
+++ b/src/login/logind-session-dbus.c
@@ -119,21 +119,21 @@ static int bus_session_append_seat(DBusMessageIter *i, const char *property, voi
static int bus_session_append_user(DBusMessageIter *i, const char *property, void *data) {
DBusMessageIter sub;
- Session *s = data;
+ User *u = data;
char *p = NULL;
assert(i);
assert(property);
- assert(s);
+ assert(u);
if (!dbus_message_iter_open_container(i, DBUS_TYPE_STRUCT, NULL, &sub))
return -ENOMEM;
- p = user_bus_path(s->user);
+ p = user_bus_path(u);
if (!p)
return -ENOMEM;
- if (!dbus_message_iter_append_basic(&sub, DBUS_TYPE_UINT32, &s->user->uid) ||
+ if (!dbus_message_iter_append_basic(&sub, DBUS_TYPE_UINT32, &u->uid) ||
!dbus_message_iter_append_basic(&sub, DBUS_TYPE_OBJECT_PATH, &p)) {
free(p);
return -ENOMEM;
@@ -222,39 +222,42 @@ static int get_session_for_path(Manager *m, const char *path, Session **_s) {
return 0;
}
+static const BusProperty bus_login_session_properties[] = {
+ { "Id", bus_property_append_string, "s", offsetof(Session, id), true },
+ { "Timestamp", bus_property_append_usec, "t", offsetof(Session, timestamp.realtime) },
+ { "TimestampMonotonic", bus_property_append_usec, "t", offsetof(Session, timestamp.monotonic) },
+ { "ControlGroupPath", bus_property_append_string, "s", offsetof(Session, cgroup_path), true },
+ { "VTNr", bus_property_append_uint32, "u", offsetof(Session, vtnr) },
+ { "Seat", bus_session_append_seat, "(so)", 0 },
+ { "TTY", bus_property_append_string, "s", offsetof(Session, tty), true },
+ { "Display", bus_property_append_string, "s", offsetof(Session, display), true },
+ { "Remote", bus_property_append_bool, "b", offsetof(Session, remote) },
+ { "RemoteUser", bus_property_append_string, "s", offsetof(Session, remote_user), true },
+ { "RemoteHost", bus_property_append_string, "s", offsetof(Session, remote_host), true },
+ { "Service", bus_property_append_string, "s", offsetof(Session, service), true },
+ { "Leader", bus_property_append_pid, "u", offsetof(Session, leader) },
+ { "Audit", bus_property_append_uint32, "u", offsetof(Session, audit_id) },
+ { "Type", bus_session_append_type, "s", offsetof(Session, type) },
+ { "Active", bus_session_append_active, "b", 0 },
+ { "Controllers", bus_property_append_strv, "as", offsetof(Session, controllers), true },
+ { "ResetControllers", bus_property_append_strv, "as", offsetof(Session, reset_controllers), true },
+ { "KillProcesses", bus_property_append_bool, "b", offsetof(Session, kill_processes) },
+ { "IdleHint", bus_session_append_idle_hint, "b", 0 },
+ { "IdleSinceHint", bus_session_append_idle_hint_since, "t", 0 },
+ { "IdleSinceHintMonotonic", bus_session_append_idle_hint_since, "t", 0 },
+ { NULL, }
+};
+
+static const BusProperty bus_login_session_user_properties[] = {
+ { "User", bus_session_append_user, "(uo)", 0 },
+ { "Name", bus_property_append_string, "s", offsetof(User, name), true },
+};
+
static DBusHandlerResult session_message_dispatch(
Session *s,
DBusConnection *connection,
DBusMessage *message) {
- const BusProperty properties[] = {
- { "org.freedesktop.login1.Session", "Id", bus_property_append_string, "s", s->id },
- { "org.freedesktop.login1.Session", "User", bus_session_append_user, "(uo)", s },
- { "org.freedesktop.login1.Session", "Name", bus_property_append_string, "s", s->user->name },
- { "org.freedesktop.login1.Session", "Timestamp", bus_property_append_usec, "t", &s->timestamp.realtime },
- { "org.freedesktop.login1.Session", "TimestampMonotonic", bus_property_append_usec, "t", &s->timestamp.monotonic },
- { "org.freedesktop.login1.Session", "ControlGroupPath", bus_property_append_string, "s", s->cgroup_path },
- { "org.freedesktop.login1.Session", "VTNr", bus_property_append_uint32, "u", &s->vtnr },
- { "org.freedesktop.login1.Session", "Seat", bus_session_append_seat, "(so)", s },
- { "org.freedesktop.login1.Session", "TTY", bus_property_append_string, "s", s->tty },
- { "org.freedesktop.login1.Session", "Display", bus_property_append_string, "s", s->display },
- { "org.freedesktop.login1.Session", "Remote", bus_property_append_bool, "b", &s->remote },
- { "org.freedesktop.login1.Session", "RemoteUser", bus_property_append_string, "s", s->remote_user },
- { "org.freedesktop.login1.Session", "RemoteHost", bus_property_append_string, "s", s->remote_host },
- { "org.freedesktop.login1.Session", "Service", bus_property_append_string, "s", s->service },
- { "org.freedesktop.login1.Session", "Leader", bus_property_append_pid, "u", &s->leader },
- { "org.freedesktop.login1.Session", "Audit", bus_property_append_uint32, "u", &s->audit_id },
- { "org.freedesktop.login1.Session", "Type", bus_session_append_type, "s", &s->type },
- { "org.freedesktop.login1.Session", "Active", bus_session_append_active, "b", s },
- { "org.freedesktop.login1.Session", "Controllers", bus_property_append_strv, "as", s->controllers },
- { "org.freedesktop.login1.Session", "ResetControllers", bus_property_append_strv, "as", s->reset_controllers },
- { "org.freedesktop.login1.Session", "KillProcesses", bus_property_append_bool, "b", &s->kill_processes },
- { "org.freedesktop.login1.Session", "IdleHint", bus_session_append_idle_hint, "b", s },
- { "org.freedesktop.login1.Session", "IdleSinceHint", bus_session_append_idle_hint_since, "t", s },
- { "org.freedesktop.login1.Session", "IdleSinceHintMonotonic", bus_session_append_idle_hint_since, "t", s },
- { NULL, NULL, NULL, NULL, NULL }
- };
-
DBusError error;
DBusMessage *reply = NULL;
int r;
@@ -351,8 +354,14 @@ static DBusHandlerResult session_message_dispatch(
if (!reply)
goto oom;
- } else
- return bus_default_message_handler(connection, message, INTROSPECTION, INTERFACES_LIST, properties);
+ } else {
+ const BusBoundProperties bps[] = {
+ { "org.freedesktop.login1.Session", bus_login_session_properties, s },
+ { "org.freedesktop.login1.Session", bus_login_session_user_properties, s->user },
+ { NULL, }
+ };
+ return bus_default_message_handler(connection, message, INTROSPECTION, INTERFACES_LIST, bps);
+ }
if (reply) {
if (!dbus_connection_send(connection, reply, NULL))
diff --git a/src/login/logind-user-dbus.c b/src/login/logind-user-dbus.c
index 3673a28..a9d680f 100644
--- a/src/login/logind-user-dbus.c
+++ b/src/login/logind-user-dbus.c
@@ -213,29 +213,29 @@ static int get_user_for_path(Manager *m, const char *path, User **_u) {
return 0;
}
+static const BusProperty bus_login_user_properties[] = {
+ { "UID", bus_property_append_uid, "u", offsetof(User, uid) },
+ { "GID", bus_property_append_gid, "u", offsetof(User, gid) },
+ { "Name", bus_property_append_string, "s", offsetof(User, name), true },
+ { "Timestamp", bus_property_append_usec, "t", offsetof(User, timestamp.realtime) },
+ { "TimestampMonotonic", bus_property_append_usec, "t", offsetof(User, timestamp.monotonic) },
+ { "RuntimePath", bus_property_append_string, "s", offsetof(User, runtime_path), true },
+ { "ControlGroupPath", bus_property_append_string, "s", offsetof(User, cgroup_path), true },
+ { "Service", bus_property_append_string, "s", offsetof(User, service), true },
+ { "Display", bus_user_append_display, "(so)", 0 },
+ { "State", bus_user_append_state, "s", 0 },
+ { "Sessions", bus_user_append_sessions, "a(so)", 0 },
+ { "IdleHint", bus_user_append_idle_hint, "b", 0 },
+ { "IdleSinceHint", bus_user_append_idle_hint_since, "t", 0 },
+ { "IdleSinceHintMonotonic", bus_user_append_idle_hint_since, "t", 0 },
+ { NULL, }
+};
+
static DBusHandlerResult user_message_dispatch(
User *u,
DBusConnection *connection,
DBusMessage *message) {
- const BusProperty properties[] = {
- { "org.freedesktop.login1.User", "UID", bus_property_append_uid, "u", &u->uid },
- { "org.freedesktop.login1.User", "GID", bus_property_append_gid, "u", &u->gid },
- { "org.freedesktop.login1.User", "Name", bus_property_append_string, "s", u->name },
- { "org.freedesktop.login1.User", "Timestamp", bus_property_append_usec, "t", &u->timestamp.realtime },
- { "org.freedesktop.login1.User", "TimestampMonotonic", bus_property_append_usec, "t", &u->timestamp.monotonic },
- { "org.freedesktop.login1.User", "RuntimePath", bus_property_append_string, "s", u->runtime_path },
- { "org.freedesktop.login1.User", "ControlGroupPath", bus_property_append_string, "s", u->cgroup_path },
- { "org.freedesktop.login1.User", "Service", bus_property_append_string, "s", u->service },
- { "org.freedesktop.login1.User", "Display", bus_user_append_display, "(so)", u },
- { "org.freedesktop.login1.User", "State", bus_user_append_state, "s", u },
- { "org.freedesktop.login1.User", "Sessions", bus_user_append_sessions, "a(so)", u },
- { "org.freedesktop.login1.User", "IdleHint", bus_user_append_idle_hint, "b", u },
- { "org.freedesktop.login1.User", "IdleSinceHint", bus_user_append_idle_hint_since, "t", u },
- { "org.freedesktop.login1.User", "IdleSinceHintMonotonic", bus_user_append_idle_hint_since, "t", u },
- { NULL, NULL, NULL, NULL, NULL }
- };
-
DBusError error;
DBusMessage *reply = NULL;
int r;
@@ -274,8 +274,14 @@ static DBusHandlerResult user_message_dispatch(
if (!reply)
goto oom;
- } else
- return bus_default_message_handler(connection, message, INTROSPECTION, INTERFACES_LIST, properties);
+ } else {
+ const BusBoundProperties bps[] = {
+ { "org.freedesktop.login1.User", bus_login_user_properties, u },
+ { NULL, }
+ };
+
+ return bus_default_message_handler(connection, message, INTROSPECTION, INTERFACES_LIST, bps);
+ }
if (reply) {
if (!dbus_connection_send(connection, reply, NULL))
diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c
index 16f54b5..97306e9 100644
--- a/src/timedate/timedated.c
+++ b/src/timedate/timedated.c
@@ -74,17 +74,23 @@
const char timedate_interface[] _introspect_("timedate1") = INTERFACE;
-static char *zone = NULL;
-static bool local_rtc = false;
-static int use_ntp = -1;
+typedef struct TZ {
+ char *zone;
+ bool local_rtc;
+ int use_ntp;
+} TZ;
-static usec_t remain_until = 0;
+static TZ tz = {
+ .use_ntp = -1,
+};
+
+static usec_t remain_until;
static void free_data(void) {
- free(zone);
- zone = NULL;
+ free(tz.zone);
+ tz.zone = NULL;
- local_rtc = false;
+ tz.local_rtc = false;
}
static bool valid_timezone(const char *name) {
@@ -140,10 +146,10 @@ static void verify_timezone(void) {
size_t l, q;
int j, k;
- if (!zone)
+ if (!tz.zone)
return;
- p = strappend("/usr/share/zoneinfo/", zone);
+ p = strappend("/usr/share/zoneinfo/", tz.zone);
if (!p) {
log_error("Out of memory");
return;
@@ -156,8 +162,8 @@ static void verify_timezone(void) {
if (j < 0 || k < 0 || l != q || memcmp(a, b, l)) {
log_warning("/etc/localtime and /etc/timezone out of sync.");
- free(zone);
- zone = NULL;
+ free(tz.zone);
+ tz.zone = NULL;
}
free(a);
@@ -169,14 +175,14 @@ static int read_data(void) {
free_data();
- r = read_one_line_file("/etc/timezone", &zone);
+ r = read_one_line_file("/etc/timezone", &tz.zone);
if (r < 0) {
if (r != -ENOENT)
log_warning("Failed to read /etc/timezone: %s", strerror(-r));
#ifdef TARGET_FEDORA
r = parse_env_file("/etc/sysconfig/clock", NEWLINE,
- "ZONE", &zone,
+ "ZONE", &tz.zone,
NULL);
if (r < 0 && r != -ENOENT)
@@ -184,14 +190,14 @@ static int read_data(void) {
#endif
}
- if (isempty(zone)) {
- free(zone);
- zone = NULL;
+ if (isempty(tz.zone)) {
+ free(tz.zone);
+ tz.zone = NULL;
}
verify_timezone();
- local_rtc = hwclock_is_localtime() > 0;
+ tz.local_rtc = hwclock_is_localtime() > 0;
return 0;
}
@@ -200,7 +206,7 @@ static int write_data_timezone(void) {
int r = 0;
char *p;
- if (!zone) {
+ if (!tz.zone) {
if (unlink("/etc/timezone") < 0 && errno != ENOENT)
r = -errno;
@@ -210,7 +216,7 @@ static int write_data_timezone(void) {
return r;
}
- p = strappend("/usr/share/zoneinfo/", zone);
+ p = strappend("/usr/share/zoneinfo/", tz.zone);
if (!p) {
log_error("Out of memory");
return -ENOMEM;
@@ -222,7 +228,7 @@ static int write_data_timezone(void) {
if (r < 0)
return r;
- r = write_one_line_file_atomic("/etc/timezone", zone);
+ r = write_one_line_file_atomic("/etc/timezone", tz.zone);
if (r < 0)
return r;
@@ -238,7 +244,7 @@ static int write_data_local_rtc(void) {
if (r != -ENOENT)
return r;
- if (!local_rtc)
+ if (!tz.local_rtc)
return 0;
w = strdup(NULL_ADJTIME_LOCAL);
@@ -270,13 +276,13 @@ static int write_data_local_rtc(void) {
a = p - s;
b = strlen(e);
- w = new(char, a + (local_rtc ? 5 : 3) + b + 1);
+ w = new(char, a + (tz.local_rtc ? 5 : 3) + b + 1);
if (!w) {
free(s);
return -ENOMEM;
}
- *(char*) mempcpy(stpcpy(mempcpy(w, s, a), local_rtc ? "LOCAL" : "UTC"), e, b) = 0;
+ *(char*) mempcpy(stpcpy(mempcpy(w, s, a), tz.local_rtc ? "LOCAL" : "UTC"), e, b) = 0;
if (streq(w, NULL_ADJTIME_UTC)) {
free(w);
@@ -341,7 +347,7 @@ static int read_ntp(DBusConnection *bus) {
goto finish;
}
- use_ntp =
+ tz.use_ntp =
streq(s, "enabled") ||
streq(s, "enabled-runtime");
r = 0;
@@ -370,7 +376,7 @@ static int start_ntp(DBusConnection *bus, DBusError *error) {
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
- use_ntp ? "StartUnit" : "StopUnit");
+ tz.use_ntp ? "StartUnit" : "StopUnit");
if (!m) {
log_error("Could not allocate message.");
r = -ENOMEM;
@@ -419,7 +425,7 @@ static int enable_ntp(DBusConnection *bus, DBusError *error) {
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
- use_ntp ? "EnableUnitFiles" : "DisableUnitFiles");
+ tz.use_ntp ? "EnableUnitFiles" : "DisableUnitFiles");
if (!m) {
log_error("Could not allocate message.");
@@ -441,7 +447,7 @@ static int enable_ntp(DBusConnection *bus, DBusError *error) {
goto finish;
}
- if (use_ntp) {
+ if (tz.use_ntp) {
/* send force bool */
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_BOOLEAN, &t)) {
log_error("Failed to append force boolean.");
@@ -495,7 +501,7 @@ static int property_append_ntp(DBusMessageIter *i, const char *property, void *d
assert(i);
assert(property);
- db = use_ntp > 0;
+ db = tz.use_ntp > 0;
if (!dbus_message_iter_append_basic(i, DBUS_TYPE_BOOLEAN, &db))
return -ENOMEM;
@@ -503,18 +509,23 @@ static int property_append_ntp(DBusMessageIter *i, const char *property, void *d
return 0;
}
+static const BusProperty bus_timedate_properties[] = {
+ { "Timezone", bus_property_append_string, "s", offsetof(TZ, zone), true },
+ { "LocalRTC", bus_property_append_bool, "b", offsetof(TZ, local_rtc) },
+ { "NTP", property_append_ntp, "b", offsetof(TZ, use_ntp) },
+ { NULL, }
+};
+
+static const BusBoundProperties bps[] = {
+ { "org.freedesktop.timedate1", bus_timedate_properties, &tz },
+ { NULL, }
+};
+
static DBusHandlerResult timedate_message_handler(
DBusConnection *connection,
DBusMessage *message,
void *userdata) {
- const BusProperty properties[] = {
- { "org.freedesktop.timedate1", "Timezone", bus_property_append_string, "s", zone },
- { "org.freedesktop.timedate1", "LocalRTC", bus_property_append_bool, "b", &local_rtc },
- { "org.freedesktop.timedate1", "NTP", property_append_ntp, "b", NULL },
- { NULL, NULL, NULL, NULL, NULL }
- };
-
DBusMessage *reply = NULL, *changed = NULL;
DBusError error;
int r;
@@ -539,7 +550,7 @@ static DBusHandlerResult timedate_message_handler(
if (!valid_timezone(z))
return bus_send_error_reply(connection, message, NULL, -EINVAL);
- if (!streq_ptr(z, zone)) {
+ if (!streq_ptr(z, tz.zone)) {
char *t;
r = verify_polkit(connection, message, "org.freedesktop.timedate1.set-timezone", interactive, &error);
@@ -550,8 +561,8 @@ static DBusHandlerResult timedate_message_handler(
if (!t)
goto oom;
- free(zone);
- zone = t;
+ free(tz.zone);
+ tz.zone = t;
/* 1. Write new configuration file */
r = write_data_timezone();
@@ -560,7 +571,7 @@ static DBusHandlerResult timedate_message_handler(
return bus_send_error_reply(connection, message, NULL, r);
}
- if (local_rtc) {
+ if (tz.local_rtc) {
struct timespec ts;
struct tm *tm;
@@ -573,7 +584,7 @@ static DBusHandlerResult timedate_message_handler(
hwclock_set_time(tm);
}
- log_info("Changed timezone to '%s'.", zone);
+ log_info("Changed timezone to '%s'.", tz.zone);
changed = bus_properties_changed_new(
"/org/freedesktop/timedate1",
@@ -597,14 +608,14 @@ static DBusHandlerResult timedate_message_handler(
DBUS_TYPE_INVALID))
return bus_send_error_reply(connection, message, &error, -EINVAL);
- if (lrtc != local_rtc) {
+ if (lrtc != tz.local_rtc) {
struct timespec ts;
r = verify_polkit(connection, message, "org.freedesktop.timedate1.set-local-rtc", interactive, &error);
if (r < 0)
return bus_send_error_reply(connection, message, &error, r);
- local_rtc = lrtc;
+ tz.local_rtc = lrtc;
/* 1. Write new configuration file */
r = write_data_local_rtc();
@@ -614,7 +625,7 @@ static DBusHandlerResult timedate_message_handler(
}
/* 2. Teach kernel new timezone */
- if (local_rtc)
+ if (tz.local_rtc)
hwclock_apply_localtime_delta(NULL);
else
hwclock_reset_localtime_delta();
@@ -628,7 +639,7 @@ static DBusHandlerResult timedate_message_handler(
/* Sync system clock from RTC; first,
* initialize the timezone fields of
* struct tm. */
- if (local_rtc)
+ if (tz.local_rtc)
tm = *localtime(&ts.tv_sec);
else
tm = *gmtime(&ts.tv_sec);
@@ -640,7 +651,7 @@ static DBusHandlerResult timedate_message_handler(
/* And set the system clock
* with this */
- if (local_rtc)
+ if (tz.local_rtc)
ts.tv_sec = mktime(&tm);
else
ts.tv_sec = timegm(&tm);
@@ -652,7 +663,7 @@ static DBusHandlerResult timedate_message_handler(
struct tm *tm;
/* Sync RTC from system clock */
- if (local_rtc)
+ if (tz.local_rtc)
tm = localtime(&ts.tv_sec);
else
tm = gmtime(&ts.tv_sec);
@@ -660,7 +671,7 @@ static DBusHandlerResult timedate_message_handler(
hwclock_set_time(tm);
}
- log_info("RTC configured to %s time.", local_rtc ? "local" : "UTC");
+ log_info("RTC configured to %s time.", tz.local_rtc ? "local" : "UTC");
changed = bus_properties_changed_new(
"/org/freedesktop/timedate1",
@@ -707,7 +718,7 @@ static DBusHandlerResult timedate_message_handler(
}
/* Sync down to RTC */
- if (local_rtc)
+ if (tz.local_rtc)
tm = localtime(&ts.tv_sec);
else
tm = gmtime(&ts.tv_sec);
@@ -728,13 +739,13 @@ static DBusHandlerResult timedate_message_handler(
DBUS_TYPE_INVALID))
return bus_send_error_reply(connection, message, &error, -EINVAL);
- if (ntp != !!use_ntp) {
+ if (ntp != !!tz.use_ntp) {
r = verify_polkit(connection, message, "org.freedesktop.timedate1.set-ntp", interactive, &error);
if (r < 0)
return bus_send_error_reply(connection, message, &error, r);
- use_ntp = !!ntp;
+ tz.use_ntp = !!ntp;
r = enable_ntp(connection, &error);
if (r < 0)
@@ -744,7 +755,7 @@ static DBusHandlerResult timedate_message_handler(
if (r < 0)
return bus_send_error_reply(connection, message, &error, r);
- log_info("Set NTP to %s", use_ntp ? "enabled" : "disabled");
+ log_info("Set NTP to %s", tz.use_ntp ? "enabled" : "disabled");
changed = bus_properties_changed_new(
"/org/freedesktop/timedate1",
@@ -755,7 +766,7 @@ static DBusHandlerResult timedate_message_handler(
}
} else
- return bus_default_message_handler(connection, message, INTROSPECTION, INTERFACES_LIST, properties);
+ return bus_default_message_handler(connection, message, INTROSPECTION, INTERFACES_LIST, bps);
if (!(reply = dbus_message_new_method_return(message)))
goto oom;
commit 595ed347a87e69893c5e72168fc2e94a7cb09e73
Author: Michal Schmidt <mschmidt at redhat.com>
Date: Sun Jan 15 12:37:16 2012 +0100
unit: use safe downcasts, remove pointless casts
Always use the macros for downcasting.
Remove a few obviously pointless casts.
diff --git a/src/automount.c b/src/automount.c
index 3c75335..aa38492 100644
--- a/src/automount.c
+++ b/src/automount.c
@@ -143,7 +143,7 @@ static int automount_add_mount_links(Automount *a) {
assert(a);
LIST_FOREACH(units_by_type, other, UNIT(a)->manager->units_by_type[UNIT_MOUNT])
- if ((r = automount_add_one_mount_link(a, (Mount*) other)) < 0)
+ if ((r = automount_add_one_mount_link(a, MOUNT(other))) < 0)
return r;
return 0;
diff --git a/src/load-fragment.c b/src/load-fragment.c
index 0961d94..deae2dc 100644
--- a/src/load-fragment.c
+++ b/src/load-fragment.c
@@ -269,7 +269,7 @@ int config_parse_socket_listen(
assert(rvalue);
assert(data);
- s = (Socket*) data;
+ s = SOCKET(data);
if (!(p = new0(SocketPort, 1)))
return -ENOMEM;
@@ -380,7 +380,7 @@ int config_parse_socket_bind(
assert(rvalue);
assert(data);
- s = (Socket*) data;
+ s = SOCKET(data);
if ((b = socket_address_bind_ipv6_only_from_string(rvalue)) < 0) {
int r;
diff --git a/src/manager.c b/src/manager.c
index 43460f1..bab1662 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -306,15 +306,15 @@ fail:
}
static unsigned manager_dispatch_cleanup_queue(Manager *m) {
- Unit *meta;
+ Unit *u;
unsigned n = 0;
assert(m);
- while ((meta = m->cleanup_queue)) {
- assert(meta->in_cleanup_queue);
+ while ((u = m->cleanup_queue)) {
+ assert(u->in_cleanup_queue);
- unit_free((Unit*) meta);
+ unit_free(u);
n++;
}
@@ -382,7 +382,7 @@ good:
}
static unsigned manager_dispatch_gc_queue(Manager *m) {
- Unit *meta;
+ Unit *u;
unsigned n = 0;
unsigned gc_marker;
@@ -401,21 +401,21 @@ static unsigned manager_dispatch_gc_queue(Manager *m) {
gc_marker = m->gc_marker;
- while ((meta = m->gc_queue)) {
- assert(meta->in_gc_queue);
+ while ((u = m->gc_queue)) {
+ assert(u->in_gc_queue);
- unit_gc_sweep((Unit*) meta, gc_marker);
+ unit_gc_sweep(u, gc_marker);
- LIST_REMOVE(Unit, gc_queue, m->gc_queue, meta);
- meta->in_gc_queue = false;
+ LIST_REMOVE(Unit, gc_queue, m->gc_queue, u);
+ u->in_gc_queue = false;
n++;
- if (meta->gc_marker == gc_marker + GC_OFFSET_BAD ||
- meta->gc_marker == gc_marker + GC_OFFSET_UNSURE) {
- log_debug("Collecting %s", meta->id);
- meta->gc_marker = gc_marker + GC_OFFSET_BAD;
- unit_add_to_cleanup_queue((Unit*) meta);
+ if (u->gc_marker == gc_marker + GC_OFFSET_BAD ||
+ u->gc_marker == gc_marker + GC_OFFSET_UNSURE) {
+ log_debug("Collecting %s", u->id);
+ u->gc_marker = gc_marker + GC_OFFSET_BAD;
+ unit_add_to_cleanup_queue(u);
}
}
@@ -1768,7 +1768,7 @@ Unit *manager_get_unit(Manager *m, const char *name) {
}
unsigned manager_dispatch_load_queue(Manager *m) {
- Unit *meta;
+ Unit *u;
unsigned n = 0;
assert(m);
@@ -1782,10 +1782,10 @@ unsigned manager_dispatch_load_queue(Manager *m) {
/* Dispatches the load queue. Takes a unit from the queue and
* tries to load its data until the queue is empty */
- while ((meta = m->load_queue)) {
- assert(meta->in_load_queue);
+ while ((u = m->load_queue)) {
+ assert(u->in_load_queue);
- unit_load((Unit*) meta);
+ unit_load(u);
n++;
}
@@ -1929,7 +1929,7 @@ unsigned manager_dispatch_run_queue(Manager *m) {
unsigned manager_dispatch_dbus_queue(Manager *m) {
Job *j;
- Unit *meta;
+ Unit *u;
unsigned n = 0;
assert(m);
@@ -1939,10 +1939,10 @@ unsigned manager_dispatch_dbus_queue(Manager *m) {
m->dispatching_dbus_queue = true;
- while ((meta = m->dbus_unit_queue)) {
- assert(meta->in_dbus_queue);
+ while ((u = m->dbus_unit_queue)) {
+ assert(u->in_dbus_queue);
- bus_unit_send_change_signal((Unit*) meta);
+ bus_unit_send_change_signal(u);
n++;
}
diff --git a/src/mount.c b/src/mount.c
index 5c45686..6d0af4e 100644
--- a/src/mount.c
+++ b/src/mount.c
@@ -160,7 +160,7 @@ static int mount_add_mount_links(Mount *m) {
* above us in the hierarchy */
LIST_FOREACH(units_by_type, other, UNIT(m)->manager->units_by_type[UNIT_MOUNT]) {
- Mount *n = (Mount*) other;
+ Mount *n = MOUNT(other);
MountParameters *pn;
if (n == m)
@@ -217,7 +217,7 @@ static int mount_add_swap_links(Mount *m) {
assert(m);
LIST_FOREACH(units_by_type, other, UNIT(m)->manager->units_by_type[UNIT_SWAP])
- if ((r = swap_add_one_mount_link((Swap*) other, m)) < 0)
+ if ((r = swap_add_one_mount_link(SWAP(other), m)) < 0)
return r;
return 0;
@@ -230,7 +230,7 @@ static int mount_add_path_links(Mount *m) {
assert(m);
LIST_FOREACH(units_by_type, other, UNIT(m)->manager->units_by_type[UNIT_PATH])
- if ((r = path_add_one_mount_link((Path*) other, m)) < 0)
+ if ((r = path_add_one_mount_link(PATH(other), m)) < 0)
return r;
return 0;
@@ -243,7 +243,7 @@ static int mount_add_automount_links(Mount *m) {
assert(m);
LIST_FOREACH(units_by_type, other, UNIT(m)->manager->units_by_type[UNIT_AUTOMOUNT])
- if ((r = automount_add_one_mount_link((Automount*) other, m)) < 0)
+ if ((r = automount_add_one_mount_link(AUTOMOUNT(other), m)) < 0)
return r;
return 0;
@@ -256,7 +256,7 @@ static int mount_add_socket_links(Mount *m) {
assert(m);
LIST_FOREACH(units_by_type, other, UNIT(m)->manager->units_by_type[UNIT_SOCKET])
- if ((r = socket_add_one_mount_link((Socket*) other, m)) < 0)
+ if ((r = socket_add_one_mount_link(SOCKET(other), m)) < 0)
return r;
return 0;
@@ -1679,7 +1679,7 @@ fail:
}
void mount_fd_event(Manager *m, int events) {
- Unit *meta;
+ Unit *u;
int r;
assert(m);
@@ -1693,8 +1693,8 @@ void mount_fd_event(Manager *m, int events) {
log_error("Failed to reread /proc/self/mountinfo: %s", strerror(-r));
/* Reset flags, just in case, for later calls */
- LIST_FOREACH(units_by_type, meta, m->units_by_type[UNIT_MOUNT]) {
- Mount *mount = (Mount*) meta;
+ LIST_FOREACH(units_by_type, u, m->units_by_type[UNIT_MOUNT]) {
+ Mount *mount = MOUNT(u);
mount->is_mounted = mount->just_mounted = mount->just_changed = false;
}
@@ -1704,8 +1704,8 @@ void mount_fd_event(Manager *m, int events) {
manager_dispatch_load_queue(m);
- LIST_FOREACH(units_by_type, meta, m->units_by_type[UNIT_MOUNT]) {
- Mount *mount = (Mount*) meta;
+ LIST_FOREACH(units_by_type, u, m->units_by_type[UNIT_MOUNT]) {
+ Mount *mount = MOUNT(u);
if (!mount->is_mounted) {
/* This has just been unmounted. */
diff --git a/src/path.c b/src/path.c
index c8086a8..a16d3fa 100644
--- a/src/path.c
+++ b/src/path.c
@@ -287,7 +287,7 @@ static int path_add_mount_links(Path *p) {
assert(p);
LIST_FOREACH(units_by_type, other, UNIT(p)->manager->units_by_type[UNIT_MOUNT])
- if ((r = path_add_one_mount_link(p, (Mount*) other)) < 0)
+ if ((r = path_add_one_mount_link(p, MOUNT(other))) < 0)
return r;
return 0;
diff --git a/src/service.c b/src/service.c
index a84cee1..0a5c35e 100644
--- a/src/service.c
+++ b/src/service.c
@@ -376,7 +376,7 @@ static int sysv_fix_order(Service *s) {
UnitDependency d;
bool special_s, special_t;
- t = (Service*) other;
+ t = SERVICE(other);
if (s == t)
continue;
@@ -1023,7 +1023,7 @@ static int fsck_fix_order(Service *s) {
Service *t;
UnitDependency d;
- t = (Service*) other;
+ t = SERVICE(other);
if (s == t)
continue;
diff --git a/src/socket.c b/src/socket.c
index e0ddcef..b2bb080 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -274,7 +274,7 @@ static int socket_add_mount_links(Socket *s) {
assert(s);
LIST_FOREACH(units_by_type, other, UNIT(s)->manager->units_by_type[UNIT_MOUNT])
- if ((r = socket_add_one_mount_link(s, (Mount*) other)) < 0)
+ if ((r = socket_add_one_mount_link(s, MOUNT(other))) < 0)
return r;
return 0;
diff --git a/src/swap.c b/src/swap.c
index ff62b1d..b4a5b3c 100644
--- a/src/swap.c
+++ b/src/swap.c
@@ -157,7 +157,7 @@ static int swap_add_mount_links(Swap *s) {
assert(s);
LIST_FOREACH(units_by_type, other, UNIT(s)->manager->units_by_type[UNIT_MOUNT])
- if ((r = swap_add_one_mount_link(s, (Mount*) other)) < 0)
+ if ((r = swap_add_one_mount_link(s, MOUNT(other))) < 0)
return r;
return 0;
@@ -1096,7 +1096,7 @@ int swap_dispatch_reload(Manager *m) {
}
int swap_fd_event(Manager *m, int events) {
- Unit *meta;
+ Unit *u;
int r;
assert(m);
@@ -1106,8 +1106,8 @@ int swap_fd_event(Manager *m, int events) {
log_error("Failed to reread /proc/swaps: %s", strerror(-r));
/* Reset flags, just in case, for late calls */
- LIST_FOREACH(units_by_type, meta, m->units_by_type[UNIT_SWAP]) {
- Swap *swap = (Swap*) meta;
+ LIST_FOREACH(units_by_type, u, m->units_by_type[UNIT_SWAP]) {
+ Swap *swap = SWAP(u);
swap->is_active = swap->just_activated = false;
}
@@ -1117,8 +1117,8 @@ int swap_fd_event(Manager *m, int events) {
manager_dispatch_load_queue(m);
- LIST_FOREACH(units_by_type, meta, m->units_by_type[UNIT_SWAP]) {
- Swap *swap = (Swap*) meta;
+ LIST_FOREACH(units_by_type, u, m->units_by_type[UNIT_SWAP]) {
+ Swap *swap = SWAP(u);
if (!swap->is_active) {
/* This has just been deactivated */
commit 1124fe6f01b1d59d016c238026f20380f38d98dc
Author: Michal Schmidt <mschmidt at redhat.com>
Date: Sun Jan 15 12:25:20 2012 +0100
unit: use the UNIT() macro consistently
The UNIT() macro upcasts from specific unit types to the base Unit.
Use it everywhere, rather than accessing the 'meta' member directly.
diff --git a/src/automount.c b/src/automount.c
index 6858e56..3c75335 100644
--- a/src/automount.c
+++ b/src/automount.c
@@ -59,7 +59,7 @@ static void automount_init(Unit *u) {
a->directory_mode = 0755;
- a->meta.ignore_on_isolate = true;
+ UNIT(a)->ignore_on_isolate = true;
}
static void repeat_unmout(const char *path) {
@@ -94,8 +94,8 @@ static void unmount_autofs(Automount *a) {
/* If we reload/reexecute things we keep the mount point
* around */
if (a->where &&
- (a->meta.manager->exit_code != MANAGER_RELOAD &&
- a->meta.manager->exit_code != MANAGER_REEXECUTE))
+ (UNIT(a)->manager->exit_code != MANAGER_RELOAD &&
+ UNIT(a)->manager->exit_code != MANAGER_REEXECUTE))
repeat_unmout(a->where);
}
@@ -120,8 +120,8 @@ int automount_add_one_mount_link(Automount *a, Mount *m) {
assert(a);
assert(m);
- if (a->meta.load_state != UNIT_LOADED ||
- m->meta.load_state != UNIT_LOADED)
+ if (UNIT(a)->load_state != UNIT_LOADED ||
+ UNIT(m)->load_state != UNIT_LOADED)
return 0;
if (!path_startswith(a->where, m->where))
@@ -142,7 +142,7 @@ static int automount_add_mount_links(Automount *a) {
assert(a);
- LIST_FOREACH(units_by_type, other, a->meta.manager->units_by_type[UNIT_MOUNT])
+ LIST_FOREACH(units_by_type, other, UNIT(a)->manager->units_by_type[UNIT_MOUNT])
if ((r = automount_add_one_mount_link(a, (Mount*) other)) < 0)
return r;
@@ -154,7 +154,7 @@ static int automount_add_default_dependencies(Automount *a) {
assert(a);
- if (a->meta.manager->running_as == MANAGER_SYSTEM) {
+ if (UNIT(a)->manager->running_as == MANAGER_SYSTEM) {
if ((r = unit_add_dependency_by_name(UNIT(a), UNIT_BEFORE, SPECIAL_BASIC_TARGET, NULL, true)) < 0)
return r;
@@ -171,7 +171,7 @@ static int automount_verify(Automount *a) {
char *e;
assert(a);
- if (a->meta.load_state != UNIT_LOADED)
+ if (UNIT(a)->load_state != UNIT_LOADED)
return 0;
if (path_equal(a->where, "/")) {
@@ -186,7 +186,7 @@ static int automount_verify(Automount *a) {
free(e);
if (!b) {
- log_error("%s's Where setting doesn't match unit name. Refusing.", a->meta.id);
+ log_error("%s's Where setting doesn't match unit name. Refusing.", UNIT(a)->id);
return -EINVAL;
}
@@ -226,7 +226,7 @@ static int automount_load(Unit *u) {
if (r < 0)
return r;
- if (a->meta.default_dependencies)
+ if (UNIT(a)->default_dependencies)
if ((r = automount_add_default_dependencies(a)) < 0)
return r;
}
@@ -247,7 +247,7 @@ static void automount_set_state(Automount *a, AutomountState state) {
if (state != old_state)
log_debug("%s changed %s -> %s",
- a->meta.id,
+ UNIT(a)->id,
automount_state_to_string(old_state),
automount_state_to_string(state));
@@ -442,7 +442,7 @@ int automount_send_ready(Automount *a, int status) {
if (set_isempty(a->tokens))
return 0;
- if ((ioctl_fd = open_ioctl_fd(a->meta.manager->dev_autofs_fd, a->where, a->dev_id)) < 0) {
+ if ((ioctl_fd = open_ioctl_fd(UNIT(a)->manager->dev_autofs_fd, a->where, a->dev_id)) < 0) {
r = ioctl_fd;
goto fail;
}
@@ -463,7 +463,7 @@ int automount_send_ready(Automount *a, int status) {
* if you pass a positive status code here, the kernel will
* freeze! Yay! */
- if ((k = autofs_send_ready(a->meta.manager->dev_autofs_fd,
+ if ((k = autofs_send_ready(UNIT(a)->manager->dev_autofs_fd,
ioctl_fd,
token,
status)) < 0)
@@ -491,7 +491,7 @@ static void automount_enter_waiting(Automount *a) {
if (a->tokens)
set_clear(a->tokens);
- if ((dev_autofs_fd = open_dev_autofs(a->meta.manager)) < 0) {
+ if ((dev_autofs_fd = open_dev_autofs(UNIT(a)->manager)) < 0) {
r = dev_autofs_fd;
goto fail;
}
@@ -581,7 +581,7 @@ static void automount_enter_runnning(Automount *a) {
/* We don't take mount requests anymore if we are supposed to
* shut down anyway */
if (unit_pending_inactive(UNIT(a))) {
- log_debug("Suppressing automount request on %s since unit stop is scheduled.", a->meta.id);
+ log_debug("Suppressing automount request on %s since unit stop is scheduled.", UNIT(a)->id);
automount_send_ready(a, -EHOSTDOWN);
return;
}
@@ -590,14 +590,14 @@ static void automount_enter_runnning(Automount *a) {
/* Before we do anything, let's see if somebody is playing games with us? */
if (lstat(a->where, &st) < 0) {
- log_warning("%s failed to stat automount point: %m", a->meta.id);
+ log_warning("%s failed to stat automount point: %m", UNIT(a)->id);
goto fail;
}
if (!S_ISDIR(st.st_mode) || st.st_dev != a->dev_id)
- log_info("%s's automount point already active?", a->meta.id);
- else if ((r = manager_add_job(a->meta.manager, JOB_START, UNIT_DEREF(a->mount), JOB_REPLACE, true, &error, NULL)) < 0) {
- log_warning("%s failed to queue mount startup job: %s", a->meta.id, bus_error(&error, r));
+ log_info("%s's automount point already active?", UNIT(a)->id);
+ else if ((r = manager_add_job(UNIT(a)->manager, JOB_START, UNIT_DEREF(a->mount), JOB_REPLACE, true, &error, NULL)) < 0) {
+ log_warning("%s failed to queue mount startup job: %s", UNIT(a)->id, bus_error(&error, r));
goto fail;
}
diff --git a/src/device.c b/src/device.c
index 9e5bd30..0575379 100644
--- a/src/device.c
+++ b/src/device.c
@@ -46,13 +46,13 @@ static void device_unset_sysfs(Device *d) {
/* Remove this unit from the chain of devices which share the
* same sysfs path. */
- first = hashmap_get(d->meta.manager->devices_by_sysfs, d->sysfs);
+ first = hashmap_get(UNIT(d)->manager->devices_by_sysfs, d->sysfs);
LIST_REMOVE(Device, same_sysfs, first, d);
if (first)
- hashmap_remove_and_replace(d->meta.manager->devices_by_sysfs, d->sysfs, first->sysfs, first);
+ hashmap_remove_and_replace(UNIT(d)->manager->devices_by_sysfs, d->sysfs, first->sysfs, first);
else
- hashmap_remove(d->meta.manager->devices_by_sysfs, d->sysfs);
+ hashmap_remove(UNIT(d)->manager->devices_by_sysfs, d->sysfs);
free(d->sysfs);
d->sysfs = NULL;
@@ -62,17 +62,17 @@ static void device_init(Unit *u) {
Device *d = DEVICE(u);
assert(d);
- assert(d->meta.load_state == UNIT_STUB);
+ assert(UNIT(d)->load_state == UNIT_STUB);
/* In contrast to all other unit types we timeout jobs waiting
* for devices by default. This is because they otherwise wait
* indefinitely for plugged in devices, something which cannot
* happen for the other units since their operations time out
* anyway. */
- d->meta.job_timeout = DEFAULT_TIMEOUT_USEC;
+ UNIT(d)->job_timeout = DEFAULT_TIMEOUT_USEC;
- d->meta.ignore_on_isolate = true;
- d->meta.ignore_on_snapshot = true;
+ UNIT(d)->ignore_on_isolate = true;
+ UNIT(d)->ignore_on_snapshot = true;
}
static void device_done(Unit *u) {
@@ -92,7 +92,7 @@ static void device_set_state(Device *d, DeviceState state) {
if (state != old_state)
log_debug("%s changed %s -> %s",
- d->meta.id,
+ UNIT(d)->id,
device_state_to_string(old_state),
device_state_to_string(state));
@@ -394,11 +394,11 @@ static Unit *device_following(Unit *u) {
/* Make everybody follow the unit that's named after the sysfs path */
for (other = d->same_sysfs_next; other; other = other->same_sysfs_next)
- if (startswith(other->meta.id, "sys-"))
+ if (startswith(UNIT(other)->id, "sys-"))
return UNIT(other);
for (other = d->same_sysfs_prev; other; other = other->same_sysfs_prev) {
- if (startswith(other->meta.id, "sys-"))
+ if (startswith(UNIT(other)->id, "sys-"))
return UNIT(other);
first = other;
diff --git a/src/load-fragment.c b/src/load-fragment.c
index 213b1e2..0961d94 100644
--- a/src/load-fragment.c
+++ b/src/load-fragment.c
@@ -1276,7 +1276,7 @@ int config_parse_timer_unit(
return 0;
}
- r = manager_load_unit(t->meta.manager, rvalue, NULL, NULL, &u);
+ r = manager_load_unit(UNIT(t)->manager, rvalue, NULL, NULL, &u);
if (r < 0) {
log_error("[%s:%u] Failed to load unit %s, ignoring: %s", filename, line, rvalue, bus_error(&error, r));
dbus_error_free(&error);
@@ -1362,7 +1362,7 @@ int config_parse_path_unit(
return 0;
}
- if ((r = manager_load_unit(t->meta.manager, rvalue, NULL, &error, &u)) < 0) {
+ if ((r = manager_load_unit(UNIT(t)->manager, rvalue, NULL, &error, &u)) < 0) {
log_error("[%s:%u] Failed to load unit %s, ignoring: %s", filename, line, rvalue, bus_error(&error, r));
dbus_error_free(&error);
return 0;
@@ -1400,7 +1400,7 @@ int config_parse_socket_service(
return 0;
}
- r = manager_load_unit(s->meta.manager, rvalue, NULL, &error, &x);
+ r = manager_load_unit(UNIT(s)->manager, rvalue, NULL, &error, &x);
if (r < 0) {
log_error("[%s:%u] Failed to load unit %s, ignoring: %s", filename, line, rvalue, bus_error(&error, r));
dbus_error_free(&error);
diff --git a/src/mount.c b/src/mount.c
index 9f7ce69..5c45686 100644
--- a/src/mount.c
+++ b/src/mount.c
@@ -83,7 +83,7 @@ static void mount_init(Unit *u) {
m->control_command_id = _MOUNT_EXEC_COMMAND_INVALID;
- m->meta.ignore_on_isolate = true;
+ UNIT(m)->ignore_on_isolate = true;
}
static void mount_unwatch_control_pid(Mount *m) {
@@ -159,14 +159,14 @@ static int mount_add_mount_links(Mount *m) {
/* Adds in links to other mount points that might lie below or
* above us in the hierarchy */
- LIST_FOREACH(units_by_type, other, m->meta.manager->units_by_type[UNIT_MOUNT]) {
+ LIST_FOREACH(units_by_type, other, UNIT(m)->manager->units_by_type[UNIT_MOUNT]) {
Mount *n = (Mount*) other;
MountParameters *pn;
if (n == m)
continue;
- if (n->meta.load_state != UNIT_LOADED)
+ if (UNIT(n)->load_state != UNIT_LOADED)
continue;
pn = get_mount_parameters_configured(n);
@@ -216,7 +216,7 @@ static int mount_add_swap_links(Mount *m) {
assert(m);
- LIST_FOREACH(units_by_type, other, m->meta.manager->units_by_type[UNIT_SWAP])
+ LIST_FOREACH(units_by_type, other, UNIT(m)->manager->units_by_type[UNIT_SWAP])
if ((r = swap_add_one_mount_link((Swap*) other, m)) < 0)
return r;
@@ -229,7 +229,7 @@ static int mount_add_path_links(Mount *m) {
assert(m);
- LIST_FOREACH(units_by_type, other, m->meta.manager->units_by_type[UNIT_PATH])
+ LIST_FOREACH(units_by_type, other, UNIT(m)->manager->units_by_type[UNIT_PATH])
if ((r = path_add_one_mount_link((Path*) other, m)) < 0)
return r;
@@ -242,7 +242,7 @@ static int mount_add_automount_links(Mount *m) {
assert(m);
- LIST_FOREACH(units_by_type, other, m->meta.manager->units_by_type[UNIT_AUTOMOUNT])
+ LIST_FOREACH(units_by_type, other, UNIT(m)->manager->units_by_type[UNIT_AUTOMOUNT])
if ((r = automount_add_one_mount_link((Automount*) other, m)) < 0)
return r;
@@ -255,7 +255,7 @@ static int mount_add_socket_links(Mount *m) {
assert(m);
- LIST_FOREACH(units_by_type, other, m->meta.manager->units_by_type[UNIT_SOCKET])
+ LIST_FOREACH(units_by_type, other, UNIT(m)->manager->units_by_type[UNIT_SOCKET])
if ((r = socket_add_one_mount_link((Socket*) other, m)) < 0)
return r;
@@ -328,7 +328,7 @@ static int mount_add_fstab_links(Mount *m) {
assert(m);
- if (m->meta.manager->running_as != MANAGER_SYSTEM)
+ if (UNIT(m)->manager->running_as != MANAGER_SYSTEM)
return 0;
if (!(p = get_mount_parameters_configured(m)))
@@ -346,7 +346,7 @@ static int mount_add_fstab_links(Mount *m) {
automount ||
mount_test_option(p->options, "comment=systemd.mount") ||
mount_test_option(p->options, "x-systemd-mount") ||
- m->meta.manager->mount_auto;
+ UNIT(m)->manager->mount_auto;
if (mount_is_network(p)) {
target = SPECIAL_REMOTE_FS_TARGET;
@@ -357,7 +357,7 @@ static int mount_add_fstab_links(Mount *m) {
after = SPECIAL_LOCAL_FS_PRE_TARGET;
}
- if ((r = manager_load_unit(m->meta.manager, target, NULL, NULL, &tu)) < 0)
+ if ((r = manager_load_unit(UNIT(m)->manager, target, NULL, NULL, &tu)) < 0)
return r;
if (after)
@@ -438,7 +438,7 @@ static int mount_add_device_links(Mount *m) {
if (!(name = unit_name_from_path_instance("fsck", p->what, ".service")))
return -ENOMEM;
- if ((r = manager_load_unit_prepare(m->meta.manager, name, NULL, NULL, &fsck)) < 0) {
+ if ((r = manager_load_unit_prepare(UNIT(m)->manager, name, NULL, NULL, &fsck)) < 0) {
log_warning("Failed to prepare unit %s: %s", name, strerror(-r));
free(name);
return r;
@@ -461,7 +461,7 @@ static int mount_add_default_dependencies(Mount *m) {
assert(m);
- if (m->meta.manager->running_as != MANAGER_SYSTEM)
+ if (UNIT(m)->manager->running_as != MANAGER_SYSTEM)
return 0;
p = get_mount_parameters_configured(m);
@@ -516,7 +516,7 @@ static int mount_fix_timeouts(Mount *m) {
return r;
}
- SET_FOREACH(other, m->meta.dependencies[UNIT_AFTER], i) {
+ SET_FOREACH(other, UNIT(m)->dependencies[UNIT_AFTER], i) {
if (other->type != UNIT_DEVICE)
continue;
@@ -531,7 +531,7 @@ static int mount_verify(Mount *m) {
char *e;
assert(m);
- if (m->meta.load_state != UNIT_LOADED)
+ if (UNIT(m)->load_state != UNIT_LOADED)
return 0;
if (!m->from_etc_fstab && !m->from_fragment && !m->from_proc_self_mountinfo)
@@ -544,7 +544,7 @@ static int mount_verify(Mount *m) {
free(e);
if (!b) {
- log_error("%s's Where setting doesn't match unit name. Refusing.", m->meta.id);
+ log_error("%s's Where setting doesn't match unit name. Refusing.", UNIT(m)->id);
return -EINVAL;
}
@@ -553,13 +553,13 @@ static int mount_verify(Mount *m) {
return -EINVAL;
}
- if (m->meta.fragment_path && !m->parameters_fragment.what) {
- log_error("%s's What setting is missing. Refusing.", m->meta.id);
+ if (UNIT(m)->fragment_path && !m->parameters_fragment.what) {
+ log_error("%s's What setting is missing. Refusing.", UNIT(m)->id);
return -EBADMSG;
}
if (m->exec_context.pam_name && m->exec_context.kill_mode != KILL_CONTROL_GROUP) {
- log_error("%s has PAM enabled. Kill mode must be set to 'control-group'. Refusing.", m->meta.id);
+ log_error("%s has PAM enabled. Kill mode must be set to 'control-group'. Refusing.", UNIT(m)->id);
return -EINVAL;
}
@@ -581,7 +581,7 @@ static int mount_load(Unit *u) {
if ((r = unit_add_exec_dependencies(u, &m->exec_context)) < 0)
return r;
- if (m->meta.fragment_path)
+ if (UNIT(m)->fragment_path)
m->from_fragment = true;
if (!m->where)
@@ -590,7 +590,7 @@ static int mount_load(Unit *u) {
path_kill_slashes(m->where);
- if (!m->meta.description)
+ if (!UNIT(m)->description)
if ((r = unit_set_description(u, m->where)) < 0)
return r;
@@ -615,7 +615,7 @@ static int mount_load(Unit *u) {
if ((r = mount_add_fstab_links(m)) < 0)
return r;
- if (m->meta.default_dependencies)
+ if (UNIT(m)->default_dependencies)
if ((r = mount_add_default_dependencies(m)) < 0)
return r;
@@ -635,7 +635,7 @@ static int mount_notify_automount(Mount *m, int status) {
assert(m);
- SET_FOREACH(p, m->meta.dependencies[UNIT_TRIGGERED_BY], i)
+ SET_FOREACH(p, UNIT(m)->dependencies[UNIT_TRIGGERED_BY], i)
if (p->type == UNIT_AUTOMOUNT) {
r = automount_send_ready(AUTOMOUNT(p), status);
if (r < 0)
@@ -684,7 +684,7 @@ static void mount_set_state(Mount *m, MountState state) {
if (state != old_state)
log_debug("%s changed %s -> %s",
- m->meta.id,
+ UNIT(m)->id,
mount_state_to_string(old_state),
mount_state_to_string(state));
@@ -786,13 +786,13 @@ static int mount_spawn(Mount *m, ExecCommand *c, pid_t *_pid) {
NULL,
&m->exec_context,
NULL, 0,
- m->meta.manager->environment,
+ UNIT(m)->manager->environment,
true,
true,
true,
- m->meta.manager->confirm_spawn,
- m->meta.cgroup_bondings,
- m->meta.cgroup_attributes,
+ UNIT(m)->manager->confirm_spawn,
+ UNIT(m)->cgroup_bondings,
+ UNIT(m)->cgroup_attributes,
&pid)) < 0)
goto fail;
@@ -863,7 +863,7 @@ static void mount_enter_signal(Mount *m, MountState state, bool success) {
if ((r = set_put(pid_set, LONG_TO_PTR(m->control_pid))) < 0)
goto fail;
- if ((r = cgroup_bonding_kill_list(m->meta.cgroup_bondings, sig, true, pid_set)) < 0) {
+ if ((r = cgroup_bonding_kill_list(UNIT(m)->cgroup_bondings, sig, true, pid_set)) < 0) {
if (r != -EAGAIN && r != -ESRCH && r != -ENOENT)
log_warning("Failed to kill control group: %s", strerror(-r));
} else if (r > 0)
@@ -887,7 +887,7 @@ static void mount_enter_signal(Mount *m, MountState state, bool success) {
return;
fail:
- log_warning("%s failed to kill processes: %s", m->meta.id, strerror(-r));
+ log_warning("%s failed to kill processes: %s", UNIT(m)->id, strerror(-r));
if (state == MOUNT_REMOUNTING_SIGTERM || state == MOUNT_REMOUNTING_SIGKILL)
mount_enter_mounted(m, false);
@@ -926,7 +926,7 @@ static void mount_enter_unmounting(Mount *m, bool success) {
return;
fail:
- log_warning("%s failed to run 'umount' task: %s", m->meta.id, strerror(-r));
+ log_warning("%s failed to run 'umount' task: %s", UNIT(m)->id, strerror(-r));
mount_enter_mounted(m, false);
}
@@ -977,7 +977,7 @@ static void mount_enter_mounting(Mount *m) {
return;
fail:
- log_warning("%s failed to run 'mount' task: %s", m->meta.id, strerror(-r));
+ log_warning("%s failed to run 'mount' task: %s", UNIT(m)->id, strerror(-r));
mount_enter_dead(m, false);
}
@@ -1045,7 +1045,7 @@ static void mount_enter_remounting(Mount *m, bool success) {
return;
fail:
- log_warning("%s failed to run 'remount' task: %s", m->meta.id, strerror(-r));
+ log_warning("%s failed to run 'remount' task: %s", UNIT(m)->id, strerror(-r));
m->reload_failure = true;
mount_enter_mounted(m, true);
}
@@ -1801,7 +1801,7 @@ static int mount_kill(Unit *u, KillWho who, KillMode mode, int signo, DBusError
goto finish;
}
- if ((q = cgroup_bonding_kill_list(m->meta.cgroup_bondings, signo, false, pid_set)) < 0)
+ if ((q = cgroup_bonding_kill_list(UNIT(m)->cgroup_bondings, signo, false, pid_set)) < 0)
if (q != -EAGAIN && q != -ESRCH && q != -ENOENT)
r = q;
}
diff --git a/src/path.c b/src/path.c
index bfb5cdf..c8086a8 100644
--- a/src/path.c
+++ b/src/path.c
@@ -264,8 +264,8 @@ int path_add_one_mount_link(Path *p, Mount *m) {
assert(p);
assert(m);
- if (p->meta.load_state != UNIT_LOADED ||
- m->meta.load_state != UNIT_LOADED)
+ if (UNIT(p)->load_state != UNIT_LOADED ||
+ UNIT(m)->load_state != UNIT_LOADED)
return 0;
LIST_FOREACH(spec, s, p->specs) {
@@ -286,7 +286,7 @@ static int path_add_mount_links(Path *p) {
assert(p);
- LIST_FOREACH(units_by_type, other, p->meta.manager->units_by_type[UNIT_MOUNT])
+ LIST_FOREACH(units_by_type, other, UNIT(p)->manager->units_by_type[UNIT_MOUNT])
if ((r = path_add_one_mount_link(p, (Mount*) other)) < 0)
return r;
@@ -296,11 +296,11 @@ static int path_add_mount_links(Path *p) {
static int path_verify(Path *p) {
assert(p);
- if (p->meta.load_state != UNIT_LOADED)
+ if (UNIT(p)->load_state != UNIT_LOADED)
return 0;
if (!p->specs) {
- log_error("%s lacks path setting. Refusing.", p->meta.id);
+ log_error("%s lacks path setting. Refusing.", UNIT(p)->id);
return -EINVAL;
}
@@ -312,7 +312,7 @@ static int path_add_default_dependencies(Path *p) {
assert(p);
- if (p->meta.manager->running_as == MANAGER_SYSTEM) {
+ if (UNIT(p)->manager->running_as == MANAGER_SYSTEM) {
if ((r = unit_add_dependency_by_name(UNIT(p), UNIT_BEFORE, SPECIAL_BASIC_TARGET, NULL, true)) < 0)
return r;
@@ -352,7 +352,7 @@ static int path_load(Unit *u) {
if ((r = path_add_mount_links(p)) < 0)
return r;
- if (p->meta.default_dependencies)
+ if (UNIT(p)->default_dependencies)
if ((r = path_add_default_dependencies(p)) < 0)
return r;
}
@@ -416,7 +416,7 @@ static void path_set_state(Path *p, PathState state) {
if (state != old_state)
log_debug("%s changed %s -> %s",
- p->meta.id,
+ UNIT(p)->id,
path_state_to_string(old_state),
path_state_to_string(state));
@@ -460,10 +460,10 @@ static void path_enter_running(Path *p) {
dbus_error_init(&error);
/* Don't start job if we are supposed to go down */
- if (p->meta.job && p->meta.job->type == JOB_STOP)
+ if (UNIT(p)->job && UNIT(p)->job->type == JOB_STOP)
return;
- if ((r = manager_add_job(p->meta.manager, JOB_START, UNIT_DEREF(p->unit), JOB_REPLACE, true, &error, NULL)) < 0)
+ if ((r = manager_add_job(UNIT(p)->manager, JOB_START, UNIT_DEREF(p->unit), JOB_REPLACE, true, &error, NULL)) < 0)
goto fail;
p->inotify_triggered = false;
@@ -475,7 +475,7 @@ static void path_enter_running(Path *p) {
return;
fail:
- log_warning("%s failed to queue unit startup job: %s", p->meta.id, bus_error(&error, r));
+ log_warning("%s failed to queue unit startup job: %s", UNIT(p)->id, bus_error(&error, r));
path_enter_dead(p, false);
dbus_error_free(&error);
@@ -502,7 +502,7 @@ static void path_enter_waiting(Path *p, bool initial, bool recheck) {
if (recheck)
if (path_check_good(p, initial)) {
- log_debug("%s got triggered.", p->meta.id);
+ log_debug("%s got triggered.", UNIT(p)->id);
path_enter_running(p);
return;
}
@@ -516,7 +516,7 @@ static void path_enter_waiting(Path *p, bool initial, bool recheck) {
if (recheck)
if (path_check_good(p, false)) {
- log_debug("%s got triggered.", p->meta.id);
+ log_debug("%s got triggered.", UNIT(p)->id);
path_enter_running(p);
return;
}
@@ -525,7 +525,7 @@ static void path_enter_waiting(Path *p, bool initial, bool recheck) {
return;
fail:
- log_warning("%s failed to enter waiting state: %s", p->meta.id, strerror(-r));
+ log_warning("%s failed to enter waiting state: %s", UNIT(p)->id, strerror(-r));
path_enter_dead(p, false);
}
@@ -675,7 +675,7 @@ void path_unit_notify(Unit *u, UnitActiveState new_state) {
p = PATH(k);
if (p->state == PATH_RUNNING && new_state == UNIT_INACTIVE) {
- log_debug("%s got notified about unit deactivation.", p->meta.id);
+ log_debug("%s got notified about unit deactivation.", UNIT(p)->id);
/* Hmm, so inotify was triggered since the
* last activation, so I guess we need to
diff --git a/src/service.c b/src/service.c
index 5543077..a84cee1 100644
--- a/src/service.c
+++ b/src/service.c
@@ -163,7 +163,7 @@ static int service_set_main_pid(Service *s, pid_t pid) {
if (get_parent_of_pid(pid, &ppid) >= 0 && ppid != getpid()) {
log_warning("%s: Supervising process %lu which is not our child. We'll most likely not notice when it exits.",
- s->meta.id, (unsigned long) pid);
+ UNIT(s)->id, (unsigned long) pid);
s->main_pid_alien = true;
} else
@@ -371,7 +371,7 @@ static int sysv_fix_order(Service *s) {
/* For each pair of services where at least one lacks a LSB
* header, we use the start priority value to order things. */
- LIST_FOREACH(units_by_type, other, s->meta.manager->units_by_type[UNIT_SERVICE]) {
+ LIST_FOREACH(units_by_type, other, UNIT(s)->manager->units_by_type[UNIT_SERVICE]) {
Service *t;
UnitDependency d;
bool special_s, special_t;
@@ -381,7 +381,7 @@ static int sysv_fix_order(Service *s) {
if (s == t)
continue;
- if (t->meta.load_state != UNIT_LOADED)
+ if (UNIT(t)->load_state != UNIT_LOADED)
continue;
if (t->sysv_start_priority < 0)
@@ -389,8 +389,8 @@ static int sysv_fix_order(Service *s) {
/* If both units have modern headers we don't care
* about the priorities */
- if ((s->meta.fragment_path || s->sysv_has_lsb) &&
- (t->meta.fragment_path || t->sysv_has_lsb))
+ if ((UNIT(s)->fragment_path || s->sysv_has_lsb) &&
+ (UNIT(t)->fragment_path || t->sysv_has_lsb))
continue;
special_s = s->sysv_runlevels && !chars_intersect(RUNLEVELS_UP, s->sysv_runlevels);
@@ -827,7 +827,7 @@ static int service_load_sysv_path(Service *s, const char *path) {
* needed for early boot) and don't create any links
* to it. */
- s->meta.default_dependencies = false;
+ UNIT(s)->default_dependencies = false;
/* Don't timeout special services during boot (like fsck) */
s->timeout_usec = 0;
@@ -840,7 +840,7 @@ static int service_load_sysv_path(Service *s, const char *path) {
s->guess_main_pid = false;
s->restart = SERVICE_RESTART_NO;
- if (s->meta.manager->sysv_console)
+ if (UNIT(s)->manager->sysv_console)
s->exec_context.std_output = EXEC_OUTPUT_JOURNAL_AND_CONSOLE;
s->exec_context.kill_mode = KILL_PROCESS;
@@ -912,7 +912,7 @@ static int service_load_sysv_name(Service *s, const char *name) {
return -ENOENT;
#endif
- STRV_FOREACH(p, s->meta.manager->lookup_paths.sysvinit_path) {
+ STRV_FOREACH(p, UNIT(s)->manager->lookup_paths.sysvinit_path) {
char *path;
int r;
@@ -926,7 +926,7 @@ static int service_load_sysv_name(Service *s, const char *name) {
r = service_load_sysv_path(s, path);
#if defined(TARGET_DEBIAN) || defined(TARGET_UBUNTU) || defined(TARGET_ANGSTROM)
- if (r >= 0 && s->meta.load_state == UNIT_STUB) {
+ if (r >= 0 && UNIT(s)->load_state == UNIT_STUB) {
/* Try Debian style *.sh source'able init scripts */
strcat(path, ".sh");
r = service_load_sysv_path(s, path);
@@ -935,7 +935,7 @@ static int service_load_sysv_name(Service *s, const char *name) {
free(path);
#ifdef TARGET_SUSE
- if (r >= 0 && s->meta.load_state == UNIT_STUB) {
+ if (r >= 0 && UNIT(s)->load_state == UNIT_STUB) {
/* Try SUSE style boot.* init scripts */
path = join(*p, "/boot.", name, NULL);
@@ -950,7 +950,7 @@ static int service_load_sysv_name(Service *s, const char *name) {
#endif
#ifdef TARGET_FRUGALWARE
- if (r >= 0 && s->meta.load_state == UNIT_STUB) {
+ if (r >= 0 && UNIT(s)->load_state == UNIT_STUB) {
/* Try Frugalware style rc.* init scripts */
path = join(*p, "/rc.", name, NULL);
@@ -967,7 +967,7 @@ static int service_load_sysv_name(Service *s, const char *name) {
if (r < 0)
return r;
- if ((s->meta.load_state != UNIT_STUB))
+ if ((UNIT(s)->load_state != UNIT_STUB))
break;
}
@@ -984,22 +984,22 @@ static int service_load_sysv(Service *s) {
/* Load service data from SysV init scripts, preferably with
* LSB headers ... */
- if (strv_isempty(s->meta.manager->lookup_paths.sysvinit_path))
+ if (strv_isempty(UNIT(s)->manager->lookup_paths.sysvinit_path))
return 0;
- if ((t = s->meta.id))
+ if ((t = UNIT(s)->id))
if ((r = service_load_sysv_name(s, t)) < 0)
return r;
- if (s->meta.load_state == UNIT_STUB)
- SET_FOREACH(t, s->meta.names, i) {
- if (t == s->meta.id)
+ if (UNIT(s)->load_state == UNIT_STUB)
+ SET_FOREACH(t, UNIT(s)->names, i) {
+ if (t == UNIT(s)->id)
continue;
if ((r = service_load_sysv_name(s, t)) < 0)
return r;
- if (s->meta.load_state != UNIT_STUB)
+ if (UNIT(s)->load_state != UNIT_STUB)
break;
}
@@ -1019,7 +1019,7 @@ static int fsck_fix_order(Service *s) {
/* For each pair of services where both have an fsck priority
* we order things based on it. */
- LIST_FOREACH(units_by_type, other, s->meta.manager->units_by_type[UNIT_SERVICE]) {
+ LIST_FOREACH(units_by_type, other, UNIT(s)->manager->units_by_type[UNIT_SERVICE]) {
Service *t;
UnitDependency d;
@@ -1028,7 +1028,7 @@ static int fsck_fix_order(Service *s) {
if (s == t)
continue;
- if (t->meta.load_state != UNIT_LOADED)
+ if (UNIT(t)->load_state != UNIT_LOADED)
continue;
if (t->fsck_passno <= 0)
@@ -1051,33 +1051,33 @@ static int fsck_fix_order(Service *s) {
static int service_verify(Service *s) {
assert(s);
- if (s->meta.load_state != UNIT_LOADED)
+ if (UNIT(s)->load_state != UNIT_LOADED)
return 0;
if (!s->exec_command[SERVICE_EXEC_START]) {
- log_error("%s lacks ExecStart setting. Refusing.", s->meta.id);
+ log_error("%s lacks ExecStart setting. Refusing.", UNIT(s)->id);
return -EINVAL;
}
if (s->type != SERVICE_ONESHOT &&
s->exec_command[SERVICE_EXEC_START]->command_next) {
- log_error("%s has more than one ExecStart setting, which is only allowed for Type=oneshot services. Refusing.", s->meta.id);
+ log_error("%s has more than one ExecStart setting, which is only allowed for Type=oneshot services. Refusing.", UNIT(s)->id);
return -EINVAL;
}
if (s->type == SERVICE_ONESHOT &&
s->exec_command[SERVICE_EXEC_RELOAD]) {
- log_error("%s has an ExecReload setting, which is not allowed for Type=oneshot services. Refusing.", s->meta.id);
+ log_error("%s has an ExecReload setting, which is not allowed for Type=oneshot services. Refusing.", UNIT(s)->id);
return -EINVAL;
}
if (s->type == SERVICE_DBUS && !s->bus_name) {
- log_error("%s is of type D-Bus but no D-Bus service name has been specified. Refusing.", s->meta.id);
+ log_error("%s is of type D-Bus but no D-Bus service name has been specified. Refusing.", UNIT(s)->id);
return -EINVAL;
}
if (s->exec_context.pam_name && s->exec_context.kill_mode != KILL_CONTROL_GROUP) {
- log_error("%s has PAM enabled. Kill mode must be set to 'control-group'. Refusing.", s->meta.id);
+ log_error("%s has PAM enabled. Kill mode must be set to 'control-group'. Refusing.", UNIT(s)->id);
return -EINVAL;
}
@@ -1093,12 +1093,12 @@ static int service_add_default_dependencies(Service *s) {
* majority of services. */
/* First, pull in base system */
- if (s->meta.manager->running_as == MANAGER_SYSTEM) {
+ if (UNIT(s)->manager->running_as == MANAGER_SYSTEM) {
if ((r = unit_add_two_dependencies_by_name(UNIT(s), UNIT_AFTER, UNIT_REQUIRES, SPECIAL_BASIC_TARGET, NULL, true)) < 0)
return r;
- } else if (s->meta.manager->running_as == MANAGER_USER) {
+ } else if (UNIT(s)->manager->running_as == MANAGER_USER) {
if ((r = unit_add_two_dependencies_by_name(UNIT(s), UNIT_AFTER, UNIT_REQUIRES, SPECIAL_SOCKETS_TARGET, NULL, true)) < 0)
return r;
@@ -1119,11 +1119,11 @@ static void service_fix_output(Service *s) {
if (s->exec_context.std_error == EXEC_OUTPUT_INHERIT &&
s->exec_context.std_output == EXEC_OUTPUT_INHERIT &&
s->exec_context.std_input == EXEC_INPUT_NULL)
- s->exec_context.std_error = s->meta.manager->default_std_error;
+ s->exec_context.std_error = UNIT(s)->manager->default_std_error;
if (s->exec_context.std_output == EXEC_OUTPUT_INHERIT &&
s->exec_context.std_input == EXEC_INPUT_NULL)
- s->exec_context.std_output = s->meta.manager->default_std_output;
+ s->exec_context.std_output = UNIT(s)->manager->default_std_output;
}
static int service_load(Unit *u) {
@@ -1181,7 +1181,7 @@ static int service_load(Unit *u) {
if ((r = unit_add_two_dependencies_by_name(u, UNIT_AFTER, UNIT_REQUIRES, SPECIAL_DBUS_SOCKET, NULL, true)) < 0)
return r;
- if (s->meta.default_dependencies)
+ if (UNIT(s)->default_dependencies)
if ((r = service_add_default_dependencies(s)) < 0)
return r;
}
@@ -1357,7 +1357,7 @@ static int service_search_main_pid(Service *s) {
assert(s->main_pid <= 0);
- if ((pid = cgroup_bonding_search_main_pid_list(s->meta.cgroup_bondings)) <= 0)
+ if ((pid = cgroup_bonding_search_main_pid_list(UNIT(s)->cgroup_bondings)) <= 0)
return -ENOENT;
log_debug("Main PID guessed: %lu", (unsigned long) pid);
@@ -1382,7 +1382,7 @@ static void service_notify_sockets_dead(Service *s) {
if (s->socket_fd >= 0)
return;
- SET_FOREACH(u, s->meta.dependencies[UNIT_TRIGGERED_BY], i)
+ SET_FOREACH(u, UNIT(s)->dependencies[UNIT_TRIGGERED_BY], i)
if (u->type == UNIT_SOCKET)
socket_notify_service_dead(SOCKET(u));
@@ -1393,7 +1393,7 @@ static void service_unwatch_pid_file(Service *s) {
if (!s->pid_file_pathspec)
return;
- log_debug("Stopping watch for %s's PID file %s", s->meta.id, s->pid_file_pathspec->path);
+ log_debug("Stopping watch for %s's PID file %s", UNIT(s)->id, s->pid_file_pathspec->path);
path_spec_unwatch(s->pid_file_pathspec, UNIT(s));
path_spec_done(s->pid_file_pathspec);
free(s->pid_file_pathspec);
@@ -1470,18 +1470,18 @@ static void service_set_state(Service *s, ServiceState state) {
state != SERVICE_STOP_POST &&
state != SERVICE_FINAL_SIGTERM &&
state != SERVICE_FINAL_SIGKILL &&
- !(state == SERVICE_DEAD && s->meta.job)) {
+ !(state == SERVICE_DEAD && UNIT(s)->job)) {
service_close_socket_fd(s);
service_connection_unref(s);
}
/* For the inactive states unit_notify() will trim the cgroup,
* but for exit we have to do that ourselves... */
- if (state == SERVICE_EXITED && s->meta.manager->n_reloading <= 0)
- cgroup_bonding_trim_list(s->meta.cgroup_bondings, true);
+ if (state == SERVICE_EXITED && UNIT(s)->manager->n_reloading <= 0)
+ cgroup_bonding_trim_list(UNIT(s)->cgroup_bondings, true);
if (old_state != state)
- log_debug("%s changed %s -> %s", s->meta.id, service_state_to_string(old_state), service_state_to_string(state));
+ log_debug("%s changed %s -> %s", UNIT(s)->id, service_state_to_string(old_state), service_state_to_string(state));
unit_notify(UNIT(s), state_translation_table[old_state], state_translation_table[state], !s->reload_failure);
s->reload_failure = false;
@@ -1567,7 +1567,7 @@ static int service_collect_fds(Service *s, int **fds, unsigned *n_fds) {
if (s->socket_fd >= 0)
return 0;
- SET_FOREACH(u, s->meta.dependencies[UNIT_TRIGGERED_BY], i) {
+ SET_FOREACH(u, UNIT(s)->dependencies[UNIT_TRIGGERED_BY], i) {
int *cfds;
unsigned cn_fds;
Socket *sock;
@@ -1670,7 +1670,7 @@ static int service_spawn(
}
if (set_notify_socket)
- if (asprintf(our_env + n_env++, "NOTIFY_SOCKET=%s", s->meta.manager->notify_socket) < 0) {
+ if (asprintf(our_env + n_env++, "NOTIFY_SOCKET=%s", UNIT(s)->manager->notify_socket) < 0) {
r = -ENOMEM;
goto fail;
}
@@ -1682,7 +1682,7 @@ static int service_spawn(
}
if (!(final_env = strv_env_merge(2,
- s->meta.manager->environment,
+ UNIT(s)->manager->environment,
our_env,
NULL))) {
r = -ENOMEM;
@@ -1697,9 +1697,9 @@ static int service_spawn(
apply_permissions,
apply_chroot,
apply_tty_stdin,
- s->meta.manager->confirm_spawn,
- s->meta.cgroup_bondings,
- s->meta.cgroup_attributes,
+ UNIT(s)->manager->confirm_spawn,
+ UNIT(s)->cgroup_bondings,
+ UNIT(s)->cgroup_attributes,
&pid);
if (r < 0)
@@ -1767,7 +1767,7 @@ static int cgroup_good(Service *s) {
assert(s);
- if ((r = cgroup_bonding_is_empty_list(s->meta.cgroup_bondings)) < 0)
+ if ((r = cgroup_bonding_is_empty_list(UNIT(s)->cgroup_bondings)) < 0)
return r;
return !r;
@@ -1801,7 +1801,7 @@ static void service_enter_dead(Service *s, bool success, bool allow_restart) {
return;
fail:
- log_warning("%s failed to run install restart timer: %s", s->meta.id, strerror(-r));
+ log_warning("%s failed to run install restart timer: %s", UNIT(s)->id, strerror(-r));
service_enter_dead(s, false, false);
}
@@ -1838,7 +1838,7 @@ static void service_enter_stop_post(Service *s, bool success) {
return;
fail:
- log_warning("%s failed to run 'stop-post' task: %s", s->meta.id, strerror(-r));
+ log_warning("%s failed to run 'stop-post' task: %s", UNIT(s)->id, strerror(-r));
service_enter_signal(s, SERVICE_FINAL_SIGTERM, false);
}
@@ -1885,7 +1885,7 @@ static void service_enter_signal(Service *s, ServiceState state, bool success) {
if ((r = set_put(pid_set, LONG_TO_PTR(s->control_pid))) < 0)
goto fail;
- if ((r = cgroup_bonding_kill_list(s->meta.cgroup_bondings, sig, true, pid_set)) < 0) {
+ if ((r = cgroup_bonding_kill_list(UNIT(s)->cgroup_bondings, sig, true, pid_set)) < 0) {
if (r != -EAGAIN && r != -ESRCH && r != -ENOENT)
log_warning("Failed to kill control group: %s", strerror(-r));
} else if (r > 0)
@@ -1910,7 +1910,7 @@ static void service_enter_signal(Service *s, ServiceState state, bool success) {
return;
fail:
- log_warning("%s failed to kill processes: %s", s->meta.id, strerror(-r));
+ log_warning("%s failed to kill processes: %s", UNIT(s)->id, strerror(-r));
if (state == SERVICE_STOP_SIGTERM || state == SERVICE_STOP_SIGKILL)
service_enter_stop_post(s, false);
@@ -1952,7 +1952,7 @@ static void service_enter_stop(Service *s, bool success) {
return;
fail:
- log_warning("%s failed to run 'stop' task: %s", s->meta.id, strerror(-r));
+ log_warning("%s failed to run 'stop' task: %s", UNIT(s)->id, strerror(-r));
service_enter_signal(s, SERVICE_STOP_SIGTERM, false);
}
@@ -2002,7 +2002,7 @@ static void service_enter_start_post(Service *s) {
return;
fail:
- log_warning("%s failed to run 'start-post' task: %s", s->meta.id, strerror(-r));
+ log_warning("%s failed to run 'start-post' task: %s", UNIT(s)->id, strerror(-r));
service_enter_stop(s, false);
}
@@ -2024,7 +2024,7 @@ static void service_enter_start(Service *s) {
/* We want to ensure that nobody leaks processes from
* START_PRE here, so let's go on a killing spree, People
* should not spawn long running processes from START_PRE. */
- cgroup_bonding_kill_list(s->meta.cgroup_bondings, SIGKILL, true, NULL);
+ cgroup_bonding_kill_list(UNIT(s)->cgroup_bondings, SIGKILL, true, NULL);
if (s->type == SERVICE_FORKING) {
s->control_command_id = SERVICE_EXEC_START;
@@ -2083,7 +2083,7 @@ static void service_enter_start(Service *s) {
return;
fail:
- log_warning("%s failed to run 'start' task: %s", s->meta.id, strerror(-r));
+ log_warning("%s failed to run 'start' task: %s", UNIT(s)->id, strerror(-r));
service_enter_signal(s, SERVICE_FINAL_SIGTERM, false);
}
@@ -2098,7 +2098,7 @@ static void service_enter_start_pre(Service *s) {
/* Before we start anything, let's clear up what might
* be left from previous runs. */
- cgroup_bonding_kill_list(s->meta.cgroup_bondings, SIGKILL, true, NULL);
+ cgroup_bonding_kill_list(UNIT(s)->cgroup_bondings, SIGKILL, true, NULL);
s->control_command_id = SERVICE_EXEC_START_PRE;
@@ -2120,7 +2120,7 @@ static void service_enter_start_pre(Service *s) {
return;
fail:
- log_warning("%s failed to run 'start-pre' task: %s", s->meta.id, strerror(-r));
+ log_warning("%s failed to run 'start-pre' task: %s", UNIT(s)->id, strerror(-r));
service_enter_dead(s, false, true);
}
@@ -2131,7 +2131,7 @@ static void service_enter_restart(Service *s) {
assert(s);
dbus_error_init(&error);
- if (s->meta.job) {
+ if (UNIT(s)->job) {
log_info("Job pending for unit, delaying automatic restart.");
if ((r = unit_watch_timer(UNIT(s), s->restart_usec, &s->timer_watch)) < 0)
@@ -2140,14 +2140,14 @@ static void service_enter_restart(Service *s) {
service_enter_dead(s, true, false);
- if ((r = manager_add_job(s->meta.manager, JOB_START, UNIT(s), JOB_FAIL, false, &error, NULL)) < 0)
+ if ((r = manager_add_job(UNIT(s)->manager, JOB_START, UNIT(s), JOB_FAIL, false, &error, NULL)) < 0)
goto fail;
- log_debug("%s scheduled restart job.", s->meta.id);
+ log_debug("%s scheduled restart job.", UNIT(s)->id);
return;
fail:
- log_warning("%s failed to schedule restart job: %s", s->meta.id, bus_error(&error, -r));
+ log_warning("%s failed to schedule restart job: %s", UNIT(s)->id, bus_error(&error, -r));
service_enter_dead(s, false, false);
dbus_error_free(&error);
@@ -2181,7 +2181,7 @@ static void service_enter_reload(Service *s) {
return;
fail:
- log_warning("%s failed to run 'reload' task: %s", s->meta.id, strerror(-r));
+ log_warning("%s failed to run 'reload' task: %s", UNIT(s)->id, strerror(-r));
s->reload_failure = true;
service_enter_running(s, true);
}
@@ -2216,7 +2216,7 @@ static void service_run_next_control(Service *s, bool success) {
return;
fail:
- log_warning("%s failed to run next control task: %s", s->meta.id, strerror(-r));
+ log_warning("%s failed to run next control task: %s", UNIT(s)->id, strerror(-r));
if (s->state == SERVICE_START_PRE)
service_enter_signal(s, SERVICE_FINAL_SIGTERM, false);
@@ -2262,7 +2262,7 @@ static void service_run_next_main(Service *s, bool success) {
return;
fail:
- log_warning("%s failed to run next main task: %s", s->meta.id, strerror(-r));
+ log_warning("%s failed to run next main task: %s", UNIT(s)->id, strerror(-r));
service_enter_stop(s, false);
}
@@ -2575,7 +2575,7 @@ static int service_retry_pid_file(Service *s) {
static int service_watch_pid_file(Service *s) {
int r;
- log_debug("Setting watch for %s's PID file %s", s->meta.id, s->pid_file_pathspec->path);
+ log_debug("Setting watch for %s's PID file %s", UNIT(s)->id, s->pid_file_pathspec->path);
r = path_spec_watch(s->pid_file_pathspec, UNIT(s));
if (r < 0)
goto fail;
@@ -2586,7 +2586,7 @@ static int service_watch_pid_file(Service *s) {
return 0;
fail:
log_error("Failed to set a watch for %s's PID file %s: %s",
- s->meta.id, s->pid_file_pathspec->path, strerror(-r));
+ UNIT(s)->id, s->pid_file_pathspec->path, strerror(-r));
service_unwatch_pid_file(s);
return r;
}
@@ -2652,7 +2652,7 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) {
assert(s);
assert(pid >= 0);
- if (!s->meta.fragment_path)
+ if (!UNIT(s)->fragment_path)
success = is_clean_exit_lsb(code, status);
else
success = is_clean_exit(code, status);
@@ -2971,7 +2971,7 @@ static void service_cgroup_notify_event(Unit *u) {
/* If we were hoping for the daemon to write its PID file,
* we can give up now. */
if (s->pid_file_pathspec) {
- log_warning("%s never wrote its PID file. Failing.", s->meta.id);
+ log_warning("%s never wrote its PID file. Failing.", UNIT(s)->id);
service_unwatch_pid_file(s);
if (s->state == SERVICE_START)
service_enter_signal(s, SERVICE_FINAL_SIGTERM, false);
@@ -3383,7 +3383,7 @@ int service_set_socket_fd(Service *s, int fd, Socket *sock) {
* service for a stream socket and the socket needs to be
* configured. */
- if (s->meta.load_state != UNIT_LOADED)
+ if (UNIT(s)->load_state != UNIT_LOADED)
return -EINVAL;
if (s->socket_fd >= 0)
@@ -3480,7 +3480,7 @@ static int service_kill(Unit *u, KillWho who, KillMode mode, int signo, DBusErro
goto finish;
}
- if ((q = cgroup_bonding_kill_list(s->meta.cgroup_bondings, signo, false, pid_set)) < 0)
+ if ((q = cgroup_bonding_kill_list(UNIT(s)->cgroup_bondings, signo, false, pid_set)) < 0)
if (q != -EAGAIN && q != -ESRCH && q != -ENOENT)
r = q;
}
diff --git a/src/snapshot.c b/src/snapshot.c
index bc1388c..82ec510 100644
--- a/src/snapshot.c
+++ b/src/snapshot.c
@@ -36,10 +36,10 @@ static void snapshot_init(Unit *u) {
Snapshot *s = SNAPSHOT(u);
assert(s);
- assert(s->meta.load_state == UNIT_STUB);
+ assert(UNIT(s)->load_state == UNIT_STUB);
- s->meta.ignore_on_isolate = true;
- s->meta.ignore_on_snapshot = true;
+ UNIT(s)->ignore_on_isolate = true;
+ UNIT(s)->ignore_on_snapshot = true;
}
static void snapshot_set_state(Snapshot *s, SnapshotState state) {
@@ -51,7 +51,7 @@ static void snapshot_set_state(Snapshot *s, SnapshotState state) {
if (state != old_state)
log_debug("%s changed %s -> %s",
- s->meta.id,
+ UNIT(s)->id,
snapshot_state_to_string(old_state),
snapshot_state_to_string(state));
@@ -66,7 +66,7 @@ static int snapshot_load(Unit *u) {
/* Make sure that only snapshots created via snapshot_create()
* can be loaded */
- if (!s->by_snapshot_create && s->meta.manager->n_reloading <= 0)
+ if (!s->by_snapshot_create && UNIT(s)->manager->n_reloading <= 0)
return -ENOENT;
u->load_state = UNIT_LOADED;
diff --git a/src/socket.c b/src/socket.c
index a9ab82c..e0ddcef 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -147,7 +147,7 @@ static int socket_instantiate_service(Socket *s) {
assert(s->accept);
- if (!(prefix = unit_name_to_prefix(s->meta.id)))
+ if (!(prefix = unit_name_to_prefix(UNIT(s)->id)))
return -ENOMEM;
r = asprintf(&name, "%s@%u.service", prefix, s->n_accepted);
@@ -156,7 +156,7 @@ static int socket_instantiate_service(Socket *s) {
if (r < 0)
return -ENOMEM;
- r = manager_load_unit(s->meta.manager, name, NULL, NULL, &u);
+ r = manager_load_unit(UNIT(s)->manager, name, NULL, NULL, &u);
free(name);
if (r < 0)
@@ -198,31 +198,31 @@ static bool have_non_accept_socket(Socket *s) {
static int socket_verify(Socket *s) {
assert(s);
- if (s->meta.load_state != UNIT_LOADED)
+ if (UNIT(s)->load_state != UNIT_LOADED)
return 0;
if (!s->ports) {
- log_error("%s lacks Listen setting. Refusing.", s->meta.id);
+ log_error("%s lacks Listen setting. Refusing.", UNIT(s)->id);
return -EINVAL;
}
if (s->accept && have_non_accept_socket(s)) {
- log_error("%s configured for accepting sockets, but sockets are non-accepting. Refusing.", s->meta.id);
+ log_error("%s configured for accepting sockets, but sockets are non-accepting. Refusing.", UNIT(s)->id);
return -EINVAL;
}
if (s->accept && s->max_connections <= 0) {
- log_error("%s's MaxConnection setting too small. Refusing.", s->meta.id);
+ log_error("%s's MaxConnection setting too small. Refusing.", UNIT(s)->id);
return -EINVAL;
}
if (s->accept && UNIT_DEREF(s->service)) {
- log_error("Explicit service configuration for accepting sockets not supported on %s. Refusing.", s->meta.id);
+ log_error("Explicit service configuration for accepting sockets not supported on %s. Refusing.", UNIT(s)->id);
return -EINVAL;
}
if (s->exec_context.pam_name && s->exec_context.kill_mode != KILL_CONTROL_GROUP) {
- log_error("%s has PAM enabled. Kill mode must be set to 'control-group'. Refusing.", s->meta.id);
+ log_error("%s has PAM enabled. Kill mode must be set to 'control-group'. Refusing.", UNIT(s)->id);
return -EINVAL;
}
@@ -254,8 +254,8 @@ int socket_add_one_mount_link(Socket *s, Mount *m) {
assert(s);
assert(m);
- if (s->meta.load_state != UNIT_LOADED ||
- m->meta.load_state != UNIT_LOADED)
+ if (UNIT(s)->load_state != UNIT_LOADED ||
+ UNIT(m)->load_state != UNIT_LOADED)
return 0;
if (!socket_needs_mount(s, m->where))
@@ -273,7 +273,7 @@ static int socket_add_mount_links(Socket *s) {
assert(s);
- LIST_FOREACH(units_by_type, other, s->meta.manager->units_by_type[UNIT_MOUNT])
+ LIST_FOREACH(units_by_type, other, UNIT(s)->manager->units_by_type[UNIT_MOUNT])
if ((r = socket_add_one_mount_link(s, (Mount*) other)) < 0)
return r;
@@ -302,7 +302,7 @@ static int socket_add_default_dependencies(Socket *s) {
int r;
assert(s);
- if (s->meta.manager->running_as == MANAGER_SYSTEM) {
+ if (UNIT(s)->manager->running_as == MANAGER_SYSTEM) {
if ((r = unit_add_dependency_by_name(UNIT(s), UNIT_BEFORE, SPECIAL_SOCKETS_TARGET, NULL, true)) < 0)
return r;
@@ -367,7 +367,7 @@ static int socket_load(Unit *u) {
if ((r = unit_add_default_cgroups(u)) < 0)
return r;
- if (s->meta.default_dependencies)
+ if (UNIT(s)->default_dependencies)
if ((r = socket_add_default_dependencies(s)) < 0)
return r;
}
@@ -1049,7 +1049,7 @@ static void socket_set_state(Socket *s, SocketState state) {
if (state != old_state)
log_debug("%s changed %s -> %s",
- s->meta.id,
+ UNIT(s)->id,
socket_state_to_string(old_state),
socket_state_to_string(state));
@@ -1124,13 +1124,13 @@ static int socket_spawn(Socket *s, ExecCommand *c, pid_t *_pid) {
argv,
&s->exec_context,
NULL, 0,
- s->meta.manager->environment,
+ UNIT(s)->manager->environment,
true,
true,
true,
- s->meta.manager->confirm_spawn,
- s->meta.cgroup_bondings,
- s->meta.cgroup_attributes,
+ UNIT(s)->manager->confirm_spawn,
+ UNIT(s)->cgroup_bondings,
+ UNIT(s)->cgroup_attributes,
&pid);
strv_free(argv);
@@ -1184,7 +1184,7 @@ static void socket_enter_stop_post(Socket *s, bool success) {
return;
fail:
- log_warning("%s failed to run 'stop-post' task: %s", s->meta.id, strerror(-r));
+ log_warning("%s failed to run 'stop-post' task: %s", UNIT(s)->id, strerror(-r));
socket_enter_signal(s, SOCKET_FINAL_SIGTERM, false);
}
@@ -1221,7 +1221,7 @@ static void socket_enter_signal(Socket *s, SocketState state, bool success) {
if ((r = set_put(pid_set, LONG_TO_PTR(s->control_pid))) < 0)
goto fail;
- if ((r = cgroup_bonding_kill_list(s->meta.cgroup_bondings, sig, true, pid_set)) < 0) {
+ if ((r = cgroup_bonding_kill_list(UNIT(s)->cgroup_bondings, sig, true, pid_set)) < 0) {
if (r != -EAGAIN && r != -ESRCH && r != -ENOENT)
log_warning("Failed to kill control group: %s", strerror(-r));
} else if (r > 0)
@@ -1245,7 +1245,7 @@ static void socket_enter_signal(Socket *s, SocketState state, bool success) {
return;
fail:
- log_warning("%s failed to kill processes: %s", s->meta.id, strerror(-r));
+ log_warning("%s failed to kill processes: %s", UNIT(s)->id, strerror(-r));
if (state == SOCKET_STOP_PRE_SIGTERM || state == SOCKET_STOP_PRE_SIGKILL)
socket_enter_stop_post(s, false);
@@ -1278,7 +1278,7 @@ static void socket_enter_stop_pre(Socket *s, bool success) {
return;
fail:
- log_warning("%s failed to run 'stop-pre' task: %s", s->meta.id, strerror(-r));
+ log_warning("%s failed to run 'stop-pre' task: %s", UNIT(s)->id, strerror(-r));
socket_enter_stop_post(s, false);
}
@@ -1287,7 +1287,7 @@ static void socket_enter_listening(Socket *s) {
assert(s);
if ((r = socket_watch_fds(s)) < 0) {
- log_warning("%s failed to watch sockets: %s", s->meta.id, strerror(-r));
+ log_warning("%s failed to watch sockets: %s", UNIT(s)->id, strerror(-r));
goto fail;
}
@@ -1303,7 +1303,7 @@ static void socket_enter_start_post(Socket *s) {
assert(s);
if ((r = socket_open_fds(s)) < 0) {
- log_warning("%s failed to listen on sockets: %s", s->meta.id, strerror(-r));
+ log_warning("%s failed to listen on sockets: %s", UNIT(s)->id, strerror(-r));
goto fail;
}
@@ -1313,7 +1313,7 @@ static void socket_enter_start_post(Socket *s) {
if ((s->control_command = s->exec_command[SOCKET_EXEC_START_POST])) {
if ((r = socket_spawn(s, s->control_command, &s->control_pid)) < 0) {
- log_warning("%s failed to run 'start-post' task: %s", s->meta.id, strerror(-r));
+ log_warning("%s failed to run 'start-post' task: %s", UNIT(s)->id, strerror(-r));
goto fail;
}
@@ -1346,7 +1346,7 @@ static void socket_enter_start_pre(Socket *s) {
return;
fail:
- log_warning("%s failed to run 'start-pre' task: %s", s->meta.id, strerror(-r));
+ log_warning("%s failed to run 'start-pre' task: %s", UNIT(s)->id, strerror(-r));
socket_enter_dead(s, false);
}
@@ -1360,7 +1360,7 @@ static void socket_enter_running(Socket *s, int cfd) {
/* We don't take connections anymore if we are supposed to
* shut down anyway */
if (unit_pending_inactive(UNIT(s))) {
- log_debug("Suppressing connection request on %s since unit stop is scheduled.", s->meta.id);
+ log_debug("Suppressing connection request on %s since unit stop is scheduled.", UNIT(s)->id);
if (cfd >= 0)
close_nointr_nofail(cfd);
@@ -1369,7 +1369,7 @@ static void socket_enter_running(Socket *s, int cfd) {
socket_close_fds(s);
if ((r = socket_watch_fds(s)) < 0) {
- log_warning("%s failed to watch sockets: %s", s->meta.id, strerror(-r));
+ log_warning("%s failed to watch sockets: %s", UNIT(s)->id, strerror(-r));
socket_enter_stop_pre(s, false);
}
}
@@ -1384,14 +1384,14 @@ static void socket_enter_running(Socket *s, int cfd) {
/* If there's already a start pending don't bother to
* do anything */
- SET_FOREACH(u, s->meta.dependencies[UNIT_TRIGGERS], i)
+ SET_FOREACH(u, UNIT(s)->dependencies[UNIT_TRIGGERS], i)
if (unit_pending_active(u)) {
pending = true;
break;
}
if (!pending)
- if ((r = manager_add_job(s->meta.manager, JOB_START, UNIT_DEREF(s->service), JOB_REPLACE, true, &error, NULL)) < 0)
+ if ((r = manager_add_job(UNIT(s)->manager, JOB_START, UNIT_DEREF(s->service), JOB_REPLACE, true, &error, NULL)) < 0)
goto fail;
socket_set_state(s, SOCKET_RUNNING);
@@ -1411,7 +1411,7 @@ static void socket_enter_running(Socket *s, int cfd) {
if ((r = instance_from_socket(cfd, s->n_accepted, &instance)) < 0)
goto fail;
- if (!(prefix = unit_name_to_prefix(s->meta.id))) {
+ if (!(prefix = unit_name_to_prefix(UNIT(s)->id))) {
free(instance);
r = -ENOMEM;
goto fail;
@@ -1435,7 +1435,7 @@ static void socket_enter_running(Socket *s, int cfd) {
unit_ref_unset(&s->service);
s->n_accepted ++;
- service->meta.no_gc = false;
+ UNIT(service)->no_gc = false;
unit_choose_id(UNIT(service), name);
free(name);
@@ -1446,7 +1446,7 @@ static void socket_enter_running(Socket *s, int cfd) {
cfd = -1;
s->n_connections ++;
- if ((r = manager_add_job(s->meta.manager, JOB_START, UNIT(service), JOB_REPLACE, true, &error, NULL)) < 0)
+ if ((r = manager_add_job(UNIT(s)->manager, JOB_START, UNIT(service), JOB_REPLACE, true, &error, NULL)) < 0)
goto fail;
/* Notify clients about changed counters */
@@ -1456,7 +1456,7 @@ static void socket_enter_running(Socket *s, int cfd) {
return;
fail:
- log_warning("%s failed to queue socket startup job: %s", s->meta.id, bus_error(&error, r));
+ log_warning("%s failed to queue socket startup job: %s", UNIT(s)->id, bus_error(&error, r));
socket_enter_stop_pre(s, false);
if (cfd >= 0)
@@ -1485,7 +1485,7 @@ static void socket_run_next(Socket *s, bool success) {
return;
fail:
- log_warning("%s failed to run next task: %s", s->meta.id, strerror(-r));
+ log_warning("%s failed to run next task: %s", UNIT(s)->id, strerror(-r));
if (s->state == SOCKET_START_POST)
socket_enter_stop_pre(s, false);
@@ -1520,8 +1520,8 @@ static int socket_start(Unit *u) {
service = SERVICE(UNIT_DEREF(s->service));
- if (service->meta.load_state != UNIT_LOADED) {
- log_error("Socket service %s not loaded, refusing.", service->meta.id);
+ if (UNIT(service)->load_state != UNIT_LOADED) {
+ log_error("Socket service %s not loaded, refusing.", UNIT(service)->id);
return -ENOENT;
}
@@ -1530,7 +1530,7 @@ static int socket_start(Unit *u) {
if (service->state != SERVICE_DEAD &&
service->state != SERVICE_FAILED &&
service->state != SERVICE_AUTO_RESTART) {
- log_error("Socket service %s already active, refusing.", service->meta.id);
+ log_error("Socket service %s already active, refusing.", UNIT(service)->id);
return -EBUSY;
}
@@ -2009,7 +2009,7 @@ void socket_notify_service_dead(Socket *s) {
* services. */
if (s->state == SOCKET_RUNNING) {
- log_debug("%s got notified about service death.", s->meta.id);
+ log_debug("%s got notified about service death.", UNIT(s)->id);
socket_enter_listening(s);
}
}
@@ -2025,7 +2025,7 @@ void socket_connection_unref(Socket *s) {
assert(s->n_connections > 0);
s->n_connections--;
- log_debug("%s: One connection closed, %u left.", s->meta.id, s->n_connections);
+ log_debug("%s: One connection closed, %u left.", UNIT(s)->id, s->n_connections);
}
static void socket_reset_failed(Unit *u) {
@@ -2074,7 +2074,7 @@ static int socket_kill(Unit *u, KillWho who, KillMode mode, int signo, DBusError
goto finish;
}
- if ((q = cgroup_bonding_kill_list(s->meta.cgroup_bondings, signo, false, pid_set)) < 0)
+ if ((q = cgroup_bonding_kill_list(UNIT(s)->cgroup_bondings, signo, false, pid_set)) < 0)
if (q != -EAGAIN && q != -ESRCH && q != -ENOENT)
r = q;
}
diff --git a/src/swap.c b/src/swap.c
index 87be552..ff62b1d 100644
--- a/src/swap.c
+++ b/src/swap.c
@@ -62,13 +62,13 @@ static void swap_unset_proc_swaps(Swap *s) {
/* Remove this unit from the chain of swaps which share the
* same kernel swap device. */
- first = hashmap_get(s->meta.manager->swaps_by_proc_swaps, s->parameters_proc_swaps.what);
+ first = hashmap_get(UNIT(s)->manager->swaps_by_proc_swaps, s->parameters_proc_swaps.what);
LIST_REMOVE(Swap, same_proc_swaps, first, s);
if (first)
- hashmap_remove_and_replace(s->meta.manager->swaps_by_proc_swaps, s->parameters_proc_swaps.what, first->parameters_proc_swaps.what, first);
+ hashmap_remove_and_replace(UNIT(s)->manager->swaps_by_proc_swaps, s->parameters_proc_swaps.what, first->parameters_proc_swaps.what, first);
else
- hashmap_remove(s->meta.manager->swaps_by_proc_swaps, s->parameters_proc_swaps.what);
+ hashmap_remove(UNIT(s)->manager->swaps_by_proc_swaps, s->parameters_proc_swaps.what);
free(s->parameters_proc_swaps.what);
s->parameters_proc_swaps.what = NULL;
@@ -78,7 +78,7 @@ static void swap_init(Unit *u) {
Swap *s = SWAP(u);
assert(s);
- assert(s->meta.load_state == UNIT_STUB);
+ assert(UNIT(s)->load_state == UNIT_STUB);
s->timeout_usec = DEFAULT_TIMEOUT_USEC;
@@ -92,7 +92,7 @@ static void swap_init(Unit *u) {
s->control_command_id = _MOUNT_EXEC_COMMAND_INVALID;
- s->meta.ignore_on_isolate = true;
+ UNIT(s)->ignore_on_isolate = true;
}
static void swap_unwatch_control_pid(Swap *s) {
@@ -134,8 +134,8 @@ int swap_add_one_mount_link(Swap *s, Mount *m) {
assert(s);
assert(m);
- if (s->meta.load_state != UNIT_LOADED ||
- m->meta.load_state != UNIT_LOADED)
+ if (UNIT(s)->load_state != UNIT_LOADED ||
+ UNIT(m)->load_state != UNIT_LOADED)
return 0;
if (is_device_path(s->what))
@@ -156,7 +156,7 @@ static int swap_add_mount_links(Swap *s) {
assert(s);
- LIST_FOREACH(units_by_type, other, s->meta.manager->units_by_type[UNIT_MOUNT])
+ LIST_FOREACH(units_by_type, other, UNIT(s)->manager->units_by_type[UNIT_MOUNT])
if ((r = swap_add_one_mount_link(s, (Mount*) other)) < 0)
return r;
@@ -177,14 +177,14 @@ static int swap_add_target_links(Swap *s) {
else
return 0;
- if ((r = manager_load_unit(s->meta.manager, SPECIAL_SWAP_TARGET, NULL, NULL, &tu)) < 0)
+ if ((r = manager_load_unit(UNIT(s)->manager, SPECIAL_SWAP_TARGET, NULL, NULL, &tu)) < 0)
return r;
if (!p->noauto &&
!p->nofail &&
- (p->handle || s->meta.manager->swap_auto) &&
+ (p->handle || UNIT(s)->manager->swap_auto) &&
s->from_etc_fstab &&
- s->meta.manager->running_as == MANAGER_SYSTEM)
+ UNIT(s)->manager->running_as == MANAGER_SYSTEM)
if ((r = unit_add_dependency(tu, UNIT_WANTS, UNIT(s), true)) < 0)
return r;
@@ -209,7 +209,7 @@ static int swap_add_device_links(Swap *s) {
if (is_device_path(s->what))
return unit_add_node_link(UNIT(s), s->what,
!p->noauto && p->nofail &&
- s->meta.manager->running_as == MANAGER_SYSTEM);
+ UNIT(s)->manager->running_as == MANAGER_SYSTEM);
else
/* File based swap devices need to be ordered after
* remount-rootfs.service, since they might need a
@@ -222,7 +222,7 @@ static int swap_add_default_dependencies(Swap *s) {
assert(s);
- if (s->meta.manager->running_as == MANAGER_SYSTEM) {
+ if (UNIT(s)->manager->running_as == MANAGER_SYSTEM) {
if ((r = unit_add_two_dependencies_by_name(UNIT(s), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_UMOUNT_TARGET, NULL, true)) < 0)
return r;
@@ -235,7 +235,7 @@ static int swap_verify(Swap *s) {
bool b;
char *e;
- if (s->meta.load_state != UNIT_LOADED)
+ if (UNIT(s)->load_state != UNIT_LOADED)
return 0;
if (!(e = unit_name_from_path(s->what, ".swap")))
@@ -245,12 +245,12 @@ static int swap_verify(Swap *s) {
free(e);
if (!b) {
- log_error("%s: Value of \"What\" and unit name do not match, not loading.\n", s->meta.id);
+ log_error("%s: Value of \"What\" and unit name do not match, not loading.\n", UNIT(s)->id);
return -EINVAL;
}
if (s->exec_context.pam_name && s->exec_context.kill_mode != KILL_CONTROL_GROUP) {
- log_error("%s has PAM enabled. Kill mode must be set to 'control-group'. Refusing.", s->meta.id);
+ log_error("%s has PAM enabled. Kill mode must be set to 'control-group'. Refusing.", UNIT(s)->id);
return -EINVAL;
}
@@ -272,7 +272,7 @@ static int swap_load(Unit *u) {
if ((r = unit_add_exec_dependencies(u, &s->exec_context)) < 0)
return r;
- if (s->meta.fragment_path)
+ if (UNIT(s)->fragment_path)
s->from_fragment = true;
if (!s->what) {
@@ -291,7 +291,7 @@ static int swap_load(Unit *u) {
path_kill_slashes(s->what);
- if (!s->meta.description)
+ if (!UNIT(s)->description)
if ((r = unit_set_description(u, s->what)) < 0)
return r;
@@ -307,7 +307,7 @@ static int swap_load(Unit *u) {
if ((r = unit_add_default_cgroups(u)) < 0)
return r;
- if (s->meta.default_dependencies)
+ if (UNIT(s)->default_dependencies)
if ((r = swap_add_default_dependencies(s)) < 0)
return r;
}
@@ -510,7 +510,7 @@ static void swap_set_state(Swap *s, SwapState state) {
if (state != old_state)
log_debug("%s changed %s -> %s",
- s->meta.id,
+ UNIT(s)->id,
swap_state_to_string(old_state),
swap_state_to_string(state));
@@ -612,13 +612,13 @@ static int swap_spawn(Swap *s, ExecCommand *c, pid_t *_pid) {
NULL,
&s->exec_context,
NULL, 0,
- s->meta.manager->environment,
+ UNIT(s)->manager->environment,
true,
true,
true,
- s->meta.manager->confirm_spawn,
- s->meta.cgroup_bondings,
- s->meta.cgroup_attributes,
+ UNIT(s)->manager->confirm_spawn,
+ UNIT(s)->cgroup_bondings,
+ UNIT(s)->cgroup_attributes,
&pid)) < 0)
goto fail;
@@ -688,7 +688,7 @@ static void swap_enter_signal(Swap *s, SwapState state, bool success) {
if ((r = set_put(pid_set, LONG_TO_PTR(s->control_pid))) < 0)
goto fail;
- if ((r = cgroup_bonding_kill_list(s->meta.cgroup_bondings, sig, true, pid_set)) < 0) {
+ if ((r = cgroup_bonding_kill_list(UNIT(s)->cgroup_bondings, sig, true, pid_set)) < 0) {
if (r != -EAGAIN && r != -ESRCH && r != -ENOENT)
log_warning("Failed to kill control group: %s", strerror(-r));
} else if (r > 0)
@@ -710,7 +710,7 @@ static void swap_enter_signal(Swap *s, SwapState state, bool success) {
return;
fail:
- log_warning("%s failed to kill processes: %s", s->meta.id, strerror(-r));
+ log_warning("%s failed to kill processes: %s", UNIT(s)->id, strerror(-r));
swap_enter_dead(s, false);
@@ -766,7 +766,7 @@ static void swap_enter_activating(Swap *s) {
return;
fail:
- log_warning("%s failed to run 'swapon' task: %s", s->meta.id, strerror(-r));
+ log_warning("%s failed to run 'swapon' task: %s", UNIT(s)->id, strerror(-r));
swap_enter_dead(s, false);
}
@@ -798,7 +798,7 @@ static void swap_enter_deactivating(Swap *s, bool success) {
return;
fail:
- log_warning("%s failed to run 'swapoff' task: %s", s->meta.id, strerror(-r));
+ log_warning("%s failed to run 'swapoff' task: %s", UNIT(s)->id, strerror(-r));
swap_enter_active(s, false);
}
@@ -1310,7 +1310,7 @@ static int swap_kill(Unit *u, KillWho who, KillMode mode, int signo, DBusError *
goto finish;
}
- if ((q = cgroup_bonding_kill_list(s->meta.cgroup_bondings, signo, false, pid_set)) < 0)
+ if ((q = cgroup_bonding_kill_list(UNIT(s)->cgroup_bondings, signo, false, pid_set)) < 0)
if (q != -EAGAIN && q != -ESRCH && q != -ENOENT)
r = q;
}
diff --git a/src/target.c b/src/target.c
index fb67ff3..6c1e0c3 100644
--- a/src/target.c
+++ b/src/target.c
@@ -45,7 +45,7 @@ static void target_set_state(Target *t, TargetState state) {
if (state != old_state)
log_debug("%s changed %s -> %s",
- t->meta.id,
+ UNIT(t)->id,
target_state_to_string(old_state),
target_state_to_string(state));
@@ -75,7 +75,7 @@ static int target_add_default_dependencies(Target *t) {
* sure we don't create a loop. */
for (k = 0; k < ELEMENTSOF(deps); k++)
- SET_FOREACH(other, t->meta.dependencies[deps[k]], i)
+ SET_FOREACH(other, UNIT(t)->dependencies[deps[k]], i)
if ((r = unit_add_default_target_dependency(other, UNIT(t))) < 0)
return r;
diff --git a/src/timer.c b/src/timer.c
index 6056d31..ce7fd6b 100644
--- a/src/timer.c
+++ b/src/timer.c
@@ -64,11 +64,11 @@ static void timer_done(Unit *u) {
static int timer_verify(Timer *t) {
assert(t);
- if (t->meta.load_state != UNIT_LOADED)
+ if (UNIT(t)->load_state != UNIT_LOADED)
return 0;
if (!t->values) {
- log_error("%s lacks value setting. Refusing.", t->meta.id);
+ log_error("%s lacks value setting. Refusing.", UNIT(t)->id);
return -EINVAL;
}
@@ -80,7 +80,7 @@ static int timer_add_default_dependencies(Timer *t) {
assert(t);
- if (t->meta.manager->running_as == MANAGER_SYSTEM) {
+ if (UNIT(t)->manager->running_as == MANAGER_SYSTEM) {
if ((r = unit_add_dependency_by_name(UNIT(t), UNIT_BEFORE, SPECIAL_BASIC_TARGET, NULL, true)) < 0)
return r;
@@ -117,7 +117,7 @@ static int timer_load(Unit *u) {
if (r < 0)
return r;
- if (t->meta.default_dependencies)
+ if (UNIT(t)->default_dependencies)
if ((r = timer_add_default_dependencies(t)) < 0)
return r;
}
@@ -157,7 +157,7 @@ static void timer_set_state(Timer *t, TimerState state) {
if (state != old_state)
log_debug("%s changed %s -> %s",
- t->meta.id,
+ UNIT(t)->id,
timer_state_to_string(old_state),
timer_state_to_string(state));
@@ -209,7 +209,7 @@ static void timer_enter_waiting(Timer *t, bool initial) {
case TIMER_ACTIVE:
if (state_translation_table[t->state] == UNIT_ACTIVE)
- base = t->meta.inactive_exit_timestamp.monotonic;
+ base = UNIT(t)->inactive_exit_timestamp.monotonic;
else
base = n;
break;
@@ -220,7 +220,7 @@ static void timer_enter_waiting(Timer *t, bool initial) {
break;
case TIMER_STARTUP:
- base = t->meta.manager->startup_timestamp.monotonic;
+ base = UNIT(t)->manager->startup_timestamp.monotonic;
break;
case TIMER_UNIT_ACTIVE:
@@ -272,7 +272,7 @@ static void timer_enter_waiting(Timer *t, bool initial) {
return;
fail:
- log_warning("%s failed to enter waiting state: %s", t->meta.id, strerror(-r));
+ log_warning("%s failed to enter waiting state: %s", UNIT(t)->id, strerror(-r));
timer_enter_dead(t, false);
}
@@ -284,17 +284,17 @@ static void timer_enter_running(Timer *t) {
dbus_error_init(&error);
/* Don't start job if we are supposed to go down */
- if (t->meta.job && t->meta.job->type == JOB_STOP)
+ if (UNIT(t)->job && UNIT(t)->job->type == JOB_STOP)
return;
- if ((r = manager_add_job(t->meta.manager, JOB_START, UNIT_DEREF(t->unit), JOB_REPLACE, true, &error, NULL)) < 0)
+ if ((r = manager_add_job(UNIT(t)->manager, JOB_START, UNIT_DEREF(t->unit), JOB_REPLACE, true, &error, NULL)) < 0)
goto fail;
timer_set_state(t, TIMER_RUNNING);
return;
fail:
- log_warning("%s failed to queue unit startup job: %s", t->meta.id, bus_error(&error, r));
+ log_warning("%s failed to queue unit startup job: %s", UNIT(t)->id, bus_error(&error, r));
timer_enter_dead(t, false);
dbus_error_free(&error);
@@ -419,7 +419,7 @@ void timer_unit_notify(Unit *u, UnitActiveState new_state) {
case TIMER_RUNNING:
if (UNIT_IS_INACTIVE_OR_FAILED(new_state)) {
- log_debug("%s got notified about unit deactivation.", t->meta.id);
+ log_debug("%s got notified about unit deactivation.", UNIT(t)->id);
timer_enter_waiting(t, false);
}
commit ac155bb885f9ea8aac3979a6b2686f0c8a9cc6e3
Author: Michal Schmidt <mschmidt at redhat.com>
Date: Sun Jan 15 12:04:08 2012 +0100
unit: remove union Unit
Now that objects of all unit types are allocated the exact amount of
memory they need, the Unit union has lost its purpose. Remove it.
"Unit" is a more natural name for the base unit class than "Meta", so
rename Meta to Unit.
Access to members of the base class gets simplified.
diff --git a/src/automount.c b/src/automount.c
index c4191f6..6858e56 100644
--- a/src/automount.c
+++ b/src/automount.c
@@ -52,7 +52,7 @@ static void automount_init(Unit *u) {
Automount *a = AUTOMOUNT(u);
assert(u);
- assert(u->meta.load_state == UNIT_STUB);
+ assert(u->load_state == UNIT_STUB);
a->pipe_watch.fd = a->pipe_fd = -1;
a->pipe_watch.type = WATCH_INVALID;
@@ -137,7 +137,7 @@ int automount_add_one_mount_link(Automount *a, Mount *m) {
}
static int automount_add_mount_links(Automount *a) {
- Meta *other;
+ Unit *other;
int r;
assert(a);
@@ -198,17 +198,17 @@ static int automount_load(Unit *u) {
Automount *a = AUTOMOUNT(u);
assert(u);
- assert(u->meta.load_state == UNIT_STUB);
+ assert(u->load_state == UNIT_STUB);
/* Load a .automount file */
if ((r = unit_load_fragment_and_dropin_optional(u)) < 0)
return r;
- if (u->meta.load_state == UNIT_LOADED) {
+ if (u->load_state == UNIT_LOADED) {
Unit *x;
if (!a->where)
- if (!(a->where = unit_name_to_path(u->meta.id)))
+ if (!(a->where = unit_name_to_path(u->id)))
return -ENOMEM;
path_kill_slashes(a->where);
@@ -263,7 +263,7 @@ static int automount_coldplug(Unit *u) {
if (a->deserialized_state != a->state) {
- if ((r = open_dev_autofs(u->meta.manager)) < 0)
+ if ((r = open_dev_autofs(u->manager)) < 0)
return r;
if (a->deserialized_state == AUTOMOUNT_WAITING ||
@@ -617,11 +617,11 @@ static int automount_start(Unit *u) {
assert(a->state == AUTOMOUNT_DEAD || a->state == AUTOMOUNT_FAILED);
if (path_is_mount_point(a->where, false)) {
- log_error("Path %s is already a mount point, refusing start for %s", a->where, u->meta.id);
+ log_error("Path %s is already a mount point, refusing start for %s", a->where, u->id);
return -EEXIST;
}
- if (UNIT_DEREF(a->mount)->meta.load_state != UNIT_LOADED)
+ if (UNIT_DEREF(a->mount)->load_state != UNIT_LOADED)
return -ENOENT;
a->failure = false;
diff --git a/src/automount.h b/src/automount.h
index c6326ed..8334c97 100644
--- a/src/automount.h
+++ b/src/automount.h
@@ -36,7 +36,7 @@ typedef enum AutomountState {
} AutomountState;
struct Automount {
- Meta meta;
+ Unit meta;
AutomountState state, deserialized_state;
diff --git a/src/cgroup.c b/src/cgroup.c
index 9680cd6..e141b41 100644
--- a/src/cgroup.c
+++ b/src/cgroup.c
@@ -66,16 +66,16 @@ void cgroup_bonding_free(CGroupBonding *b, bool remove_or_trim) {
if (b->unit) {
CGroupBonding *f;
- LIST_REMOVE(CGroupBonding, by_unit, b->unit->meta.cgroup_bondings, b);
+ LIST_REMOVE(CGroupBonding, by_unit, b->unit->cgroup_bondings, b);
if (streq(b->controller, SYSTEMD_CGROUP_CONTROLLER)) {
- assert_se(f = hashmap_get(b->unit->meta.manager->cgroup_bondings, b->path));
+ assert_se(f = hashmap_get(b->unit->manager->cgroup_bondings, b->path));
LIST_REMOVE(CGroupBonding, by_path, f, b);
if (f)
- hashmap_replace(b->unit->meta.manager->cgroup_bondings, b->path, f);
+ hashmap_replace(b->unit->manager->cgroup_bondings, b->path, f);
else
- hashmap_remove(b->unit->meta.manager->cgroup_bondings, b->path);
+ hashmap_remove(b->unit->manager->cgroup_bondings, b->path);
}
}
@@ -388,7 +388,7 @@ int cgroup_notify_empty(Manager *m, const char *group) {
if (t > 0) {
/* If it is empty, let's delete it */
- cgroup_bonding_trim_list(b->unit->meta.cgroup_bondings, true);
+ cgroup_bonding_trim_list(b->unit->cgroup_bondings, true);
if (UNIT_VTABLE(b->unit)->cgroup_notify_empty)
UNIT_VTABLE(b->unit)->cgroup_notify_empty(b->unit);
diff --git a/src/dbus-automount.c b/src/dbus-automount.c
index 8268425..62e8a5f 100644
--- a/src/dbus-automount.c
+++ b/src/dbus-automount.c
@@ -46,10 +46,11 @@
const char bus_automount_interface[] _introspect_("Automount") = BUS_AUTOMOUNT_INTERFACE;
DBusHandlerResult bus_automount_message_handler(Unit *u, DBusConnection *c, DBusMessage *message) {
+ Automount *am = AUTOMOUNT(u);
const BusProperty properties[] = {
BUS_UNIT_PROPERTIES,
- { "org.freedesktop.systemd1.Automount", "Where", bus_property_append_string, "s", u->automount.where },
- { "org.freedesktop.systemd1.Automount", "DirectoryMode", bus_property_append_mode, "u", &u->automount.directory_mode },
+ { "org.freedesktop.systemd1.Automount", "Where", bus_property_append_string, "s", am->where },
+ { "org.freedesktop.systemd1.Automount", "DirectoryMode", bus_property_append_mode, "u", &am->directory_mode },
{ NULL, NULL, NULL, NULL, NULL }
};
diff --git a/src/dbus-device.c b/src/dbus-device.c
index f85ad2d..dd5d0e9 100644
--- a/src/dbus-device.c
+++ b/src/dbus-device.c
@@ -48,9 +48,10 @@ const char bus_device_invalidating_properties[] =
"SysFSPath\0";
DBusHandlerResult bus_device_message_handler(Unit *u, DBusConnection *c, DBusMessage *message) {
+ Device *d = DEVICE(u);
const BusProperty properties[] = {
BUS_UNIT_PROPERTIES,
- { "org.freedesktop.systemd1.Device", "SysFSPath", bus_property_append_string, "s", u->device.sysfs },
+ { "org.freedesktop.systemd1.Device", "SysFSPath", bus_property_append_string, "s", d->sysfs },
{ NULL, NULL, NULL, NULL, NULL }
};
diff --git a/src/dbus-job.c b/src/dbus-job.c
index 2308be3..82a23a8 100644
--- a/src/dbus-job.c
+++ b/src/dbus-job.c
@@ -71,7 +71,7 @@ static int bus_job_append_unit(DBusMessageIter *i, const char *property, void *d
if (!(p = unit_dbus_path(j->unit)))
return -ENOMEM;
- if (!dbus_message_iter_append_basic(&sub, DBUS_TYPE_STRING, &j->unit->meta.id) ||
+ if (!dbus_message_iter_append_basic(&sub, DBUS_TYPE_STRING, &j->unit->id) ||
!dbus_message_iter_append_basic(&sub, DBUS_TYPE_OBJECT_PATH, &p)) {
free(p);
return -ENOMEM;
diff --git a/src/dbus-manager.c b/src/dbus-manager.c
index 7b68156..710cbcb 100644
--- a/src/dbus-manager.c
+++ b/src/dbus-manager.c
@@ -777,39 +777,39 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
uint32_t job_id;
Unit *f;
- if (k != u->meta.id)
+ if (k != u->id)
continue;
if (!dbus_message_iter_open_container(&sub, DBUS_TYPE_STRUCT, NULL, &sub2))
goto oom;
description = unit_description(u);
- load_state = unit_load_state_to_string(u->meta.load_state);
+ load_state = unit_load_state_to_string(u->load_state);
active_state = unit_active_state_to_string(unit_active_state(u));
sub_state = unit_sub_state_to_string(u);
f = unit_following(u);
- following = f ? f->meta.id : "";
+ following = f ? f->id : "";
if (!(u_path = unit_dbus_path(u)))
goto oom;
- if (u->meta.job) {
- job_id = (uint32_t) u->meta.job->id;
+ if (u->job) {
+ job_id = (uint32_t) u->job->id;
- if (!(j_path = job_dbus_path(u->meta.job))) {
+ if (!(j_path = job_dbus_path(u->job))) {
free(u_path);
goto oom;
}
- sjob_type = job_type_to_string(u->meta.job->type);
+ sjob_type = job_type_to_string(u->job->type);
} else {
job_id = 0;
j_path = u_path;
sjob_type = "";
}
- if (!dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &u->meta.id) ||
+ if (!dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &u->id) ||
!dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &description) ||
!dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &load_state) ||
!dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &active_state) ||
@@ -820,13 +820,13 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
!dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &sjob_type) ||
!dbus_message_iter_append_basic(&sub2, DBUS_TYPE_OBJECT_PATH, &j_path)) {
free(u_path);
- if (u->meta.job)
+ if (u->job)
free(j_path);
goto oom;
}
free(u_path);
- if (u->meta.job)
+ if (u->job)
free(j_path);
if (!dbus_message_iter_close_container(&sub, &sub2))
@@ -871,7 +871,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
}
if (!dbus_message_iter_append_basic(&sub2, DBUS_TYPE_UINT32, &id) ||
- !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &j->unit->meta.id) ||
+ !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &j->unit->id) ||
!dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &type) ||
!dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &state) ||
!dbus_message_iter_append_basic(&sub2, DBUS_TYPE_OBJECT_PATH, &j_path) ||
@@ -1013,7 +1013,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
HASHMAP_FOREACH_KEY(u, k, m->units, i) {
char *p;
- if (k != u->meta.id)
+ if (k != u->id)
continue;
if (!(p = bus_path_escape(k))) {
@@ -1447,8 +1447,8 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
if (old_name)
if (!(u = manager_get_unit(m, old_name)) ||
- !u->meta.job ||
- u->meta.job->type != JOB_START) {
+ !u->job ||
+ u->job->type != JOB_START) {
dbus_set_error(&error, BUS_ERROR_NO_SUCH_JOB, "No job queued for unit %s", old_name);
return bus_send_error_reply(connection, message, &error, -ENOENT);
}
@@ -1469,10 +1469,10 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
job_type = JOB_RELOAD;
}
- if ((job_type == JOB_START && u->meta.refuse_manual_start) ||
- (job_type == JOB_STOP && u->meta.refuse_manual_stop) ||
+ if ((job_type == JOB_START && u->refuse_manual_start) ||
+ (job_type == JOB_STOP && u->refuse_manual_stop) ||
((job_type == JOB_RESTART || job_type == JOB_TRY_RESTART) &&
- (u->meta.refuse_manual_start || u->meta.refuse_manual_stop))) {
+ (u->refuse_manual_start || u->refuse_manual_stop))) {
dbus_set_error(&error, BUS_ERROR_ONLY_BY_DEPENDENCY, "Operation refused, may be requested by dependency only.");
return bus_send_error_reply(connection, message, &error, -EPERM);
}
diff --git a/src/dbus-mount.c b/src/dbus-mount.c
index cfbfd45..60f1e92 100644
--- a/src/dbus-mount.c
+++ b/src/dbus-mount.c
@@ -136,20 +136,20 @@ static int bus_mount_append_type(DBusMessageIter *i, const char *property, void
}
DBusHandlerResult bus_mount_message_handler(Unit *u, DBusConnection *c, DBusMessage *message) {
-
+ Mount *m = MOUNT(u);
const BusProperty properties[] = {
BUS_UNIT_PROPERTIES,
- { "org.freedesktop.systemd1.Mount", "Where", bus_property_append_string, "s", u->mount.where },
+ { "org.freedesktop.systemd1.Mount", "Where", bus_property_append_string, "s", m->where },
{ "org.freedesktop.systemd1.Mount", "What", bus_mount_append_what, "s", u },
{ "org.freedesktop.systemd1.Mount", "Options", bus_mount_append_options, "s", u },
{ "org.freedesktop.systemd1.Mount", "Type", bus_mount_append_type, "s", u },
- { "org.freedesktop.systemd1.Mount", "TimeoutUSec", bus_property_append_usec, "t", &u->mount.timeout_usec },
- BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Mount", u->mount.exec_command+MOUNT_EXEC_MOUNT, "ExecMount"),
- BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Mount", u->mount.exec_command+MOUNT_EXEC_UNMOUNT, "ExecUnmount"),
- BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Mount", u->mount.exec_command+MOUNT_EXEC_REMOUNT, "ExecRemount"),
- BUS_EXEC_CONTEXT_PROPERTIES("org.freedesktop.systemd1.Mount", u->mount.exec_context),
- { "org.freedesktop.systemd1.Mount", "ControlPID", bus_property_append_pid, "u", &u->mount.control_pid },
- { "org.freedesktop.systemd1.Mount", "DirectoryMode", bus_property_append_mode, "u", &u->mount.directory_mode },
+ { "org.freedesktop.systemd1.Mount", "TimeoutUSec", bus_property_append_usec, "t", &m->timeout_usec },
+ BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Mount", m->exec_command+MOUNT_EXEC_MOUNT, "ExecMount"),
+ BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Mount", m->exec_command+MOUNT_EXEC_UNMOUNT, "ExecUnmount"),
+ BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Mount", m->exec_command+MOUNT_EXEC_REMOUNT, "ExecRemount"),
+ BUS_EXEC_CONTEXT_PROPERTIES("org.freedesktop.systemd1.Mount", m->exec_context),
+ { "org.freedesktop.systemd1.Mount", "ControlPID", bus_property_append_pid, "u", &m->control_pid },
+ { "org.freedesktop.systemd1.Mount", "DirectoryMode", bus_property_append_mode, "u", &m->directory_mode },
{ NULL, NULL, NULL, NULL, NULL }
};
diff --git a/src/dbus-path.c b/src/dbus-path.c
index f67b5a2..53a5b42 100644
--- a/src/dbus-path.c
+++ b/src/dbus-path.c
@@ -80,24 +80,26 @@ static int bus_path_append_paths(DBusMessageIter *i, const char *property, void
static int bus_path_append_unit(DBusMessageIter *i, const char *property, void *data) {
Unit *u = data;
+ Path *p = PATH(u);
const char *t;
assert(i);
assert(property);
assert(u);
- t = UNIT_DEREF(u->path.unit) ? UNIT_DEREF(u->path.unit)->meta.id : "";
+ t = UNIT_DEREF(p->unit) ? UNIT_DEREF(p->unit)->id : "";
return dbus_message_iter_append_basic(i, DBUS_TYPE_STRING, &t) ? 0 : -ENOMEM;
}
DBusHandlerResult bus_path_message_handler(Unit *u, DBusConnection *c, DBusMessage *message) {
+ Path *p = PATH(u);
const BusProperty properties[] = {
BUS_UNIT_PROPERTIES,
- { "org.freedesktop.systemd1.Path", "Unit", bus_path_append_unit, "s", u },
- { "org.freedesktop.systemd1.Path", "Paths", bus_path_append_paths, "a(ss)", u },
- { "org.freedesktop.systemd1.Path", "MakeDirectory", bus_property_append_bool, "b", &u->path.make_directory },
- { "org.freedesktop.systemd1.Path", "DirectoryMode", bus_property_append_mode, "u", &u->path.directory_mode },
+ { "org.freedesktop.systemd1.Path", "Unit", bus_path_append_unit, "s", u },
+ { "org.freedesktop.systemd1.Path", "Paths", bus_path_append_paths, "a(ss)", u },
+ { "org.freedesktop.systemd1.Path", "MakeDirectory", bus_property_append_bool, "b", &p->make_directory },
+ { "org.freedesktop.systemd1.Path", "DirectoryMode", bus_property_append_mode, "u", &p->directory_mode },
{ NULL, NULL, NULL, NULL, NULL }
};
diff --git a/src/dbus-service.c b/src/dbus-service.c
index 373e3f5..2157c2b 100644
--- a/src/dbus-service.c
+++ b/src/dbus-service.c
@@ -95,36 +95,37 @@ static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_service_append_restart, service_resta
static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_service_append_notify_access, notify_access, NotifyAccess);
DBusHandlerResult bus_service_message_handler(Unit *u, DBusConnection *connection, DBusMessage *message) {
+ Service *s = SERVICE(u);
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", "NotifyAccess", bus_service_append_notify_access, "s", &u->service.notify_access },
- { "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 },
- BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Service", u->service.exec_command[SERVICE_EXEC_START_PRE], "ExecStartPre"),
- BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Service", u->service.exec_command[SERVICE_EXEC_START], "ExecStart"),
- BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Service", u->service.exec_command[SERVICE_EXEC_START_POST], "ExecStartPost"),
- BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Service", u->service.exec_command[SERVICE_EXEC_RELOAD], "ExecReload"),
- BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Service", u->service.exec_command[SERVICE_EXEC_STOP], "ExecStop"),
- BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Service", u->service.exec_command[SERVICE_EXEC_STOP_POST], "ExecStopPost"),
- 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", "RemainAfterExit", bus_property_append_bool, "b", &u->service.remain_after_exit },
- { "org.freedesktop.systemd1.Service", "GuessMainPID", bus_property_append_bool, "b", &u->service.guess_main_pid },
- BUS_EXEC_STATUS_PROPERTIES("org.freedesktop.systemd1.Service", u->service.main_exec_status, "ExecMain"),
- { "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", "BusName", bus_property_append_string, "s", u->service.bus_name },
- { "org.freedesktop.systemd1.Service", "StatusText", bus_property_append_string, "s", u->service.status_text },
+ { "org.freedesktop.systemd1.Service", "Type", bus_service_append_type, "s", &s->type },
+ { "org.freedesktop.systemd1.Service", "Restart", bus_service_append_restart, "s", &s->restart },
+ { "org.freedesktop.systemd1.Service", "PIDFile", bus_property_append_string, "s", s->pid_file },
+ { "org.freedesktop.systemd1.Service", "NotifyAccess", bus_service_append_notify_access, "s", &s->notify_access },
+ { "org.freedesktop.systemd1.Service", "RestartUSec", bus_property_append_usec, "t", &s->restart_usec },
+ { "org.freedesktop.systemd1.Service", "TimeoutUSec", bus_property_append_usec, "t", &s->timeout_usec },
+ BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Service", s->exec_command[SERVICE_EXEC_START_PRE], "ExecStartPre"),
+ BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Service", s->exec_command[SERVICE_EXEC_START], "ExecStart"),
+ BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Service", s->exec_command[SERVICE_EXEC_START_POST], "ExecStartPost"),
+ BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Service", s->exec_command[SERVICE_EXEC_RELOAD], "ExecReload"),
+ BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Service", s->exec_command[SERVICE_EXEC_STOP], "ExecStop"),
+ BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Service", s->exec_command[SERVICE_EXEC_STOP_POST], "ExecStopPost"),
+ BUS_EXEC_CONTEXT_PROPERTIES("org.freedesktop.systemd1.Service", s->exec_context),
+ { "org.freedesktop.systemd1.Service", "PermissionsStartOnly", bus_property_append_bool, "b", &s->permissions_start_only },
+ { "org.freedesktop.systemd1.Service", "RootDirectoryStartOnly", bus_property_append_bool, "b", &s->root_directory_start_only },
+ { "org.freedesktop.systemd1.Service", "RemainAfterExit", bus_property_append_bool, "b", &s->remain_after_exit },
+ { "org.freedesktop.systemd1.Service", "GuessMainPID", bus_property_append_bool, "b", &s->guess_main_pid },
+ BUS_EXEC_STATUS_PROPERTIES("org.freedesktop.systemd1.Service", s->main_exec_status, "ExecMain"),
+ { "org.freedesktop.systemd1.Service", "MainPID", bus_property_append_pid, "u", &s->main_pid },
+ { "org.freedesktop.systemd1.Service", "ControlPID", bus_property_append_pid, "u", &s->control_pid },
+ { "org.freedesktop.systemd1.Service", "BusName", bus_property_append_string, "s", s->bus_name },
+ { "org.freedesktop.systemd1.Service", "StatusText", bus_property_append_string, "s", s->status_text },
#ifdef HAVE_SYSV_COMPAT
- { "org.freedesktop.systemd1.Service", "SysVRunLevels", bus_property_append_string, "s", u->service.sysv_runlevels },
- { "org.freedesktop.systemd1.Service", "SysVStartPriority", bus_property_append_int, "i", &u->service.sysv_start_priority },
- { "org.freedesktop.systemd1.Service", "SysVPath", bus_property_append_string, "s", u->service.sysv_path },
+ { "org.freedesktop.systemd1.Service", "SysVRunLevels", bus_property_append_string, "s", s->sysv_runlevels },
+ { "org.freedesktop.systemd1.Service", "SysVStartPriority", bus_property_append_int, "i", &s->sysv_start_priority },
+ { "org.freedesktop.systemd1.Service", "SysVPath", bus_property_append_string, "s", s->sysv_path },
#endif
- { "org.freedesktop.systemd1.Service", "FsckPassNo", bus_property_append_int, "i", &u->service.fsck_passno },
+ { "org.freedesktop.systemd1.Service", "FsckPassNo", bus_property_append_int, "i", &s->fsck_passno },
{ NULL, NULL, NULL, NULL, NULL }
};
diff --git a/src/dbus-snapshot.c b/src/dbus-snapshot.c
index 0c2f349..0967034 100644
--- a/src/dbus-snapshot.c
+++ b/src/dbus-snapshot.c
@@ -46,10 +46,10 @@
const char bus_snapshot_interface[] _introspect_("Snapshot") = BUS_SNAPSHOT_INTERFACE;
DBusHandlerResult bus_snapshot_message_handler(Unit *u, DBusConnection *c, DBusMessage *message) {
-
+ Snapshot *s = SNAPSHOT(u);
const BusProperty properties[] = {
BUS_UNIT_PROPERTIES,
- { "org.freedesktop.systemd1.Snapshot", "Cleanup", bus_property_append_bool, "b", &u->snapshot.cleanup },
+ { "org.freedesktop.systemd1.Snapshot", "Cleanup", bus_property_append_bool, "b", &s->cleanup },
{ NULL, NULL, NULL, NULL, NULL }
};
diff --git a/src/dbus-socket.c b/src/dbus-socket.c
index c428189..9caed55 100644
--- a/src/dbus-socket.c
+++ b/src/dbus-socket.c
@@ -88,39 +88,39 @@ const char bus_socket_invalidating_properties[] =
static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_socket_append_bind_ipv6_only, socket_address_bind_ipv6_only, SocketAddressBindIPv6Only);
DBusHandlerResult bus_socket_message_handler(Unit *u, DBusConnection *c, DBusMessage *message) {
-
+ Socket *s = SOCKET(u);
const BusProperty properties[] = {
BUS_UNIT_PROPERTIES,
- { "org.freedesktop.systemd1.Socket", "BindIPv6Only", bus_socket_append_bind_ipv6_only, "s", &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 },
- BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Socket", u->service.exec_command[SOCKET_EXEC_START_PRE], "ExecStartPre"),
- BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Socket", u->service.exec_command[SOCKET_EXEC_START_POST], "ExecStartPost"),
- BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Socket", u->service.exec_command[SOCKET_EXEC_STOP_PRE], "ExecStopPre"),
- BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Socket", u->service.exec_command[SOCKET_EXEC_STOP_POST], "ExecStopPost"),
- BUS_EXEC_CONTEXT_PROPERTIES("org.freedesktop.systemd1.Socket", u->socket.exec_context),
- { "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 },
- { "org.freedesktop.systemd1.Socket", "KeepAlive", bus_property_append_bool, "b", &u->socket.keep_alive },
- { "org.freedesktop.systemd1.Socket", "Priority", bus_property_append_int, "i", &u->socket.priority },
- { "org.freedesktop.systemd1.Socket", "ReceiveBuffer", bus_property_append_size, "t", &u->socket.receive_buffer },
- { "org.freedesktop.systemd1.Socket", "SendBuffer", bus_property_append_size, "t", &u->socket.send_buffer },
- { "org.freedesktop.systemd1.Socket", "IPTOS", bus_property_append_int, "i", &u->socket.ip_tos },
- { "org.freedesktop.systemd1.Socket", "IPTTL", bus_property_append_int, "i", &u->socket.ip_ttl },
- { "org.freedesktop.systemd1.Socket", "PipeSize", bus_property_append_size, "t", &u->socket.pipe_size },
- { "org.freedesktop.systemd1.Socket", "FreeBind", bus_property_append_bool, "b", &u->socket.free_bind },
- { "org.freedesktop.systemd1.Socket", "Transparent", bus_property_append_bool, "b", &u->socket.transparent },
- { "org.freedesktop.systemd1.Socket", "Broadcast", bus_property_append_bool, "b", &u->socket.broadcast },
- { "org.freedesktop.systemd1.Socket", "PassCredentials",bus_property_append_bool, "b", &u->socket.pass_cred },
- { "org.freedesktop.systemd1.Socket", "Mark", bus_property_append_int, "i", &u->socket.mark },
- { "org.freedesktop.systemd1.Socket", "MaxConnections", bus_property_append_unsigned, "u", &u->socket.max_connections },
- { "org.freedesktop.systemd1.Socket", "NConnections", bus_property_append_unsigned, "u", &u->socket.n_connections },
- { "org.freedesktop.systemd1.Socket", "NAccepted", bus_property_append_unsigned, "u", &u->socket.n_accepted },
- { "org.freedesktop.systemd1.Socket", "MessageQueueMaxMessages", bus_property_append_long,"x", &u->socket.mq_maxmsg },
- { "org.freedesktop.systemd1.Socket", "MessageQueueMessageSize", bus_property_append_long,"x", &u->socket.mq_msgsize },
+ { "org.freedesktop.systemd1.Socket", "BindIPv6Only", bus_socket_append_bind_ipv6_only, "s", &s->bind_ipv6_only },
+ { "org.freedesktop.systemd1.Socket", "Backlog", bus_property_append_unsigned, "u", &s->backlog },
+ { "org.freedesktop.systemd1.Socket", "TimeoutUSec", bus_property_append_usec, "t", &s->timeout_usec },
+ BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Socket", s->exec_command[SOCKET_EXEC_START_PRE], "ExecStartPre"),
+ BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Socket", s->exec_command[SOCKET_EXEC_START_POST], "ExecStartPost"),
+ BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Socket", s->exec_command[SOCKET_EXEC_STOP_PRE], "ExecStopPre"),
+ BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Socket", s->exec_command[SOCKET_EXEC_STOP_POST], "ExecStopPost"),
+ BUS_EXEC_CONTEXT_PROPERTIES("org.freedesktop.systemd1.Socket", s->exec_context),
+ { "org.freedesktop.systemd1.Socket", "ControlPID", bus_property_append_pid, "u", &s->control_pid },
+ { "org.freedesktop.systemd1.Socket", "BindToDevice", bus_property_append_string, "s", s->bind_to_device },
+ { "org.freedesktop.systemd1.Socket", "DirectoryMode", bus_property_append_mode, "u", &s->directory_mode },
+ { "org.freedesktop.systemd1.Socket", "SocketMode", bus_property_append_mode, "u", &s->socket_mode },
+ { "org.freedesktop.systemd1.Socket", "Accept", bus_property_append_bool, "b", &s->accept },
+ { "org.freedesktop.systemd1.Socket", "KeepAlive", bus_property_append_bool, "b", &s->keep_alive },
+ { "org.freedesktop.systemd1.Socket", "Priority", bus_property_append_int, "i", &s->priority },
+ { "org.freedesktop.systemd1.Socket", "ReceiveBuffer", bus_property_append_size, "t", &s->receive_buffer },
+ { "org.freedesktop.systemd1.Socket", "SendBuffer", bus_property_append_size, "t", &s->send_buffer },
+ { "org.freedesktop.systemd1.Socket", "IPTOS", bus_property_append_int, "i", &s->ip_tos },
+ { "org.freedesktop.systemd1.Socket", "IPTTL", bus_property_append_int, "i", &s->ip_ttl },
+ { "org.freedesktop.systemd1.Socket", "PipeSize", bus_property_append_size, "t", &s->pipe_size },
+ { "org.freedesktop.systemd1.Socket", "FreeBind", bus_property_append_bool, "b", &s->free_bind },
+ { "org.freedesktop.systemd1.Socket", "Transparent", bus_property_append_bool, "b", &s->transparent },
+ { "org.freedesktop.systemd1.Socket", "Broadcast", bus_property_append_bool, "b", &s->broadcast },
+ { "org.freedesktop.systemd1.Socket", "PassCredentials",bus_property_append_bool, "b", &s->pass_cred },
+ { "org.freedesktop.systemd1.Socket", "Mark", bus_property_append_int, "i", &s->mark },
+ { "org.freedesktop.systemd1.Socket", "MaxConnections", bus_property_append_unsigned, "u", &s->max_connections },
+ { "org.freedesktop.systemd1.Socket", "NConnections", bus_property_append_unsigned, "u", &s->n_connections },
+ { "org.freedesktop.systemd1.Socket", "NAccepted", bus_property_append_unsigned, "u", &s->n_accepted },
+ { "org.freedesktop.systemd1.Socket", "MessageQueueMaxMessages", bus_property_append_long,"x", &s->mq_maxmsg },
+ { "org.freedesktop.systemd1.Socket", "MessageQueueMessageSize", bus_property_append_long,"x", &s->mq_msgsize },
{ NULL, NULL, NULL, NULL, NULL }
};
diff --git a/src/dbus-swap.c b/src/dbus-swap.c
index 988ca58..3002581 100644
--- a/src/dbus-swap.c
+++ b/src/dbus-swap.c
@@ -85,14 +85,15 @@ static int bus_swap_append_priority(DBusMessageIter *i, const char *property, vo
}
DBusHandlerResult bus_swap_message_handler(Unit *u, DBusConnection *c, DBusMessage *message) {
+ Swap *s = SWAP(u);
const BusProperty properties[] = {
BUS_UNIT_PROPERTIES,
- { "org.freedesktop.systemd1.Swap", "What", bus_property_append_string, "s", u->swap.what },
- { "org.freedesktop.systemd1.Swap", "Priority", bus_swap_append_priority, "i", u },
- BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Swap", u->swap.exec_command+SWAP_EXEC_ACTIVATE, "ExecActivate"),
- BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Swap", u->swap.exec_command+SWAP_EXEC_DEACTIVATE, "ExecDeactivate"),
- BUS_EXEC_CONTEXT_PROPERTIES("org.freedesktop.systemd1.Swap", u->swap.exec_context),
- { "org.freedesktop.systemd1.Swap", "ControlPID", bus_property_append_pid, "u", &u->swap.control_pid },
+ { "org.freedesktop.systemd1.Swap", "What", bus_property_append_string, "s", s->what },
+ { "org.freedesktop.systemd1.Swap", "Priority", bus_swap_append_priority, "i", u },
+ BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Swap", s->exec_command+SWAP_EXEC_ACTIVATE, "ExecActivate"),
+ BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Swap", s->exec_command+SWAP_EXEC_DEACTIVATE, "ExecDeactivate"),
+ BUS_EXEC_CONTEXT_PROPERTIES("org.freedesktop.systemd1.Swap", s->exec_context),
+ { "org.freedesktop.systemd1.Swap", "ControlPID", bus_property_append_pid, "u", &s->control_pid },
{ NULL, NULL, NULL, NULL, NULL }
};
diff --git a/src/dbus-timer.c b/src/dbus-timer.c
index 07d425e..0c4b4f3 100644
--- a/src/dbus-timer.c
+++ b/src/dbus-timer.c
@@ -101,23 +101,25 @@ static int bus_timer_append_timers(DBusMessageIter *i, const char *property, voi
static int bus_timer_append_unit(DBusMessageIter *i, const char *property, void *data) {
Unit *u = data;
+ Timer *timer = TIMER(u);
const char *t;
assert(i);
assert(property);
assert(u);
- t = UNIT_DEREF(u->timer.unit) ? UNIT_DEREF(u->timer.unit)->meta.id : "";
+ t = UNIT_DEREF(timer->unit) ? UNIT_DEREF(timer->unit)->id : "";
return dbus_message_iter_append_basic(i, DBUS_TYPE_STRING, &t) ? 0 : -ENOMEM;
}
DBusHandlerResult bus_timer_message_handler(Unit *u, DBusConnection *c, DBusMessage *message) {
+ Timer *t = TIMER(u);
const BusProperty properties[] = {
BUS_UNIT_PROPERTIES,
- { "org.freedesktop.systemd1.Timer", "Unit", bus_timer_append_unit, "s", u },
- { "org.freedesktop.systemd1.Timer", "Timers", bus_timer_append_timers, "a(stt)", u },
- { "org.freedesktop.systemd1.Timer", "NextElapseUSec", bus_property_append_usec, "t", &u->timer.next_elapse },
+ { "org.freedesktop.systemd1.Timer", "Unit", bus_timer_append_unit, "s", u },
+ { "org.freedesktop.systemd1.Timer", "Timers", bus_timer_append_timers, "a(stt)", u },
+ { "org.freedesktop.systemd1.Timer", "NextElapseUSec", bus_property_append_usec, "t", &t->next_elapse },
{ NULL, NULL, NULL, NULL, NULL }
};
diff --git a/src/dbus-unit.c b/src/dbus-unit.c
index 611a120..dc5321e 100644
--- a/src/dbus-unit.c
+++ b/src/dbus-unit.c
@@ -49,7 +49,7 @@ int bus_unit_append_names(DBusMessageIter *i, const char *property, void *data)
if (!dbus_message_iter_open_container(i, DBUS_TYPE_ARRAY, "s", &sub))
return -ENOMEM;
- SET_FOREACH(t, u->meta.names, j)
+ SET_FOREACH(t, u->names, j)
if (!dbus_message_iter_append_basic(&sub, DBUS_TYPE_STRING, &t))
return -ENOMEM;
@@ -68,7 +68,7 @@ int bus_unit_append_following(DBusMessageIter *i, const char *property, void *da
assert(u);
f = unit_following(u);
- d = f ? f->meta.id : "";
+ d = f ? f->id : "";
if (!dbus_message_iter_append_basic(i, DBUS_TYPE_STRING, &d))
return -ENOMEM;
@@ -86,7 +86,7 @@ int bus_unit_append_dependencies(DBusMessageIter *i, const char *property, void
return -ENOMEM;
SET_FOREACH(u, s, j)
- if (!dbus_message_iter_append_basic(&sub, DBUS_TYPE_STRING, &u->meta.id))
+ if (!dbus_message_iter_append_basic(&sub, DBUS_TYPE_STRING, &u->id))
return -ENOMEM;
if (!dbus_message_iter_close_container(i, &sub))
@@ -170,7 +170,7 @@ int bus_unit_append_can_start(DBusMessageIter *i, const char *property, void *da
assert(u);
b = unit_can_start(u) &&
- !u->meta.refuse_manual_start;
+ !u->refuse_manual_start;
if (!dbus_message_iter_append_basic(i, DBUS_TYPE_BOOLEAN, &b))
return -ENOMEM;
@@ -190,7 +190,7 @@ int bus_unit_append_can_stop(DBusMessageIter *i, const char *property, void *dat
* we can also stop */
b = unit_can_start(u) &&
- !u->meta.refuse_manual_stop;
+ !u->refuse_manual_stop;
if (!dbus_message_iter_append_basic(i, DBUS_TYPE_BOOLEAN, &b))
return -ENOMEM;
@@ -223,7 +223,7 @@ int bus_unit_append_can_isolate(DBusMessageIter *i, const char *property, void *
assert(u);
b = unit_can_isolate(u) &&
- !u->meta.refuse_manual_start;
+ !u->refuse_manual_start;
if (!dbus_message_iter_append_basic(i, DBUS_TYPE_BOOLEAN, &b))
return -ENOMEM;
@@ -243,12 +243,12 @@ int bus_unit_append_job(DBusMessageIter *i, const char *property, void *data) {
if (!dbus_message_iter_open_container(i, DBUS_TYPE_STRUCT, NULL, &sub))
return -ENOMEM;
- if (u->meta.job) {
+ if (u->job) {
- if (!(p = job_dbus_path(u->meta.job)))
+ if (!(p = job_dbus_path(u->job)))
return -ENOMEM;
- if (!dbus_message_iter_append_basic(&sub, DBUS_TYPE_UINT32, &u->meta.job->id) ||
+ if (!dbus_message_iter_append_basic(&sub, DBUS_TYPE_UINT32, &u->job->id) ||
!dbus_message_iter_append_basic(&sub, DBUS_TYPE_OBJECT_PATH, &p)) {
free(p);
return -ENOMEM;
@@ -310,7 +310,7 @@ int bus_unit_append_cgroups(DBusMessageIter *i, const char *property, void *data
if (!dbus_message_iter_open_container(i, DBUS_TYPE_ARRAY, "s", &sub))
return -ENOMEM;
- LIST_FOREACH(by_unit, cgb, u->meta.cgroup_bondings) {
+ LIST_FOREACH(by_unit, cgb, u->cgroup_bondings) {
char *t;
bool success;
@@ -338,7 +338,7 @@ int bus_unit_append_cgroup_attrs(DBusMessageIter *i, const char *property, void
if (!dbus_message_iter_open_container(i, DBUS_TYPE_ARRAY, "(sss)", &sub))
return -ENOMEM;
- LIST_FOREACH(by_unit, a, u->meta.cgroup_attributes) {
+ LIST_FOREACH(by_unit, a, u->cgroup_attributes) {
char *v = NULL;
bool success;
@@ -389,9 +389,9 @@ int bus_unit_append_load_error(DBusMessageIter *i, const char *property, void *d
assert(property);
assert(u);
- if (u->meta.load_error != 0) {
- name = bus_errno_to_dbus(u->meta.load_error);
- message = strempty(strerror(-u->meta.load_error));
+ if (u->load_error != 0) {
+ name = bus_errno_to_dbus(u->load_error);
+ message = strempty(strerror(-u->load_error));
} else
name = message = "";
@@ -406,7 +406,7 @@ int bus_unit_append_load_error(DBusMessageIter *i, const char *property, void *d
static DBusHandlerResult bus_unit_message_dispatch(Unit *u, DBusConnection *connection, DBusMessage *message) {
DBusMessage *reply = NULL;
- Manager *m = u->meta.manager;
+ Manager *m = u->manager;
DBusError error;
JobType job_type = _JOB_TYPE_INVALID;
char *path = NULL;
@@ -489,10 +489,10 @@ static DBusHandlerResult bus_unit_message_dispatch(Unit *u, DBusConnection *conn
Job *j;
int r;
- if ((job_type == JOB_START && u->meta.refuse_manual_start) ||
- (job_type == JOB_STOP && u->meta.refuse_manual_stop) ||
+ if ((job_type == JOB_START && u->refuse_manual_start) ||
+ (job_type == JOB_STOP && u->refuse_manual_stop) ||
((job_type == JOB_RESTART || job_type == JOB_TRY_RESTART) &&
- (u->meta.refuse_manual_start || u->meta.refuse_manual_stop))) {
+ (u->refuse_manual_start || u->refuse_manual_stop))) {
dbus_set_error(&error, BUS_ERROR_ONLY_BY_DEPENDENCY, "Operation refused, may be requested by dependency only.");
return bus_send_error_reply(connection, message, &error, -EPERM);
}
@@ -594,7 +594,7 @@ static DBusHandlerResult bus_unit_message_handler(DBusConnection *connection, DB
HASHMAP_FOREACH_KEY(u, k, m->units, i) {
char *p;
- if (k != u->meta.id)
+ if (k != u->id)
continue;
if (!(p = bus_path_escape(k))) {
@@ -673,23 +673,23 @@ void bus_unit_send_change_signal(Unit *u) {
assert(u);
- if (u->meta.in_dbus_queue) {
- LIST_REMOVE(Meta, dbus_queue, u->meta.manager->dbus_unit_queue, &u->meta);
- u->meta.in_dbus_queue = false;
+ if (u->in_dbus_queue) {
+ LIST_REMOVE(Unit, dbus_queue, u->manager->dbus_unit_queue, u);
+ u->in_dbus_queue = false;
}
- if (!u->meta.id)
+ if (!u->id)
return;
- if (!bus_has_subscriber(u->meta.manager)) {
- u->meta.sent_dbus_new_signal = true;
+ if (!bus_has_subscriber(u->manager)) {
+ u->sent_dbus_new_signal = true;
return;
}
if (!(p = unit_dbus_path(u)))
goto oom;
- if (u->meta.sent_dbus_new_signal) {
+ if (u->sent_dbus_new_signal) {
/* Send a properties changed signal. First for the
* specific type, then for the generic unit. The
* clients may rely on this order to get atomic
@@ -702,7 +702,7 @@ void bus_unit_send_change_signal(Unit *u) {
UNIT_VTABLE(u)->bus_invalidating_properties)))
goto oom;
- if (bus_broadcast(u->meta.manager, m) < 0)
+ if (bus_broadcast(u->manager, m) < 0)
goto oom;
dbus_message_unref(m);
@@ -718,19 +718,19 @@ void bus_unit_send_change_signal(Unit *u) {
goto oom;
if (!dbus_message_append_args(m,
- DBUS_TYPE_STRING, &u->meta.id,
+ DBUS_TYPE_STRING, &u->id,
DBUS_TYPE_OBJECT_PATH, &p,
DBUS_TYPE_INVALID))
goto oom;
}
- if (bus_broadcast(u->meta.manager, m) < 0)
+ if (bus_broadcast(u->manager, m) < 0)
goto oom;
free(p);
dbus_message_unref(m);
- u->meta.sent_dbus_new_signal = true;
+ u->sent_dbus_new_signal = true;
return;
@@ -749,13 +749,13 @@ void bus_unit_send_removed_signal(Unit *u) {
assert(u);
- if (!bus_has_subscriber(u->meta.manager))
+ if (!bus_has_subscriber(u->manager))
return;
- if (!u->meta.sent_dbus_new_signal)
+ if (!u->sent_dbus_new_signal)
bus_unit_send_change_signal(u);
- if (!u->meta.id)
+ if (!u->id)
return;
if (!(p = unit_dbus_path(u)))
@@ -765,12 +765,12 @@ void bus_unit_send_removed_signal(Unit *u) {
goto oom;
if (!dbus_message_append_args(m,
- DBUS_TYPE_STRING, &u->meta.id,
+ DBUS_TYPE_STRING, &u->id,
DBUS_TYPE_OBJECT_PATH, &p,
DBUS_TYPE_INVALID))
goto oom;
- if (bus_broadcast(u->meta.manager, m) < 0)
+ if (bus_broadcast(u->manager, m) < 0)
goto oom;
free(p);
diff --git a/src/dbus-unit.h b/src/dbus-unit.h
index 7a43410..6476c8a 100644
--- a/src/dbus-unit.h
+++ b/src/dbus-unit.h
@@ -127,63 +127,63 @@
"org.freedesktop.systemd1.Unit\0"
#define BUS_UNIT_PROPERTIES \
- { "org.freedesktop.systemd1.Unit", "Id", bus_property_append_string, "s", u->meta.id }, \
+ { "org.freedesktop.systemd1.Unit", "Id", bus_property_append_string, "s", u->id }, \
{ "org.freedesktop.systemd1.Unit", "Names", bus_unit_append_names, "as", u }, \
{ "org.freedesktop.systemd1.Unit", "Following", bus_unit_append_following, "s", u }, \
- { "org.freedesktop.systemd1.Unit", "Requires", bus_unit_append_dependencies, "as", u->meta.dependencies[UNIT_REQUIRES] }, \
- { "org.freedesktop.systemd1.Unit", "RequiresOverridable", bus_unit_append_dependencies, "as", u->meta.dependencies[UNIT_REQUIRES_OVERRIDABLE] }, \
- { "org.freedesktop.systemd1.Unit", "Requisite", bus_unit_append_dependencies, "as", u->meta.dependencies[UNIT_REQUISITE] }, \
- { "org.freedesktop.systemd1.Unit", "RequisiteOverridable", bus_unit_append_dependencies, "as", u->meta.dependencies[UNIT_REQUISITE_OVERRIDABLE] }, \
- { "org.freedesktop.systemd1.Unit", "Wants", bus_unit_append_dependencies, "as", u->meta.dependencies[UNIT_WANTS] }, \
- { "org.freedesktop.systemd1.Unit", "BindTo", bus_unit_append_dependencies, "as", u->meta.dependencies[UNIT_BIND_TO] }, \
- { "org.freedesktop.systemd1.Unit", "RequiredBy", bus_unit_append_dependencies, "as", u->meta.dependencies[UNIT_REQUIRED_BY] }, \
- { "org.freedesktop.systemd1.Unit", "RequiredByOverridable",bus_unit_append_dependencies, "as", u->meta.dependencies[UNIT_REQUIRED_BY_OVERRIDABLE] }, \
- { "org.freedesktop.systemd1.Unit", "WantedBy", bus_unit_append_dependencies, "as", u->meta.dependencies[UNIT_WANTED_BY] }, \
- { "org.freedesktop.systemd1.Unit", "BoundBy", bus_unit_append_dependencies, "as", u->meta.dependencies[UNIT_BOUND_BY] }, \
- { "org.freedesktop.systemd1.Unit", "Conflicts", bus_unit_append_dependencies, "as", u->meta.dependencies[UNIT_CONFLICTS] }, \
- { "org.freedesktop.systemd1.Unit", "ConflictedBy", bus_unit_append_dependencies, "as", u->meta.dependencies[UNIT_CONFLICTED_BY] }, \
- { "org.freedesktop.systemd1.Unit", "Before", bus_unit_append_dependencies, "as", u->meta.dependencies[UNIT_BEFORE] }, \
- { "org.freedesktop.systemd1.Unit", "After", bus_unit_append_dependencies, "as", u->meta.dependencies[UNIT_AFTER] }, \
- { "org.freedesktop.systemd1.Unit", "OnFailure", bus_unit_append_dependencies, "as", u->meta.dependencies[UNIT_ON_FAILURE] }, \
- { "org.freedesktop.systemd1.Unit", "Triggers", bus_unit_append_dependencies, "as", u->meta.dependencies[UNIT_TRIGGERS] }, \
- { "org.freedesktop.systemd1.Unit", "TriggeredBy", bus_unit_append_dependencies, "as", u->meta.dependencies[UNIT_TRIGGERED_BY] }, \
- { "org.freedesktop.systemd1.Unit", "PropagateReloadTo", bus_unit_append_dependencies, "as", u->meta.dependencies[UNIT_PROPAGATE_RELOAD_TO] }, \
- { "org.freedesktop.systemd1.Unit", "PropagateReloadFrom", bus_unit_append_dependencies, "as", u->meta.dependencies[UNIT_PROPAGATE_RELOAD_FROM] }, \
+ { "org.freedesktop.systemd1.Unit", "Requires", bus_unit_append_dependencies, "as", u->dependencies[UNIT_REQUIRES] }, \
+ { "org.freedesktop.systemd1.Unit", "RequiresOverridable", bus_unit_append_dependencies, "as", u->dependencies[UNIT_REQUIRES_OVERRIDABLE] }, \
+ { "org.freedesktop.systemd1.Unit", "Requisite", bus_unit_append_dependencies, "as", u->dependencies[UNIT_REQUISITE] }, \
+ { "org.freedesktop.systemd1.Unit", "RequisiteOverridable", bus_unit_append_dependencies, "as", u->dependencies[UNIT_REQUISITE_OVERRIDABLE] }, \
+ { "org.freedesktop.systemd1.Unit", "Wants", bus_unit_append_dependencies, "as", u->dependencies[UNIT_WANTS] }, \
+ { "org.freedesktop.systemd1.Unit", "BindTo", bus_unit_append_dependencies, "as", u->dependencies[UNIT_BIND_TO] }, \
+ { "org.freedesktop.systemd1.Unit", "RequiredBy", bus_unit_append_dependencies, "as", u->dependencies[UNIT_REQUIRED_BY] }, \
+ { "org.freedesktop.systemd1.Unit", "RequiredByOverridable",bus_unit_append_dependencies, "as", u->dependencies[UNIT_REQUIRED_BY_OVERRIDABLE] }, \
+ { "org.freedesktop.systemd1.Unit", "WantedBy", bus_unit_append_dependencies, "as", u->dependencies[UNIT_WANTED_BY] }, \
+ { "org.freedesktop.systemd1.Unit", "BoundBy", bus_unit_append_dependencies, "as", u->dependencies[UNIT_BOUND_BY] }, \
+ { "org.freedesktop.systemd1.Unit", "Conflicts", bus_unit_append_dependencies, "as", u->dependencies[UNIT_CONFLICTS] }, \
+ { "org.freedesktop.systemd1.Unit", "ConflictedBy", bus_unit_append_dependencies, "as", u->dependencies[UNIT_CONFLICTED_BY] }, \
+ { "org.freedesktop.systemd1.Unit", "Before", bus_unit_append_dependencies, "as", u->dependencies[UNIT_BEFORE] }, \
+ { "org.freedesktop.systemd1.Unit", "After", bus_unit_append_dependencies, "as", u->dependencies[UNIT_AFTER] }, \
+ { "org.freedesktop.systemd1.Unit", "OnFailure", bus_unit_append_dependencies, "as", u->dependencies[UNIT_ON_FAILURE] }, \
+ { "org.freedesktop.systemd1.Unit", "Triggers", bus_unit_append_dependencies, "as", u->dependencies[UNIT_TRIGGERS] }, \
+ { "org.freedesktop.systemd1.Unit", "TriggeredBy", bus_unit_append_dependencies, "as", u->dependencies[UNIT_TRIGGERED_BY] }, \
+ { "org.freedesktop.systemd1.Unit", "PropagateReloadTo", bus_unit_append_dependencies, "as", u->dependencies[UNIT_PROPAGATE_RELOAD_TO] }, \
+ { "org.freedesktop.systemd1.Unit", "PropagateReloadFrom", bus_unit_append_dependencies, "as", u->dependencies[UNIT_PROPAGATE_RELOAD_FROM] }, \
{ "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", "LoadState", bus_unit_append_load_state, "s", &u->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", "FragmentPath", bus_property_append_string, "s", u->fragment_path }, \
{ "org.freedesktop.systemd1.Unit", "UnitFileState", bus_unit_append_file_state, "s", u }, \
- { "org.freedesktop.systemd1.Unit", "InactiveExitTimestamp",bus_property_append_usec, "t", &u->meta.inactive_exit_timestamp.realtime }, \
- { "org.freedesktop.systemd1.Unit", "InactiveExitTimestampMonotonic",bus_property_append_usec, "t", &u->meta.inactive_exit_timestamp.monotonic }, \
- { "org.freedesktop.systemd1.Unit", "ActiveEnterTimestamp", bus_property_append_usec, "t", &u->meta.active_enter_timestamp.realtime }, \
- { "org.freedesktop.systemd1.Unit", "ActiveEnterTimestampMonotonic", bus_property_append_usec, "t", &u->meta.active_enter_timestamp.monotonic }, \
- { "org.freedesktop.systemd1.Unit", "ActiveExitTimestamp", bus_property_append_usec, "t", &u->meta.active_exit_timestamp.realtime }, \
- { "org.freedesktop.systemd1.Unit", "ActiveExitTimestampMonotonic", bus_property_append_usec, "t", &u->meta.active_exit_timestamp.monotonic }, \
- { "org.freedesktop.systemd1.Unit", "InactiveEnterTimestamp",bus_property_append_usec, "t", &u->meta.inactive_enter_timestamp.realtime }, \
- { "org.freedesktop.systemd1.Unit", "InactiveEnterTimestampMonotonic",bus_property_append_usec,"t", &u->meta.inactive_enter_timestamp.monotonic }, \
+ { "org.freedesktop.systemd1.Unit", "InactiveExitTimestamp",bus_property_append_usec, "t", &u->inactive_exit_timestamp.realtime }, \
+ { "org.freedesktop.systemd1.Unit", "InactiveExitTimestampMonotonic",bus_property_append_usec, "t", &u->inactive_exit_timestamp.monotonic }, \
+ { "org.freedesktop.systemd1.Unit", "ActiveEnterTimestamp", bus_property_append_usec, "t", &u->active_enter_timestamp.realtime }, \
+ { "org.freedesktop.systemd1.Unit", "ActiveEnterTimestampMonotonic", bus_property_append_usec, "t", &u->active_enter_timestamp.monotonic }, \
+ { "org.freedesktop.systemd1.Unit", "ActiveExitTimestamp", bus_property_append_usec, "t", &u->active_exit_timestamp.realtime }, \
+ { "org.freedesktop.systemd1.Unit", "ActiveExitTimestampMonotonic", bus_property_append_usec, "t", &u->active_exit_timestamp.monotonic }, \
+ { "org.freedesktop.systemd1.Unit", "InactiveEnterTimestamp",bus_property_append_usec, "t", &u->inactive_enter_timestamp.realtime }, \
+ { "org.freedesktop.systemd1.Unit", "InactiveEnterTimestampMonotonic",bus_property_append_usec,"t", &u->inactive_enter_timestamp.monotonic }, \
{ "org.freedesktop.systemd1.Unit", "CanStart", bus_unit_append_can_start, "b", u }, \
{ "org.freedesktop.systemd1.Unit", "CanStop", bus_unit_append_can_stop, "b", u }, \
{ "org.freedesktop.systemd1.Unit", "CanReload", bus_unit_append_can_reload, "b", u }, \
{ "org.freedesktop.systemd1.Unit", "CanIsolate", bus_unit_append_can_isolate, "b", u }, \
{ "org.freedesktop.systemd1.Unit", "Job", bus_unit_append_job, "(uo)", u }, \
- { "org.freedesktop.systemd1.Unit", "StopWhenUnneeded", bus_property_append_bool, "b", &u->meta.stop_when_unneeded }, \
- { "org.freedesktop.systemd1.Unit", "RefuseManualStart", bus_property_append_bool, "b", &u->meta.refuse_manual_start }, \
- { "org.freedesktop.systemd1.Unit", "RefuseManualStop", bus_property_append_bool, "b", &u->meta.refuse_manual_stop }, \
- { "org.freedesktop.systemd1.Unit", "AllowIsolate", bus_property_append_bool, "b", &u->meta.allow_isolate }, \
- { "org.freedesktop.systemd1.Unit", "DefaultDependencies", bus_property_append_bool, "b", &u->meta.default_dependencies }, \
- { "org.freedesktop.systemd1.Unit", "OnFailureIsolate", bus_property_append_bool, "b", &u->meta.on_failure_isolate }, \
- { "org.freedesktop.systemd1.Unit", "IgnoreOnIsolate", bus_property_append_bool, "b", &u->meta.ignore_on_isolate }, \
- { "org.freedesktop.systemd1.Unit", "IgnoreOnSnapshot", bus_property_append_bool, "b", &u->meta.ignore_on_snapshot }, \
+ { "org.freedesktop.systemd1.Unit", "StopWhenUnneeded", bus_property_append_bool, "b", &u->stop_when_unneeded }, \
+ { "org.freedesktop.systemd1.Unit", "RefuseManualStart", bus_property_append_bool, "b", &u->refuse_manual_start }, \
+ { "org.freedesktop.systemd1.Unit", "RefuseManualStop", bus_property_append_bool, "b", &u->refuse_manual_stop }, \
+ { "org.freedesktop.systemd1.Unit", "AllowIsolate", bus_property_append_bool, "b", &u->allow_isolate }, \
+ { "org.freedesktop.systemd1.Unit", "DefaultDependencies", bus_property_append_bool, "b", &u->default_dependencies }, \
+ { "org.freedesktop.systemd1.Unit", "OnFailureIsolate", bus_property_append_bool, "b", &u->on_failure_isolate }, \
+ { "org.freedesktop.systemd1.Unit", "IgnoreOnIsolate", bus_property_append_bool, "b", &u->ignore_on_isolate }, \
+ { "org.freedesktop.systemd1.Unit", "IgnoreOnSnapshot", bus_property_append_bool, "b", &u->ignore_on_snapshot }, \
{ "org.freedesktop.systemd1.Unit", "DefaultControlGroup", bus_unit_append_default_cgroup, "s", u }, \
{ "org.freedesktop.systemd1.Unit", "ControlGroup", bus_unit_append_cgroups, "as", u }, \
{ "org.freedesktop.systemd1.Unit", "ControlGroupAttributes", bus_unit_append_cgroup_attrs, "a(sss)", u }, \
{ "org.freedesktop.systemd1.Unit", "NeedDaemonReload", bus_unit_append_need_daemon_reload, "b", u }, \
- { "org.freedesktop.systemd1.Unit", "JobTimeoutUSec", bus_property_append_usec, "t", &u->meta.job_timeout }, \
- { "org.freedesktop.systemd1.Unit", "ConditionTimestamp", bus_property_append_usec, "t", &u->meta.condition_timestamp.realtime }, \
- { "org.freedesktop.systemd1.Unit", "ConditionTimestampMonotonic", bus_property_append_usec,"t", &u->meta.condition_timestamp.monotonic }, \
- { "org.freedesktop.systemd1.Unit", "ConditionResult", bus_property_append_bool, "b", &u->meta.condition_result }, \
+ { "org.freedesktop.systemd1.Unit", "JobTimeoutUSec", bus_property_append_usec, "t", &u->job_timeout }, \
+ { "org.freedesktop.systemd1.Unit", "ConditionTimestamp", bus_property_append_usec, "t", &u->condition_timestamp.realtime }, \
+ { "org.freedesktop.systemd1.Unit", "ConditionTimestampMonotonic", bus_property_append_usec,"t", &u->condition_timestamp.monotonic }, \
+ { "org.freedesktop.systemd1.Unit", "ConditionResult", bus_property_append_bool, "b", &u->condition_result }, \
{ "org.freedesktop.systemd1.Unit", "LoadError", bus_unit_append_load_error, "(ss)", u }
int bus_unit_append_names(DBusMessageIter *i, const char *property, void *data);
diff --git a/src/dbus.c b/src/dbus.c
index f9250f1..8e6e9fd 100644
--- a/src/dbus.c
+++ b/src/dbus.c
@@ -370,7 +370,7 @@ static DBusHandlerResult api_bus_message_filter(DBusConnection *connection, DBus
} else {
r = manager_load_unit(m, name, NULL, &error, &u);
- if (r >= 0 && u->meta.refuse_manual_start)
+ if (r >= 0 && u->refuse_manual_start)
r = -EPERM;
if (r >= 0)
diff --git a/src/device.c b/src/device.c
index 64665a8..9e5bd30 100644
--- a/src/device.c
+++ b/src/device.c
@@ -389,7 +389,7 @@ static Unit *device_following(Unit *u) {
assert(d);
- if (startswith(u->meta.id, "sys-"))
+ if (startswith(u->id, "sys-"))
return NULL;
/* Make everybody follow the unit that's named after the sysfs path */
diff --git a/src/device.h b/src/device.h
index 9a56a52..a05c3d3 100644
--- a/src/device.h
+++ b/src/device.h
@@ -36,7 +36,7 @@ typedef enum DeviceState {
} DeviceState;
struct Device {
- Meta meta;
+ Unit meta;
char *sysfs;
diff --git a/src/job.c b/src/job.c
index 85f2dee..e57286f 100644
--- a/src/job.c
+++ b/src/job.c
@@ -62,8 +62,8 @@ void job_free(Job *j) {
if (j->installed) {
bus_job_send_removed_signal(j);
- if (j->unit->meta.job == j) {
- j->unit->meta.job = NULL;
+ if (j->unit->job == j) {
+ j->unit->job = NULL;
unit_add_to_gc_queue(j->unit);
}
@@ -147,7 +147,7 @@ void job_dump(Job *j, FILE*f, const char *prefix) {
"%s\tState: %s\n"
"%s\tForced: %s\n",
prefix, j->id,
- prefix, j->unit->meta.id, job_type_to_string(j->type),
+ prefix, j->unit->id, job_type_to_string(j->type),
prefix, job_state_to_string(j->state),
prefix, yes_no(j->override));
}
@@ -326,19 +326,19 @@ bool job_is_runnable(Job *j) {
* dependencies, regardless whether they are
* starting or stopping something. */
- SET_FOREACH(other, j->unit->meta.dependencies[UNIT_AFTER], i)
- if (other->meta.job)
+ SET_FOREACH(other, j->unit->dependencies[UNIT_AFTER], i)
+ if (other->job)
return false;
}
/* Also, if something else is being stopped and we should
* change state after it, then lets wait. */
- SET_FOREACH(other, j->unit->meta.dependencies[UNIT_BEFORE], i)
- if (other->meta.job &&
- (other->meta.job->type == JOB_STOP ||
- other->meta.job->type == JOB_RESTART ||
- other->meta.job->type == JOB_TRY_RESTART))
+ SET_FOREACH(other, j->unit->dependencies[UNIT_BEFORE], i)
+ if (other->job &&
+ (other->job->type == JOB_STOP ||
+ other->job->type == JOB_RESTART ||
+ other->job->type == JOB_TRY_RESTART))
return false;
/* This means that for a service a and a service b where b
@@ -489,7 +489,7 @@ static void job_print_status_message(Unit *u, JobType t, JobResult result) {
case JOB_FAILED:
unit_status_printf(u, ANSI_HIGHLIGHT_RED_ON "FAILED" ANSI_HIGHLIGHT_OFF, "Failed to start %s", unit_description(u));
- unit_status_printf(u, NULL, "See 'systemctl status %s' for details.", u->meta.id);
+ unit_status_printf(u, NULL, "See 'systemctl status %s' for details.", u->id);
break;
case JOB_DEPENDENCY:
@@ -539,8 +539,8 @@ int job_finish_and_invalidate(Job *j, JobResult result) {
if (result == JOB_DONE && (j->type == JOB_RESTART || j->type == JOB_TRY_RESTART)) {
log_debug("Converting job %s/%s -> %s/%s",
- j->unit->meta.id, job_type_to_string(j->type),
- j->unit->meta.id, job_type_to_string(JOB_START));
+ j->unit->id, job_type_to_string(j->type),
+ j->unit->id, job_type_to_string(JOB_START));
j->state = JOB_WAITING;
j->type = JOB_START;
@@ -553,7 +553,7 @@ int job_finish_and_invalidate(Job *j, JobResult result) {
j->result = result;
- log_debug("Job %s/%s finished, result=%s", j->unit->meta.id, job_type_to_string(j->type), job_result_to_string(result));
+ log_debug("Job %s/%s finished, result=%s", j->unit->id, job_type_to_string(j->type), job_result_to_string(result));
if (result == JOB_FAILED)
j->manager->n_failed_jobs ++;
@@ -571,42 +571,42 @@ int job_finish_and_invalidate(Job *j, JobResult result) {
t == JOB_VERIFY_ACTIVE ||
t == JOB_RELOAD_OR_START) {
- SET_FOREACH(other, u->meta.dependencies[UNIT_REQUIRED_BY], i)
- if (other->meta.job &&
- (other->meta.job->type == JOB_START ||
- other->meta.job->type == JOB_VERIFY_ACTIVE ||
- other->meta.job->type == JOB_RELOAD_OR_START)) {
- job_finish_and_invalidate(other->meta.job, JOB_DEPENDENCY);
+ SET_FOREACH(other, u->dependencies[UNIT_REQUIRED_BY], i)
+ if (other->job &&
+ (other->job->type == JOB_START ||
+ other->job->type == JOB_VERIFY_ACTIVE ||
+ other->job->type == JOB_RELOAD_OR_START)) {
+ job_finish_and_invalidate(other->job, JOB_DEPENDENCY);
recursed = true;
}
- SET_FOREACH(other, u->meta.dependencies[UNIT_BOUND_BY], i)
- if (other->meta.job &&
- (other->meta.job->type == JOB_START ||
- other->meta.job->type == JOB_VERIFY_ACTIVE ||
- other->meta.job->type == JOB_RELOAD_OR_START)) {
- job_finish_and_invalidate(other->meta.job, JOB_DEPENDENCY);
+ SET_FOREACH(other, u->dependencies[UNIT_BOUND_BY], i)
+ if (other->job &&
+ (other->job->type == JOB_START ||
+ other->job->type == JOB_VERIFY_ACTIVE ||
+ other->job->type == JOB_RELOAD_OR_START)) {
+ job_finish_and_invalidate(other->job, JOB_DEPENDENCY);
recursed = true;
}
- SET_FOREACH(other, u->meta.dependencies[UNIT_REQUIRED_BY_OVERRIDABLE], i)
- if (other->meta.job &&
- !other->meta.job->override &&
- (other->meta.job->type == JOB_START ||
- other->meta.job->type == JOB_VERIFY_ACTIVE ||
- other->meta.job->type == JOB_RELOAD_OR_START)) {
- job_finish_and_invalidate(other->meta.job, JOB_DEPENDENCY);
+ SET_FOREACH(other, u->dependencies[UNIT_REQUIRED_BY_OVERRIDABLE], i)
+ if (other->job &&
+ !other->job->override &&
+ (other->job->type == JOB_START ||
+ other->job->type == JOB_VERIFY_ACTIVE ||
+ other->job->type == JOB_RELOAD_OR_START)) {
+ job_finish_and_invalidate(other->job, JOB_DEPENDENCY);
recursed = true;
}
} else if (t == JOB_STOP) {
- SET_FOREACH(other, u->meta.dependencies[UNIT_CONFLICTED_BY], i)
- if (other->meta.job &&
- (other->meta.job->type == JOB_START ||
- other->meta.job->type == JOB_VERIFY_ACTIVE ||
- other->meta.job->type == JOB_RELOAD_OR_START)) {
- job_finish_and_invalidate(other->meta.job, JOB_DEPENDENCY);
+ SET_FOREACH(other, u->dependencies[UNIT_CONFLICTED_BY], i)
+ if (other->job &&
+ (other->job->type == JOB_START ||
+ other->job->type == JOB_VERIFY_ACTIVE ||
+ other->job->type == JOB_RELOAD_OR_START)) {
+ job_finish_and_invalidate(other->job, JOB_DEPENDENCY);
recursed = true;
}
}
@@ -618,7 +618,7 @@ int job_finish_and_invalidate(Job *j, JobResult result) {
* unit itself. */
if (result == JOB_TIMEOUT || result == JOB_DEPENDENCY) {
log_notice("Job %s/%s failed with result '%s'.",
- u->meta.id,
+ u->id,
job_type_to_string(t),
job_result_to_string(result));
@@ -627,14 +627,14 @@ int job_finish_and_invalidate(Job *j, JobResult result) {
finish:
/* Try to start the next jobs that can be started */
- SET_FOREACH(other, u->meta.dependencies[UNIT_AFTER], i)
- if (other->meta.job)
- job_add_to_run_queue(other->meta.job);
- SET_FOREACH(other, u->meta.dependencies[UNIT_BEFORE], i)
- if (other->meta.job)
- job_add_to_run_queue(other->meta.job);
+ SET_FOREACH(other, u->dependencies[UNIT_AFTER], i)
+ if (other->job)
+ job_add_to_run_queue(other->job);
+ SET_FOREACH(other, u->dependencies[UNIT_BEFORE], i)
+ if (other->job)
+ job_add_to_run_queue(other->job);
- manager_check_finished(u->meta.manager);
+ manager_check_finished(u->manager);
return recursed;
}
@@ -645,7 +645,7 @@ int job_start_timer(Job *j) {
int fd, r;
assert(j);
- if (j->unit->meta.job_timeout <= 0 ||
+ if (j->unit->job_timeout <= 0 ||
j->timer_watch.type == WATCH_JOB_TIMER)
return 0;
@@ -657,7 +657,7 @@ int job_start_timer(Job *j) {
}
zero(its);
- timespec_store(&its.it_value, j->unit->meta.job_timeout);
+ timespec_store(&its.it_value, j->unit->job_timeout);
if (timerfd_settime(fd, 0, &its, NULL) < 0) {
r = -errno;
@@ -727,7 +727,7 @@ void job_timer_event(Job *j, uint64_t n_elapsed, Watch *w) {
assert(j);
assert(w == &j->timer_watch);
- log_warning("Job %s/%s timed out.", j->unit->meta.id, job_type_to_string(j->type));
+ log_warning("Job %s/%s timed out.", j->unit->id, job_type_to_string(j->type));
job_finish_and_invalidate(j, JOB_TIMEOUT);
}
diff --git a/src/load-dropin.c b/src/load-dropin.c
index d114faa..d869ee0 100644
--- a/src/load-dropin.c
+++ b/src/load-dropin.c
@@ -61,7 +61,7 @@ static int iterate_dir(Unit *u, const char *path, UnitDependency dependency) {
free(f);
if (r < 0)
- log_error("Cannot add dependency %s to %s, ignoring: %s", de->d_name, u->meta.id, strerror(-r));
+ log_error("Cannot add dependency %s to %s, ignoring: %s", de->d_name, u->id, strerror(-r));
}
r = 0;
@@ -84,8 +84,8 @@ static int process_dir(Unit *u, const char *unit_path, const char *name, const c
if (!path)
return -ENOMEM;
- if (u->meta.manager->unit_path_cache &&
- !set_get(u->meta.manager->unit_path_cache, path))
+ if (u->manager->unit_path_cache &&
+ !set_get(u->manager->unit_path_cache, path))
r = 0;
else
r = iterate_dir(u, path, dependency);
@@ -94,7 +94,7 @@ static int process_dir(Unit *u, const char *unit_path, const char *name, const c
if (r < 0)
return r;
- if (u->meta.instance) {
+ if (u->instance) {
char *template;
/* Also try the template dir */
@@ -108,8 +108,8 @@ static int process_dir(Unit *u, const char *unit_path, const char *name, const c
if (!path)
return -ENOMEM;
- if (u->meta.manager->unit_path_cache &&
- !set_get(u->meta.manager->unit_path_cache, path))
+ if (u->manager->unit_path_cache &&
+ !set_get(u->manager->unit_path_cache, path))
r = 0;
else
r = iterate_dir(u, path, dependency);
@@ -130,10 +130,10 @@ int unit_load_dropin(Unit *u) {
/* Load dependencies from supplementary drop-in directories */
- SET_FOREACH(t, u->meta.names, i) {
+ SET_FOREACH(t, u->names, i) {
char **p;
- STRV_FOREACH(p, u->meta.manager->lookup_paths.unit_path) {
+ STRV_FOREACH(p, u->manager->lookup_paths.unit_path) {
int r;
r = process_dir(u, *p, t, ".wants", UNIT_WANTS);
diff --git a/src/load-fragment-gperf.gperf.m4 b/src/load-fragment-gperf.gperf.m4
index 11e6324..c3f2957 100644
--- a/src/load-fragment-gperf.gperf.m4
+++ b/src/load-fragment-gperf.gperf.m4
@@ -89,7 +89,7 @@ $1.UtmpIdentifier, config_parse_unit_string_printf, 0,
$1.ControlGroupModify, config_parse_bool, 0, offsetof($1, exec_context.control_group_modify)'
)m4_dnl
Unit.Names, config_parse_unit_names, 0, 0
-Unit.Description, config_parse_unit_string_printf, 0, offsetof(Meta, description)
+Unit.Description, config_parse_unit_string_printf, 0, offsetof(Unit, description)
Unit.Requires, config_parse_unit_deps, UNIT_REQUIRES, 0
Unit.RequiresOverridable, config_parse_unit_deps, UNIT_REQUIRES_OVERRIDABLE, 0
Unit.Requisite, config_parse_unit_deps, UNIT_REQUISITE, 0
@@ -102,15 +102,15 @@ Unit.After, config_parse_unit_deps, UNIT_AFTER,
Unit.OnFailure, config_parse_unit_deps, UNIT_ON_FAILURE, 0
Unit.PropagateReloadTo, config_parse_unit_deps, UNIT_PROPAGATE_RELOAD_TO, 0
Unit.PropagateReloadFrom, config_parse_unit_deps, UNIT_PROPAGATE_RELOAD_FROM, 0
-Unit.StopWhenUnneeded, config_parse_bool, 0, offsetof(Meta, stop_when_unneeded)
-Unit.RefuseManualStart, config_parse_bool, 0, offsetof(Meta, refuse_manual_start)
-Unit.RefuseManualStop, config_parse_bool, 0, offsetof(Meta, refuse_manual_stop)
-Unit.AllowIsolate, config_parse_bool, 0, offsetof(Meta, allow_isolate)
-Unit.DefaultDependencies, config_parse_bool, 0, offsetof(Meta, default_dependencies)
-Unit.OnFailureIsolate, config_parse_bool, 0, offsetof(Meta, on_failure_isolate)
-Unit.IgnoreOnIsolate, config_parse_bool, 0, offsetof(Meta, ignore_on_isolate)
-Unit.IgnoreOnSnapshot, config_parse_bool, 0, offsetof(Meta, ignore_on_snapshot)
-Unit.JobTimeoutSec, config_parse_usec, 0, offsetof(Meta, job_timeout)
+Unit.StopWhenUnneeded, config_parse_bool, 0, offsetof(Unit, stop_when_unneeded)
+Unit.RefuseManualStart, config_parse_bool, 0, offsetof(Unit, refuse_manual_start)
+Unit.RefuseManualStop, config_parse_bool, 0, offsetof(Unit, refuse_manual_stop)
+Unit.AllowIsolate, config_parse_bool, 0, offsetof(Unit, allow_isolate)
+Unit.DefaultDependencies, config_parse_bool, 0, offsetof(Unit, default_dependencies)
+Unit.OnFailureIsolate, config_parse_bool, 0, offsetof(Unit, on_failure_isolate)
+Unit.IgnoreOnIsolate, config_parse_bool, 0, offsetof(Unit, ignore_on_isolate)
+Unit.IgnoreOnSnapshot, config_parse_bool, 0, offsetof(Unit, ignore_on_snapshot)
+Unit.JobTimeoutSec, config_parse_usec, 0, offsetof(Unit, job_timeout)
Unit.ConditionPathExists, config_parse_unit_condition_path, CONDITION_PATH_EXISTS, 0
Unit.ConditionPathExistsGlob, config_parse_unit_condition_path, CONDITION_PATH_EXISTS_GLOB, 0
Unit.ConditionPathIsDirectory, config_parse_unit_condition_path, CONDITION_PATH_IS_DIRECTORY, 0
diff --git a/src/load-fragment.c b/src/load-fragment.c
index ef5d192..213b1e2 100644
--- a/src/load-fragment.c
+++ b/src/load-fragment.c
@@ -1569,7 +1569,7 @@ int config_parse_unit_condition_path(
if (!c)
return -ENOMEM;
- LIST_PREPEND(Condition, conditions, u->meta.conditions, c);
+ LIST_PREPEND(Condition, conditions, u->conditions, c);
return 0;
}
@@ -1602,7 +1602,7 @@ int config_parse_unit_condition_string(
if (!(c = condition_new(cond, rvalue, trigger, negate)))
return -ENOMEM;
- LIST_PREPEND(Condition, conditions, u->meta.conditions, c);
+ LIST_PREPEND(Condition, conditions, u->conditions, c);
return 0;
}
@@ -1643,7 +1643,7 @@ int config_parse_unit_condition_null(
if (!(c = condition_new(CONDITION_NULL, NULL, trigger, negate)))
return -ENOMEM;
- LIST_PREPEND(Condition, conditions, u->meta.conditions, c);
+ LIST_PREPEND(Condition, conditions, u->conditions, c);
return 0;
}
@@ -2109,7 +2109,7 @@ static int merge_by_names(Unit **u, Set *names, const char *id) {
* ours? Then let's try it the other way
* round */
- other = manager_get_unit((*u)->meta.manager, k);
+ other = manager_get_unit((*u)->manager, k);
free(k);
if (other)
@@ -2163,7 +2163,7 @@ static int load_from_path(Unit *u, const char *path) {
} else {
char **p;
- STRV_FOREACH(p, u->meta.manager->lookup_paths.unit_path) {
+ STRV_FOREACH(p, u->manager->lookup_paths.unit_path) {
/* Instead of opening the path right away, we manually
* follow all symlinks and add their name to our unit
@@ -2173,8 +2173,8 @@ static int load_from_path(Unit *u, const char *path) {
goto finish;
}
- if (u->meta.manager->unit_path_cache &&
- !set_get(u->meta.manager->unit_path_cache, filename))
+ if (u->manager->unit_path_cache &&
+ !set_get(u->manager->unit_path_cache, filename))
r = -ENOENT;
else
r = open_follow(&filename, &f, symlink_names, &id);
@@ -2210,7 +2210,7 @@ static int load_from_path(Unit *u, const char *path) {
goto finish;
if (merged != u) {
- u->meta.load_state = UNIT_MERGED;
+ u->load_state = UNIT_MERGED;
r = 0;
goto finish;
}
@@ -2222,21 +2222,21 @@ static int load_from_path(Unit *u, const char *path) {
}
if (null_or_empty(&st))
- u->meta.load_state = UNIT_MASKED;
+ u->load_state = UNIT_MASKED;
else {
/* Now, parse the file contents */
r = config_parse(filename, f, UNIT_VTABLE(u)->sections, config_item_perf_lookup, (void*) load_fragment_gperf_lookup, false, u);
if (r < 0)
goto finish;
- u->meta.load_state = UNIT_LOADED;
+ u->load_state = UNIT_LOADED;
}
- free(u->meta.fragment_path);
- u->meta.fragment_path = filename;
+ free(u->fragment_path);
+ u->fragment_path = filename;
filename = NULL;
- u->meta.fragment_mtime = timespec_load(&st.st_mtim);
+ u->fragment_mtime = timespec_load(&st.st_mtim);
r = 0;
@@ -2256,49 +2256,49 @@ int unit_load_fragment(Unit *u) {
const char *t;
assert(u);
- assert(u->meta.load_state == UNIT_STUB);
- assert(u->meta.id);
+ assert(u->load_state == UNIT_STUB);
+ assert(u->id);
/* First, try to find the unit under its id. We always look
* for unit files in the default directories, to make it easy
* to override things by placing things in /etc/systemd/system */
- if ((r = load_from_path(u, u->meta.id)) < 0)
+ if ((r = load_from_path(u, u->id)) < 0)
return r;
/* Try to find an alias we can load this with */
- if (u->meta.load_state == UNIT_STUB)
- SET_FOREACH(t, u->meta.names, i) {
+ if (u->load_state == UNIT_STUB)
+ SET_FOREACH(t, u->names, i) {
- if (t == u->meta.id)
+ if (t == u->id)
continue;
if ((r = load_from_path(u, t)) < 0)
return r;
- if (u->meta.load_state != UNIT_STUB)
+ if (u->load_state != UNIT_STUB)
break;
}
/* And now, try looking for it under the suggested (originally linked) path */
- if (u->meta.load_state == UNIT_STUB && u->meta.fragment_path) {
+ if (u->load_state == UNIT_STUB && u->fragment_path) {
- if ((r = load_from_path(u, u->meta.fragment_path)) < 0)
+ if ((r = load_from_path(u, u->fragment_path)) < 0)
return r;
- if (u->meta.load_state == UNIT_STUB) {
+ if (u->load_state == UNIT_STUB) {
/* Hmm, this didn't work? Then let's get rid
* of the fragment path stored for us, so that
* we don't point to an invalid location. */
- free(u->meta.fragment_path);
- u->meta.fragment_path = NULL;
+ free(u->fragment_path);
+ u->fragment_path = NULL;
}
}
/* Look for a template */
- if (u->meta.load_state == UNIT_STUB && u->meta.instance) {
+ if (u->load_state == UNIT_STUB && u->instance) {
char *k;
- if (!(k = unit_name_template(u->meta.id)))
+ if (!(k = unit_name_template(u->id)))
return -ENOMEM;
r = load_from_path(u, k);
@@ -2307,10 +2307,10 @@ int unit_load_fragment(Unit *u) {
if (r < 0)
return r;
- if (u->meta.load_state == UNIT_STUB)
- SET_FOREACH(t, u->meta.names, i) {
+ if (u->load_state == UNIT_STUB)
+ SET_FOREACH(t, u->names, i) {
- if (t == u->meta.id)
+ if (t == u->id)
continue;
if (!(k = unit_name_template(t)))
@@ -2322,7 +2322,7 @@ int unit_load_fragment(Unit *u) {
if (r < 0)
return r;
- if (u->meta.load_state != UNIT_STUB)
+ if (u->load_state != UNIT_STUB)
break;
}
}
diff --git a/src/main.c b/src/main.c
index 91516da..cec9b49 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1408,28 +1408,28 @@ int main(int argc, char *argv[]) {
if ((r = manager_load_unit(m, arg_default_unit, NULL, &error, &target)) < 0) {
log_error("Failed to load default target: %s", bus_error(&error, r));
dbus_error_free(&error);
- } else if (target->meta.load_state == UNIT_ERROR)
- log_error("Failed to load default target: %s", strerror(-target->meta.load_error));
- else if (target->meta.load_state == UNIT_MASKED)
+ } else if (target->load_state == UNIT_ERROR)
+ log_error("Failed to load default target: %s", strerror(-target->load_error));
+ else if (target->load_state == UNIT_MASKED)
log_error("Default target masked.");
- if (!target || target->meta.load_state != UNIT_LOADED) {
+ if (!target || target->load_state != UNIT_LOADED) {
log_info("Trying to load rescue target...");
if ((r = manager_load_unit(m, SPECIAL_RESCUE_TARGET, NULL, &error, &target)) < 0) {
log_error("Failed to load rescue target: %s", bus_error(&error, r));
dbus_error_free(&error);
goto finish;
- } else if (target->meta.load_state == UNIT_ERROR) {
- log_error("Failed to load rescue target: %s", strerror(-target->meta.load_error));
+ } else if (target->load_state == UNIT_ERROR) {
+ log_error("Failed to load rescue target: %s", strerror(-target->load_error));
goto finish;
- } else if (target->meta.load_state == UNIT_MASKED) {
+ } else if (target->load_state == UNIT_MASKED) {
log_error("Rescue target masked.");
goto finish;
}
}
- assert(target->meta.load_state == UNIT_LOADED);
+ assert(target->load_state == UNIT_LOADED);
if (arg_action == ACTION_TEST) {
printf("-> By units:\n");
diff --git a/src/manager.c b/src/manager.c
index 6831973..43460f1 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -306,7 +306,7 @@ fail:
}
static unsigned manager_dispatch_cleanup_queue(Manager *m) {
- Meta *meta;
+ Unit *meta;
unsigned n = 0;
assert(m);
@@ -336,28 +336,28 @@ static void unit_gc_sweep(Unit *u, unsigned gc_marker) {
assert(u);
- if (u->meta.gc_marker == gc_marker + GC_OFFSET_GOOD ||
- u->meta.gc_marker == gc_marker + GC_OFFSET_BAD ||
- u->meta.gc_marker == gc_marker + GC_OFFSET_IN_PATH)
+ if (u->gc_marker == gc_marker + GC_OFFSET_GOOD ||
+ u->gc_marker == gc_marker + GC_OFFSET_BAD ||
+ u->gc_marker == gc_marker + GC_OFFSET_IN_PATH)
return;
- if (u->meta.in_cleanup_queue)
+ if (u->in_cleanup_queue)
goto bad;
if (unit_check_gc(u))
goto good;
- u->meta.gc_marker = gc_marker + GC_OFFSET_IN_PATH;
+ u->gc_marker = gc_marker + GC_OFFSET_IN_PATH;
is_bad = true;
- SET_FOREACH(other, u->meta.dependencies[UNIT_REFERENCED_BY], i) {
+ SET_FOREACH(other, u->dependencies[UNIT_REFERENCED_BY], i) {
unit_gc_sweep(other, gc_marker);
- if (other->meta.gc_marker == gc_marker + GC_OFFSET_GOOD)
+ if (other->gc_marker == gc_marker + GC_OFFSET_GOOD)
goto good;
- if (other->meta.gc_marker != gc_marker + GC_OFFSET_BAD)
+ if (other->gc_marker != gc_marker + GC_OFFSET_BAD)
is_bad = false;
}
@@ -366,23 +366,23 @@ static void unit_gc_sweep(Unit *u, unsigned gc_marker) {
/* We were unable to find anything out about this entry, so
* let's investigate it later */
- u->meta.gc_marker = gc_marker + GC_OFFSET_UNSURE;
+ u->gc_marker = gc_marker + GC_OFFSET_UNSURE;
unit_add_to_gc_queue(u);
return;
bad:
/* We definitely know that this one is not useful anymore, so
* let's mark it for deletion */
- u->meta.gc_marker = gc_marker + GC_OFFSET_BAD;
+ u->gc_marker = gc_marker + GC_OFFSET_BAD;
unit_add_to_cleanup_queue(u);
return;
good:
- u->meta.gc_marker = gc_marker + GC_OFFSET_GOOD;
+ u->gc_marker = gc_marker + GC_OFFSET_GOOD;
}
static unsigned manager_dispatch_gc_queue(Manager *m) {
- Meta *meta;
+ Unit *meta;
unsigned n = 0;
unsigned gc_marker;
@@ -406,7 +406,7 @@ static unsigned manager_dispatch_gc_queue(Manager *m) {
unit_gc_sweep((Unit*) meta, gc_marker);
- LIST_REMOVE(Meta, gc_queue, m->gc_queue, meta);
+ LIST_REMOVE(Unit, gc_queue, m->gc_queue, meta);
meta->in_gc_queue = false;
n++;
@@ -530,7 +530,7 @@ int manager_coldplug(Manager *m) {
HASHMAP_FOREACH_KEY(u, k, m->units, i) {
/* ignore aliases */
- if (u->meta.id != k)
+ if (u->id != k)
continue;
if ((q = unit_coldplug(u)) < 0)
@@ -823,8 +823,8 @@ static int delete_one_unmergeable_job(Manager *m, Job *j) {
* another unit in which case we
* rather remove the start. */
- log_debug("Looking at job %s/%s conflicted_by=%s", j->unit->meta.id, job_type_to_string(j->type), yes_no(j->type == JOB_STOP && job_is_conflicted_by(j)));
- log_debug("Looking at job %s/%s conflicted_by=%s", k->unit->meta.id, job_type_to_string(k->type), yes_no(k->type == JOB_STOP && job_is_conflicted_by(k)));
+ log_debug("Looking at job %s/%s conflicted_by=%s", j->unit->id, job_type_to_string(j->type), yes_no(j->type == JOB_STOP && job_is_conflicted_by(j)));
+ log_debug("Looking at job %s/%s conflicted_by=%s", k->unit->id, job_type_to_string(k->type), yes_no(k->type == JOB_STOP && job_is_conflicted_by(k)));
if (j->type == JOB_STOP) {
@@ -850,7 +850,7 @@ static int delete_one_unmergeable_job(Manager *m, Job *j) {
return -ENOEXEC;
/* Ok, we can drop one, so let's do so. */
- log_debug("Fixing conflicting jobs by deleting job %s/%s", d->unit->meta.id, job_type_to_string(d->type));
+ log_debug("Fixing conflicting jobs by deleting job %s/%s", d->unit->id, job_type_to_string(d->type));
transaction_delete_job(m, d, true);
return 0;
}
@@ -888,7 +888,7 @@ static int transaction_merge_jobs(Manager *m, DBusError *e) {
/* We couldn't merge anything. Failure */
dbus_set_error(e, BUS_ERROR_TRANSACTION_JOBS_CONFLICTING, "Transaction contains conflicting jobs '%s' and '%s' for %s. Probably contradicting requirement dependencies configured.",
- job_type_to_string(t), job_type_to_string(k->type), k->unit->meta.id);
+ job_type_to_string(t), job_type_to_string(k->type), k->unit->id);
return r;
}
}
@@ -903,8 +903,8 @@ static int transaction_merge_jobs(Manager *m, DBusError *e) {
assert_se(job_type_merge(&t, k->type) == 0);
/* If an active job is mergeable, merge it too */
- if (j->unit->meta.job)
- job_type_merge(&t, j->unit->meta.job->type); /* Might fail. Which is OK */
+ if (j->unit->job)
+ job_type_merge(&t, j->unit->job->type); /* Might fail. Which is OK */
while ((k = j->transaction_next)) {
if (j->installed) {
@@ -914,8 +914,8 @@ static int transaction_merge_jobs(Manager *m, DBusError *e) {
transaction_merge_and_delete_job(m, j, k, t);
}
- if (j->unit->meta.job && !j->installed)
- transaction_merge_and_delete_job(m, j, j->unit->meta.job, t);
+ if (j->unit->job && !j->installed)
+ transaction_merge_and_delete_job(m, j, j->unit->job, t);
assert(!j->transaction_next);
assert(!j->transaction_prev);
@@ -946,7 +946,7 @@ static void transaction_drop_redundant(Manager *m) {
if (!job_is_anchor(k) &&
(k->installed || job_type_is_redundant(k->type, unit_active_state(k->unit))) &&
- (!k->unit->meta.job || !job_type_is_conflicting(k->type, k->unit->meta.job->type)))
+ (!k->unit->job || !job_type_is_conflicting(k->type, k->unit->job->type)))
continue;
changes_something = true;
@@ -956,7 +956,7 @@ static void transaction_drop_redundant(Manager *m) {
if (changes_something)
continue;
- /* log_debug("Found redundant job %s/%s, dropping.", j->unit->meta.id, job_type_to_string(j->type)); */
+ /* log_debug("Found redundant job %s/%s, dropping.", j->unit->id, job_type_to_string(j->type)); */
transaction_delete_job(m, j, false);
again = true;
break;
@@ -1007,12 +1007,12 @@ static int transaction_verify_order_one(Manager *m, Job *j, Job *from, unsigned
* job to remove. We use the marker to find our way
* back, since smart how we are we stored our way back
* in there. */
- log_warning("Found ordering cycle on %s/%s", j->unit->meta.id, job_type_to_string(j->type));
+ log_warning("Found ordering cycle on %s/%s", j->unit->id, job_type_to_string(j->type));
delete = NULL;
for (k = from; k; k = ((k->generation == generation && k->marker != k) ? k->marker : NULL)) {
- log_info("Walked on cycle path to %s/%s", k->unit->meta.id, job_type_to_string(k->type));
+ log_info("Walked on cycle path to %s/%s", k->unit->id, job_type_to_string(k->type));
if (!delete &&
!k->installed &&
@@ -1030,7 +1030,7 @@ static int transaction_verify_order_one(Manager *m, Job *j, Job *from, unsigned
if (delete) {
- log_warning("Breaking ordering cycle by deleting job %s/%s", delete->unit->meta.id, job_type_to_string(delete->type));
+ log_warning("Breaking ordering cycle by deleting job %s/%s", delete->unit->id, job_type_to_string(delete->type));
transaction_delete_unit(m, delete->unit);
return -EAGAIN;
}
@@ -1050,7 +1050,7 @@ static int transaction_verify_order_one(Manager *m, Job *j, Job *from, unsigned
/* We assume that the the dependencies are bidirectional, and
* hence can ignore UNIT_AFTER */
- SET_FOREACH(u, j->unit->meta.dependencies[UNIT_BEFORE], i) {
+ SET_FOREACH(u, j->unit->dependencies[UNIT_BEFORE], i) {
Job *o;
/* Is there a job for this unit? */
@@ -1059,7 +1059,7 @@ static int transaction_verify_order_one(Manager *m, Job *j, Job *from, unsigned
/* Ok, there is no job for this in the
* transaction, but maybe there is already one
* running? */
- if (!(o = u->meta.job))
+ if (!(o = u->job))
continue;
if ((r = transaction_verify_order_one(m, o, j, generation, e)) < 0)
@@ -1110,13 +1110,13 @@ static void transaction_collect_garbage(Manager *m) {
HASHMAP_FOREACH(j, m->transaction_jobs, i) {
if (j->object_list) {
/* log_debug("Keeping job %s/%s because of %s/%s", */
- /* j->unit->meta.id, job_type_to_string(j->type), */
- /* j->object_list->subject ? j->object_list->subject->unit->meta.id : "root", */
+ /* j->unit->id, job_type_to_string(j->type), */
+ /* j->object_list->subject ? j->object_list->subject->unit->id : "root", */
/* j->object_list->subject ? job_type_to_string(j->object_list->subject->type) : "root"); */
continue;
}
- /* log_debug("Garbage collecting job %s/%s", j->unit->meta.id, job_type_to_string(j->type)); */
+ /* log_debug("Garbage collecting job %s/%s", j->unit->id, job_type_to_string(j->type)); */
transaction_delete_job(m, j, true);
again = true;
break;
@@ -1140,9 +1140,9 @@ static int transaction_is_destructive(Manager *m, DBusError *e) {
assert(!j->transaction_prev);
assert(!j->transaction_next);
- if (j->unit->meta.job &&
- j->unit->meta.job != j &&
- !job_type_is_superset(j->type, j->unit->meta.job->type)) {
+ if (j->unit->job &&
+ j->unit->job != j &&
+ !job_type_is_superset(j->type, j->unit->job->type)) {
dbus_set_error(e, BUS_ERROR_TRANSACTION_IS_DESTRUCTIVE, "Transaction is destructive.");
return -EEXIST;
@@ -1181,20 +1181,20 @@ static void transaction_minimize_impact(Manager *m) {
j->type == JOB_STOP && UNIT_IS_ACTIVE_OR_ACTIVATING(unit_active_state(j->unit));
changes_existing_job =
- j->unit->meta.job &&
- job_type_is_conflicting(j->type, j->unit->meta.job->type);
+ j->unit->job &&
+ job_type_is_conflicting(j->type, j->unit->job->type);
if (!stops_running_service && !changes_existing_job)
continue;
if (stops_running_service)
- log_debug("%s/%s would stop a running service.", j->unit->meta.id, job_type_to_string(j->type));
+ log_debug("%s/%s would stop a running service.", j->unit->id, job_type_to_string(j->type));
if (changes_existing_job)
- log_debug("%s/%s would change existing job.", j->unit->meta.id, job_type_to_string(j->type));
+ log_debug("%s/%s would change existing job.", j->unit->id, job_type_to_string(j->type));
/* Ok, let's get rid of this */
- log_debug("Deleting %s/%s to minimize impact.", j->unit->meta.id, job_type_to_string(j->type));
+ log_debug("Deleting %s/%s to minimize impact.", j->unit->id, job_type_to_string(j->type));
transaction_delete_job(m, j, true);
again = true;
@@ -1248,14 +1248,14 @@ static int transaction_apply(Manager *m, JobMode mode) {
while ((j = hashmap_steal_first(m->transaction_jobs))) {
if (j->installed) {
- /* log_debug("Skipping already installed job %s/%s as %u", j->unit->meta.id, job_type_to_string(j->type), (unsigned) j->id); */
+ /* log_debug("Skipping already installed job %s/%s as %u", j->unit->id, job_type_to_string(j->type), (unsigned) j->id); */
continue;
}
- if (j->unit->meta.job)
- job_free(j->unit->meta.job);
+ if (j->unit->job)
+ job_free(j->unit->job);
- j->unit->meta.job = j;
+ j->unit->job = j;
j->installed = true;
m->n_installed_jobs ++;
@@ -1269,7 +1269,7 @@ static int transaction_apply(Manager *m, JobMode mode) {
job_add_to_dbus_queue(j);
job_start_timer(j);
- log_debug("Installed new job %s/%s as %u", j->unit->meta.id, job_type_to_string(j->type), (unsigned) j->id);
+ log_debug("Installed new job %s/%s as %u", j->unit->id, job_type_to_string(j->type), (unsigned) j->id);
}
/* As last step, kill all remaining job dependencies. */
@@ -1399,8 +1399,8 @@ static Job* transaction_add_one_job(Manager *m, JobType type, Unit *unit, bool o
}
}
- if (unit->meta.job && unit->meta.job->type == type)
- j = unit->meta.job;
+ if (unit->job && unit->job->type == type)
+ j = unit->job;
else if (!(j = job_new(m, type, unit)))
return NULL;
@@ -1419,7 +1419,7 @@ static Job* transaction_add_one_job(Manager *m, JobType type, Unit *unit, bool o
if (is_new)
*is_new = true;
- /* log_debug("Added job %s/%s to transaction.", unit->meta.id, job_type_to_string(type)); */
+ /* log_debug("Added job %s/%s to transaction.", unit->id, job_type_to_string(type)); */
return j;
}
@@ -1450,8 +1450,8 @@ void manager_transaction_unlink_job(Manager *m, Job *j, bool delete_dependencies
if (other && delete_dependencies) {
log_debug("Deleting job %s/%s as dependency of job %s/%s",
- other->unit->meta.id, job_type_to_string(other->type),
- j->unit->meta.id, job_type_to_string(j->type));
+ other->unit->id, job_type_to_string(other->type),
+ j->unit->id, job_type_to_string(j->type));
transaction_delete_job(m, other, delete_dependencies);
}
}
@@ -1480,34 +1480,34 @@ static int transaction_add_job_and_dependencies(
assert(unit);
/* log_debug("Pulling in %s/%s from %s/%s", */
- /* unit->meta.id, job_type_to_string(type), */
- /* by ? by->unit->meta.id : "NA", */
+ /* unit->id, job_type_to_string(type), */
+ /* by ? by->unit->id : "NA", */
/* by ? job_type_to_string(by->type) : "NA"); */
- if (unit->meta.load_state != UNIT_LOADED &&
- unit->meta.load_state != UNIT_ERROR &&
- unit->meta.load_state != UNIT_MASKED) {
- dbus_set_error(e, BUS_ERROR_LOAD_FAILED, "Unit %s is not loaded properly.", unit->meta.id);
+ if (unit->load_state != UNIT_LOADED &&
+ unit->load_state != UNIT_ERROR &&
+ unit->load_state != UNIT_MASKED) {
+ dbus_set_error(e, BUS_ERROR_LOAD_FAILED, "Unit %s is not loaded properly.", unit->id);
return -EINVAL;
}
- if (type != JOB_STOP && unit->meta.load_state == UNIT_ERROR) {
+ if (type != JOB_STOP && unit->load_state == UNIT_ERROR) {
dbus_set_error(e, BUS_ERROR_LOAD_FAILED,
"Unit %s failed to load: %s. "
"See system logs and 'systemctl status %s' for details.",
- unit->meta.id,
- strerror(-unit->meta.load_error),
- unit->meta.id);
+ unit->id,
+ strerror(-unit->load_error),
+ unit->id);
return -EINVAL;
}
- if (type != JOB_STOP && unit->meta.load_state == UNIT_MASKED) {
- dbus_set_error(e, BUS_ERROR_MASKED, "Unit %s is masked.", unit->meta.id);
+ if (type != JOB_STOP && unit->load_state == UNIT_MASKED) {
+ dbus_set_error(e, BUS_ERROR_MASKED, "Unit %s is masked.", unit->id);
return -EINVAL;
}
if (!unit_job_is_applicable(unit, type)) {
- dbus_set_error(e, BUS_ERROR_JOB_TYPE_NOT_APPLICABLE, "Job type %s is not applicable for unit %s.", job_type_to_string(type), unit->meta.id);
+ dbus_set_error(e, BUS_ERROR_JOB_TYPE_NOT_APPLICABLE, "Job type %s is not applicable for unit %s.", job_type_to_string(type), unit->id);
return -EBADR;
}
@@ -1529,7 +1529,7 @@ static int transaction_add_job_and_dependencies(
if (unit_following_set(ret->unit, &following) > 0) {
SET_FOREACH(dep, following, i)
if ((r = transaction_add_job_and_dependencies(m, type, dep, ret, false, override, false, false, ignore_order, e, NULL)) < 0) {
- log_warning("Cannot add dependency job for unit %s, ignoring: %s", dep->meta.id, bus_error(e, r));
+ log_warning("Cannot add dependency job for unit %s, ignoring: %s", dep->id, bus_error(e, r));
if (e)
dbus_error_free(e);
@@ -1540,7 +1540,7 @@ static int transaction_add_job_and_dependencies(
/* Finally, recursively add in all dependencies. */
if (type == JOB_START || type == JOB_RELOAD_OR_START) {
- SET_FOREACH(dep, ret->unit->meta.dependencies[UNIT_REQUIRES], i)
+ SET_FOREACH(dep, ret->unit->dependencies[UNIT_REQUIRES], i)
if ((r = transaction_add_job_and_dependencies(m, JOB_START, dep, ret, true, override, false, false, ignore_order, e, NULL)) < 0) {
if (r != -EBADR)
goto fail;
@@ -1549,7 +1549,7 @@ static int transaction_add_job_and_dependencies(
dbus_error_free(e);
}
- SET_FOREACH(dep, ret->unit->meta.dependencies[UNIT_BIND_TO], i)
+ SET_FOREACH(dep, ret->unit->dependencies[UNIT_BIND_TO], i)
if ((r = transaction_add_job_and_dependencies(m, JOB_START, dep, ret, true, override, false, false, ignore_order, e, NULL)) < 0) {
if (r != -EBADR)
@@ -1559,23 +1559,23 @@ static int transaction_add_job_and_dependencies(
dbus_error_free(e);
}
- SET_FOREACH(dep, ret->unit->meta.dependencies[UNIT_REQUIRES_OVERRIDABLE], i)
+ SET_FOREACH(dep, ret->unit->dependencies[UNIT_REQUIRES_OVERRIDABLE], i)
if ((r = transaction_add_job_and_dependencies(m, JOB_START, dep, ret, !override, override, false, false, ignore_order, e, NULL)) < 0) {
- log_warning("Cannot add dependency job for unit %s, ignoring: %s", dep->meta.id, bus_error(e, r));
+ log_warning("Cannot add dependency job for unit %s, ignoring: %s", dep->id, bus_error(e, r));
if (e)
dbus_error_free(e);
}
- SET_FOREACH(dep, ret->unit->meta.dependencies[UNIT_WANTS], i)
+ SET_FOREACH(dep, ret->unit->dependencies[UNIT_WANTS], i)
if ((r = transaction_add_job_and_dependencies(m, JOB_START, dep, ret, false, false, false, false, ignore_order, e, NULL)) < 0) {
- log_warning("Cannot add dependency job for unit %s, ignoring: %s", dep->meta.id, bus_error(e, r));
+ log_warning("Cannot add dependency job for unit %s, ignoring: %s", dep->id, bus_error(e, r));
if (e)
dbus_error_free(e);
}
- SET_FOREACH(dep, ret->unit->meta.dependencies[UNIT_REQUISITE], i)
+ SET_FOREACH(dep, ret->unit->dependencies[UNIT_REQUISITE], i)
if ((r = transaction_add_job_and_dependencies(m, JOB_VERIFY_ACTIVE, dep, ret, true, override, false, false, ignore_order, e, NULL)) < 0) {
if (r != -EBADR)
@@ -1585,15 +1585,15 @@ static int transaction_add_job_and_dependencies(
dbus_error_free(e);
}
- SET_FOREACH(dep, ret->unit->meta.dependencies[UNIT_REQUISITE_OVERRIDABLE], i)
+ SET_FOREACH(dep, ret->unit->dependencies[UNIT_REQUISITE_OVERRIDABLE], i)
if ((r = transaction_add_job_and_dependencies(m, JOB_VERIFY_ACTIVE, dep, ret, !override, override, false, false, ignore_order, e, NULL)) < 0) {
- log_warning("Cannot add dependency job for unit %s, ignoring: %s", dep->meta.id, bus_error(e, r));
+ log_warning("Cannot add dependency job for unit %s, ignoring: %s", dep->id, bus_error(e, r));
if (e)
dbus_error_free(e);
}
- SET_FOREACH(dep, ret->unit->meta.dependencies[UNIT_CONFLICTS], i)
+ SET_FOREACH(dep, ret->unit->dependencies[UNIT_CONFLICTS], i)
if ((r = transaction_add_job_and_dependencies(m, JOB_STOP, dep, ret, true, override, true, false, ignore_order, e, NULL)) < 0) {
if (r != -EBADR)
@@ -1603,9 +1603,9 @@ static int transaction_add_job_and_dependencies(
dbus_error_free(e);
}
- SET_FOREACH(dep, ret->unit->meta.dependencies[UNIT_CONFLICTED_BY], i)
+ SET_FOREACH(dep, ret->unit->dependencies[UNIT_CONFLICTED_BY], i)
if ((r = transaction_add_job_and_dependencies(m, JOB_STOP, dep, ret, false, override, false, false, ignore_order, e, NULL)) < 0) {
- log_warning("Cannot add dependency job for unit %s, ignoring: %s", dep->meta.id, bus_error(e, r));
+ log_warning("Cannot add dependency job for unit %s, ignoring: %s", dep->id, bus_error(e, r));
if (e)
dbus_error_free(e);
@@ -1615,7 +1615,7 @@ static int transaction_add_job_and_dependencies(
if (type == JOB_STOP || type == JOB_RESTART || type == JOB_TRY_RESTART) {
- SET_FOREACH(dep, ret->unit->meta.dependencies[UNIT_REQUIRED_BY], i)
+ SET_FOREACH(dep, ret->unit->dependencies[UNIT_REQUIRED_BY], i)
if ((r = transaction_add_job_and_dependencies(m, type, dep, ret, true, override, false, false, ignore_order, e, NULL)) < 0) {
if (r != -EBADR)
@@ -1625,7 +1625,7 @@ static int transaction_add_job_and_dependencies(
dbus_error_free(e);
}
- SET_FOREACH(dep, ret->unit->meta.dependencies[UNIT_BOUND_BY], i)
+ SET_FOREACH(dep, ret->unit->dependencies[UNIT_BOUND_BY], i)
if ((r = transaction_add_job_and_dependencies(m, type, dep, ret, true, override, false, false, ignore_order, e, NULL)) < 0) {
if (r != -EBADR)
@@ -1638,11 +1638,11 @@ static int transaction_add_job_and_dependencies(
if (type == JOB_RELOAD || type == JOB_RELOAD_OR_START) {
- SET_FOREACH(dep, ret->unit->meta.dependencies[UNIT_PROPAGATE_RELOAD_TO], i) {
+ SET_FOREACH(dep, ret->unit->dependencies[UNIT_PROPAGATE_RELOAD_TO], i) {
r = transaction_add_job_and_dependencies(m, JOB_RELOAD, dep, ret, false, override, false, false, ignore_order, e, NULL);
if (r < 0) {
- log_warning("Cannot add dependency reload job for unit %s, ignoring: %s", dep->meta.id, bus_error(e, r));
+ log_warning("Cannot add dependency reload job for unit %s, ignoring: %s", dep->id, bus_error(e, r));
if (e)
dbus_error_free(e);
@@ -1673,14 +1673,14 @@ static int transaction_add_isolate_jobs(Manager *m) {
HASHMAP_FOREACH_KEY(u, k, m->units, i) {
/* ignore aliases */
- if (u->meta.id != k)
+ if (u->id != k)
continue;
- if (u->meta.ignore_on_isolate)
+ if (u->ignore_on_isolate)
continue;
/* No need to stop inactive jobs */
- if (UNIT_IS_INACTIVE_OR_FAILED(unit_active_state(u)) && !u->meta.job)
+ if (UNIT_IS_INACTIVE_OR_FAILED(unit_active_state(u)) && !u->job)
continue;
/* Is there already something listed for this? */
@@ -1688,7 +1688,7 @@ static int transaction_add_isolate_jobs(Manager *m) {
continue;
if ((r = transaction_add_job_and_dependencies(m, JOB_STOP, u, NULL, true, false, false, false, false, NULL, NULL)) < 0)
- log_warning("Cannot add isolate job for unit %s, ignoring: %s", u->meta.id, strerror(-r));
+ log_warning("Cannot add isolate job for unit %s, ignoring: %s", u->id, strerror(-r));
}
return 0;
@@ -1708,12 +1708,12 @@ int manager_add_job(Manager *m, JobType type, Unit *unit, JobMode mode, bool ove
return -EINVAL;
}
- if (mode == JOB_ISOLATE && !unit->meta.allow_isolate) {
+ if (mode == JOB_ISOLATE && !unit->allow_isolate) {
dbus_set_error(e, BUS_ERROR_NO_ISOLATION, "Operation refused, unit may not be isolated.");
return -EPERM;
}
- log_debug("Trying to enqueue job %s/%s/%s", unit->meta.id, job_type_to_string(type), job_mode_to_string(mode));
+ log_debug("Trying to enqueue job %s/%s/%s", unit->id, job_type_to_string(type), job_mode_to_string(mode));
if ((r = transaction_add_job_and_dependencies(m, type, unit, NULL, true, override, false,
mode == JOB_IGNORE_DEPENDENCIES || mode == JOB_IGNORE_REQUIREMENTS,
@@ -1731,7 +1731,7 @@ int manager_add_job(Manager *m, JobType type, Unit *unit, JobMode mode, bool ove
if ((r = transaction_activate(m, mode, e)) < 0)
return r;
- log_debug("Enqueued job %s/%s as %u", unit->meta.id, job_type_to_string(type), (unsigned) ret->id);
+ log_debug("Enqueued job %s/%s as %u", unit->id, job_type_to_string(type), (unsigned) ret->id);
if (_ret)
*_ret = ret;
@@ -1768,7 +1768,7 @@ Unit *manager_get_unit(Manager *m, const char *name) {
}
unsigned manager_dispatch_load_queue(Manager *m) {
- Meta *meta;
+ Unit *meta;
unsigned n = 0;
assert(m);
@@ -1830,8 +1830,8 @@ int manager_load_unit_prepare(Manager *m, const char *name, const char *path, DB
return -ENOMEM;
if (path) {
- ret->meta.fragment_path = strdup(path);
- if (!ret->meta.fragment_path) {
+ ret->fragment_path = strdup(path);
+ if (!ret->fragment_path) {
unit_free(ret);
return -ENOMEM;
}
@@ -1891,7 +1891,7 @@ void manager_dump_units(Manager *s, FILE *f, const char *prefix) {
assert(f);
HASHMAP_FOREACH_KEY(u, t, s->units, i)
- if (u->meta.id == t)
+ if (u->id == t)
unit_dump(u, f, prefix);
}
@@ -1929,7 +1929,7 @@ unsigned manager_dispatch_run_queue(Manager *m) {
unsigned manager_dispatch_dbus_queue(Manager *m) {
Job *j;
- Meta *meta;
+ Unit *meta;
unsigned n = 0;
assert(m);
@@ -2016,7 +2016,7 @@ static int manager_process_notify_fd(Manager *m) {
if (!(tags = strv_split(buf, "\n\r")))
return -ENOMEM;
- log_debug("Got notification message for unit %s", u->meta.id);
+ log_debug("Got notification message for unit %s", u->id);
if (UNIT_VTABLE(u)->notify_message)
UNIT_VTABLE(u)->notify_message(u, ucred->pid, tags);
@@ -2095,7 +2095,7 @@ static int manager_dispatch_sigchld(Manager *m) {
if (!u)
continue;
- log_debug("Child %lu belongs to %s", (long unsigned) si.si_pid, u->meta.id);
+ log_debug("Child %lu belongs to %s", (long unsigned) si.si_pid, u->id);
hashmap_remove(m->watch_pids, LONG_TO_PTR(si.si_pid));
UNIT_VTABLE(u)->sigchld_event(u, si.si_pid, si.si_code, si.si_status);
@@ -2559,10 +2559,10 @@ void manager_send_unit_audit(Manager *m, Unit *u, int type, bool success) {
if (m->running_as != MANAGER_SYSTEM)
return;
- if (u->meta.type != UNIT_SERVICE)
+ if (u->type != UNIT_SERVICE)
return;
- if (!(p = unit_name_to_prefix_and_instance(u->meta.id))) {
+ if (!(p = unit_name_to_prefix_and_instance(u->id))) {
log_error("Failed to allocate unit name for audit message: %s", strerror(ENOMEM));
return;
}
@@ -2600,9 +2600,9 @@ void manager_send_unit_plymouth(Manager *m, Unit *u) {
if (m->running_as != MANAGER_SYSTEM)
return;
- if (u->meta.type != UNIT_SERVICE &&
- u->meta.type != UNIT_MOUNT &&
- u->meta.type != UNIT_SWAP)
+ if (u->type != UNIT_SERVICE &&
+ u->type != UNIT_MOUNT &&
+ u->type != UNIT_SWAP)
return;
/* We set SOCK_NONBLOCK here so that we rather drop the
@@ -2628,7 +2628,7 @@ void manager_send_unit_plymouth(Manager *m, Unit *u) {
goto finish;
}
- if (asprintf(&message, "U\002%c%s%n", (int) (strlen(u->meta.id) + 1), u->meta.id, &n) < 0) {
+ if (asprintf(&message, "U\002%c%s%n", (int) (strlen(u->id) + 1), u->id, &n) < 0) {
log_error("Out of memory");
goto finish;
}
@@ -2748,14 +2748,14 @@ int manager_serialize(Manager *m, FILE *f, FDSet *fds) {
fputc('\n', f);
HASHMAP_FOREACH_KEY(u, t, m->units, i) {
- if (u->meta.id != t)
+ if (u->id != t)
continue;
if (!unit_can_serialize(u))
continue;
/* Start marker */
- fputs(u->meta.id, f);
+ fputs(u->id, f);
fputc('\n', f);
if ((r = unit_serialize(u, f, fds)) < 0) {
@@ -2946,7 +2946,7 @@ bool manager_is_booting_or_shutting_down(Manager *m) {
/* Is there a job for the shutdown target? */
u = manager_get_unit(m, SPECIAL_SHUTDOWN_TARGET);
if (u)
- return !!u->meta.job;
+ return !!u->job;
return false;
}
diff --git a/src/manager.h b/src/manager.h
index 0ace0c9..5e65fdb 100644
--- a/src/manager.h
+++ b/src/manager.h
@@ -74,7 +74,7 @@ struct Watch {
int fd;
WatchType type;
union {
- union Unit *unit;
+ struct Unit *unit;
struct Job *job;
DBusWatch *bus_watch;
DBusTimeout *bus_timeout;
@@ -102,10 +102,10 @@ struct Manager {
/* To make it easy to iterate through the units of a specific
* type we maintain a per type linked list */
- LIST_HEAD(Meta, units_by_type[_UNIT_TYPE_MAX]);
+ LIST_HEAD(Unit, units_by_type[_UNIT_TYPE_MAX]);
/* Units that need to be loaded */
- LIST_HEAD(Meta, load_queue); /* this is actually more a stack than a queue, but uh. */
+ LIST_HEAD(Unit, load_queue); /* this is actually more a stack than a queue, but uh. */
/* Jobs that need to be run */
LIST_HEAD(Job, run_queue); /* more a stack than a queue, too */
@@ -114,14 +114,14 @@ struct Manager {
* D-Bus. When something about a job changes it is added here
* if it is not in there yet. This allows easy coalescing of
* D-Bus change signals. */
- LIST_HEAD(Meta, dbus_unit_queue);
+ LIST_HEAD(Unit, dbus_unit_queue);
LIST_HEAD(Job, dbus_job_queue);
/* Units to remove */
- LIST_HEAD(Meta, cleanup_queue);
+ LIST_HEAD(Unit, cleanup_queue);
/* Units to check when doing GC */
- LIST_HEAD(Meta, gc_queue);
+ LIST_HEAD(Unit, gc_queue);
/* Jobs to be added */
Hashmap *transaction_jobs; /* Unit object => Job object list 1:1 */
diff --git a/src/mount.c b/src/mount.c
index f94c0eb..9f7ce69 100644
--- a/src/mount.c
+++ b/src/mount.c
@@ -59,7 +59,7 @@ static void mount_init(Unit *u) {
Mount *m = MOUNT(u);
assert(u);
- assert(u->meta.load_state == UNIT_STUB);
+ assert(u->load_state == UNIT_STUB);
m->timeout_usec = DEFAULT_TIMEOUT_USEC;
m->directory_mode = 0755;
@@ -69,8 +69,8 @@ static void mount_init(Unit *u) {
/* The stdio/kmsg bridge socket is on /, in order to avoid a
* dep loop, don't use kmsg logging for -.mount */
if (!unit_has_name(u, "-.mount")) {
- m->exec_context.std_output = u->meta.manager->default_std_output;
- m->exec_context.std_error = u->meta.manager->default_std_error;
+ m->exec_context.std_output = u->manager->default_std_output;
+ m->exec_context.std_error = u->manager->default_std_error;
}
/* We need to make sure that /bin/mount is always called in
@@ -148,7 +148,7 @@ static MountParameters* get_mount_parameters(Mount *m) {
}
static int mount_add_mount_links(Mount *m) {
- Meta *other;
+ Unit *other;
int r;
MountParameters *pm;
@@ -211,7 +211,7 @@ static int mount_add_mount_links(Mount *m) {
}
static int mount_add_swap_links(Mount *m) {
- Meta *other;
+ Unit *other;
int r;
assert(m);
@@ -224,7 +224,7 @@ static int mount_add_swap_links(Mount *m) {
}
static int mount_add_path_links(Mount *m) {
- Meta *other;
+ Unit *other;
int r;
assert(m);
@@ -237,7 +237,7 @@ static int mount_add_path_links(Mount *m) {
}
static int mount_add_automount_links(Mount *m) {
- Meta *other;
+ Unit *other;
int r;
assert(m);
@@ -250,7 +250,7 @@ static int mount_add_automount_links(Mount *m) {
}
static int mount_add_socket_links(Mount *m) {
- Meta *other;
+ Unit *other;
int r;
assert(m);
@@ -382,9 +382,9 @@ static int mount_add_fstab_links(Mount *m) {
/* Install automount unit */
if (!nofail) /* automount + fail */
- return unit_add_two_dependencies(tu, UNIT_AFTER, UNIT_REQUIRES, UNIT(am), true);
+ return unit_add_two_dependencies(tu, UNIT_AFTER, UNIT_REQUIRES, am, true);
else /* automount + nofail */
- return unit_add_two_dependencies(tu, UNIT_AFTER, UNIT_WANTS, UNIT(am), true);
+ return unit_add_two_dependencies(tu, UNIT_AFTER, UNIT_WANTS, am, true);
} else if (handle && !noauto) {
@@ -422,13 +422,13 @@ static int mount_add_device_links(Mount *m) {
if ((r = unit_add_node_link(UNIT(m), p->what,
!noauto && nofail &&
- UNIT(m)->meta.manager->running_as == MANAGER_SYSTEM)) < 0)
+ UNIT(m)->manager->running_as == MANAGER_SYSTEM)) < 0)
return r;
}
if (p->passno > 0 &&
!mount_is_bind(p) &&
- UNIT(m)->meta.manager->running_as == MANAGER_SYSTEM &&
+ UNIT(m)->manager->running_as == MANAGER_SYSTEM &&
!path_equal(m->where, "/")) {
char *name;
Unit *fsck;
@@ -517,10 +517,10 @@ static int mount_fix_timeouts(Mount *m) {
}
SET_FOREACH(other, m->meta.dependencies[UNIT_AFTER], i) {
- if (other->meta.type != UNIT_DEVICE)
+ if (other->type != UNIT_DEVICE)
continue;
- other->meta.job_timeout = u;
+ other->job_timeout = u;
}
return 0;
@@ -571,13 +571,13 @@ static int mount_load(Unit *u) {
int r;
assert(u);
- assert(u->meta.load_state == UNIT_STUB);
+ assert(u->load_state == UNIT_STUB);
if ((r = unit_load_fragment_and_dropin_optional(u)) < 0)
return r;
/* This is a new unit? Then let's add in some extras */
- if (u->meta.load_state == UNIT_LOADED) {
+ if (u->load_state == UNIT_LOADED) {
if ((r = unit_add_exec_dependencies(u, &m->exec_context)) < 0)
return r;
@@ -585,7 +585,7 @@ static int mount_load(Unit *u) {
m->from_fragment = true;
if (!m->where)
- if (!(m->where = unit_name_to_path(u->meta.id)))
+ if (!(m->where = unit_name_to_path(u->id)))
return -ENOMEM;
path_kill_slashes(m->where);
@@ -636,7 +636,7 @@ static int mount_notify_automount(Mount *m, int status) {
assert(m);
SET_FOREACH(p, m->meta.dependencies[UNIT_TRIGGERED_BY], i)
- if (p->meta.type == UNIT_AUTOMOUNT) {
+ if (p->type == UNIT_AUTOMOUNT) {
r = automount_send_ready(AUTOMOUNT(p), status);
if (r < 0)
return r;
@@ -1220,7 +1220,7 @@ static void mount_sigchld_event(Unit *u, pid_t pid, int code, int status) {
}
log_full(success ? LOG_DEBUG : LOG_NOTICE,
- "%s mount process exited, code=%s status=%i", u->meta.id, sigchld_code_to_string(code), status);
+ "%s mount process exited, code=%s status=%i", u->id, sigchld_code_to_string(code), status);
/* Note that mount(8) returning and the kernel sending us a
* mount table change event might happen out-of-order. If an
@@ -1287,27 +1287,27 @@ static void mount_timer_event(Unit *u, uint64_t elapsed, Watch *w) {
case MOUNT_MOUNTING:
case MOUNT_MOUNTING_DONE:
- log_warning("%s mounting timed out. Stopping.", u->meta.id);
+ log_warning("%s mounting timed out. Stopping.", u->id);
mount_enter_signal(m, MOUNT_MOUNTING_SIGTERM, false);
break;
case MOUNT_REMOUNTING:
- log_warning("%s remounting timed out. Stopping.", u->meta.id);
+ log_warning("%s remounting timed out. Stopping.", u->id);
m->reload_failure = true;
mount_enter_mounted(m, true);
break;
case MOUNT_UNMOUNTING:
- log_warning("%s unmounting timed out. Stopping.", u->meta.id);
+ log_warning("%s unmounting timed out. Stopping.", u->id);
mount_enter_signal(m, MOUNT_UNMOUNTING_SIGTERM, false);
break;
case MOUNT_MOUNTING_SIGTERM:
if (m->exec_context.send_sigkill) {
- log_warning("%s mounting timed out. Killing.", u->meta.id);
+ log_warning("%s mounting timed out. Killing.", u->id);
mount_enter_signal(m, MOUNT_MOUNTING_SIGKILL, false);
} else {
- log_warning("%s mounting timed out. Skipping SIGKILL. Ignoring.", u->meta.id);
+ log_warning("%s mounting timed out. Skipping SIGKILL. Ignoring.", u->id);
if (m->from_proc_self_mountinfo)
mount_enter_mounted(m, false);
@@ -1318,10 +1318,10 @@ static void mount_timer_event(Unit *u, uint64_t elapsed, Watch *w) {
case MOUNT_REMOUNTING_SIGTERM:
if (m->exec_context.send_sigkill) {
- log_warning("%s remounting timed out. Killing.", u->meta.id);
+ log_warning("%s remounting timed out. Killing.", u->id);
mount_enter_signal(m, MOUNT_REMOUNTING_SIGKILL, false);
} else {
- log_warning("%s remounting timed out. Skipping SIGKILL. Ignoring.", u->meta.id);
+ log_warning("%s remounting timed out. Skipping SIGKILL. Ignoring.", u->id);
if (m->from_proc_self_mountinfo)
mount_enter_mounted(m, false);
@@ -1332,10 +1332,10 @@ static void mount_timer_event(Unit *u, uint64_t elapsed, Watch *w) {
case MOUNT_UNMOUNTING_SIGTERM:
if (m->exec_context.send_sigkill) {
- log_warning("%s unmounting timed out. Killing.", u->meta.id);
+ log_warning("%s unmounting timed out. Killing.", u->id);
mount_enter_signal(m, MOUNT_UNMOUNTING_SIGKILL, false);
} else {
- log_warning("%s unmounting timed out. Skipping SIGKILL. Ignoring.", u->meta.id);
+ log_warning("%s unmounting timed out. Skipping SIGKILL. Ignoring.", u->id);
if (m->from_proc_self_mountinfo)
mount_enter_mounted(m, false);
@@ -1347,7 +1347,7 @@ static void mount_timer_event(Unit *u, uint64_t elapsed, Watch *w) {
case MOUNT_MOUNTING_SIGKILL:
case MOUNT_REMOUNTING_SIGKILL:
case MOUNT_UNMOUNTING_SIGKILL:
- log_warning("%s mount process still around after SIGKILL. Ignoring.", u->meta.id);
+ log_warning("%s mount process still around after SIGKILL. Ignoring.", u->id);
if (m->from_proc_self_mountinfo)
mount_enter_mounted(m, false);
@@ -1679,7 +1679,7 @@ fail:
}
void mount_fd_event(Manager *m, int events) {
- Meta *meta;
+ Unit *meta;
int r;
assert(m);
diff --git a/src/mount.h b/src/mount.h
index 7c5d9d1..730c4c2 100644
--- a/src/mount.h
+++ b/src/mount.h
@@ -60,7 +60,7 @@ typedef struct MountParameters {
} MountParameters;
struct Mount {
- Meta meta;
+ Unit meta;
char *where;
diff --git a/src/path.c b/src/path.c
index ae5052a..bfb5cdf 100644
--- a/src/path.c
+++ b/src/path.c
@@ -236,7 +236,7 @@ static void path_init(Unit *u) {
Path *p = PATH(u);
assert(u);
- assert(u->meta.load_state == UNIT_STUB);
+ assert(u->load_state == UNIT_STUB);
p->directory_mode = 0755;
}
@@ -281,7 +281,7 @@ int path_add_one_mount_link(Path *p, Mount *m) {
}
static int path_add_mount_links(Path *p) {
- Meta *other;
+ Unit *other;
int r;
assert(p);
@@ -328,12 +328,12 @@ static int path_load(Unit *u) {
int r;
assert(u);
- assert(u->meta.load_state == UNIT_STUB);
+ assert(u->load_state == UNIT_STUB);
if ((r = unit_load_fragment_and_dropin(u)) < 0)
return r;
- if (u->meta.load_state == UNIT_LOADED) {
+ if (u->load_state == UNIT_LOADED) {
if (!UNIT_DEREF(p->unit)) {
Unit *x;
@@ -373,7 +373,7 @@ static void path_dump(Unit *u, FILE *f, const char *prefix) {
"%sMakeDirectory: %s\n"
"%sDirectoryMode: %04o\n",
prefix, path_state_to_string(p->state),
- prefix, UNIT_DEREF(p->unit)->meta.id,
+ prefix, UNIT_DEREF(p->unit)->id,
prefix, yes_no(p->make_directory),
prefix, p->directory_mode);
@@ -547,7 +547,7 @@ static int path_start(Unit *u) {
assert(p);
assert(p->state == PATH_DEAD || p->state == PATH_FAILED);
- if (UNIT_DEREF(p->unit)->meta.load_state != UNIT_LOADED)
+ if (UNIT_DEREF(p->unit)->load_state != UNIT_LOADED)
return -ENOENT;
path_mkdir(p);
@@ -625,7 +625,7 @@ static void path_fd_event(Unit *u, int fd, uint32_t events, Watch *w) {
p->state != PATH_RUNNING)
return;
- /* log_debug("inotify wakeup on %s.", u->meta.id); */
+ /* log_debug("inotify wakeup on %s.", u->id); */
LIST_FOREACH(spec, s, p->specs)
if (path_spec_owns_inotify_fd(s, fd))
@@ -660,16 +660,16 @@ void path_unit_notify(Unit *u, UnitActiveState new_state) {
Iterator i;
Unit *k;
- if (u->meta.type == UNIT_PATH)
+ if (u->type == UNIT_PATH)
return;
- SET_FOREACH(k, u->meta.dependencies[UNIT_TRIGGERED_BY], i) {
+ SET_FOREACH(k, u->dependencies[UNIT_TRIGGERED_BY], i) {
Path *p;
- if (k->meta.type != UNIT_PATH)
+ if (k->type != UNIT_PATH)
continue;
- if (k->meta.load_state != UNIT_LOADED)
+ if (k->load_state != UNIT_LOADED)
continue;
p = PATH(k);
diff --git a/src/path.h b/src/path.h
index 8b3c0bc..04d43c8 100644
--- a/src/path.h
+++ b/src/path.h
@@ -70,7 +70,7 @@ static inline bool path_spec_owns_inotify_fd(PathSpec *s, int fd) {
}
struct Path {
- Meta meta;
+ Unit meta;
LIST_HEAD(PathSpec, specs);
diff --git a/src/service.c b/src/service.c
index 6ce6b19..5543077 100644
--- a/src/service.c
+++ b/src/service.c
@@ -108,7 +108,7 @@ static void service_init(Unit *u) {
Service *s = SERVICE(u);
assert(u);
- assert(u->meta.load_state == UNIT_STUB);
+ assert(u->load_state == UNIT_STUB);
s->timeout_usec = DEFAULT_TIMEOUT_USEC;
s->restart_usec = DEFAULT_RESTART_USEC;
@@ -224,7 +224,7 @@ static void service_done(Unit *u) {
service_unwatch_control_pid(s);
if (s->bus_name) {
- unit_unwatch_bus_name(UNIT(u), s->bus_name);
+ unit_unwatch_bus_name(u, s->bus_name);
free(s->bus_name);
s->bus_name = NULL;
}
@@ -360,7 +360,7 @@ finish:
}
static int sysv_fix_order(Service *s) {
- Meta *other;
+ Unit *other;
int r;
assert(s);
@@ -496,7 +496,7 @@ static int service_load_sysv_path(Service *s, const char *path) {
s->sysv_mtime = timespec_load(&st.st_mtim);
if (null_or_empty(&st)) {
- u->meta.load_state = UNIT_MASKED;
+ u->load_state = UNIT_MASKED;
r = 0;
goto finish;
}
@@ -865,7 +865,7 @@ static int service_load_sysv_path(Service *s, const char *path) {
goto finish;
}
- u->meta.description = d;
+ u->description = d;
}
/* The priority that has been set in /etc/rcN.d/ hierarchies
@@ -874,7 +874,7 @@ static int service_load_sysv_path(Service *s, const char *path) {
if (s->sysv_start_priority_from_rcnd >= 0)
s->sysv_start_priority = s->sysv_start_priority_from_rcnd;
- u->meta.load_state = UNIT_LOADED;
+ u->load_state = UNIT_LOADED;
r = 0;
finish:
@@ -1008,7 +1008,7 @@ static int service_load_sysv(Service *s) {
#endif
static int fsck_fix_order(Service *s) {
- Meta *other;
+ Unit *other;
int r;
assert(s);
@@ -1138,13 +1138,13 @@ static int service_load(Unit *u) {
#ifdef HAVE_SYSV_COMPAT
/* Load a classic init script as a fallback, if we couldn't find anything */
- if (u->meta.load_state == UNIT_STUB)
+ if (u->load_state == UNIT_STUB)
if ((r = service_load_sysv(s)) < 0)
return r;
#endif
/* Still nothing found? Then let's give up */
- if (u->meta.load_state == UNIT_STUB)
+ if (u->load_state == UNIT_STUB)
return -ENOENT;
/* We were able to load something, then let's add in the
@@ -1153,7 +1153,7 @@ static int service_load(Unit *u) {
return r;
/* This is a new unit? Then let's add in some extras */
- if (u->meta.load_state == UNIT_LOADED) {
+ if (u->load_state == UNIT_LOADED) {
service_fix_output(s);
if ((r = unit_add_exec_dependencies(u, &s->exec_context)) < 0)
@@ -1383,7 +1383,7 @@ static void service_notify_sockets_dead(Service *s) {
return;
SET_FOREACH(u, s->meta.dependencies[UNIT_TRIGGERED_BY], i)
- if (u->meta.type == UNIT_SOCKET)
+ if (u->type == UNIT_SOCKET)
socket_notify_service_dead(SOCKET(u));
return;
@@ -1572,7 +1572,7 @@ static int service_collect_fds(Service *s, int **fds, unsigned *n_fds) {
unsigned cn_fds;
Socket *sock;
- if (u->meta.type != UNIT_SOCKET)
+ if (u->type != UNIT_SOCKET)
continue;
sock = SOCKET(u);
@@ -2291,7 +2291,7 @@ static int service_start(Unit *u) {
/* Make sure we don't enter a busy loop of some kind. */
if (!ratelimit_test(&s->ratelimit)) {
- log_warning("%s start request repeated too quickly, refusing to start.", u->meta.id);
+ log_warning("%s start request repeated too quickly, refusing to start.", u->id);
return -ECANCELED;
}
@@ -2628,7 +2628,7 @@ static void service_fd_event(Unit *u, int fd, uint32_t events, Watch *w) {
assert(s->pid_file_pathspec);
assert(path_spec_owns_inotify_fd(s->pid_file_pathspec, fd));
- log_debug("inotify event for %s", u->meta.id);
+ log_debug("inotify event for %s", u->id);
if (path_spec_fd_event(s->pid_file_pathspec, events) < 0)
goto fail;
@@ -2679,7 +2679,7 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) {
}
log_full(success ? LOG_DEBUG : LOG_NOTICE,
- "%s: main process exited, code=%s, status=%i", u->meta.id, sigchld_code_to_string(code), status);
+ "%s: main process exited, code=%s, status=%i", u->id, sigchld_code_to_string(code), status);
s->failure = s->failure || !success;
if (s->main_command &&
@@ -2689,7 +2689,7 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) {
/* There is another command to *
* execute, so let's do that. */
- log_debug("%s running next main command for state %s", u->meta.id, service_state_to_string(s->state));
+ log_debug("%s running next main command for state %s", u->id, service_state_to_string(s->state));
service_run_next_main(s, success);
} else {
@@ -2751,7 +2751,7 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) {
}
log_full(success ? LOG_DEBUG : LOG_NOTICE,
- "%s: control process exited, code=%s status=%i", u->meta.id, sigchld_code_to_string(code), status);
+ "%s: control process exited, code=%s status=%i", u->id, sigchld_code_to_string(code), status);
s->failure = s->failure || !success;
if (s->control_command &&
@@ -2761,7 +2761,7 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) {
/* There is another command to *
* execute, so let's do that. */
- log_debug("%s running next control command for state %s", u->meta.id, service_state_to_string(s->state));
+ log_debug("%s running next control command for state %s", u->id, service_state_to_string(s->state));
service_run_next_control(s, success);
} else {
@@ -2771,7 +2771,7 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) {
s->control_command = NULL;
s->control_command_id = _SERVICE_EXEC_COMMAND_INVALID;
- log_debug("%s got final SIGCHLD for state %s", u->meta.id, service_state_to_string(s->state));
+ log_debug("%s got final SIGCHLD for state %s", u->id, service_state_to_string(s->state));
switch (s->state) {
@@ -2880,32 +2880,32 @@ static void service_timer_event(Unit *u, uint64_t elapsed, Watch* w) {
case SERVICE_START_PRE:
case SERVICE_START:
- log_warning("%s operation timed out. Terminating.", u->meta.id);
+ log_warning("%s operation timed out. Terminating.", u->id);
service_enter_signal(s, SERVICE_FINAL_SIGTERM, false);
break;
case SERVICE_START_POST:
- log_warning("%s operation timed out. Stopping.", u->meta.id);
+ log_warning("%s operation timed out. Stopping.", u->id);
service_enter_stop(s, false);
break;
case SERVICE_RELOAD:
- log_warning("%s operation timed out. Stopping.", u->meta.id);
+ log_warning("%s operation timed out. Stopping.", u->id);
s->reload_failure = true;
service_enter_running(s, true);
break;
case SERVICE_STOP:
- log_warning("%s stopping timed out. Terminating.", u->meta.id);
+ log_warning("%s stopping timed out. Terminating.", u->id);
service_enter_signal(s, SERVICE_STOP_SIGTERM, false);
break;
case SERVICE_STOP_SIGTERM:
if (s->exec_context.send_sigkill) {
- log_warning("%s stopping timed out. Killing.", u->meta.id);
+ log_warning("%s stopping timed out. Killing.", u->id);
service_enter_signal(s, SERVICE_STOP_SIGKILL, false);
} else {
- log_warning("%s stopping timed out. Skipping SIGKILL.", u->meta.id);
+ log_warning("%s stopping timed out. Skipping SIGKILL.", u->id);
service_enter_stop_post(s, false);
}
@@ -2916,33 +2916,33 @@ static void service_timer_event(Unit *u, uint64_t elapsed, Watch* w) {
* Must be something we cannot kill, so let's just be
* weirded out and continue */
- log_warning("%s still around after SIGKILL. Ignoring.", u->meta.id);
+ log_warning("%s still around after SIGKILL. Ignoring.", u->id);
service_enter_stop_post(s, false);
break;
case SERVICE_STOP_POST:
- log_warning("%s stopping timed out (2). Terminating.", u->meta.id);
+ log_warning("%s stopping timed out (2). Terminating.", u->id);
service_enter_signal(s, SERVICE_FINAL_SIGTERM, false);
break;
case SERVICE_FINAL_SIGTERM:
if (s->exec_context.send_sigkill) {
- log_warning("%s stopping timed out (2). Killing.", u->meta.id);
+ log_warning("%s stopping timed out (2). Killing.", u->id);
service_enter_signal(s, SERVICE_FINAL_SIGKILL, false);
} else {
- log_warning("%s stopping timed out (2). Skipping SIGKILL. Entering failed mode.", u->meta.id);
+ log_warning("%s stopping timed out (2). Skipping SIGKILL. Entering failed mode.", u->id);
service_enter_dead(s, false, true);
}
break;
case SERVICE_FINAL_SIGKILL:
- log_warning("%s still around after SIGKILL (2). Entering failed mode.", u->meta.id);
+ log_warning("%s still around after SIGKILL (2). Entering failed mode.", u->id);
service_enter_dead(s, false, true);
break;
case SERVICE_AUTO_RESTART:
- log_info("%s holdoff time over, scheduling restart.", u->meta.id);
+ log_info("%s holdoff time over, scheduling restart.", u->id);
service_enter_restart(s);
break;
@@ -2956,7 +2956,7 @@ static void service_cgroup_notify_event(Unit *u) {
assert(u);
- log_debug("%s: cgroup is empty", u->meta.id);
+ log_debug("%s: cgroup is empty", u->id);
switch (s->state) {
@@ -3012,17 +3012,17 @@ static void service_notify_message(Unit *u, pid_t pid, char **tags) {
if (s->notify_access == NOTIFY_NONE) {
log_warning("%s: Got notification message from PID %lu, but reception is disabled.",
- u->meta.id, (unsigned long) pid);
+ u->id, (unsigned long) pid);
return;
}
if (s->notify_access == NOTIFY_MAIN && pid != s->main_pid) {
log_warning("%s: Got notification message from PID %lu, but reception only permitted for PID %lu",
- u->meta.id, (unsigned long) pid, (unsigned long) s->main_pid);
+ u->id, (unsigned long) pid, (unsigned long) s->main_pid);
return;
}
- log_debug("%s: Got message", u->meta.id);
+ log_debug("%s: Got message", u->id);
/* Interpret MAINPID= */
if ((e = strv_find_prefix(tags, "MAINPID=")) &&
@@ -3034,7 +3034,7 @@ static void service_notify_message(Unit *u, pid_t pid, char **tags) {
if (parse_pid(e + 8, &pid) < 0)
log_warning("Failed to parse notification message %s", e);
else {
- log_debug("%s: got %s", u->meta.id, e);
+ log_debug("%s: got %s", u->id, e);
service_set_main_pid(s, pid);
}
}
@@ -3043,7 +3043,7 @@ static void service_notify_message(Unit *u, pid_t pid, char **tags) {
if (s->type == SERVICE_NOTIFY &&
s->state == SERVICE_START &&
strv_find(tags, "READY=1")) {
- log_debug("%s: got READY=1", u->meta.id);
+ log_debug("%s: got READY=1", u->id);
service_enter_start_post(s);
}
@@ -3058,7 +3058,7 @@ static void service_notify_message(Unit *u, pid_t pid, char **tags) {
return;
}
- log_debug("%s: got %s", u->meta.id, e);
+ log_debug("%s: got %s", u->id, e);
free(s->status_text);
s->status_text = t;
@@ -3109,7 +3109,7 @@ static void sysv_facility_in_insserv_conf(Manager *mgr) {
Unit *u;
if (sysv_translate_facility(parsed[0], NULL, &facility) < 0)
continue;
- if ((u = manager_get_unit(mgr, facility)) && (u->meta.type == UNIT_TARGET)) {
+ if ((u = manager_get_unit(mgr, facility)) && (u->type == UNIT_TARGET)) {
UnitDependency e;
char *dep = NULL, *name, **j;
@@ -3262,7 +3262,7 @@ static int service_enumerate(Manager *m) {
SET_FOREACH(service, runlevel_services[i], j) {
service = unit_follow_merge(service);
- if (service->meta.fragment_path)
+ if (service->fragment_path)
continue;
if ((r = unit_add_two_dependencies_by_name_inverse(service, UNIT_AFTER, UNIT_WANTS, rcnd_table[i].target, NULL, true)) < 0)
@@ -3279,7 +3279,7 @@ static int service_enumerate(Manager *m) {
SET_FOREACH(service, shutdown_services, j) {
service = unit_follow_merge(service);
- if (service->meta.fragment_path)
+ if (service->fragment_path)
continue;
if ((r = unit_add_two_dependencies_by_name(service, UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_SHUTDOWN_TARGET, NULL, true)) < 0)
@@ -3323,11 +3323,11 @@ static void service_bus_name_owner_change(
assert(old_owner || new_owner);
if (old_owner && new_owner)
- log_debug("%s's D-Bus name %s changed owner from %s to %s", u->meta.id, name, old_owner, new_owner);
+ log_debug("%s's D-Bus name %s changed owner from %s to %s", u->id, name, old_owner, new_owner);
else if (old_owner)
- log_debug("%s's D-Bus name %s no longer registered by %s", u->meta.id, name, old_owner);
+ log_debug("%s's D-Bus name %s no longer registered by %s", u->id, name, old_owner);
else
- log_debug("%s's D-Bus name %s now registered by %s", u->meta.id, name, new_owner);
+ log_debug("%s's D-Bus name %s now registered by %s", u->id, name, new_owner);
s->bus_name_good = !!new_owner;
@@ -3350,7 +3350,7 @@ static void service_bus_name_owner_change(
/* Try to acquire PID from bus service */
log_debug("Trying to acquire PID from D-Bus name...");
- bus_query_pid(u->meta.manager, name);
+ bus_query_pid(u->manager, name);
}
}
@@ -3364,7 +3364,7 @@ static void service_bus_query_pid_done(
assert(s);
assert(name);
- log_debug("%s's D-Bus name %s is now owned by process %u", u->meta.id, name, (unsigned) pid);
+ log_debug("%s's D-Bus name %s is now owned by process %u", u->id, name, (unsigned) pid);
if (s->main_pid <= 0 &&
(s->state == SERVICE_START ||
diff --git a/src/service.h b/src/service.h
index 8f67ad5..0b4f8be 100644
--- a/src/service.h
+++ b/src/service.h
@@ -89,7 +89,7 @@ typedef enum NotifyAccess {
} NotifyAccess;
struct Service {
- Meta meta;
+ Unit meta;
ServiceType type;
ServiceRestart restart;
diff --git a/src/snapshot.c b/src/snapshot.c
index 161629d..bc1388c 100644
--- a/src/snapshot.c
+++ b/src/snapshot.c
@@ -62,14 +62,14 @@ static int snapshot_load(Unit *u) {
Snapshot *s = SNAPSHOT(u);
assert(u);
- assert(u->meta.load_state == UNIT_STUB);
+ assert(u->load_state == UNIT_STUB);
/* Make sure that only snapshots created via snapshot_create()
* can be loaded */
if (!s->by_snapshot_create && s->meta.manager->n_reloading <= 0)
return -ENOENT;
- u->meta.load_state = UNIT_LOADED;
+ u->load_state = UNIT_LOADED;
return 0;
}
@@ -133,8 +133,8 @@ static int snapshot_serialize(Unit *u, FILE *f, FDSet *fds) {
unit_serialize_item(u, f, "state", snapshot_state_to_string(s->state));
unit_serialize_item(u, f, "cleanup", yes_no(s->cleanup));
- SET_FOREACH(other, u->meta.dependencies[UNIT_WANTS], i)
- unit_serialize_item(u, f, "wants", other->meta.id);
+ SET_FOREACH(other, u->dependencies[UNIT_WANTS], i)
+ unit_serialize_item(u, f, "wants", other->id);
return 0;
}
@@ -234,14 +234,14 @@ int snapshot_create(Manager *m, const char *name, bool cleanup, DBusError *e, Sn
SNAPSHOT(u)->by_snapshot_create = true;
manager_dispatch_load_queue(m);
- assert(u->meta.load_state == UNIT_LOADED);
+ assert(u->load_state == UNIT_LOADED);
HASHMAP_FOREACH_KEY(other, k, m->units, i) {
- if (other->meta.ignore_on_snapshot)
+ if (other->ignore_on_snapshot)
continue;
- if (k != other->meta.id)
+ if (k != other->id)
continue;
if (UNIT_VTABLE(other)->check_snapshot)
diff --git a/src/snapshot.h b/src/snapshot.h
index 9a30520..bf92e99 100644
--- a/src/snapshot.h
+++ b/src/snapshot.h
@@ -34,7 +34,7 @@ typedef enum SnapshotState {
} SnapshotState;
struct Snapshot {
- Meta meta;
+ Unit meta;
SnapshotState state, deserialized_state;
diff --git a/src/socket.c b/src/socket.c
index 1a245aa..a9ab82c 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -64,7 +64,7 @@ static void socket_init(Unit *u) {
Socket *s = SOCKET(u);
assert(u);
- assert(u->meta.load_state == UNIT_STUB);
+ assert(u->load_state == UNIT_STUB);
s->backlog = SOMAXCONN;
s->timeout_usec = DEFAULT_TIMEOUT_USEC;
@@ -79,8 +79,8 @@ static void socket_init(Unit *u) {
s->mark = -1;
exec_context_init(&s->exec_context);
- s->exec_context.std_output = u->meta.manager->default_std_output;
- s->exec_context.std_error = u->meta.manager->default_std_error;
+ s->exec_context.std_output = u->manager->default_std_output;
+ s->exec_context.std_error = u->manager->default_std_error;
s->control_command_id = _SOCKET_EXEC_COMMAND_INVALID;
}
@@ -169,7 +169,7 @@ static int socket_instantiate_service(Socket *s) {
}
#endif
- u->meta.no_gc = true;
+ u->no_gc = true;
unit_ref_set(&s->service, u);
return unit_add_two_dependencies(UNIT(s), UNIT_BEFORE, UNIT_TRIGGERS, u, false);
@@ -268,7 +268,7 @@ int socket_add_one_mount_link(Socket *s, Mount *m) {
}
static int socket_add_mount_links(Socket *s) {
- Meta *other;
+ Unit *other;
int r;
assert(s);
@@ -329,13 +329,13 @@ static int socket_load(Unit *u) {
int r;
assert(u);
- assert(u->meta.load_state == UNIT_STUB);
+ assert(u->load_state == UNIT_STUB);
if ((r = unit_load_fragment_and_dropin(u)) < 0)
return r;
/* This is a new unit? Then let's add in some extras */
- if (u->meta.load_state == UNIT_LOADED) {
+ if (u->load_state == UNIT_LOADED) {
if (have_non_accept_socket(s)) {
@@ -1787,14 +1787,14 @@ static void socket_fd_event(Unit *u, int fd, uint32_t events, Watch *w) {
if (s->state != SOCKET_LISTENING)
return;
- log_debug("Incoming traffic on %s", u->meta.id);
+ log_debug("Incoming traffic on %s", u->id);
if (events != EPOLLIN) {
if (events & EPOLLHUP)
- log_error("%s: Got POLLHUP on a listening socket. The service probably invoked shutdown() on it, and should better not do that.", u->meta.id);
+ log_error("%s: Got POLLHUP on a listening socket. The service probably invoked shutdown() on it, and should better not do that.", u->id);
else
- log_error("%s: Got unexpected poll event (0x%x) on socket.", u->meta.id, events);
+ log_error("%s: Got unexpected poll event (0x%x) on socket.", u->id, events);
goto fail;
}
@@ -1846,11 +1846,11 @@ static void socket_sigchld_event(Unit *u, pid_t pid, int code, int status) {
}
log_full(success ? LOG_DEBUG : LOG_NOTICE,
- "%s control process exited, code=%s status=%i", u->meta.id, sigchld_code_to_string(code), status);
+ "%s control process exited, code=%s status=%i", u->id, sigchld_code_to_string(code), status);
s->failure = s->failure || !success;
if (s->control_command && s->control_command->command_next && success) {
- log_debug("%s running next command for state %s", u->meta.id, socket_state_to_string(s->state));
+ log_debug("%s running next command for state %s", u->id, socket_state_to_string(s->state));
socket_run_next(s, success);
} else {
s->control_command = NULL;
@@ -1859,7 +1859,7 @@ static void socket_sigchld_event(Unit *u, pid_t pid, int code, int status) {
/* No further commands for this step, so let's figure
* out what to do next */
- log_debug("%s got final SIGCHLD for state %s", u->meta.id, socket_state_to_string(s->state));
+ log_debug("%s got final SIGCHLD for state %s", u->id, socket_state_to_string(s->state));
switch (s->state) {
@@ -1908,52 +1908,52 @@ static void socket_timer_event(Unit *u, uint64_t elapsed, Watch *w) {
switch (s->state) {
case SOCKET_START_PRE:
- log_warning("%s starting timed out. Terminating.", u->meta.id);
+ log_warning("%s starting timed out. Terminating.", u->id);
socket_enter_signal(s, SOCKET_FINAL_SIGTERM, false);
break;
case SOCKET_START_POST:
- log_warning("%s starting timed out. Stopping.", u->meta.id);
+ log_warning("%s starting timed out. Stopping.", u->id);
socket_enter_stop_pre(s, false);
break;
case SOCKET_STOP_PRE:
- log_warning("%s stopping timed out. Terminating.", u->meta.id);
+ log_warning("%s stopping timed out. Terminating.", u->id);
socket_enter_signal(s, SOCKET_STOP_PRE_SIGTERM, false);
break;
case SOCKET_STOP_PRE_SIGTERM:
if (s->exec_context.send_sigkill) {
- log_warning("%s stopping timed out. Killing.", u->meta.id);
+ log_warning("%s stopping timed out. Killing.", u->id);
socket_enter_signal(s, SOCKET_STOP_PRE_SIGKILL, false);
} else {
- log_warning("%s stopping timed out. Skipping SIGKILL. Ignoring.", u->meta.id);
+ log_warning("%s stopping timed out. Skipping SIGKILL. Ignoring.", u->id);
socket_enter_stop_post(s, false);
}
break;
case SOCKET_STOP_PRE_SIGKILL:
- log_warning("%s still around after SIGKILL. Ignoring.", u->meta.id);
+ log_warning("%s still around after SIGKILL. Ignoring.", u->id);
socket_enter_stop_post(s, false);
break;
case SOCKET_STOP_POST:
- log_warning("%s stopping timed out (2). Terminating.", u->meta.id);
+ log_warning("%s stopping timed out (2). Terminating.", u->id);
socket_enter_signal(s, SOCKET_FINAL_SIGTERM, false);
break;
case SOCKET_FINAL_SIGTERM:
if (s->exec_context.send_sigkill) {
- log_warning("%s stopping timed out (2). Killing.", u->meta.id);
+ log_warning("%s stopping timed out (2). Killing.", u->id);
socket_enter_signal(s, SOCKET_FINAL_SIGKILL, false);
} else {
- log_warning("%s stopping timed out (2). Skipping SIGKILL. Ignoring.", u->meta.id);
+ log_warning("%s stopping timed out (2). Skipping SIGKILL. Ignoring.", u->id);
socket_enter_dead(s, false);
}
break;
case SOCKET_FINAL_SIGKILL:
- log_warning("%s still around after SIGKILL (2). Entering failed mode.", u->meta.id);
+ log_warning("%s still around after SIGKILL (2). Entering failed mode.", u->id);
socket_enter_dead(s, false);
break;
diff --git a/src/socket.h b/src/socket.h
index 4fc2cbe..b6df83a 100644
--- a/src/socket.h
+++ b/src/socket.h
@@ -77,7 +77,7 @@ typedef struct SocketPort {
} SocketPort;
struct Socket {
- Meta meta;
+ Unit meta;
LIST_HEAD(SocketPort, ports);
diff --git a/src/swap.c b/src/swap.c
index 202c4e6..87be552 100644
--- a/src/swap.c
+++ b/src/swap.c
@@ -83,8 +83,8 @@ static void swap_init(Unit *u) {
s->timeout_usec = DEFAULT_TIMEOUT_USEC;
exec_context_init(&s->exec_context);
- s->exec_context.std_output = u->meta.manager->default_std_output;
- s->exec_context.std_error = u->meta.manager->default_std_error;
+ s->exec_context.std_output = u->manager->default_std_output;
+ s->exec_context.std_error = u->manager->default_std_error;
s->parameters_etc_fstab.priority = s->parameters_proc_swaps.priority = s->parameters_fragment.priority = -1;
@@ -151,7 +151,7 @@ int swap_add_one_mount_link(Swap *s, Mount *m) {
}
static int swap_add_mount_links(Swap *s) {
- Meta *other;
+ Unit *other;
int r;
assert(s);
@@ -262,13 +262,13 @@ static int swap_load(Unit *u) {
Swap *s = SWAP(u);
assert(s);
- assert(u->meta.load_state == UNIT_STUB);
+ assert(u->load_state == UNIT_STUB);
/* Load a .swap file */
if ((r = unit_load_fragment_and_dropin_optional(u)) < 0)
return r;
- if (u->meta.load_state == UNIT_LOADED) {
+ if (u->load_state == UNIT_LOADED) {
if ((r = unit_add_exec_dependencies(u, &s->exec_context)) < 0)
return r;
@@ -283,7 +283,7 @@ static int swap_load(Unit *u) {
else if (s->parameters_proc_swaps.what)
s->what = strdup(s->parameters_proc_swaps.what);
else
- s->what = unit_name_to_path(u->meta.id);
+ s->what = unit_name_to_path(u->id);
if (!s->what)
return -ENOMEM;
@@ -952,7 +952,7 @@ static void swap_sigchld_event(Unit *u, pid_t pid, int code, int status) {
}
log_full(success ? LOG_DEBUG : LOG_NOTICE,
- "%s swap process exited, code=%s status=%i", u->meta.id, sigchld_code_to_string(code), status);
+ "%s swap process exited, code=%s status=%i", u->id, sigchld_code_to_string(code), status);
switch (s->state) {
@@ -985,7 +985,7 @@ static void swap_sigchld_event(Unit *u, pid_t pid, int code, int status) {
/* Request a reload of /proc/swaps, so that following units
* can follow our state change */
- u->meta.manager->request_reload = true;
+ u->manager->request_reload = true;
}
static void swap_timer_event(Unit *u, uint64_t elapsed, Watch *w) {
@@ -998,38 +998,38 @@ static void swap_timer_event(Unit *u, uint64_t elapsed, Watch *w) {
switch (s->state) {
case SWAP_ACTIVATING:
- log_warning("%s activation timed out. Stopping.", u->meta.id);
+ log_warning("%s activation timed out. Stopping.", u->id);
swap_enter_signal(s, SWAP_ACTIVATING_SIGTERM, false);
break;
case SWAP_DEACTIVATING:
- log_warning("%s deactivation timed out. Stopping.", u->meta.id);
+ log_warning("%s deactivation timed out. Stopping.", u->id);
swap_enter_signal(s, SWAP_DEACTIVATING_SIGTERM, false);
break;
case SWAP_ACTIVATING_SIGTERM:
if (s->exec_context.send_sigkill) {
- log_warning("%s activation timed out. Killing.", u->meta.id);
+ log_warning("%s activation timed out. Killing.", u->id);
swap_enter_signal(s, SWAP_ACTIVATING_SIGKILL, false);
} else {
- log_warning("%s activation timed out. Skipping SIGKILL. Ignoring.", u->meta.id);
+ log_warning("%s activation timed out. Skipping SIGKILL. Ignoring.", u->id);
swap_enter_dead(s, false);
}
break;
case SWAP_DEACTIVATING_SIGTERM:
if (s->exec_context.send_sigkill) {
- log_warning("%s deactivation timed out. Killing.", u->meta.id);
+ log_warning("%s deactivation timed out. Killing.", u->id);
swap_enter_signal(s, SWAP_DEACTIVATING_SIGKILL, false);
} else {
- log_warning("%s deactivation timed out. Skipping SIGKILL. Ignoring.", u->meta.id);
+ log_warning("%s deactivation timed out. Skipping SIGKILL. Ignoring.", u->id);
swap_enter_dead(s, false);
}
break;
case SWAP_ACTIVATING_SIGKILL:
case SWAP_DEACTIVATING_SIGKILL:
- log_warning("%s swap process still around after SIGKILL. Ignoring.", u->meta.id);
+ log_warning("%s swap process still around after SIGKILL. Ignoring.", u->id);
swap_enter_dead(s, false);
break;
@@ -1096,7 +1096,7 @@ int swap_dispatch_reload(Manager *m) {
}
int swap_fd_event(Manager *m, int events) {
- Meta *meta;
+ Unit *meta;
int r;
assert(m);
diff --git a/src/swap.h b/src/swap.h
index 0d5c9a2..ea98bc2 100644
--- a/src/swap.h
+++ b/src/swap.h
@@ -57,7 +57,7 @@ typedef struct SwapParameters {
} SwapParameters;
struct Swap {
- Meta meta;
+ Unit meta;
char *what;
diff --git a/src/target.c b/src/target.c
index b774cfb..fb67ff3 100644
--- a/src/target.c
+++ b/src/target.c
@@ -93,8 +93,8 @@ static int target_load(Unit *u) {
return r;
/* This is a new unit? Then let's add in some extras */
- if (u->meta.load_state == UNIT_LOADED) {
- if (u->meta.default_dependencies)
+ if (u->load_state == UNIT_LOADED) {
+ if (u->default_dependencies)
if ((r = target_add_default_dependencies(t)) < 0)
return r;
}
diff --git a/src/target.h b/src/target.h
index b1d055f..5b97c86 100644
--- a/src/target.h
+++ b/src/target.h
@@ -34,7 +34,7 @@ typedef enum TargetState {
} TargetState;
struct Target {
- Meta meta;
+ Unit meta;
TargetState state, deserialized_state;
};
diff --git a/src/timer.c b/src/timer.c
index 87adb29..6056d31 100644
--- a/src/timer.c
+++ b/src/timer.c
@@ -40,7 +40,7 @@ static void timer_init(Unit *u) {
Timer *t = TIMER(u);
assert(u);
- assert(u->meta.load_state == UNIT_STUB);
+ assert(u->load_state == UNIT_STUB);
t->next_elapse = (usec_t) -1;
}
@@ -96,12 +96,12 @@ static int timer_load(Unit *u) {
int r;
assert(u);
- assert(u->meta.load_state == UNIT_STUB);
+ assert(u->load_state == UNIT_STUB);
if ((r = unit_load_fragment_and_dropin(u)) < 0)
return r;
- if (u->meta.load_state == UNIT_LOADED) {
+ if (u->load_state == UNIT_LOADED) {
if (!UNIT_DEREF(t->unit)) {
Unit *x;
@@ -135,7 +135,7 @@ static void timer_dump(Unit *u, FILE *f, const char *prefix) {
"%sTimer State: %s\n"
"%sUnit: %s\n",
prefix, timer_state_to_string(t->state),
- prefix, UNIT_DEREF(t->unit)->meta.id);
+ prefix, UNIT_DEREF(t->unit)->id);
LIST_FOREACH(value, v, t->values)
fprintf(f,
@@ -225,18 +225,18 @@ static void timer_enter_waiting(Timer *t, bool initial) {
case TIMER_UNIT_ACTIVE:
- if (UNIT_DEREF(t->unit)->meta.inactive_exit_timestamp.monotonic <= 0)
+ if (UNIT_DEREF(t->unit)->inactive_exit_timestamp.monotonic <= 0)
continue;
- base = UNIT_DEREF(t->unit)->meta.inactive_exit_timestamp.monotonic;
+ base = UNIT_DEREF(t->unit)->inactive_exit_timestamp.monotonic;
break;
case TIMER_UNIT_INACTIVE:
- if (UNIT_DEREF(t->unit)->meta.inactive_enter_timestamp.monotonic <= 0)
+ if (UNIT_DEREF(t->unit)->inactive_enter_timestamp.monotonic <= 0)
continue;
- base = UNIT_DEREF(t->unit)->meta.inactive_enter_timestamp.monotonic;
+ base = UNIT_DEREF(t->unit)->inactive_enter_timestamp.monotonic;
break;
default:
@@ -306,7 +306,7 @@ static int timer_start(Unit *u) {
assert(t);
assert(t->state == TIMER_DEAD || t->state == TIMER_FAILED);
- if (UNIT_DEREF(t->unit)->meta.load_state != UNIT_LOADED)
+ if (UNIT_DEREF(t->unit)->load_state != UNIT_LOADED)
return -ENOENT;
t->failure = false;
@@ -378,7 +378,7 @@ static void timer_timer_event(Unit *u, uint64_t elapsed, Watch *w) {
if (t->state != TIMER_WAITING)
return;
- log_debug("Timer elapsed on %s", u->meta.id);
+ log_debug("Timer elapsed on %s", u->id);
timer_enter_running(t);
}
@@ -386,17 +386,17 @@ void timer_unit_notify(Unit *u, UnitActiveState new_state) {
Iterator i;
Unit *k;
- if (u->meta.type == UNIT_TIMER)
+ if (u->type == UNIT_TIMER)
return;
- SET_FOREACH(k, u->meta.dependencies[UNIT_TRIGGERED_BY], i) {
+ SET_FOREACH(k, u->dependencies[UNIT_TRIGGERED_BY], i) {
Timer *t;
TimerValue *v;
- if (k->meta.type != UNIT_TIMER)
+ if (k->type != UNIT_TIMER)
continue;
- if (k->meta.load_state != UNIT_LOADED)
+ if (k->load_state != UNIT_LOADED)
continue;
t = TIMER(k);
diff --git a/src/timer.h b/src/timer.h
index ad55cf7..d5cbc11 100644
--- a/src/timer.h
+++ b/src/timer.h
@@ -57,7 +57,7 @@ typedef struct TimerValue {
} TimerValue;
struct Timer {
- Meta meta;
+ Unit meta;
LIST_HEAD(TimerValue, values);
usec_t next_elapse;
diff --git a/src/unit.c b/src/unit.c
index fa3c264..9e33701 100644
--- a/src/unit.c
+++ b/src/unit.c
@@ -61,23 +61,23 @@ Unit *unit_new(Manager *m, size_t size) {
Unit *u;
assert(m);
- assert(size >= sizeof(Meta));
+ assert(size >= sizeof(Unit));
u = malloc0(size);
if (!u)
return NULL;
- u->meta.names = set_new(string_hash_func, string_compare_func);
- if (!u->meta.names) {
+ u->names = set_new(string_hash_func, string_compare_func);
+ if (!u->names) {
free(u);
return NULL;
}
- u->meta.manager = m;
- u->meta.type = _UNIT_TYPE_INVALID;
- u->meta.deserialized_job = _JOB_TYPE_INVALID;
- u->meta.default_dependencies = true;
- u->meta.unit_file_state = _UNIT_FILE_STATE_INVALID;
+ u->manager = m;
+ u->type = _UNIT_TYPE_INVALID;
+ u->deserialized_job = _JOB_TYPE_INVALID;
+ u->default_dependencies = true;
+ u->unit_file_state = _UNIT_FILE_STATE_INVALID;
return u;
}
@@ -86,7 +86,7 @@ bool unit_has_name(Unit *u, const char *name) {
assert(u);
assert(name);
- return !!set_get(u->meta.names, (char*) name);
+ return !!set_get(u->names, (char*) name);
}
int unit_add_name(Unit *u, const char *text) {
@@ -98,10 +98,10 @@ int unit_add_name(Unit *u, const char *text) {
assert(text);
if (unit_name_is_template(text)) {
- if (!u->meta.instance)
+ if (!u->instance)
return -EINVAL;
- s = unit_name_replace_instance(text, u->meta.instance);
+ s = unit_name_replace_instance(text, u->instance);
} else
s = strdup(text);
@@ -115,7 +115,7 @@ int unit_add_name(Unit *u, const char *text) {
assert_se((t = unit_name_to_type(s)) >= 0);
- if (u->meta.type != _UNIT_TYPE_INVALID && t != u->meta.type) {
+ if (u->type != _UNIT_TYPE_INVALID && t != u->type) {
r = -EINVAL;
goto fail;
}
@@ -130,41 +130,41 @@ int unit_add_name(Unit *u, const char *text) {
/* Ensure that this unit is either instanced or not instanced,
* but not both. */
- if (u->meta.type != _UNIT_TYPE_INVALID && !u->meta.instance != !i) {
+ if (u->type != _UNIT_TYPE_INVALID && !u->instance != !i) {
r = -EINVAL;
goto fail;
}
if (unit_vtable[t]->no_alias &&
- !set_isempty(u->meta.names) &&
- !set_get(u->meta.names, s)) {
+ !set_isempty(u->names) &&
+ !set_get(u->names, s)) {
r = -EEXIST;
goto fail;
}
- if (hashmap_size(u->meta.manager->units) >= MANAGER_MAX_NAMES) {
+ if (hashmap_size(u->manager->units) >= MANAGER_MAX_NAMES) {
r = -E2BIG;
goto fail;
}
- if ((r = set_put(u->meta.names, s)) < 0) {
+ if ((r = set_put(u->names, s)) < 0) {
if (r == -EEXIST)
r = 0;
goto fail;
}
- if ((r = hashmap_put(u->meta.manager->units, s, u)) < 0) {
- set_remove(u->meta.names, s);
+ if ((r = hashmap_put(u->manager->units, s, u)) < 0) {
+ set_remove(u->names, s);
goto fail;
}
- if (u->meta.type == _UNIT_TYPE_INVALID) {
+ if (u->type == _UNIT_TYPE_INVALID) {
- u->meta.type = t;
- u->meta.id = s;
- u->meta.instance = i;
+ u->type = t;
+ u->id = s;
+ u->instance = i;
- LIST_PREPEND(Meta, units_by_type, u->meta.manager->units_by_type[t], &u->meta);
+ LIST_PREPEND(Unit, units_by_type, u->manager->units_by_type[t], u);
if (UNIT_VTABLE(u)->init)
UNIT_VTABLE(u)->init(u);
@@ -190,17 +190,17 @@ int unit_choose_id(Unit *u, const char *name) {
if (unit_name_is_template(name)) {
- if (!u->meta.instance)
+ if (!u->instance)
return -EINVAL;
- if (!(t = unit_name_replace_instance(name, u->meta.instance)))
+ if (!(t = unit_name_replace_instance(name, u->instance)))
return -ENOMEM;
name = t;
}
/* Selects one of the names of this unit as the id */
- s = set_get(u->meta.names, (char*) name);
+ s = set_get(u->names, (char*) name);
free(t);
if (!s)
@@ -209,10 +209,10 @@ int unit_choose_id(Unit *u, const char *name) {
if ((r = unit_name_to_instance(s, &i)) < 0)
return r;
- u->meta.id = s;
+ u->id = s;
- free(u->meta.instance);
- u->meta.instance = i;
+ free(u->instance);
+ u->instance = i;
unit_add_to_dbus_queue(u);
@@ -227,8 +227,8 @@ int unit_set_description(Unit *u, const char *description) {
if (!(s = strdup(description)))
return -ENOMEM;
- free(u->meta.description);
- u->meta.description = s;
+ free(u->description);
+ u->description = s;
unit_add_to_dbus_queue(u);
return 0;
@@ -237,16 +237,16 @@ int unit_set_description(Unit *u, const char *description) {
bool unit_check_gc(Unit *u) {
assert(u);
- if (u->meta.load_state == UNIT_STUB)
+ if (u->load_state == UNIT_STUB)
return true;
if (UNIT_VTABLE(u)->no_gc)
return true;
- if (u->meta.no_gc)
+ if (u->no_gc)
return true;
- if (u->meta.job)
+ if (u->job)
return true;
if (unit_active_state(u) != UNIT_INACTIVE)
@@ -261,58 +261,58 @@ bool unit_check_gc(Unit *u) {
void unit_add_to_load_queue(Unit *u) {
assert(u);
- assert(u->meta.type != _UNIT_TYPE_INVALID);
+ assert(u->type != _UNIT_TYPE_INVALID);
- if (u->meta.load_state != UNIT_STUB || u->meta.in_load_queue)
+ if (u->load_state != UNIT_STUB || u->in_load_queue)
return;
- LIST_PREPEND(Meta, load_queue, u->meta.manager->load_queue, &u->meta);
- u->meta.in_load_queue = true;
+ LIST_PREPEND(Unit, load_queue, u->manager->load_queue, u);
+ u->in_load_queue = true;
}
void unit_add_to_cleanup_queue(Unit *u) {
assert(u);
- if (u->meta.in_cleanup_queue)
+ if (u->in_cleanup_queue)
return;
- LIST_PREPEND(Meta, cleanup_queue, u->meta.manager->cleanup_queue, &u->meta);
- u->meta.in_cleanup_queue = true;
+ LIST_PREPEND(Unit, cleanup_queue, u->manager->cleanup_queue, u);
+ u->in_cleanup_queue = true;
}
void unit_add_to_gc_queue(Unit *u) {
assert(u);
- if (u->meta.in_gc_queue || u->meta.in_cleanup_queue)
+ if (u->in_gc_queue || u->in_cleanup_queue)
return;
if (unit_check_gc(u))
return;
- LIST_PREPEND(Meta, gc_queue, u->meta.manager->gc_queue, &u->meta);
- u->meta.in_gc_queue = true;
+ LIST_PREPEND(Unit, gc_queue, u->manager->gc_queue, u);
+ u->in_gc_queue = true;
- u->meta.manager->n_in_gc_queue ++;
+ u->manager->n_in_gc_queue ++;
- if (u->meta.manager->gc_queue_timestamp <= 0)
- u->meta.manager->gc_queue_timestamp = now(CLOCK_MONOTONIC);
+ if (u->manager->gc_queue_timestamp <= 0)
+ u->manager->gc_queue_timestamp = now(CLOCK_MONOTONIC);
}
void unit_add_to_dbus_queue(Unit *u) {
assert(u);
- assert(u->meta.type != _UNIT_TYPE_INVALID);
+ assert(u->type != _UNIT_TYPE_INVALID);
- if (u->meta.load_state == UNIT_STUB || u->meta.in_dbus_queue)
+ if (u->load_state == UNIT_STUB || u->in_dbus_queue)
return;
/* Shortcut things if nobody cares */
- if (!bus_has_subscriber(u->meta.manager)) {
- u->meta.sent_dbus_new_signal = true;
+ if (!bus_has_subscriber(u->manager)) {
+ u->sent_dbus_new_signal = true;
return;
}
- LIST_PREPEND(Meta, dbus_queue, u->meta.manager->dbus_unit_queue, &u->meta);
- u->meta.in_dbus_queue = true;
+ LIST_PREPEND(Unit, dbus_queue, u->manager->dbus_unit_queue, u);
+ u->in_dbus_queue = true;
}
static void bidi_set_free(Unit *u, Set *s) {
@@ -328,7 +328,7 @@ static void bidi_set_free(Unit *u, Set *s) {
UnitDependency d;
for (d = 0; d < _UNIT_DEPENDENCY_MAX; d++)
- set_remove(other->meta.dependencies[d], u);
+ set_remove(other->dependencies[d], u);
unit_add_to_gc_queue(other);
}
@@ -345,49 +345,49 @@ void unit_free(Unit *u) {
bus_unit_send_removed_signal(u);
- if (u->meta.load_state != UNIT_STUB)
+ if (u->load_state != UNIT_STUB)
if (UNIT_VTABLE(u)->done)
UNIT_VTABLE(u)->done(u);
- SET_FOREACH(t, u->meta.names, i)
- hashmap_remove_value(u->meta.manager->units, t, u);
+ SET_FOREACH(t, u->names, i)
+ hashmap_remove_value(u->manager->units, t, u);
- if (u->meta.job)
- job_free(u->meta.job);
+ if (u->job)
+ job_free(u->job);
for (d = 0; d < _UNIT_DEPENDENCY_MAX; d++)
- bidi_set_free(u, u->meta.dependencies[d]);
+ bidi_set_free(u, u->dependencies[d]);
- if (u->meta.type != _UNIT_TYPE_INVALID)
- LIST_REMOVE(Meta, units_by_type, u->meta.manager->units_by_type[u->meta.type], &u->meta);
+ if (u->type != _UNIT_TYPE_INVALID)
+ LIST_REMOVE(Unit, units_by_type, u->manager->units_by_type[u->type], u);
- if (u->meta.in_load_queue)
- LIST_REMOVE(Meta, load_queue, u->meta.manager->load_queue, &u->meta);
+ if (u->in_load_queue)
+ LIST_REMOVE(Unit, load_queue, u->manager->load_queue, u);
- if (u->meta.in_dbus_queue)
- LIST_REMOVE(Meta, dbus_queue, u->meta.manager->dbus_unit_queue, &u->meta);
+ if (u->in_dbus_queue)
+ LIST_REMOVE(Unit, dbus_queue, u->manager->dbus_unit_queue, u);
- if (u->meta.in_cleanup_queue)
- LIST_REMOVE(Meta, cleanup_queue, u->meta.manager->cleanup_queue, &u->meta);
+ if (u->in_cleanup_queue)
+ LIST_REMOVE(Unit, cleanup_queue, u->manager->cleanup_queue, u);
- if (u->meta.in_gc_queue) {
- LIST_REMOVE(Meta, gc_queue, u->meta.manager->gc_queue, &u->meta);
- u->meta.manager->n_in_gc_queue--;
+ if (u->in_gc_queue) {
+ LIST_REMOVE(Unit, gc_queue, u->manager->gc_queue, u);
+ u->manager->n_in_gc_queue--;
}
- cgroup_bonding_free_list(u->meta.cgroup_bondings, u->meta.manager->n_reloading <= 0);
- cgroup_attribute_free_list(u->meta.cgroup_attributes);
+ cgroup_bonding_free_list(u->cgroup_bondings, u->manager->n_reloading <= 0);
+ cgroup_attribute_free_list(u->cgroup_attributes);
- free(u->meta.description);
- free(u->meta.fragment_path);
- free(u->meta.instance);
+ free(u->description);
+ free(u->fragment_path);
+ free(u->instance);
- set_free_free(u->meta.names);
+ set_free_free(u->names);
- condition_free_list(u->meta.conditions);
+ condition_free_list(u->conditions);
- while (u->meta.refs)
- unit_ref_unset(u->meta.refs);
+ while (u->refs)
+ unit_ref_unset(u->refs);
free(u);
}
@@ -395,7 +395,7 @@ void unit_free(Unit *u) {
UnitActiveState unit_active_state(Unit *u) {
assert(u);
- if (u->meta.load_state == UNIT_MERGED)
+ if (u->load_state == UNIT_MERGED)
return unit_active_state(unit_follow_merge(u));
/* After a reload it might happen that a unit is not correctly
@@ -433,14 +433,14 @@ static void merge_names(Unit *u, Unit *other) {
assert(u);
assert(other);
- complete_move(&u->meta.names, &other->meta.names);
+ complete_move(&u->names, &other->names);
- set_free_free(other->meta.names);
- other->meta.names = NULL;
- other->meta.id = NULL;
+ set_free_free(other->names);
+ other->names = NULL;
+ other->id = NULL;
- SET_FOREACH(t, u->meta.names, i)
- assert_se(hashmap_replace(u->meta.manager->units, t, u) == 0);
+ SET_FOREACH(t, u->names, i)
+ assert_se(hashmap_replace(u->manager->units, t, u) == 0);
}
static void merge_dependencies(Unit *u, Unit *other, UnitDependency d) {
@@ -453,23 +453,23 @@ static void merge_dependencies(Unit *u, Unit *other, UnitDependency d) {
assert(d < _UNIT_DEPENDENCY_MAX);
/* Fix backwards pointers */
- SET_FOREACH(back, other->meta.dependencies[d], i) {
+ SET_FOREACH(back, other->dependencies[d], i) {
UnitDependency k;
for (k = 0; k < _UNIT_DEPENDENCY_MAX; k++)
- if ((r = set_remove_and_put(back->meta.dependencies[k], other, u)) < 0) {
+ if ((r = set_remove_and_put(back->dependencies[k], other, u)) < 0) {
if (r == -EEXIST)
- set_remove(back->meta.dependencies[k], other);
+ set_remove(back->dependencies[k], other);
else
assert(r == -ENOENT);
}
}
- complete_move(&u->meta.dependencies[d], &other->meta.dependencies[d]);
+ complete_move(&u->dependencies[d], &other->dependencies[d]);
- set_free(other->meta.dependencies[d]);
- other->meta.dependencies[d] = NULL;
+ set_free(other->dependencies[d]);
+ other->dependencies[d] = NULL;
}
int unit_merge(Unit *u, Unit *other) {
@@ -477,25 +477,25 @@ int unit_merge(Unit *u, Unit *other) {
assert(u);
assert(other);
- assert(u->meta.manager == other->meta.manager);
- assert(u->meta.type != _UNIT_TYPE_INVALID);
+ assert(u->manager == other->manager);
+ assert(u->type != _UNIT_TYPE_INVALID);
other = unit_follow_merge(other);
if (other == u)
return 0;
- if (u->meta.type != other->meta.type)
+ if (u->type != other->type)
return -EINVAL;
- if (!u->meta.instance != !other->meta.instance)
+ if (!u->instance != !other->instance)
return -EINVAL;
- if (other->meta.load_state != UNIT_STUB &&
- other->meta.load_state != UNIT_ERROR)
+ if (other->load_state != UNIT_STUB &&
+ other->load_state != UNIT_ERROR)
return -EEXIST;
- if (other->meta.job)
+ if (other->job)
return -EEXIST;
if (!UNIT_IS_INACTIVE_OR_FAILED(unit_active_state(other)))
@@ -505,19 +505,19 @@ int unit_merge(Unit *u, Unit *other) {
merge_names(u, other);
/* Redirect all references */
- while (other->meta.refs)
- unit_ref_set(other->meta.refs, u);
+ while (other->refs)
+ unit_ref_set(other->refs, u);
/* Merge dependencies */
for (d = 0; d < _UNIT_DEPENDENCY_MAX; d++)
merge_dependencies(u, other, d);
- other->meta.load_state = UNIT_MERGED;
- other->meta.merged_into = u;
+ other->load_state = UNIT_MERGED;
+ other->merged_into = u;
/* If there is still some data attached to the other node, we
* don't need it anymore, and can free it. */
- if (other->meta.load_state != UNIT_STUB)
+ if (other->load_state != UNIT_STUB)
if (UNIT_VTABLE(other)->done)
UNIT_VTABLE(other)->done(other);
@@ -536,16 +536,16 @@ int unit_merge_by_name(Unit *u, const char *name) {
assert(name);
if (unit_name_is_template(name)) {
- if (!u->meta.instance)
+ if (!u->instance)
return -EINVAL;
- if (!(s = unit_name_replace_instance(name, u->meta.instance)))
+ if (!(s = unit_name_replace_instance(name, u->instance)))
return -ENOMEM;
name = s;
}
- if (!(other = manager_get_unit(u->meta.manager, name)))
+ if (!(other = manager_get_unit(u->manager, name)))
r = unit_add_name(u, name);
else
r = unit_merge(u, other);
@@ -557,8 +557,8 @@ int unit_merge_by_name(Unit *u, const char *name) {
Unit* unit_follow_merge(Unit *u) {
assert(u);
- while (u->meta.load_state == UNIT_MERGED)
- assert_se(u = u->meta.merged_into);
+ while (u->load_state == UNIT_MERGED)
+ assert_se(u = u->merged_into);
return u;
}
@@ -586,7 +586,7 @@ int unit_add_exec_dependencies(Unit *u, ExecContext *c) {
/* If syslog or kernel logging is requested, make sure our own
* logging daemon is run first. */
- if (u->meta.manager->running_as == MANAGER_SYSTEM)
+ if (u->manager->running_as == MANAGER_SYSTEM)
if ((r = unit_add_two_dependencies_by_name(u, UNIT_REQUIRES, UNIT_AFTER, SPECIAL_JOURNALD_SOCKET, NULL, true)) < 0)
return r;
@@ -596,10 +596,10 @@ int unit_add_exec_dependencies(Unit *u, ExecContext *c) {
const char *unit_description(Unit *u) {
assert(u);
- if (u->meta.description)
- return u->meta.description;
+ if (u->description)
+ return u->description;
- return strna(u->meta.id);
+ return strna(u->id);
}
void unit_dump(Unit *u, FILE *f, const char *prefix) {
@@ -617,7 +617,7 @@ void unit_dump(Unit *u, FILE *f, const char *prefix) {
Unit *following;
assert(u);
- assert(u->meta.type >= 0);
+ assert(u->type >= 0);
if (!prefix)
prefix = "";
@@ -636,47 +636,47 @@ void unit_dump(Unit *u, FILE *f, const char *prefix) {
"%s\tInactive Enter Timestamp: %s\n"
"%s\tGC Check Good: %s\n"
"%s\tNeed Daemon Reload: %s\n",
- prefix, u->meta.id,
+ prefix, u->id,
prefix, unit_description(u),
- prefix, strna(u->meta.instance),
- prefix, unit_load_state_to_string(u->meta.load_state),
+ prefix, strna(u->instance),
+ prefix, unit_load_state_to_string(u->load_state),
prefix, unit_active_state_to_string(unit_active_state(u)),
- prefix, strna(format_timestamp(timestamp1, sizeof(timestamp1), u->meta.inactive_exit_timestamp.realtime)),
- prefix, strna(format_timestamp(timestamp2, sizeof(timestamp2), u->meta.active_enter_timestamp.realtime)),
- prefix, strna(format_timestamp(timestamp3, sizeof(timestamp3), u->meta.active_exit_timestamp.realtime)),
- prefix, strna(format_timestamp(timestamp4, sizeof(timestamp4), u->meta.inactive_enter_timestamp.realtime)),
+ prefix, strna(format_timestamp(timestamp1, sizeof(timestamp1), u->inactive_exit_timestamp.realtime)),
+ prefix, strna(format_timestamp(timestamp2, sizeof(timestamp2), u->active_enter_timestamp.realtime)),
+ prefix, strna(format_timestamp(timestamp3, sizeof(timestamp3), u->active_exit_timestamp.realtime)),
+ prefix, strna(format_timestamp(timestamp4, sizeof(timestamp4), u->inactive_enter_timestamp.realtime)),
prefix, yes_no(unit_check_gc(u)),
prefix, yes_no(unit_need_daemon_reload(u)));
- SET_FOREACH(t, u->meta.names, i)
+ SET_FOREACH(t, u->names, i)
fprintf(f, "%s\tName: %s\n", prefix, t);
if ((following = unit_following(u)))
- fprintf(f, "%s\tFollowing: %s\n", prefix, following->meta.id);
+ fprintf(f, "%s\tFollowing: %s\n", prefix, following->id);
- if (u->meta.fragment_path)
- fprintf(f, "%s\tFragment Path: %s\n", prefix, u->meta.fragment_path);
+ if (u->fragment_path)
+ fprintf(f, "%s\tFragment Path: %s\n", prefix, u->fragment_path);
- if (u->meta.job_timeout > 0)
- fprintf(f, "%s\tJob Timeout: %s\n", prefix, format_timespan(timespan, sizeof(timespan), u->meta.job_timeout));
+ if (u->job_timeout > 0)
+ fprintf(f, "%s\tJob Timeout: %s\n", prefix, format_timespan(timespan, sizeof(timespan), u->job_timeout));
- condition_dump_list(u->meta.conditions, f, prefix);
+ condition_dump_list(u->conditions, f, prefix);
- if (dual_timestamp_is_set(&u->meta.condition_timestamp))
+ if (dual_timestamp_is_set(&u->condition_timestamp))
fprintf(f,
"%s\tCondition Timestamp: %s\n"
"%s\tCondition Result: %s\n",
- prefix, strna(format_timestamp(timestamp1, sizeof(timestamp1), u->meta.condition_timestamp.realtime)),
- prefix, yes_no(u->meta.condition_result));
+ prefix, strna(format_timestamp(timestamp1, sizeof(timestamp1), u->condition_timestamp.realtime)),
+ prefix, yes_no(u->condition_result));
for (d = 0; d < _UNIT_DEPENDENCY_MAX; d++) {
Unit *other;
- SET_FOREACH(other, u->meta.dependencies[d], i)
- fprintf(f, "%s\t%s: %s\n", prefix, unit_dependency_to_string(d), other->meta.id);
+ SET_FOREACH(other, u->dependencies[d], i)
+ fprintf(f, "%s\t%s: %s\n", prefix, unit_dependency_to_string(d), other->id);
}
- if (u->meta.load_state == UNIT_LOADED) {
+ if (u->load_state == UNIT_LOADED) {
CGroupBonding *b;
CGroupAttribute *a;
@@ -688,19 +688,19 @@ void unit_dump(Unit *u, FILE *f, const char *prefix) {
"%s\tOnFailureIsolate: %s\n"
"%s\tIgnoreOnIsolate: %s\n"
"%s\tIgnoreOnSnapshot: %s\n",
- prefix, yes_no(u->meta.stop_when_unneeded),
- prefix, yes_no(u->meta.refuse_manual_start),
- prefix, yes_no(u->meta.refuse_manual_stop),
- prefix, yes_no(u->meta.default_dependencies),
- prefix, yes_no(u->meta.on_failure_isolate),
- prefix, yes_no(u->meta.ignore_on_isolate),
- prefix, yes_no(u->meta.ignore_on_snapshot));
-
- LIST_FOREACH(by_unit, b, u->meta.cgroup_bondings)
+ prefix, yes_no(u->stop_when_unneeded),
+ prefix, yes_no(u->refuse_manual_start),
+ prefix, yes_no(u->refuse_manual_stop),
+ prefix, yes_no(u->default_dependencies),
+ prefix, yes_no(u->on_failure_isolate),
+ prefix, yes_no(u->ignore_on_isolate),
+ prefix, yes_no(u->ignore_on_snapshot));
+
+ LIST_FOREACH(by_unit, b, u->cgroup_bondings)
fprintf(f, "%s\tControlGroup: %s:%s\n",
prefix, b->controller, b->path);
- LIST_FOREACH(by_unit, a, u->meta.cgroup_attributes) {
+ LIST_FOREACH(by_unit, a, u->cgroup_attributes) {
char *v = NULL;
if (a->map_callback)
@@ -715,16 +715,16 @@ void unit_dump(Unit *u, FILE *f, const char *prefix) {
if (UNIT_VTABLE(u)->dump)
UNIT_VTABLE(u)->dump(u, f, prefix2);
- } else if (u->meta.load_state == UNIT_MERGED)
+ } else if (u->load_state == UNIT_MERGED)
fprintf(f,
"%s\tMerged into: %s\n",
- prefix, u->meta.merged_into->meta.id);
- else if (u->meta.load_state == UNIT_ERROR)
- fprintf(f, "%s\tLoad Error Code: %s\n", prefix, strerror(-u->meta.load_error));
+ prefix, u->merged_into->id);
+ else if (u->load_state == UNIT_ERROR)
+ fprintf(f, "%s\tLoad Error Code: %s\n", prefix, strerror(-u->load_error));
- if (u->meta.job)
- job_dump(u->meta.job, f, prefix2);
+ if (u->job)
+ job_dump(u->job, f, prefix2);
free(p2);
}
@@ -739,7 +739,7 @@ int unit_load_fragment_and_dropin(Unit *u) {
if ((r = unit_load_fragment(u)) < 0)
return r;
- if (u->meta.load_state == UNIT_STUB)
+ if (u->load_state == UNIT_STUB)
return -ENOENT;
/* Load drop-in directory data */
@@ -762,8 +762,8 @@ int unit_load_fragment_and_dropin_optional(Unit *u) {
if ((r = unit_load_fragment(u)) < 0)
return r;
- if (u->meta.load_state == UNIT_STUB)
- u->meta.load_state = UNIT_LOADED;
+ if (u->load_state == UNIT_STUB)
+ u->load_state = UNIT_LOADED;
/* Load drop-in directory data */
if ((r = unit_load_dropin(unit_follow_merge(u))) < 0)
@@ -776,23 +776,23 @@ int unit_add_default_target_dependency(Unit *u, Unit *target) {
assert(u);
assert(target);
- if (target->meta.type != UNIT_TARGET)
+ if (target->type != UNIT_TARGET)
return 0;
/* Only add the dependency if both units are loaded, so that
* that loop check below is reliable */
- if (u->meta.load_state != UNIT_LOADED ||
- target->meta.load_state != UNIT_LOADED)
+ if (u->load_state != UNIT_LOADED ||
+ target->load_state != UNIT_LOADED)
return 0;
/* If either side wants no automatic dependencies, then let's
* skip this */
- if (!u->meta.default_dependencies ||
- !target->meta.default_dependencies)
+ if (!u->default_dependencies ||
+ !target->default_dependencies)
return 0;
/* Don't create loops */
- if (set_get(target->meta.dependencies[UNIT_BEFORE], u))
+ if (set_get(target->dependencies[UNIT_BEFORE], u))
return 0;
return unit_add_dependency(target, UNIT_AFTER, u, true);
@@ -814,7 +814,7 @@ static int unit_add_default_dependencies(Unit *u) {
assert(u);
for (k = 0; k < ELEMENTSOF(deps); k++)
- SET_FOREACH(target, u->meta.dependencies[deps[k]], i)
+ SET_FOREACH(target, u->dependencies[deps[k]], i)
if ((r = unit_add_default_target_dependency(u, target)) < 0)
return r;
@@ -826,42 +826,42 @@ int unit_load(Unit *u) {
assert(u);
- if (u->meta.in_load_queue) {
- LIST_REMOVE(Meta, load_queue, u->meta.manager->load_queue, &u->meta);
- u->meta.in_load_queue = false;
+ if (u->in_load_queue) {
+ LIST_REMOVE(Unit, load_queue, u->manager->load_queue, u);
+ u->in_load_queue = false;
}
- if (u->meta.type == _UNIT_TYPE_INVALID)
+ if (u->type == _UNIT_TYPE_INVALID)
return -EINVAL;
- if (u->meta.load_state != UNIT_STUB)
+ if (u->load_state != UNIT_STUB)
return 0;
if (UNIT_VTABLE(u)->load)
if ((r = UNIT_VTABLE(u)->load(u)) < 0)
goto fail;
- if (u->meta.load_state == UNIT_STUB) {
+ if (u->load_state == UNIT_STUB) {
r = -ENOENT;
goto fail;
}
- if (u->meta.load_state == UNIT_LOADED &&
- u->meta.default_dependencies)
+ if (u->load_state == UNIT_LOADED &&
+ u->default_dependencies)
if ((r = unit_add_default_dependencies(u)) < 0)
goto fail;
- if (u->meta.on_failure_isolate &&
- set_size(u->meta.dependencies[UNIT_ON_FAILURE]) > 1) {
+ if (u->on_failure_isolate &&
+ set_size(u->dependencies[UNIT_ON_FAILURE]) > 1) {
log_error("More than one OnFailure= dependencies specified for %s but OnFailureIsolate= enabled. Refusing.",
- u->meta.id);
+ u->id);
r = -EINVAL;
goto fail;
}
- assert((u->meta.load_state != UNIT_MERGED) == !u->meta.merged_into);
+ assert((u->load_state != UNIT_MERGED) == !u->merged_into);
unit_add_to_dbus_queue(unit_follow_merge(u));
unit_add_to_gc_queue(u);
@@ -869,12 +869,12 @@ int unit_load(Unit *u) {
return 0;
fail:
- u->meta.load_state = UNIT_ERROR;
- u->meta.load_error = r;
+ u->load_state = UNIT_ERROR;
+ u->load_error = r;
unit_add_to_dbus_queue(u);
unit_add_to_gc_queue(u);
- log_debug("Failed to load configuration for %s: %s", u->meta.id, strerror(-r));
+ log_debug("Failed to load configuration for %s: %s", u->id, strerror(-r));
return r;
}
@@ -882,10 +882,10 @@ fail:
bool unit_condition_test(Unit *u) {
assert(u);
- dual_timestamp_get(&u->meta.condition_timestamp);
- u->meta.condition_result = condition_test_list(u->meta.conditions);
+ dual_timestamp_get(&u->condition_timestamp);
+ u->condition_result = condition_test_list(u->conditions);
- return u->meta.condition_result;
+ return u->condition_result;
}
/* Errors:
@@ -900,7 +900,7 @@ int unit_start(Unit *u) {
assert(u);
- if (u->meta.load_state != UNIT_LOADED)
+ if (u->load_state != UNIT_LOADED)
return -EINVAL;
/* If this is already started, then this will succeed. Note
@@ -917,13 +917,13 @@ int unit_start(Unit *u) {
* but we don't want to recheck the condition in that case. */
if (state != UNIT_ACTIVATING &&
!unit_condition_test(u)) {
- log_debug("Starting of %s requested but condition failed. Ignoring.", u->meta.id);
+ log_debug("Starting of %s requested but condition failed. Ignoring.", u->id);
return -EALREADY;
}
/* Forward to the main object, if we aren't it. */
if ((following = unit_following(u))) {
- log_debug("Redirecting start request from %s to %s.", u->meta.id, following->meta.id);
+ log_debug("Redirecting start request from %s to %s.", u->id, following->id);
return unit_start(following);
}
@@ -953,7 +953,7 @@ bool unit_can_isolate(Unit *u) {
assert(u);
return unit_can_start(u) &&
- u->meta.allow_isolate;
+ u->allow_isolate;
}
/* Errors:
@@ -972,7 +972,7 @@ int unit_stop(Unit *u) {
return -EALREADY;
if ((following = unit_following(u))) {
- log_debug("Redirecting stop request from %s to %s.", u->meta.id, following->meta.id);
+ log_debug("Redirecting stop request from %s to %s.", u->id, following->id);
return unit_stop(following);
}
@@ -996,7 +996,7 @@ int unit_reload(Unit *u) {
assert(u);
- if (u->meta.load_state != UNIT_LOADED)
+ if (u->load_state != UNIT_LOADED)
return -EINVAL;
if (!unit_can_reload(u))
@@ -1010,7 +1010,7 @@ int unit_reload(Unit *u) {
return -ENOEXEC;
if ((following = unit_following(u))) {
- log_debug("Redirecting reload request from %s to %s.", u->meta.id, following->meta.id);
+ log_debug("Redirecting reload request from %s to %s.", u->id, following->id);
return unit_reload(following);
}
@@ -1039,32 +1039,32 @@ static void unit_check_unneeded(Unit *u) {
/* If this service shall be shut down when unneeded then do
* so. */
- if (!u->meta.stop_when_unneeded)
+ if (!u->stop_when_unneeded)
return;
if (!UNIT_IS_ACTIVE_OR_ACTIVATING(unit_active_state(u)))
return;
- SET_FOREACH(other, u->meta.dependencies[UNIT_REQUIRED_BY], i)
+ SET_FOREACH(other, u->dependencies[UNIT_REQUIRED_BY], i)
if (unit_pending_active(other))
return;
- SET_FOREACH(other, u->meta.dependencies[UNIT_REQUIRED_BY_OVERRIDABLE], i)
+ SET_FOREACH(other, u->dependencies[UNIT_REQUIRED_BY_OVERRIDABLE], i)
if (unit_pending_active(other))
return;
- SET_FOREACH(other, u->meta.dependencies[UNIT_WANTED_BY], i)
+ SET_FOREACH(other, u->dependencies[UNIT_WANTED_BY], i)
if (unit_pending_active(other))
return;
- SET_FOREACH(other, u->meta.dependencies[UNIT_BOUND_BY], i)
+ SET_FOREACH(other, u->dependencies[UNIT_BOUND_BY], i)
if (unit_pending_active(other))
return;
- log_info("Service %s is not needed anymore. Stopping.", u->meta.id);
+ log_info("Service %s is not needed anymore. Stopping.", u->id);
/* Ok, nobody needs us anymore. Sniff. Then let's commit suicide */
- manager_add_job(u->meta.manager, JOB_STOP, u, JOB_FAIL, true, NULL, NULL);
+ manager_add_job(u->manager, JOB_STOP, u, JOB_FAIL, true, NULL, NULL);
}
static void retroactively_start_dependencies(Unit *u) {
@@ -1074,38 +1074,38 @@ static void retroactively_start_dependencies(Unit *u) {
assert(u);
assert(UNIT_IS_ACTIVE_OR_ACTIVATING(unit_active_state(u)));
- SET_FOREACH(other, u->meta.dependencies[UNIT_REQUIRES], i)
- if (!set_get(u->meta.dependencies[UNIT_AFTER], other) &&
+ SET_FOREACH(other, u->dependencies[UNIT_REQUIRES], i)
+ if (!set_get(u->dependencies[UNIT_AFTER], other) &&
!UNIT_IS_ACTIVE_OR_ACTIVATING(unit_active_state(other)))
- manager_add_job(u->meta.manager, JOB_START, other, JOB_REPLACE, true, NULL, NULL);
+ manager_add_job(u->manager, JOB_START, other, JOB_REPLACE, true, NULL, NULL);
- SET_FOREACH(other, u->meta.dependencies[UNIT_BIND_TO], i)
- if (!set_get(u->meta.dependencies[UNIT_AFTER], other) &&
+ SET_FOREACH(other, u->dependencies[UNIT_BIND_TO], i)
+ if (!set_get(u->dependencies[UNIT_AFTER], other) &&
!UNIT_IS_ACTIVE_OR_ACTIVATING(unit_active_state(other)))
- manager_add_job(u->meta.manager, JOB_START, other, JOB_REPLACE, true, NULL, NULL);
+ manager_add_job(u->manager, JOB_START, other, JOB_REPLACE, true, NULL, NULL);
- SET_FOREACH(other, u->meta.dependencies[UNIT_REQUIRES_OVERRIDABLE], i)
- if (!set_get(u->meta.dependencies[UNIT_AFTER], other) &&
+ SET_FOREACH(other, u->dependencies[UNIT_REQUIRES_OVERRIDABLE], i)
+ if (!set_get(u->dependencies[UNIT_AFTER], other) &&
!UNIT_IS_ACTIVE_OR_ACTIVATING(unit_active_state(other)))
- manager_add_job(u->meta.manager, JOB_START, other, JOB_FAIL, false, NULL, NULL);
+ manager_add_job(u->manager, JOB_START, other, JOB_FAIL, false, NULL, NULL);
- SET_FOREACH(other, u->meta.dependencies[UNIT_REQUISITE], i)
- if (!set_get(u->meta.dependencies[UNIT_AFTER], other) &&
+ SET_FOREACH(other, u->dependencies[UNIT_REQUISITE], i)
+ if (!set_get(u->dependencies[UNIT_AFTER], other) &&
!UNIT_IS_ACTIVE_OR_ACTIVATING(unit_active_state(other)))
- manager_add_job(u->meta.manager, JOB_START, other, JOB_REPLACE, true, NULL, NULL);
+ manager_add_job(u->manager, JOB_START, other, JOB_REPLACE, true, NULL, NULL);
- SET_FOREACH(other, u->meta.dependencies[UNIT_WANTS], i)
- if (!set_get(u->meta.dependencies[UNIT_AFTER], other) &&
+ SET_FOREACH(other, u->dependencies[UNIT_WANTS], i)
+ if (!set_get(u->dependencies[UNIT_AFTER], other) &&
!UNIT_IS_ACTIVE_OR_ACTIVATING(unit_active_state(other)))
- manager_add_job(u->meta.manager, JOB_START, other, JOB_FAIL, false, NULL, NULL);
+ manager_add_job(u->manager, JOB_START, other, JOB_FAIL, false, NULL, NULL);
- SET_FOREACH(other, u->meta.dependencies[UNIT_CONFLICTS], i)
+ SET_FOREACH(other, u->dependencies[UNIT_CONFLICTS], i)
if (!UNIT_IS_INACTIVE_OR_DEACTIVATING(unit_active_state(other)))
- manager_add_job(u->meta.manager, JOB_STOP, other, JOB_REPLACE, true, NULL, NULL);
+ manager_add_job(u->manager, JOB_STOP, other, JOB_REPLACE, true, NULL, NULL);
- SET_FOREACH(other, u->meta.dependencies[UNIT_CONFLICTED_BY], i)
+ SET_FOREACH(other, u->dependencies[UNIT_CONFLICTED_BY], i)
if (!UNIT_IS_INACTIVE_OR_DEACTIVATING(unit_active_state(other)))
- manager_add_job(u->meta.manager, JOB_STOP, other, JOB_REPLACE, true, NULL, NULL);
+ manager_add_job(u->manager, JOB_STOP, other, JOB_REPLACE, true, NULL, NULL);
}
static void retroactively_stop_dependencies(Unit *u) {
@@ -1116,9 +1116,9 @@ static void retroactively_stop_dependencies(Unit *u) {
assert(UNIT_IS_INACTIVE_OR_DEACTIVATING(unit_active_state(u)));
/* Pull down units which are bound to us recursively if enabled */
- SET_FOREACH(other, u->meta.dependencies[UNIT_BOUND_BY], i)
+ SET_FOREACH(other, u->dependencies[UNIT_BOUND_BY], i)
if (!UNIT_IS_INACTIVE_OR_DEACTIVATING(unit_active_state(other)))
- manager_add_job(u->meta.manager, JOB_STOP, other, JOB_REPLACE, true, NULL, NULL);
+ manager_add_job(u->manager, JOB_STOP, other, JOB_REPLACE, true, NULL, NULL);
}
static void check_unneeded_dependencies(Unit *u) {
@@ -1129,22 +1129,22 @@ static void check_unneeded_dependencies(Unit *u) {
assert(UNIT_IS_INACTIVE_OR_DEACTIVATING(unit_active_state(u)));
/* Garbage collect services that might not be needed anymore, if enabled */
- SET_FOREACH(other, u->meta.dependencies[UNIT_REQUIRES], i)
+ SET_FOREACH(other, u->dependencies[UNIT_REQUIRES], i)
if (!UNIT_IS_INACTIVE_OR_DEACTIVATING(unit_active_state(other)))
unit_check_unneeded(other);
- SET_FOREACH(other, u->meta.dependencies[UNIT_REQUIRES_OVERRIDABLE], i)
+ SET_FOREACH(other, u->dependencies[UNIT_REQUIRES_OVERRIDABLE], i)
if (!UNIT_IS_INACTIVE_OR_DEACTIVATING(unit_active_state(other)))
unit_check_unneeded(other);
- SET_FOREACH(other, u->meta.dependencies[UNIT_WANTS], i)
+ SET_FOREACH(other, u->dependencies[UNIT_WANTS], i)
if (!UNIT_IS_INACTIVE_OR_DEACTIVATING(unit_active_state(other)))
unit_check_unneeded(other);
- SET_FOREACH(other, u->meta.dependencies[UNIT_REQUISITE], i)
+ SET_FOREACH(other, u->dependencies[UNIT_REQUISITE], i)
if (!UNIT_IS_INACTIVE_OR_DEACTIVATING(unit_active_state(other)))
unit_check_unneeded(other);
- SET_FOREACH(other, u->meta.dependencies[UNIT_REQUISITE_OVERRIDABLE], i)
+ SET_FOREACH(other, u->dependencies[UNIT_REQUISITE_OVERRIDABLE], i)
if (!UNIT_IS_INACTIVE_OR_DEACTIVATING(unit_active_state(other)))
unit_check_unneeded(other);
- SET_FOREACH(other, u->meta.dependencies[UNIT_BIND_TO], i)
+ SET_FOREACH(other, u->dependencies[UNIT_BIND_TO], i)
if (!UNIT_IS_INACTIVE_OR_DEACTIVATING(unit_active_state(other)))
unit_check_unneeded(other);
}
@@ -1155,15 +1155,15 @@ void unit_trigger_on_failure(Unit *u) {
assert(u);
- if (set_size(u->meta.dependencies[UNIT_ON_FAILURE]) <= 0)
+ if (set_size(u->dependencies[UNIT_ON_FAILURE]) <= 0)
return;
- log_info("Triggering OnFailure= dependencies of %s.", u->meta.id);
+ log_info("Triggering OnFailure= dependencies of %s.", u->id);
- SET_FOREACH(other, u->meta.dependencies[UNIT_ON_FAILURE], i) {
+ SET_FOREACH(other, u->dependencies[UNIT_ON_FAILURE], i) {
int r;
- if ((r = manager_add_job(u->meta.manager, JOB_START, other, u->meta.on_failure_isolate ? JOB_ISOLATE : JOB_REPLACE, true, NULL, NULL)) < 0)
+ if ((r = manager_add_job(u->manager, JOB_START, other, u->on_failure_isolate ? JOB_ISOLATE : JOB_REPLACE, true, NULL, NULL)) < 0)
log_error("Failed to enqueue OnFailure= job: %s", strerror(-r));
}
}
@@ -1181,54 +1181,54 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_su
* behaviour here. For example: if a mount point is remounted
* this function will be called too! */
- if (u->meta.manager->n_reloading <= 0) {
+ if (u->manager->n_reloading <= 0) {
dual_timestamp ts;
dual_timestamp_get(&ts);
if (UNIT_IS_INACTIVE_OR_FAILED(os) && !UNIT_IS_INACTIVE_OR_FAILED(ns))
- u->meta.inactive_exit_timestamp = ts;
+ u->inactive_exit_timestamp = ts;
else if (!UNIT_IS_INACTIVE_OR_FAILED(os) && UNIT_IS_INACTIVE_OR_FAILED(ns))
- u->meta.inactive_enter_timestamp = ts;
+ u->inactive_enter_timestamp = ts;
if (!UNIT_IS_ACTIVE_OR_RELOADING(os) && UNIT_IS_ACTIVE_OR_RELOADING(ns))
- u->meta.active_enter_timestamp = ts;
+ u->active_enter_timestamp = ts;
else if (UNIT_IS_ACTIVE_OR_RELOADING(os) && !UNIT_IS_ACTIVE_OR_RELOADING(ns))
- u->meta.active_exit_timestamp = ts;
+ u->active_exit_timestamp = ts;
timer_unit_notify(u, ns);
path_unit_notify(u, ns);
}
if (UNIT_IS_INACTIVE_OR_FAILED(ns))
- cgroup_bonding_trim_list(u->meta.cgroup_bondings, true);
+ cgroup_bonding_trim_list(u->cgroup_bondings, true);
- if (u->meta.job) {
+ if (u->job) {
unexpected = false;
- if (u->meta.job->state == JOB_WAITING)
+ if (u->job->state == JOB_WAITING)
/* So we reached a different state for this
* job. Let's see if we can run it now if it
* failed previously due to EAGAIN. */
- job_add_to_run_queue(u->meta.job);
+ job_add_to_run_queue(u->job);
/* Let's check whether this state change constitutes a
* finished job, or maybe contradicts a running job and
* hence needs to invalidate jobs. */
- switch (u->meta.job->type) {
+ switch (u->job->type) {
case JOB_START:
case JOB_VERIFY_ACTIVE:
if (UNIT_IS_ACTIVE_OR_RELOADING(ns))
- job_finish_and_invalidate(u->meta.job, JOB_DONE);
- else if (u->meta.job->state == JOB_RUNNING && ns != UNIT_ACTIVATING) {
+ job_finish_and_invalidate(u->job, JOB_DONE);
+ else if (u->job->state == JOB_RUNNING && ns != UNIT_ACTIVATING) {
unexpected = true;
if (UNIT_IS_INACTIVE_OR_FAILED(ns))
- job_finish_and_invalidate(u->meta.job, ns == UNIT_FAILED ? JOB_FAILED : JOB_DONE);
+ job_finish_and_invalidate(u->job, ns == UNIT_FAILED ? JOB_FAILED : JOB_DONE);
}
break;
@@ -1236,14 +1236,14 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_su
case JOB_RELOAD:
case JOB_RELOAD_OR_START:
- if (u->meta.job->state == JOB_RUNNING) {
+ if (u->job->state == JOB_RUNNING) {
if (ns == UNIT_ACTIVE)
- job_finish_and_invalidate(u->meta.job, reload_success ? JOB_DONE : JOB_FAILED);
+ job_finish_and_invalidate(u->job, reload_success ? JOB_DONE : JOB_FAILED);
else if (ns != UNIT_ACTIVATING && ns != UNIT_RELOADING) {
unexpected = true;
if (UNIT_IS_INACTIVE_OR_FAILED(ns))
- job_finish_and_invalidate(u->meta.job, ns == UNIT_FAILED ? JOB_FAILED : JOB_DONE);
+ job_finish_and_invalidate(u->job, ns == UNIT_FAILED ? JOB_FAILED : JOB_DONE);
}
}
@@ -1254,10 +1254,10 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_su
case JOB_TRY_RESTART:
if (UNIT_IS_INACTIVE_OR_FAILED(ns))
- job_finish_and_invalidate(u->meta.job, JOB_DONE);
- else if (u->meta.job->state == JOB_RUNNING && ns != UNIT_DEACTIVATING) {
+ job_finish_and_invalidate(u->job, JOB_DONE);
+ else if (u->job->state == JOB_RUNNING && ns != UNIT_DEACTIVATING) {
unexpected = true;
- job_finish_and_invalidate(u->meta.job, JOB_FAILED);
+ job_finish_and_invalidate(u->job, JOB_FAILED);
}
break;
@@ -1269,7 +1269,7 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_su
} else
unexpected = true;
- if (u->meta.manager->n_reloading <= 0) {
+ if (u->manager->n_reloading <= 0) {
/* If this state change happened without being
* requested by a job, then let's retroactively start
@@ -1290,7 +1290,7 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_su
check_unneeded_dependencies(u);
if (ns != os && ns == UNIT_FAILED) {
- log_notice("Unit %s entered failed state.", u->meta.id);
+ log_notice("Unit %s entered failed state.", u->id);
unit_trigger_on_failure(u);
}
}
@@ -1302,46 +1302,46 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_su
/* The bus just might have become available,
* hence try to connect to it, if we aren't
* yet connected. */
- bus_init(u->meta.manager, true);
+ bus_init(u->manager, true);
- if (u->meta.type == UNIT_SERVICE &&
+ if (u->type == UNIT_SERVICE &&
!UNIT_IS_ACTIVE_OR_RELOADING(os) &&
- u->meta.manager->n_reloading <= 0) {
+ u->manager->n_reloading <= 0) {
/* Write audit record if we have just finished starting up */
- manager_send_unit_audit(u->meta.manager, u, AUDIT_SERVICE_START, true);
- u->meta.in_audit = true;
+ manager_send_unit_audit(u->manager, u, AUDIT_SERVICE_START, true);
+ u->in_audit = true;
}
if (!UNIT_IS_ACTIVE_OR_RELOADING(os))
- manager_send_unit_plymouth(u->meta.manager, u);
+ manager_send_unit_plymouth(u->manager, u);
} else {
/* We don't care about D-Bus here, since we'll get an
* asynchronous notification for it anyway. */
- if (u->meta.type == UNIT_SERVICE &&
+ if (u->type == UNIT_SERVICE &&
UNIT_IS_INACTIVE_OR_FAILED(ns) &&
!UNIT_IS_INACTIVE_OR_FAILED(os) &&
- u->meta.manager->n_reloading <= 0) {
+ u->manager->n_reloading <= 0) {
/* Hmm, if there was no start record written
* write it now, so that we always have a nice
* pair */
- if (!u->meta.in_audit) {
- manager_send_unit_audit(u->meta.manager, u, AUDIT_SERVICE_START, ns == UNIT_INACTIVE);
+ if (!u->in_audit) {
+ manager_send_unit_audit(u->manager, u, AUDIT_SERVICE_START, ns == UNIT_INACTIVE);
if (ns == UNIT_INACTIVE)
- manager_send_unit_audit(u->meta.manager, u, AUDIT_SERVICE_STOP, true);
+ manager_send_unit_audit(u->manager, u, AUDIT_SERVICE_STOP, true);
} else
/* Write audit record if we have just finished shutting down */
- manager_send_unit_audit(u->meta.manager, u, AUDIT_SERVICE_STOP, ns == UNIT_INACTIVE);
+ manager_send_unit_audit(u->manager, u, AUDIT_SERVICE_STOP, ns == UNIT_INACTIVE);
- u->meta.in_audit = false;
+ u->in_audit = false;
}
}
- manager_recheck_journal(u->meta.manager);
+ manager_recheck_journal(u->manager);
/* Maybe we finished startup and are now ready for being
* stopped because unneeded? */
@@ -1363,7 +1363,7 @@ int unit_watch_fd(Unit *u, int fd, uint32_t events, Watch *w) {
ev.data.ptr = w;
ev.events = events;
- if (epoll_ctl(u->meta.manager->epoll_fd,
+ if (epoll_ctl(u->manager->epoll_fd,
w->type == WATCH_INVALID ? EPOLL_CTL_ADD : EPOLL_CTL_MOD,
fd,
&ev) < 0)
@@ -1385,7 +1385,7 @@ void unit_unwatch_fd(Unit *u, Watch *w) {
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);
+ assert_se(epoll_ctl(u->manager->epoll_fd, EPOLL_CTL_DEL, w->fd, NULL) >= 0);
w->fd = -1;
w->type = WATCH_INVALID;
@@ -1399,14 +1399,14 @@ int unit_watch_pid(Unit *u, pid_t pid) {
/* Watch a specific PID. We only support one unit watching
* each PID for now. */
- return hashmap_put(u->meta.manager->watch_pids, LONG_TO_PTR(pid), u);
+ return hashmap_put(u->manager->watch_pids, LONG_TO_PTR(pid), u);
}
void unit_unwatch_pid(Unit *u, pid_t pid) {
assert(u);
assert(pid >= 1);
- hashmap_remove_value(u->meta.manager->watch_pids, LONG_TO_PTR(pid), u);
+ hashmap_remove_value(u->manager->watch_pids, LONG_TO_PTR(pid), u);
}
int unit_watch_timer(Unit *u, usec_t delay, Watch *w) {
@@ -1459,7 +1459,7 @@ int unit_watch_timer(Unit *u, usec_t delay, Watch *w) {
ev.data.ptr = w;
ev.events = EPOLLIN;
- if (epoll_ctl(u->meta.manager->epoll_fd, EPOLL_CTL_ADD, fd, &ev) < 0)
+ if (epoll_ctl(u->manager->epoll_fd, EPOLL_CTL_ADD, fd, &ev) < 0)
goto fail;
}
@@ -1487,7 +1487,7 @@ void unit_unwatch_timer(Unit *u, Watch *w) {
assert(w->data.unit == u);
assert(w->fd >= 0);
- assert_se(epoll_ctl(u->meta.manager->epoll_fd, EPOLL_CTL_DEL, w->fd, NULL) >= 0);
+ assert_se(epoll_ctl(u->manager->epoll_fd, EPOLL_CTL_DEL, w->fd, NULL) >= 0);
close_nointr_nofail(w->fd);
w->fd = -1;
@@ -1560,34 +1560,34 @@ int unit_add_dependency(Unit *u, UnitDependency d, Unit *other, bool add_referen
if (u == other)
return 0;
- if ((r = set_ensure_allocated(&u->meta.dependencies[d], trivial_hash_func, trivial_compare_func)) < 0)
+ if ((r = set_ensure_allocated(&u->dependencies[d], trivial_hash_func, trivial_compare_func)) < 0)
return r;
if (inverse_table[d] != _UNIT_DEPENDENCY_INVALID)
- if ((r = set_ensure_allocated(&other->meta.dependencies[inverse_table[d]], trivial_hash_func, trivial_compare_func)) < 0)
+ if ((r = set_ensure_allocated(&other->dependencies[inverse_table[d]], trivial_hash_func, trivial_compare_func)) < 0)
return r;
if (add_reference)
- if ((r = set_ensure_allocated(&u->meta.dependencies[UNIT_REFERENCES], trivial_hash_func, trivial_compare_func)) < 0 ||
- (r = set_ensure_allocated(&other->meta.dependencies[UNIT_REFERENCED_BY], trivial_hash_func, trivial_compare_func)) < 0)
+ if ((r = set_ensure_allocated(&u->dependencies[UNIT_REFERENCES], trivial_hash_func, trivial_compare_func)) < 0 ||
+ (r = set_ensure_allocated(&other->dependencies[UNIT_REFERENCED_BY], trivial_hash_func, trivial_compare_func)) < 0)
return r;
- if ((q = set_put(u->meta.dependencies[d], other)) < 0)
+ if ((q = set_put(u->dependencies[d], other)) < 0)
return q;
if (inverse_table[d] != _UNIT_DEPENDENCY_INVALID)
- if ((v = set_put(other->meta.dependencies[inverse_table[d]], u)) < 0) {
+ if ((v = set_put(other->dependencies[inverse_table[d]], u)) < 0) {
r = v;
goto fail;
}
if (add_reference) {
- if ((w = set_put(u->meta.dependencies[UNIT_REFERENCES], other)) < 0) {
+ if ((w = set_put(u->dependencies[UNIT_REFERENCES], other)) < 0) {
r = w;
goto fail;
}
- if ((r = set_put(other->meta.dependencies[UNIT_REFERENCED_BY], u)) < 0)
+ if ((r = set_put(other->dependencies[UNIT_REFERENCED_BY], u)) < 0)
goto fail;
}
@@ -1596,13 +1596,13 @@ int unit_add_dependency(Unit *u, UnitDependency d, Unit *other, bool add_referen
fail:
if (q > 0)
- set_remove(u->meta.dependencies[d], other);
+ set_remove(u->dependencies[d], other);
if (v > 0)
- set_remove(other->meta.dependencies[inverse_table[d]], u);
+ set_remove(other->dependencies[inverse_table[d]], u);
if (w > 0)
- set_remove(u->meta.dependencies[UNIT_REFERENCES], other);
+ set_remove(u->dependencies[UNIT_REFERENCES], other);
return r;
}
@@ -1635,12 +1635,12 @@ static const char *resolve_template(Unit *u, const char *name, const char*path,
return name;
}
- if (u->meta.instance)
- s = unit_name_replace_instance(name, u->meta.instance);
+ if (u->instance)
+ s = unit_name_replace_instance(name, u->instance);
else {
char *i;
- if (!(i = unit_name_to_prefix(u->meta.id)))
+ if (!(i = unit_name_to_prefix(u->id)))
return NULL;
s = unit_name_replace_instance(name, i);
@@ -1665,7 +1665,7 @@ int unit_add_dependency_by_name(Unit *u, UnitDependency d, const char *name, con
if (!(name = resolve_template(u, name, path, &s)))
return -ENOMEM;
- if ((r = manager_load_unit(u->meta.manager, name, path, NULL, &other)) < 0)
+ if ((r = manager_load_unit(u->manager, name, path, NULL, &other)) < 0)
goto finish;
r = unit_add_dependency(u, d, other, add_reference);
@@ -1686,7 +1686,7 @@ int unit_add_two_dependencies_by_name(Unit *u, UnitDependency d, UnitDependency
if (!(name = resolve_template(u, name, path, &s)))
return -ENOMEM;
- if ((r = manager_load_unit(u->meta.manager, name, path, NULL, &other)) < 0)
+ if ((r = manager_load_unit(u->manager, name, path, NULL, &other)) < 0)
goto finish;
r = unit_add_two_dependencies(u, d, e, other, add_reference);
@@ -1707,7 +1707,7 @@ int unit_add_dependency_by_name_inverse(Unit *u, UnitDependency d, const char *n
if (!(name = resolve_template(u, name, path, &s)))
return -ENOMEM;
- if ((r = manager_load_unit(u->meta.manager, name, path, NULL, &other)) < 0)
+ if ((r = manager_load_unit(u->manager, name, path, NULL, &other)) < 0)
goto finish;
r = unit_add_dependency(other, d, u, add_reference);
@@ -1728,7 +1728,7 @@ int unit_add_two_dependencies_by_name_inverse(Unit *u, UnitDependency d, UnitDep
if (!(name = resolve_template(u, name, path, &s)))
return -ENOMEM;
- if ((r = manager_load_unit(u->meta.manager, name, path, NULL, &other)) < 0)
+ if ((r = manager_load_unit(u->manager, name, path, NULL, &other)) < 0)
goto finish;
if ((r = unit_add_two_dependencies(other, d, e, u, add_reference)) < 0)
@@ -1773,10 +1773,10 @@ char *unit_dbus_path(Unit *u) {
assert(u);
- if (!u->meta.id)
+ if (!u->id)
return NULL;
- if (!(e = bus_path_escape(u->meta.id)))
+ if (!(e = bus_path_escape(u->id)))
return NULL;
p = strappend("/org/freedesktop/systemd1/unit/", e);
@@ -1806,16 +1806,16 @@ int unit_add_cgroup(Unit *u, CGroupBonding *b) {
if (streq(b->controller, SYSTEMD_CGROUP_CONTROLLER)) {
CGroupBonding *l;
- l = hashmap_get(u->meta.manager->cgroup_bondings, b->path);
+ l = hashmap_get(u->manager->cgroup_bondings, b->path);
LIST_PREPEND(CGroupBonding, by_path, l, b);
- if ((r = hashmap_replace(u->meta.manager->cgroup_bondings, b->path, l)) < 0) {
+ if ((r = hashmap_replace(u->manager->cgroup_bondings, b->path, l)) < 0) {
LIST_REMOVE(CGroupBonding, by_path, l, b);
return r;
}
}
- LIST_PREPEND(CGroupBonding, by_unit, u->meta.cgroup_bondings, b);
+ LIST_PREPEND(CGroupBonding, by_unit, u->cgroup_bondings, b);
b->unit = u;
return 0;
@@ -1826,17 +1826,17 @@ static char *default_cgroup_path(Unit *u) {
assert(u);
- if (u->meta.instance) {
+ if (u->instance) {
char *t;
- t = unit_name_template(u->meta.id);
+ t = unit_name_template(u->id);
if (!t)
return NULL;
- p = join(u->meta.manager->cgroup_hierarchy, "/", t, "/", u->meta.instance, NULL);
+ p = join(u->manager->cgroup_hierarchy, "/", t, "/", u->instance, NULL);
free(t);
} else
- p = join(u->meta.manager->cgroup_hierarchy, "/", u->meta.id, NULL);
+ p = join(u->manager->cgroup_hierarchy, "/", u->id, NULL);
return p;
}
@@ -1870,7 +1870,7 @@ int unit_add_cgroup_from_text(Unit *u, const char *name) {
return -ENOMEM;
}
- if (cgroup_bonding_find_list(u->meta.cgroup_bondings, controller)) {
+ if (cgroup_bonding_find_list(u->cgroup_bondings, controller)) {
r = -EEXIST;
goto fail;
}
@@ -1907,7 +1907,7 @@ static int unit_add_one_default_cgroup(Unit *u, const char *controller) {
if (!controller)
controller = SYSTEMD_CGROUP_CONTROLLER;
- if (cgroup_bonding_find_list(u->meta.cgroup_bondings, controller))
+ if (cgroup_bonding_find_list(u->cgroup_bondings, controller))
return 0;
if (!(b = new0(CGroupBonding, 1)))
@@ -1945,16 +1945,16 @@ int unit_add_default_cgroups(Unit *u) {
/* Adds in the default cgroups, if they weren't specified
* otherwise. */
- if (!u->meta.manager->cgroup_hierarchy)
+ if (!u->manager->cgroup_hierarchy)
return 0;
if ((r = unit_add_one_default_cgroup(u, NULL)) < 0)
return r;
- STRV_FOREACH(c, u->meta.manager->default_controllers)
+ STRV_FOREACH(c, u->manager->default_controllers)
unit_add_one_default_cgroup(u, *c);
- LIST_FOREACH(by_unit, a, u->meta.cgroup_attributes)
+ LIST_FOREACH(by_unit, a, u->cgroup_attributes)
unit_add_one_default_cgroup(u, a->controller);
return 0;
@@ -1963,7 +1963,7 @@ int unit_add_default_cgroups(Unit *u) {
CGroupBonding* unit_get_default_cgroup(Unit *u) {
assert(u);
- return cgroup_bonding_find_list(u->meta.cgroup_bondings, SYSTEMD_CGROUP_CONTROLLER);
+ return cgroup_bonding_find_list(u->cgroup_bondings, SYSTEMD_CGROUP_CONTROLLER);
}
int unit_add_cgroup_attribute(Unit *u, const char *controller, const char *name, const char *value, CGroupAttributeMapCallback map_callback) {
@@ -2020,7 +2020,7 @@ int unit_add_cgroup_attribute(Unit *u, const char *controller, const char *name,
a->map_callback = map_callback;
- LIST_PREPEND(CGroupAttribute, by_unit, u->meta.cgroup_attributes, a);
+ LIST_PREPEND(CGroupAttribute, by_unit, u->cgroup_attributes, a);
r = 0;
@@ -2037,12 +2037,12 @@ int unit_load_related_unit(Unit *u, const char *type, Unit **_found) {
assert(type);
assert(_found);
- if (!(t = unit_name_change_suffix(u->meta.id, type)))
+ if (!(t = unit_name_change_suffix(u->id, type)))
return -ENOMEM;
assert(!unit_has_name(u, t));
- r = manager_load_unit(u->meta.manager, t, NULL, NULL, _found);
+ r = manager_load_unit(u->manager, t, NULL, NULL, _found);
free(t);
assert(r < 0 || *_found != u);
@@ -2058,12 +2058,12 @@ int unit_get_related_unit(Unit *u, const char *type, Unit **_found) {
assert(type);
assert(_found);
- if (!(t = unit_name_change_suffix(u->meta.id, type)))
+ if (!(t = unit_name_change_suffix(u->id, type)))
return -ENOMEM;
assert(!unit_has_name(u, t));
- found = manager_get_unit(u->meta.manager, t);
+ found = manager_get_unit(u->manager, t);
free(t);
if (!found)
@@ -2077,14 +2077,14 @@ static char *specifier_prefix_and_instance(char specifier, void *data, void *use
Unit *u = userdata;
assert(u);
- return unit_name_to_prefix_and_instance(u->meta.id);
+ return unit_name_to_prefix_and_instance(u->id);
}
static char *specifier_prefix(char specifier, void *data, void *userdata) {
Unit *u = userdata;
assert(u);
- return unit_name_to_prefix(u->meta.id);
+ return unit_name_to_prefix(u->id);
}
static char *specifier_prefix_unescaped(char specifier, void *data, void *userdata) {
@@ -2093,7 +2093,7 @@ static char *specifier_prefix_unescaped(char specifier, void *data, void *userda
assert(u);
- if (!(p = unit_name_to_prefix(u->meta.id)))
+ if (!(p = unit_name_to_prefix(u->id)))
return NULL;
r = unit_name_unescape(p);
@@ -2106,8 +2106,8 @@ static char *specifier_instance_unescaped(char specifier, void *data, void *user
Unit *u = userdata;
assert(u);
- if (u->meta.instance)
- return unit_name_unescape(u->meta.instance);
+ if (u->instance)
+ return unit_name_unescape(u->instance);
return strdup("");
}
@@ -2116,10 +2116,10 @@ static char *specifier_filename(char specifier, void *data, void *userdata) {
Unit *u = userdata;
assert(u);
- if (u->meta.instance)
- return unit_name_path_unescape(u->meta.instance);
+ if (u->instance)
+ return unit_name_path_unescape(u->instance);
- return unit_name_to_path(u->meta.instance);
+ return unit_name_to_path(u->instance);
}
static char *specifier_cgroup(char specifier, void *data, void *userdata) {
@@ -2135,9 +2135,9 @@ static char *specifier_cgroup_root(char specifier, void *data, void *userdata) {
assert(u);
if (specifier == 'r')
- return strdup(u->meta.manager->cgroup_hierarchy);
+ return strdup(u->manager->cgroup_hierarchy);
- if (parent_of_path(u->meta.manager->cgroup_hierarchy, &p) < 0)
+ if (parent_of_path(u->manager->cgroup_hierarchy, &p) < 0)
return strdup("");
if (streq(p, "/")) {
@@ -2152,7 +2152,7 @@ static char *specifier_runtime(char specifier, void *data, void *userdata) {
Unit *u = userdata;
assert(u);
- if (u->meta.manager->running_as == MANAGER_USER) {
+ if (u->manager->running_as == MANAGER_USER) {
const char *e;
e = getenv("XDG_RUNTIME_DIR");
@@ -2176,10 +2176,10 @@ char *unit_name_printf(Unit *u, const char* format) {
*/
const Specifier table[] = {
- { 'n', specifier_string, u->meta.id },
+ { 'n', specifier_string, u->id },
{ 'N', specifier_prefix_and_instance, NULL },
{ 'p', specifier_prefix, NULL },
- { 'i', specifier_string, u->meta.instance },
+ { 'i', specifier_string, u->instance },
{ 0, NULL, NULL }
};
@@ -2201,11 +2201,11 @@ char *unit_full_printf(Unit *u, const char *format) {
*/
const Specifier table[] = {
- { 'n', specifier_string, u->meta.id },
+ { 'n', specifier_string, u->id },
{ 'N', specifier_prefix_and_instance, NULL },
{ 'p', specifier_prefix, NULL },
{ 'P', specifier_prefix_unescaped, NULL },
- { 'i', specifier_string, u->meta.instance },
+ { 'i', specifier_string, u->instance },
{ 'I', specifier_instance_unescaped, NULL },
{ 'f', specifier_filename, NULL },
{ 'c', specifier_cgroup, NULL },
@@ -2256,14 +2256,14 @@ int unit_watch_bus_name(Unit *u, const char *name) {
/* Watch a specific name on the bus. We only support one unit
* watching each name for now. */
- return hashmap_put(u->meta.manager->watch_bus, name, u);
+ return hashmap_put(u->manager->watch_bus, name, u);
}
void unit_unwatch_bus_name(Unit *u, const char *name) {
assert(u);
assert(name);
- hashmap_remove_value(u->meta.manager->watch_bus, name, u);
+ hashmap_remove_value(u->manager->watch_bus, name, u);
}
bool unit_can_serialize(Unit *u) {
@@ -2285,17 +2285,17 @@ int unit_serialize(Unit *u, FILE *f, FDSet *fds) {
if ((r = UNIT_VTABLE(u)->serialize(u, f, fds)) < 0)
return r;
- if (u->meta.job)
- unit_serialize_item(u, f, "job", job_type_to_string(u->meta.job->type));
+ if (u->job)
+ unit_serialize_item(u, f, "job", job_type_to_string(u->job->type));
- dual_timestamp_serialize(f, "inactive-exit-timestamp", &u->meta.inactive_exit_timestamp);
- dual_timestamp_serialize(f, "active-enter-timestamp", &u->meta.active_enter_timestamp);
- dual_timestamp_serialize(f, "active-exit-timestamp", &u->meta.active_exit_timestamp);
- dual_timestamp_serialize(f, "inactive-enter-timestamp", &u->meta.inactive_enter_timestamp);
- dual_timestamp_serialize(f, "condition-timestamp", &u->meta.condition_timestamp);
+ dual_timestamp_serialize(f, "inactive-exit-timestamp", &u->inactive_exit_timestamp);
+ dual_timestamp_serialize(f, "active-enter-timestamp", &u->active_enter_timestamp);
+ dual_timestamp_serialize(f, "active-exit-timestamp", &u->active_exit_timestamp);
+ dual_timestamp_serialize(f, "inactive-enter-timestamp", &u->inactive_enter_timestamp);
+ dual_timestamp_serialize(f, "condition-timestamp", &u->condition_timestamp);
- if (dual_timestamp_is_set(&u->meta.condition_timestamp))
- unit_serialize_item(u, f, "condition-result", yes_no(u->meta.condition_result));
+ if (dual_timestamp_is_set(&u->condition_timestamp))
+ unit_serialize_item(u, f, "condition-result", yes_no(u->condition_result));
/* End marker */
fputc('\n', f);
@@ -2370,23 +2370,23 @@ int unit_deserialize(Unit *u, FILE *f, FDSet *fds) {
if ((type = job_type_from_string(v)) < 0)
log_debug("Failed to parse job type value %s", v);
else
- u->meta.deserialized_job = type;
+ u->deserialized_job = type;
continue;
} else if (streq(l, "inactive-exit-timestamp")) {
- dual_timestamp_deserialize(v, &u->meta.inactive_exit_timestamp);
+ dual_timestamp_deserialize(v, &u->inactive_exit_timestamp);
continue;
} else if (streq(l, "active-enter-timestamp")) {
- dual_timestamp_deserialize(v, &u->meta.active_enter_timestamp);
+ dual_timestamp_deserialize(v, &u->active_enter_timestamp);
continue;
} else if (streq(l, "active-exit-timestamp")) {
- dual_timestamp_deserialize(v, &u->meta.active_exit_timestamp);
+ dual_timestamp_deserialize(v, &u->active_exit_timestamp);
continue;
} else if (streq(l, "inactive-enter-timestamp")) {
- dual_timestamp_deserialize(v, &u->meta.inactive_enter_timestamp);
+ dual_timestamp_deserialize(v, &u->inactive_enter_timestamp);
continue;
} else if (streq(l, "condition-timestamp")) {
- dual_timestamp_deserialize(v, &u->meta.condition_timestamp);
+ dual_timestamp_deserialize(v, &u->condition_timestamp);
continue;
} else if (streq(l, "condition-result")) {
int b;
@@ -2394,7 +2394,7 @@ int unit_deserialize(Unit *u, FILE *f, FDSet *fds) {
if ((b = parse_boolean(v)) < 0)
log_debug("Failed to parse condition result value %s", v);
else
- u->meta.condition_result = b;
+ u->condition_result = b;
continue;
}
@@ -2422,7 +2422,7 @@ int unit_add_node_link(Unit *u, const char *what, bool wants) {
if (!(e = unit_name_build_escape(what+1, NULL, ".device")))
return -ENOMEM;
- r = manager_load_unit(u->meta.manager, e, NULL, NULL, &device);
+ r = manager_load_unit(u->manager, e, NULL, NULL, &device);
free(e);
if (r < 0)
@@ -2447,11 +2447,11 @@ int unit_coldplug(Unit *u) {
if ((r = UNIT_VTABLE(u)->coldplug(u)) < 0)
return r;
- if (u->meta.deserialized_job >= 0) {
- if ((r = manager_add_job(u->meta.manager, u->meta.deserialized_job, u, JOB_IGNORE_REQUIREMENTS, false, NULL, NULL)) < 0)
+ if (u->deserialized_job >= 0) {
+ if ((r = manager_add_job(u->manager, u->deserialized_job, u, JOB_IGNORE_REQUIREMENTS, false, NULL, NULL)) < 0)
return r;
- u->meta.deserialized_job = _JOB_TYPE_INVALID;
+ u->deserialized_job = _JOB_TYPE_INVALID;
}
return 0;
@@ -2466,10 +2466,10 @@ void unit_status_printf(Unit *u, const char *status, const char *format, ...) {
if (!UNIT_VTABLE(u)->show_status)
return;
- if (!manager_get_show_status(u->meta.manager))
+ if (!manager_get_show_status(u->manager))
return;
- if (!manager_is_booting_or_shutting_down(u->meta.manager))
+ if (!manager_is_booting_or_shutting_down(u->manager))
return;
va_start(ap, format);
@@ -2480,16 +2480,16 @@ void unit_status_printf(Unit *u, const char *status, const char *format, ...) {
bool unit_need_daemon_reload(Unit *u) {
assert(u);
- if (u->meta.fragment_path) {
+ if (u->fragment_path) {
struct stat st;
zero(st);
- if (stat(u->meta.fragment_path, &st) < 0)
+ if (stat(u->fragment_path, &st) < 0)
/* What, cannot access this anymore? */
return true;
- if (u->meta.fragment_mtime > 0 &&
- timespec_load(&st.st_mtim) != u->meta.fragment_mtime)
+ if (u->fragment_mtime > 0 &&
+ timespec_load(&st.st_mtim) != u->fragment_mtime)
return true;
}
@@ -2523,7 +2523,7 @@ bool unit_pending_inactive(Unit *u) {
if (UNIT_IS_INACTIVE_OR_DEACTIVATING(unit_active_state(u)))
return true;
- if (u->meta.job && u->meta.job->type == JOB_STOP)
+ if (u->job && u->job->type == JOB_STOP)
return true;
return false;
@@ -2537,10 +2537,10 @@ bool unit_pending_active(Unit *u) {
if (UNIT_IS_ACTIVE_OR_ACTIVATING(unit_active_state(u)))
return true;
- if (u->meta.job &&
- (u->meta.job->type == JOB_START ||
- u->meta.job->type == JOB_RELOAD_OR_START ||
- u->meta.job->type == JOB_RESTART))
+ if (u->job &&
+ (u->job->type == JOB_START ||
+ u->job->type == JOB_RELOAD_OR_START ||
+ u->job->type == JOB_RESTART))
return true;
return false;
@@ -2598,12 +2598,12 @@ int unit_following_set(Unit *u, Set **s) {
UnitFileState unit_get_unit_file_state(Unit *u) {
assert(u);
- if (u->meta.unit_file_state < 0 && u->meta.fragment_path)
- u->meta.unit_file_state = unit_file_get_state(
- u->meta.manager->running_as == MANAGER_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER,
- NULL, file_name_from_path(u->meta.fragment_path));
+ if (u->unit_file_state < 0 && u->fragment_path)
+ u->unit_file_state = unit_file_get_state(
+ u->manager->running_as == MANAGER_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER,
+ NULL, file_name_from_path(u->fragment_path));
- return u->meta.unit_file_state;
+ return u->unit_file_state;
}
Unit* unit_ref_set(UnitRef *ref, Unit *u) {
@@ -2614,7 +2614,7 @@ Unit* unit_ref_set(UnitRef *ref, Unit *u) {
unit_ref_unset(ref);
ref->unit = u;
- LIST_PREPEND(UnitRef, refs, u->meta.refs, ref);
+ LIST_PREPEND(UnitRef, refs, u->refs, ref);
return u;
}
@@ -2624,7 +2624,7 @@ void unit_ref_unset(UnitRef *ref) {
if (!ref->unit)
return;
- LIST_REMOVE(UnitRef, refs, ref->unit->meta.refs, ref);
+ LIST_REMOVE(UnitRef, refs, ref->unit->refs, ref);
ref->unit = NULL;
}
diff --git a/src/unit.h b/src/unit.h
index 626bdc4..756f465 100644
--- a/src/unit.h
+++ b/src/unit.h
@@ -25,8 +25,7 @@
#include <stdbool.h>
#include <stdlib.h>
-typedef union Unit Unit;
-typedef struct Meta Meta;
+typedef struct Unit Unit;
typedef struct UnitVTable UnitVTable;
typedef enum UnitType UnitType;
typedef enum UnitLoadState UnitLoadState;
@@ -141,7 +140,7 @@ enum UnitDependency {
#include "cgroup.h"
#include "cgroup-attr.h"
-struct Meta {
+struct Unit {
Manager *manager;
UnitType type;
@@ -183,19 +182,19 @@ struct Meta {
CGroupAttribute *cgroup_attributes;
/* Per type list */
- LIST_FIELDS(Meta, units_by_type);
+ LIST_FIELDS(Unit, units_by_type);
/* Load queue */
- LIST_FIELDS(Meta, load_queue);
+ LIST_FIELDS(Unit, load_queue);
/* D-Bus queue */
- LIST_FIELDS(Meta, dbus_queue);
+ LIST_FIELDS(Unit, dbus_queue);
/* Cleanup queue */
- LIST_FIELDS(Meta, cleanup_queue);
+ LIST_FIELDS(Unit, cleanup_queue);
/* GC queue */
- LIST_FIELDS(Meta, gc_queue);
+ LIST_FIELDS(Unit, gc_queue);
/* Used during GC sweeps */
unsigned gc_marker;
@@ -269,20 +268,6 @@ struct UnitRef {
#include "swap.h"
#include "path.h"
-union Unit {
- Meta meta;
- Service service;
- Timer timer;
- Socket socket;
- Target target;
- Device device;
- Mount mount;
- Automount automount;
- Snapshot snapshot;
- Swap swap;
- Path path;
-};
-
struct UnitVTable {
const char *suffix;
@@ -413,19 +398,19 @@ struct UnitVTable {
extern const UnitVTable * const unit_vtable[_UNIT_TYPE_MAX];
-#define UNIT_VTABLE(u) unit_vtable[(u)->meta.type]
+#define UNIT_VTABLE(u) unit_vtable[(u)->type]
/* For casting a unit into the various unit types */
#define DEFINE_CAST(UPPERCASE, MixedCase) \
static inline MixedCase* UPPERCASE(Unit *u) { \
- if (_unlikely_(!u || u->meta.type != UNIT_##UPPERCASE)) \
+ if (_unlikely_(!u || u->type != UNIT_##UPPERCASE)) \
return NULL; \
\
return (MixedCase*) u; \
}
/* For casting the various unit types into a unit */
-#define UNIT(u) ((Unit*) (&(u)->meta))
+#define UNIT(u) (&(u)->meta)
DEFINE_CAST(SOCKET, Socket);
DEFINE_CAST(TIMER, Timer);
commit 7d17cfbc46306a106dbda0f3e92fbc0792d1e9e9
Author: Michal Schmidt <mschmidt at redhat.com>
Date: Sun Jan 15 10:53:49 2012 +0100
unit: reduce heap usage for unit objects
The storage of the unit objects on the heap is currently not very
efficient. For every unit object we allocate a chunk of memory as large
as the biggest unit type, although there are significant differences in
the units' real requirements.
pahole shows the following sizes of structs:
488 Target
496 Snapshot
512 Device
528 Path
560 Timer
576 Automount
1080 Socket
1160 Swap
1168 Service
1280 Mount
Usually there aren't many targets or snapshots in the system, but Device
is one of the most common unit types and for every one we waste
1280 - 512 = 768 bytes.
Fix it by allocating only the right amount for the given unit type.
On my machine (x86_64, with 39 LVM volumes) this decreases systemd's
USS (unique set size) by more than 300 KB.
diff --git a/src/automount.c b/src/automount.c
index b70f8b4..c4191f6 100644
--- a/src/automount.c
+++ b/src/automount.c
@@ -836,6 +836,7 @@ DEFINE_STRING_TABLE_LOOKUP(automount_state, AutomountState);
const UnitVTable automount_vtable = {
.suffix = ".automount",
+ .object_size = sizeof(Automount),
.sections =
"Unit\0"
"Automount\0"
diff --git a/src/device.c b/src/device.c
index bffeca0..64665a8 100644
--- a/src/device.c
+++ b/src/device.c
@@ -198,10 +198,12 @@ static int device_update_unit(Manager *m, struct udev_device *dev, const char *p
if (!u) {
delete = true;
- if (!(u = unit_new(m)))
+ u = unit_new(m, sizeof(Device));
+ if (!u)
return -ENOMEM;
- if ((r = device_add_escaped_name(u, path)) < 0)
+ r = device_add_escaped_name(u, path);
+ if (r < 0)
goto fail;
unit_add_to_load_queue(u);
@@ -583,6 +585,7 @@ DEFINE_STRING_TABLE_LOOKUP(device_state, DeviceState);
const UnitVTable device_vtable = {
.suffix = ".device",
+ .object_size = sizeof(Device),
.sections =
"Unit\0"
"Device\0"
diff --git a/src/manager.c b/src/manager.c
index a549209..6831973 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -1795,6 +1795,7 @@ unsigned manager_dispatch_load_queue(Manager *m) {
int manager_load_unit_prepare(Manager *m, const char *name, const char *path, DBusError *e, Unit **_ret) {
Unit *ret;
+ UnitType t;
int r;
assert(m);
@@ -1811,24 +1812,30 @@ int manager_load_unit_prepare(Manager *m, const char *name, const char *path, DB
if (!name)
name = file_name_from_path(path);
- if (!unit_name_is_valid(name, false)) {
+ t = unit_name_to_type(name);
+
+ if (t == _UNIT_TYPE_INVALID || !unit_name_is_valid_no_type(name, false)) {
dbus_set_error(e, BUS_ERROR_INVALID_NAME, "Unit name %s is not valid.", name);
return -EINVAL;
}
- if ((ret = manager_get_unit(m, name))) {
+ ret = manager_get_unit(m, name);
+ if (ret) {
*_ret = ret;
return 1;
}
- if (!(ret = unit_new(m)))
+ ret = unit_new(m, unit_vtable[t]->object_size);
+ if (!ret)
return -ENOMEM;
- if (path)
- if (!(ret->meta.fragment_path = strdup(path))) {
+ if (path) {
+ ret->meta.fragment_path = strdup(path);
+ if (!ret->meta.fragment_path) {
unit_free(ret);
return -ENOMEM;
}
+ }
if ((r = unit_add_name(ret, name)) < 0) {
unit_free(ret);
diff --git a/src/mount.c b/src/mount.c
index 12c0710..f94c0eb 100644
--- a/src/mount.c
+++ b/src/mount.c
@@ -1395,13 +1395,16 @@ static int mount_add_one(
if (!is_path(where))
return 0;
- if (!(e = unit_name_from_path(where, ".mount")))
+ e = unit_name_from_path(where, ".mount");
+ if (!e)
return -ENOMEM;
- if (!(u = manager_get_unit(m, e))) {
+ u = manager_get_unit(m, e);
+ if (!u) {
delete = true;
- if (!(u = unit_new(m))) {
+ u = unit_new(m, sizeof(Mount));
+ if (!u) {
free(e);
return -ENOMEM;
}
@@ -1412,7 +1415,8 @@ static int mount_add_one(
if (r < 0)
goto fail;
- if (!(MOUNT(u)->where = strdup(where))) {
+ MOUNT(u)->where = strdup(where);
+ if (!MOUNT(u)->where) {
r = -ENOMEM;
goto fail;
}
@@ -1837,6 +1841,7 @@ DEFINE_STRING_TABLE_LOOKUP(mount_exec_command, MountExecCommand);
const UnitVTable mount_vtable = {
.suffix = ".mount",
+ .object_size = sizeof(Mount),
.sections =
"Unit\0"
"Mount\0"
diff --git a/src/path.c b/src/path.c
index 957af05..ae5052a 100644
--- a/src/path.c
+++ b/src/path.c
@@ -717,6 +717,7 @@ DEFINE_STRING_TABLE_LOOKUP(path_type, PathType);
const UnitVTable path_vtable = {
.suffix = ".path",
+ .object_size = sizeof(Path),
.sections =
"Unit\0"
"Path\0"
diff --git a/src/service.c b/src/service.c
index 113be34..6ce6b19 100644
--- a/src/service.c
+++ b/src/service.c
@@ -3553,6 +3553,7 @@ DEFINE_STRING_TABLE_LOOKUP(notify_access, NotifyAccess);
const UnitVTable service_vtable = {
.suffix = ".service",
+ .object_size = sizeof(Service),
.sections =
"Unit\0"
"Service\0"
diff --git a/src/snapshot.c b/src/snapshot.c
index 270dc4f..161629d 100644
--- a/src/snapshot.c
+++ b/src/snapshot.c
@@ -282,6 +282,7 @@ DEFINE_STRING_TABLE_LOOKUP(snapshot_state, SnapshotState);
const UnitVTable snapshot_vtable = {
.suffix = ".snapshot",
+ .object_size = sizeof(Snapshot),
.no_alias = true,
.no_instances = true,
diff --git a/src/socket.c b/src/socket.c
index 7034436..1a245aa 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -2114,6 +2114,7 @@ DEFINE_STRING_TABLE_LOOKUP(socket_exec_command, SocketExecCommand);
const UnitVTable socket_vtable = {
.suffix = ".socket",
+ .object_size = sizeof(Socket),
.sections =
"Unit\0"
"Socket\0"
diff --git a/src/swap.c b/src/swap.c
index 4fa30a3..202c4e6 100644
--- a/src/swap.c
+++ b/src/swap.c
@@ -334,7 +334,8 @@ int swap_add_one(
assert(m);
assert(what);
- if (!(e = unit_name_from_path(what, ".swap")))
+ e = unit_name_from_path(what, ".swap");
+ if (!e)
return -ENOMEM;
u = manager_get_unit(m, e);
@@ -348,15 +349,18 @@ int swap_add_one(
if (!u) {
delete = true;
- if (!(u = unit_new(m))) {
+ u = unit_new(m, sizeof(Swap));
+ if (!u) {
free(e);
return -ENOMEM;
}
- if ((r = unit_add_name(u, e)) < 0)
+ r = unit_add_name(u, e);
+ if (r < 0)
goto fail;
- if (!(SWAP(u)->what = strdup(what))) {
+ SWAP(u)->what = strdup(what);
+ if (!SWAP(u)->what) {
r = -ENOMEM;
goto fail;
}
@@ -1341,6 +1345,7 @@ DEFINE_STRING_TABLE_LOOKUP(swap_exec_command, SwapExecCommand);
const UnitVTable swap_vtable = {
.suffix = ".swap",
+ .object_size = sizeof(Swap),
.sections =
"Unit\0"
"Swap\0"
diff --git a/src/target.c b/src/target.c
index 340e990..b774cfb 100644
--- a/src/target.c
+++ b/src/target.c
@@ -199,6 +199,7 @@ DEFINE_STRING_TABLE_LOOKUP(target_state, TargetState);
const UnitVTable target_vtable = {
.suffix = ".target",
+ .object_size = sizeof(Target),
.sections =
"Unit\0"
"Target\0"
diff --git a/src/timer.c b/src/timer.c
index d127a11..87adb29 100644
--- a/src/timer.c
+++ b/src/timer.c
@@ -468,6 +468,7 @@ DEFINE_STRING_TABLE_LOOKUP(timer_base, TimerBase);
const UnitVTable timer_vtable = {
.suffix = ".timer",
+ .object_size = sizeof(Timer),
.sections =
"Unit\0"
"Timer\0"
diff --git a/src/unit.c b/src/unit.c
index 1fbfb1d..fa3c264 100644
--- a/src/unit.c
+++ b/src/unit.c
@@ -57,15 +57,18 @@ const UnitVTable * const unit_vtable[_UNIT_TYPE_MAX] = {
[UNIT_PATH] = &path_vtable
};
-Unit *unit_new(Manager *m) {
+Unit *unit_new(Manager *m, size_t size) {
Unit *u;
assert(m);
+ assert(size >= sizeof(Meta));
- if (!(u = new0(Unit, 1)))
+ u = malloc0(size);
+ if (!u)
return NULL;
- if (!(u->meta.names = set_new(string_hash_func, string_compare_func))) {
+ u->meta.names = set_new(string_hash_func, string_compare_func);
+ if (!u->meta.names) {
free(u);
return NULL;
}
diff --git a/src/unit.h b/src/unit.h
index 19314d6..626bdc4 100644
--- a/src/unit.h
+++ b/src/unit.h
@@ -286,6 +286,9 @@ union Unit {
struct UnitVTable {
const char *suffix;
+ /* How much memory does an object of this unit type need */
+ size_t object_size;
+
/* Config file sections this unit type understands, separated
* by NUL chars */
const char *sections;
@@ -435,7 +438,7 @@ DEFINE_CAST(SNAPSHOT, Snapshot);
DEFINE_CAST(SWAP, Swap);
DEFINE_CAST(PATH, Path);
-Unit *unit_new(Manager *m);
+Unit *unit_new(Manager *m, size_t size);
void unit_free(Unit *u);
int unit_add_name(Unit *u, const char *name);
More information about the systemd-commits
mailing list