Commit ac155bb8 authored by Michal Schmidt's avatar Michal Schmidt
Browse files

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.
parent 7d17cfbc
......@@ -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;
......
......@@ -36,7 +36,7 @@ typedef enum AutomountState {
} AutomountState;
struct Automount {
Meta meta;
Unit meta;
AutomountState state, deserialized_state;
......
......@@ -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);
......
......@@ -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 }
};
......
......@@ -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 }
};
......
......@@ -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;
......
......@@ -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);
}
......
......@@ -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 }
};
......
......@@ -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 }
};
......
......@@ -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 }
};
......
......@@ -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 }
};
......
......@@ -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 }
};
......
......@@ -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 }
};
......
......@@ -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 }
};
......
......@@ -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) {