[PATCH] Support for floppies whose sectors are numbered from zero

From: Alain Knaff (Alain.Knaff@ltnb.lu)
Date: Wed Jul 19 2000 - 14:33:27 EST


[Well, I admit it might be a little bit late for a "feature" patch,
codefreeze and all but this patch is rather small and thus low
risk...]

This patch adds support for floppy disks whose sectors are numbered
starting at 0 rather than 1 as usual disks would be. This format is
used for some CP/M disks, and also for certain music synthesizers
(Ensoniq sampler).

In order to use, you need to apply the fdutils-20000716 patch at
http://fdutils.linux.lu as well, and do
 setfdrpm /dev/fd0 dd zerobased sect=10
or
 setfdprm /dev/fd0 hd zerobased sect=20.
 
Regards,

Alain

diff -ur test5-pre3/linux/drivers/block/floppy.c linux/drivers/block/floppy.c
--- test5-pre3/linux/drivers/block/floppy.c Wed Jul 19 20:47:20 2000
+++ linux/drivers/block/floppy.c Wed Jul 19 21:15:24 2000
@@ -2229,6 +2229,10 @@
                         }
                 }
         }
+ if(_floppy->stretch & FD_ZEROBASED) {
+ for(count = 0; count < F_SECT_PER_TRACK; count++)
+ here[count].sect--;
+ }
 }
 
 static void redo_format(void)
@@ -2645,7 +2649,8 @@
         }
         HEAD = sector_t / _floppy->sect;
 
- if (((_floppy->stretch & FD_SWAPSIDES) || TESTF(FD_NEED_TWADDLE)) &&
+ if (( (_floppy->stretch & (FD_SWAPSIDES | FD_ZEROBASED)) ||
+ TESTF(FD_NEED_TWADDLE)) &&
             sector_t < _floppy->sect)
                 max_sector = _floppy->sect;
 
@@ -2675,7 +2680,8 @@
         GAP = _floppy->gap;
         CODE2SIZE;
         SECT_PER_TRACK = _floppy->sect << 2 >> SIZECODE;
- SECTOR = ((sector_t % _floppy->sect) << 2 >> SIZECODE) + 1;
+ SECTOR = ((sector_t % _floppy->sect) << 2 >> SIZECODE) +
+ ((_floppy->stretch & FD_ZEROBASED) ? 0 : 1);
 
         /* tracksize describes the size which can be filled up with sectors
          * of size ssize.
@@ -3312,7 +3318,7 @@
             g->track <= 0 ||
             g->track > UDP->tracks>>STRETCH(g) ||
             /* check if reserved bits are set */
- (g->stretch&~(FD_STRETCH|FD_SWAPSIDES)) != 0)
+ (g->stretch&~(FD_STRETCH|FD_SWAPSIDES|FD_ZEROBASED)) != 0)
                 return -EINVAL;
         if (type){
                 if (!capable(CAP_SYS_ADMIN))
@@ -3337,11 +3343,13 @@
                                               drive_state[cnt].fd_device));
                 }
         } else {
+ int oldStretch;
                 LOCK_FDC(drive,1);
                 if (cmd != FDDEFPRM)
                         /* notice a disk change immediately, else
                          * we lose our settings immediately*/
                         CALL(poll_drive(1, FD_RAW_NEED_DISK));
+ oldStretch = g->stretch;
                 user_params[drive] = *g;
                 if (buffer_drive == drive)
                         SUPBOUND(buffer_max, user_params[drive].sect);
@@ -3356,7 +3364,10 @@
                  * whose number will change. This is useful, because
                  * mtools often changes the geometry of the disk after
                  * looking at the boot block */
- if (DRS->maxblock > user_params[drive].sect || DRS->maxtrack)
+ if (DRS->maxblock > user_params[drive].sect ||
+ DRS->maxtrack ||
+ ((user_params[drive].sect ^ oldStretch) &
+ FD_SWAPSIDES | FD_ZEROBASED))
                         invalidate_drive(device);
                 else
                         process_fd_request();

-
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 : Sun Jul 23 2000 - 21:00:12 EST