disable comment on get_upstream
[gitlive] / fanotify / fanotify.vala
diff --git a/fanotify/fanotify.vala b/fanotify/fanotify.vala
new file mode 100644 (file)
index 0000000..d73859a
--- /dev/null
@@ -0,0 +1,49 @@
+
+/**
+valac --vapidir=. --pkg fanotify --pkg posix -o /tmp/fanotify fanotify.vala fanotify-helper.c
+*/
+
+extern   void fanotify_read (int fh);
+
+void main (string[] args) {
+
+  
+    // root version?
+    //var fan = Fanotify.init(Fanotify.InitFlag.CLOEXEC | Fanotify.InitFlag.CLASS_CONTENT ,   Posix.O_RDONLY );   
+    
+      //non-root (not content?)
+    // var fan = Fanotify.init(Fanotify.InitFlag.CLOEXEC | Fanotify.InitFlag.CLASS_NOTIF | Fanotify.InitFlag.REPORT_FID   , Posix.O_RDONLY );
+     var fan = Fanotify.init(
+            Fanotify.InitFlag.CLOEXEC | Fanotify.InitFlag.CLASS_NOTIF | Fanotify.InitFlag.REPORT_DIR_FID  |  Fanotify.InitFlag.REPORT_NAME ,
+            Posix.O_RDONLY );   
+    if(fan == -1){
+        Posix.perror("fanotify_init");
+        Posix.exit(Posix.EXIT_FAILURE);
+    }
+    /* 
+    // root version.
+     var ret = Fanotify.mark(
+                fan,
+                Fanotify.Mark.ADD | Fanotify.Mark.MOUNT,
+                Fanotify.EventType.OPEN_PERM  | Fanotify.EventType.CLOSE_WRITE  ,  
+                Posix.AT_FDCWD, "/home/"
+    );
+ */
+    // not root version?
+    var ret = Fanotify.mark(
+                fan,
+                Fanotify.Mark.ADD  ,
+                Fanotify.EventType.CREATE | Fanotify.EventType.DELETE | Fanotify.EventType.MODIFY | Fanotify.EventType.EVENT_ON_CHILD,
+                Posix.AT_FDCWD, "/home/alan/gitlive/gitlive/fanotify"
+    );
+    
+    if(ret == -1){
+        Posix.perror("fanotify_mark");
+        Posix.exit(Posix.EXIT_FAILURE);
+    }
+    Posix.printf("got mark %d", ret);
+    fanotify_read(fan);
+    
+}
\ No newline at end of file