47 lines
1.8 KiB
Diff
47 lines
1.8 KiB
Diff
From 581e2d96fccde1d367ead9f12fadf4a1ea6affe3 Mon Sep 17 00:00:00 2001
|
|
From: Michal Suchanek <msuchanek@suse.de>
|
|
Date: Mon, 4 Nov 2019 21:23:15 +0100
|
|
Subject: [PATCH] libblkid: open device in nonblock mode.
|
|
|
|
Conflict:NA
|
|
Reference:https://github.com/systemd/systemd/commit/581e2d96fccde1d367ead9f12fadf4a1ea6affe3
|
|
|
|
When autoclose is set (kernel default but many distributions reverse the
|
|
setting) opening a CD-rom device causes the tray to close.
|
|
|
|
The function of blkid is to report the current state of the device and
|
|
not to change it. Hence it should use O_NONBLOCK when opening the
|
|
device to avoid closing a CD-rom tray.
|
|
|
|
blkid is used liberally in scripts so it can potentially interfere with
|
|
the user operating the CD-rom hardware.
|
|
|
|
[kzak@redhat.com: add O_NONBLOCK also to:
|
|
- wipefs
|
|
- blkid_new_probe_from_filename()
|
|
- blkid_evaluate_tag()]
|
|
|
|
Signed-off-by: Michal Suchanek <msuchanek@suse.de>
|
|
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
(cherry picked from commit 39f5af25982d8b0244000e92a9d0e0e6557d0e17)
|
|
---
|
|
src/udev/udev-builtin-blkid.c | 2 +-
|
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
|
diff --git a/src/udev/udev-builtin-blkid.c b/src/udev/udev-builtin-blkid.c
|
|
index 8798a5a5e2..1df41dab36 100644
|
|
--- a/src/udev/udev-builtin-blkid.c
|
|
+++ b/src/udev/udev-builtin-blkid.c
|
|
@@ -264,7 +264,7 @@ static int builtin_blkid(sd_device *dev, int argc, char *argv[], bool test) {
|
|
if (r < 0)
|
|
return log_device_debug_errno(dev, r, "Failed to get device name: %m");
|
|
|
|
- fd = open(devnode, O_RDONLY|O_CLOEXEC);
|
|
+ fd = open(devnode, O_RDONLY|O_CLOEXEC|O_NONBLOCK);
|
|
if (fd < 0)
|
|
return log_device_debug_errno(dev, errno, "Failed to open block device %s: %m", devnode);
|
|
|
|
--
|
|
2.23.0
|
|
|