mirror of
https://github.com/systemd/systemd.git
synced 2025-08-30 05:49:54 +03:00
sd-device: skip diskseq verification when ID_IGNORE_DISKSEQ property is set
Some drivers do not announce the diskseq change. E.g. for md devices, the kernel increments the diskseq *after* emitting a 'change' uevent when backing block devices are added to a md device, and udevd does not receive no uevent which contains the new diskseq.
This commit is contained in:
@ -2281,7 +2281,7 @@ _public_ int sd_device_trigger_with_uuid(
|
|||||||
|
|
||||||
_public_ int sd_device_open(sd_device *device, int flags) {
|
_public_ int sd_device_open(sd_device *device, int flags) {
|
||||||
_cleanup_close_ int fd = -1, fd2 = -1;
|
_cleanup_close_ int fd = -1, fd2 = -1;
|
||||||
const char *devname, *subsystem = NULL;
|
const char *devname, *subsystem = NULL, *val = NULL;
|
||||||
uint64_t q, diskseq = 0;
|
uint64_t q, diskseq = 0;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
dev_t devnum;
|
dev_t devnum;
|
||||||
@ -2306,10 +2306,6 @@ _public_ int sd_device_open(sd_device *device, int flags) {
|
|||||||
if (r < 0 && r != -ENOENT)
|
if (r < 0 && r != -ENOENT)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
r = sd_device_get_diskseq(device, &diskseq);
|
|
||||||
if (r < 0 && r != -ENOENT)
|
|
||||||
return r;
|
|
||||||
|
|
||||||
fd = open(devname, FLAGS_SET(flags, O_PATH) ? flags : O_CLOEXEC|O_NOFOLLOW|O_PATH);
|
fd = open(devname, FLAGS_SET(flags, O_PATH) ? flags : O_CLOEXEC|O_NOFOLLOW|O_PATH);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return -errno;
|
return -errno;
|
||||||
@ -2327,6 +2323,16 @@ _public_ int sd_device_open(sd_device *device, int flags) {
|
|||||||
if (FLAGS_SET(flags, O_PATH))
|
if (FLAGS_SET(flags, O_PATH))
|
||||||
return TAKE_FD(fd);
|
return TAKE_FD(fd);
|
||||||
|
|
||||||
|
r = sd_device_get_property_value(device, "ID_IGNORE_DISKSEQ", &val);
|
||||||
|
if (r < 0 && r != -ENOENT)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
if (!val || parse_boolean(val) <= 0) {
|
||||||
|
r = sd_device_get_diskseq(device, &diskseq);
|
||||||
|
if (r < 0 && r != -ENOENT)
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
fd2 = open(FORMAT_PROC_FD_PATH(fd), flags);
|
fd2 = open(FORMAT_PROC_FD_PATH(fd), flags);
|
||||||
if (fd2 < 0)
|
if (fd2 < 0)
|
||||||
return -errno;
|
return -errno;
|
||||||
|
Reference in New Issue
Block a user