Local directory synchronization daemon with event-driven architecture, worker processes, and inotify-based change detection.
file-sync-system is a modular, event-driven file synchronization service for Linux.
It monitors multiple source directories and keeps corresponding target directories up to date, reacting to filesystem changes in real time.
The system consists of:
-
fss_manager — a long-running daemon that:
-
Tracks monitored directory pairs
-
Watches for file changes using inotify
-
Spawns isolated worker processes for sync operations
-
Handles sync queueing, backpressure, and logging
-
Communicates with a console client over named pipes
-
-
fss_console — an interactive CLI client that:
-
Sends commands to the manager (add, cancel, status, sync, shutdown)
-
Receives structured responses from the manager
-
Logs all user actions and manager replies
-
-
worker — an exec’d subprocess performing:
-
FULL directory synchronization
-
File-level updates (ADDED / MODIFIED / DELETED)
-
Low-level I/O with detailed structured reporting back to the manager
-
All communication between components uses FIFO pipes (fss_in, fss_out).
All file operations use low-level POSIX primitives (open, read, write, unlink, stat, etc.).
Single poll() loop in the manager handles:
-
Console commands
-
inotify filesystem events
-
Worker reports through non-blocking pipes
-
Uses inotify_add_watch / inotify_rm_watch
-
Detects file ADDED, MODIFIED, and DELETED events
-
Configurable max concurrent workers
-
New tasks queued when the pool is saturated
-
Workers run via fork + exec, report results to manager
-
Skips unnecessary copies (size + mtime check)
-
Preserves timestamps (utime) to maintain correctness
-
Supports:
-
FULL directory sync
-
Target updates triggered by file-level changes
-
-
Manager log: timestamped entries for all worker actions, PIDs, results
-
Console log: user commands + manager responses
-
Config file supports multiple directory pairs
-
Manager accepts command-line flags for log paths and worker limit
make # build all components
make clean
make erase-logs
make prepare_dirsIndividual targets:
make bin/fss_manager
make bin/fss_console
make bin/worker./bin/fss_manager -l <manager_log_file> -c <config_file> -n <worker_limit>
Typical:
./bin/fss_manager -l logs/manager.log -c config/dirs.conf -n 4
./bin/fss_console -l <console_log_file>
Example:
./bin/fss_console -l logs/console.log
| Command | Description |
|---|---|
add <src> <trg> |
Monitor a directory pair |
cancel <src> |
Stop monitoring a directory |
status <src> |
Show state of a monitored pair |
sync <src> |
Trigger a FULL sync |
shutdown |
Stop the manager daemon |
The console sends requests through fss_in and prints structured responses from fss_out.