ExFAT

From OSDev.wiki
Revision as of 13:42, 3 March 2015 by Candy (talk | contribs)
Jump to navigation Jump to search

Filesystem Header:

   struct bootsector {
       char jump[3];
       char fsid[8];
       char pad[53];
       uint64_t unk; // sectors before first cluster too?
       uint64_t fsSizeInSectors;
       uint32_t sectorsToStartOfFat;
       uint32_t sectorsUsedForFat;
       uint32_t sectorStartOfFirstCluster;
       uint32_t clusterCountInFs;
       uint32_t clusterForRootDirectory;
       uint32_t unk[2];
       uint8_t logBytesPerSector, logSectorsPerCluster, fatCount, driveId; // 2-log for both. bytesPerCluster = 1 << (logBytesPerSector + logSectorsPerCluster).
       uint8_t percentInUse; // for display ala windows computer explorer
       uint8_t unk[7];
       char bootcode[390];
       char bootsign[2];
   };

block bitmap is cluster 2, upcase tbl is cluster 3.

Directory entries:

32-byte entries. Entries contain one of a few possible entry types, first byte identifies which type it is. The second byte identifies how many subsequent entries are part of this entry. All bytes after are dependent on the type of entry. Any entry with the highest bit of entrytype set is not used.

   struct {
       uint8_t entrytype = 0x85;
       uint8_t entrycount; // This is the number of subsequent entries that also belong to this "file" entry. Should be at least 2, one 0xC0 and one 0xC1 for info and filename.
       uint8_t pad[2];
       uint32_t flags; // 0x10 == directory, probably identical to fat32
       uint32_t creation, modification, access;
       char pad[12];
   } fileEntry;
   struct {
       uint8_t entryType = 0xC0;
       uint8_t flags;
       uint8_t unk; // = 0. May be part of next field, but then it'd be in big-endian order which is unlikely.
       uint8_t filenameLengthInBytes;
       uint64_t filesize;
       uint32_t unk;
       uint32_t startCluster; // minus 2! Same as fat12/16/32.
       uint64_t filesize2;
   } fileInfoEntry;
   struct {
       uint8_t entrytype = 0xC1, entrycount = 0x00;
       uint16_t name[15];
   } filenameEntry;

Short filename:

   01040300  85 02 c8 f9 10 00 00 00  5b a9 47 45 6f a9 47 45  |........[.GEo.GE|
   01040310  6f a9 47 45 25 25 88 88  88 00 00 00 00 00 00 00  |o.GE%%..........|
   01040320  c0 03 00 05 ae 26 00 00  00 00 02 00 00 00 00 00  |.....&..........|
   01040330  00 00 00 00 17 00 00 00  00 00 02 00 00 00 00 00  |................|
   01040340  c1 00 69 00 6d 00 61 00  67 00 65 00 00 00 00 00  |..i.m.a.g.e.....|
   01040350  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

Longer filename:

   01080060  85 03 34 aa 10 00 00 00  1c a5 47 45 92 0a 48 45  |..4.......GE..HE|
   01080070  92 0a 48 45 94 94 88 88  88 00 00 00 00 00 00 00  |..HE............|
   01080080  c0 03 00 18 23 20 00 00  00 00 02 00 00 00 00 00  |....# ..........|
   01080090  00 00 00 00 07 00 00 00  00 00 02 00 00 00 00 00  |................|
   010800a0  c1 00 63 00 6f 00 6d 00  2e 00 67 00 6f 00 6f 00  |..c.o.m...g.o.o.|
   010800b0  67 00 6c 00 65 00 2e 00  61 00 6e 00 64 00 72 00  |g.l.e...a.n.d.r.|
   010800c0  c1 00 6f 00 69 00 64 00  2e 00 6d 00 75 00 73 00  |..o.i.d...m.u.s.|
   010800d0  69 00 63 00 00 00 00 00  00 00 00 00 00 00 00 00  |i.c.............|

Really long filename:

   01100640  85 05 a9 6f 20 00 00 00  25 38 48 45 26 38 48 45  |...o ...%8HE&8HE|
   01100650  25 38 48 45 64 64 00 00  00 00 00 00 00 00 00 00  |%8HEdd..........|
   01100660  c0 01 00 32 c6 a5 00 00  d8 52 76 00 00 00 00 00  |...2.....Rv.....|
   01100670  00 00 00 00 14 46 00 00  d8 52 76 00 00 00 00 00  |.....F...Rv.....|
   01100680  c1 00 30 00 30 00 33 00  20 00 2d 00 20 00 4c 00  |..0.0.3. .-. .L.|
   01100690  65 00 64 00 20 00 5a 00  65 00 70 00 70 00 65 00  |e.d. .Z.e.p.p.e.|
   011006a0  c1 00 6c 00 69 00 6e 00  20 00 2d 00 20 00 53 00  |..l.i.n. .-. .S.|
   011006b0  74 00 61 00 69 00 72 00  77 00 61 00 79 00 20 00  |t.a.i.r.w.a.y. .|
   011006c0  c1 00 74 00 6f 00 20 00  68 00 65 00 61 00 76 00  |..t.o. .h.e.a.v.|
   011006d0  65 00 6e 00 20 00 2d 00  20 00 31 00 39 00 37 00  |e.n. .-. .1.9.7.|
   011006e0  c1 00 32 00 2e 00 6d 00  70 00 33 00 00 00 00 00  |..2...m.p.3.....|    
   011006f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|