Pick a Free OS

User login

Navigation

Virtual file system Part 1

Virtual File System is an interface providing a clearly defined link between the operating system kernel and the different File Systems. The VFS supplies the applications with the system calls for file management (like “open”, “read”, “write” etc.), maintains internal data structures (the administrative data for maintaining the integrity of the File System), and passes tasks onto the appropriate actual File System. Another important job of the VFS is, performing standard actions. For example, as a rule, no File System implementation will actually provide an lseek() function, as the functions of lseek() are provided by a standard action of the VFS.

Kernel’s representation of the File Systems

The representation or layout of data on a floppy disk, hard disk or any other storage media may differ considerably from one implementation of File System to another. But the actual representation of this data in Linux kernel’s memory is the same for all File System implementations. The Linux management structures for the File Systems are similar to the logical structure of a Unix File System.

The VFS calls the file-system-specific functions for various implementations to fill up these structures. These functions are provided by every File System implementation and are made known to the VFS via the function register_filesystem(). This function sets up the file_system_type structure it has passed, in a singly linked list headed by the pointer “file_systems”. The file_system_type structure gives information about a specific File System implementation. The structure is as follows:

struct file_system_type

{

struct super_block *(*read_super)(struct super_block *, void *, int);

char *name;

int requires_dev;

struct file_system_type *next;

};

· The function “read_super(..)” forms the mount interface, i.e. it is only via this function that further functions of the File System implementation will be made known to the VFS. It takes three parameters:

* A super_block structure in which the data relevant to this instance of File System implementation is filled up.

* A character string (in this case void *), which contains further mount options for the file system.

* A flag, which is used to indicate whether unsuccessful mounting should be reported. This flag is used only by the kernel function mount_root(), as this calls all the read_super() functions present in the various File System implementations.

* The “name” field contains the name of the actual File System.