diff options
author | Michal Suchanek <msuchanek@suse.de> | 2019-11-04 21:23:15 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-11-19 11:07:30 +0100 |
commit | 53d8feeb2334c396dcfa7106c78ce1791fb5d0c4 (patch) | |
tree | 4e33075b2ef532f27600644c74b7b6c7947d31a2 | |
parent | b9478046b03d6b76c32aed8940b2ae222e4e54d6 (diff) | |
download | systemd-53d8feeb2334c396dcfa7106c78ce1791fb5d0c4.tar.gz |
libblkid: open device in nonblock mode.
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)
(cherry picked from commit 581e2d96fccde1d367ead9f12fadf4a1ea6affe3)
-rw-r--r-- | src/udev/udev-builtin-blkid.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/udev/udev-builtin-blkid.c b/src/udev/udev-builtin-blkid.c index 7ef75e6f91..41799f43e8 100644 --- a/src/udev/udev-builtin-blkid.c +++ b/src/udev/udev-builtin-blkid.c @@ -266,7 +266,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); |