Creating and Deleting Inodes

Inodes must also be created and deleted by low-level functions of the Ext2 filesystem. This is necessary when a file or directory is created (or deleted) — the core code of the two variants hardly differs.

Let's begin with the creation of a file or directory. As explained in Chapter 8, the open and mkdir system calls are available for this purpose. They work through the various functions of the virtual filesystem to arrive at the create and mkdir functions, each of which is pointed to by a function pointer in the file-specific instance of inode_operations. The ext2_create and ext2_mkdir functions are inserted as described in Section 9.2.4. Both functions are located in fs/ext2/namei.c. The flow of both actions is shown in the code flow diagrams in Figures 9-18 and 9-19.

ext2_

mkdir|

ext2_new_inode |

Insert i_op, i_fop, and i_mapping->a_ops

ext2_make_empty |

ext2_add_link |

Figure 9-18: Code flow diagram for ext2_mkdir.

Figure 9-18: Code flow diagram for ext2_mkdir.

ext2_create

ext2_new_inode |

Set i_op, i_fop, and i_mapping->a_ops

ext2_add_nond^-

ext2_add_link

Continue reading here: Figure 919 Code flow diagram for ext2create

Was this article helpful?

0 0