FAT32 file system - Adding and removing files.

Discussion in 'C Programming' started by superhac007@gmail.com, Sep 17, 2009.

  1. Guest

    Hi,

    I am looking for information on how to add and remove files from a
    fat32 file system. Specifically the pseudo mechanics not actual
    code. I have some idea, but I'm not sure if this is the optimum way.

    For adding I am assuming the following steps:

    1) add the file entry to the directory. Do I find the first available
    entry (0x00) or can I replace a deleted directory entry (0xE5)?

    2) Find an available cluster in the FAT Table. Do I search for the
    first available entry location that is set to 0x00000000?

    3) Break up the file data among clusters and update the FAT entries,
    and set starting cluster of file.

    for deleting:

    1) set the filename length to 0xE5. Then do I reset the clusters that
    make up that file to (0x00000000)?

    Thanks,

    Steve
     
    , Sep 17, 2009
    #1
    1. Advertising

  2. Seebs Guest

    On 2009-09-17, <> wrote:
    > Hi,
    >
    > I am looking for information on how to add and remove files from a
    > fat32 file system. Specifically the pseudo mechanics not actual
    > code. I have some idea, but I'm not sure if this is the optimum way.


    You might try a DOS or Windows newsgroup, as this has entirely to do with
    a filesystem. You could write this code in any language you wanted, and
    it would be essentially the same.

    -s
    --
    Copyright 2009, all wrongs reversed. Peter Seebach /
    http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
    http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
     
    Seebs, Sep 17, 2009
    #2
    1. Advertising

  3. Guest

    On Sep 17, 4:02 pm, Kenneth Brody <> wrote:
    > wrote:
    > > Hi,

    >
    > >  I am looking for information on how to add and remove files from a
    > > fat32 file system.  Specifically the pseudo mechanics not actual
    > > code.  I have some idea, but I'm not sure if this is the optimum way.

    >
    > [...]
    >
    > I would recommend using fopen() and remove().
    >
    > --
    > Kenneth Brody


    lol... ;)

    This is a from scratch parser. As in I am parsing the disk raw. I've
    got the boot sector parsed, fat table parsed, and can navigate the
    directories, but I am looking for the proper way to add and remove
    files. I can't seem to find any examples on the web.

    Steve
     
    , Sep 17, 2009
    #3
  4. Beej Jorgensen, Sep 18, 2009
    #4
  5. "Seebs" <> wrote in message
    news:...
    > On 2009-09-17, <> wrote:
    >> Hi,
    >>
    >> I am looking for information on how to add and remove files from a
    >> fat32 file system. Specifically the pseudo mechanics not actual
    >> code. I have some idea, but I'm not sure if this is the optimum way.

    >
    > You might try a DOS or Windows newsgroup, as this has entirely to do with
    > a filesystem. You could write this code in any language you wanted, and
    > it would be essentially the same.


    How would you react to the following statement:


    You cannot create low-level algorithm X in any language you wanted to, C/C++
    aside of course!!!!!:


    http://groups.google.com/group/comp.lang.c/msg/d8ae596a08b7afd9


    without resorting to unsafe coding practices wrt said languages
    safe-guards...






    ;^)
     
    Chris M. Thomasson, Sep 18, 2009
    #5
  6. Guest

    On Sep 17, 6:39 pm, Beej Jorgensen <> wrote:
    > <> wrote:
    > >For adding I am assuming the following steps:
    > >for deleting:

    >
    > Seems unlikely that people here would know, but I could recommend the
    > Linux kernel source as a reference:
    >
    > http://lxr.linux.no/linux v2.6.31/f.../lxr.linux.no/linux v2.6.31/fs/fat/dir.c#L984
    >
    > But, to be honest, I don't know a thing about it.
    >
    > -Beej


    Thanks Beej. That was exactly what I was looking for. For some
    reason I never thought of looking at the Linux modules for FAT, even
    though I'm working on Linux!! It appears that I was pretty close with
    my assumptions on first glance.

    I'm with you before I started this project I never looked at how file
    systems worked. Its an obscure topic, and most people would just use
    ready made drivers. I learned quite a bit so far, and now have a
    great appreciation for the role it fulfills.


    Thanks again,

    Steve
     
    , Sep 18, 2009
    #6
  7. Guest

    On Sep 18, 8:39 am, "" <>
    wrote:
    > On Sep 17, 6:39 pm, Beej Jorgensen <> wrote:
    >
    > > <> wrote:
    > > >For adding I am assuming the following steps:
    > > >for deleting:

    >
    > > Seems unlikely that people here would know, but I could recommend the
    > > Linux kernel source as a reference:

    >
    > >http://lxr.linux.no/linux v2.6.31/fs/fat/dir.c#L1230http://lxr.linux....

    >
    > > But, to be honest, I don't know a thing about it.

    >
    > > -Beej

    >
    > Thanks Beej.  That was exactly what I was looking for.  For some
    > reason I never thought of looking at the Linux modules for FAT, even
    > though I'm working on Linux!!  It appears that I was pretty close with
    > my assumptions on first glance.



    While OT, this is pretty much the definitive specification for FAT:

    http://www.microsoft.com/whdc/system/platform/firmware/fatgen.mspx
     
    , Sep 18, 2009
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. knight1fox3

    FAT32 Filesystem

    knight1fox3, Dec 1, 2003, in forum: VHDL
    Replies:
    1
    Views:
    2,102
    john jakson
    Dec 3, 2003
  2. Matt
    Replies:
    2
    Views:
    861
    Kristo
    Apr 22, 2005
  3. Amod
    Replies:
    1
    Views:
    436
    Jonathan Mcdougall
    Nov 14, 2005
  4. Amod
    Replies:
    1
    Views:
    408
    Jonathan Mcdougall
    Nov 14, 2005
  5. Replies:
    2
    Views:
    428
    Alex Buell
    May 22, 2007
Loading...

Share This Page