]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
mount,swap: include ExecStatus output in dump
authorLennart Poettering <lennart@poettering.net>
Wed, 24 Apr 2024 09:10:50 +0000 (11:10 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Wed, 24 Apr 2024 19:23:42 +0000 (21:23 +0200)
socket and service units output there ExecCommand/ExecStatus definitions
already, but this was missing in mount/swap. Fix that.

src/core/execute.c
src/core/execute.h
src/core/mount.c
src/core/swap.c

index cab74fdcc1046c66efee18fd06626e198fffe49d..26a4bf1b6f502f052209e8298736c6621acad62c 100644 (file)
@@ -1881,7 +1881,7 @@ void exec_status_dump(const ExecStatus *s, FILE *f, const char *prefix) {
                         prefix, s->status);
 }
 
-static void exec_command_dump(ExecCommand *c, FILE *f, const char *prefix) {
+void exec_command_dump(ExecCommand *c, FILE *f, const char *prefix) {
         _cleanup_free_ char *cmd = NULL;
         const char *prefix2;
 
index acca6e3152d40968284896608305022786e371a6..f6595cf93e19c3c50f666b9d9c5a18a3a448ba58 100644 (file)
@@ -497,6 +497,7 @@ void exec_command_free_array(ExecCommand **c, size_t n);
 void exec_command_reset_status_array(ExecCommand *c, size_t n);
 void exec_command_reset_status_list_array(ExecCommand **c, size_t n);
 
+void exec_command_dump(ExecCommand *c, FILE *f, const char *prefix);
 void exec_command_dump_list(ExecCommand *c, FILE *f, const char *prefix);
 void exec_command_append_list(ExecCommand **l, ExecCommand *e);
 int exec_command_set(ExecCommand *c, const char *path, ...) _sentinel_;
index 886ef8974cb00ee4f47b9dd1a394c5cf23ae033f..d70a60b37746f290ec8d114688905a024128b1fd 100644 (file)
@@ -810,9 +810,13 @@ static void mount_catchup(Unit *u) {
 static void mount_dump(Unit *u, FILE *f, const char *prefix) {
         Mount *m = ASSERT_PTR(MOUNT(u));
         MountParameters *p;
+        const char *prefix2;
 
         assert(f);
 
+        prefix = strempty(prefix);
+        prefix2 = strjoina(prefix, "\t");
+
         p = get_mount_parameters(m);
 
         fprintf(f,
@@ -857,6 +861,16 @@ static void mount_dump(Unit *u, FILE *f, const char *prefix) {
         exec_context_dump(&m->exec_context, f, prefix);
         kill_context_dump(&m->kill_context, f, prefix);
         cgroup_context_dump(UNIT(m), f, prefix);
+
+        for (MountExecCommand c = 0; c < _MOUNT_EXEC_COMMAND_MAX; c++) {
+                if (!m->exec_command[c].argv)
+                        continue;
+
+                fprintf(f, "%s%s %s:\n",
+                        prefix, special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), mount_exec_command_to_string(c));
+
+                exec_command_dump(m->exec_command + c, f, prefix2);
+        }
 }
 
 static int mount_spawn(Mount *m, ExecCommand *c, PidRef *ret_pid) {
index 820dfdff81c9999fca9df44702f0bee44107809d..3d2026072870503837b519950a2364d35c2cf5ea 100644 (file)
@@ -560,9 +560,13 @@ static int swap_coldplug(Unit *u) {
 static void swap_dump(Unit *u, FILE *f, const char *prefix) {
         Swap *s = ASSERT_PTR(SWAP(u));
         SwapParameters *p;
+        const char *prefix2;
 
         assert(f);
 
+        prefix = strempty(prefix);
+        prefix2 = strjoina(prefix, "\t");
+
         if (s->from_proc_swaps)
                 p = &s->parameters_proc_swaps;
         else if (s->from_fragment)
@@ -608,6 +612,17 @@ static void swap_dump(Unit *u, FILE *f, const char *prefix) {
         exec_context_dump(&s->exec_context, f, prefix);
         kill_context_dump(&s->kill_context, f, prefix);
         cgroup_context_dump(UNIT(s), f, prefix);
+
+        for (SwapExecCommand c = 0; c < _SWAP_EXEC_COMMAND_MAX; c++) {
+                if (!s->exec_command[c].argv)
+                        continue;
+
+                fprintf(f, "%s%s %s:\n",
+                        prefix, special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), swap_exec_command_to_string(c));
+
+                exec_command_dump(s->exec_command + c, f, prefix2);
+        }
+
 }
 
 static int swap_spawn(Swap *s, ExecCommand *c, PidRef *ret_pid) {