Pick a Free OS

User login

Navigation

Virtual file system Part 1

The superblock contains information on the entire File System, such as block size, access rights and time of the last modification. In addition, the union u at the end of the structure holds special information on the relevant file system. For file system modules mounted later, there is a pointer generic_sdp. The components s_lock and s_wait are used to ensure synchronized access to the superblock. The superblock also holds reference to the file system’s root inode “s_mounted” and the inode of the mount_point “s_covered”.

Superblock Operations

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

{

void (*read_inode) (struct inode *);

int (*notify_change) (struct inode *, struct iattr *);

void (*write_inode) (struct inode *);

void (*put_inode) (struct inode *);

void (*put_super) (struct super_block *);

void (*write_super) (struct super_block *);

void (*statfs) (struct super_block *, struct statfs *);

int (*remount_fs) (struct super_block *, int *, char *);

};

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)

This function is used to save the information of superblock back on to the storage media. However, this doesn’t guarantee the consistency of the file system due to the caching of inode and data blocks done by LINUX. It is used for synchronizing the device and is ignored by the read-only file systems.

* put_super(sb)

The VFS calls this function when unmounting file systems, when it should also release the superblock and other information buffers.

* statfs(sb, statfsbuf)

The system calls statfs and fstatfs call this superblock operation, which fills in the statfs structure that provides information on the file system, like the number of free blocks and the preferred block size.

* remount_fs(sb, flags, options)