Compare commits
12 Commits
5c236388c3
...
9457b6bb21
Author | SHA1 | Date |
---|---|---|
Yu Watanabe | 9457b6bb21 | |
Marc Kleine-Budde | b46d8c1c70 | |
Zbigniew Jędrzejewski-Szmek | d17eabb105 | |
Yu Watanabe | 116739cfb6 | |
Yu Watanabe | 437b9a7f75 | |
Yu Watanabe | daa227a320 | |
Yu Watanabe | 74f1bb5c9f | |
Lennart Poettering | 40af3d020f | |
Lennart Poettering | 9176326ba2 | |
Lennart Poettering | 807542bece | |
Lennart Poettering | 9b71e4ab90 | |
Lennart Poettering | c664cf5607 |
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include "analyze-security.h"
|
#include "analyze-security.h"
|
||||||
#include "bus-error.h"
|
#include "bus-error.h"
|
||||||
|
#include "bus-map-properties.h"
|
||||||
#include "bus-unit-util.h"
|
#include "bus-unit-util.h"
|
||||||
#include "bus-util.h"
|
#include "bus-util.h"
|
||||||
#include "env-util.h"
|
#include "env-util.h"
|
||||||
|
|
|
@ -17,8 +17,9 @@
|
||||||
#include "analyze-verify.h"
|
#include "analyze-verify.h"
|
||||||
#include "build.h"
|
#include "build.h"
|
||||||
#include "bus-error.h"
|
#include "bus-error.h"
|
||||||
|
#include "bus-locator.h"
|
||||||
|
#include "bus-map-properties.h"
|
||||||
#include "bus-unit-util.h"
|
#include "bus-unit-util.h"
|
||||||
#include "bus-util.h"
|
|
||||||
#include "calendarspec.h"
|
#include "calendarspec.h"
|
||||||
#include "conf-files.h"
|
#include "conf-files.h"
|
||||||
#include "copy.h"
|
#include "copy.h"
|
||||||
|
|
|
@ -224,10 +224,8 @@ static int get_max_brightness(sd_device *device, unsigned *ret) {
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_device_warning_errno(device, r, "Failed to parse 'max_brightness' \"%s\": %m", max_brightness_str);
|
return log_device_warning_errno(device, r, "Failed to parse 'max_brightness' \"%s\": %m", max_brightness_str);
|
||||||
|
|
||||||
if (max_brightness <= 0) {
|
if (max_brightness <= 0)
|
||||||
log_device_warning(device, "Maximum brightness is 0, ignoring device.");
|
return log_device_warning_errno(device, SYNTHETIC_ERRNO(EINVAL), "Maximum brightness is 0, ignoring device.");
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
*ret = max_brightness;
|
*ret = max_brightness;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -299,6 +297,34 @@ static bool shall_clamp(sd_device *d) {
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int read_brightness(sd_device *device, const char **ret) {
|
||||||
|
const char *subsystem;
|
||||||
|
int r;
|
||||||
|
|
||||||
|
assert(device);
|
||||||
|
assert(ret);
|
||||||
|
|
||||||
|
r = sd_device_get_subsystem(device, &subsystem);
|
||||||
|
if (r < 0)
|
||||||
|
return log_device_debug_errno(device, r, "Failed to get subsystem: %m");
|
||||||
|
|
||||||
|
if (streq(subsystem, "backlight")) {
|
||||||
|
r = sd_device_get_sysattr_value(device, "actual_brightness", ret);
|
||||||
|
if (r >= 0)
|
||||||
|
return 0;
|
||||||
|
if (r != -ENOENT)
|
||||||
|
return log_device_debug_errno(device, r, "Failed to read 'actual_brightness' attribute: %m");
|
||||||
|
|
||||||
|
log_device_debug_errno(device, r, "Failed to read 'actual_brightness' attribute, fall back to use 'brightness' attribute: %m");
|
||||||
|
}
|
||||||
|
|
||||||
|
r = sd_device_get_sysattr_value(device, "brightness", ret);
|
||||||
|
if (r < 0)
|
||||||
|
return log_device_debug_errno(device, r, "Failed to read 'brightness' attribute: %m");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int run(int argc, char *argv[]) {
|
static int run(int argc, char *argv[]) {
|
||||||
_cleanup_(sd_device_unrefp) sd_device *device = NULL;
|
_cleanup_(sd_device_unrefp) sd_device *device = NULL;
|
||||||
_cleanup_free_ char *escaped_ss = NULL, *escaped_sysname = NULL, *escaped_path_id = NULL;
|
_cleanup_free_ char *escaped_ss = NULL, *escaped_sysname = NULL, *escaped_path_id = NULL;
|
||||||
|
@ -306,13 +332,11 @@ static int run(int argc, char *argv[]) {
|
||||||
unsigned max_brightness;
|
unsigned max_brightness;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
if (argc != 3) {
|
|
||||||
log_error("This program requires two arguments.");
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
log_setup_service();
|
log_setup_service();
|
||||||
|
|
||||||
|
if (argc != 3)
|
||||||
|
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "This program requires two arguments.");
|
||||||
|
|
||||||
umask(0022);
|
umask(0022);
|
||||||
|
|
||||||
r = mkdir_p("/var/lib/systemd/backlight", 0755);
|
r = mkdir_p("/var/lib/systemd/backlight", 0755);
|
||||||
|
@ -320,19 +344,15 @@ static int run(int argc, char *argv[]) {
|
||||||
return log_error_errno(r, "Failed to create backlight directory /var/lib/systemd/backlight: %m");
|
return log_error_errno(r, "Failed to create backlight directory /var/lib/systemd/backlight: %m");
|
||||||
|
|
||||||
sysname = strchr(argv[2], ':');
|
sysname = strchr(argv[2], ':');
|
||||||
if (!sysname) {
|
if (!sysname)
|
||||||
log_error("Requires a subsystem and sysname pair specifying a backlight device.");
|
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Requires a subsystem and sysname pair specifying a backlight device.");
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ss = strndupa(argv[2], sysname - argv[2]);
|
ss = strndupa(argv[2], sysname - argv[2]);
|
||||||
|
|
||||||
sysname++;
|
sysname++;
|
||||||
|
|
||||||
if (!STR_IN_SET(ss, "backlight", "leds")) {
|
if (!STR_IN_SET(ss, "backlight", "leds"))
|
||||||
log_error("Not a backlight or LED device: '%s:%s'", ss, sysname);
|
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Not a backlight or LED device: '%s:%s'", ss, sysname);
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
r = sd_device_new_from_subsystem_sysname(&device, ss, sysname);
|
r = sd_device_new_from_subsystem_sysname(&device, ss, sysname);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
|
@ -391,9 +411,9 @@ static int run(int argc, char *argv[]) {
|
||||||
if (!clamp)
|
if (!clamp)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
r = sd_device_get_sysattr_value(device, "brightness", &curval);
|
r = read_brightness(device, &curval);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_device_warning_errno(device, r, "Failed to read 'brightness' attribute: %m");
|
return log_device_error_errno(device, r, "Failed to read current brightness: %m");
|
||||||
|
|
||||||
value = strdup(curval);
|
value = strdup(curval);
|
||||||
if (!value)
|
if (!value)
|
||||||
|
@ -416,18 +436,16 @@ static int run(int argc, char *argv[]) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = sd_device_get_sysattr_value(device, "brightness", &value);
|
r = read_brightness(device, &value);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_device_error_errno(device, r, "Failed to read system 'brightness' attribute: %m");
|
return log_device_error_errno(device, r, "Failed to read current brightness: %m");
|
||||||
|
|
||||||
r = write_string_file(saved, value, WRITE_STRING_FILE_CREATE);
|
r = write_string_file(saved, value, WRITE_STRING_FILE_CREATE);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_device_error_errno(device, r, "Failed to write %s: %m", saved);
|
return log_device_error_errno(device, r, "Failed to write %s: %m", saved);
|
||||||
|
|
||||||
} else {
|
} else
|
||||||
log_error("Unknown verb %s.", argv[1]);
|
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Unknown verb %s.", argv[1]);
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||||
|
|
||||||
#include "automount.h"
|
#include "automount.h"
|
||||||
#include "bus-util.h"
|
#include "bus-get-properties.h"
|
||||||
#include "dbus-automount.h"
|
#include "dbus-automount.h"
|
||||||
#include "dbus-util.h"
|
#include "dbus-util.h"
|
||||||
#include "string-util.h"
|
#include "string-util.h"
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include "af-list.h"
|
#include "af-list.h"
|
||||||
#include "alloc-util.h"
|
#include "alloc-util.h"
|
||||||
#include "bpf-firewall.h"
|
#include "bpf-firewall.h"
|
||||||
#include "bus-util.h"
|
#include "bus-get-properties.h"
|
||||||
#include "cgroup-util.h"
|
#include "cgroup-util.h"
|
||||||
#include "cgroup.h"
|
#include "cgroup.h"
|
||||||
#include "dbus-cgroup.h"
|
#include "dbus-cgroup.h"
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
#include "af-list.h"
|
#include "af-list.h"
|
||||||
#include "alloc-util.h"
|
#include "alloc-util.h"
|
||||||
#include "bus-util.h"
|
#include "bus-get-properties.h"
|
||||||
#include "cap-list.h"
|
#include "cap-list.h"
|
||||||
#include "capability-util.h"
|
#include "capability-util.h"
|
||||||
#include "cpu-set-util.h"
|
#include "cpu-set-util.h"
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "sd-bus.h"
|
#include "sd-bus.h"
|
||||||
|
|
||||||
#include "alloc-util.h"
|
#include "alloc-util.h"
|
||||||
|
#include "bus-get-properties.h"
|
||||||
#include "bus-util.h"
|
#include "bus-util.h"
|
||||||
#include "dbus-job.h"
|
#include "dbus-job.h"
|
||||||
#include "dbus-unit.h"
|
#include "dbus-unit.h"
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "sd-bus.h"
|
#include "sd-bus.h"
|
||||||
|
|
||||||
#include "unit.h"
|
#include "unit.h"
|
||||||
#include "bus-util.h"
|
#include "bus-object.h"
|
||||||
|
|
||||||
extern const sd_bus_vtable bus_job_vtable[];
|
extern const sd_bus_vtable bus_job_vtable[];
|
||||||
extern const BusObjectImplementation job_object;
|
extern const BusObjectImplementation job_object;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||||
|
|
||||||
#include "bus-util.h"
|
#include "bus-get-properties.h"
|
||||||
#include "dbus-kill.h"
|
#include "dbus-kill.h"
|
||||||
#include "dbus-util.h"
|
#include "dbus-util.h"
|
||||||
#include "kill.h"
|
#include "kill.h"
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
#include "architecture.h"
|
#include "architecture.h"
|
||||||
#include "build.h"
|
#include "build.h"
|
||||||
#include "bus-common-errors.h"
|
#include "bus-common-errors.h"
|
||||||
|
#include "bus-get-properties.h"
|
||||||
#include "bus-log-control-api.h"
|
#include "bus-log-control-api.h"
|
||||||
#include "bus-util.h"
|
|
||||||
#include "dbus-cgroup.h"
|
#include "dbus-cgroup.h"
|
||||||
#include "dbus-execute.h"
|
#include "dbus-execute.h"
|
||||||
#include "dbus-job.h"
|
#include "dbus-job.h"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||||
|
|
||||||
#include "bus-util.h"
|
#include "bus-get-properties.h"
|
||||||
#include "dbus-cgroup.h"
|
#include "dbus-cgroup.h"
|
||||||
#include "dbus-execute.h"
|
#include "dbus-execute.h"
|
||||||
#include "dbus-kill.h"
|
#include "dbus-kill.h"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||||
|
|
||||||
#include "alloc-util.h"
|
#include "alloc-util.h"
|
||||||
#include "bus-util.h"
|
#include "bus-get-properties.h"
|
||||||
#include "dbus-path.h"
|
#include "dbus-path.h"
|
||||||
#include "dbus-util.h"
|
#include "dbus-util.h"
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#include "alloc-util.h"
|
#include "alloc-util.h"
|
||||||
#include "bus-common-errors.h"
|
#include "bus-common-errors.h"
|
||||||
#include "bus-util.h"
|
#include "bus-get-properties.h"
|
||||||
#include "dbus-cgroup.h"
|
#include "dbus-cgroup.h"
|
||||||
#include "dbus-kill.h"
|
#include "dbus-kill.h"
|
||||||
#include "dbus-scope.h"
|
#include "dbus-scope.h"
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
#include "alloc-util.h"
|
#include "alloc-util.h"
|
||||||
#include "async.h"
|
#include "async.h"
|
||||||
#include "bus-util.h"
|
#include "bus-get-properties.h"
|
||||||
#include "dbus-cgroup.h"
|
#include "dbus-cgroup.h"
|
||||||
#include "dbus-execute.h"
|
#include "dbus-execute.h"
|
||||||
#include "dbus-kill.h"
|
#include "dbus-kill.h"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||||
|
|
||||||
#include "alloc-util.h"
|
#include "alloc-util.h"
|
||||||
#include "bus-util.h"
|
#include "bus-get-properties.h"
|
||||||
#include "dbus-cgroup.h"
|
#include "dbus-cgroup.h"
|
||||||
#include "dbus-execute.h"
|
#include "dbus-execute.h"
|
||||||
#include "dbus-kill.h"
|
#include "dbus-kill.h"
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
Copyright © 2010 Maarten Lankhorst
|
Copyright © 2010 Maarten Lankhorst
|
||||||
***/
|
***/
|
||||||
|
|
||||||
#include "bus-util.h"
|
#include "bus-get-properties.h"
|
||||||
#include "dbus-cgroup.h"
|
#include "dbus-cgroup.h"
|
||||||
#include "dbus-execute.h"
|
#include "dbus-execute.h"
|
||||||
#include "dbus-swap.h"
|
#include "dbus-swap.h"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||||
|
|
||||||
#include "alloc-util.h"
|
#include "alloc-util.h"
|
||||||
#include "bus-util.h"
|
#include "bus-get-properties.h"
|
||||||
#include "dbus-timer.h"
|
#include "dbus-timer.h"
|
||||||
#include "dbus-util.h"
|
#include "dbus-util.h"
|
||||||
#include "strv.h"
|
#include "strv.h"
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
#include "alloc-util.h"
|
#include "alloc-util.h"
|
||||||
#include "bpf-firewall.h"
|
#include "bpf-firewall.h"
|
||||||
#include "bus-common-errors.h"
|
#include "bus-common-errors.h"
|
||||||
|
#include "bus-get-properties.h"
|
||||||
#include "bus-polkit.h"
|
#include "bus-polkit.h"
|
||||||
#include "bus-util.h"
|
|
||||||
#include "cgroup-util.h"
|
#include "cgroup-util.h"
|
||||||
#include "condition.h"
|
#include "condition.h"
|
||||||
#include "dbus-job.h"
|
#include "dbus-job.h"
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#include "ask-password-api.h"
|
#include "ask-password-api.h"
|
||||||
#include "bus-common-errors.h"
|
#include "bus-common-errors.h"
|
||||||
#include "bus-error.h"
|
#include "bus-error.h"
|
||||||
#include "bus-util.h"
|
#include "bus-locator.h"
|
||||||
#include "cgroup-util.h"
|
#include "cgroup-util.h"
|
||||||
#include "dns-domain.h"
|
#include "dns-domain.h"
|
||||||
#include "env-util.h"
|
#include "env-util.h"
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include "sd-bus.h"
|
#include "sd-bus.h"
|
||||||
|
|
||||||
#include "bus-util.h"
|
#include "bus-object.h"
|
||||||
#include "homed-home.h"
|
#include "homed-home.h"
|
||||||
|
|
||||||
int bus_home_client_is_trusted(Home *h, sd_bus_message *message);
|
int bus_home_client_is_trusted(Home *h, sd_bus_message *message);
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#include "sd-bus.h"
|
#include "sd-bus.h"
|
||||||
|
|
||||||
#include "bus-common-errors.h"
|
#include "bus-common-errors.h"
|
||||||
#include "bus-util.h"
|
#include "bus-locator.h"
|
||||||
#include "errno-util.h"
|
#include "errno-util.h"
|
||||||
#include "fd-util.h"
|
#include "fd-util.h"
|
||||||
#include "home-util.h"
|
#include "home-util.h"
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
#include "alloc-util.h"
|
#include "alloc-util.h"
|
||||||
#include "architecture.h"
|
#include "architecture.h"
|
||||||
#include "bus-error.h"
|
#include "bus-error.h"
|
||||||
#include "bus-util.h"
|
#include "bus-map-properties.h"
|
||||||
#include "hostname-util.h"
|
#include "hostname-util.h"
|
||||||
#include "main-func.h"
|
#include "main-func.h"
|
||||||
#include "pretty-print.h"
|
#include "pretty-print.h"
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
|
|
||||||
#include "alloc-util.h"
|
#include "alloc-util.h"
|
||||||
#include "bus-common-errors.h"
|
#include "bus-common-errors.h"
|
||||||
|
#include "bus-get-properties.h"
|
||||||
#include "bus-log-control-api.h"
|
#include "bus-log-control-api.h"
|
||||||
#include "bus-util.h"
|
|
||||||
#include "bus-polkit.h"
|
#include "bus-polkit.h"
|
||||||
#include "def.h"
|
#include "def.h"
|
||||||
#include "fd-util.h"
|
#include "fd-util.h"
|
||||||
|
@ -22,8 +22,8 @@
|
||||||
#include "parse-util.h"
|
#include "parse-util.h"
|
||||||
#include "path-util.h"
|
#include "path-util.h"
|
||||||
#include "process-util.h"
|
#include "process-util.h"
|
||||||
#include "signal-util.h"
|
|
||||||
#include "service-util.h"
|
#include "service-util.h"
|
||||||
|
#include "signal-util.h"
|
||||||
#include "socket-util.h"
|
#include "socket-util.h"
|
||||||
#include "stat-util.h"
|
#include "stat-util.h"
|
||||||
#include "string-table.h"
|
#include "string-table.h"
|
||||||
|
|
|
@ -349,7 +349,7 @@ static int request_parse_range(
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int request_parse_arguments_iterator(
|
static mhd_result request_parse_arguments_iterator(
|
||||||
void *cls,
|
void *cls,
|
||||||
enum MHD_ValueKind kind,
|
enum MHD_ValueKind kind,
|
||||||
const char *key,
|
const char *key,
|
||||||
|
@ -796,7 +796,7 @@ static int request_handler_machine(
|
||||||
return MHD_queue_response(connection, MHD_HTTP_OK, response);
|
return MHD_queue_response(connection, MHD_HTTP_OK, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int request_handler(
|
static mhd_result request_handler(
|
||||||
void *cls,
|
void *cls,
|
||||||
struct MHD_Connection *connection,
|
struct MHD_Connection *connection,
|
||||||
const char *url,
|
const char *url,
|
||||||
|
|
|
@ -253,7 +253,7 @@ static int process_http_upload(
|
||||||
return mhd_respond(connection, MHD_HTTP_ACCEPTED, "OK.");
|
return mhd_respond(connection, MHD_HTTP_ACCEPTED, "OK.");
|
||||||
};
|
};
|
||||||
|
|
||||||
static int request_handler(
|
static mhd_result request_handler(
|
||||||
void *cls,
|
void *cls,
|
||||||
struct MHD_Connection *connection,
|
struct MHD_Connection *connection,
|
||||||
const char *url,
|
const char *url,
|
||||||
|
|
|
@ -47,6 +47,12 @@
|
||||||
# define MHD_create_response_from_fd_at_offset64 MHD_create_response_from_fd_at_offset
|
# define MHD_create_response_from_fd_at_offset64 MHD_create_response_from_fd_at_offset
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if MHD_VERSION >= 0x00097002
|
||||||
|
# define mhd_result enum MHD_Result
|
||||||
|
#else
|
||||||
|
# define mhd_result int
|
||||||
|
#endif
|
||||||
|
|
||||||
void microhttpd_logger(void *arg, const char *fmt, va_list ap) _printf_(2, 0);
|
void microhttpd_logger(void *arg, const char *fmt, va_list ap) _printf_(2, 0);
|
||||||
|
|
||||||
/* respond_oom() must be usable with return, hence this form. */
|
/* respond_oom() must be usable with return, hence this form. */
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include "bus-internal.h"
|
#include "bus-internal.h"
|
||||||
#include "bus-track.h"
|
#include "bus-track.h"
|
||||||
#include "bus-util.h"
|
#include "bus-util.h"
|
||||||
|
#include "string-util.h"
|
||||||
|
|
||||||
struct track_item {
|
struct track_item {
|
||||||
unsigned n_ref;
|
unsigned n_ref;
|
||||||
|
|
|
@ -8,7 +8,8 @@
|
||||||
#include "sd-bus.h"
|
#include "sd-bus.h"
|
||||||
|
|
||||||
#include "bus-error.h"
|
#include "bus-error.h"
|
||||||
#include "bus-util.h"
|
#include "bus-locator.h"
|
||||||
|
#include "bus-map-properties.h"
|
||||||
#include "fd-util.h"
|
#include "fd-util.h"
|
||||||
#include "fileio.h"
|
#include "fileio.h"
|
||||||
#include "kbd-util.h"
|
#include "kbd-util.h"
|
||||||
|
|
|
@ -9,8 +9,10 @@
|
||||||
|
|
||||||
#include "alloc-util.h"
|
#include "alloc-util.h"
|
||||||
#include "bus-error.h"
|
#include "bus-error.h"
|
||||||
|
#include "bus-locator.h"
|
||||||
|
#include "bus-map-properties.h"
|
||||||
|
#include "bus-print-properties.h"
|
||||||
#include "bus-unit-procs.h"
|
#include "bus-unit-procs.h"
|
||||||
#include "bus-util.h"
|
|
||||||
#include "cgroup-show.h"
|
#include "cgroup-show.h"
|
||||||
#include "cgroup-util.h"
|
#include "cgroup-util.h"
|
||||||
#include "format-table.h"
|
#include "format-table.h"
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
#include "bootspec.h"
|
#include "bootspec.h"
|
||||||
#include "bus-common-errors.h"
|
#include "bus-common-errors.h"
|
||||||
#include "bus-error.h"
|
#include "bus-error.h"
|
||||||
|
#include "bus-get-properties.h"
|
||||||
|
#include "bus-locator.h"
|
||||||
#include "bus-polkit.h"
|
#include "bus-polkit.h"
|
||||||
#include "bus-unit-util.h"
|
#include "bus-unit-util.h"
|
||||||
#include "bus-util.h"
|
#include "bus-util.h"
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
|
|
||||||
#include "sd-bus.h"
|
#include "sd-bus.h"
|
||||||
|
|
||||||
#include "bus-util.h"
|
#include "bus-object.h"
|
||||||
#include "logind.h"
|
|
||||||
#include "logind-session.h"
|
#include "logind-session.h"
|
||||||
#include "logind-user.h"
|
#include "logind-user.h"
|
||||||
|
#include "logind.h"
|
||||||
|
|
||||||
int manager_get_session_from_creds(Manager *m, sd_bus_message *message, const char *name, sd_bus_error *error, Session **ret);
|
int manager_get_session_from_creds(Manager *m, sd_bus_message *message, const char *name, sd_bus_error *error, Session **ret);
|
||||||
int manager_get_user_from_creds(Manager *m, sd_bus_message *message, uid_t uid, sd_bus_error *error, User **ret);
|
int manager_get_user_from_creds(Manager *m, sd_bus_message *message, uid_t uid, sd_bus_error *error, User **ret);
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include "alloc-util.h"
|
#include "alloc-util.h"
|
||||||
#include "bus-common-errors.h"
|
#include "bus-common-errors.h"
|
||||||
|
#include "bus-get-properties.h"
|
||||||
#include "bus-label.h"
|
#include "bus-label.h"
|
||||||
#include "bus-polkit.h"
|
#include "bus-polkit.h"
|
||||||
#include "bus-util.h"
|
#include "bus-util.h"
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
|
|
||||||
#include "sd-bus.h"
|
#include "sd-bus.h"
|
||||||
|
|
||||||
|
#include "bus-object.h"
|
||||||
#include "logind-seat.h"
|
#include "logind-seat.h"
|
||||||
#include "bus-util.h"
|
|
||||||
|
|
||||||
extern const BusObjectImplementation seat_object;
|
extern const BusObjectImplementation seat_object;
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include "alloc-util.h"
|
#include "alloc-util.h"
|
||||||
#include "bus-common-errors.h"
|
#include "bus-common-errors.h"
|
||||||
|
#include "bus-get-properties.h"
|
||||||
#include "bus-label.h"
|
#include "bus-label.h"
|
||||||
#include "bus-polkit.h"
|
#include "bus-polkit.h"
|
||||||
#include "bus-util.h"
|
#include "bus-util.h"
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include "sd-bus.h"
|
#include "sd-bus.h"
|
||||||
|
|
||||||
|
#include "bus-object.h"
|
||||||
#include "logind-session.h"
|
#include "logind-session.h"
|
||||||
|
|
||||||
extern const BusObjectImplementation session_object;
|
extern const BusObjectImplementation session_object;
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include "alloc-util.h"
|
#include "alloc-util.h"
|
||||||
|
#include "bus-get-properties.h"
|
||||||
#include "bus-polkit.h"
|
#include "bus-polkit.h"
|
||||||
#include "bus-util.h"
|
#include "bus-util.h"
|
||||||
#include "format-util.h"
|
#include "format-util.h"
|
||||||
|
|
|
@ -10,9 +10,9 @@
|
||||||
|
|
||||||
#include "alloc-util.h"
|
#include "alloc-util.h"
|
||||||
#include "bus-error.h"
|
#include "bus-error.h"
|
||||||
|
#include "bus-locator.h"
|
||||||
#include "bus-log-control-api.h"
|
#include "bus-log-control-api.h"
|
||||||
#include "bus-polkit.h"
|
#include "bus-polkit.h"
|
||||||
#include "bus-util.h"
|
|
||||||
#include "cgroup-util.h"
|
#include "cgroup-util.h"
|
||||||
#include "def.h"
|
#include "def.h"
|
||||||
#include "device-util.h"
|
#include "device-util.h"
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#include "bus-common-errors.h"
|
#include "bus-common-errors.h"
|
||||||
#include "bus-error.h"
|
#include "bus-error.h"
|
||||||
#include "bus-internal.h"
|
#include "bus-internal.h"
|
||||||
#include "bus-util.h"
|
#include "bus-locator.h"
|
||||||
#include "cgroup-setup.h"
|
#include "cgroup-setup.h"
|
||||||
#include "errno-util.h"
|
#include "errno-util.h"
|
||||||
#include "fd-util.h"
|
#include "fd-util.h"
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
#include <sys/mount.h>
|
#include <sys/mount.h>
|
||||||
|
|
||||||
#include "alloc-util.h"
|
#include "alloc-util.h"
|
||||||
|
#include "bus-get-properties.h"
|
||||||
#include "bus-label.h"
|
#include "bus-label.h"
|
||||||
#include "bus-polkit.h"
|
#include "bus-polkit.h"
|
||||||
#include "bus-util.h"
|
|
||||||
#include "copy.h"
|
#include "copy.h"
|
||||||
#include "dissect-image.h"
|
#include "dissect-image.h"
|
||||||
#include "fd-util.h"
|
#include "fd-util.h"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "bus-util.h"
|
#include "bus-object.h"
|
||||||
#include "machined.h"
|
#include "machined.h"
|
||||||
|
|
||||||
extern const BusObjectImplementation image_object;
|
extern const BusObjectImplementation image_object;
|
||||||
|
|
|
@ -12,10 +12,11 @@
|
||||||
|
|
||||||
#include "alloc-util.h"
|
#include "alloc-util.h"
|
||||||
#include "bus-common-errors.h"
|
#include "bus-common-errors.h"
|
||||||
|
#include "bus-get-properties.h"
|
||||||
#include "bus-internal.h"
|
#include "bus-internal.h"
|
||||||
#include "bus-label.h"
|
#include "bus-label.h"
|
||||||
|
#include "bus-locator.h"
|
||||||
#include "bus-polkit.h"
|
#include "bus-polkit.h"
|
||||||
#include "bus-util.h"
|
|
||||||
#include "copy.h"
|
#include "copy.h"
|
||||||
#include "env-file.h"
|
#include "env-file.h"
|
||||||
#include "env-util.h"
|
#include "env-util.h"
|
||||||
|
|
|
@ -16,9 +16,11 @@
|
||||||
#include "alloc-util.h"
|
#include "alloc-util.h"
|
||||||
#include "bus-common-errors.h"
|
#include "bus-common-errors.h"
|
||||||
#include "bus-error.h"
|
#include "bus-error.h"
|
||||||
|
#include "bus-locator.h"
|
||||||
|
#include "bus-map-properties.h"
|
||||||
|
#include "bus-print-properties.h"
|
||||||
#include "bus-unit-procs.h"
|
#include "bus-unit-procs.h"
|
||||||
#include "bus-unit-util.h"
|
#include "bus-unit-util.h"
|
||||||
#include "bus-util.h"
|
|
||||||
#include "bus-wait-for-jobs.h"
|
#include "bus-wait-for-jobs.h"
|
||||||
#include "cgroup-show.h"
|
#include "cgroup-show.h"
|
||||||
#include "cgroup-util.h"
|
#include "cgroup-util.h"
|
||||||
|
|
|
@ -8,8 +8,9 @@
|
||||||
#include "alloc-util.h"
|
#include "alloc-util.h"
|
||||||
#include "btrfs-util.h"
|
#include "btrfs-util.h"
|
||||||
#include "bus-common-errors.h"
|
#include "bus-common-errors.h"
|
||||||
|
#include "bus-get-properties.h"
|
||||||
|
#include "bus-locator.h"
|
||||||
#include "bus-polkit.h"
|
#include "bus-polkit.h"
|
||||||
#include "bus-util.h"
|
|
||||||
#include "cgroup-util.h"
|
#include "cgroup-util.h"
|
||||||
#include "errno-util.h"
|
#include "errno-util.h"
|
||||||
#include "fd-util.h"
|
#include "fd-util.h"
|
||||||
|
|
|
@ -10,9 +10,9 @@
|
||||||
|
|
||||||
#include "alloc-util.h"
|
#include "alloc-util.h"
|
||||||
#include "bus-error.h"
|
#include "bus-error.h"
|
||||||
|
#include "bus-locator.h"
|
||||||
#include "bus-log-control-api.h"
|
#include "bus-log-control-api.h"
|
||||||
#include "bus-polkit.h"
|
#include "bus-polkit.h"
|
||||||
#include "bus-util.h"
|
|
||||||
#include "cgroup-util.h"
|
#include "cgroup-util.h"
|
||||||
#include "dirent-util.h"
|
#include "dirent-util.h"
|
||||||
#include "fd-util.h"
|
#include "fd-util.h"
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
#include "sd-device.h"
|
#include "sd-device.h"
|
||||||
|
|
||||||
#include "bus-error.h"
|
#include "bus-error.h"
|
||||||
|
#include "bus-locator.h"
|
||||||
#include "bus-unit-util.h"
|
#include "bus-unit-util.h"
|
||||||
#include "bus-util.h"
|
|
||||||
#include "bus-wait-for-jobs.h"
|
#include "bus-wait-for-jobs.h"
|
||||||
#include "device-util.h"
|
#include "device-util.h"
|
||||||
#include "dirent-util.h"
|
#include "dirent-util.h"
|
||||||
|
|
|
@ -21,10 +21,10 @@
|
||||||
|
|
||||||
#include "alloc-util.h"
|
#include "alloc-util.h"
|
||||||
#include "bond-util.h"
|
#include "bond-util.h"
|
||||||
|
#include "bridge-util.h"
|
||||||
#include "bus-common-errors.h"
|
#include "bus-common-errors.h"
|
||||||
#include "bus-error.h"
|
#include "bus-error.h"
|
||||||
#include "bus-util.h"
|
#include "bus-locator.h"
|
||||||
#include "bridge-util.h"
|
|
||||||
#include "device-util.h"
|
#include "device-util.h"
|
||||||
#include "escape.h"
|
#include "escape.h"
|
||||||
#include "ether-addr-util.h"
|
#include "ether-addr-util.h"
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
|
|
||||||
#include "alloc-util.h"
|
#include "alloc-util.h"
|
||||||
#include "bus-common-errors.h"
|
#include "bus-common-errors.h"
|
||||||
|
#include "bus-get-properties.h"
|
||||||
#include "bus-polkit.h"
|
#include "bus-polkit.h"
|
||||||
#include "bus-util.h"
|
|
||||||
#include "dns-domain.h"
|
#include "dns-domain.h"
|
||||||
#include "networkd-link-bus.h"
|
#include "networkd-link-bus.h"
|
||||||
#include "networkd-link.h"
|
#include "networkd-link.h"
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "sd-bus.h"
|
#include "sd-bus.h"
|
||||||
|
|
||||||
#include "bus-error.h"
|
#include "bus-error.h"
|
||||||
|
#include "bus-locator.h"
|
||||||
#include "bus-unit-util.h"
|
#include "bus-unit-util.h"
|
||||||
#include "bus-util.h"
|
#include "bus-util.h"
|
||||||
#include "bus-wait-for-jobs.h"
|
#include "bus-wait-for-jobs.h"
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
#include "alloc-util.h"
|
#include "alloc-util.h"
|
||||||
#include "bus-common-errors.h"
|
#include "bus-common-errors.h"
|
||||||
#include "bus-util.h"
|
#include "bus-locator.h"
|
||||||
#include "env-util.h"
|
#include "env-util.h"
|
||||||
#include "errno-util.h"
|
#include "errno-util.h"
|
||||||
#include "format-util.h"
|
#include "format-util.h"
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#include "sd-bus.h"
|
#include "sd-bus.h"
|
||||||
|
|
||||||
#include "bus-common-errors.h"
|
#include "bus-common-errors.h"
|
||||||
#include "bus-util.h"
|
#include "bus-locator.h"
|
||||||
#include "errno-util.h"
|
#include "errno-util.h"
|
||||||
#include "in-addr-util.h"
|
#include "in-addr-util.h"
|
||||||
#include "macro.h"
|
#include "macro.h"
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
|
|
||||||
#include "alloc-util.h"
|
#include "alloc-util.h"
|
||||||
#include "bus-error.h"
|
#include "bus-error.h"
|
||||||
|
#include "bus-locator.h"
|
||||||
#include "bus-unit-util.h"
|
#include "bus-unit-util.h"
|
||||||
#include "bus-util.h"
|
|
||||||
#include "bus-wait-for-jobs.h"
|
#include "bus-wait-for-jobs.h"
|
||||||
#include "def.h"
|
#include "def.h"
|
||||||
#include "dirent-util.h"
|
#include "dirent-util.h"
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
#include "alloc-util.h"
|
#include "alloc-util.h"
|
||||||
#include "bus-common-errors.h"
|
#include "bus-common-errors.h"
|
||||||
|
#include "bus-get-properties.h"
|
||||||
#include "bus-label.h"
|
#include "bus-label.h"
|
||||||
#include "bus-polkit.h"
|
#include "bus-polkit.h"
|
||||||
#include "bus-util.h"
|
#include "bus-util.h"
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
#include "alloc-util.h"
|
#include "alloc-util.h"
|
||||||
#include "bus-common-errors.h"
|
#include "bus-common-errors.h"
|
||||||
#include "bus-error.h"
|
#include "bus-error.h"
|
||||||
#include "bus-util.h"
|
#include "bus-locator.h"
|
||||||
|
#include "bus-map-properties.h"
|
||||||
#include "dns-domain.h"
|
#include "dns-domain.h"
|
||||||
#include "escape.h"
|
#include "escape.h"
|
||||||
#include "format-table.h"
|
#include "format-table.h"
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
|
|
||||||
#include "alloc-util.h"
|
#include "alloc-util.h"
|
||||||
#include "bus-common-errors.h"
|
#include "bus-common-errors.h"
|
||||||
|
#include "bus-get-properties.h"
|
||||||
#include "bus-log-control-api.h"
|
#include "bus-log-control-api.h"
|
||||||
#include "bus-polkit.h"
|
#include "bus-polkit.h"
|
||||||
#include "bus-util.h"
|
|
||||||
#include "dns-domain.h"
|
#include "dns-domain.h"
|
||||||
#include "memory-util.h"
|
#include "memory-util.h"
|
||||||
#include "missing_capability.h"
|
#include "missing_capability.h"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "bus-util.h"
|
#include "bus-object.h"
|
||||||
#include "resolved-manager.h"
|
#include "resolved-manager.h"
|
||||||
|
|
||||||
extern const BusObjectImplementation manager_object;
|
extern const BusObjectImplementation manager_object;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#include "sd-bus.h"
|
#include "sd-bus.h"
|
||||||
|
|
||||||
#include "bus-util.h"
|
#include "bus-object.h"
|
||||||
|
|
||||||
extern const BusObjectImplementation dnssd_object;
|
extern const BusObjectImplementation dnssd_object;
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
|
|
||||||
#include "alloc-util.h"
|
#include "alloc-util.h"
|
||||||
#include "bus-common-errors.h"
|
#include "bus-common-errors.h"
|
||||||
|
#include "bus-get-properties.h"
|
||||||
#include "bus-polkit.h"
|
#include "bus-polkit.h"
|
||||||
#include "bus-util.h"
|
|
||||||
#include "parse-util.h"
|
#include "parse-util.h"
|
||||||
#include "resolve-util.h"
|
#include "resolve-util.h"
|
||||||
#include "resolved-bus.h"
|
#include "resolved-bus.h"
|
||||||
|
|
|
@ -11,8 +11,9 @@
|
||||||
|
|
||||||
#include "alloc-util.h"
|
#include "alloc-util.h"
|
||||||
#include "bus-error.h"
|
#include "bus-error.h"
|
||||||
|
#include "bus-locator.h"
|
||||||
|
#include "bus-map-properties.h"
|
||||||
#include "bus-unit-util.h"
|
#include "bus-unit-util.h"
|
||||||
#include "bus-util.h"
|
|
||||||
#include "bus-wait-for-jobs.h"
|
#include "bus-wait-for-jobs.h"
|
||||||
#include "calendarspec.h"
|
#include "calendarspec.h"
|
||||||
#include "env-util.h"
|
#include "env-util.h"
|
||||||
|
|
|
@ -0,0 +1,149 @@
|
||||||
|
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||||
|
|
||||||
|
#include "bus-get-properties.h"
|
||||||
|
#include "rlimit-util.h"
|
||||||
|
#include "string-util.h"
|
||||||
|
|
||||||
|
int bus_property_get_bool(
|
||||||
|
sd_bus *bus,
|
||||||
|
const char *path,
|
||||||
|
const char *interface,
|
||||||
|
const char *property,
|
||||||
|
sd_bus_message *reply,
|
||||||
|
void *userdata,
|
||||||
|
sd_bus_error *error) {
|
||||||
|
|
||||||
|
int b = *(bool*) userdata;
|
||||||
|
|
||||||
|
return sd_bus_message_append_basic(reply, 'b', &b);
|
||||||
|
}
|
||||||
|
|
||||||
|
int bus_property_set_bool(
|
||||||
|
sd_bus *bus,
|
||||||
|
const char *path,
|
||||||
|
const char *interface,
|
||||||
|
const char *property,
|
||||||
|
sd_bus_message *value,
|
||||||
|
void *userdata,
|
||||||
|
sd_bus_error *error) {
|
||||||
|
|
||||||
|
int b, r;
|
||||||
|
|
||||||
|
r = sd_bus_message_read(value, "b", &b);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
*(bool*) userdata = b;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int bus_property_get_id128(
|
||||||
|
sd_bus *bus,
|
||||||
|
const char *path,
|
||||||
|
const char *interface,
|
||||||
|
const char *property,
|
||||||
|
sd_bus_message *reply,
|
||||||
|
void *userdata,
|
||||||
|
sd_bus_error *error) {
|
||||||
|
|
||||||
|
sd_id128_t *id = userdata;
|
||||||
|
|
||||||
|
if (sd_id128_is_null(*id)) /* Add an empty array if the ID is zero */
|
||||||
|
return sd_bus_message_append(reply, "ay", 0);
|
||||||
|
else
|
||||||
|
return sd_bus_message_append_array(reply, 'y', id->bytes, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if __SIZEOF_SIZE_T__ != 8
|
||||||
|
int bus_property_get_size(
|
||||||
|
sd_bus *bus,
|
||||||
|
const char *path,
|
||||||
|
const char *interface,
|
||||||
|
const char *property,
|
||||||
|
sd_bus_message *reply,
|
||||||
|
void *userdata,
|
||||||
|
sd_bus_error *error) {
|
||||||
|
|
||||||
|
uint64_t sz = *(size_t*) userdata;
|
||||||
|
|
||||||
|
return sd_bus_message_append_basic(reply, 't', &sz);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if __SIZEOF_LONG__ != 8
|
||||||
|
int bus_property_get_long(
|
||||||
|
sd_bus *bus,
|
||||||
|
const char *path,
|
||||||
|
const char *interface,
|
||||||
|
const char *property,
|
||||||
|
sd_bus_message *reply,
|
||||||
|
void *userdata,
|
||||||
|
sd_bus_error *error) {
|
||||||
|
|
||||||
|
int64_t l = *(long*) userdata;
|
||||||
|
|
||||||
|
return sd_bus_message_append_basic(reply, 'x', &l);
|
||||||
|
}
|
||||||
|
|
||||||
|
int bus_property_get_ulong(
|
||||||
|
sd_bus *bus,
|
||||||
|
const char *path,
|
||||||
|
const char *interface,
|
||||||
|
const char *property,
|
||||||
|
sd_bus_message *reply,
|
||||||
|
void *userdata,
|
||||||
|
sd_bus_error *error) {
|
||||||
|
|
||||||
|
uint64_t ul = *(unsigned long*) userdata;
|
||||||
|
|
||||||
|
return sd_bus_message_append_basic(reply, 't', &ul);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int bus_property_get_rlimit(
|
||||||
|
sd_bus *bus,
|
||||||
|
const char *path,
|
||||||
|
const char *interface,
|
||||||
|
const char *property,
|
||||||
|
sd_bus_message *reply,
|
||||||
|
void *userdata,
|
||||||
|
sd_bus_error *error) {
|
||||||
|
|
||||||
|
const char *is_soft;
|
||||||
|
struct rlimit *rl;
|
||||||
|
uint64_t u;
|
||||||
|
rlim_t x;
|
||||||
|
|
||||||
|
assert(bus);
|
||||||
|
assert(reply);
|
||||||
|
assert(userdata);
|
||||||
|
|
||||||
|
is_soft = endswith(property, "Soft");
|
||||||
|
|
||||||
|
rl = *(struct rlimit**) userdata;
|
||||||
|
if (rl)
|
||||||
|
x = is_soft ? rl->rlim_cur : rl->rlim_max;
|
||||||
|
else {
|
||||||
|
struct rlimit buf = {};
|
||||||
|
const char *s, *p;
|
||||||
|
int z;
|
||||||
|
|
||||||
|
/* Chop off "Soft" suffix */
|
||||||
|
s = is_soft ? strndupa(property, is_soft - property) : property;
|
||||||
|
|
||||||
|
/* Skip over any prefix, such as "Default" */
|
||||||
|
assert_se(p = strstr(s, "Limit"));
|
||||||
|
|
||||||
|
z = rlimit_from_string(p + 5);
|
||||||
|
assert(z >= 0);
|
||||||
|
|
||||||
|
(void) getrlimit(z, &buf);
|
||||||
|
x = is_soft ? buf.rlim_cur : buf.rlim_max;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* rlim_t might have different sizes, let's map RLIMIT_INFINITY to (uint64_t) -1, so that it is the same on all
|
||||||
|
* archs */
|
||||||
|
u = x == RLIM_INFINITY ? (uint64_t) -1 : (uint64_t) x;
|
||||||
|
|
||||||
|
return sd_bus_message_append(reply, "t", u);
|
||||||
|
}
|
|
@ -0,0 +1,103 @@
|
||||||
|
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "sd-bus.h"
|
||||||
|
|
||||||
|
#include "sd-bus.h"
|
||||||
|
|
||||||
|
#include "macro.h"
|
||||||
|
|
||||||
|
int bus_property_get_bool(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error);
|
||||||
|
int bus_property_set_bool(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *value, void *userdata, sd_bus_error *error);
|
||||||
|
int bus_property_get_id128(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error);
|
||||||
|
|
||||||
|
#define bus_property_get_usec ((sd_bus_property_get_t) NULL)
|
||||||
|
#define bus_property_set_usec ((sd_bus_property_set_t) NULL)
|
||||||
|
|
||||||
|
assert_cc(sizeof(int) == sizeof(int32_t));
|
||||||
|
#define bus_property_get_int ((sd_bus_property_get_t) NULL)
|
||||||
|
|
||||||
|
assert_cc(sizeof(unsigned) == sizeof(uint32_t));
|
||||||
|
#define bus_property_get_unsigned ((sd_bus_property_get_t) NULL)
|
||||||
|
|
||||||
|
/* On 64bit machines we can use the default serializer for size_t and
|
||||||
|
* friends, otherwise we need to cast this manually */
|
||||||
|
#if __SIZEOF_SIZE_T__ == 8
|
||||||
|
#define bus_property_get_size ((sd_bus_property_get_t) NULL)
|
||||||
|
#else
|
||||||
|
int bus_property_get_size(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if __SIZEOF_LONG__ == 8
|
||||||
|
#define bus_property_get_long ((sd_bus_property_get_t) NULL)
|
||||||
|
#define bus_property_get_ulong ((sd_bus_property_get_t) NULL)
|
||||||
|
#else
|
||||||
|
int bus_property_get_long(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error);
|
||||||
|
int bus_property_get_ulong(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* uid_t and friends on Linux 32 bit. This means we can just use the
|
||||||
|
* default serializer for 32bit unsigned, for serializing it, and map
|
||||||
|
* it to NULL here */
|
||||||
|
assert_cc(sizeof(uid_t) == sizeof(uint32_t));
|
||||||
|
#define bus_property_get_uid ((sd_bus_property_get_t) NULL)
|
||||||
|
|
||||||
|
assert_cc(sizeof(gid_t) == sizeof(uint32_t));
|
||||||
|
#define bus_property_get_gid ((sd_bus_property_get_t) NULL)
|
||||||
|
|
||||||
|
assert_cc(sizeof(pid_t) == sizeof(uint32_t));
|
||||||
|
#define bus_property_get_pid ((sd_bus_property_get_t) NULL)
|
||||||
|
|
||||||
|
assert_cc(sizeof(mode_t) == sizeof(uint32_t));
|
||||||
|
#define bus_property_get_mode ((sd_bus_property_get_t) NULL)
|
||||||
|
|
||||||
|
int bus_property_get_rlimit(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error);
|
||||||
|
|
||||||
|
#define BUS_DEFINE_PROPERTY_GET_GLOBAL(function, bus_type, val) \
|
||||||
|
int function(sd_bus *bus, \
|
||||||
|
const char *path, \
|
||||||
|
const char *interface, \
|
||||||
|
const char *property, \
|
||||||
|
sd_bus_message *reply, \
|
||||||
|
void *userdata, \
|
||||||
|
sd_bus_error *error) { \
|
||||||
|
\
|
||||||
|
assert(bus); \
|
||||||
|
assert(reply); \
|
||||||
|
\
|
||||||
|
return sd_bus_message_append(reply, bus_type, val); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define BUS_DEFINE_PROPERTY_GET2(function, bus_type, data_type, get1, get2) \
|
||||||
|
int function(sd_bus *bus, \
|
||||||
|
const char *path, \
|
||||||
|
const char *interface, \
|
||||||
|
const char *property, \
|
||||||
|
sd_bus_message *reply, \
|
||||||
|
void *userdata, \
|
||||||
|
sd_bus_error *error) { \
|
||||||
|
\
|
||||||
|
data_type *data = userdata; \
|
||||||
|
\
|
||||||
|
assert(bus); \
|
||||||
|
assert(reply); \
|
||||||
|
assert(data); \
|
||||||
|
\
|
||||||
|
return sd_bus_message_append(reply, bus_type, \
|
||||||
|
get2(get1(data))); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define ident(x) (x)
|
||||||
|
#define BUS_DEFINE_PROPERTY_GET(function, bus_type, data_type, get1) \
|
||||||
|
BUS_DEFINE_PROPERTY_GET2(function, bus_type, data_type, get1, ident)
|
||||||
|
|
||||||
|
#define ref(x) (*(x))
|
||||||
|
#define BUS_DEFINE_PROPERTY_GET_REF(function, bus_type, data_type, get) \
|
||||||
|
BUS_DEFINE_PROPERTY_GET2(function, bus_type, data_type, ref, get)
|
||||||
|
|
||||||
|
#define BUS_DEFINE_PROPERTY_GET_ENUM(function, name, type) \
|
||||||
|
BUS_DEFINE_PROPERTY_GET_REF(function, "s", type, name##_to_string)
|
||||||
|
|
||||||
|
#define BUS_PROPERTY_DUAL_TIMESTAMP(name, offset, flags) \
|
||||||
|
SD_BUS_PROPERTY(name, "t", bus_property_get_usec, (offset) + offsetof(struct dual_timestamp, realtime), (flags)), \
|
||||||
|
SD_BUS_PROPERTY(name "Monotonic", "t", bus_property_get_usec, (offset) + offsetof(struct dual_timestamp, monotonic), (flags))
|
|
@ -1,6 +1,7 @@
|
||||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||||
|
|
||||||
#include "bus-locator.h"
|
#include "bus-locator.h"
|
||||||
|
#include "macro.h"
|
||||||
|
|
||||||
const BusLocator* const bus_home_mgr = &(BusLocator){
|
const BusLocator* const bus_home_mgr = &(BusLocator){
|
||||||
.destination = "org.freedesktop.home1",
|
.destination = "org.freedesktop.home1",
|
||||||
|
@ -61,3 +62,152 @@ const BusLocator* const bus_timedate = &(BusLocator){
|
||||||
.path = "/org/freedesktop/timedate1",
|
.path = "/org/freedesktop/timedate1",
|
||||||
.interface = "org.freedesktop.timedate1"
|
.interface = "org.freedesktop.timedate1"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Shorthand flavors of the sd-bus convenience helpers with destination,path,interface strings encapsulated
|
||||||
|
* within a single struct. */
|
||||||
|
int bus_call_method_async(
|
||||||
|
sd_bus *bus,
|
||||||
|
sd_bus_slot **slot,
|
||||||
|
const BusLocator *locator,
|
||||||
|
const char *member,
|
||||||
|
sd_bus_message_handler_t callback,
|
||||||
|
void *userdata,
|
||||||
|
const char *types, ...) {
|
||||||
|
|
||||||
|
va_list ap;
|
||||||
|
int r;
|
||||||
|
|
||||||
|
assert(locator);
|
||||||
|
|
||||||
|
va_start(ap, types);
|
||||||
|
r = sd_bus_call_method_asyncv(bus, slot, locator->destination, locator->path, locator->interface, member, callback, userdata, types, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
int bus_call_method(
|
||||||
|
sd_bus *bus,
|
||||||
|
const BusLocator *locator,
|
||||||
|
const char *member,
|
||||||
|
sd_bus_error *error,
|
||||||
|
sd_bus_message **reply,
|
||||||
|
const char *types, ...) {
|
||||||
|
|
||||||
|
va_list ap;
|
||||||
|
int r;
|
||||||
|
|
||||||
|
assert(locator);
|
||||||
|
|
||||||
|
va_start(ap, types);
|
||||||
|
r = sd_bus_call_methodv(bus, locator->destination, locator->path, locator->interface, member, error, reply, types, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
int bus_get_property(
|
||||||
|
sd_bus *bus,
|
||||||
|
const BusLocator *locator,
|
||||||
|
const char *member,
|
||||||
|
sd_bus_error *error,
|
||||||
|
sd_bus_message **reply,
|
||||||
|
const char *type) {
|
||||||
|
|
||||||
|
assert(locator);
|
||||||
|
|
||||||
|
return sd_bus_get_property(bus, locator->destination, locator->path, locator->interface, member, error, reply, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
int bus_get_property_trivial(
|
||||||
|
sd_bus *bus,
|
||||||
|
const BusLocator *locator,
|
||||||
|
const char *member,
|
||||||
|
sd_bus_error *error,
|
||||||
|
char type, void *ptr) {
|
||||||
|
|
||||||
|
assert(locator);
|
||||||
|
|
||||||
|
return sd_bus_get_property_trivial(bus, locator->destination, locator->path, locator->interface, member, error, type, ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
int bus_get_property_string(
|
||||||
|
sd_bus *bus,
|
||||||
|
const BusLocator *locator,
|
||||||
|
const char *member,
|
||||||
|
sd_bus_error *error,
|
||||||
|
char **ret) {
|
||||||
|
|
||||||
|
assert(locator);
|
||||||
|
|
||||||
|
return sd_bus_get_property_string(bus, locator->destination, locator->path, locator->interface, member, error, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
int bus_get_property_strv(
|
||||||
|
sd_bus *bus,
|
||||||
|
const BusLocator *locator,
|
||||||
|
const char *member,
|
||||||
|
sd_bus_error *error,
|
||||||
|
char ***ret) {
|
||||||
|
|
||||||
|
assert(locator);
|
||||||
|
|
||||||
|
return sd_bus_get_property_strv(bus, locator->destination, locator->path, locator->interface, member, error, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
int bus_set_property(
|
||||||
|
sd_bus *bus,
|
||||||
|
const BusLocator *locator,
|
||||||
|
const char *member,
|
||||||
|
sd_bus_error *error,
|
||||||
|
const char *type, ...) {
|
||||||
|
|
||||||
|
va_list ap;
|
||||||
|
int r;
|
||||||
|
|
||||||
|
assert(locator);
|
||||||
|
|
||||||
|
va_start(ap, type);
|
||||||
|
r = sd_bus_set_propertyv(bus, locator->destination, locator->path, locator->interface, member, error, type, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
int bus_match_signal(
|
||||||
|
sd_bus *bus,
|
||||||
|
sd_bus_slot **ret,
|
||||||
|
const BusLocator *locator,
|
||||||
|
const char *member,
|
||||||
|
sd_bus_message_handler_t callback,
|
||||||
|
void *userdata) {
|
||||||
|
|
||||||
|
assert(locator);
|
||||||
|
|
||||||
|
return sd_bus_match_signal(bus, ret, locator->destination, locator->path, locator->interface, member, callback, userdata);
|
||||||
|
}
|
||||||
|
|
||||||
|
int bus_match_signal_async(
|
||||||
|
sd_bus *bus,
|
||||||
|
sd_bus_slot **ret,
|
||||||
|
const BusLocator *locator,
|
||||||
|
const char *member,
|
||||||
|
sd_bus_message_handler_t callback,
|
||||||
|
sd_bus_message_handler_t install_callback,
|
||||||
|
void *userdata) {
|
||||||
|
|
||||||
|
assert(locator);
|
||||||
|
|
||||||
|
return sd_bus_match_signal_async(bus, ret, locator->destination, locator->path, locator->interface, member, callback, install_callback, userdata);
|
||||||
|
}
|
||||||
|
|
||||||
|
int bus_message_new_method_call(
|
||||||
|
sd_bus *bus,
|
||||||
|
sd_bus_message **m,
|
||||||
|
const BusLocator *locator,
|
||||||
|
const char *member) {
|
||||||
|
|
||||||
|
assert(locator);
|
||||||
|
|
||||||
|
return sd_bus_message_new_method_call(bus, m, locator->destination, locator->path, locator->interface, member);
|
||||||
|
}
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "sd-bus.h"
|
||||||
|
|
||||||
typedef struct BusLocator {
|
typedef struct BusLocator {
|
||||||
const char *destination;
|
const char *destination;
|
||||||
const char *path;
|
const char *path;
|
||||||
const char *interface;
|
const char *interface;
|
||||||
} BusLocator;
|
} BusLocator;
|
||||||
|
|
||||||
extern const BusLocator* const bus_home_mgr;
|
extern const BusLocator* const bus_home_mgr;
|
||||||
|
@ -17,3 +19,16 @@ extern const BusLocator* const bus_portable_mgr;
|
||||||
extern const BusLocator* const bus_resolve_mgr;
|
extern const BusLocator* const bus_resolve_mgr;
|
||||||
extern const BusLocator* const bus_systemd_mgr;
|
extern const BusLocator* const bus_systemd_mgr;
|
||||||
extern const BusLocator* const bus_timedate;
|
extern const BusLocator* const bus_timedate;
|
||||||
|
|
||||||
|
/* Shorthand flavors of the sd-bus convenience helpers with destination,path,interface strings encapsulated
|
||||||
|
* within a single struct. */
|
||||||
|
int bus_call_method_async(sd_bus *bus, sd_bus_slot **slot, const BusLocator *locator, const char *member, sd_bus_message_handler_t callback, void *userdata, const char *types, ...);
|
||||||
|
int bus_call_method(sd_bus *bus, const BusLocator *locator, const char *member, sd_bus_error *error, sd_bus_message **reply, const char *types, ...);
|
||||||
|
int bus_get_property(sd_bus *bus, const BusLocator *locator, const char *member, sd_bus_error *error, sd_bus_message **reply, const char *type);
|
||||||
|
int bus_get_property_trivial(sd_bus *bus, const BusLocator *locator, const char *member, sd_bus_error *error, char type, void *ptr);
|
||||||
|
int bus_get_property_string(sd_bus *bus, const BusLocator *locator, const char *member, sd_bus_error *error, char **ret);
|
||||||
|
int bus_get_property_strv(sd_bus *bus, const BusLocator *locator, const char *member, sd_bus_error *error, char ***ret);
|
||||||
|
int bus_set_property(sd_bus *bus, const BusLocator *locator, const char *member, sd_bus_error *error, const char *type, ...);
|
||||||
|
int bus_match_signal(sd_bus *bus, sd_bus_slot **ret, const BusLocator *locator, const char *member, sd_bus_message_handler_t callback, void *userdata);
|
||||||
|
int bus_match_signal_async(sd_bus *bus, sd_bus_slot **ret, const BusLocator *locator, const char *member, sd_bus_message_handler_t callback, sd_bus_message_handler_t install_callback, void *userdata);
|
||||||
|
int bus_message_new_method_call(sd_bus *bus, sd_bus_message **m, const BusLocator *locator, const char *member);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||||
|
|
||||||
#include "alloc-util.h"
|
#include "alloc-util.h"
|
||||||
|
#include "bus-get-properties.h"
|
||||||
#include "bus-log-control-api.h"
|
#include "bus-log-control-api.h"
|
||||||
#include "bus-util.h"
|
#include "bus-util.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include "sd-bus.h"
|
#include "sd-bus.h"
|
||||||
|
|
||||||
#include "bus-util.h"
|
#include "bus-object.h"
|
||||||
|
|
||||||
extern const BusObjectImplementation log_control_object;
|
extern const BusObjectImplementation log_control_object;
|
||||||
static inline int bus_log_control_api_register(sd_bus *bus) {
|
static inline int bus_log_control_api_register(sd_bus *bus) {
|
||||||
|
|
|
@ -0,0 +1,229 @@
|
||||||
|
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||||
|
|
||||||
|
#include "bus-map-properties.h"
|
||||||
|
#include "alloc-util.h"
|
||||||
|
#include "strv.h"
|
||||||
|
#include "bus-message.h"
|
||||||
|
|
||||||
|
int bus_map_id128(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_error *error, void *userdata) {
|
||||||
|
sd_id128_t *p = userdata;
|
||||||
|
const void *v;
|
||||||
|
size_t n;
|
||||||
|
int r;
|
||||||
|
|
||||||
|
r = sd_bus_message_read_array(m, SD_BUS_TYPE_BYTE, &v, &n);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
if (n == 0)
|
||||||
|
*p = SD_ID128_NULL;
|
||||||
|
else if (n == 16)
|
||||||
|
memcpy((*p).bytes, v, n);
|
||||||
|
else
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int map_basic(sd_bus *bus, const char *member, sd_bus_message *m, unsigned flags, sd_bus_error *error, void *userdata) {
|
||||||
|
char type;
|
||||||
|
int r;
|
||||||
|
|
||||||
|
r = sd_bus_message_peek_type(m, &type, NULL);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
|
||||||
|
case SD_BUS_TYPE_STRING:
|
||||||
|
case SD_BUS_TYPE_OBJECT_PATH: {
|
||||||
|
const char **p = userdata;
|
||||||
|
const char *s;
|
||||||
|
|
||||||
|
r = sd_bus_message_read_basic(m, type, &s);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
if (isempty(s))
|
||||||
|
s = NULL;
|
||||||
|
|
||||||
|
if (flags & BUS_MAP_STRDUP)
|
||||||
|
return free_and_strdup((char **) userdata, s);
|
||||||
|
|
||||||
|
*p = s;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
case SD_BUS_TYPE_ARRAY: {
|
||||||
|
_cleanup_strv_free_ char **l = NULL;
|
||||||
|
char ***p = userdata;
|
||||||
|
|
||||||
|
r = bus_message_read_strv_extend(m, &l);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
return strv_extend_strv(p, l, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
case SD_BUS_TYPE_BOOLEAN: {
|
||||||
|
int b;
|
||||||
|
|
||||||
|
r = sd_bus_message_read_basic(m, type, &b);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
if (flags & BUS_MAP_BOOLEAN_AS_BOOL)
|
||||||
|
*(bool*) userdata = b;
|
||||||
|
else
|
||||||
|
*(int*) userdata = b;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
case SD_BUS_TYPE_INT32:
|
||||||
|
case SD_BUS_TYPE_UINT32: {
|
||||||
|
uint32_t u, *p = userdata;
|
||||||
|
|
||||||
|
r = sd_bus_message_read_basic(m, type, &u);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
*p = u;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
case SD_BUS_TYPE_INT64:
|
||||||
|
case SD_BUS_TYPE_UINT64: {
|
||||||
|
uint64_t t, *p = userdata;
|
||||||
|
|
||||||
|
r = sd_bus_message_read_basic(m, type, &t);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
*p = t;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
case SD_BUS_TYPE_DOUBLE: {
|
||||||
|
double d, *p = userdata;
|
||||||
|
|
||||||
|
r = sd_bus_message_read_basic(m, type, &d);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
*p = d;
|
||||||
|
return 0;
|
||||||
|
}}
|
||||||
|
|
||||||
|
return -EOPNOTSUPP;
|
||||||
|
}
|
||||||
|
|
||||||
|
int bus_message_map_all_properties(
|
||||||
|
sd_bus_message *m,
|
||||||
|
const struct bus_properties_map *map,
|
||||||
|
unsigned flags,
|
||||||
|
sd_bus_error *error,
|
||||||
|
void *userdata) {
|
||||||
|
|
||||||
|
int r;
|
||||||
|
|
||||||
|
assert(m);
|
||||||
|
assert(map);
|
||||||
|
|
||||||
|
r = sd_bus_message_enter_container(m, SD_BUS_TYPE_ARRAY, "{sv}");
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
while ((r = sd_bus_message_enter_container(m, SD_BUS_TYPE_DICT_ENTRY, "sv")) > 0) {
|
||||||
|
const struct bus_properties_map *prop;
|
||||||
|
const char *member;
|
||||||
|
const char *contents;
|
||||||
|
void *v;
|
||||||
|
unsigned i;
|
||||||
|
|
||||||
|
r = sd_bus_message_read_basic(m, SD_BUS_TYPE_STRING, &member);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
for (i = 0, prop = NULL; map[i].member; i++)
|
||||||
|
if (streq(map[i].member, member)) {
|
||||||
|
prop = &map[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prop) {
|
||||||
|
r = sd_bus_message_peek_type(m, NULL, &contents);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
r = sd_bus_message_enter_container(m, SD_BUS_TYPE_VARIANT, contents);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
v = (uint8_t *)userdata + prop->offset;
|
||||||
|
if (map[i].set)
|
||||||
|
r = prop->set(sd_bus_message_get_bus(m), member, m, error, v);
|
||||||
|
else
|
||||||
|
r = map_basic(sd_bus_message_get_bus(m), member, m, flags, error, v);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
r = sd_bus_message_exit_container(m);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
} else {
|
||||||
|
r = sd_bus_message_skip(m, "v");
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
r = sd_bus_message_exit_container(m);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
return sd_bus_message_exit_container(m);
|
||||||
|
}
|
||||||
|
|
||||||
|
int bus_map_all_properties(
|
||||||
|
sd_bus *bus,
|
||||||
|
const char *destination,
|
||||||
|
const char *path,
|
||||||
|
const struct bus_properties_map *map,
|
||||||
|
unsigned flags,
|
||||||
|
sd_bus_error *error,
|
||||||
|
sd_bus_message **reply,
|
||||||
|
void *userdata) {
|
||||||
|
|
||||||
|
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
|
||||||
|
int r;
|
||||||
|
|
||||||
|
assert(bus);
|
||||||
|
assert(destination);
|
||||||
|
assert(path);
|
||||||
|
assert(map);
|
||||||
|
assert(reply || (flags & BUS_MAP_STRDUP));
|
||||||
|
|
||||||
|
r = sd_bus_call_method(
|
||||||
|
bus,
|
||||||
|
destination,
|
||||||
|
path,
|
||||||
|
"org.freedesktop.DBus.Properties",
|
||||||
|
"GetAll",
|
||||||
|
error,
|
||||||
|
&m,
|
||||||
|
"s", "");
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
r = bus_message_map_all_properties(m, map, flags, error, userdata);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
if (reply)
|
||||||
|
*reply = sd_bus_message_ref(m);
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "sd-bus.h"
|
||||||
|
|
||||||
|
typedef int (*bus_property_set_t) (sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_error *error, void *userdata);
|
||||||
|
|
||||||
|
struct bus_properties_map {
|
||||||
|
const char *member;
|
||||||
|
const char *signature;
|
||||||
|
bus_property_set_t set;
|
||||||
|
size_t offset;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
BUS_MAP_STRDUP = 1 << 0, /* If set, each "s" message is duplicated. Thus, each pointer needs to be freed. */
|
||||||
|
BUS_MAP_BOOLEAN_AS_BOOL = 1 << 1, /* If set, each "b" message is written to a bool pointer. If not set, "b" is written to a int pointer. */
|
||||||
|
};
|
||||||
|
|
||||||
|
int bus_map_id128(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_error *error, void *userdata);
|
||||||
|
|
||||||
|
int bus_message_map_all_properties(sd_bus_message *m, const struct bus_properties_map *map, unsigned flags, sd_bus_error *error, void *userdata);
|
||||||
|
int bus_map_all_properties(sd_bus *bus, const char *destination, const char *path, const struct bus_properties_map *map,
|
||||||
|
unsigned flags, sd_bus_error *error, sd_bus_message **reply, void *userdata);
|
|
@ -0,0 +1,177 @@
|
||||||
|
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||||
|
|
||||||
|
#include "bus-introspect.h"
|
||||||
|
#include "bus-object.h"
|
||||||
|
#include "macro.h"
|
||||||
|
#include "string-util.h"
|
||||||
|
#include "strv.h"
|
||||||
|
|
||||||
|
int bus_add_implementation(sd_bus *bus, const BusObjectImplementation *impl, void *userdata) {
|
||||||
|
int r;
|
||||||
|
|
||||||
|
log_debug("Registering bus object implementation for path=%s iface=%s", impl->path, impl->interface);
|
||||||
|
|
||||||
|
for (const sd_bus_vtable **p = impl->vtables; p && *p; p++) {
|
||||||
|
r = sd_bus_add_object_vtable(bus, NULL,
|
||||||
|
impl->path,
|
||||||
|
impl->interface,
|
||||||
|
*p,
|
||||||
|
userdata);
|
||||||
|
if (r < 0)
|
||||||
|
return log_error_errno(r, "Failed to register bus path %s with interface %s: %m",
|
||||||
|
impl->path,
|
||||||
|
impl->interface);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const BusObjectVtablePair *p = impl->fallback_vtables; p && p->vtable; p++) {
|
||||||
|
r = sd_bus_add_fallback_vtable(bus, NULL,
|
||||||
|
impl->path,
|
||||||
|
impl->interface,
|
||||||
|
p->vtable,
|
||||||
|
p->object_find,
|
||||||
|
userdata);
|
||||||
|
if (r < 0)
|
||||||
|
return log_error_errno(r, "Failed to register bus path %s with interface %s: %m",
|
||||||
|
impl->path,
|
||||||
|
impl->interface);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (impl->node_enumerator) {
|
||||||
|
r = sd_bus_add_node_enumerator(bus, NULL,
|
||||||
|
impl->path,
|
||||||
|
impl->node_enumerator,
|
||||||
|
userdata);
|
||||||
|
if (r < 0)
|
||||||
|
return log_error_errno(r, "Failed to add node enumerator for %s: %m",
|
||||||
|
impl->path);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (impl->manager) {
|
||||||
|
r = sd_bus_add_object_manager(bus, NULL, impl->path);
|
||||||
|
if (r < 0)
|
||||||
|
return log_error_errno(r, "Failed to add object manager for %s: %m", impl->path);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (size_t i = 0; impl->children && impl->children[i]; i++) {
|
||||||
|
r = bus_add_implementation(bus, impl->children[i], userdata);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const BusObjectImplementation* find_implementation(
|
||||||
|
const char *pattern,
|
||||||
|
const BusObjectImplementation* const* bus_objects) {
|
||||||
|
|
||||||
|
for (size_t i = 0; bus_objects && bus_objects[i]; i++) {
|
||||||
|
const BusObjectImplementation *impl = bus_objects[i];
|
||||||
|
|
||||||
|
if (STR_IN_SET(pattern, impl->path, impl->interface))
|
||||||
|
return impl;
|
||||||
|
|
||||||
|
impl = find_implementation(pattern, impl->children);
|
||||||
|
if (impl)
|
||||||
|
return impl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int bus_introspect_implementation(
|
||||||
|
struct introspect *intro,
|
||||||
|
const BusObjectImplementation *impl) {
|
||||||
|
int r;
|
||||||
|
|
||||||
|
for (const sd_bus_vtable **p = impl->vtables; p && *p; p++) {
|
||||||
|
r = introspect_write_interface(intro, impl->interface, *p);
|
||||||
|
if (r < 0)
|
||||||
|
return log_error_errno(r, "Failed to write introspection data: %m");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const BusObjectVtablePair *p = impl->fallback_vtables; p && p->vtable; p++) {
|
||||||
|
r = introspect_write_interface(intro, impl->interface, p->vtable);
|
||||||
|
if (r < 0)
|
||||||
|
return log_error_errno(r, "Failed to write introspection data: %m");
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void list_paths(
|
||||||
|
FILE *out,
|
||||||
|
const BusObjectImplementation* const* bus_objects) {
|
||||||
|
|
||||||
|
for (size_t i = 0; bus_objects[i]; i++) {
|
||||||
|
fprintf(out, "%s\t%s\n", bus_objects[i]->path, bus_objects[i]->interface);
|
||||||
|
if (bus_objects[i]->children)
|
||||||
|
list_paths(out, bus_objects[i]->children);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int bus_introspect_implementations(
|
||||||
|
FILE *out,
|
||||||
|
const char *pattern,
|
||||||
|
const BusObjectImplementation* const* bus_objects) {
|
||||||
|
|
||||||
|
const BusObjectImplementation *impl, *main_impl = NULL;
|
||||||
|
_cleanup_free_ char *s = NULL;
|
||||||
|
int r;
|
||||||
|
|
||||||
|
if (streq(pattern, "list")) {
|
||||||
|
list_paths(out, bus_objects);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct introspect intro = {};
|
||||||
|
bool is_interface = sd_bus_interface_name_is_valid(pattern);
|
||||||
|
|
||||||
|
impl = find_implementation(pattern, bus_objects);
|
||||||
|
if (!impl)
|
||||||
|
return log_error_errno(SYNTHETIC_ERRNO(ENOENT),
|
||||||
|
"%s %s not found",
|
||||||
|
is_interface ? "Interface" : "Object path",
|
||||||
|
pattern);
|
||||||
|
|
||||||
|
/* We use trusted=false here to get all the @org.freedesktop.systemd1.Privileged annotations. */
|
||||||
|
r = introspect_begin(&intro, false);
|
||||||
|
if (r < 0)
|
||||||
|
return log_error_errno(r, "Failed to write introspection data: %m");
|
||||||
|
|
||||||
|
r = introspect_write_default_interfaces(&intro, impl->manager);
|
||||||
|
if (r < 0)
|
||||||
|
return log_error_errno(r, "Failed to write introspection data: %m");
|
||||||
|
|
||||||
|
/* Check if there is a non-fallback path that applies to the given interface, also
|
||||||
|
* print it. This is useful in the case of units: o.fd.systemd1.Service is declared
|
||||||
|
* as a fallback vtable for o/fd/systemd1/unit, and we also want to print
|
||||||
|
* o.fd.systemd1.Unit, which is the non-fallback implementation. */
|
||||||
|
if (impl->fallback_vtables && is_interface)
|
||||||
|
main_impl = find_implementation(impl->path, bus_objects);
|
||||||
|
|
||||||
|
if (main_impl)
|
||||||
|
bus_introspect_implementation(&intro, main_impl);
|
||||||
|
|
||||||
|
if (impl != main_impl)
|
||||||
|
bus_introspect_implementation(&intro, impl);
|
||||||
|
|
||||||
|
_cleanup_set_free_ Set *nodes = NULL;
|
||||||
|
|
||||||
|
for (size_t i = 0; impl->children && impl->children[i]; i++) {
|
||||||
|
r = set_put_strdup(&nodes, impl->children[i]->path);
|
||||||
|
if (r < 0)
|
||||||
|
return log_oom();
|
||||||
|
}
|
||||||
|
|
||||||
|
r = introspect_write_child_nodes(&intro, nodes, impl->path);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
r = introspect_finish(&intro, &s);
|
||||||
|
if (r < 0)
|
||||||
|
return log_error_errno(r, "Failed to write introspection data: %m");
|
||||||
|
|
||||||
|
fputs(s, out);
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "sd-bus.h"
|
||||||
|
|
||||||
|
typedef struct BusObjectImplementation BusObjectImplementation;
|
||||||
|
|
||||||
|
typedef struct BusObjectVtablePair {
|
||||||
|
const sd_bus_vtable *vtable;
|
||||||
|
sd_bus_object_find_t object_find;
|
||||||
|
} BusObjectVtablePair;
|
||||||
|
|
||||||
|
struct BusObjectImplementation {
|
||||||
|
const char *path;
|
||||||
|
const char *interface;
|
||||||
|
const sd_bus_vtable **vtables;
|
||||||
|
const BusObjectVtablePair *fallback_vtables;
|
||||||
|
sd_bus_node_enumerator_t node_enumerator;
|
||||||
|
bool manager;
|
||||||
|
const BusObjectImplementation **children;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define BUS_VTABLES(...) ((const sd_bus_vtable* []){ __VA_ARGS__, NULL })
|
||||||
|
#define BUS_FALLBACK_VTABLES(...) ((const BusObjectVtablePair[]) { __VA_ARGS__, {} })
|
||||||
|
#define BUS_IMPLEMENTATIONS(...) ((const BusObjectImplementation* []) { __VA_ARGS__, NULL })
|
||||||
|
|
||||||
|
int bus_add_implementation(sd_bus *bus, const BusObjectImplementation *impl, void *userdata);
|
||||||
|
int bus_introspect_implementations(
|
||||||
|
FILE *out,
|
||||||
|
const char *pattern,
|
||||||
|
const BusObjectImplementation* const* bus_objects);
|
|
@ -0,0 +1,462 @@
|
||||||
|
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||||
|
|
||||||
|
#include "bus-print-properties.h"
|
||||||
|
#include "cap-list.h"
|
||||||
|
#include "cgroup-util.h"
|
||||||
|
#include "escape.h"
|
||||||
|
#include "mountpoint-util.h"
|
||||||
|
#include "nsflags.h"
|
||||||
|
#include "parse-util.h"
|
||||||
|
#include "stdio-util.h"
|
||||||
|
#include "string-util.h"
|
||||||
|
#include "strv.h"
|
||||||
|
#include "time-util.h"
|
||||||
|
#include "user-util.h"
|
||||||
|
|
||||||
|
int bus_print_property_value(const char *name, const char *expected_value, bool only_value, const char *value) {
|
||||||
|
assert(name);
|
||||||
|
|
||||||
|
if (expected_value && !streq_ptr(expected_value, value))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (only_value)
|
||||||
|
puts(value);
|
||||||
|
else
|
||||||
|
printf("%s=%s\n", name, value);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int bus_print_property_valuef(const char *name, const char *expected_value, bool only_value, const char *fmt, ...) {
|
||||||
|
va_list ap;
|
||||||
|
int r;
|
||||||
|
|
||||||
|
assert(name);
|
||||||
|
assert(fmt);
|
||||||
|
|
||||||
|
if (expected_value) {
|
||||||
|
_cleanup_free_ char *s = NULL;
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
|
r = vasprintf(&s, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
if (r < 0)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
if (streq_ptr(expected_value, s)) {
|
||||||
|
if (only_value)
|
||||||
|
puts(s);
|
||||||
|
else
|
||||||
|
printf("%s=%s\n", name, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!only_value)
|
||||||
|
printf("%s=", name);
|
||||||
|
va_start(ap, fmt);
|
||||||
|
vprintf(fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
puts("");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int bus_print_property(const char *name, const char *expected_value, sd_bus_message *m, bool value, bool all) {
|
||||||
|
char type;
|
||||||
|
const char *contents;
|
||||||
|
int r;
|
||||||
|
|
||||||
|
assert(name);
|
||||||
|
assert(m);
|
||||||
|
|
||||||
|
r = sd_bus_message_peek_type(m, &type, &contents);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
|
||||||
|
case SD_BUS_TYPE_STRING: {
|
||||||
|
const char *s;
|
||||||
|
|
||||||
|
r = sd_bus_message_read_basic(m, type, &s);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
if (all || !isempty(s)) {
|
||||||
|
bool good;
|
||||||
|
|
||||||
|
/* This property has a single value, so we need to take
|
||||||
|
* care not to print a new line, everything else is OK. */
|
||||||
|
good = !strchr(s, '\n');
|
||||||
|
bus_print_property_value(name, expected_value, value, good ? s : "[unprintable]");
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
case SD_BUS_TYPE_BOOLEAN: {
|
||||||
|
int b;
|
||||||
|
|
||||||
|
r = sd_bus_message_read_basic(m, type, &b);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
if (expected_value && parse_boolean(expected_value) != b)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
bus_print_property_value(name, NULL, value, yes_no(b));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
case SD_BUS_TYPE_UINT64: {
|
||||||
|
uint64_t u;
|
||||||
|
|
||||||
|
r = sd_bus_message_read_basic(m, type, &u);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
/* Yes, heuristics! But we can change this check
|
||||||
|
* should it turn out to not be sufficient */
|
||||||
|
|
||||||
|
if (endswith(name, "Timestamp") ||
|
||||||
|
STR_IN_SET(name, "NextElapseUSecRealtime", "LastTriggerUSec", "TimeUSec", "RTCTimeUSec")) {
|
||||||
|
char timestamp[FORMAT_TIMESTAMP_MAX];
|
||||||
|
const char *t;
|
||||||
|
|
||||||
|
t = format_timestamp(timestamp, sizeof(timestamp), u);
|
||||||
|
if (t || all)
|
||||||
|
bus_print_property_value(name, expected_value, value, strempty(t));
|
||||||
|
|
||||||
|
} else if (strstr(name, "USec")) {
|
||||||
|
char timespan[FORMAT_TIMESPAN_MAX];
|
||||||
|
|
||||||
|
(void) format_timespan(timespan, sizeof(timespan), u, 0);
|
||||||
|
bus_print_property_value(name, expected_value, value, timespan);
|
||||||
|
|
||||||
|
} else if (streq(name, "CoredumpFilter")) {
|
||||||
|
char buf[STRLEN("0xFFFFFFFF")];
|
||||||
|
|
||||||
|
xsprintf(buf, "0x%"PRIx64, u);
|
||||||
|
bus_print_property_value(name, expected_value, value, buf);
|
||||||
|
|
||||||
|
} else if (streq(name, "RestrictNamespaces")) {
|
||||||
|
_cleanup_free_ char *s = NULL;
|
||||||
|
const char *result;
|
||||||
|
|
||||||
|
if ((u & NAMESPACE_FLAGS_ALL) == 0)
|
||||||
|
result = "yes";
|
||||||
|
else if (FLAGS_SET(u, NAMESPACE_FLAGS_ALL))
|
||||||
|
result = "no";
|
||||||
|
else {
|
||||||
|
r = namespace_flags_to_string(u, &s);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
result = strempty(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
bus_print_property_value(name, expected_value, value, result);
|
||||||
|
|
||||||
|
} else if (streq(name, "MountFlags")) {
|
||||||
|
const char *result;
|
||||||
|
|
||||||
|
result = mount_propagation_flags_to_string(u);
|
||||||
|
if (!result)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
bus_print_property_value(name, expected_value, value, result);
|
||||||
|
|
||||||
|
} else if (STR_IN_SET(name, "CapabilityBoundingSet", "AmbientCapabilities")) {
|
||||||
|
_cleanup_free_ char *s = NULL;
|
||||||
|
|
||||||
|
r = capability_set_to_string_alloc(u, &s);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
bus_print_property_value(name, expected_value, value, s);
|
||||||
|
|
||||||
|
} else if ((STR_IN_SET(name, "CPUWeight", "StartupCPUWeight", "IOWeight", "StartupIOWeight") && u == CGROUP_WEIGHT_INVALID) ||
|
||||||
|
(STR_IN_SET(name, "CPUShares", "StartupCPUShares") && u == CGROUP_CPU_SHARES_INVALID) ||
|
||||||
|
(STR_IN_SET(name, "BlockIOWeight", "StartupBlockIOWeight") && u == CGROUP_BLKIO_WEIGHT_INVALID) ||
|
||||||
|
(STR_IN_SET(name, "MemoryCurrent", "TasksCurrent") && u == (uint64_t) -1) ||
|
||||||
|
(endswith(name, "NSec") && u == (uint64_t) -1))
|
||||||
|
|
||||||
|
bus_print_property_value(name, expected_value, value, "[not set]");
|
||||||
|
|
||||||
|
else if ((STR_IN_SET(name, "DefaultMemoryLow", "DefaultMemoryMin", "MemoryLow", "MemoryHigh", "MemoryMax", "MemorySwapMax", "MemoryLimit") && u == CGROUP_LIMIT_MAX) ||
|
||||||
|
(STR_IN_SET(name, "TasksMax", "DefaultTasksMax") && u == (uint64_t) -1) ||
|
||||||
|
(startswith(name, "Limit") && u == (uint64_t) -1) ||
|
||||||
|
(startswith(name, "DefaultLimit") && u == (uint64_t) -1))
|
||||||
|
|
||||||
|
bus_print_property_value(name, expected_value, value, "infinity");
|
||||||
|
else if (STR_IN_SET(name, "IPIngressBytes", "IPIngressPackets", "IPEgressBytes", "IPEgressPackets") && u == (uint64_t) -1)
|
||||||
|
bus_print_property_value(name, expected_value, value, "[no data]");
|
||||||
|
else
|
||||||
|
bus_print_property_valuef(name, expected_value, value, "%"PRIu64, u);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
case SD_BUS_TYPE_INT64: {
|
||||||
|
int64_t i;
|
||||||
|
|
||||||
|
r = sd_bus_message_read_basic(m, type, &i);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
bus_print_property_valuef(name, expected_value, value, "%"PRIi64, i);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
case SD_BUS_TYPE_UINT32: {
|
||||||
|
uint32_t u;
|
||||||
|
|
||||||
|
r = sd_bus_message_read_basic(m, type, &u);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
if (strstr(name, "UMask") || strstr(name, "Mode"))
|
||||||
|
bus_print_property_valuef(name, expected_value, value, "%04o", u);
|
||||||
|
|
||||||
|
else if (streq(name, "UID")) {
|
||||||
|
if (u == UID_INVALID)
|
||||||
|
bus_print_property_value(name, expected_value, value, "[not set]");
|
||||||
|
else
|
||||||
|
bus_print_property_valuef(name, expected_value, value, "%"PRIu32, u);
|
||||||
|
} else if (streq(name, "GID")) {
|
||||||
|
if (u == GID_INVALID)
|
||||||
|
bus_print_property_value(name, expected_value, value, "[not set]");
|
||||||
|
else
|
||||||
|
bus_print_property_valuef(name, expected_value, value, "%"PRIu32, u);
|
||||||
|
} else
|
||||||
|
bus_print_property_valuef(name, expected_value, value, "%"PRIu32, u);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
case SD_BUS_TYPE_INT32: {
|
||||||
|
int32_t i;
|
||||||
|
|
||||||
|
r = sd_bus_message_read_basic(m, type, &i);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
bus_print_property_valuef(name, expected_value, value, "%"PRIi32, i);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
case SD_BUS_TYPE_DOUBLE: {
|
||||||
|
double d;
|
||||||
|
|
||||||
|
r = sd_bus_message_read_basic(m, type, &d);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
bus_print_property_valuef(name, expected_value, value, "%g", d);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
case SD_BUS_TYPE_ARRAY:
|
||||||
|
if (streq(contents, "s")) {
|
||||||
|
bool first = true;
|
||||||
|
const char *str;
|
||||||
|
|
||||||
|
r = sd_bus_message_enter_container(m, SD_BUS_TYPE_ARRAY, contents);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
while ((r = sd_bus_message_read_basic(m, SD_BUS_TYPE_STRING, &str)) > 0) {
|
||||||
|
_cleanup_free_ char *e = NULL;
|
||||||
|
|
||||||
|
e = shell_maybe_quote(str, ESCAPE_BACKSLASH_ONELINE);
|
||||||
|
if (!e)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
if (first) {
|
||||||
|
if (!value)
|
||||||
|
printf("%s=", name);
|
||||||
|
first = false;
|
||||||
|
} else
|
||||||
|
fputs(" ", stdout);
|
||||||
|
|
||||||
|
fputs(e, stdout);
|
||||||
|
}
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
if (first && all && !value)
|
||||||
|
printf("%s=", name);
|
||||||
|
if (!first || all)
|
||||||
|
puts("");
|
||||||
|
|
||||||
|
r = sd_bus_message_exit_container(m);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
} else if (streq(contents, "y")) {
|
||||||
|
const uint8_t *u;
|
||||||
|
size_t n;
|
||||||
|
|
||||||
|
r = sd_bus_message_read_array(m, SD_BUS_TYPE_BYTE, (const void**) &u, &n);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
if (all || n > 0) {
|
||||||
|
unsigned i;
|
||||||
|
|
||||||
|
if (!value)
|
||||||
|
printf("%s=", name);
|
||||||
|
|
||||||
|
for (i = 0; i < n; i++)
|
||||||
|
printf("%02x", u[i]);
|
||||||
|
|
||||||
|
puts("");
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
} else if (streq(contents, "u")) {
|
||||||
|
uint32_t *u;
|
||||||
|
size_t n;
|
||||||
|
|
||||||
|
r = sd_bus_message_read_array(m, SD_BUS_TYPE_UINT32, (const void**) &u, &n);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
if (all || n > 0) {
|
||||||
|
unsigned i;
|
||||||
|
|
||||||
|
if (!value)
|
||||||
|
printf("%s=", name);
|
||||||
|
|
||||||
|
for (i = 0; i < n; i++)
|
||||||
|
printf("%08x", u[i]);
|
||||||
|
|
||||||
|
puts("");
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int bus_message_print_all_properties(
|
||||||
|
sd_bus_message *m,
|
||||||
|
bus_message_print_t func,
|
||||||
|
char **filter,
|
||||||
|
bool value,
|
||||||
|
bool all,
|
||||||
|
Set **found_properties) {
|
||||||
|
|
||||||
|
int r;
|
||||||
|
|
||||||
|
assert(m);
|
||||||
|
|
||||||
|
r = sd_bus_message_enter_container(m, SD_BUS_TYPE_ARRAY, "{sv}");
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
while ((r = sd_bus_message_enter_container(m, SD_BUS_TYPE_DICT_ENTRY, "sv")) > 0) {
|
||||||
|
_cleanup_free_ char *name_with_equal = NULL;
|
||||||
|
const char *name, *contents, *expected_value = NULL;
|
||||||
|
|
||||||
|
r = sd_bus_message_read_basic(m, SD_BUS_TYPE_STRING, &name);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
if (found_properties) {
|
||||||
|
r = set_ensure_put(found_properties, &string_hash_ops, name);
|
||||||
|
if (r < 0)
|
||||||
|
return log_oom();
|
||||||
|
}
|
||||||
|
|
||||||
|
name_with_equal = strjoin(name, "=");
|
||||||
|
if (!name_with_equal)
|
||||||
|
return log_oom();
|
||||||
|
|
||||||
|
if (!filter || strv_find(filter, name) ||
|
||||||
|
(expected_value = strv_find_startswith(filter, name_with_equal))) {
|
||||||
|
r = sd_bus_message_peek_type(m, NULL, &contents);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
r = sd_bus_message_enter_container(m, SD_BUS_TYPE_VARIANT, contents);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
if (func)
|
||||||
|
r = func(name, expected_value, m, value, all);
|
||||||
|
if (!func || r == 0)
|
||||||
|
r = bus_print_property(name, expected_value, m, value, all);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
if (r == 0) {
|
||||||
|
if (all && !expected_value)
|
||||||
|
printf("%s=[unprintable]\n", name);
|
||||||
|
/* skip what we didn't read */
|
||||||
|
r = sd_bus_message_skip(m, contents);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
r = sd_bus_message_exit_container(m);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
} else {
|
||||||
|
r = sd_bus_message_skip(m, "v");
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
r = sd_bus_message_exit_container(m);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
r = sd_bus_message_exit_container(m);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int bus_print_all_properties(
|
||||||
|
sd_bus *bus,
|
||||||
|
const char *dest,
|
||||||
|
const char *path,
|
||||||
|
bus_message_print_t func,
|
||||||
|
char **filter,
|
||||||
|
bool value,
|
||||||
|
bool all,
|
||||||
|
Set **found_properties) {
|
||||||
|
|
||||||
|
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
|
||||||
|
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
|
||||||
|
int r;
|
||||||
|
|
||||||
|
assert(bus);
|
||||||
|
assert(path);
|
||||||
|
|
||||||
|
r = sd_bus_call_method(bus,
|
||||||
|
dest,
|
||||||
|
path,
|
||||||
|
"org.freedesktop.DBus.Properties",
|
||||||
|
"GetAll",
|
||||||
|
&error,
|
||||||
|
&reply,
|
||||||
|
"s", "");
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
return bus_message_print_all_properties(reply, func, filter, value, all, found_properties);
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#include "sd-bus.h"
|
||||||
|
|
||||||
|
#include "macro.h"
|
||||||
|
#include "set.h"
|
||||||
|
|
||||||
|
typedef int (*bus_message_print_t) (const char *name, const char *expected_value, sd_bus_message *m, bool value, bool all);
|
||||||
|
|
||||||
|
int bus_print_property_value(const char *name, const char *expected_value, bool only_value, const char *value);
|
||||||
|
int bus_print_property_valuef(const char *name, const char *expected_value, bool only_value, const char *fmt, ...) _printf_(4,5);
|
||||||
|
int bus_message_print_all_properties(sd_bus_message *m, bus_message_print_t func, char **filter, bool value, bool all, Set **found_properties);
|
||||||
|
int bus_print_all_properties(sd_bus *bus, const char *dest, const char *path, bus_message_print_t func, char **filter, bool value, bool all, Set **found_properties);
|
File diff suppressed because it is too large
Load Diff
|
@ -9,9 +9,7 @@
|
||||||
#include "sd-bus.h"
|
#include "sd-bus.h"
|
||||||
#include "sd-event.h"
|
#include "sd-event.h"
|
||||||
|
|
||||||
#include "bus-locator.h"
|
|
||||||
#include "macro.h"
|
#include "macro.h"
|
||||||
#include "set.h"
|
|
||||||
#include "string-util.h"
|
#include "string-util.h"
|
||||||
#include "time-util.h"
|
#include "time-util.h"
|
||||||
|
|
||||||
|
@ -23,47 +21,6 @@ typedef enum BusTransport {
|
||||||
_BUS_TRANSPORT_INVALID = -1
|
_BUS_TRANSPORT_INVALID = -1
|
||||||
} BusTransport;
|
} BusTransport;
|
||||||
|
|
||||||
typedef struct BusObjectImplementation BusObjectImplementation;
|
|
||||||
|
|
||||||
typedef struct BusObjectVtablePair {
|
|
||||||
const sd_bus_vtable *vtable;
|
|
||||||
sd_bus_object_find_t object_find;
|
|
||||||
} BusObjectVtablePair;
|
|
||||||
|
|
||||||
struct BusObjectImplementation {
|
|
||||||
const char *path;
|
|
||||||
const char *interface;
|
|
||||||
const sd_bus_vtable **vtables;
|
|
||||||
const BusObjectVtablePair *fallback_vtables;
|
|
||||||
sd_bus_node_enumerator_t node_enumerator;
|
|
||||||
bool manager;
|
|
||||||
const BusObjectImplementation **children;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define BUS_VTABLES(...) ((const sd_bus_vtable* []){ __VA_ARGS__, NULL })
|
|
||||||
#define BUS_FALLBACK_VTABLES(...) ((const BusObjectVtablePair[]) { __VA_ARGS__, {} })
|
|
||||||
#define BUS_IMPLEMENTATIONS(...) ((const BusObjectImplementation* []) { __VA_ARGS__, NULL })
|
|
||||||
|
|
||||||
typedef int (*bus_property_set_t) (sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_error *error, void *userdata);
|
|
||||||
|
|
||||||
struct bus_properties_map {
|
|
||||||
const char *member;
|
|
||||||
const char *signature;
|
|
||||||
bus_property_set_t set;
|
|
||||||
size_t offset;
|
|
||||||
};
|
|
||||||
|
|
||||||
enum {
|
|
||||||
BUS_MAP_STRDUP = 1 << 0, /* If set, each "s" message is duplicated. Thus, each pointer needs to be freed. */
|
|
||||||
BUS_MAP_BOOLEAN_AS_BOOL = 1 << 1, /* If set, each "b" message is written to a bool pointer. If not set, "b" is written to a int pointer. */
|
|
||||||
};
|
|
||||||
|
|
||||||
int bus_map_id128(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_error *error, void *userdata);
|
|
||||||
|
|
||||||
int bus_message_map_all_properties(sd_bus_message *m, const struct bus_properties_map *map, unsigned flags, sd_bus_error *error, void *userdata);
|
|
||||||
int bus_map_all_properties(sd_bus *bus, const char *destination, const char *path, const struct bus_properties_map *map,
|
|
||||||
unsigned flags, sd_bus_error *error, sd_bus_message **reply, void *userdata);
|
|
||||||
|
|
||||||
int bus_async_unregister_and_exit(sd_event *e, sd_bus *bus, const char *name);
|
int bus_async_unregister_and_exit(sd_event *e, sd_bus *bus, const char *name);
|
||||||
|
|
||||||
typedef bool (*check_idle_t)(void *userdata);
|
typedef bool (*check_idle_t)(void *userdata);
|
||||||
|
@ -80,117 +37,15 @@ int bus_connect_user_systemd(sd_bus **_bus);
|
||||||
int bus_connect_transport(BusTransport transport, const char *host, bool user, sd_bus **bus);
|
int bus_connect_transport(BusTransport transport, const char *host, bool user, sd_bus **bus);
|
||||||
int bus_connect_transport_systemd(BusTransport transport, const char *host, bool user, sd_bus **bus);
|
int bus_connect_transport_systemd(BusTransport transport, const char *host, bool user, sd_bus **bus);
|
||||||
|
|
||||||
typedef int (*bus_message_print_t) (const char *name, const char *expected_value, sd_bus_message *m, bool value, bool all);
|
|
||||||
|
|
||||||
int bus_print_property_value(const char *name, const char *expected_value, bool only_value, const char *value);
|
|
||||||
int bus_print_property_valuef(const char *name, const char *expected_value, bool only_value, const char *fmt, ...) _printf_(4,5);
|
|
||||||
int bus_message_print_all_properties(sd_bus_message *m, bus_message_print_t func, char **filter, bool value, bool all, Set **found_properties);
|
|
||||||
int bus_print_all_properties(sd_bus *bus, const char *dest, const char *path, bus_message_print_t func, char **filter, bool value, bool all, Set **found_properties);
|
|
||||||
|
|
||||||
int bus_property_get_bool(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error);
|
|
||||||
int bus_property_set_bool(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *value, void *userdata, sd_bus_error *error);
|
|
||||||
int bus_property_get_id128(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error);
|
|
||||||
|
|
||||||
#define bus_property_get_usec ((sd_bus_property_get_t) NULL)
|
|
||||||
#define bus_property_set_usec ((sd_bus_property_set_t) NULL)
|
|
||||||
|
|
||||||
assert_cc(sizeof(int) == sizeof(int32_t));
|
|
||||||
#define bus_property_get_int ((sd_bus_property_get_t) NULL)
|
|
||||||
|
|
||||||
assert_cc(sizeof(unsigned) == sizeof(uint32_t));
|
|
||||||
#define bus_property_get_unsigned ((sd_bus_property_get_t) NULL)
|
|
||||||
|
|
||||||
/* On 64bit machines we can use the default serializer for size_t and
|
|
||||||
* friends, otherwise we need to cast this manually */
|
|
||||||
#if __SIZEOF_SIZE_T__ == 8
|
|
||||||
#define bus_property_get_size ((sd_bus_property_get_t) NULL)
|
|
||||||
#else
|
|
||||||
int bus_property_get_size(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if __SIZEOF_LONG__ == 8
|
|
||||||
#define bus_property_get_long ((sd_bus_property_get_t) NULL)
|
|
||||||
#define bus_property_get_ulong ((sd_bus_property_get_t) NULL)
|
|
||||||
#else
|
|
||||||
int bus_property_get_long(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error);
|
|
||||||
int bus_property_get_ulong(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* uid_t and friends on Linux 32 bit. This means we can just use the
|
|
||||||
* default serializer for 32bit unsigned, for serializing it, and map
|
|
||||||
* it to NULL here */
|
|
||||||
assert_cc(sizeof(uid_t) == sizeof(uint32_t));
|
|
||||||
#define bus_property_get_uid ((sd_bus_property_get_t) NULL)
|
|
||||||
|
|
||||||
assert_cc(sizeof(gid_t) == sizeof(uint32_t));
|
|
||||||
#define bus_property_get_gid ((sd_bus_property_get_t) NULL)
|
|
||||||
|
|
||||||
assert_cc(sizeof(pid_t) == sizeof(uint32_t));
|
|
||||||
#define bus_property_get_pid ((sd_bus_property_get_t) NULL)
|
|
||||||
|
|
||||||
assert_cc(sizeof(mode_t) == sizeof(uint32_t));
|
|
||||||
#define bus_property_get_mode ((sd_bus_property_get_t) NULL)
|
|
||||||
|
|
||||||
#define bus_log_parse_error(r) \
|
#define bus_log_parse_error(r) \
|
||||||
log_error_errno(r, "Failed to parse bus message: %m")
|
log_error_errno(r, "Failed to parse bus message: %m")
|
||||||
|
|
||||||
#define bus_log_create_error(r) \
|
#define bus_log_create_error(r) \
|
||||||
log_error_errno(r, "Failed to create bus message: %m")
|
log_error_errno(r, "Failed to create bus message: %m")
|
||||||
|
|
||||||
#define BUS_DEFINE_PROPERTY_GET_GLOBAL(function, bus_type, val) \
|
|
||||||
int function(sd_bus *bus, \
|
|
||||||
const char *path, \
|
|
||||||
const char *interface, \
|
|
||||||
const char *property, \
|
|
||||||
sd_bus_message *reply, \
|
|
||||||
void *userdata, \
|
|
||||||
sd_bus_error *error) { \
|
|
||||||
\
|
|
||||||
assert(bus); \
|
|
||||||
assert(reply); \
|
|
||||||
\
|
|
||||||
return sd_bus_message_append(reply, bus_type, val); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define BUS_DEFINE_PROPERTY_GET2(function, bus_type, data_type, get1, get2) \
|
|
||||||
int function(sd_bus *bus, \
|
|
||||||
const char *path, \
|
|
||||||
const char *interface, \
|
|
||||||
const char *property, \
|
|
||||||
sd_bus_message *reply, \
|
|
||||||
void *userdata, \
|
|
||||||
sd_bus_error *error) { \
|
|
||||||
\
|
|
||||||
data_type *data = userdata; \
|
|
||||||
\
|
|
||||||
assert(bus); \
|
|
||||||
assert(reply); \
|
|
||||||
assert(data); \
|
|
||||||
\
|
|
||||||
return sd_bus_message_append(reply, bus_type, \
|
|
||||||
get2(get1(data))); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define ident(x) (x)
|
|
||||||
#define BUS_DEFINE_PROPERTY_GET(function, bus_type, data_type, get1) \
|
|
||||||
BUS_DEFINE_PROPERTY_GET2(function, bus_type, data_type, get1, ident)
|
|
||||||
|
|
||||||
#define ref(x) (*(x))
|
|
||||||
#define BUS_DEFINE_PROPERTY_GET_REF(function, bus_type, data_type, get) \
|
|
||||||
BUS_DEFINE_PROPERTY_GET2(function, bus_type, data_type, ref, get)
|
|
||||||
|
|
||||||
#define BUS_DEFINE_PROPERTY_GET_ENUM(function, name, type) \
|
|
||||||
BUS_DEFINE_PROPERTY_GET_REF(function, "s", type, name##_to_string)
|
|
||||||
|
|
||||||
#define BUS_PROPERTY_DUAL_TIMESTAMP(name, offset, flags) \
|
|
||||||
SD_BUS_PROPERTY(name, "t", bus_property_get_usec, (offset) + offsetof(struct dual_timestamp, realtime), (flags)), \
|
|
||||||
SD_BUS_PROPERTY(name "Monotonic", "t", bus_property_get_usec, (offset) + offsetof(struct dual_timestamp, monotonic), (flags))
|
|
||||||
|
|
||||||
int bus_path_encode_unique(sd_bus *b, const char *prefix, const char *sender_id, const char *external_id, char **ret_path);
|
int bus_path_encode_unique(sd_bus *b, const char *prefix, const char *sender_id, const char *external_id, char **ret_path);
|
||||||
int bus_path_decode_unique(const char *path, const char *prefix, char **ret_sender, char **ret_external);
|
int bus_path_decode_unique(const char *path, const char *prefix, char **ret_sender, char **ret_external);
|
||||||
|
|
||||||
int bus_property_get_rlimit(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error);
|
|
||||||
|
|
||||||
int bus_track_add_name_many(sd_bus_track *t, char **l);
|
int bus_track_add_name_many(sd_bus_track *t, char **l);
|
||||||
|
|
||||||
int bus_open_system_watch_bind_with_description(sd_bus **ret, const char *description);
|
int bus_open_system_watch_bind_with_description(sd_bus **ret, const char *description);
|
||||||
|
@ -201,23 +56,3 @@ static inline int bus_open_system_watch_bind(sd_bus **ret) {
|
||||||
int bus_reply_pair_array(sd_bus_message *m, char **l);
|
int bus_reply_pair_array(sd_bus_message *m, char **l);
|
||||||
|
|
||||||
extern const struct hash_ops bus_message_hash_ops;
|
extern const struct hash_ops bus_message_hash_ops;
|
||||||
|
|
||||||
/* Shorthand flavors of the sd-bus convenience helpers with destination,path,interface
|
|
||||||
* strings encapsulated within a single struct.
|
|
||||||
*/
|
|
||||||
int bus_call_method_async(sd_bus *bus, sd_bus_slot **slot, const BusLocator *locator, const char *member, sd_bus_message_handler_t callback, void *userdata, const char *types, ...);
|
|
||||||
int bus_call_method(sd_bus *bus, const BusLocator *locator, const char *member, sd_bus_error *error, sd_bus_message **reply, const char *types, ...);
|
|
||||||
int bus_get_property(sd_bus *bus, const BusLocator *locator, const char *member, sd_bus_error *error, sd_bus_message **reply, const char *type);
|
|
||||||
int bus_get_property_trivial(sd_bus *bus, const BusLocator *locator, const char *member, sd_bus_error *error, char type, void *ptr);
|
|
||||||
int bus_get_property_string(sd_bus *bus, const BusLocator *locator, const char *member, sd_bus_error *error, char **ret);
|
|
||||||
int bus_get_property_strv(sd_bus *bus, const BusLocator *locator, const char *member, sd_bus_error *error, char ***ret);
|
|
||||||
int bus_set_property(sd_bus *bus, const BusLocator *locator, const char *member, sd_bus_error *error, const char *type, ...);
|
|
||||||
int bus_match_signal(sd_bus *bus, sd_bus_slot **ret, const BusLocator *locator, const char *member, sd_bus_message_handler_t callback, void *userdata);
|
|
||||||
int bus_match_signal_async(sd_bus *bus, sd_bus_slot **ret, const BusLocator *locator, const char *member, sd_bus_message_handler_t callback, sd_bus_message_handler_t install_callback, void *userdata);
|
|
||||||
int bus_message_new_method_call(sd_bus *bus, sd_bus_message **m, const BusLocator *locator, const char *member);
|
|
||||||
|
|
||||||
int bus_add_implementation(sd_bus *bus, const BusObjectImplementation *impl, void *userdata);
|
|
||||||
int bus_introspect_implementations(
|
|
||||||
FILE *out,
|
|
||||||
const char *pattern,
|
|
||||||
const BusObjectImplementation* const* bus_objects);
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||||
|
|
||||||
#include "bus-util.h"
|
#include "bus-map-properties.h"
|
||||||
#include "bus-wait-for-units.h"
|
#include "bus-wait-for-units.h"
|
||||||
#include "hashmap.h"
|
#include "hashmap.h"
|
||||||
#include "string-util.h"
|
#include "string-util.h"
|
||||||
|
|
|
@ -27,12 +27,20 @@ shared_sources = files('''
|
||||||
bpf-program.h
|
bpf-program.h
|
||||||
bridge-util.c
|
bridge-util.c
|
||||||
bridge-util.h
|
bridge-util.h
|
||||||
|
bus-get-properties.c
|
||||||
|
bus-get-properties.h
|
||||||
bus-locator.c
|
bus-locator.c
|
||||||
bus-locator.h
|
bus-locator.h
|
||||||
bus-log-control-api.c
|
bus-log-control-api.c
|
||||||
bus-log-control-api.h
|
bus-log-control-api.h
|
||||||
|
bus-map-properties.c
|
||||||
|
bus-map-properties.h
|
||||||
|
bus-object.c
|
||||||
|
bus-object.h
|
||||||
bus-polkit.c
|
bus-polkit.c
|
||||||
bus-polkit.h
|
bus-polkit.h
|
||||||
|
bus-print-properties.c
|
||||||
|
bus-print-properties.h
|
||||||
bus-unit-procs.c
|
bus-unit-procs.c
|
||||||
bus-unit-procs.h
|
bus-unit-procs.h
|
||||||
bus-unit-util.c
|
bus-unit-util.c
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "bus-util.h"
|
#include "bus-object.h"
|
||||||
|
|
||||||
int service_parse_argv(
|
int service_parse_argv(
|
||||||
const char *service,
|
const char *service,
|
||||||
|
|
|
@ -20,10 +20,12 @@
|
||||||
#include "bootspec.h"
|
#include "bootspec.h"
|
||||||
#include "bus-common-errors.h"
|
#include "bus-common-errors.h"
|
||||||
#include "bus-error.h"
|
#include "bus-error.h"
|
||||||
|
#include "bus-locator.h"
|
||||||
|
#include "bus-map-properties.h"
|
||||||
#include "bus-message.h"
|
#include "bus-message.h"
|
||||||
|
#include "bus-print-properties.h"
|
||||||
#include "bus-unit-procs.h"
|
#include "bus-unit-procs.h"
|
||||||
#include "bus-unit-util.h"
|
#include "bus-unit-util.h"
|
||||||
#include "bus-util.h"
|
|
||||||
#include "bus-wait-for-jobs.h"
|
#include "bus-wait-for-jobs.h"
|
||||||
#include "bus-wait-for-units.h"
|
#include "bus-wait-for-units.h"
|
||||||
#include "cgroup-show.h"
|
#include "cgroup-show.h"
|
||||||
|
|
|
@ -9,15 +9,17 @@
|
||||||
#include "sd-bus.h"
|
#include "sd-bus.h"
|
||||||
|
|
||||||
#include "bus-error.h"
|
#include "bus-error.h"
|
||||||
#include "bus-util.h"
|
#include "bus-locator.h"
|
||||||
|
#include "bus-map-properties.h"
|
||||||
|
#include "bus-print-properties.h"
|
||||||
#include "format-table.h"
|
#include "format-table.h"
|
||||||
#include "in-addr-util.h"
|
#include "in-addr-util.h"
|
||||||
#include "main-func.h"
|
#include "main-func.h"
|
||||||
#include "pager.h"
|
#include "pager.h"
|
||||||
#include "parse-util.h"
|
#include "parse-util.h"
|
||||||
#include "pretty-print.h"
|
#include "pretty-print.h"
|
||||||
#include "spawn-polkit-agent.h"
|
|
||||||
#include "sparse-endian.h"
|
#include "sparse-endian.h"
|
||||||
|
#include "spawn-polkit-agent.h"
|
||||||
#include "string-table.h"
|
#include "string-table.h"
|
||||||
#include "strv.h"
|
#include "strv.h"
|
||||||
#include "terminal-util.h"
|
#include "terminal-util.h"
|
||||||
|
|
|
@ -12,9 +12,11 @@
|
||||||
#include "alloc-util.h"
|
#include "alloc-util.h"
|
||||||
#include "bus-common-errors.h"
|
#include "bus-common-errors.h"
|
||||||
#include "bus-error.h"
|
#include "bus-error.h"
|
||||||
|
#include "bus-get-properties.h"
|
||||||
|
#include "bus-locator.h"
|
||||||
#include "bus-log-control-api.h"
|
#include "bus-log-control-api.h"
|
||||||
|
#include "bus-map-properties.h"
|
||||||
#include "bus-polkit.h"
|
#include "bus-polkit.h"
|
||||||
#include "bus-util.h"
|
|
||||||
#include "clock-util.h"
|
#include "clock-util.h"
|
||||||
#include "conf-files.h"
|
#include "conf-files.h"
|
||||||
#include "def.h"
|
#include "def.h"
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "sd-bus.h"
|
#include "sd-bus.h"
|
||||||
|
|
||||||
#include "alloc-util.h"
|
#include "alloc-util.h"
|
||||||
|
#include "bus-get-properties.h"
|
||||||
#include "bus-internal.h"
|
#include "bus-internal.h"
|
||||||
#include "bus-log-control-api.h"
|
#include "bus-log-control-api.h"
|
||||||
#include "bus-protocol.h"
|
#include "bus-protocol.h"
|
||||||
|
|
|
@ -643,6 +643,13 @@ static int builtin_path_id(sd_device *dev, int argc, char *argv[], bool test) {
|
||||||
supported_parent = true;
|
supported_parent = true;
|
||||||
supported_transport = true;
|
supported_transport = true;
|
||||||
}
|
}
|
||||||
|
} else if (streq(subsys, "spi")) {
|
||||||
|
const char *sysnum;
|
||||||
|
|
||||||
|
if (sd_device_get_sysnum(parent, &sysnum) >= 0 && sysnum) {
|
||||||
|
path_prepend(&path, "cs-%s", sysnum);
|
||||||
|
parent = skip_subsystem(parent, "spi");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!parent)
|
if (!parent)
|
||||||
|
|
Loading…
Reference in New Issue