a->result = AUTOMOUNT_SUCCESS;
}
-static bool automount_supported(Manager *m) {
+static bool automount_supported(void) {
static int supported = -1;
- assert(m);
-
if (supported < 0)
supported = access("/dev/autofs", F_OK) >= 0;
return 1;
}
-static bool busname_supported(Manager *m) {
+static bool busname_supported(void) {
static int supported = -1;
- assert(m);
if (supported < 0)
supported = access("/sys/fs/kdbus", F_OK) >= 0;
return 0;
}
-static bool device_supported(Manager *m) {
+static bool device_supported(void) {
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. */
for (c = 0; c < _UNIT_TYPE_MAX; c++) {
int q;
- if (unit_vtable[c]->supported && !unit_vtable[c]->supported(m)) {
+ if (!unit_type_supported(c)) {
log_debug("Unit type .%s is not supported on this system.", unit_type_to_string(c));
continue;
}
return 1;
}
-static bool swap_supported(Manager *m) {
+static bool swap_supported(void) {
static int supported = -1;
/* If swap support is not available in the kernel, or we are
return unit_start(following);
}
- if (UNIT_VTABLE(u)->supported && !UNIT_VTABLE(u)->supported(u->manager))
+ if (!unit_supported(u))
return -EOPNOTSUPP;
/* If it is stopped, but we cannot start it, then fail */
/* When device units aren't supported (such as in a
* container), don't create dependencies on them. */
- if (unit_vtable[UNIT_DEVICE]->supported && !unit_vtable[UNIT_DEVICE]->supported(u->manager))
+ if (!unit_type_supported(UNIT_DEVICE))
return 0;
e = unit_name_from_path(what, ".device");
return exec_runtime_make(rt, unit_get_exec_context(u), u->id);
}
+bool unit_type_supported(UnitType t) {
+ if (_unlikely_(t < 0))
+ return false;
+ if (_unlikely_(t >= _UNIT_TYPE_MAX))
+ return false;
+
+ if (!unit_vtable[t]->supported)
+ return true;
+
+ return unit_vtable[t]->supported();
+}
+
static const char* const unit_active_state_table[_UNIT_ACTIVE_STATE_MAX] = {
[UNIT_ACTIVE] = "active",
[UNIT_RELOADING] = "reloading",
/* If this function is set and return false all jobs for units
* of this type will immediately fail. */
- bool (*supported)(Manager *m);
+ bool (*supported)(void);
/* The interface name */
const char *bus_interface;
int unit_require_mounts_for(Unit *u, const char *path);
+bool unit_type_supported(UnitType t);
+
+static inline bool unit_supported(Unit *u) {
+ return unit_type_supported(u->type);
+}
+
const char *unit_active_state_to_string(UnitActiveState i) _const_;
UnitActiveState unit_active_state_from_string(const char *s) _pure_;