add syscall wrappers for inotify
authorRich Felker <dalias@aerifal.cx>
Sat, 19 Feb 2011 07:52:29 +0000 (02:52 -0500)
committerRich Felker <dalias@aerifal.cx>
Sat, 19 Feb 2011 07:52:29 +0000 (02:52 -0500)
include/sys/inotify.h [new file with mode: 0644]
src/linux/inotify_add_watch.c [new file with mode: 0644]
src/linux/inotify_init.c [new file with mode: 0644]
src/linux/inotify_init1.c [new file with mode: 0644]
src/linux/inotify_rm_watch.c [new file with mode: 0644]

diff --git a/include/sys/inotify.h b/include/sys/inotify.h
new file mode 100644 (file)
index 0000000..59644ef
--- /dev/null
@@ -0,0 +1,55 @@
+#ifndef _SYS_INOTIFY_H
+#define _SYS_INOTIFY_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+
+struct inotify_event {
+       int we;
+       uint32_t mask, cookie, len;
+       char name[];
+};
+
+#define IN_CLOEXEC 020000000
+#define IN_NONBLOCK 04000
+
+#define IN_ACCESS        0x00000001
+#define IN_MODIFY        0x00000002
+#define IN_ATTRIB        0x00000004
+#define IN_CLOSE_WRITE   0x00000008
+#define IN_CLOSE_NOWRITE 0x00000010
+#define IN_CLOSE         (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE)
+#define IN_OPEN          0x00000020
+#define IN_MOVED_FROM    0x00000040
+#define IN_MOVED_TO      0x00000080
+#define IN_MOVE          (IN_MOVED_FROM | IN_MOVED_TO)
+#define IN_CREATE        0x00000100
+#define IN_DELETE        0x00000200
+#define IN_DELETE_SELF   0x00000400
+#define IN_MOVE_SELF     0x00000800
+#define IN_ALL_EVENTS    0x00000fff
+
+#define IN_UNMOUNT       0x00002000
+#define IN_Q_OVERFLOW    0x00004000
+#define IN_IGNORED       0x00008000
+
+#define IN_ONLYDIR       0x01000000
+#define IN_DONT_FOLLOW   0x02000000
+#define IN_MASK_ADD      0x20000000
+
+#define IN_ISDIR         0x40000000
+#define IN_ONESHOT       0x80000000
+
+int inotify_init(void);
+int inotify_init1(int);
+int inotify_add_watch(int, const char *, uint32_t);
+int inotify_rm_watch(int, uint32_t);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/linux/inotify_add_watch.c b/src/linux/inotify_add_watch.c
new file mode 100644 (file)
index 0000000..9973f16
--- /dev/null
@@ -0,0 +1,7 @@
+#include <sys/inotify.h>
+#include "syscall.h"
+
+int inotify_add_watch(int fd, const char *pathname, uint32_t mask)
+{
+       return syscall3(__NR_inotify_add_watch, fd, (long)pathname, mask);
+}
diff --git a/src/linux/inotify_init.c b/src/linux/inotify_init.c
new file mode 100644 (file)
index 0000000..d378460
--- /dev/null
@@ -0,0 +1,7 @@
+#include <sys/inotify.h>
+#include "syscall.h"
+
+int inotify_init()
+{
+       return syscall0(__NR_inotify_init);
+}
diff --git a/src/linux/inotify_init1.c b/src/linux/inotify_init1.c
new file mode 100644 (file)
index 0000000..5fad094
--- /dev/null
@@ -0,0 +1,7 @@
+#include <sys/inotify.h>
+#include "syscall.h"
+
+int inotify_init1(int flags)
+{
+       return syscall1(__NR_inotify_init1, flags);
+}
diff --git a/src/linux/inotify_rm_watch.c b/src/linux/inotify_rm_watch.c
new file mode 100644 (file)
index 0000000..0772d71
--- /dev/null
@@ -0,0 +1,7 @@
+#include <sys/inotify.h>
+#include "syscall.h"
+
+int inotify_rm_watch(int fd, uint32_t wd)
+{
+       return syscall2(__NR_inotify_rm_watch, fd, wd);
+}