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
In memory filesystem
- NickJohnson
- Member
- Posts: 1249
- Joined: Tue Mar 24, 2009 8:11 pm
- Location: Sunnyvale, California
Re: In memory filesystem
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.
Edit: if you meant a in-memory copy of a filesystem, then ignore the previous.
Last edited by NickJohnson on Mon Apr 11, 2011 7:30 pm, edited 1 time in total.
- JackScott
- Member
- Posts: 1032
- Joined: Thu Dec 21, 2006 3:03 am
- Location: Hobart, Australia
- Mastodon: https://aus.social/@jackscottau
- GitHub: https://github.com/JackScottAU
- Contact:
Re: In memory filesystem
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
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
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.