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/core/automount.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/core/automount.c') diff --git a/src/core/automount.c b/src/core/automount.c index f795487131..90beb4daaa 100644 --- a/src/core/automount.c +++ b/src/core/automount.c @@ -807,6 +807,17 @@ static void automount_reset_failed(Unit *u) { a->result = AUTOMOUNT_SUCCESS; } +static bool automount_supported(Manager *m) { + static int supported = -1; + + assert(m); + + if (supported < 0) + supported = access("/dev/autofs", F_OK) >= 0; + + return supported; +} + static const char* const automount_state_table[_AUTOMOUNT_STATE_MAX] = { [AUTOMOUNT_DEAD] = "dead", [AUTOMOUNT_WAITING] = "waiting", @@ -859,6 +870,7 @@ const UnitVTable automount_vtable = { .bus_vtable = bus_automount_vtable, .shutdown = automount_shutdown, + .supported = automount_supported, .status_message_formats = { .finished_start_job = { -- cgit v1.2.3-54-g00ecf