File System
Custom filesystem and ramdisk
On This Page
Custom File System
guideXOS includes a custom in-memory file system designed for simplicity and speed. Files and directories are stored in RAM and persist only for the current session.
Key Features
- In-Memory - All files stored in RAM for fast access
- Hierarchical - Unix-like directory tree structure
- Virtual Root - Starts at root directory
/ - Path Navigation - Supports absolute and relative paths
- Ramdisk Support - Load files from embedded ramdisk
Files are not persisted to disk. All data is lost when the system is powered off or rebooted. This is an in-memory file system only.
Directory Structure
The default filesystem layout follows Unix conventions:
/ Root directory
├── bin/ Executable files (.gxm format)
│ ├── notepad.gxm
│ ├── paint.gxm
│ └── calc.gxm
├── etc/ Configuration files
│ ├── config.txt
│ └── hosts
├── home/ User files
│ └── documents/
├── tmp/ Temporary files
├── dev/ Device files (future)
└── sys/ System information
Special Directories
| Path | Purpose |
|---|---|
/bin |
Application executables in .gxm format |
/etc |
System and application configuration |
/home |
User documents and files |
/tmp |
Temporary working files |
/dev |
Device nodes (future feature) |
/sys |
System runtime information |
File Operations
The file system API provides standard operations for managing files and directories:
File API
// Create file
File.Create(string path, byte[] data)
// Read file
byte[] File.Read(string path)
// Write file (overwrite)
File.Write(string path, byte[] data)
// Delete file
File.Delete(string path)
// Check if file exists
bool File.Exists(string path)
// Get file size
long File.GetSize(string path)
Directory API
// Create directory
Directory.Create(string path)
// Delete directory
Directory.Delete(string path)
// List contents
string[] Directory.List(string path)
// Check if directory exists
bool Directory.Exists(string path)
// Change current directory
Directory.SetCurrent(string path)
// Get current directory
string Directory.GetCurrent()
Path Resolution
- Absolute paths - Start with
/(e.g.,/home/document.txt) - Relative paths - Relative to current directory (e.g.,
documents/file.txt) - Parent directory - Use
..to go up one level - Current directory - Use
.to refer to current location
Ramdisk System
The ramdisk is an archive embedded in the ISO that contains default files and applications. It's loaded at boot time and extracted to the filesystem.
Ramdisk Contents
- Applications - Built-in .gxm executables (Notepad, Paint, Calculator)
- Configuration - Default config files
- Sample Files - Example text files, images
- System Data - Fonts, icons, resources
Loading Process
Boot → FileSystem.Initialize()
↓
Locate ramdisk.img on ISO
↓
Read ramdisk archive
↓
Extract files and directories
↓
Populate filesystem in RAM
↓
Filesystem ready for use
Ramdisk Format
The ramdisk uses a simple custom format:
Header:
Magic: "RDSK"
Version: 1
FileCount: N
For each file:
PathLength: 2 bytes
Path: string
DataLength: 4 bytes
Data: bytes[]
To add custom files to the ramdisk, modify the ramdisk builder tool in the source code and rebuild the ISO image.
File System Commands
Common commands for navigating and managing the filesystem:
Navigation
gx> pwd
/home
gx> ls
documents downloads pictures
gx> cd documents
gx> pwd
/home/documents
gx> cd ..
gx> pwd
/home
gx> cd /bin
gx> ls
notepad.gxm paint.gxm calc.gxm
File Operations
gx> cat README.txt
Welcome to guideXOS!
gx> touch newfile.txt
Created: newfile.txt
gx> echo "Hello World" > test.txt
Written to test.txt
gx> cat test.txt
Hello World
gx> rm test.txt
Deleted: test.txt
Directory Operations
gx> mkdir mydir
Created directory: mydir
gx> cd mydir
gx> touch file1.txt
gx> touch file2.txt
gx> ls
file1.txt file2.txt
gx> cd ..
gx> rmdir mydir
Error: Directory not empty
gx> rm mydir/file1.txt
gx> rm mydir/file2.txt
gx> rmdir mydir
Deleted directory: mydir
Available Commands
| Command | Description |
|---|---|
ls [path] |
List directory contents |
cd <path> |
Change directory |
pwd |
Print working directory |
cat <file> |
Display file contents |
touch <file> |
Create empty file |
rm <file> |
Delete file |
mkdir <dir> |
Create directory |
rmdir <dir> |
Delete empty directory |
cp <src> <dst> |
Copy file |
mv <src> <dst> |
Move/rename file |