6.3 Directories

A directory starts with an inode that has the “mode” indicating that it represents a directory. The content (the data blocks) of a directory is a list that maps a name to the block number of the inode that represents that named file or directory.

A directory also remembers whether a named file is a regular file or a directory. Because only a byte is reserved to indicate the length of a directory entry, and two bytes are used for the length of name and file type, a file or directory name can only have up to 253 bytes.

The first inode pointed to by the superblock of VFS must be the inode of a directory. This is called the “root” directory of the file system.

Despite a directory is really a special file, normal commands cannot see it as such. This is intentional so that a user does not mistakenly treat a directory as a file.