Pick a Free OS

User login


Ext2- Part II: Inside the bonnet

The Block Bitmap is a clever way to keep track of new empty and old used ones. In order to look for a block, one needs to check the group to which the file belongs. Then the Block Bitmap of the appropriate `Group’ is selected and searched for the required block.

Inode Bitmap of the Group: Similar to the blocks, the inodes assigned to the various files need to be taken into account. The inode stores all information about a file. A fixed number of blocks are usually allocated for storing the Inode Table, which stores all the file inodes. The inodes also contain pointers to disk blocks where the actual files are stored. The Inode bitmap is provided to check for allocated blocks and free them when files are deleted from the system.

Inode Table of the group: Inode Table contains an array of records (inodes), which are basically arrays of structures, containing Meta information about the file. This information includes the filename, the file size, a pointer to the disk blocks containing the file, the file creation, access and modification times, the number of links to the file, as well as the user and group ids of the file. The structures of the pointers to disk blocks are arranged in such a manner that they can be easily accessed.

The inode contains 15 pointers to blocks. Of these pointers, the first 12 are direct pointers to data. The following entry is indirect pointers to data. The next one points to `a block of pointers’ to `blocks of pointers’ to `data’ (double indirect). And another entry points to a `block of pointers’ to `a block of pointers’ to `a block of pointers’ to `data’ (triple indirect). After these data structures follow the disk blocks on which the actual blocks of data are stored.

Directories: A `directory, is used for logical organization and security of files on a file system. It is a standard feature of most file systems. On an ext2-based system, a directory has a specific structure. This structure contains the length of the record, the inode number associated with it, as well as the name and the length of the filename. The first two entries are ‘.’ and ‘..’ respectively for every directory.

Easy operations

It is interesting to note how some of these features make common operations on a filesystem a lot easier. Take the example of moving a file or a directory to another directory. Here we merely change the inode number for the ‘..’ entry in the directory, and this accomplishes our ‘move’ operation. Creating a symlink to a file simply requires a change in the inode entry of the newly created ‘symlink’ file.