summaryrefslogtreecommitdiff
path: root/src/core/device.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-12-12 21:05:32 +0100
committerLennart Poettering <lennart@poettering.net>2014-12-15 19:02:17 +0100
commit0faacd470dfbd24f4c6504da6f04213aa05f9d19 (patch)
tree9b13b654d993efc475f9209f8b1cf602850ee27b /src/core/device.c
parent17d1f37d0dbd2d78b8866e1350c83a9755105144 (diff)
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.
Diffstat (limited to 'src/core/device.c')
-rw-r--r--src/core/device.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/core/device.c b/src/core/device.c
index c298cd95f6..d3deac3936 100644
--- a/src/core/device.c
+++ b/src/core/device.c
@@ -673,6 +673,19 @@ static int device_dispatch_io(sd_event_source *source, int fd, uint32_t revents,
return 0;
}
+static bool device_supported(Manager *m) {
+ static int read_only = -1;
+ assert(m);
+
+ /* If /sys is read-only we don't support device units, and any
+ * attempts to start one should fail immediately. */
+
+ if (read_only < 0)
+ read_only = path_is_read_only_fs("/sys");
+
+ return read_only <= 0;
+}
+
static const char* const device_state_table[_DEVICE_STATE_MAX] = {
[DEVICE_DEAD] = "dead",
[DEVICE_PLUGGED] = "plugged"
@@ -708,6 +721,7 @@ const UnitVTable device_vtable = {
.enumerate = device_enumerate,
.shutdown = device_shutdown,
+ .supported = device_supported,
.status_message_formats = {
.starting_stopping = {