c - How can I watch a specific path? -


is possible 'watch' specifc path , have kernel notify me whenever file or directory of name deleted / written / read / created / etc.?

note: looking answer in c. accept answer points me underlying implementation in different language though (provided find c code)

on linux, kernel supports inotify, allows monitoring of specific files , directories. appears similar thing available freebsd called pnotify based on linux 'inotify' interface. (i have used inotify; however, have not used pnotify myself).

inotify not require write kernel module. apis available in user-space. once initialized, application calls read() inotify file descriptor monitor file and/or directory activity. read events come in structure:

struct inotify_event        {    int      wd;       /* watch descriptor */    uint32_t mask;     /* mask of events */    uint32_t cookie;   /* unique cookie associating related events */    uint32_t len;      /* size of name field */    char     name[];   /* optional null-terminated name */    }; 

from have read of pnotify, similar.


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -