FAT File System

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
deus_the_programmer

FAT File System

Post by deus_the_programmer »

Please can somebody help me develop a fat file system driver in ANSI C. To start with i only want to be able to view the files that exsist on a fat 12 formatted floppy disk. any help is greatly appricated. this has to be done without access to dos ints, ie only bios int 13h.
thanks for your help.
ed.
JAAman

RE:FAT File System

Post by JAAman »

this is easy for FAT12 if you've already got the code to access the disk

        CHS = Cylindar(track on FDD), Head, Sector
1st read the bpb (the first sector: 0-0-1 CHS)
2nd locate the root dir:
    hidden sectors(usually 0:offset 0x1C in bpb)
  + reserved sectors(usually 1:offset 0x0E)
  + (    FAT copies (usually 2:offset 0x10)
       * sectors/FAT (usually 9:offset 0x16)
    )

                now you have the root dir LBA address
3rd LBA->CHS
      tmp1 = LBA / Sectors/track
      S = LBA % Sectors/track
      H = tmp1 % #heads(2)
      C = tmp1 / #heads
                  I think this is correct this is from memory
4th read sector

5th take first 11 characters from each 32 bytes -- this is the file name

            if first char is 0xE5 then entry deleted skip to next
            if first char is 0x05 then first char is 0xE5
            if first char is 0xE2 ( period) then entry is subdirectory
                  if second char  is also 0xE2 then entry is parent dir (not
                                     valid for root dir)
            if first char is 0x00 then no entries exist past this point so END
add 1 to LBA and GOTO 3rd step if not past max root entries ( offset 0x11 in bpb
                                                                  usually 512)

sub dirs are a little different since they are essentially files and exist in the FAT tables
JAAman

RE:FAT File System

Post by JAAman »

oops sorry I forgot:

step 3 after done you must add 1 to Sector# because LBA starts at 0 and Sector# starts at 1
deus_the_programmer

RE:FAT File System

Post by deus_the_programmer »

I dont have any code at the moment can someone help me write some code?
thanks,

ed.
Post Reply