Ticket #257 (Fixed)Fri Nov 26 12:05:11 UTC 2010
DOSFS can corrupt FAT16 partitions with certain sectors-per-cluster values
Reported by: | Jeffrey Lee (213) | Severity: | Normal |
Part: | RISC OS: Module | Release: | |
Milestone: | Status | Fixed |
Details by Jeffrey Lee (213):
The following unix shell script will produce an 8MB FAT16 disc image, with 1 sector per cluster. Both Linux and Windows seem to handle the partition fine, but DOSFS will corrupt the partition when writing files. Copying small (e.g. <1MB) files will result in silent corruption that can later be detected by fsck, while copying big files (e.g. >=4MB) will result in a “Cluster chain is not consistent” error from DOSFS itself.
<pre>#!/bin/bash
dd if=/dev/zero of=wibble bs=8225280 count=1
sfdisk -C 1 -H 255 -S 63 -D wibble <<EOF
,,0×0e,*
EOF
sudo losetup -v -o 32256 /dev/loop0 wibble
sudo mkfs.vfat /dev/loop0 -n “RISC OS” -F 16 -s 1
sudo losetup -d /dev/loop0</pre>
Changelog:
Modified by Jeffrey Lee (213) Fri, November 26 2010 - 12:08:34 GMT
Let’s try that again, since ISTR that textile formatting works for replies but not the initial posting:
<pre>#!/bin/bash
dd if=/dev/zero of=wibble bs=8225280 count=1
sfdisk -C 1 -H 255 -S 63 -D wibble <<EOF
,,0×0e,*
EOF
sudo losetup -v -o 32256 /dev/loop0 wibble
sudo mkfs.vfat /dev/loop0 -n “RISC OS” -F 16 -s 1
sudo losetup -d /dev/loop0</pre>
Modified by Jeffrey Lee (213) Fri, November 26 2010 - 12:09:39 GMT
Obviously not :( Just remove the blank lines and all will be good.
#!/bin/bash
dd if=/dev/zero of=wibble bs=8225280 count=1
sfdisk -C 1 -H 255 -S 63 -D wibble <<EOF
,,0×0e,*
EOF
sudo losetup -v -o 32256 /dev/loop0 wibble
sudo mkfs.vfat /dev/loop0 -n “RISC OS” -F 16 -s 1
sudo losetup -d /dev/loop0
Modified by Sprow (202) Sun, September 18 2011 - 16:10:35 GMT
- Status changed from Open to WorksForMe
Works fine here, DOSFS 0.87. Steps tried:
– use !SDCreate to create an 8MB DOSDisc image
– copy this (via SCSIFS) to a 32MB RAM disc on a loan Beagleboard
– *CREATE $.test1m 100000
– *COPY $.test1m $.imagefile.test1m
– *COPY $.imagefile.test1m null:
– repeated in increments of 1MB up to and including 7MB
No errors reported.
Modified by Sprow (202) Sun, September 18 2011 - 16:42:41 GMT
- Status changed from WorksForMe to Open
Whoops, was looking at the wrong byte in the BPB for sectors per cluster. SDCreate has 4, thus doesn’t match the bug description.
Generated one with MkDOSFS (for Windows) with
and it does indeed give up. However, DOSFS 0.77 works.
Modified by Sprow (202) Sun, September 18 2011 - 17:15:50 GMT
Yeah. 0.78 works too, 0.79 does not.
Modified by Ben Avison (25) Sun, September 02 2012 - 14:03:15 GMT
- Status changed from Open to Fixed
I’ve verified that DOSFS 0.95 fixes this as a side-effect!