struct super_operations {

struct inode *(*alloc_inode)(struct super_block *sb); void (*destroy_inode)(struct inode *);

void (*write_super_lockfs) (struct super_block *);

void (*unlockfs) (struct super_block *);

int (*statfs) (struct super_block *, struct kstatfs *);

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

void (*umount_begin) (struct super_block *);

int (*show_options)(struct seq_file *, struct vfsmount *); int (*show_stats)(struct seq_file *, struct vfsmount *);

The operations in the structure do not change the contents of inodes but control the way in which inode data are obtained and returned to the underlying implementations. The structure also includes methods for carrying out relatively extensive tasks such as remounting filesystems. As the names of the function pointers clearly indicate the actions performed by the functions, I describe them in a very cursory fashion below.

□ read_inode reads inode data; strangely, it requires a pointer to an inode structure but no other parameters. How does the function then know which inode to read? The answer is relatively simple. The i_ino field of the passed inode holds an inode number that uniquely identifies the desired inode in the filesystem. The routines of the low-level implementation read this value, fetch the relevant data from the storage medium, and fill the remaining fields of the inode object.

□ dirty_inode marks the passed inode structure as "dirty" because its data have been modified.

□ delete_inode deletes the inode from memory and from the underlying storage medium.

As you will see when examining the filesystem implementations, deleting an inode from a storage medium causes the pointer to the associated data blocks to be removed but leaves the file data untouched (they are overwritten at an unspecified time in the future). Knowledge of the filesystem structure coupled with physical access to the computer are therefore sufficient to restore deleted files — and this could be a problem where sensitive data are concerned.

□ put_inode decrements the inode usage counter in memory when a process finishes using the data.

The object cannot be removed from memory until all users have invoked this function and the counter has reached 0.

□ clear_inode is invoked internally by the VFS when there is no further use for an inode. It frees all associated memory pages still containing data. clear_inode is not implemented by all filesystems as these are able to release memory in other ways.

□ write_super and write_super_lockfs write the superblock to the storage medium. The difference between the two functions is the way in which they use kernel locking. The kernel must select the function appropriate to the situation. I won't bother discussing the detailed differences in code because both alternatives do basically the same work.

□ unlockfs is used by the Ext3 and Reiserfs journaling filesystem to ensure correct interaction with the Device Mapper Code.

□ remount_fs remounts a mounted filesystem with modified options (this happens at boot time, e.g., to allow Write access to the root filesystem previously mounted with Read Only access).

□ put_super removes private information of the superblock from memory when a filesystem is unmounted and the data are no longer needed.

□ statfs delivers statistics information on the filesystem — for instance, the number of used and unused data blocks or the maximum length of filenames. It works hand-in-hand with the system call of the same name.

□ umount_begin is used only by networking filesystems (NFS, CIFS, and 9fs) and userspace filesystems (FUSE). It permits communication with the remote partner before the unmounting operation is started. It is invoked only when a filesystem is forced to unmount; in other words, it is only used when mnt_force forces the kernel to perform the umount operation, although there are still references to the filesystem.

□ sync_fs synchronizes the filesystem data with the data on the underlying block device.

□ show_options is used by the proc filesystem to display the filesystem mount options. show_stats provides filesystem statistics for the same purpose.

Continue reading here: Fsnamespacec

Was this article helpful?

0 0