Click here to Skip to main content
15,914,014 members
Please Sign up or sign in to vote.
4.50/5 (2 votes)
See more:
Hello :)

I'm working on a project which deals with simulating the unix file system or any other file system.I can invent my own as well. I'm developing a unix like shell which will provide all the file handling commands similar to unix.Basically I want to allocate a large file on the actual file system, and treat it as a virtual disk for the file system simulation. In order to implement the file system, I would create and manipulate various data structures on the virtual disk to create and manage the file system.

but my problem is how do i store the tree like unix file system in a file(virtual disk) ??or how do i create data structures like superblock, boot block,inode list, within this virtual disk ??is simulating the unix file system tougher ?if yes then what other options should I look for ?

Regards!
Posted
Comments
Sergey Alexandrovich Kryukov 20-Apr-12 21:43pm    
This is a very interesting question, my 5.
Unfortunately, answering is way harder than asking about it. :-)
I hope my answer can help you just to get some basic ideas and learn about such software.
--SA

1 solution

Sorry that I don't give you the full answer, because this is way too big topic for this Quick Questions & Answers.

I only want to bring to your attention that you already trying to make a wrong assumption about Unix file systems. More exactly, there are many Unix-compatible file systems, so we should talk about some common denominator called POSIX file systems. By the way Windows NTFS also implement POSIX features (and many developers do not know about them).

Here is the thing: POSIX file systems are not tree-like. The general instance of a file systems represents a more common graph which is not a tree because it has circular paths in it. First of all, files are linked with inodes as hard links. If an inode represents a single unique physical file, the file as a file system object represent position of the file in a tree; and one inode is hard-linked with unlimited number of file system objects. The inode exists

Please see: http://en.wikipedia.org/wiki/Hard_link[^].

On top of it, there are also soft links or symbolic links. In Windows, they are also called reparse points. They link not to a inode, but to a file/directory name. Please see:
http://en.wikipedia.org/wiki/Soft_link[^],
http://en.wikipedia.org/wiki/NTFS_reparse_point[^].

One more complication is that the modern Unix-like systems offer a choice of different file systems, and the default system is usually a journaling file system. However, using such system is fully transparent to the OS, until it comes to the disaster recovery. Please see:
http://en.wikipedia.org/wiki/Journalling_file_system[^].

The task of implementing of a single file the virtual type system is quite a big one. You can try to find some available Open-Source solution. The only Open-Source code of this sort I heard of is the whefs project. According to this article,
whefs (http://code.google.com/p/whefs[^]) is an Open Source C library for POSIX-compliant operating systems which provides features for accessing and manipulating a single-file virtual file system from within C and C++ applications.


Please see:
http://code.google.com/p/whefs/wiki/HomePage[^].

—SA
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900