Skip to content

About

Event-driven file synchronization system with inotify monitoring, worker processes, and FIFO-based console control

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

76 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

file-sync-system

Local directory synchronization daemon with event-driven architecture, worker processes, and inotify-based change detection.

Overview

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.).

Features

Event-driven design

Single poll() loop in the manager handles:

  • Console commands

  • inotify filesystem events

  • Worker reports through non-blocking pipes

Real-time filesystem monitoring

  • Uses inotify_add_watch / inotify_rm_watch

  • Detects file ADDED, MODIFIED, and DELETED events

Worker pool with queueing

  • Configurable max concurrent workers

  • New tasks queued when the pool is saturated

  • Workers run via fork + exec, report results to manager

Efficient file synchronization

  • Skips unnecessary copies (size + mtime check)

  • Preserves timestamps (utime) to maintain correctness

  • Supports:

    • FULL directory sync

    • Target updates triggered by file-level changes

Structured logging

  • Manager log: timestamped entries for all worker actions, PIDs, results

  • Console log: user commands + manager responses

Config and startup options

  • Config file supports multiple directory pairs

  • Manager accepts command-line flags for log paths and worker limit

Build

make        # build all components
make clean
make erase-logs
make prepare_dirs

Individual targets:

make bin/fss_manager
make bin/fss_console
make bin/worker

Usage

Start the manager

./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

Start the console client

./bin/fss_console -l <console_log_file>

Example:

./bin/fss_console -l logs/console.log

Console commands

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.

About

Event-driven file synchronization system with inotify monitoring, worker processes, and FIFO-based console control

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages