[] FreeBSD bug: kern/86767 bogus "slice starts beyond end of the disk:..." mount. [] Most accesses to USB floppy drives, especially mounts, tend to result in bogus "slice starts beyond end of the disk:..." errors. [] if the boot parameter block claims the device is a floppy media then it is NOW assumed there is no partition table to check. [] Much thanks to Bruce Evans for hints on where to drop this patch. --- sys/msdosfs/bootsect.h Fri Aug 27 20:48:06 1999 +++ sys/msdosfs/bootsect.h Mon Oct 3 18:04:27 2005 @@ -94,6 +94,34 @@ struct bootsector710 bs710; }; + + /* selected media description bytes within bsPBP. used to detect + * media that only has one slice on it. for now this is expected + * to be floppy media. + ghealton@exit109.com & ... @lumeta.com */ + /* (as of 2005-09 floppy media description bytes were available at + http://support.microsoft.com/default.aspx?scid=kb;en-us;140418 + http://www.win.tue.nl/~aeb/linux/fs/fat/fat-1.html) + /* size DOS Capicty sides tks spt */ +#define MSDOS_MEDIA_ONESLICE0 0xF9 /* 5.25 3.0 1200KB 2 80 15 */ +#define MSDOS_MEDIA_ONESLICE1 0xFF /* 5.25 1.1 320KB 2 40 8 */ + +#define MSDOS_MEDIA_ONESLICE2 0xF0 /* 3.5 ?.? 2880KB 2 80 36 */ + +#define MSDOS_MEDIA_oneslice(c) ( \ + ( md >= MSDOS_MEDIA_ONESLICE0 && md <= MSDOS_MEDIA_ONESLICE1 ) \ + || ( md == MSDOS_MEDIA_ONESLICE2 ) \ + ) + /* if floppies with slice tables are ever used I suspose + that a check for s1-s4 could be made to verify the + first byte of each slice table is 0x00 or 0x80 AND + at most one byte has the 0x80 value in it AND the + remaining bytes of each slice table are not all zeros. If + this test is met you might be able to assume a slice + table exists. But I would make such a compile-option for + those expressly asking for it. */ + + #if 0 /* * Shorthand for fields in the bpb. --- sys/kern/subr_diskmbr.c Fri Jan 28 05:22:07 2000 +++ sys/kern/subr_diskmbr.c Mon Oct 3 18:16:19 2005 @@ -42,6 +42,7 @@ #include #include #include +#include /* BOOTSIG0, BOOTSIG1, MSDOS_MEDIA_oneslice */ #ifdef PC98 #define PC98_ATCOMPAT #define dsinit atcompat_dsinit @@ -200,13 +201,26 @@ /* Weakly verify it. */ cp = bp->b_data; sname = dsname(dev, dkunit(dev), WHOLE_DISK_SLICE, RAW_PART, partname); - if (cp[0x1FE] != 0x55 || cp[0x1FF] != 0xAA) { + if (cp[0x1FE] != BOOTSIG0 || cp[0x1FF] != BOOTSIG1) { if (bootverbose) printf("%s: invalid primary partition table: no magic\n", sname); error = EINVAL; goto done; } + + { /* ghealton@exit109.com also ....@lumeta.com */ + /* check if media description byte within range of known floppy medias */ + + u_char md = cp[0x15]; /* set local easy access variable */ + + if ( MSDOS_MEDIA_oneslice(md) ) { + /* this media only uses a single slice (e.g., floppies) */ + + error = 0; + goto done; /* no partition table to process */ + } + } /* Make a copy of the partition table to avoid alignment problems. */ memcpy(&dpcopy[0], cp + DOSPARTOFF, sizeof(dpcopy));