This project combines a Computer Science course assignment that aimed to create an interactive shell for running commands on a .iso or .img disk image using the EXT2 filesystem, with a Go API, leveraging these developed operations as a "database."
Link to the EXT2 project (switch to the db-engine branch for this project)
The system consists of two main components that communicate via standard I/O (stdin/stdout):
-
Database (
ext2-db-engine):
A C command-line tool compiled from the original project, which directly manipulates an EXT2 disk image.
It handles all low-level operations, such as inode allocation, bitmap manipulation, and block read/write. -
Go API:
A simple RESTful API that exposes endpoints for Create and List (with filters) operations on a "user database."
It processes HTTP requests, validates data, and calls the C "database" to persist or retrieve information.
- GCC compiler
readlinelibrary (sudo apt-get install libreadline-devor equivalent)- Go (version 1.18 or higher)
The project uses a Makefile in the root of the ext2-fs-tools submodule to compile the C engine and a Makefile in the ext2-db-go-api root to orchestrate everything.
- Compile the C engine:
cd ext2-db-engine make all cd ..
1.1 Generate a new image
make generate-ext21.2 Creating the table
make runInside the terminal that opens, create the database with the command:
touch user_record-
Start the Go API: In the project root, run:
cd api go run .
The server will be running at
http://localhost:8080.
The API exposes the following endpoints for the User entity:
-
Endpoint:
POST /users -
Description: Creates a new user record in the
/user_recordfile inside the EXT2 image. -
Request Body (JSON):
{ "id": 1, "is_active": 1, "username": "moraski", "email": "moraski@gmail.com" }
- Endpoint:
GET /users - Description: Returns a list of all registered users.
- Query Parameters:
limit=<number>: Limits the number of results.filters=<conditions>: (Optional) Filters results. Conditions must follow the patternfield:operator:value.- Supports
=,%
- Supports