I want to ask you, how I can track file events (e.g. create, update, delete, etc.) on unix using c?
            Asked
            
        
        
            Active
            
        
            Viewed 160 times
        
    1
            
            
        - 
                    2For Linux you might like to read here: http://man7.org/linux/man-pages/man7/inotify.7.html – alk Apr 02 '14 at 16:36
- 
                    Perhaps use SVN/GIT/Mercurial? – Ed Heal Apr 02 '14 at 16:38
- 
                    I need write my own implementation of tracking file events, able to send information to server. – antoniaklja Apr 02 '14 at 16:38
2 Answers
2
            
            
        Use inotify.
From the man page:
The
inotifyAPI provides a mechanism for monitoring file system events.Inotifycan be used to monitor individual files, or to monitor directories. When a directory is monitored,inotifywill return events for the directory itself, and for files inside the directory.
Essentially you create an inotify instance with inotify_init which returns an fd, then add a number of watches with inotify_add_watch. You can then select on the fd and will get notified of any changes relating to the watches you have made.
 
    
    
        abligh
        
- 24,573
- 4
- 47
- 84
-1
            
            
        Unix native package do not provide anything to maintain file versions. you can use SVN unix tool to maintain versions.
 
    
    
        user1011046
        
- 204
- 1
- 5
- 16
