disable comment on get_upstream
[gitlive] / fanotify / fanotify.vala
1
2 /**
3 valac --vapidir=. --pkg fanotify --pkg posix -o /tmp/fanotify fanotify.vala fanotify-helper.c
4  
5 */
6
7  
8 extern   void fanotify_read (int fh);
9
10 void main (string[] args) {
11
12   
13     // root version?
14     //var fan = Fanotify.init(Fanotify.InitFlag.CLOEXEC | Fanotify.InitFlag.CLASS_CONTENT ,   Posix.O_RDONLY );   
15     
16       //non-root (not content?)
17     // var fan = Fanotify.init(Fanotify.InitFlag.CLOEXEC | Fanotify.InitFlag.CLASS_NOTIF | Fanotify.InitFlag.REPORT_FID   , Posix.O_RDONLY );
18      var fan = Fanotify.init(
19             Fanotify.InitFlag.CLOEXEC | Fanotify.InitFlag.CLASS_NOTIF | Fanotify.InitFlag.REPORT_DIR_FID  |  Fanotify.InitFlag.REPORT_NAME ,
20             Posix.O_RDONLY );   
21     if(fan == -1){
22         Posix.perror("fanotify_init");
23         Posix.exit(Posix.EXIT_FAILURE);
24     }
25     /* 
26     // root version.
27      var ret = Fanotify.mark(
28                 fan,
29                 Fanotify.Mark.ADD | Fanotify.Mark.MOUNT,
30                 Fanotify.EventType.OPEN_PERM  | Fanotify.EventType.CLOSE_WRITE  ,  
31                 Posix.AT_FDCWD, "/home/"
32     );
33  */
34     // not root version?
35     var ret = Fanotify.mark(
36                 fan,
37                 Fanotify.Mark.ADD  ,
38                 Fanotify.EventType.CREATE | Fanotify.EventType.DELETE | Fanotify.EventType.MODIFY | Fanotify.EventType.EVENT_ON_CHILD,
39                 Posix.AT_FDCWD, "/home/alan/gitlive/gitlive/fanotify"
40     );
41     
42     if(ret == -1){
43         Posix.perror("fanotify_mark");
44         Posix.exit(Posix.EXIT_FAILURE);
45     }
46     Posix.printf("got mark %d", ret);
47     fanotify_read(fan);
48     
49 }