Page 1 of 1

In memory filesystem

Posted: Mon Apr 11, 2011 7:11 pm
by nvm
Hello,

Has anyone implemented an in memory filesystem? Any source code available? It would be nice if something simple to understand would be available, if I can create a file and do a cat filename to print it's contents it would be great. Please don't point me to fat or ext implementations I can find them by myself.

Thank you

Re: In memory filesystem

Posted: Mon Apr 11, 2011 7:14 pm
by NickJohnson
You really just need a working heap (with which to allocate file space) in order to implement a memory filesystem (like Linux's tmpfs.) Most of the code will involve interfacing with whatever VFS API you have. Basically, the filesystem format part of such a filesystem is trivial.

Edit: if you meant a in-memory copy of a filesystem, then ignore the previous.

Re: In memory filesystem

Posted: Mon Apr 11, 2011 7:15 pm
by JackScott
This sort of thing is commonly known as a ramdisk, so searching for that should lead to some usable results.

Jezze on this forum gave a tutorial for using the TAR format as an (I presume) read-only ramdisk, which can be viewed at http://forum.osdev.org/viewtopic.php?f=8&t=23339

Re: In memory filesystem

Posted: Tue Apr 12, 2011 2:21 am
by rdos
The problem is often not to implement a ram-drive-type file system, but rather to implement the VFS. Once you have a reasonable VFS abstraction, it is usually easy to add a ram-drive. My ram-drive has two types of files: read-only files that are preloaded from the OS binary, and temporary files created by applications. I think this is a good idea, especially for OSes targeting potentially diskless systems. In a diskless system, application binaries can be preloaded on ram-drive, and then look like ordinary applications to loaders.