From 0faacd470dfbd24f4c6504da6f04213aa05f9d19 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 12 Dec 2014 21:05:32 +0100 Subject: unit: handle nicely of certain unit types are not supported on specific systems Containers do not really support .device, .automount or .swap units; Systems compiled without support for swap do not support .swap units; Systems without kdbus do not support .busname units. With this change attempts to start a unsupported unit types will result in an immediate "unsupported" job result, which is a lot more descriptive then before. Also, attempts to start device units in containers will now immediately fail instead of causing jobs to be enqueued that never go away. --- src/systemctl/systemctl.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'src/systemctl') diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 8400bc8cd4..8a1b481fdc 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -2380,12 +2380,18 @@ static int check_wait_response(WaitData *d) { assert(d->result); if (!arg_quiet) { - if (streq(d->result, "timeout")) - log_error("Job for %s timed out.", strna(d->name)); - else if (streq(d->result, "canceled")) + if (streq(d->result, "canceled")) log_error("Job for %s canceled.", strna(d->name)); + else if (streq(d->result, "timeout")) + log_error("Job for %s timed out.", strna(d->name)); else if (streq(d->result, "dependency")) log_error("A dependency job for %s failed. See 'journalctl -xe' for details.", strna(d->name)); + else if (streq(d->result, "invalid")) + log_error("Job for %s invalid.", strna(d->name)); + else if (streq(d->result, "assert")) + log_error("Assertion failed on job for %s.", strna(d->name)); + else if (streq(d->result, "unsupported")) + log_error("Operation on or unit type of %s not supported on this system.", strna(d->name)); else if (!streq(d->result, "done") && !streq(d->result, "skipped")) { if (d->name) { bool quotes; @@ -2400,12 +2406,18 @@ static int check_wait_response(WaitData *d) { } } - if (streq(d->result, "timeout")) - r = -ETIME; - else if (streq(d->result, "canceled")) + if (streq(d->result, "canceled")) r = -ECANCELED; + else if (streq(d->result, "timeout")) + r = -ETIME; else if (streq(d->result, "dependency")) r = -EIO; + else if (streq(d->result, "invalid")) + r = -ENOEXEC; + else if (streq(d->result, "assert")) + r = -EPROTO; + else if (streq(d->result, "unsupported")) + r = -ENOTSUP; else if (!streq(d->result, "done") && !streq(d->result, "skipped")) r = -EIO; -- cgit v1.2.3-54-g00ecf