mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 10:00:17 +00:00
floppy: fix open(O_ACCMODE) for ioctl-only open
commitff06db1efbupstream. Commit09954bad4("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. Reported-by: Wim Osterholt <wim@djo.tudelft.nl> Tested-by: Wim Osterholt <wim@djo.tudelft.nl> Signed-off-by: Jiri Kosina <jkosina@suse.cz> Signed-off-by: Jens Axboe <axboe@fb.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
b410df3a2f
commit
c0b0edbc90
@@ -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,6 +3706,7 @@ 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;
|
||||||
|
|
||||||
|
if (mode & (FMODE_READ|FMODE_WRITE)) {
|
||||||
UDRS->last_checked = 0;
|
UDRS->last_checked = 0;
|
||||||
clear_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags);
|
clear_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags);
|
||||||
check_disk_change(bdev);
|
check_disk_change(bdev);
|
||||||
@@ -3718,6 +3714,7 @@ static int floppy_open(struct block_device *bdev, fmode_t mode)
|
|||||||
goto out;
|
goto out;
|
||||||
if (test_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags))
|
if (test_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags))
|
||||||
goto out;
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
res = -EROFS;
|
res = -EROFS;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user