Chapter 9: The Extended Filesystem Family
ext2_mkdir
ext2_new_inode
ext2_make_empty
ext2_add_link
Insert i_op, i_fop, and i_mapping->a_ops
Figure 9-18: Code flow diagram forext2_mkdir.
ext2_create
ext2_new_inode
ext2_add_nondir ext2_add_link
Set i_op, i_fop, and i_mapping->a_ops
Figure 9-19: Code flow diagram forext2_create.
Let us first examine how new directories are created usingmkdir. The kernel passes via the VFS function
vfs_mkdirto theext2_mkdirlow-level function with the following signature.
fs/ext2/namei.c
static int ext2_mkdir(struct inode * dir, struct dentry * dentry, int mode)
diris the directory in which the new subdirectory is to be created, anddentryspecifies the pathname of
the new directory.modespecifies the access mode of the new directory.
Onceext2_new_inodehas reserved a new inode at a suitable place on the hard disk (the section below
describes how the kernel finds the most suitable location with the help of the Orlov allocator), it is pro-
vided with the appropriate file, inode, and address space operations.
fs/ext2/namei.c
static int ext2_mkdir(struct inode * dir, struct dentry * dentry, int mode)
{
...
inode->i_op = &ext2_dir_inode_operations;
inode->i_fop = &ext2_dir_operations;
if (test_opt(inode->i_sb, NOBH))
inode->i_mapping->a_ops = &ext2_nobh_aops;
else
inode->i_mapping->a_ops = &ext2_aops;
...
}