From 1ce0d040593c92adebceed29618f170faaee0839 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 4 Apr 2022 15:18:57 +0200 Subject: 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. --- src/libsystemd/sd-device/sd-device.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'src/libsystemd/sd-device/sd-device.c') 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")) -- cgit v1.2.3