1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-23 17:34:00 +03:00

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.
This commit is contained in:
Lennart Poettering 2022-04-04 15:18:57 +02:00
parent d4df6ce215
commit 1ce0d04059
3 changed files with 33 additions and 23 deletions

View File

@ -109,6 +109,7 @@ int device_set_devname(sd_device *device, const char *devname);
int device_set_devtype(sd_device *device, const char *devtype);
int device_set_devnum(sd_device *device, const char *major, const char *minor);
int device_set_subsystem(sd_device *device, const char *subsystem);
int device_set_diskseq(sd_device *device, const char *str);
int device_set_drivers_subsystem(sd_device *device);
int device_set_driver(sd_device *device, const char *driver);
int device_set_usec_initialized(sd_device *device, usec_t when);

View File

@ -255,28 +255,6 @@ static int device_set_seqnum(sd_device *device, const char *str) {
return 0;
}
static 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 device_amend(sd_device *device, const char *key, const char *value) {
int r;

View File

@ -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"))