X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fcore%2Fdevice.c;h=d3deac393649667a89a676d2f1c570bfa45f34b2;hb=821d4b6e068b2afaad94d43db22171c34a30400e;hp=c298cd95f69c613bdd17efa02a011a91cb92a705;hpb=ee33e53a70c0d3f9d8aeafe4b8fd84a0d5e1d8d9;p=elogind.git diff --git a/src/core/device.c b/src/core/device.c index c298cd95f..d3deac393 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 = {