core: add helper to retrieve service.status_text
This commit is contained in:
@@ -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 = {
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user