The purpose of the Vtree class is to store all the virtual file system data. It manages the whole hierarchy structure and its elements are virtual entries implemented by the Ventry class.
Vtree communicates directly to PKGFS and PKGFSCache. Its job consists in initializing the tree (adding the base virtual entries) and providing typical methods to manage it. Then the Vtree object mainly acts as a wrapper for the Ventry class, because only this latter knows the tree internals.
Thus, nothing more has to be said about the Vtree public interface; we explain the tree structure internals instead. As we see in figure 5.8, the virtual tree is a simple left-son, right-brothered one. We have chosen such a tree, because it is the natural structure that permits to carry out flat and hierarchical visits. PackageFS itself has to deal with relatively low deeplevels, so any kind of balancing operation would not increase the searching speed. Moreover, the Vtree object keeps in memory the pointers to the last accessed virtual entry and to its parent in order to avoid starting each lookup operation from the root of the tree.
The PKGFSCache interaction consists in saving and restoring the data from the disk. Currently the Vtree only contributes to the PKGFS cache with its virtual entries amount. The content is contributed by each entry as the tree visit starts from the Ventry root node.
The Ventry class holds the data belonging to each node and only the Vtree object is aware of its presence. A virtual entry is identified by its pathname, which is split in and pair to perform some checks easily. Each node keeps the pointers to and lists. Currently these latter are double linked lists and their implementation is taken from the Linux kernel. The file included in the kernel headers provides several macros and inline functions to create and manage those kinds of lists.
Meaningful nodes data are stored within structure provided by LUFS itself. As the reader may notice in figure 5.9, this latter is very similar to the structure presented in chapter 3. In fact it holds all the necessary fields to save file attributes and thus, to make PackageFS able to satisfy ordinary requests.