]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
fdisk: open device in nonblock mode
authorchanglianzhi <changlianzhi@uniontech.com>
Thu, 16 Dec 2021 02:56:25 +0000 (10:56 +0800)
committerchanglianzhi <changlianzhi@uniontech.com>
Thu, 16 Dec 2021 03:00:24 +0000 (11:00 +0800)
When autoclose is set (kernel default) opening a CD-rom
device causes the tray to close.

Signed-off-by: changlianzhi <changlianzhi@uniontech.com>
disk-utils/fdisk-list.c
lib/ismounted.c

index 9f64decabad69f7946fc4d4a38386ca4dce4217b..21d215e5844a85c3ea6f61bf6348c953ad9cec9f 100644 (file)
@@ -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);
 
index 9a20b236739b5c2a8eb63569433ef95800c10ccc..565a8325931735830acdf94c31e53bf2086bace6 100644 (file)
@@ -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;