zanesterling / fatr

A FAT12 parsing and manipulation tool
MIT License
1 stars 0 forks source link

Mixed case volume label support #12

Open kallisti5 opened 7 years ago

kallisti5 commented 7 years ago

FAT filesystems can have a mixed case label, however it changes how it is stored in unique ways...

A test with mtools...

Setup:

echo 'drive i: file="/home/kallisti5/test.img" partition=1 cylinders=8 heads=255 sectors=63 mformat_only' > test.img.mtools
export MTOOLSRC=test.img.mtools

Success:

$ dd if=/dev/zero of=~/test.img bs=1048576 count=32
$ mformat -L 32 -v "test" i:
$ file ~/test.img
/home/kallisti5/test.img: DOS/MBR boot sector, code offset 0x3c+2, OEM-ID "MTOO4018", sectors/cluster 16, root entries 512, sectors/FAT 32, sectors/track 63, heads 255, sectors 128520 (volumes > 32 MB) , serial number 0x2947b2e, label: "test       ", FAT (16 bit)
$ ./target/debug/fatr ls ~/test.img
 Volume "TEST       "
 Volume has 512 bytes per sector

    0 File(s)       0 bytes

Failure:

$ dd if=/dev/zero of=~/test.img bs=1048576 count=32
$ mformat -L 32 -v "Test" i:
$ file ~/test.img
/home/kallisti5/test.img: DOS/MBR boot sector, code offset 0x3c+2, OEM-ID "MTOO4018", sectors/cluster 16, root entries 512, sectors/FAT 32, sectors/track 63, heads 255, sectors 128520 (volumes > 32 MB) , serial number 0x8530ac2, label: "Test       ", FAT (16 bit)
$ ./target/debug/fatr ls ~/test.img
 Volume "AT\u{0}e\u{0}s\u{0}t\u{0}\u{0}\u{0}"
 Volume has 512 bytes per sector

    0 File(s)       0 bytes

There is some extra encoding when a volume label is mixed case.