The virtual file system is one of the best features of Linux that makes Linux an operating system of choice. Format a pen drive in any Linux flavor operating system and try to see the contents in windows OS. Windows OS does not show anything. What is the problem?
Now try doing the same in windows i.e format a Pendrive in the windows operating system to store some files and then try to view these files through any Linux operating system. we will be able to see the contents. we will also be able to open and read file content easily.
How is that possible? The answer to these questions lies in the concept of the virtual file system that Linux support. VFX is a file system interface for a user process. VFS has the capability of conceiving features and behavior of any file system regardless of processor type memory format as well as hardware.
Two mapping functions are used that transform the properties of the real-time system to the characteristics required by VFS.
Virtual File SystemAs shown in the diagram:
The user process initiates the execution of the system call with the help of the VFS method. VFS interprets this stimulus into an appropriate internal file system call which in turn activates the concerned mapping function of the specified file system.
In the case of an operating system that demands structural changes, all required constructs are created dynamically to meet the requirements. Ex: In FAT-compatible systems, directories are not treated as files so such characteristics are dynamically created since they cannot be mapped. The target file system is then activated to take control so that results can be delivered to the user of the system.
As seen in the above diagram actions and reactions are observed as a role of VFS:
The user initiates a file-oriented system call.
- Kernel calls function in VFS.
- Execution of file system independent manipulation and initiation of target file system call.
- mapping of calls from VFS to the target file system.
- The target file system converts the request into device driver execution.
- Appropriate action is completed as per the guidance of the device driver function and the results are obtained.
- Since VFS objects are implemented as C data structures. Every object is attached with data and pointers.
Primary Types in VFS
- Superblock object: point out specific mount points.
- inode object: Relates specific file.
- Directory: Shows entry to a specific directory.
- File object: Depicts an open file that is used by the process.
1. Tmpfs virtual file system: A virtual file system for Linux called tmpfs stores data in the system's virtual memory. The internal caches of the kernel serve as temporary storage for all files, much like any other virtual file system.
2. Sysfs virtual file system: When a device is added or withdrawn, the sysfs virtual file system dynamically updates the user-specified view of the system's devices. The global, bus, and device discovery levels are represented by the directory hierarchy beneath /sys. The files on the global layer record the device's power state, which is also programmable. The files in the bus layer report details about each device's resources and IRQ number. The file system contains files that a device driver can use to access data or configurable interfaces.
The filesystem type, which is specified in include/linux/fs.h (and abbreviated here for brevity), must be known by the kernel in order to use a filesystem:
Example 1:
C++
struct file_system_type {
const char* name;
int fs_flags;
int (*init_fs_context)(struct fs_context*);
const struct fs_parameter_spec* parameters;
struct dentry* (*mount)(struct file_system_type*, int,
const char*, void*);
void (*kill_sb)(struct super_block*);
struct module* owner;
struct file_system_type* next;
struct hlist_head fs_supers;
};
- struct file_system_type maintains data related to a filesystem but is not associated with any particular 'instance of a filesystem'.
- The userspace command cat /proc/filesystems can be used to inspect the linked list of known filesystem types that the VFS keeps.
- Filesystem types are unregistered and registered in the kernel through these functions in include/linux/fs.h:
- A filesystem of a certain type may be mounted to a place in the directory tree if the kernel is aware of it (i.e., it has been registered).
Similar Reads
Virtual Memory in Operating System
Virtual memory is a memory management technique used by operating systems to give the appearance of a large, continuous block of memory to applications, even if the physical memory (RAM) is limited. It allows larger applications to run on systems with less RAM.The main objective of virtual memory is
15+ min read
Virtual Machines in Operating System
A Virtual Machine is an Operating System or application environment that runs on software that replicates special hardware. The end-user experience when utilizing a virtual machine is identical to that of special hardware. What is Virtual Machine?Virtual Machine abstracts the hardware of our persona
5 min read
Virtualization in Distributed System
Virtualization in distributed systems enhances flexibility and resource efficiency by abstracting hardware and software layers. This technology enables the creation of virtual environments, optimizing resource use, improving scalability, and simplifying management in complex, distributed infrastruct
11 min read
Operating System Tutorial
An Operating System(OS) is a software that manages and handles hardware and software resources of a computing device. Responsible for managing and controlling all the activities and sharing of computer resources among different running applications.A low-level Software that includes all the basic fu
4 min read
Types of Virtual Machines
In this article, we will study about virtual machines, types of virtual machines, and virtual machine languages. Virtual Machine is like fake computer system operating on your hardware. It partially uses the hardware of your system (like CPU, RAM, disk space, etc.) but its space is completely separa
3 min read
Andrew File System
The Andrew File System (AFS) is a distributed file system that allows multiple computers to share files and data seamlessly. It was developed by Morris ET AL. in 1986 at Carnegie Mellon University in collaboration with IBM. AFS was designed to make it easier for people working on different computers
5 min read
Virtual Address Space in Operating System
In operating systems, Virtual memory plays a very vital role, in managing the memory allotted to different processes and efficiently isolating the different memory addresses. The role of the virtual address is to assign a space to the ledger of all the virtual memory areas that are provided to diffe
5 min read
Socio-technical Systems
Software and hardware are interdependent. Without the hardware, a software is an abstraction. When you put hardware and software together, you create a system. This system will be able to carry out multiple complex computations and return the result to its environment. This illustrates one of the fu
4 min read
Virtual Memory | Questions
Advantages Large virtual memory. More efficient use of memory. Unconstrained multiprogramming. There is no limit on degree of multiprogramming. Disadvantages Number of tables and amount of processor overhead for handling page interrupts are greater than in the case of the simple paged management tec
2 min read
Bash Script - File system
On a partition or disc, a file system is a logical grouping of files. A partition serves as a storage space for data and, if needed, can take up the entire hard disc. One file system may house the /file system, while another may house the /home file system. Your hard drive may have a variety of part
7 min read