device_unset_sysfs(d);
d->wants_property = strv_free(d->wants_property);
+ d->path = mfree(d->path);
}
static int device_load(Unit *u) {
assert(f);
assert(fds);
+ if (d->path)
+ (void) serialize_item(f, "path", d->path);
+
(void) serialize_item(f, "state", device_state_to_string(d->state));
if (device_found_to_string_many(d->found, &s) >= 0)
assert(value);
assert(fds);
- if (streq(key, "state")) {
+ if (streq(key, "path")) {
+ if (!d->path) {
+ d->path = strdup(value);
+ if (!d->path)
+ log_oom_debug();
+ }
+
+ } else if (streq(key, "state")) {
DeviceState state;
state = device_state_from_string(value);
fprintf(f,
"%sDevice State: %s\n"
+ "%sDevice Path: %s\n"
"%sSysfs Path: %s\n"
"%sFound: %s\n",
prefix, device_state_to_string(d->state),
+ prefix, strna(d->path),
prefix, strna(d->sysfs),
prefix, strna(s));
unit_add_to_load_queue(u);
}
+ if (!DEVICE(u)->path) {
+ DEVICE(u)->path = strdup(path);
+ if (!DEVICE(u)->path)
+ return log_oom();
+ }
+
/* If this was created via some dependency and has not actually been seen yet ->sysfs will not be
* initialized. Hence initialize it if necessary. */
if (sysfs) {
Unit meta;
char *sysfs;
+ char *path; /* syspath, device node, alias, or devlink */
/* In order to be able to distinguish dependencies on different device nodes we might end up creating multiple
* devices for the same sysfs path. We chain them up here. */