Possible bug in FAT dir listing

Gene Smith gds at chartertn.net
Tue Jan 13 23:45:51 CST 2009


I formatted an MMC card on linux with gparted as FAT16. I copy one file 
to it called freddy.txt I unmount and dump the partition with dd. The 
root directory entry appears like this:
:
003d5f0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
003d600: 4166 0072 0065 0064 0064 000f 0055 7900  Af.r.e.d.d...Uy.
003d610: 2e00 7400 7800 7400 0000 0000 ffff ffff  ..t.x.t.........
003d620: 4652 4544 4459 2020 5458 5420 0000 9100  FREDDY  TXT ....
003d630: 2e3a 2d3a 0000 6eb5 2c3a 0300 1300 0000  .:-:..n.,:......
003d640: 0000 0000 0000 0000 0000 0000 0000 0000  ................
:

There are two entries. One starts with A and seems to be unicode of some 
sort (32 bytes at 3d600) while the 2nd is conventional ASCII and is 32 
bytes at 3d620.

When I mount on rtems and do ls in the shell I see this:

[/mnt] # ls
Af              FREDDY.TXT

The entry that starts with A shows up as "Af". From what I have read it 
should actually be ignored and not printed because the byte at 3d60b is 
0x0f. The 0x0f is the file attributes indicating this is a volume label, 
system file, hidden file and read-only. This is a key that it should not 
be displayed. (Why this filename gets put in I don't know. I think 
windows does the same.)

Both of these sites mention that the attribute flag 0xf means don't show 
the file:
http://www.win.tue.nl/~aeb/linux/fs/fat/fat-1.html
http://home.teleport.com/~brainy/lfn.htm

This also explains why a volume label shows up as a file in rtems when 
doing ls. It should be ignored too.

AFAICT, there is no code in the rtems FAT library to ignore files when 
these attribute flags are set. I only see the "directory" attribute 
checked in some places.

-gene




More information about the rtems-users mailing list