6.2 An Inode

Some blocks of VFS (and ext2) are inodes. An inode includes important attributes of files.

6.2.1 Mode

The “mode” of an inode indicates special attributes of a file. For example, a directory is represented by a mode flag. Linux has many other special kinds of file that are flagged by the mode bits. Such file types include sockets, pipes and symbolic links.

The mode also includes important flags like read permission, write permission and execute permission.

Many mode options of a file can be changed by the chmod (CHange MODe) command.

6.2.2 Owner info

There are actually two owners to each file. The first is a “user” owner, while the second is a “group” owner. Both owners are represented as a number. This is possible because each user and each group has a numeric identifier (ID). The ID of the user owner is known as the UID, while the ID of the group owner is known as the GID.

The owner information of a file can be changed by the verb’chown’ (CHange OWNer) command.

6.2.3 Size and timestamps

The size is the size of the file in number of bytes. This field is necessary because the disk space used by a file is measured in blocks, but a file may end anywhere in the last logical block.

There are several timestamps that an inode tracks: creation, last modified and last accessed.

6.2.4 Direct blocks

The “direct blocks” are really pointers. Each pointer is a block number that identifies a block that is a portion of the represented file. There are 12 (twelve) direct blocks. This means that any file that has a size of less than 12 times “block size” do not need indirect blocks of any kind.

6.2.5 (Single) Indirect block

There is one pointer to a single indirect block. This pointer is the number of a block that itself is a table of numbers of blocks of the represented file. We also say that one indirect access is needed from this pointer to get to the block number of a data block (of the file).

6.2.6 Double Indirect block

Two indirect access is needed from this pointer to get to the block number of a data block of the file.

6.2.7 Triple Indirect block

Three indirect access is needed from this pointer to get to the block number of a data block of the file.

Figure 6.2.7 illustrates how the data blocks of a file are linked from an inode.


PIC

Figure 1: Data blocks linked from an inode.

6.2.8 For more info

Visit http://en.wikipedia.org/wiki/Inode_pointer_structure.