diff options
author | Michal Schmidt <mschmidt@redhat.com> | 2012-05-13 18:18:54 +0200 |
---|---|---|
committer | Michal Schmidt <mschmidt@redhat.com> | 2012-05-14 14:29:53 +0200 |
commit | c69182961b00707d977957cf81d5c41cfbeab429 (patch) | |
tree | 0fea4038b59b5c82f71686c0ca50d118da983699 /src/core/unit.c | |
parent | 9ab7a8d2a30f440c008d127113419030e4572cb4 (diff) |
unit: unit type dependent status messages
Instead of generic "Starting..." and "Started" messages for all unit use
type-dependent messages. For example, mounts will announce "Mounting..."
and "Mounted".
Add status messages to units of types that used to be entirely silent
(automounts, sockets, targets, devices). For unit types whose jobs are
instantaneous, report only the job completion, not the starting event.
Socket units with non-instantaneous jobs are rare (Exec*= is not used
often in socket units), so I chose not to print the starting messages
for them either.
This will hopefully give people better understanding of the boot.
Diffstat (limited to 'src/core/unit.c')
-rw-r--r-- | src/core/unit.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/src/core/unit.c b/src/core/unit.c index ddcfad5912..200d196878 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -930,6 +930,21 @@ bool unit_condition_test(Unit *u) { return u->condition_result; } +static void unit_status_print_starting_stopping(Unit *u, bool stopping) { + const UnitStatusMessageFormats *format_table; + const char *format; + + format_table = &UNIT_VTABLE(u)->status_message_formats; + if (!format_table) + return; + + format = format_table->starting_stopping[stopping]; + if (!format) + return; + + unit_status_printf(u, "", format, unit_description(u)); +} + /* Errors: * -EBADR: This unit type does not support starting. * -EALREADY: Unit is already started. @@ -969,6 +984,8 @@ int unit_start(Unit *u) { return unit_start(following); } + unit_status_print_starting_stopping(u, false); + /* If it is stopped, but we cannot start it, then fail */ if (!UNIT_VTABLE(u)->start) return -EBADR; @@ -981,7 +998,6 @@ int unit_start(Unit *u) { unit_add_to_dbus_queue(u); - unit_status_printf(u, "", "Starting %s...", unit_description(u)); return UNIT_VTABLE(u)->start(u); } @@ -1018,12 +1034,13 @@ int unit_stop(Unit *u) { return unit_stop(following); } + unit_status_print_starting_stopping(u, true); + if (!UNIT_VTABLE(u)->stop) return -EBADR; unit_add_to_dbus_queue(u); - unit_status_printf(u, "", "Stopping %s...", unit_description(u)); return UNIT_VTABLE(u)->stop(u); } @@ -2544,9 +2561,6 @@ void unit_status_printf(Unit *u, const char *status, const char *format, ...) { assert(u); assert(format); - if (!UNIT_VTABLE(u)->show_status) - return; - if (!manager_get_show_status(u->manager)) return; |