AlgoMaster Logo

Design In-Memory File System

Ashish

Ashish Pratap Singh

hard

In this chapter, we will explore the low-level design of file system in detail.

Let's start by clarifying the requirements:

1. Clarifying Requirements

Before starting the design, it's important to ask thoughtful questions to uncover hidden assumptions, clarify ambiguities, and define the system's scope more precisely.

Here is an example of how a conversation between the candidate and the interviewer might unfold:

After gathering the details, we can summarize the key system requirements.

1.1 Functional Requirements

  • Support creation of files and directories organized in a hierarchical structure.
  • The entire file system state, including all files and directories, must be stored in memory.
  • Interaction with the file system will be through a shell that parses and executes string-based commands.
  • The following commands must be supported: mkdir, cd, touch, ls, pwd, cat, and echo?
  •  ls command should support a simple format and a detailed (-l) format.
  • The system must correctly handle both absolute (e.g., /home/user) and relative (e.g., documents, ../) paths.
  • Files should be able to store simple string-based content.

1.2 Non-Functional Requirements

  • Modularity: The system should follow object-oriented principles with clear separation of concerns across components.
  • Maintainability: Code should be clean, testable, and easy to extend or debug.
  • Extensibility: It should be easy to add new commands to the shell or new listing strategies for the ls command without modifying existing core logic.
  • Error Handling: The system should provide clear error messages for invalid operations, such as trying to cd into a file or accessing a non-existent path.
  • Usability: The system should expose an intuitive API for common file system operations.

2. Identifying Core Entities

Premium Content

This content is for premium members only.