summaryrefslogtreecommitdiffstats
path: root/src/libsystemd/sd-device/sd-device.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2022-04-04 15:18:57 +0200
committerLennart Poettering <lennart@poettering.net>2022-04-04 18:21:41 +0200
commit1ce0d040593c92adebceed29618f170faaee0839 (patch)
tree97749f056420561a73be316c483526b7b6587618 /src/libsystemd/sd-device/sd-device.c
parentsd-device: rename return parameter of sd_device_get_devpath() to ret (diff)
downloadsystemd-1ce0d040593c92adebceed29618f170faaee0839.tar.xz
systemd-1ce0d040593c92adebceed29618f170faaee0839.zip
sd-device: actually read diskseq if told so
sd_device_get_diskseq() actually called device_read_uevent_file() but that function didn't actually parse DISKSEQ= so far. Fix that.
Diffstat (limited to '')
-rw-r--r--src/libsystemd/sd-device/sd-device.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c
index bf9217b649..22200c0eea 100644
--- a/src/libsystemd/sd-device/sd-device.c
+++ b/src/libsystemd/sd-device/sd-device.c
@@ -570,7 +570,34 @@ int device_set_devnum(sd_device *device, const char *major, const char *minor) {
return 0;
}
-static int handle_uevent_line(sd_device *device, const char *key, const char *value, const char **major, const char **minor) {
+int device_set_diskseq(sd_device *device, const char *str) {
+ uint64_t diskseq;
+ int r;
+
+ assert(device);
+ assert(str);
+
+ r = safe_atou64(str, &diskseq);
+ if (r < 0)
+ return r;
+ if (diskseq == 0)
+ return -EINVAL;
+
+ r = device_add_property_internal(device, "DISKSEQ", str);
+ if (r < 0)
+ return r;
+
+ device->diskseq = diskseq;
+
+ return 0;
+}
+
+static int handle_uevent_line(
+ sd_device *device,
+ const char *key,
+ const char *value,
+ const char **major,
+ const char **minor) {
int r;
assert(device);
@@ -595,6 +622,10 @@ static int handle_uevent_line(sd_device *device, const char *key, const char *va
r = device_set_devmode(device, value);
if (r < 0)
return r;
+ } else if (streq(key, "DISKSEQ")) {
+ r = device_set_diskseq(device, value);
+ if (r < 0)
+ return r;
} else if (streq(key, "MAJOR"))
*major = value;
else if (streq(key, "MINOR"))