Pick a Free OS

Virtual file system Part 1

* “requires_dev” is a flag indicating whether a device is strictly necessary to mount the File System from.

A typical statement to register a File System would look similar to the following code:


register_filesystem(&(struct file_system_type) {ext2_read_super, “Ext2”, 1, NULL});


Once a File System implementation has been registered with the VFS, file systems of this type can be administered.

Mounting a file system

In order to access a file, the file system containing the file must be mounted onto some mount point in the Linux directory hierarchy. This can be done using either the mount system call or the mount_root() function.

After all the File System implementations permanently included in the kernel have been registered, the setup() system call (which is called immediately after the init process is created by the kernel function init()) makes a call to the mount_root() function which takes care of mounting the first File System (the root File System).

A separate superblock structure is maintained for every mounted File System. These structures are held in the static table super_block[], which has the capacity for holding NR_SUPER such entries. The superblock is initialized by the function read_super() in the VFS. This file-system-specific function reads its data if necessary from the appropriate block device using the LINUX cache functions.

The Linux superblock has the following structure:

Struct super_block


dev_t s_dev; /* device for File System */

unsigned long s_blocksize; /* block size */

unsigned char s_blocksize_bits; /* ld (block size) */

unsigned char s_lock; /* superblock lock */

unsigned char s_rd_only; /* not used (= 0) */

unsigned char s_dirt; /* superblock modified */

struct file_system_type *s_type; /* file system type */

struct super_operations *s_op; /* super block operations */

unsigned long s_flags; /* flags */

unsigned long s_magic; /* file system identifier */

unsigned long s_time; /* time of change */

struct inode * s_covered; /* mount point */

struct inode * s_mounted; /* root inode */

struct wait_queue * s_wait; /* s_lock wait queue */



struct minix_sb_info minix_sb;


void * generic_sdp;

} u; /* file-system-specific information */