From: Yu Watanabe Date: Tue, 25 Oct 2022 12:41:17 +0000 (+0900) Subject: core/device: also serialize/deserialize device syspath X-Git-Tag: v253-rc1~429^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1ea74fca3a3c737f3901bc10d879b7830b3528bf;p=thirdparty%2Fsystemd.git core/device: also serialize/deserialize device syspath The field will be used in later commits. --- diff --git a/src/core/device.c b/src/core/device.c index c79fd08bbb4..7e354b2b4a7 100644 --- a/src/core/device.c +++ b/src/core/device.c @@ -135,6 +135,7 @@ static void device_done(Unit *u) { assert(d); device_unset_sysfs(d); + d->deserialized_sysfs = mfree(d->deserialized_sysfs); d->wants_property = strv_free(d->wants_property); d->path = mfree(d->path); } @@ -392,6 +393,9 @@ static int device_serialize(Unit *u, FILE *f, FDSet *fds) { assert(f); assert(fds); + if (d->sysfs) + (void) serialize_item(f, "sysfs", d->sysfs); + if (d->path) (void) serialize_item(f, "path", d->path); @@ -413,7 +417,14 @@ static int device_deserialize_item(Unit *u, const char *key, const char *value, assert(value); assert(fds); - if (streq(key, "path")) { + if (streq(key, "sysfs")) { + if (!d->deserialized_sysfs) { + d->deserialized_sysfs = strdup(value); + if (!d->deserialized_sysfs) + log_oom_debug(); + } + + } else if (streq(key, "path")) { if (!d->path) { d->path = strdup(value); if (!d->path) diff --git a/src/core/device.h b/src/core/device.h index 7584bc70c4f..9dd6fb57c23 100644 --- a/src/core/device.h +++ b/src/core/device.h @@ -20,7 +20,7 @@ typedef enum DeviceFound { struct Device { Unit meta; - char *sysfs; + char *sysfs, *deserialized_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