" <property name=\"Paths\" type=\"a(ss)\" access=\"read\"/>\n" \
" <property name=\"MakeDirectory\" type=\"b\" access=\"read\"/>\n" \
" <property name=\"DirectoryMode\" type=\"u\" access=\"read\"/>\n" \
+ " <property name=\"Result\" type=\"s\" access=\"read\"/>\n" \
" </interface>\n"
#define INTROSPECTION \
const char bus_path_interface[] _introspect_("Path") = BUS_PATH_INTERFACE;
+const char bus_path_invalidating_properties[] =
+ "Result\0";
+
static int bus_path_append_paths(DBusMessageIter *i, const char *property, void *data) {
Path *p = data;
DBusMessageIter sub, sub2;
return dbus_message_iter_append_basic(i, DBUS_TYPE_STRING, &t) ? 0 : -ENOMEM;
}
+static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_path_append_path_result, path_result, PathResult);
+
static const BusProperty bus_path_properties[] = {
{ "Unit", bus_path_append_unit, "s", 0 },
{ "Paths", bus_path_append_paths, "a(ss)", 0 },
{ "MakeDirectory", bus_property_append_bool, "b", offsetof(Path, make_directory) },
{ "DirectoryMode", bus_property_append_mode, "u", offsetof(Path, directory_mode) },
+ { "Result", bus_path_append_path_result, "s", offsetof(Path, result) },
{ NULL, }
};
fprintf(f,
"%sPath State: %s\n"
+ "%sResult: %s\n"
"%sUnit: %s\n"
"%sMakeDirectory: %s\n"
"%sDirectoryMode: %04o\n",
prefix, path_state_to_string(p->state),
+ prefix, path_result_to_string(p->result),
prefix, UNIT_DEREF(p->unit)->id,
prefix, yes_no(p->make_directory),
prefix, p->directory_mode);
return 0;
}
-static void path_enter_dead(Path *p, bool success) {
+static void path_enter_dead(Path *p, PathResult f) {
assert(p);
- if (!success)
- p->failure = true;
+ if (f != PATH_SUCCESS)
+ p->result = f;
- path_set_state(p, p->failure ? PATH_FAILED : PATH_DEAD);
+ path_set_state(p, p->result != PATH_SUCCESS ? PATH_FAILED : PATH_DEAD);
}
static void path_enter_running(Path *p) {
fail:
log_warning("%s failed to queue unit startup job: %s", UNIT(p)->id, bus_error(&error, r));
- path_enter_dead(p, false);
+ path_enter_dead(p, PATH_FAILURE_RESOURCES);
dbus_error_free(&error);
}
fail:
log_warning("%s failed to enter waiting state: %s", UNIT(p)->id, strerror(-r));
- path_enter_dead(p, false);
+ path_enter_dead(p, PATH_FAILURE_RESOURCES);
}
static void path_mkdir(Path *p) {
path_mkdir(p);
- p->failure = false;
+ p->result = PATH_SUCCESS;
path_enter_waiting(p, true, true);
return 0;
assert(p);
assert(p->state == PATH_WAITING || p->state == PATH_RUNNING);
- path_enter_dead(p, true);
+ path_enter_dead(p, PATH_SUCCESS);
return 0;
}
assert(fds);
unit_serialize_item(u, f, "state", path_state_to_string(p->state));
+ unit_serialize_item(u, f, "result", path_result_to_string(p->result));
return 0;
}
log_debug("Failed to parse state value %s", value);
else
p->deserialized_state = state;
+
+ } else if (streq(key, "result")) {
+ PathResult f;
+
+ f = path_result_from_string(value);
+ if (f < 0)
+ log_debug("Failed to parse result value %s", value);
+ else if (f != PATH_SUCCESS)
+ p->result = f;
+
} else
log_debug("Unknown serialization key '%s'", key);
return;
fail:
- path_enter_dead(p, false);
+ path_enter_dead(p, PATH_FAILURE_RESOURCES);
}
void path_unit_notify(Unit *u, UnitActiveState new_state) {
if (p->state == PATH_FAILED)
path_set_state(p, PATH_DEAD);
- p->failure = false;
+ p->result = PATH_SUCCESS;
}
static const char* const path_state_table[_PATH_STATE_MAX] = {
DEFINE_STRING_TABLE_LOOKUP(path_type, PathType);
+static const char* const path_result_table[_PATH_RESULT_MAX] = {
+ [PATH_SUCCESS] = "success",
+ [PATH_FAILURE_RESOURCES] = "resources"
+};
+
+DEFINE_STRING_TABLE_LOOKUP(path_result, PathResult);
+
const UnitVTable path_vtable = {
.suffix = ".path",
.object_size = sizeof(Path),
.reset_failed = path_reset_failed,
.bus_interface = "org.freedesktop.systemd1.Path",
- .bus_message_handler = bus_path_message_handler
+ .bus_message_handler = bus_path_message_handler,
+ .bus_invalidating_properties = bus_path_invalidating_properties
};