" <property name=\"ActiveState\" type=\"s\" access=\"read\"/>\n" \
" <property name=\"SubState\" type=\"s\" access=\"read\"/>\n" \
" <property name=\"FragmentPath\" type=\"s\" access=\"read\"/>\n" \
+ " <property name=\"UnitFileState\" type=\"s\" access=\"read\"/>\n" \
" <property name=\"InactiveExitTimestamp\" type=\"t\" access=\"read\"/>\n" \
" <property name=\"InactiveExitTimestampMonotonic\" type=\"t\" access=\"read\"/>\n" \
" <property name=\"ActiveEnterTimestamp\" type=\"t\" access=\"read\"/>\n" \
{ "org.freedesktop.systemd1.Unit", "ActiveState", bus_unit_append_active_state, "s", u }, \
{ "org.freedesktop.systemd1.Unit", "SubState", bus_unit_append_sub_state, "s", u }, \
{ "org.freedesktop.systemd1.Unit", "FragmentPath", bus_property_append_string, "s", u->meta.fragment_path }, \
+ { "org.freedesktop.systemd1.Unit", "UnitFileState", bus_unit_append_file_state, "s", u }, \
{ "org.freedesktop.systemd1.Unit", "InactiveExitTimestamp",bus_property_append_usec, "t", &u->meta.inactive_exit_timestamp.realtime }, \
{ "org.freedesktop.systemd1.Unit", "InactiveExitTimestampMonotonic",bus_property_append_usec, "t", &u->meta.inactive_exit_timestamp.monotonic }, \
{ "org.freedesktop.systemd1.Unit", "ActiveEnterTimestamp", bus_property_append_usec, "t", &u->meta.active_enter_timestamp.realtime }, \
int bus_unit_append_load_state(DBusMessageIter *i, const char *property, void *data);
int bus_unit_append_active_state(DBusMessageIter *i, const char *property, void *data);
int bus_unit_append_sub_state(DBusMessageIter *i, const char *property, void *data);
+int bus_unit_append_file_state(DBusMessageIter *i, const char *property, void *data);
int bus_unit_append_can_start(DBusMessageIter *i, const char *property, void *data);
int bus_unit_append_can_stop(DBusMessageIter *i, const char *property, void *data);
int bus_unit_append_can_reload(DBusMessageIter *i, const char *property, void *data);
const char *load_state;
const char *active_state;
const char *sub_state;
+ const char *unit_file_state;
const char *description;
const char *following;
if (i->load_error)
printf("\t Loaded: %s%s%s (Reason: %s)\n", on, strna(i->load_state), off, i->load_error);
+ else if (i->path && i->unit_file_state)
+ printf("\t Loaded: %s%s%s (%s; %s)\n", on, strna(i->load_state), off, i->path, i->unit_file_state);
else if (i->path)
printf("\t Loaded: %s%s%s (%s)\n", on, strna(i->load_state), off, i->path);
else
i->what = s;
else if (streq(name, "Following"))
i->following = s;
+ else if (streq(name, "UnitFileState"))
+ i->unit_file_state = s;
}
break;
u->meta.type = _UNIT_TYPE_INVALID;
u->meta.deserialized_job = _JOB_TYPE_INVALID;
u->meta.default_dependencies = true;
+ u->meta.unit_file_state = _UNIT_FILE_STATE_INVALID;
return u;
}
return 0;
}
+UnitFileState unit_get_unit_file_state(Unit *u) {
+ assert(u);
+
+ if (u->meta.unit_file_state < 0 && u->meta.fragment_path)
+ u->meta.unit_file_state = unit_file_get_state(
+ u->meta.manager->running_as == MANAGER_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER,
+ NULL, file_name_from_path(u->meta.fragment_path));
+
+ return u->meta.unit_file_state;
+}
+
static const char* const unit_load_state_table[_UNIT_LOAD_STATE_MAX] = {
[UNIT_STUB] = "stub",
[UNIT_LOADED] = "loaded",
#include "socket-util.h"
#include "execute.h"
#include "condition.h"
+#include "install.h"
enum UnitType {
UNIT_SERVICE = 0,
/* Error code when we didn't manage to load the unit (negative) */
int load_error;
+ /* Cached unit file state */
+ UnitFileState unit_file_state;
+
/* Garbage collect us we nobody wants or requires us anymore */
bool stop_when_unneeded;
bool unit_condition_test(Unit *u);
+UnitFileState unit_get_unit_file_state(Unit *u);
+
const char *unit_load_state_to_string(UnitLoadState i);
UnitLoadState unit_load_state_from_string(const char *s);