Linux Foundation and Application Development Series VII: Everything is a file

Linux kernel

Shield hardware differences, abstract all hardware devices into files, and provide a unified interface for users to use.

virtual file system

The abstraction layer, the access to the file actually makes the access to the abstraction layer.

  • Abstract object: encapsulates the details of reading and writing at the bottom layer, and uses the polymorphism of C language to realize the interface of the specific file system system.

The Virtual File System (VFS for short) is a subsystem in the Linux operating system, which provides an abstraction layer for unified management of various types of file systems. VFS allows applications to use a unified interface to access different file systems without caring about the specific implementation of the underlying file system.

In Linux, each file system has its own driver responsible for implementing specific file system operations, such as reading, writing, creating, and deleting files. VFS provides a common file system interface through which applications can use the same method to operate various types of file systems, whether ext4, NTFS, FAT32 or other file systems.

The core data structure of VFS is the virtual file table (Virtual File Table, referred to as VFT). Each opened file will have a corresponding VFT item, which contains information related to the file, such as the location, permissions, and operations of the file. VFS also provides some functions for operations such as searching, opening, closing, and reading and writing files.

Through VFS, users can switch between different file systems without modifying the code of the application. This enables Linux to support a variety of different file systems and provides applications with greater flexibility and portability.

 

 

Ordinary file system:

  • ext4

  • fat32

  • ubifs

Special file system:

  • Process file system: procfs, mount (mount command) in /proc, store process-related information, which is equivalent to the task manager under win.

  • Device file system: devfs, mounted on /dev. Store the hardware operation interface.

Guess you like

Origin blog.csdn.net/qq_51519091/article/details/132193947