summaryrefslogtreecommitdiffstats
path: root/source/a/floppy/fdutils-5.5-20081027.diff
diff options
context:
space:
mode:
Diffstat (limited to 'source/a/floppy/fdutils-5.5-20081027.diff')
-rw-r--r--source/a/floppy/fdutils-5.5-20081027.diff905
1 files changed, 905 insertions, 0 deletions
diff --git a/source/a/floppy/fdutils-5.5-20081027.diff b/source/a/floppy/fdutils-5.5-20081027.diff
new file mode 100644
index 000000000..d4033be37
--- /dev/null
+++ b/source/a/floppy/fdutils-5.5-20081027.diff
@@ -0,0 +1,905 @@
+diff -ur --new-file --exclude-from=/home/alain/Projects/Fdutils/exclude fdutils-5.5/Changelog fdutils/Changelog
+--- fdutils-5.5/Changelog 2005-03-03 22:41:49.000000000 +0100
++++ fdutils/Changelog 2006-02-27 23:01:38.000000000 +0100
+@@ -1,3 +1,5 @@
++v20060227
++ * Fixed "zero-based" flag
+ v20050303
+ * Fixed instant verification in superformat (now based on
+ FDRAWCMD, rather than VFS' read which is plagued by excessive
+diff -ur --new-file --exclude-from=/home/alain/Projects/Fdutils/exclude fdutils-5.5/doc/diskd.1 fdutils/doc/diskd.1
+--- fdutils-5.5/doc/diskd.1 2005-03-03 22:55:18.000000000 +0100
++++ fdutils/doc/diskd.1 2008-10-27 20:53:44.000000000 +0100
+@@ -1,4 +1,4 @@
+-.TH diskd 1 "03Mar05" fdutils-5.5
++.TH diskd 1 "27oct08" fdutils-5.5
+ .SH Name
+ diskd - disk daemon; wait for disk to be inserted
+ '\" t
+diff -ur --new-file --exclude-from=/home/alain/Projects/Fdutils/exclude fdutils-5.5/doc/diskseekd.1 fdutils/doc/diskseekd.1
+--- fdutils-5.5/doc/diskseekd.1 2005-03-03 22:55:18.000000000 +0100
++++ fdutils/doc/diskseekd.1 2008-10-27 20:53:44.000000000 +0100
+@@ -1,4 +1,4 @@
+-.TH diskseekd 1 "03Mar05" fdutils-5.5
++.TH diskseekd 1 "27oct08" fdutils-5.5
+ .SH Name
+ diskseek, diskseekd - disk seek daemon; simulates Messy Dos' drive cleaning effect
+ '\" t
+diff -ur --new-file --exclude-from=/home/alain/Projects/Fdutils/exclude fdutils-5.5/doc/fdmount.1 fdutils/doc/fdmount.1
+--- fdutils-5.5/doc/fdmount.1 2005-03-03 22:55:18.000000000 +0100
++++ fdutils/doc/fdmount.1 2008-10-27 20:53:45.000000000 +0100
+@@ -1,4 +1,4 @@
+-.TH fdmount 1 "03Mar05" fdutils-5.5
++.TH fdmount 1 "27oct08" fdutils-5.5
+ .SH Name
+ fdmount - Floppy disk mount utility
+ '\" t
+diff -ur --new-file --exclude-from=/home/alain/Projects/Fdutils/exclude fdutils-5.5/doc/fdrawcmd.1 fdutils/doc/fdrawcmd.1
+--- fdutils-5.5/doc/fdrawcmd.1 2005-03-03 22:55:18.000000000 +0100
++++ fdutils/doc/fdrawcmd.1 2008-10-27 20:53:45.000000000 +0100
+@@ -1,4 +1,4 @@
+-.TH fdrawcmd 1 "03Mar05" fdutils-5.5
++.TH fdrawcmd 1 "27oct08" fdutils-5.5
+ .SH Name
+ fdrawcmd - send raw commands to the floppy disk controller
+ '\" t
+diff -ur --new-file --exclude-from=/home/alain/Projects/Fdutils/exclude fdutils-5.5/doc/floppycontrol.1 fdutils/doc/floppycontrol.1
+--- fdutils-5.5/doc/floppycontrol.1 2005-03-03 22:55:18.000000000 +0100
++++ fdutils/doc/floppycontrol.1 2008-10-27 20:53:45.000000000 +0100
+@@ -1,4 +1,4 @@
+-.TH floppycontrol 1 "03Mar05" fdutils-5.5
++.TH floppycontrol 1 "27oct08" fdutils-5.5
+ .SH Name
+ floppycontrol - floppy driver configuration utility
+ '\" t
+diff -ur --new-file --exclude-from=/home/alain/Projects/Fdutils/exclude fdutils-5.5/doc/floppymeter.1 fdutils/doc/floppymeter.1
+--- fdutils-5.5/doc/floppymeter.1 2005-03-03 22:55:18.000000000 +0100
++++ fdutils/doc/floppymeter.1 2008-10-27 20:53:45.000000000 +0100
+@@ -1,4 +1,4 @@
+-.TH floppymeter 1 "03Mar05" fdutils-5.5
++.TH floppymeter 1 "27oct08" fdutils-5.5
+ .SH Name
+ floppymeter - measure raw capacity and exact rotation speed of floppy drive
+ '\" t
+diff -ur --new-file --exclude-from=/home/alain/Projects/Fdutils/exclude fdutils-5.5/doc/formatlist.texi fdutils/doc/formatlist.texi
+--- fdutils-5.5/doc/formatlist.texi 2002-05-02 23:03:31.000000000 +0200
++++ fdutils/doc/formatlist.texi 2006-02-27 23:08:50.000000000 +0100
+@@ -221,7 +221,7 @@
+ setfdprm /dev/fd0H1520 1520 19 2 80 0 0x1b 0 0xcf 0x6c
+ @end example
+
+-@strong{Note:} This redefines the geometry for any device node with the
++@strong{NB:} This redefines the geometry for any device node with the
+ same format number, not just the new node.
+
+ The new geometry is only valid until the next reboot (or removal of the
+diff -ur --new-file --exclude-from=/home/alain/Projects/Fdutils/exclude fdutils-5.5/doc/getfdprm.1 fdutils/doc/getfdprm.1
+--- fdutils-5.5/doc/getfdprm.1 2005-03-03 22:55:18.000000000 +0100
++++ fdutils/doc/getfdprm.1 2008-10-27 20:53:45.000000000 +0100
+@@ -1,4 +1,4 @@
+-.TH getfdprm 1 "03Mar05" fdutils-5.5
++.TH getfdprm 1 "27oct08" fdutils-5.5
+ .SH Name
+ getfdprm - print the current format information
+ '\" t
+diff -ur --new-file --exclude-from=/home/alain/Projects/Fdutils/exclude fdutils-5.5/doc/makefloppies.1 fdutils/doc/makefloppies.1
+--- fdutils-5.5/doc/makefloppies.1 2005-03-03 22:55:18.000000000 +0100
++++ fdutils/doc/makefloppies.1 2008-10-27 20:53:45.000000000 +0100
+@@ -1,4 +1,4 @@
+-.TH makefloppies 1 "03Mar05" fdutils-5.5
++.TH makefloppies 1 "27oct08" fdutils-5.5
+ .SH Name
+ MAKEFLOPPIES - Creates the default floppy device nodes.
+ '\" t
+diff -ur --new-file --exclude-from=/home/alain/Projects/Fdutils/exclude fdutils-5.5/doc/setfdprm.1 fdutils/doc/setfdprm.1
+--- fdutils-5.5/doc/setfdprm.1 2005-03-03 22:55:18.000000000 +0100
++++ fdutils/doc/setfdprm.1 2008-10-27 20:53:45.000000000 +0100
+@@ -1,4 +1,4 @@
+-.TH setfdprm 1 "03Mar05" fdutils-5.5
++.TH setfdprm 1 "27oct08" fdutils-5.5
+ .SH Name
+ setfdprm - sets user-provided floppy disk parameters
+ '\" t
+diff -ur --new-file --exclude-from=/home/alain/Projects/Fdutils/exclude fdutils-5.5/doc/superformat.1 fdutils/doc/superformat.1
+--- fdutils-5.5/doc/superformat.1 2005-03-03 22:55:18.000000000 +0100
++++ fdutils/doc/superformat.1 2008-10-27 20:53:45.000000000 +0100
+@@ -1,4 +1,4 @@
+-.TH superformat 1 "03Mar05" fdutils-5.5
++.TH superformat 1 "27oct08" fdutils-5.5
+ .SH Name
+ superformat - format floppies
+ '\" t
+@@ -79,7 +79,7 @@
+ .in +0.3i
+ \&\fR\&\f(CWsuperformat [\fR\&\f(CW-D \fIdos-drive\fR\&\f(CW] [\fR\&\f(CW-v \fIverbosity-level\fR\&\f(CW] [\fR\&\f(CW-b \fIbegin-track\fR\&\f(CW]
+ [\fR\&\f(CW-e \fIend-track\fR\&\f(CW] [\fR\&\f(CW--superverify] [\fR\&\f(CW--dosverify]
+-[\fR\&\f(CW--noverify] [\fR\&\f(CW--verify_later] [\fR\&\f(CW--zero-based]
++[\fR\&\f(CW--noverify] [\fR\&\f(CW--verify_later] [\fR\&\f(CW--first-sector-number \fIn\fR\&\f(CW] [\fR\&\f(CW--zero-based]
+ [\fR\&\f(CW-G \fIformat-gap\fR\&\f(CW] [\fR\&\f(CW-F \fIfinal-gap\fR\&\f(CW] [\fR\&\f(CW-i \fIinterleave\fR\&\f(CW] [\fR\&\f(CW-c \fIchunksize\fR\&\f(CW]
+ [\fR\&\f(CW-g \fIgap\fR\&\f(CW] [\fR\&\f(CW--absolute-skew \fIabsolute-skew\fR\&\f(CW] [\fR\&\f(CW--head-skew \fIhead-skew\fR\&\f(CW]
+ [\fR\&\f(CW--track-skew \fItrack-skew\fR\&\f(CW] [\fR\&\f(CW--biggest-last] \fIdrive\fR\&\f(CW [\fImedia-description\fR\&\f(CW]
+@@ -237,13 +237,12 @@
+ For MSS formats, make sure that the biggest sector is last on the track.
+ This makes the format more reliable on drives which are out of spec.
+ .TP
++\&\fR\&\f(CW--first-sector-number\ \fIn\fR\&\f(CW\fR\
++Formats the disk with sector numbers starting at \fIn\fR, rather than
++1. Certain CP/M boxes or Music synthesizers use this format.
++.TP
+ \&\fR\&\f(CW--zero-based\fR\
+-Formats the disk with sector numbers starting at 0, rather than
+-1. Certain CP/M boxes or Music synthesizers use this format. Those disks
+-can currently not be read/written to by the standard Linux read/write
+-API; you have to use fdrawcmd to access them. As disk verifying is done
+-by this API, verifying is automatically switched off when formatting
+-zero-based.
++Shorthand for \fR\&\f(CW--first-sector-number 0\fR
+ .PP
+ .SH Sector\ skewing\ options
+ .PP
+diff -ur --new-file --exclude-from=/home/alain/Projects/Fdutils/exclude fdutils-5.5/doc/superformat.texi fdutils/doc/superformat.texi
+--- fdutils-5.5/doc/superformat.texi 2002-11-02 14:35:11.000000000 +0100
++++ fdutils/doc/superformat.texi 2008-10-27 20:53:41.000000000 +0100
+@@ -6,7 +6,7 @@
+ @example
+ @code{superformat} [@code{-D} @var{dos-drive}] [@code{-v} @var{verbosity-level}] [@code{-b} @var{begin-track}]
+ [@code{-e} @var{end-track}] [@code{--superverify}] [@code{--dosverify}]
+-[@code{--noverify}] [@code{--verify_later}] [@code{--zero-based}]
++[@code{--noverify}] [@code{--verify_later}] [@code{--first-sector-number} @var{n}] [@code{--zero-based}]
+ [@code{-G} @var{format-gap}] [@code{-F} @var{final-gap}] [@code{-i} @var{interleave}] [@code{-c} @var{chunksize}]
+ [@code{-g} @var{gap}] [@code{--absolute-skew} @var{absolute-skew}] [@code{--head-skew} @var{head-skew}]
+ [@code{--track-skew} @var{track-skew}] [@code{--biggest-last}] @var{drive} [@var{media-description}]
+@@ -162,13 +162,12 @@
+ For MSS formats, make sure that the biggest sector is last on the track.
+ This makes the format more reliable on drives which are out of spec.
+
++@item --first-sector-number @var{n}
++Formats the disk with sector numbers starting at @var{n}, rather than
++1. Certain CP/M boxes or Music synthesizers use this format.
++
+ @item --zero-based
+-Formats the disk with sector numbers starting at 0, rather than
+-1. Certain CP/M boxes or Music synthesizers use this format. Those disks
+-can currently not be read/written to by the standard Linux read/write
+-API; you have to use fdrawcmd to access them. As disk verifying is done
+-by this API, verifying is automatically switched off when formatting
+-zero-based.
++Shorthand for @code{--first-sector-number 0}
+
+ @end table
+
+diff -ur --new-file --exclude-from=/home/alain/Projects/Fdutils/exclude fdutils-5.5/doc/xdfcopy.1 fdutils/doc/xdfcopy.1
+--- fdutils-5.5/doc/xdfcopy.1 2005-03-03 22:55:18.000000000 +0100
++++ fdutils/doc/xdfcopy.1 2008-10-27 20:53:45.000000000 +0100
+@@ -1,4 +1,4 @@
+-.TH xdfcopy 1 "03Mar05" fdutils-5.5
++.TH xdfcopy 1 "27oct08" fdutils-5.5
+ .SH Name
+ xdfcopy - Program to copy and format Xdf disks in Linux
+ '\" t
+diff -ur --new-file --exclude-from=/home/alain/Projects/Fdutils/exclude fdutils-5.5/src/calc-format.c fdutils/src/calc-format.c
+--- fdutils-5.5/src/calc-format.c 2004-02-28 23:00:28.000000000 +0100
++++ fdutils/src/calc-format.c 2008-10-27 20:19:20.000000000 +0100
+@@ -10,8 +10,8 @@
+ #define SSIZE(j) ( (128<<j) + GAPSIZE(j) + header_size)
+
+
+-static inline int chunks_in_sect(struct params *fd, int i,
+- int gap, int chunksize)
++static inline unsigned int chunks_in_sect(struct params *fd, int i,
++ int gap, int chunksize)
+ {
+ return (SSIZE(i)-1) / chunksize + 1;
+ }
+@@ -28,22 +28,22 @@
+ }
+
+
+-static inline int firstSector(struct params *fd, int i)
++static inline unsigned int firstSector(struct params *fd, int i)
+ {
+ if(i>=MAX_SIZECODE-1)
+- return 1;
++ return 0;
+ else
+ return fd->last_sect[i+1];
+ }
+
+-static inline int lastSector(struct params *fd, int i)
++static inline unsigned int lastSector(struct params *fd, int i)
+ {
+ return fd->last_sect[i];
+ }
+
+-static inline int nrSectorsForSize(struct params *fd, int i)
++static inline unsigned int nrSectorsForSize(struct params *fd, int i)
+ {
+- return lastSector(fd, i) - firstSector(fd, i);
++ return lastSector(fd, i) - firstSector(fd, i);
+ }
+
+
+@@ -93,7 +93,7 @@
+ int i;
+ int nr_sectors;
+
+- cur_sector = 1;
++ cur_sector = 0;
+ sizes=0;
+ for (i=MAX_SIZECODE-1; i>=0; --i) {
+ if(i > max_sizecode)
+@@ -107,7 +107,7 @@
+ if(nr_sectors)
+ sizes++;
+ }
+- fd->dsect = cur_sector-1; /* number of data sectors */
++ fd->dsect = cur_sector; /* number of data sectors */
+ if(sizes > 1)
+ fd->need_init = 1;
+
+@@ -264,51 +264,54 @@
+ */
+ static void calc_sequence(struct params *fd, int tailsect)
+ {
+- int sec_id, cur_sector, i;
++ int sec_id, cur_slot, i;
++ int *occupied = SafeNewArray(fd->dsect, int);
++ int last_slot = fd->dsect - 1;
+
+- fd->sequence = SafeNewArray(fd->dsect,struct fparm2);
+- cur_sector = fd->dsect-1;
++ fd->sequence = SafeNewArray(fd->dsect, struct fparm2);
++ cur_slot = last_slot;
+
+- /* construct the sequence while working backwards. cur_sector
++ /* construct the sequence while working backwards. cur_slot
+ * points to the place where the next sector will be placed.
+ * We place it, then move circularily backwards placing more
+ * and more sectors */
+ sec_id = tailsect;
+ fd->rotations = 0;
+ for(i=0; i < fd->dsect;
+- i++, cur_sector -= fd->actual_interleave, sec_id--) {
+- if (sec_id == 0)
+- sec_id = fd->dsect;
+-
+- if ( cur_sector < 0) {
+- cur_sector += fd->dsect;
+- if(sec_id != fd->dsect)
++ i++, cur_slot -= fd->actual_interleave, sec_id--) {
++ if (sec_id < 0)
++ sec_id = last_slot;
++
++ if ( cur_slot < 0) {
++ cur_slot += fd->dsect;
++ if(sec_id != last_slot)
+ fd->rotations++;
+ }
+
+ /* slot occupied, look elsewhere */
+- while(fd->sequence[cur_sector].sect ){
+- cur_sector--;
+- if ( cur_sector < 0 ) {
+- cur_sector += fd->dsect;
+- if(sec_id != fd->dsect)
++ while(occupied[cur_slot]) {
++ cur_slot--;
++ if ( cur_slot < 0 ) {
++ cur_slot += fd->dsect;
++ if(sec_id != last_slot)
+ fd->rotations++;
+ }
+ }
+
+ /* place the sector */
+- fd->sequence[cur_sector].sect = sec_id;
+- fd->sequence[cur_sector].size = sizeOfSector(fd, sec_id);
++ fd->sequence[cur_slot].sect = sec_id;
++ fd->sequence[cur_slot].size = sizeOfSector(fd, sec_id);
++ occupied[cur_slot] = 1;
+ }
+
+ /* handle wrap-around between tailsect and tailsect+1 */
+- if(tailsect != fd->dsect) {
+- /* always add one rotation, because tailsect+1 cannot be
++ if(tailsect != last_slot) {
++ /* always add one rotation, because tailsect cannot be
+ * at the last position, thus is necessarily earlyer */
+ fd->rotations++;
+
+ if(fd->actual_interleave == 2 &&
+- cur_sector + fd->actual_interleave == 1)
++ cur_slot + fd->actual_interleave == 1)
+ /* if we use interleave, and the last sector was
+ * placed at the first last position, add one
+ * extra rotation for tailsect+1 following tailsect
+@@ -333,11 +336,11 @@
+ max_offset = cur_sector;
+
+ /* offset of the starting sector */
+- if ( fd->sequence[i].sect == 1 )
++ if ( fd->sequence[i].sect == 0 )
+ fd->min = cur_sector * fd->chunksize;
+
+ /* offset of the end of the of the highest sector */
+- if (fd->sequence[i].sect == fd->dsect)
++ if (fd->sequence[i].sect == fd->dsect - 1)
+ track_end = cur_sector * fd->chunksize +
+ header_size + index_size +
+ SSIZE(fd->sequence[i].size);
+@@ -509,7 +512,7 @@
+ fd->min = 0;
+
+ for(i=0; i<sectors; i++){
+- fd->sequence[i].sect = i+1;
++ fd->sequence[i].sect = i;
+ fd->sequence[i].size = 2;
+ fd->sequence[i].offset = i;
+ }
+diff -ur --new-file --exclude-from=/home/alain/Projects/Fdutils/exclude fdutils-5.5/src/fdmount.c fdutils/src/fdmount.c
+--- fdutils-5.5/src/fdmount.c 2005-03-03 23:09:16.000000000 +0100
++++ fdutils/src/fdmount.c 2008-10-27 20:45:50.000000000 +0100
+@@ -629,7 +629,7 @@
+ struct mntent ms;
+ struct floppy_drive_struct drivstat;
+ char options[80+MAX_OPT];
+- char super[2048];
++ unsigned char super[2048];
+ char *mountpoint;
+
+ strncpy(curdev,devname, sizeof(curdev));
+diff -ur --new-file --exclude-from=/home/alain/Projects/Fdutils/exclude fdutils-5.5/src/fdutils.h fdutils/src/fdutils.h
+--- fdutils-5.5/src/fdutils.h 2002-05-02 23:03:31.000000000 +0200
++++ fdutils/src/fdutils.h 2008-10-25 22:17:36.000000000 +0200
+@@ -1,4 +1,8 @@
++#ifndef __FDUTILS_H
++#define __FDUTILS_H
++
+ #include <assert.h>
++#include <linux/fd.h>
+ /* This file contains common structures understood by several of the
+ * fdutils
+ */
+@@ -22,3 +26,17 @@
+ #define SafeNew(type) ((type *)(safe_malloc(sizeof(type))))
+ void *safe_malloc(size_t size);
+ void *safe_calloc(size_t nmemb, size_t size);
++
++#ifndef FD_SWAPSIDES
++#define FD_SWAPSIDES 2
++#endif
++
++#ifndef FD_ZEROBASED
++#define FD_ZEROBASED 4
++#endif
++
++#ifndef FD_SECTBASEMASK
++#define FD_SECTBASEMASK 0x3fc
++#endif
++
++#endif
+diff -ur --new-file --exclude-from=/home/alain/Projects/Fdutils/exclude fdutils-5.5/src/floppycontrol.c fdutils/src/floppycontrol.c
+--- fdutils-5.5/src/floppycontrol.c 2002-11-02 14:36:43.000000000 +0100
++++ fdutils/src/floppycontrol.c 2008-10-26 09:27:38.000000000 +0100
+@@ -379,7 +379,7 @@
+ }
+
+ if (mask & SET_RESET)
+- eioctl(fd, FDRESET, (void *)reset_now, "reset");
++ eioctl(fd, FDRESET, (void *)(long)reset_now, "reset");
+
+ if (mask & (PRINTSTATE | POLLSTATE) ){
+ if ( mask & POLLSTATE )
+diff -ur --new-file --exclude-from=/home/alain/Projects/Fdutils/exclude fdutils-5.5/src/mediaprm.c fdutils/src/mediaprm.c
+--- fdutils-5.5/src/mediaprm.c 2005-03-03 21:51:06.000000000 +0100
++++ fdutils/src/mediaprm.c 2008-10-27 20:34:09.000000000 +0100
+@@ -21,6 +21,7 @@
+ FE_STRETCH,
+ FE_SWAPSIDES,
+ FE_ZEROBASED,
++ FE_FIRSTSECTORNUMBER,
+
+ FE_GAP,
+
+@@ -36,7 +37,7 @@
+ FE_DENSITY,
+ } field_t;
+
+-static int SIZE, SECT, VSECT, HEAD, CYL, TPI, STRETCH, SWAPSIDES, ZEROBASED;
++static int SIZE, SECT, VSECT, HEAD, CYL, TPI, STRETCH, SWAPSIDES, ZEROBASED, FIRSTSECTORNUMBER=1;
+ static int GAP, FM;
+ static int PERP, SSIZE, _2M, DTR, SPEC1, FMT_GAP, DENSITY;
+ static int ssize;
+@@ -51,6 +52,7 @@
+ #define F_STRETCH FE_STRETCH,&STRETCH
+ #define F_SWAPSIDES FE_SWAPSIDES,&SWAPSIDES
+ #define F_ZEROBASED FE_ZEROBASED,&ZEROBASED
++#define F_FIRSTSECTORNUMBER FE_FIRSTSECTORNUMBER,&FIRSTSECTORNUMBER
+
+ #define F_GAP FE_GAP,&GAP
+
+@@ -81,6 +83,8 @@
+
+ { "swapsides", F_SWAPSIDES, 1},
+ { "zerobased", F_ZEROBASED, 1},
++ { "zero-based", F_ZEROBASED, 1},
++ { "first-sector-number", F_FIRSTSECTORNUMBER, 0},
+
+ { "gap", F_GAP, 0},
+
+@@ -234,11 +238,25 @@
+ }
+ set_field(F_2M,0);
+
++ if(mask & (1 << FE_ZEROBASED)) {
++ if((mask & (1 << FE_FIRSTSECTORNUMBER)) &&
++ FIRSTSECTORNUMBER != 0) {
++ fprintf(stderr,
++ "Zerobased incompatible with first-sector-number=%d\n",
++ FIRSTSECTORNUMBER);
++ exit(1);
++ } else
++ FIRSTSECTORNUMBER = 0;
++ } else if(! (mask & (1 << FE_FIRSTSECTORNUMBER))) {
++ FIRSTSECTORNUMBER = 1;
++ }
++
+ medprm->size = SIZE;
+ medprm->sect = VSECT / 512;
+ medprm->head = HEAD;
+ medprm->track = CYL;
+- medprm->stretch = STRETCH | (SWAPSIDES << 1) | (ZEROBASED << 2);
++ medprm->stretch = STRETCH | (SWAPSIDES << 1) |
++ ((1^FIRSTSECTORNUMBER) << 2);
+ medprm->gap = GAP;
+ medprm->rate = (FM<<7) | (PERP<<6) | (ssize<<3) | (_2M<<2) | DTR;
+ medprm->spec1 = SPEC1;
+diff -ur --new-file --exclude-from=/home/alain/Projects/Fdutils/exclude fdutils-5.5/src/mediaprm.lex fdutils/src/mediaprm.lex
+--- fdutils-5.5/src/mediaprm.lex 2002-05-02 23:03:31.000000000 +0200
++++ fdutils/src/mediaprm.lex 2006-02-27 22:56:21.000000000 +0100
+@@ -12,7 +12,7 @@
+ %option pointer
+
+ fid [^\"]+
+-vid [A-Za-z_][A-Za-z0-9_]*
++vid [A-Za-z_][A-Za-z0-9_-]*
+ number (0x[a-zA-Z0-9]+|-?[0-9]+)(KB|k|b)?
+
+ %%
+@@ -37,6 +37,8 @@
+ }
+
+ swapsides |
++zerobased |
++zero-based |
+ mss |
+ 2m |
+ 2M |
+diff -ur --new-file --exclude-from=/home/alain/Projects/Fdutils/exclude fdutils-5.5/src/msdos_fs.h fdutils/src/msdos_fs.h
+--- fdutils-5.5/src/msdos_fs.h 2002-05-02 23:03:31.000000000 +0200
++++ fdutils/src/msdos_fs.h 2008-10-26 09:27:07.000000000 +0100
+@@ -6,41 +6,41 @@
+ #define p packed
+
+ struct msdos_boot_sector {
+- char jump[3] p; /* 0 - Boot strap short or near jump */
+- char banner[8] p; /* 3 - Name - can be used to special case
++ char jump[3]; /* 0 - Boot strap short or near jump */
++ char banner[8]; /* 3 - Name - can be used to special case
+ partition manager volumes */
+ unsigned short sector_size p; /* 11 - bytes per logical sector */
+- unsigned char cluster_size p; /* 13 - sectors/cluster */
++ unsigned char cluster_size; /* 13 - sectors/cluster */
+ unsigned short res_sect p; /* 14 - reserved sectors */
+- unsigned char fats p; /* 16 - number of FATs */
++ unsigned char fats; /* 16 - number of FATs */
+ unsigned short dir_entries p; /* 17 - root directory entries */
+ unsigned short sectors p; /* 19 - number of sectors */
+- unsigned char media p; /* 21 - media code (unused) */
++ unsigned char media; /* 21 - media code (unused) */
+ unsigned short fat_length p; /* 22 - sectors/FAT */
+ unsigned short secs_track p; /* 24 - sectors per track */
+ unsigned short heads p; /* 26 - number of heads */
+ unsigned long hidden p; /* 28 - hidden sectors (unused) */
+ unsigned long total_sect p; /* 32 - number of sectors (if sectors == 0) */
+- unsigned char physdrive p; /* 36 physical drive ? */
+- unsigned char _reserved p; /* 37 reserved */
+- unsigned char dos4 p; /* 38 DOS > 4.0 diskette */
++ unsigned char physdrive; /* 36 physical drive ? */
++ unsigned char _reserved; /* 37 reserved */
++ unsigned char dos4; /* 38 DOS > 4.0 diskette */
+ unsigned long serial p; /* 39 serial number */
+- unsigned char label[11] p; /* 43 disk label */
+- unsigned char fat_type[8] p; /* 54 FAT type */
++ unsigned char label[11]; /* 43 disk label */
++ char fat_type[8]; /* 54 FAT type */
+ #ifdef USE_2M
+- unsigned char res_2m p; /* 62 reserved by 2M */
+- unsigned char CheckSum p; /* 63 2M checksum (not used) */
+- unsigned char fmt_2mf p; /* 64 2MF format version */
+- unsigned char wt p; /* 65 1 if write track after format */
+- unsigned char rate_0 p; /* 66 data transfer rate on track 0 */
+- unsigned char rate_any p; /* 67 data transfer rate on track<>0 */
++ unsigned char res_2m; /* 62 reserved by 2M */
++ unsigned char CheckSum; /* 63 2M checksum (not used) */
++ unsigned char fmt_2mf; /* 64 2MF format version */
++ unsigned char wt; /* 65 1 if write track after format */
++ unsigned char rate_0; /* 66 data transfer rate on track 0 */
++ unsigned char rate_any; /* 67 data transfer rate on track<>0 */
+ unsigned short BootP p; /* 68 offset to boot program */
+ unsigned short Infp0 p; /* 70 T1: information for track 0 */
+ unsigned short InfpX p; /* 72 T2: information for track<>0 */
+ unsigned short InfTm p; /* 74 T3: track sectors size table */
+- unsigned char junk[126 - 76] p; /* 76 remaining data */
++ unsigned char junk[126 - 76]; /* 76 remaining data */
+ #else
+- unsigned char junk[126 - 62] p; /* 76 remaining data */
++ unsigned char junk[126 - 62]; /* 76 remaining data */
+ #endif
+ unsigned short bootid p; /* 510 should be 0xAA55 */
+ };
+diff -ur --new-file --exclude-from=/home/alain/Projects/Fdutils/exclude fdutils-5.5/src/printfdprm.c fdutils/src/printfdprm.c
+--- fdutils-5.5/src/printfdprm.c 2004-03-13 11:02:45.000000000 +0100
++++ fdutils/src/printfdprm.c 2008-10-27 00:59:01.000000000 +0100
+@@ -1,5 +1,6 @@
+ #include <stdio.h>
+ #include "printfdprm.h"
++#include "fdutils.h"
+
+
+ void print_params(drivedesc_t *drivedesc,
+@@ -101,9 +102,9 @@
+ print("tpi=48",0);
+ break;
+ default:
+- if(level >= LEV_ALL || ft->stretch)
+- print("stretch=%d", ft->stretch);
+- break;
++ if(level >= LEV_ALL || (ft->stretch & 1))
++ print("stretch=%d", ft->stretch & 1);
++ break;
+ }
+
+ if(level >= LEV_ALL || ft->size != ft->sect * ft->head * ft->track)
+@@ -136,20 +137,20 @@
+ if(level >= LEV_EXPL || (ft->track != 80 && ft->track != 40))
+ print("cyl=%d", ft->track);
+
+-#ifdef FD_SWAPSIDES
+ if(ft->stretch & FD_SWAPSIDES)
+ print("swapsides",0);
+-#endif
+-
+-#ifdef FD_ZEROBASED
+- if(ft->stretch & FD_ZEROBASED)
+- print("zerobased",0);
+-#endif
+
++ if(ft->stretch & FD_SECTBASEMASK) {
++ int firstSectorNumber = ((ft->stretch & FD_SECTBASEMASK)>>2)^1;
++ if(firstSectorNumber > 1)
++ print("first-sector-number=%d",firstSectorNumber);
++ else if(firstSectorNumber==0)
++ print("zero-based",0);
++ }
+
+ if(ft->rate & FD_2M)
+ print("2M",0);
+-
++
+ if(level < LEV_ALL &&
+ ft->sect * 4 < (2 << ssize) && ft->sect * 4 % (1 << ssize))
+ print("mss", 0);
+@@ -163,7 +164,7 @@
+ }
+
+ /* useless stuff */
+- if(level >= LEV_MOST) {
++ if(level >= LEV_MOST) {
+ print("gap=0x%02x", (unsigned char) ft->gap);
+ print("fmt_gap=0x%02x", (unsigned char) ft->fmt_gap);
+ }
+diff -ur --new-file --exclude-from=/home/alain/Projects/Fdutils/exclude fdutils-5.5/src/superformat.c fdutils/src/superformat.c
+--- fdutils-5.5/src/superformat.c 2005-03-03 22:41:05.000000000 +0100
++++ fdutils/src/superformat.c 2008-10-27 20:40:47.000000000 +0100
+@@ -296,7 +296,7 @@
+ fd += findex[cylinder][head];
+ skew = fd->min + lskews[cylinder][head] * fd->chunksize;
+ assert(skew >= fd->min);
+- assert(skew <= fd->max);
++ assert(skew <= fd->max);
+ } else
+ skew = 0;
+
+@@ -305,7 +305,8 @@
+ for (i=0; i<fd->dsect; ++i){
+ offset = fd->sequence[i].offset + lskews[cylinder][head];
+ offset = offset % fd->nssect;
+- data[offset].sector = fd->sequence[i].sect - fd->zeroBased;
++ data[offset].sector =
++ fd->sequence[i].sect + fd->firstSectorNumber;
+ data[offset].size = fd->sequence[i].size;
+ data[offset].cylinder = cylinder;
+ data[offset].head = head;
+@@ -339,7 +340,7 @@
+ raw_cmd.cmd[3] = nssect;
+ raw_cmd.cmd[4] = fd->fmt_gap;
+ raw_cmd.cmd[5] = 0;
+- raw_cmd.flags = FD_RAW_WRITE | FD_RAW_INTR | FD_RAW_SPIN |
++ raw_cmd.flags = FD_RAW_WRITE | FD_RAW_INTR | FD_RAW_SPIN |
+ FD_RAW_NEED_SEEK | FD_RAW_NEED_DISK;
+ raw_cmd.track = cylinder << stretch;
+ raw_cmd.rate = fd->rate & 0x43;
+@@ -363,14 +364,16 @@
+ static int rw_track(struct params *fd, int cylinder, int head, int mode)
+ {
+ int i;
+- int cur_sector;
++ int cur_sector; /* current sector, logical (based on 0) */
+ int retries;
+ struct floppy_raw_cmd raw_cmd;
+
+- cur_sector = 1 - fd->zeroBased;
++ cur_sector = 0;
+
+ for (i=MAX_SIZECODE-1; i>=0; --i) {
+- if ( fd->last_sect[i] <= cur_sector + fd->zeroBased)
++ if ( cur_sector >= fd->last_sect[i] )
++ /* last sector for size reached, move on to next
++ * sizecode */
+ continue;
+ retries=0;
+ retry:
+@@ -383,32 +386,31 @@
+ (fd->swapSides ? 4 : 0);
+ raw_cmd.cmd[2] = cylinder;
+ raw_cmd.cmd[3] = head;
+- raw_cmd.cmd[4] = cur_sector;
++ raw_cmd.cmd[4] = cur_sector + fd->firstSectorNumber;
+ raw_cmd.cmd[5] = i;
+- raw_cmd.cmd[6] = fd->last_sect[i] - 1 - fd->zeroBased;
++ raw_cmd.cmd[6] = fd->last_sect[i] + fd->firstSectorNumber - 1;
+ raw_cmd.cmd[7] = fd->gap;
+ if ( i )
+ raw_cmd.cmd[8] = 0xff;
+ else
+ raw_cmd.cmd[8] = 0xff;
+- raw_cmd.flags = (mode ? FD_RAW_WRITE : FD_RAW_READ) |
++ raw_cmd.flags = (mode ? FD_RAW_WRITE : FD_RAW_READ) |
+ FD_RAW_INTR | FD_RAW_SPIN |
+ FD_RAW_NEED_SEEK | FD_RAW_NEED_DISK;
+ raw_cmd.track = cylinder << stretch;
+ raw_cmd.rate = fd->rate & 0x43;
+
+- raw_cmd.length = (fd->last_sect[i] -
+- fd->zeroBased -
+- cur_sector) * 128 << i;
++ raw_cmd.length = (fd->last_sect[i] - cur_sector) * 128 << i;
+ /* debugging */
+ if (verbosity == 9)
+ printf("%s %ld sectors of size %d starting at %d\n",
+ mode ? "writing" : "reading",
+ raw_cmd.length / 512, i, cur_sector);
+- if(send_cmd(fd->fd, & raw_cmd,
++ if(send_cmd(fd->fd, & raw_cmd,
+ mode ? "format" : "verify")){
+ if ( !retries && mode && (raw_cmd.reply[1] & ST1_ND) ){
+- cur_sector = raw_cmd.reply[5];
++ cur_sector =
++ raw_cmd.reply[5] - fd->firstSectorNumber;
+ retries++;
+ goto retry;
+ }
+@@ -516,6 +518,7 @@
+
+ short retries;
+ short zeroBased=0;
++ short firstSectorNumber=1;
+ short swapSides=0;
+ int n,rsize;
+ char *verify_buffer = NULL;
+@@ -673,6 +676,10 @@
+ (void *) &zeroBased,
+ "Start numbering sectors from 0 instead of 1 (not readable by normal I/O)" },
+
++ { '\0', "first-sector-number", 1, EO_TYPE_SHORT, 1, 0,
++ (void *) &firstSectorNumber,
++ "Number of first sector (by default, 1)" },
++
+ { '\0', 0 }
+ };
+
+@@ -693,6 +700,15 @@
+ exit(1);
+ }
+
++ if(zeroBased) {
++ if(firstSectorNumber == 1)
++ firstSectorNumber = 0;
++ else if(firstSectorNumber > 1) {
++ fprintf(stderr, "Contradiction between zeroBased and firstSectorNumber");
++ exit(1);
++ }
++ }
++
+ /* sanity checking */
+ if (sizecode < 0 || sizecode >= MAX_SIZECODE) {
+ fprintf(stderr,"Bad sizecode %d\n", sizecode);
+@@ -730,7 +746,7 @@
+ while(1) {
+ fd[0].fd = open(fd[0].name, O_RDWR | O_NDELAY | O_EXCL);
+
+- /* we open the disk wronly/rdwr in order to check write
++ /* we open the disk wronly/rdwr in order to check write
+ * protect */
+ if (fd[0].fd < 0) {
+ perror("open");
+@@ -778,7 +794,7 @@
+
+
+ if(have_geom) {
+- if(mask & (SET_SECTORS | SET_CYLINDERS |
++ if(mask & (SET_SECTORS | SET_CYLINDERS |
+ SET_HEADS | SET_SIZECODE | SET_2M | SET_RATE)) {
+ fprintf(stderr,
+ "Cannot mix old style and new style geometry spec\n");
+@@ -805,17 +821,14 @@
+ break;
+ }
+ stretch = geometry.stretch & 1;
+-#ifdef FD_ZEROBASED
+- if(geometry.stretch & FD_ZEROBASED) {
+- zeroBased = 1;
++ if(geometry.stretch & FD_SECTBASEMASK) {
++ firstSectorNumber =
++ ((geometry.stretch & FD_SECTBASEMASK)>>2)^1;
+ }
+-#endif
+-#ifdef FD_SWAPSIDES
+ if(geometry.stretch & FD_SWAPSIDES) {
+ swapSides = 1;
+ }
+-#endif
+- mask |= SET_SECTORS | SET_CYLINDERS |
++ mask |= SET_SECTORS | SET_CYLINDERS |
+ SET_SIZECODE | SET_2M | SET_RATE;
+ } else {
+ /* density */
+@@ -831,7 +844,7 @@
+ density = DRIVE_DEFAULTS.density;
+ if ( mask & SET_RATE ){
+ for (i=0; i< density; ++i) {
+- if(fd[0].rate ==
++ if(fd[0].rate ==
+ DRIVE_DEFAULTS.fmt[i].rate)
+ density=i;
+ }
+@@ -867,13 +880,7 @@
+ }
+ }
+
+- fd[0].zeroBased = zeroBased;
+-#ifndef FD_ZEROBASED
+- if(zeroBased) {
+- noverify = 1;
+- }
+-#endif
+-
++ fd[0].firstSectorNumber = firstSectorNumber;
+ fd[0].swapSides = swapSides;
+
+ if (cylinders > fd[0].drvprm.tracks) {
+@@ -914,7 +921,7 @@
+ header_size = 62;
+
+ if(! (mask & (SET_DEVIATION | SET_MARGIN)) &&
+- (drivedesc.mask & (1 << FE__DEVIATION))) {
++ (drivedesc.mask & (1 << FE__DEVIATION))) {
+ deviation = drivedesc.type.deviation;
+ mask |= SET_DEVIATION;
+ }
+@@ -947,14 +954,14 @@
+ "add the following line to " DRIVEPRMFILE ":\n");
+ fprintf(stdout,
+ "drive%d: deviation=%d\n",
+- fd[0].drive,
++ fd[0].drive,
+ (fd[0].raw_capacity-old_capacity)*1000000/
+ old_capacity);
+ fprintf(stderr,
+ "CAUTION: The line is drive and controller "
+- "specific, so it should be\n"
++ "specific, so it should be\n"
+ "removed before installing a new "
+- "drive %d or floppy controller.\n\n",
++ "drive %d or floppy controller.\n\n",
+ fd[0].drive);
+ }
+ }
+@@ -981,7 +988,7 @@
+ if (verbosity == 9) {
+ for (i=0; i<fd[0].dsect; ++i)
+ printf("s=%2d S=%2d o=%2d\n",
+- fd[0].sequence[i].sect,
++ fd[0].sequence[i].sect + firstSectorNumber,
+ fd[0].sequence[i].size,
+ fd[0].sequence[i].offset);
+
+@@ -1004,9 +1011,10 @@
+ if (verbosity == 9){
+ for (i=0; i< fd0.dsect; i++)
+ printf("s=%2d S=%2d o=%2d\n",
+- fd0.sequence[i].sect,
+- fd0.sequence[i].size,
+- fd0.sequence[i].offset);
++ fd0.sequence[i].sect +
++ fd0.firstSectorNumber,
++ fd0.sequence[i].size,
++ fd0.sequence[i].offset);
+
+ printf("fd[0].sizecode=%d\n", fd0.sizecode);
+ printf("fd[0].fmt_gap=%d\n", fd0.fmt_gap);
+@@ -1019,11 +1027,9 @@
+ parameters.head = heads;
+ parameters.track = cylinders;
+ parameters.size = cylinders * heads * sectors;
+- parameters.stretch = stretch
+-#ifdef FD_ZEROBASED
+- | (zeroBased ? 4 : 0)
+-#endif
+- | (swapSides ? 2 : 0);
++ parameters.stretch = stretch
++ | (swapSides ? 2 : 0)
++ | ((1^firstSectorNumber) << 2);
+ parameters.gap = fd[0].gap;
+ if ( !use_2m)
+ fd0.rate = fd[0].rate;
+@@ -1109,7 +1115,8 @@
+ ioctl(fd[0].fd, FDFLUSH );
+ close(fd[0].fd);
+
+- if (! (mask & SET_DOSDRIVE ) && fd[0].drive < 2 && !zeroBased)
++ if (! (mask & SET_DOSDRIVE ) && fd[0].drive < 2 &&
++ firstSectorNumber == 1)
+ dosdrive = fd[0].drive+'a';
+
+ if (dosdrive) {
+@@ -1133,14 +1140,14 @@
+ setenv("MTOOLS_RATE_ANY", env_buffer,1);
+ if(system(command_buffer)){
+ fprintf(stderr,"\nwarning: mformat error\n");
+- /*exit(1);*/
+- /* Do not fail, if mformat happens to not be
++ /*exit(1);*/
++ /* Do not fail, if mformat happens to not be
+ * installed. The user might have wanted to make
+ * an ext2 disk for instance */
+ dosverify = 0;
+ }
+ } else {
+- if(!zeroBased)
++ if(firstSectorNumber != 1)
+ fprintf(stderr,
+ "\nwarning: mformat not called because DOS drive unknown\n");
+ /*exit(1);*/
+@@ -1173,7 +1180,7 @@
+ n = read(fd[0].fd,verify_buffer,rsize);
+ if ( n < 0){
+ perror("read");
+- fprintf(stderr,
++ fprintf(stderr,
+ "remaining %d\n", n);
+ exit(1);
+ }
+diff -ur --new-file --exclude-from=/home/alain/Projects/Fdutils/exclude fdutils-5.5/src/superformat.h fdutils/src/superformat.h
+--- fdutils-5.5/src/superformat.h 2002-11-02 14:36:45.000000000 +0100
++++ fdutils/src/superformat.h 2008-10-27 20:17:54.000000000 +0100
+@@ -83,7 +83,7 @@
+ int length; /* length of the track */
+ int rotations; /* how many time do we have to go over 0 to read
+ * the track */
+- int zeroBased; /* 1 if sector numbering starts at zero */
++ int firstSectorNumber; /* Number of first sector (1, by default) */
+ int swapSides; /* if logical side 0 is on physical 1 and vice-versa */
+ };
+