From: changlianzhi Date: Thu, 16 Dec 2021 02:56:25 +0000 (+0800) Subject: fdisk: open device in nonblock mode X-Git-Tag: v2.38-rc1~83^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=38401453c522a7bf099c4e5a41056310dcd635b8;p=thirdparty%2Futil-linux.git fdisk: open device in nonblock mode When autoclose is set (kernel default) opening a CD-rom device causes the tray to close. Signed-off-by: changlianzhi --- diff --git a/disk-utils/fdisk-list.c b/disk-utils/fdisk-list.c index 9f64decaba..21d215e584 100644 --- a/disk-utils/fdisk-list.c +++ b/disk-utils/fdisk-list.c @@ -26,7 +26,7 @@ static int is_ide_cdrom_or_tape(char *device) { int fd, ret; - if ((fd = open(device, O_RDONLY)) < 0) + if ((fd = open(device, O_RDONLY|O_NONBLOCK)) < 0) return 0; ret = blkdev_is_cdrom(fd); diff --git a/lib/ismounted.c b/lib/ismounted.c index 9a20b23673..565a832593 100644 --- a/lib/ismounted.c +++ b/lib/ismounted.c @@ -347,7 +347,7 @@ int check_mount_point(const char *device, int *mount_flags, if ((stat(device, &st_buf) != 0) || !S_ISBLK(st_buf.st_mode)) return 0; - fd = open(device, O_RDONLY|O_EXCL|O_CLOEXEC); + fd = open(device, O_RDONLY|O_EXCL|O_CLOEXEC|O_NONBLOCK); if (fd < 0) { if (errno == EBUSY) *mount_flags |= MF_BUSY;