mirror of
https://github.com/systemd/systemd.git
synced 2024-11-02 19:21:53 +03:00
manager: convert ephemeral to enum
In preparation for subsequent changes.
This commit is contained in:
parent
2de51fdc52
commit
127d5fd156
@ -639,7 +639,7 @@ static void job_print_status_message(Unit *u, JobType t, JobResult result) {
|
||||
|
||||
manager_flip_auto_status(u->manager, true);
|
||||
unit_status_printf(u, ANSI_HIGHLIGHT_RED_ON "FAILED" ANSI_HIGHLIGHT_OFF, format);
|
||||
manager_status_printf(u->manager, false, NULL,
|
||||
manager_status_printf(u->manager, STATUS_TYPE_NORMAL, NULL,
|
||||
"See \"systemctl status %s%s%s\" for details.",
|
||||
quotes ? "'" : "", u->id, quotes ? "'" : "");
|
||||
break;
|
||||
|
@ -194,7 +194,7 @@ static void manager_print_jobs_in_progress(Manager *m) {
|
||||
if (job_get_timeout(j, &x) > 0)
|
||||
format_timespan(limit, sizeof(limit), x - j->begin_usec, 1*USEC_PER_SEC);
|
||||
|
||||
manager_status_printf(m, true, cylon,
|
||||
manager_status_printf(m, STATUS_TYPE_EPHEMERAL, cylon,
|
||||
"%sA %s job is running for %s (%s / %s)",
|
||||
strempty(job_of_n),
|
||||
job_type_to_string(j->type),
|
||||
@ -2931,7 +2931,7 @@ void manager_set_show_status(Manager *m, ShowStatus mode) {
|
||||
unlink("/run/systemd/show-status");
|
||||
}
|
||||
|
||||
static bool manager_get_show_status(Manager *m) {
|
||||
static bool manager_get_show_status(Manager *m, StatusType type) {
|
||||
assert(m);
|
||||
|
||||
if (m->running_as != SYSTEMD_SYSTEM)
|
||||
@ -2969,19 +2969,19 @@ void manager_set_first_boot(Manager *m, bool b) {
|
||||
unlink("/run/systemd/first-boot");
|
||||
}
|
||||
|
||||
void manager_status_printf(Manager *m, bool ephemeral, const char *status, const char *format, ...) {
|
||||
void manager_status_printf(Manager *m, StatusType type, const char *status, const char *format, ...) {
|
||||
va_list ap;
|
||||
|
||||
if (!manager_get_show_status(m))
|
||||
if (!manager_get_show_status(m, type))
|
||||
return;
|
||||
|
||||
/* XXX We should totally drop the check for ephemeral here
|
||||
* and thus effectively make 'Type=idle' pointless. */
|
||||
if (ephemeral && m->n_on_console > 0)
|
||||
if (type == STATUS_TYPE_EPHEMERAL && m->n_on_console > 0)
|
||||
return;
|
||||
|
||||
va_start(ap, format);
|
||||
status_vprintf(status, true, ephemeral, format, ap);
|
||||
status_vprintf(status, true, type == STATUS_TYPE_EPHEMERAL, format, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
|
@ -60,6 +60,11 @@ typedef enum ManagerExitCode {
|
||||
_MANAGER_EXIT_CODE_INVALID = -1
|
||||
} ManagerExitCode;
|
||||
|
||||
typedef enum StatusType {
|
||||
STATUS_TYPE_EPHEMERAL,
|
||||
STATUS_TYPE_NORMAL,
|
||||
} StatusType;
|
||||
|
||||
#include "unit.h"
|
||||
#include "job.h"
|
||||
#include "hashmap.h"
|
||||
@ -349,7 +354,7 @@ void manager_recheck_journal(Manager *m);
|
||||
void manager_set_show_status(Manager *m, ShowStatus mode);
|
||||
void manager_set_first_boot(Manager *m, bool b);
|
||||
|
||||
void manager_status_printf(Manager *m, bool ephemeral, const char *status, const char *format, ...) _printf_(4,5);
|
||||
void manager_status_printf(Manager *m, StatusType type, const char *status, const char *format, ...) _printf_(4,5);
|
||||
void manager_flip_auto_status(Manager *m, bool enable);
|
||||
|
||||
Set *manager_get_units_requiring_mounts_for(Manager *m, const char *path);
|
||||
|
@ -2768,7 +2768,8 @@ int unit_coldplug(Unit *u) {
|
||||
|
||||
void unit_status_printf(Unit *u, const char *status, const char *unit_status_msg_format) {
|
||||
DISABLE_WARNING_FORMAT_NONLITERAL;
|
||||
manager_status_printf(u->manager, false, status, unit_status_msg_format, unit_description(u));
|
||||
manager_status_printf(u->manager, STATUS_TYPE_NORMAL,
|
||||
status, unit_status_msg_format, unit_description(u));
|
||||
REENABLE_WARNING;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user