Commit ff06db1e authored by Jiri Kosina's avatar Jiri Kosina Committed by Jens Axboe

floppy: fix open(O_ACCMODE) for ioctl-only open

Commit 09954bad ("floppy: refactor open() flags handling"), as a
side-effect, causes open(/dev/fdX, O_ACCMODE) to fail. It turns out that
this is being used setfdprm userspace for ioctl-only open().

Reintroduce back the original behavior wrt !(FMODE_READ|FMODE_WRITE)
modes, while still keeping the original O_NDELAY bug fixed.

Cc: stable@vger.kernel.org # v4.5+
Reported-by: default avatarWim Osterholt <wim@djo.tudelft.nl>
Tested-by: default avatarWim Osterholt <wim@djo.tudelft.nl>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent c1ece767
...@@ -3663,11 +3663,6 @@ static int floppy_open(struct block_device *bdev, fmode_t mode) ...@@ -3663,11 +3663,6 @@ static int floppy_open(struct block_device *bdev, fmode_t mode)
opened_bdev[drive] = bdev; opened_bdev[drive] = bdev;
if (!(mode & (FMODE_READ|FMODE_WRITE))) {
res = -EINVAL;
goto out;
}
res = -ENXIO; res = -ENXIO;
if (!floppy_track_buffer) { if (!floppy_track_buffer) {
...@@ -3711,13 +3706,15 @@ static int floppy_open(struct block_device *bdev, fmode_t mode) ...@@ -3711,13 +3706,15 @@ static int floppy_open(struct block_device *bdev, fmode_t mode)
if (UFDCS->rawcmd == 1) if (UFDCS->rawcmd == 1)
UFDCS->rawcmd = 2; UFDCS->rawcmd = 2;
UDRS->last_checked = 0; if (mode & (FMODE_READ|FMODE_WRITE)) {
clear_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags); UDRS->last_checked = 0;
check_disk_change(bdev); clear_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags);
if (test_bit(FD_DISK_CHANGED_BIT, &UDRS->flags)) check_disk_change(bdev);
goto out; if (test_bit(FD_DISK_CHANGED_BIT, &UDRS->flags))
if (test_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags)) goto out;
goto out; if (test_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags))
goto out;
}
res = -EROFS; res = -EROFS;
......
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