2002-06-04 08:43:34

by Leigh Brown

[permalink] [raw]
Subject: [PATCH] Further change to change_floppy()

Hi,

The swim3 floppy driver does not let you open the floppy device for
writing (O_RDWR) if the drive contains a write-protected floppy. Since
the FDEJECT IOCTL works if the device has been opened read only, the
open can safely be changed to use O_RDONLY.

This patch (against 2.4.19pre9) has been tested on an ANS (swim3), but
has not been tested using the standard floppy driver. However, there is
a comment in the standard floppy driver code to indicate that it should
work, as shown below:

/* Allow ioctls if we have write-permissions even if read-only open.
* Needed so that programs such as fdrawcmd still can work on write
* protected disks */
if ((filp->f_mode & 2) ||
(inode->i_sb && (permission(inode,2) == 0)))
filp->private_data = (void*) 8;

Cheers,

Leigh.

diff -ur linux-2.4.19-pre9/init/do_mounts.c linux-2.4.19-pre9-local/init/do_mounts.c
--- linux-2.4.19-pre9/init/do_mounts.c Fri May 31 09:22:57 2002
+++ linux-2.4.19-pre9-local/init/do_mounts.c Fri May 31 09:36:00 2002
@@ -388,7 +388,7 @@
va_start(args, fmt);
vsprintf(buf, fmt, args);
va_end(args);
- fd = open("/dev/root", O_RDWR | O_NDELAY, 0);
+ fd = open("/dev/root", O_RDONLY | O_NDELAY, 0);
if (fd >= 0) {
sys_ioctl(fd, FDEJECT, 0);
close(fd);