linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [BUG] FLOPPY DRIVER since 5.10.20
@ 2021-07-23 18:47 Mark Hounschell
  2021-07-26  7:57 ` Denis Efremov
  2021-08-08  7:42 ` [PATCH] Revert "floppy: reintroduce O_NDELAY fix" Denis Efremov
  0 siblings, 2 replies; 13+ messages in thread
From: Mark Hounschell @ 2021-07-23 18:47 UTC (permalink / raw)
  To: linux-block, Linux-kernel
  Cc: Denis Efremov, Jiri Kosina, Mark Hounschell, Greg Kroah-Hartman


These 2 incremental patches, patch-5.10.19-20 and patch-5.11.2-3 have 
broken the user land fd = open("/dev/fd0", (O_RDWR | O_NDELAY)); 
functionality.

Since FOREVER before the patch, when using O_NDELAY, one could open the 
floppy device with no media inserted or even with write protected media 
without error. "Read-only file system" status is returned only when we 
actually tried to write to it. We have software still in use today that 
relies on this functionality.

After the patch, if no media is in the drive the open fails with "no 
such device or address". If the floppy media is write protected the open 
fails with "Read-only file system".

This is certainly drastically changing user land usage incorrectly IMHO.

I think the commit is commit 8a0c014cd20516ade9654fc13b51345ec58e7be8
It is the only reference to the floppy driver in ChangeLog-5.10.20. 
However this change log entry actually sounds like it fixes the very 
issue I am reporting.

Here is the patch from the 5.10.19-20 change.

diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index 7df79ae6b0a1e..295da442329f3 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -4120,23 +4120,23 @@ static int floppy_open(struct block_device 
*bdev, fmode_t mode)
         if (fdc_state[FDC(drive)].rawcmd == 1)
                 fdc_state[FDC(drive)].rawcmd = 2;

-       if (!(mode & FMODE_NDELAY)) {
-               if (mode & (FMODE_READ|FMODE_WRITE)) {
-                       drive_state[drive].last_checked = 0;
-                       clear_bit(FD_OPEN_SHOULD_FAIL_BIT,
-                                 &drive_state[drive].flags);
-                       if (bdev_check_media_change(bdev))
-                               floppy_revalidate(bdev->bd_disk);
-                       if (test_bit(FD_DISK_CHANGED_BIT, 
&drive_state[drive].flags))
-                               goto out;
-                       if (test_bit(FD_OPEN_SHOULD_FAIL_BIT, 
&drive_state[drive].flags))
-                               goto out;
-               }
-               res = -EROFS;
-               if ((mode & FMODE_WRITE) &&
-                   !test_bit(FD_DISK_WRITABLE_BIT, 
&drive_state[drive].flags))
+       if (mode & (FMODE_READ|FMODE_WRITE)) {
+               drive_state[drive].last_checked = 0;
+               clear_bit(FD_OPEN_SHOULD_FAIL_BIT, 
&drive_state[drive].flags);
+               if (bdev_check_media_change(bdev))
+                       floppy_revalidate(bdev->bd_disk);
+               if (test_bit(FD_DISK_CHANGED_BIT, 
&drive_state[drive].flags))
+                       goto out;
+               if (test_bit(FD_OPEN_SHOULD_FAIL_BIT, 
&drive_state[drive].flags))
                         goto out;
         }
+
+       res = -EROFS;
+
+       if ((mode & FMODE_WRITE) &&
+                       !test_bit(FD_DISK_WRITABLE_BIT, 
&drive_state[drive].flags))
+               goto out;
+
         mutex_unlock(&open_lock);
         mutex_unlock(&floppy_mutex);
         return 0;

Regards
Mark

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2021-08-30  9:44 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-23 18:47 [BUG] FLOPPY DRIVER since 5.10.20 Mark Hounschell
2021-07-26  7:57 ` Denis Efremov
2021-07-26 11:15   ` Mark Hounschell
2021-07-26 11:17   ` Mark Hounschell
2021-07-26 11:37     ` Denis Efremov
2021-07-26 12:23       ` Mark Hounschell
2021-07-26 16:34         ` Denis Efremov
2021-07-30  5:15           ` Denis Efremov
2021-08-01 11:14             ` Kurt Garloff
2021-08-08  7:42 ` [PATCH] Revert "floppy: reintroduce O_NDELAY fix" Denis Efremov
2021-08-16  7:17   ` Jiri Kosina
2021-08-18 15:53     ` Denis Efremov
2021-08-30  9:20   ` Thorsten Leemhuis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).