SafeFS

Static README snapshot; an interactive deployment can be added later.

SafeFS

`SafeFS` is a user-space filesystem prototype for Windows that stores its data in one large container file and mounts it through Dokan.

It is aimed at unreliable SSD/USB media where you want:

What This Version Does

Important Limitation

This first version works inside a normal host filesystem file. That means it can manage **logical** bad blocks and rewrite around corruption inside the container, but it cannot fully control where the host filesystem places the container on the physical flash.

So:

The direct-device version is the right next step if you want true physical placement control and stronger wear-management guarantees.

Layout

- container geometry

- metadata snapshots

- block IO

- parity repair

- wear-aware allocator

- B+tree-backed indexes

- Dokan callbacks

- mounted filesystem surface

- CLI commands

Build

This repo is C++20 + CMake and expects the local Dokan SDK under:

`C:\Program Files\Dokan\DokanLibrary-1.0.5`

Build from a VS Build Tools developer environment:

cmd /c '"C:\Program Files (x86)\Microsoft Visual Studio\18\BuildTools\VC\Auxiliary\Build\vcvars64.bat" && cmake -S . -B build -G "NMake Makefiles" && cmake --build build'

The executable will be:

`build\safefs.exe`

Commands

Initialize a container that uses nearly all free space on the target volume:

.\build\safefs.exe init --image T:\safefs.img --size auto --label SAFEFS

Mount it as a drive letter:

.\build\safefs.exe mount --image T:\safefs.img --mount M:

Unmount it:

.\build\safefs.exe unmount --mount M:

Mount it into an NTFS directory:

mkdir C:\safefs-mount
.\build\safefs.exe mount --image T:\safefs.img --mount C:\safefs-mount

Unmount the directory mount:

.\build\safefs.exe unmount --mount C:\safefs-mount

Check status:

.\build\safefs.exe status --image T:\safefs.img

Fill the remaining free SafeFS space with a deterministic test file, read it back, and seed the bad-block map:

.\build\safefs.exe autofill --image T:\safefs.img --chunk 4MB

Keep some free space reserved and preserve the fill file for later inspection:

.\build\safefs.exe autofill --image T:\safefs.img --reserve 128MB --keep-file

Scrub and repair:

.\build\safefs.exe scrub --image T:\safefs.img --repair

Run the built-in corruption/recovery test:

.\build\safefs.exe selftest --workdir .\test-output

Current Design Notes

Future Work