Commit c7e9d002 authored by Denis Efremov's avatar Denis Efremov

Revert "floppy: reintroduce O_NDELAY fix"

The patch breaks userspace implementations (e.g. fdutils) and introduces
regressions in behaviour. Previously, it was possible to O_NDELAY open a
floppy device with no media inserted or with write protected media without
an error. Some userspace tools use this particular behavior for probing.

It's not the first time when we revert this patch. Previous revert is in
commit f2791e7e (Revert "floppy: refactor open() flags handling").

This reverts commit 8a0c014c.

Link: https://lore.kernel.org/linux-block/de10cb47-34d1-5a88-7751-225ca380f735@compro.net/Reported-by: default avatarMark Hounschell <markh@compro.net>
Cc: Jiri Kosina <jkosina@suse.cz>
Cc: Wim Osterholt <wim@djo.tudelft.nl>
Cc: Kurt Garloff <kurt@garloff.de>
Cc: <stable@vger.kernel.org>
Signed-off-by: default avatarDenis Efremov <efremov@linux.com>
parent 461d9712
...@@ -4029,23 +4029,23 @@ static int floppy_open(struct block_device *bdev, fmode_t mode) ...@@ -4029,23 +4029,23 @@ static int floppy_open(struct block_device *bdev, fmode_t mode)
if (fdc_state[FDC(drive)].rawcmd == 1) if (fdc_state[FDC(drive)].rawcmd == 1)
fdc_state[FDC(drive)].rawcmd = 2; fdc_state[FDC(drive)].rawcmd = 2;
if (mode & (FMODE_READ|FMODE_WRITE)) { if (!(mode & FMODE_NDELAY)) {
drive_state[drive].last_checked = 0; if (mode & (FMODE_READ|FMODE_WRITE)) {
clear_bit(FD_OPEN_SHOULD_FAIL_BIT, &drive_state[drive].flags); drive_state[drive].last_checked = 0;
if (bdev_check_media_change(bdev)) clear_bit(FD_OPEN_SHOULD_FAIL_BIT,
floppy_revalidate(bdev->bd_disk); &drive_state[drive].flags);
if (test_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags)) if (bdev_check_media_change(bdev))
goto out; floppy_revalidate(bdev->bd_disk);
if (test_bit(FD_OPEN_SHOULD_FAIL_BIT, &drive_state[drive].flags)) if (test_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags))
goto out;
if (test_bit(FD_OPEN_SHOULD_FAIL_BIT, &drive_state[drive].flags))
goto out;
}
res = -EROFS;
if ((mode & FMODE_WRITE) &&
!test_bit(FD_DISK_WRITABLE_BIT, &drive_state[drive].flags))
goto out; goto out;
} }
res = -EROFS;
if ((mode & FMODE_WRITE) &&
!test_bit(FD_DISK_WRITABLE_BIT, &drive_state[drive].flags))
goto out;
mutex_unlock(&open_lock); mutex_unlock(&open_lock);
mutex_unlock(&floppy_mutex); mutex_unlock(&floppy_mutex);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment