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>
This commit is contained in:
parent
b4402de7a0
commit
39f5af2598
|
@ -70,7 +70,7 @@ static int verify_tag(const char *devname, const char *name, const char *value)
|
||||||
blkid_probe_enable_partitions(pr, TRUE);
|
blkid_probe_enable_partitions(pr, TRUE);
|
||||||
blkid_probe_set_partitions_flags(pr, BLKID_PARTS_ENTRY_DETAILS);
|
blkid_probe_set_partitions_flags(pr, BLKID_PARTS_ENTRY_DETAILS);
|
||||||
|
|
||||||
fd = open(devname, O_RDONLY|O_CLOEXEC);
|
fd = open(devname, O_RDONLY|O_CLOEXEC|O_NONBLOCK);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
errsv = errno;
|
errsv = errno;
|
||||||
goto done;
|
goto done;
|
||||||
|
|
|
@ -203,7 +203,7 @@ blkid_probe blkid_new_probe_from_filename(const char *filename)
|
||||||
int fd;
|
int fd;
|
||||||
blkid_probe pr = NULL;
|
blkid_probe pr = NULL;
|
||||||
|
|
||||||
fd = open(filename, O_RDONLY|O_CLOEXEC);
|
fd = open(filename, O_RDONLY|O_CLOEXEC|O_NONBLOCK);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|
|
@ -126,7 +126,7 @@ blkid_dev blkid_verify(blkid_cache cache, blkid_dev dev)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fd = open(dev->bid_name, O_RDONLY|O_CLOEXEC);
|
fd = open(dev->bid_name, O_RDONLY|O_CLOEXEC|O_NONBLOCK);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
DBG(PROBE, ul_debug("blkid_verify: error %m (%d) while "
|
DBG(PROBE, ul_debug("blkid_verify: error %m (%d) while "
|
||||||
"opening %s", errno,
|
"opening %s", errno,
|
||||||
|
|
|
@ -499,7 +499,7 @@ static int lowprobe_device(blkid_probe pr, const char *devname,
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
static int first = 1;
|
static int first = 1;
|
||||||
|
|
||||||
fd = open(devname, O_RDONLY|O_CLOEXEC);
|
fd = open(devname, O_RDONLY|O_CLOEXEC|O_NONBLOCK);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
warn(_("error: %s"), devname);
|
warn(_("error: %s"), devname);
|
||||||
return BLKID_EXIT_NOTFOUND;
|
return BLKID_EXIT_NOTFOUND;
|
||||||
|
|
|
@ -386,7 +386,7 @@ new_probe(const char *devname, int mode)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (mode) {
|
if (mode) {
|
||||||
int fd = open(devname, mode);
|
int fd = open(devname, mode | O_NONBLOCK);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue