Search code examples
cfilesystemsfile-monitoring

Build a File Monitoring System


I have just started programming and would like to implement a file monitoring system from scratch in C.

I have used the Watch Service API in java but I would like to learn how to build one from scratch. I would really appreciate some assistance and guidance.

Thanks.


Solution

  • You can:

    • either rely on existing system calls that will push you notifications on file system modifications (eg: inotify)

    • implement your own kernel module that will intercept file system modification and notify you (if you really want to reimplement the wheel)

    • use a polling-approach, rebuild the filesystem tree in-memory and compare it every second or so. This will be very cpu/io/memory consuming, but it can be instructive.