Acho que você deseja anexar um manipulador de eventos do sistema de arquivos ao arquivo, inotify
é o caminho a percorrer. Há uma ferramenta de linha de comando, bem como um api C. Eu não sou especialista em usá-lo, eu apenas mucked com a ferramenta de linha de comando por alguns minutos, então eu não vou tentar fornecer exemplos de código, mas você pode encontrar muita informação sobre as pesquisas do Google.
link
link
Ele fornecerá notificações para (da página man acima):
IN_ACCESS
File was accessed (read) (*).
IN_ATTRIB
Metadata changed, e.g., permissions, timestamps, extended attributes, link count (since Linux 2.6.25), UID, GID, etc. (*).
IN_CLOSE_WRITE
File opened for writing was closed (*).
IN_CLOSE_NOWRITE
File not opened for writing was closed (*).
IN_CREATE
File/directory created in watched directory (*).
IN_DELETE
File/directory deleted from watched directory (*).
IN_DELETE_SELF
Watched file/directory was itself deleted.
IN_MODIFY
File was modified (*).
IN_MOVE_SELF
Watched file/directory was itself moved.
IN_MOVED_FROM
File moved out of watched directory (*).
IN_MOVED_TO
File moved into watched directory (*).
IN_OPEN
File was opened (*).