The source and introduction of the file system of the VFS file system in Linux

Source: Internet
Author: User

Recently mounted n many file systems, roughly the corresponding characteristics of different file systems and mount mode, but still the Linux file system is not from the source to understand. Superficial understanding really not good.

So learn from some of Daniel's blog and his own understanding, summed up the blog series:

First, what is VFS:

VFS is a virtual file system in Linux, also known as the virtual file system switching layer (Filesystem switch), is a software mechanism . It provides an abstraction for application programmers to mask the differences in the underlying file systems. As shown in the following:

The purpose of introducing a file system is to block the differences in various file systems

(1) VFS to the actual file system abstraction, the use of a unified file system to provide users with a set of uniform standard file Operation interface (Open,read,close,select,poll, etc.);

(2) operation through the system call to the VFS to the actual file system.

Ii. Types of File systems:

(1) Disk-based file system;

(2) Network File system (NFS);

(3) Pseudo-file system (SYSFS, proc);

VFS Directory tree structure:

Third, the registration of the file system: (Linux kernel 2.6 source code)

The file system here refers to the actual file systems that may be mounted to the directory tree, the so-called actual file system, meaning that the actual operations in the VFS are ultimately done through them, and does not mean that they must exist on a particular storage device. For example, in the author's Linux machine is registered with "Rootfs", "proc", "ext2", "SOCKFS" and other more than 10 kinds of file systems.

3.1 Data structure:

File_system_type in Include/linux/fs.h:

1 structFile_system_type {2     Const Char*name;3     intfs_flags;4     int(*GET_SB) (structFile_system_type *,int,5                Const Char*,void*,structVfsmount *);6     void(*KILL_SB) (structSuper_block *);7     structModule *owner;8     structFile_system_type *Next;9     structList_head fs_supers;Ten     structLock_class_key S_lock_key; One     structLock_class_key S_umount_key; A};

The registration process will actually represent the instantiation of the struct FILE_SYSTEM_TYPE data structure of each actual filesystem, and then form a list of the links in the kernel with a global variable called File_systems that points to the table header of the linked list.

3.2 Registering the Rootfs file system

In many of the actual file systems, the reason why the Rootfs file system registration process, is because the file system VFS is too close, if EXT2/EXT3 is the native file system of Linux, then the Rootfs file system is the basis of the VFS existence. The general file system registration is done through the Module_init macro and the Do_initcalls () function (readers can understand the process by reading the MODULE_INIT macro declaration and Arch\i386\vmlinux.lds file), but Rootfs Registration is done through the INIT_ROOTFS () initialization function, which means that the ROOTFS registration process is an integral part of the Linux kernel initialization phase.

Init_rootfs () completes the Rootfs file system registration by calling the Register_filesystem (&rootfs_fs_type) function, where rootfs_fs_type is defined as follows: (In fs/ramfs/ INODE.C)

1  struct file_system_type rootfs_fs_type =2     name:        "rootfs"      3 read_super:    4fs_flags: fs_nomount|      5     owner:        6  }

Functions to register the file system:

1 int register_filesystem (struct file_system_type * fs)

Linked list chart for the file system after registration:

Reference:

https://www.ibm.com/developerworks/cn/linux/l-vfs/

The source and introduction of the file system of the VFS file system in Linux

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.