I have a web application which is to be hosted on an embedded controller.

This controller (not mine) has a FAT12-like 8.3 UPPERCASE filenames filesystem.

My buildsystem runs un Linux, and can use any filename allowed in ext4 (UTF-8).

The problem is: I cannot build and sign the firmwarearchive by myself, I have to hand out compressed archives to the key owner.

If anything sneaks into the archive, it is lots of trouble and arguing because the process only breaks after creating the signed firmware archive, when it is uploaded to a test controler.

Because of this hassle, I want to catch those errors as early as possible in my build system.

I tried mounting a VFAT filesystem contained in a file mounted via loop device in FAT12 mode on my build/ directory with mode=strict, but no restriction seems to work other than the space restriction to the loopback file.

Is there another way to add constraints to filesystems in order to simulate limited filesystems?

Edit 19.Dec.2012: Perhaps I should show what I have tried before: (my test shell script in -vx debug mode)

export LANG=C
+ export LANG=C
export LC_ALL=C
+ export LC_ALL=C

IMAGE=$(mktemp --quiet --suffix=fat12.img 8dot3XXXXXXXX)
mktemp --quiet --suffix=fat12.img 8dot3XXXXXXXX)
mktemp --quiet --suffix=fat12.img 8dot3XXXXXXXX
++ mktemp --quiet --suffix=fat12.img 8dot3XXXXXXXX
+ IMAGE=8dot3C2CGojhZfat12.img

+ MOUNTPOINT=/home/human/fat-test

dd if=/dev/zero of=${IMAGE} bs=1M count=1
+ dd if=/dev/zero of=8dot3C2CGojhZfat12.img bs=1M count=1
1+0 records in
1+0 records out
1048576 bytes (1.0 MB) copied, 0.00500883 s, 209 MB/s

mkfs.vfat -F 12 -n flashfs ${IMAGE}
+ mkfs.vfat -F 12 -n flashfs 8dot3C2CGojhZfat12.img
mkfs.vfat 3.0.12 (29 Oct 2011)

file ${IMAGE}
+ file 8dot3C2CGojhZfat12.img
8dot3C2CGojhZfat12.img: x86 boot sector, mkdosfs boot message display, code offset 0x3c, OEM-ID " mkdosfs", sectors/cluster 4, root entries 512, sectors 2048 (volumes <=32 MB) , Media descriptor 0xf8, sectors/FAT 2, heads 64, serial number 0xc02d5e98, label: "flashfs    ", FAT (12 bit)

mkdir -p ${MOUNTPOINT}
+ mkdir -p /home/human/fat-test
\sudo mount ${IMAGE} ${MOUNTPOINT} -t vfat -o fat=12,check=strict,shortname=win95,uid=1000,gid=1000,debug
+ sudo mount 8dot3C2CGojhZfat12.img /home/human/fat-test -t vfat -o fat=12,check=strict,shortname=win95,uid=1000,gid=1000,debug

+ cd /home/human/fat-test
+ df -h /home/human/fat-test
Filesystem      Size  Used Avail Use% Mounted on
/dev/loop1     1004K     0 1004K   0% /home/human/fat-test

## test suite

# is 8.3 and uppercase, should work
mkdir TEST
+ mkdir TEST

# is 8.3, but wrong case, should fail
mkdir trial
+ mkdir trial
mkdir trial/trial.txt
+ mkdir trial/trial.txt

# should fail
mkdir muchtoolong
+ mkdir muchtoolong
touch muchtoolong/muchtoolong.with.triple.extension
+ touch muchtoolong/muchtoolong.with.triple.extension

find  ${MOUNTPOINT} -ls
+ find /home/human/fat-test -ls
     1   16 drwxr-xr-x   5 human    human       16384 Dec 19 18:40 /home/human/fat-test
    21    2 drwxr-xr-x   2 human    human        2048 Dec 19 18:40 /home/human/fat-test/TEST
    22    0 -rwxr-xr-x   1 human    human           0 Dec 19 18:40 /home/human/fat-test/TEST/TEST.TXT
    23    2 drwxr-xr-x   3 human    human        2048 Dec 19 18:40 /home/human/fat-test/trial
    24    2 drwxr-xr-x   2 human    human        2048 Dec 19 18:40 /home/human/fat-test/trial/trial.txt
    25    2 drwxr-xr-x   2 human    human        2048 Dec 19 18:40 /home/human/fat-test/muchtoolong
    26    0 -rwxr-xr-x   1 human    human           0 Dec 19 18:40 /home/human/fat-test/muchtoolong/muchtoolong.with.triple.extension

+ cd
\sudo umount  ${MOUNTPOINT}
+ sudo umount /home/human/fat-test
rm ${IMAGE}
+ rm 8dot3C2CGojhZfat12.img

If anybody can spot the error: TIA, because I fail to find it.

  • 1
    FAT12 supports a max. partition size of 8MB.Is your loopback image of that size? Format it using mkfs.vfat with the -F12 switch.Also, while mounting it,you could try the -o fat=12 switch – itisravi Dec 19 '12 at 5:09
  • @staff: thank you for migrating this thread. I was not shure if build system related problems belong here. But you'll sure know better :) – Peter Dec 19 '12 at 21:09
  • @itisravi: it is only 1 MB in size. I just added my test case script to my original question. – Peter Dec 19 '12 at 21:17

You seem to struggle with presence of long names on FS you suppose to restrict by pure MSDOS conventions. Then use "-t msdos" rather than "-t vfat". Otherwise, VFAT will only store long names for "impossible" files along with constructing short alternatives to them.

You'll have to remove "shortname" option as "msdos" FS is not aware what "short names" mean for.

BTW, there's another error in your script making it unworkable as you intend: you missed "loop" option in mount command, hence it'll report in error and all further operations will happen in ${MOUNTPOINT} directory of underlying FS rather than the tested FS in your test file. You seemed to edit your script / output before posting because there's an obvious mistyped backslash "\" before your "sudo mount" command. So, the correct mount command will be like that:

sudo mount ${IMAGE} ${MOUNTPOINT} -t msdos -o loop,fat=12,check=strict,uid=1000,gid=1000,debug

One more note: in MSDOS mode, names on disk are stored only in uppercase. So, "msdos" FS Linux developers took decision to convert and display all names only to/from lowercase while storing them still in uppercase. That means your tests for cases will work the opposite: allowing only names all in lowercase but reject any uppercase chars. While it may cause inconveniences for your tests, the names in your file will always be created correctly and all mixed duplicates rejected (as well as other non-8.3 anomalies), so I believe you'll be able to adapt your situation to this particular peculiarity of mounting MSDOS FS in Linux.

  • Thank you very much! The -o loop is being done by mount automatically: "The mount command automatically creates a loop device from a regular file if a filesystem type is not specified or the filesystem is known for libblkid" (man mount 2.22.2, sce. "The Loop Device") – Peter Dec 26 '12 at 21:02
  • The backslash is harmless: it suppresses the evaluation of an alias with the name "sudo" - an old habit of mine. – Peter Dec 26 '12 at 21:16
  • @Peter: Heh, never happened to meet both these features before, thanks for explaining them. – Van Jone Dec 27 '12 at 16:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.