1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-22 17:35:35 +03:00

busctl: show information of passed file descriptor

This commit is contained in:
Yu Watanabe 2024-10-13 13:17:26 +09:00
parent 60ae3b86fb
commit ba0d3d490f
2 changed files with 11 additions and 3 deletions

View File

@ -21,6 +21,7 @@
#include "fileio.h"
#include "format-table.h"
#include "glyph-util.h"
#include "json-util.h"
#include "log.h"
#include "main-func.h"
#include "memstream-util.h"
@ -2008,16 +2009,19 @@ static int json_transform_one(sd_bus_message *m, sd_json_variant **ret) {
break;
}
case SD_BUS_TYPE_UNIX_FD:
r = sd_bus_message_read_basic(m, type, NULL);
case SD_BUS_TYPE_UNIX_FD: {
int fd;
r = sd_bus_message_read_basic(m, type, &fd);
if (r < 0)
return bus_log_parse_error(r);
r = sd_json_variant_new_null(&v);
r = json_variant_new_fd_info(&v, fd);
if (r < 0)
return log_error_errno(r, "Failed to transform fd: %m");
break;
}
case SD_BUS_TYPE_ARRAY:
case SD_BUS_TYPE_VARIANT:

View File

@ -46,6 +46,10 @@ busctl call -j \
busctl call --verbose --timeout=60 --expect-reply=yes \
org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager \
ListUnitsByPatterns asas 1 "active" 2 "systemd-*.socket" "*.mount"
# show information passed fd
busctl call --json=pretty \
org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager \
DumpByFileDescriptor | jq
busctl emit /org/freedesktop/login1 org.freedesktop.login1.Manager \
PrepareForSleep b false