[PATCH v2 1/3] swim: Return -EROFS when opened with BLK_OPEN_WRITE flag
From: Finn Thain
Date: Mon Sep 28 2026 - 20:31:03 EST
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
Fixes: 8852ecd97488 ("m68k: mac - Add SWIM floppy support")
Tested-by: Stan Johnson <userm57@xxxxxxxxx>
Signed-off-by: Finn Thain <fthain@xxxxxxxxxxxxxx>
---
drivers/block/swim.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/block/swim.c b/drivers/block/swim.c
index 6f37a01219c2..49c894af7c13 100644
--- a/drivers/block/swim.c
+++ b/drivers/block/swim.c
@@ -639,7 +639,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;
}