block/swim: Minor fixes
cover block/swim: Minor fixes
Two old bugs were reported to me by Stan Johnson while he was testing my recent patch series, "[PATCH v3] block/swim: Fixes and improvements". The following patches fix those bugs.
---
Finn Thain (2):
swim: Return -EROFS when opened with BLK_OPEN_WRITE flag
swim: Fix FDEJECT ioctl for exclusive open
drivers/block/swim.c | 5 +++-- drivers/block/swim3.c | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-)
Signature · 1 line
2.52.0
PATCH 1/2 swim: Return -EROFS when opened with BLK_OPEN_WRITE flag
Write requests are not supported by the driver and produce IO errors as shown below. Avoid this by returning -EROFS when opened for writing.
[ 4111.690000] I/O error, dev fd0, sector 2 op 0x1:(WRITE) flags 0x800800 phys_seg 1 prio class 2 [ 4111.700000] Buffer I/O error on dev fd0, logical block 2, lost async page write
--- drivers/block/swim.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/block/swim.c +2 -1
@@ -640,7 +640,8 @@ static int floppy_open(struct gendisk *disk, blk_mode_t mode)if (mode & (BLK_OPEN_READ |BLK_OPEN_WRITE )) {if (disk_check_media_change (disk) && fs->disk_in) fs->ejected =0 ; -if ((mode &BLK_OPEN_WRITE ) && fs->write_protected) { +if (mode &BLK_OPEN_WRITE ) { +/* Write support isn't implemented. */ err = -EROFS ; goto out; }
Signature · 1 line
2.52.0
PATCH 2/2 swim, swim3: Fix FDEJECT ioctl for exclusive open
In reply to Finn ThainThe eject command from the util-linux package does not work with swim3 or swim drivers: the drive doesn't eject anything and the command fails. Apparently, ioctl(fd, FDEJECT) returns -EBUSY when fd is opened O_EXCL. Fix this by checking ref_count for either 1 or -1. Either value means that the caller is the sole user of the disk.
--- drivers/block/swim.c | 2 +- drivers/block/swim3.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/block/swim.c +1 -1
@@ -696,7 +696,7 @@ static int floppy_ioctl(struct block_device *bdev, blk_mode_t mode,switch (cmd) {case FDEJECT : -if (fs->ref_count !=1 ) +if (fs->ref_count !=-1 && fs->ref_count !=1 )return -EBUSY ;mutex_lock (&swim_mutex); err =floppy_eject (fs);
drivers/block/swim3.c +1 -1
@@ -898,7 +898,7 @@ static int floppy_locked_ioctl(struct block_device *bdev, blk_mode_t mode,switch (cmd) {case FDEJECT : -if (fs->ref_count !=1 ) +if (fs->ref_count !=-1 && fs->ref_count !=1 )return -EBUSY ; err =fd_eject (fs);return err;
Signature · 1 line
2.52.0
Re: [PATCH 2/2] swim, swim3: Fix FDEJECT ioctl for exclusive open
Please disregard this patch. When I re-read it, I noticed that the ref_count access should really be protected by the mutex. So I will fix that and re-submit.
Quoted 41 lines · Finn Thain
The eject command from the util-linux package does not work with swim3 or swim drivers: the drive doesn't eject anything and the command fails. Apparently,
ioctl(fd, FDEJECT)returns-EBUSYwhen fd is openedO_EXCL. Fix this by checkingref_countfor either 1 or -1. Either value means that the caller is the sole user of the disk.Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")Fixes 8852ecd97488 ("m68k: mac - Add SWIM floppy support")Signed-off-by Finn Thain <[email protected]>--- drivers/block/swim.c | 2 +- drivers/block/swim3.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)drivers/block/swim.c +1
-1@@ -696,7 +696,7 @@ static int floppy_ioctl(struct block_device *bdev, blk_mode_t mode,switch (cmd) {case FDEJECT : -if (fs->ref_count !=1 ) +if (fs->ref_count !=-1 && fs->ref_count !=1 )return -EBUSY ;mutex_lock (&swim_mutex); err =floppy_eject (fs);drivers/block/swim3.c +1
-1@@ -898,7 +898,7 @@ static int floppy_locked_ioctl(struct block_device *bdev, blk_mode_t mode,switch (cmd) {case FDEJECT : -if (fs->ref_count !=1 ) +if (fs->ref_count !=-1 && fs->ref_count !=1 )return -EBUSY ; err =fd_eject (fs);return err;
This patch series was successfully tested on a Mac IIci and a PowerBook Wallstreet (G3 Series).
Quoted 14 lines · Finn Thain
Two old bugs were reported to me by Stan Johnson while he was testing my recent patch series, "[PATCH v3] block/swim: Fixes and improvements". The following patches fix those bugs.
---
Finn Thain (2):
swim: Return-EROFSwhen opened withBLK_OPEN_WRITEflag
swim: Fix FDEJECT ioctl for exclusive opendrivers/block/swim.c | 5 +++-- drivers/block/swim3.c | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-)