Module fs_objects

Module fs_objects 

Source
Expand description

§File system objects.

Every on-disk object is represented by an inode. This inode is diverge into multiple file types like a regular file or a directory based on the Inode::ftype field. In this project, you will support only two primary types of file:

  • RegularFile: A regular file is the most common file type. It represents a sequence of bytes, typically used to store application data, logs, executables, or any other form of persistent information. The operating system exposes system calls such as read(), and write() to allow user programs to interact with regular files. Inodes for regular files point to data blocks on disk that store the actual file content.
  • Directory: A directory is a special type of file that acts as a container for other files. Internally, a directory consists of a list of entries that map human-readable file names to inode numbers. This mapping allows the kernel to resolve file paths and traverse the hierarchical file system structure. Directory inodes point to data blocks containing serialized directory entries rather than arbitrary user data.

§Directory Internals

A directory is represented as a collection of directory entries stored within the data blocks of the directory inode. Each directory block contains an array of DirectoryBlockEntry structures, which provide the mapping between human-readable names and their corresponding inode numbers. All directory operations, such as adding, removing, or searching for files and subdirectories, are performed by manipulating this collection of entries. The directory MUST start with two entries: “.” and “..”, which points to itself and the parent directory respectively.

§Implementation Requirements

You need to implement the followings:

At this point, you have implemented the core abstractions for managing inodes in the filesystem, supporting both regular files and directories. These abstractions provide safe and structured access to both on-disk and in-memory inode data, allowing higher-level components to interact with files without dealing directly with low-level disk structures.

This module gives you insight into the internal foundations of the file abstraction in the filesystem. The next section will focus on maintaining crash consistency in the filesystem..

Structs§

Directory
Represents a directory, which contains multiple directory entries.
RegularFile
A handle to a regular file in the filesystem.