fsdb is a lightweight and secure Unix daemon that provides basic key-value storage functionality over a UNIX domain socket. A local, atomic, multi-threaded, syslog-audited, filesystem-backed object store with consistent performance under load.
- ✅ Fast local IPC via UNIX domain sockets
- ✅ Extremely scalable 2-level folder sharding for 100M+ files
- ✅ Safe concurrent access via POSIX file locks
- ✅ Audit logging with timestamped entries
- ✅ Process-safe with
flock
-based PID file locking - ✅ Signal handling for graceful shutdown
- ✅ Hardened with
-fPIE
,-D_FORTIFY_SOURCE=2
, stack protector, and secure file sanitization - ✅ Memory-safe: passes Valgrind and Clang analyzer with zero leaks
- ✅ Can run on
tmpfs
,xfs
, or any Linux filesystem - 🔒 Secure and concurrent: uses
epoll
,pthread
, and safe file locking (fcntl
) - 🔌 Communication via Unix socket
🧪 Commands Supported
CREATE <db>
: initialize DB structureINSERT <db> <id> <data>
: insert new recordUPDATE <db> <id> <data>
: update existingGET <db> <id>
: fetch contentsDELETE <db> <id>
: remove entryCHECK <db> <id>
: test existenceTOUCH <db> <id>
: create an empty file
🔐 Security & Hardening
Uses flock() and fcntl() locks Sanitizes all id and db inputs Resists TOCTOU vulnerabilities Can run under chroot or as an unprivileged user Validated with valgrind, clang --analyze, and sanitizers
🧱 Architecture
main() initializes socket, threads, and event loop Clients accepted via epoll, queued using a ring buffer Worker threads process requests from the queue Each database is a subdirectory; each key is a file
🧠 Recommended Filesystem Tuning
For best performance:
Use XFS with directory indexing and large inode allocation Mount with noatime, nodiratime, inode64 (XFS-specific) For high-performance volatility: mount tmpfs on specific DBs