sd-device: skip to check diskseq if device is not initialized

This commit is contained in:
Yu Watanabe
2022-08-28 10:10:44 +09:00
parent ff65036cfe
commit 42899bcee5
+11 -4
View File
@@ -2422,13 +2422,20 @@ _public_ int sd_device_open(sd_device *device, int flags) {
if (FLAGS_SET(flags, O_PATH))
return TAKE_FD(fd);
r = device_get_property_bool(device, "ID_IGNORE_DISKSEQ");
if (r < 0 && r != -ENOENT)
/* If the device is not initialized, then we cannot determine if we should check diskseq through
* ID_IGNORE_DISKSEQ property. Let's skip to check diskseq in that case. */
r = sd_device_get_is_initialized(device);
if (r < 0)
return r;
if (r <= 0) {
r = sd_device_get_diskseq(device, &diskseq);
if (r > 0) {
r = device_get_property_bool(device, "ID_IGNORE_DISKSEQ");
if (r < 0 && r != -ENOENT)
return r;
if (r <= 0) {
r = sd_device_get_diskseq(device, &diskseq);
if (r < 0 && r != -ENOENT)
return r;
}
}
fd2 = open(FORMAT_PROC_FD_PATH(fd), flags);