[PATCH] Further change to change_floppy()

Leigh Brown (leigh@solinno.co.uk)
04 Jun 2002 09:42:06 +0100


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);

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/