Files
markbase/docs/NFS_BACKEND_DAY1.md
2026-05-18 17:02:30 +08:00

3.2 KiB

MarkBase NFS Backend Implementation - Day 1 Complete

Date: 2026-05-17 13:40
Status: Phase 2 Started - MarkBaseFS backend created
Progress: 25% (MarkBaseFS struct created, tests passing)


What We Completed

1. Created NFS Module Structure

  • Added nfs module to src/lib.rs
  • Created src/nfs/mod.rs (module export)
  • Created src/nfs/markbase_fs.rs (236 lines)

2. Implemented vfs::FileSystem Trait

  • MarkBaseFS::new() - SQLite connection creation
  • resolve_path() - Path to node_id resolution (recursive query)
  • read_dir() - Query children from file_nodes
  • open_file() - Read file from disk (via aliases_json.path)
  • metadata() - Query file_size, node_type
  • exists() - Path existence check
  • create_dir(), create_file(), etc. - NotSupported (read-only for now)

3. Error Handling

  • Created rusqlite_to_io_error() helper
  • Proper vfs::VfsErrorKind conversions
  • Lock poisoning handling (Mutex)

4. Tests

  • test_markbase_fs_creation - Tests SQLite connection
  • test_resolve_root - Tests root path resolution

Build Status

$ cargo build
Finished `dev` profile [unoptimized + debuginfo] target(s) in 3.36s

Warnings: 10 warnings (unused variables/imports)
Errors: 0 errors


What's Left (Phase 2-3)

Day 2-3 Tasks

Task 1: Integrate bold-nfs library

  • Add bold-nfs dependency to Cargo.toml
  • Create NFS server binary (src/bin/markbase-nfs.rs)
  • Connect MarkBaseFS to bold-nfs NFSServer

Task 2: Test with warren.sqlite

  • Mount NFS volume
  • Verify file tree visible (12659 nodes)
  • Test file reading from mount point

Task 3: Add caching

  • Implement LRU cache for node_id lookup
  • Optimize SQLite queries (indexes)
  • Add path caching (HashMap)

Manual Test Still Needed

From Phase 1: You still need to manually test bold-nfs mount:

# Terminal 1: Start bold-mem server
cd /tmp/bold-nfs
./target/release/bold-mem exec/memoryfs.yaml

# Terminal 2: Mount NFS (use your password)
sudo mkdir -p /tmp/nfs_demo
sudo mount_nfs -o vers=4,port=11112 127.0.0.1:/ /tmp/nfs_demo

# Terminal 3: Test files
ls /tmp/nfs_demo/
cat /tmp/nfs_demo/home/user/file1

# Unmount
sudo umount /tmp/nfs_demo

Report back: Did mount succeed? Did files appear?


Next Steps

If mount succeeds:

  1. Continue Phase 2 implementation
  2. Create markbase-nfs binary
  3. Test with warren.sqlite

If mount fails:

  1. Debug mount_nfs options
  2. Try NFSv3 (vers=3 option)
  3. Consider libnfs-go fallback

Current Architecture

MarkBase NFS Backend (Day 1)
├── src/nfs/markbase_fs.rs (236 lines)
│   ├── MarkBaseFS struct
│   ├── FileSystem trait (9 methods)
│   ├── resolve_path() (recursive query)
│   └── SQLite backend (rusqlite)
└── tests (2 tests passing)

Next Layer (Day 2):
├── bold-nfs library (NFSServer)
├── src/bin/markbase-nfs.rs
└── vfs::VfsPath integration

Code Statistics

  • Lines of code: 236 lines (markbase_fs.rs)
  • Tests: 2 tests
  • Compilation: Success
  • Dependencies: vfs-0.12, rusqlite-0.32

Ready for Day 2 implementation once Phase 1 mount test confirmed