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