![]() |
|
|
|
|
|
Virtual file system Part 1
By Vans Information <content@vansinfo.com>
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 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 · 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. * “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: #ifdef CONFIG_EXT2_FS Once a File System implementation has been registered with the VFS, file systems of this type can be administered.
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
The superblock provides pointers to functions, for accessing the file system, in the function vector s_op. These functions are used to perform all the operations on the File System. The super_operations structure is as follows: struct super_operations The functions in the super_operations structure serve to read and write an individual inode, to write the superblock and to read filesystem information. This means that the superblock operations contain functions to transfer the specific representation of the superblock and inode on the data media to their general form in memory and vice versa. As a result, this layer completely hides actual representations. The operations listed in the structure are as follows: * write_super(sb) * put_super(sb) * statfs(sb, statfsbuf) * remount_fs(sb, flags, options) * read_inode(inode) * notify_change(inode, attr) * write_inode(inode) * put_inode(inode)
Other articles by Vans Information
Current Rating: [ 5.67 / 10 ]
Number of Times Rated: [ 46 ]
|
|
|
© 1998-2004 FreeOS Technologies (I) Pvt. Ltd. All rights reserved.
[Privacy Policy]
![]() |