summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2023-03-30 16:38:47 +0200
committerLennart Poettering <lennart@poettering.net>2023-04-04 09:45:17 +0200
commitf2eb0c508fc384cdc1a04580bbe91d70dba192f3 (patch)
treedc2856da44b6889a29cca0e700010f54cb2a9ca3
parentb3a3ed2d5019c9663e3225464b365328678baeb2 (diff)
downloadsystemd-f2eb0c508fc384cdc1a04580bbe91d70dba192f3.tar.gz
service: dump fdstore contents also in free-form debug dump
-rw-r--r--src/core/service.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/core/service.c b/src/core/service.c
index df1af81318..bebcf5cb5f 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -17,6 +17,7 @@
#include "constants.h"
#include "dbus-service.h"
#include "dbus-unit.h"
+#include "devnum-util.h"
#include "env-util.h"
#include "escape.h"
#include "exit-status.h"
@@ -874,6 +875,42 @@ static int service_load(Unit *u) {
return service_verify(s);
}
+static void service_dump_fdstore(Service *s, FILE *f, const char *prefix) {
+ assert(s);
+ assert(f);
+ assert(prefix);
+
+ LIST_FOREACH(fd_store, i, s->fd_store) {
+ _cleanup_free_ char *path = NULL;
+ struct stat st;
+ int flags;
+
+ if (fstat(i->fd, &st) < 0) {
+ log_debug_errno(errno, "Failed to stat fdstore entry: %m");
+ continue;
+ }
+
+ flags = fcntl(i->fd, F_GETFL);
+ if (flags < 0) {
+ log_debug_errno(errno, "Failed to get fdstore entry flags: %m");
+ continue;
+ }
+
+ (void) fd_get_path(i->fd, &path);
+
+ fprintf(f,
+ "%s%s '%s' (type=%s; dev=" DEVNUM_FORMAT_STR "; inode=%" PRIu64 "; rdev=" DEVNUM_FORMAT_STR "; path=%s; access=%s)\n",
+ prefix, i == s->fd_store ? "File Descriptor Store Entry:" : " ",
+ i->fdname,
+ inode_type_to_string(st.st_mode),
+ DEVNUM_FORMAT_VAL(st.st_dev),
+ (uint64_t) st.st_ino,
+ DEVNUM_FORMAT_VAL(st.st_rdev),
+ strna(path),
+ accmode_to_string(flags));
+ }
+}
+
static void service_dump(Unit *u, FILE *f, const char *prefix) {
Service *s = SERVICE(u);
const char *prefix2;
@@ -997,6 +1034,8 @@ static void service_dump(Unit *u, FILE *f, const char *prefix) {
prefix, s->n_fd_store_max,
prefix, s->n_fd_store);
+ service_dump_fdstore(s, f, prefix);
+
if (s->open_files)
LIST_FOREACH(open_files, of, s->open_files) {
_cleanup_free_ char *ofs = NULL;