#include "shared/log.h"
-#define SYSTEMD_DBUS_SERVICE "org.freedesktop.systemd1"
+#define SYSTEMD_DBUS_SERVICE "org.freedesktop.systemd1"
#define SYSTEMD_DBUS_PATH "/org/freedesktop/systemd1"
-#define SYSTEMD_DBUS_UNIT_PATH "/org/freedesktop/systemd1/unit/"
+#define SYSTEMD_DBUS_UNIT_PATH "/org/freedesktop/systemd1/unit/"
#define SYSTEMD_DBUS_MANAGER_IFACE "org.freedesktop.systemd1.Manager"
#define SYSTEMD_DBUS_UNIT_IFACE "org.freedesktop.systemd1.Unit"
#define DBUS_IFACE_DBUS_PROPERTIES "org.freedesktop.DBus.Properties"
-#define SUFFIX_SERVICE ".service"
-#define SUFFIX_SOCKET ".socket"
-#define SUFFIX_BUSNAME ".busname"
-#define SUFFIX_TARGET ".target"
-#define SUFFIX_DEVICE ".device"
-#define SUFFIX_MOUNT ".mount"
-#define SUFFIX_SWAP ".swap"
-#define SUFFIX_TIMER ".timer"
-#define SUFFIX_PATH ".path"
-#define SUFFIX_SLICE ".slice"
-#define SUFFIX_SCOPE ".scope"
+#define SUFFIX_SERVICE ".service"
+#define SUFFIX_SOCKET ".socket"
+#define SUFFIX_BUSNAME ".busname"
+#define SUFFIX_TARGET ".target"
+#define SUFFIX_DEVICE ".device"
+#define SUFFIX_MOUNT ".mount"
+#define SUFFIX_SWAP ".swap"
+#define SUFFIX_TIMER ".timer"
+#define SUFFIX_PATH ".path"
+#define SUFFIX_SLICE ".slice"
+#define SUFFIX_SCOPE ".scope"
#define UNIT_NAME_MAX 256
} unitinfo;
static void _cb_JobRemoved(GDBusConnection *conn,
- const char *sender,
- const char *path,
- const char *iface,
- const char *name,
- GVariant *param,
- gpointer data)
+ const char *sender,
+ const char *path,
+ const char *iface,
+ const char *name,
+ GVariant *param,
+ gpointer data)
{
sig_ctx *ctx = data;
gchar *job_id = NULL;
g_free(unit_name);
}
-static int _systemd_control_unit_wait(const char *method, const char *name, int timeout_msec)
+static int _systemd_control_unit_wait(const char *method,
+ const char *name,
+ int timeout_msec)
{
GVariant *reply = NULL;
gchar *objpath = NULL;
_I("Starting: %s %s", method, name);
/* synchronous signal subscription */
- ret = subscribe_dbus_signal_ctx(NULL, ctx, SYSTEMD_DBUS_SERVICE, SYSTEMD_DBUS_PATH, SYSTEMD_DBUS_IFACE_MANAGER, "JobRemoved", _cb_JobRemoved);
+ ret = subscribe_dbus_signal_ctx(NULL,
+ ctx,
+ SYSTEMD_DBUS_SERVICE,
+ SYSTEMD_DBUS_PATH,
+ SYSTEMD_DBUS_IFACE_MANAGER,
+ "JobRemoved",
+ _cb_JobRemoved);
if (ret == 0) {
ret = -1;
goto finish;
}
reply = dbus_handle_method_sync_with_reply_var(SYSTEMD_DBUS_DEST,
- SYSTEMD_DBUS_PATH,
- SYSTEMD_DBUS_MANAGER_IFACE,
- method,
- g_variant_new("(ss)", name, "replace"));
+ SYSTEMD_DBUS_PATH,
+ SYSTEMD_DBUS_MANAGER_IFACE,
+ method,
+ g_variant_new("(ss)", name, "replace"));
if (!reply || !dh_get_param_from_var(reply, "(o)", &objpath)) {
_E("fail (%s): no message", method);
ret = -EBADMSG;
_I("Starting: %s %s", method, name);
reply = dbus_handle_method_sync_with_reply_var(SYSTEMD_DBUS_DEST,
- SYSTEMD_DBUS_PATH,
- SYSTEMD_DBUS_MANAGER_IFACE,
- method,
- g_variant_new("(ss)", name, "replace"));
+ SYSTEMD_DBUS_PATH,
+ SYSTEMD_DBUS_MANAGER_IFACE,
+ method,
+ g_variant_new("(ss)", name, "replace"));
if (!reply || !dh_get_param_from_var(reply, "(o)", &objpath)) {
_E("fail (%s): no message", method);
return ret;
}
-static int _change_suffix(const char *name, const char *suffix, char **new_name)
+static int _change_suffix(const char *name,
+ const char *suffix,
+ char **new_name)
{
char *buf = NULL;
char *ext = NULL;
@param suffix: (nullable): change extension of unit name, or %NULL
@param timeout_msec: the timeout in milliseconds, -1 to use the default
@param method: method name, "StartUnit" or "StopUnit"
-@param sync: %TRUE
+@param wait: %TRUE
Returns: the exit status
*/
-static int _systemd_control_unit(const char *name, const char *suffix,
- int timeout_msec, const char *method, int wait)
+static int _systemd_control_unit(const char *name,
+ const char *suffix,
+ int timeout_msec,
+ const char *method,
+ int wait)
{
char *new_name = NULL;
int ret = 0;
return NULL;
reply = dbus_handle_method_sync_with_reply_var(SYSTEMD_DBUS_DEST,
- SYSTEMD_DBUS_PATH,
- DBUS_IFACE_DBUS_PROPERTIES,
- "Get",
- g_variant_new("(ss)", SYSTEMD_DBUS_MANAGER_IFACE, property));
+ SYSTEMD_DBUS_PATH,
+ DBUS_IFACE_DBUS_PROPERTIES,
+ "Get",
+ g_variant_new("(ss)", SYSTEMD_DBUS_MANAGER_IFACE, property));
if (!reply || !dh_get_param_from_var(reply, "(v)", &val))
_E("Failed to get variant");
if (reply)
return val;
}
-GVariant *systemd_get_unit_property(const char *unit,
- const char *property)
+GVariant *systemd_get_unit_property(const char *unit, const char *property)
{
char *escaped;
GVariant *reply = NULL;
escaped = systemd_get_unit_dbus_path(unit);
reply = dbus_handle_method_sync_with_reply_var(SYSTEMD_DBUS_DEST,
- escaped,
- DBUS_IFACE_DBUS_PROPERTIES,
- "Get",
- g_variant_new("(ss)", SYSTEMD_DBUS_UNIT_IFACE, property));
+ escaped,
+ DBUS_IFACE_DBUS_PROPERTIES,
+ "Get",
+ g_variant_new("(ss)", SYSTEMD_DBUS_UNIT_IFACE, property));
if (!reply || !dh_get_param_from_var(reply, "(v)", &val))
_E("Failed to get variant");
return val;
}
-GVariant *systemd_get_service_property(const char *unit,
- const char *property)
+GVariant *systemd_get_service_property(const char *unit, const char *property)
{
char *escaped;
GVariant *reply = NULL;
escaped = systemd_get_unit_dbus_path(unit);
reply = dbus_handle_method_sync_with_reply_var(SYSTEMD_DBUS_DEST,
- escaped,
- DBUS_IFACE_DBUS_PROPERTIES,
- "Get",
- g_variant_new("(ss)", SYSTEMD_DBUS_SERVICE_IFACE, property));
+ escaped,
+ DBUS_IFACE_DBUS_PROPERTIES,
+ "Get",
+ g_variant_new("(ss)", SYSTEMD_DBUS_SERVICE_IFACE, property));
if (!reply || !dh_get_param_from_var(reply, "(v)", &val))
_E("Failed to get variant");
if (reply)