Hello,
The following patch makes the floppy driver more robust against
filesystem code that may perform improper operations (such as
check_media_change and revalidate) on unopened devices.
Whith it, you can again mount ext2 and vfat floppies in the
2.4.0-test1 and 2.4.0-test2 kernels (you still get a couple of short
warning messages, but the stability of the kernel is no longer
compromised)
Regards,
Alain
--- 2.4.0.2/linux/drivers/block/floppy.c Tue Jul 4 23:04:10 2000
+++ linux/drivers/block/floppy.c Wed Jul 5 23:01:19 2000
@@ -852,10 +852,10 @@
}
/* locks the driver */
-static int lock_fdc(int drive, int interruptible)
+static int _lock_fdc(int drive, int interruptible, int line)
{
if (!usage_count){
- printk(KERN_ERR "Trying to lock fdc while usage count=0\n");
+ printk(KERN_ERR "Trying to lock fdc while usage count=0 at line %d\n", line);
return -1;
}
if(floppy_grab_irq_and_dma()==-1)
@@ -889,6 +889,8 @@
return 0;
}
+#define lock_fdc(drive,interruptible) _lock_fdc(drive,interruptible, __LINE__)
+
#define LOCK_FDC(drive,interruptible) \
if (lock_fdc(drive,interruptible)) return -EINTR;
@@ -2601,6 +2603,11 @@
int aligned_sector_t;
int max_sector, max_size, tracksize, ssize;
+ if(max_buffer_sectors == 0) {
+ printk("VFS: Block I/O scheduled on unopened device\n");
+ return 0;
+ }
+
set_fdc(DRIVE(CURRENT->rq_dev));
raw_cmd = &default_raw_cmd;
@@ -2955,6 +2962,11 @@
static void do_fd_request(request_queue_t * q)
{
+ if(max_buffer_sectors == 0) {
+ printk("VFS: do_fd_request called on non-open device\n");
+ return;
+ }
+
if (usage_count == 0) {
printk("warning: usage count=0, CURRENT=%p exiting\n", CURRENT);
printk("sect=%ld cmd=%d\n", CURRENT->sector, CURRENT->cmd);
@@ -3782,9 +3794,14 @@
return 1;
if (UDP->checkfreq < (int)(jiffies - UDRS->last_checked)) {
+ if(floppy_grab_irq_and_dma()) {
+ return 1;
+ }
+
lock_fdc(drive,0);
poll_drive(0,0);
process_fd_request();
+ floppy_release_irq_and_dma();
}
if (UTESTF(FD_DISK_CHANGED) ||
@@ -3810,6 +3827,10 @@
UTESTF(FD_VERIFY) ||
test_bit(drive, &fake_change) ||
NO_GEOM){
+ if(usage_count == 0) {
+ printk("VFS: revalidate called on non-open device.\n");
+ return -EFAULT;
+ }
lock_fdc(drive,0);
cf = UTESTF(FD_DISK_CHANGED) || UTESTF(FD_VERIFY);
if (!(cf || test_bit(drive, &fake_change) || NO_GEOM)){
@@ -3831,7 +3852,7 @@
size = 1024;
if (!(bh = getblk(dev,0,size))){
process_fd_request();
- return 1;
+ return -ENXIO;
}
if (bh && !buffer_uptodate(bh))
ll_rw_block(READ, 1, &bh);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/
This archive was generated by hypermail 2b29 : Fri Jul 07 2000 - 21:00:19 EST