usb/86767: [usb] bogus "slice starts beyond end of the disk:..."
Gilbert C Healton
ghealton at overpass.exit109.com
Mon Feb 6 09:10:12 PST 2006
The following reply was made to PR usb/86767; it has been noted by GNATS.
From: Gilbert C Healton <ghealton at overpass.exit109.com>
To: bug-followup at FreeBSD.org
Cc:
Subject: Re: usb/86767: [usb] bogus "slice starts beyond end of the disk:..."
Date: Mon, 6 Feb 2006 12:08:44 -0500 (EST)
>Fix:
There are actually two bugs in two different sections of the kernel.
Individual fixes for each problem follow:
86767-beyond.patch
fixes main "slice starts beyond end of the disk:..." problem.
Floppy disks are not expected to contain partition tables.
See additional documentation within the patch.
86767-unsupportedUFI.patch
fixes "umass0: contained Unsupported UFI command 0x35" problem
also reported in 86767. Originally I thought it was another
symptom of the same problem.
USB floppy drives now return "success" on SYNCHRONIZE_CACHE requests
These patches have been running for some months without causing any
problems.
86767-beyond.patch
--------------------------------------------------------------
[] 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 <bde at zeta.org.au> 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 at 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 <sys/systm.h>
#include <sys/buf.h>
#include <sys/conf.h>
+#include <msdosfs/bootsect.h> /* 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 at exit109.com also .... at 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));
86767-unsupportedUFI.patch
--------------------------------------------------------------
[] FreeBSD bug: kern/86767 bogus "slice starts beyond end of the disk:..."
mount. (also umass0: contained Unsupported UFI command 0x35, which
this patch addresses)
[] The unmount "unsupported UFI command" and "cache sync" errors are caused
by UFI operations not supporting SYNCHRONIZE_CACHE. They now no-operation
on SYNCHRONIZE_CACHE requests. Not an ideal solution, but it does
get rid of the message.
--- sys/dev/usb/umass.c Mon Sep 20 01:30:42 2004
+++ sys/dev/usb/umass.c Thu Oct 13 20:11:34 2005
@@ -2880,6 +2880,13 @@
}
switch (cmd[0]) {
+ /* { ghealton at exit109.com.com */
+ /* Commands which we ignore (for floppy drives) */
+ /* (a better way should occur, but that's all for now folks) */
+ case SYNCHRONIZE_CACHE:
+ return 1; /* return success */
+ /* } */
+
/* Commands of which the format has been verified. They should work. */
case TEST_UNIT_READY:
case REZERO_UNIT:
--------------------------------------------------------------
ghealton at exit109.com http://www.exit109.com/~ghealton/
--------------------------------------------------------------
Computers should be fun playthings or useful tools...
not obstacles to overcome.
More information about the freebsd-usb
mailing list