Many of the VFS methods described in Chapter 12 have a corresponding Ext2 implementation. Since it would take a whole book to describe all of them, we limit ourselves to briefly reviewing the methods implemented in Ext2. Once the disk and the memory data structures are clearly understood, the reader should be able to follow the code of the Ext2 functions that implement them.
Many VFS superblock operations have a specific implementation in Ext2, namely read_inode, write_inode, put_inode, delete_inode, put_super, write_super, statfs, and remount_fs. The addresses of the superblock methods are stored into the ext2_sops array of pointers.
Some of the VFS inode operations have a specific implementation in Ext2, which depends on the type of the file to which the inode refers.
If the inode refers to a regular file, all inode operations listed in the ext2_file_inode_operations table have a NULL pointer, except for the truncate operation that is implemented by the ext2_truncate( ) function. Recall that the VFS uses its own generic functions when the corresponding Ext2 method is undefined (a NULL pointer).
If the inode refers to a directory, most inode operations listed in the ext2_dir_inode_operations table are implemented by specific Ext2 functions (see Table 17-8).
If the inode refers to a symbolic link that can be fully stored inside the inode itself, all inode methods are NULL except for readlink and follow_link, which are implemented by ext2_readlink( ) and ext2_follow_link( ), respectively. The addresses of those methods are stored in the ext2_fast_symlink_inode_operations table. On the other hand, if the inode refers to a long symbolic link that has to be stored inside a data block, the readlink and follow_link methods are implemented by the generic page_readlink( ) and page_follow_link( ) functions, whose addresses are stored in the page_symlink_inode_operations table.
If the inode refers to a character device file, to a block device file, or to a named pipe (see Section 19.2), the inode operations do not depend on the filesystem. They are specified in the chrdev_inode_operations, blkdev_inode_operations, and fifo_inode_operations tables, respectively.
The file operations specific to the Ext2 filesystem are listed in Table 17-9. As you can see, several VFS methods are implemented by generic functions that are common to many filesystems. The addresses of these methods are stored in the ext2_file_operations table.
Notice that the Ext2's read and write methods are implemented by the generic_file_read( ) and generic_file_write( ) functions, respectively. These are described in Section 15.1.1 and Section 15.1.3.