From: Zbigniew Jędrzejewski-Szmek Date: Fri, 2 Jul 2021 15:00:00 +0000 (+0200) Subject: core: add helper to retrieve service.status_text X-Git-Tag: v250-rc1~933^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5e1669ff26198a916c4fe1532448b8bf908b2eaa;p=thirdparty%2Fsystemd.git core: add helper to retrieve service.status_text --- diff --git a/src/core/service.c b/src/core/service.c index 1f38a254768..f4a79dc2af5 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -4379,6 +4379,14 @@ static int service_exit_status(Unit *u) { return s->main_exec_status.status; } +static const char* service_status_text(Unit *u) { + Service *s = SERVICE(u); + + assert(s); + + return s->status_text; +} + static int service_clean(Unit *u, ExecCleanMask mask) { _cleanup_strv_free_ char **l = NULL; Service *s = SERVICE(u); @@ -4590,6 +4598,7 @@ const UnitVTable service_vtable = { .get_timeout = service_get_timeout, .needs_console = service_needs_console, .exit_status = service_exit_status, + .status_text = service_status_text, .status_message_formats = { .finished_start_job = { diff --git a/src/core/unit.h b/src/core/unit.h index 759104ffa79..48074d8ca5b 100644 --- a/src/core/unit.h +++ b/src/core/unit.h @@ -631,6 +631,9 @@ typedef struct UnitVTable { * exit code of the "main" process of the service or similar. */ int (*exit_status)(Unit *u); + /* Return a copy of the status string pointer. */ + const char* (*status_text)(Unit *u); + /* Like the enumerate() callback further down, but only enumerates the perpetual units, i.e. all units that * unconditionally exist and are always active. The main reason to keep both enumeration functions separate is * philosophical: the state of perpetual units should be put in place by coldplug(), while the state of those @@ -744,6 +747,12 @@ static inline bool unit_is_extrinsic(Unit *u) { (UNIT_VTABLE(u)->is_extrinsic && UNIT_VTABLE(u)->is_extrinsic(u)); } +static inline const char* unit_status_text(Unit *u) { + if (u && UNIT_VTABLE(u)->status_text) + return UNIT_VTABLE(u)->status_text(u); + return NULL; +} + void unit_add_to_load_queue(Unit *u); void unit_add_to_dbus_queue(Unit *u); void unit_add_to_cleanup_queue(Unit *u);