Skip to content

Commit 05f67ba

Browse files
evdenisgregkh
authored andcommitted
Revert "floppy: reintroduce O_NDELAY fix"
commit c7e9d0020361f4308a70cdfd6d5335e273eb8717 upstream. 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 f2791e7 (Revert "floppy: refactor open() flags handling"). This reverts commit 8a0c014cd20516ade9654fc13b51345ec58e7be8. Link: https://lore.kernel.org/linux-block/de10cb47-34d1-5a88-7751-225ca380f735@compro.net/ Reported-by: Mark 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: Denis Efremov <efremov@linux.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent b52e6a3 commit 05f67ba

1 file changed

Lines changed: 13 additions & 14 deletions

File tree

drivers/block/floppy.c

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4067,22 +4067,21 @@ static int floppy_open(struct block_device *bdev, fmode_t mode)
40674067
if (UFDCS->rawcmd == 1)
40684068
UFDCS->rawcmd = 2;
40694069

4070-
if (mode & (FMODE_READ|FMODE_WRITE)) {
4071-
UDRS->last_checked = 0;
4072-
clear_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags);
4073-
check_disk_change(bdev);
4074-
if (test_bit(FD_DISK_CHANGED_BIT, &UDRS->flags))
4075-
goto out;
4076-
if (test_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags))
4070+
if (!(mode & FMODE_NDELAY)) {
4071+
if (mode & (FMODE_READ|FMODE_WRITE)) {
4072+
UDRS->last_checked = 0;
4073+
clear_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags);
4074+
check_disk_change(bdev);
4075+
if (test_bit(FD_DISK_CHANGED_BIT, &UDRS->flags))
4076+
goto out;
4077+
if (test_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags))
4078+
goto out;
4079+
}
4080+
res = -EROFS;
4081+
if ((mode & FMODE_WRITE) &&
4082+
!test_bit(FD_DISK_WRITABLE_BIT, &UDRS->flags))
40774083
goto out;
40784084
}
4079-
4080-
res = -EROFS;
4081-
4082-
if ((mode & FMODE_WRITE) &&
4083-
!test_bit(FD_DISK_WRITABLE_BIT, &UDRS->flags))
4084-
goto out;
4085-
40864085
mutex_unlock(&open_lock);
40874086
mutex_unlock(&floppy_mutex);
40884087
return 0;

0 commit comments

Comments
 (0)