Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] New 1 GB SD card reports being full after only 467 MBused



On Fri, 10 Feb 2006 13:29:27 +0900, Edward Middleton
<edward@example.com> wrote:

> It should be [1]65,517 files for a fat16 formated SD card.

Not necessarily.

The word at offset 0x11 in the filesystem bootsector contains the number of
entries allowed in the FAT16/FAT12 filesystem root directory. Typically,
it's 128 for a floppy and 256 or 512 for a HDD or removeable media. This is
handled differently by FAT32.

Read the source for mkdosfs! (to which I made a modest contribution a while
back...
http://nehru.mat.upm.es/cgi-bin/dwww?type=file&location=/usr/share/doc/dosfstools/changelog.gz)

  if (size_fat == 32)
    {
      /* Under FAT32, the root dir is in a cluster chain, and this is
       * signalled by bs.dir_entries being 0. */
      bs.dir_entries[0] = bs.dir_entries[1] = (char) 0;
      root_dir_entries = 0;
    }
  else if (root_dir_entries)
    {
      /* Override default from establish_params() */
      bs.dir_entries[0] = (char) (root_dir_entries & 0x00ff);
      bs.dir_entries[1] = (char) ((root_dir_entries & 0xff00) >> 8);
    }
  else
    root_dir_entries = bs.dir_entries[0] + (bs.dir_entries[1] << 8);


After doing "mkdosfs -I -F 16 fatfs", where 'fatfs' is a 512MB file:

$ dd if=fatfs bs=512 count=1 | hexdump -C
1+0 records in
1+0 records out
00000000  eb 3c 90 6d 6b 64 6f 73  66 73 00 00 02 10 01 00  |ë<.mkdosfs......|
00000010  02 00 02 00 00 f8 00 01  20 00 40 00 00 00 00 00  |.....ø.. .@example.com|
00000020  00 00 10 00 00 00 29 18  6a ec 43 20 20 20 20 20  |......).jìC     |
00000030  20 20 20 20 20 20 46 41  54 31 36 20 20 20 0e 1f  |      FAT16   ..|
00000040  be 5b 7c ac 22 c0 74 0b  56 b4 0e bb 07 00 cd 10  |Ÿ[|¬"Àt.VŽ.»..Í.|
00000050  5e eb f0 32 e4 cd 16 cd  19 eb fe 54 68 69 73 20  |^ëð2äÍ.Í.ëþThis |
00000060  69 73 20 6e 6f 74 20 61  20 62 6f 6f 74 61 62 6c  |is not a bootabl|
00000070  65 20 64 69 73 6b 2e 20  20 50 6c 65 61 73 65 20  |e disk.  Please |
00000080  69 6e 73 65 72 74 20 61  20 62 6f 6f 74 61 62 6c  |insert a bootabl|
00000090  65 20 66 6c 6f 70 70 79  20 61 6e 64 0d 0a 70 72  |e floppy and..pr|
000000a0  65 73 73 20 61 6e 79 20  6b 65 79 20 74 6f 20 74  |ess any key to t|
000000b0  72 79 20 61 67 61 69 6e  20 2e 2e 2e 20 0d 0a 00  |ry again ... ...|
000000c0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............Uª|
00000200

This shows the word at offset 0x11 to be 0x0200 => 512 entries in the root
directory.

Entries in root directory != total number of clusters.

-- 
G. Stewart - godwin.stewart@example.com

Shin, n.: a device for finding furniture in the dark.

Attachment: pgp00013.pgp
Description: PGP signature


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links