[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [torsocks/master] Add support for the various inotify routines when invoked via syscall().
commit 824d88b9e47f8e2f3e5a3158f440154a04c2eb55
Author: Yawning Angel <yawning@xxxxxxxxxxxxxxx>
Date: Tue Apr 7 11:37:41 2015 +0000
Add support for the various inotify routines when invoked via syscall().
Signed-off-by: Yawning Angel <yawning@xxxxxxxxxxxxxxx>
---
src/common/compat.h | 13 +++++++++++++
src/lib/syscall.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 62 insertions(+)
diff --git a/src/common/compat.h b/src/common/compat.h
index 187818c..e7e5812 100644
--- a/src/common/compat.h
+++ b/src/common/compat.h
@@ -119,6 +119,7 @@ void tsocks_mutex_unlock(tsocks_mutex_t *m);
#include <sys/epoll.h>
#include <sys/eventfd.h>
+#include <sys/inotify.h>
#ifndef __NR_epoll_create1
#define __NR_epoll_create1 -128
@@ -135,12 +136,24 @@ void tsocks_mutex_unlock(tsocks_mutex_t *m);
#ifndef __NR_eventfd2
#define __NR_eventfd2 -132
#endif
+#ifndef __NR_inotify_init1
+#define __NR_inotify_init1 -133
+#endif
+#ifndef __NR_inotify_add_watch
+#define __NR_inotify_add_watch -134
+#endif
+#ifndef __NR_inotify_rm_watch
+#define __NR_inotify_rm_watch -135
+#endif
#define TSOCKS_NR_EPOLL_CREATE1 __NR_epoll_create1
#define TSOCKS_NR_EPOLL_WAIT __NR_epoll_wait
#define TSOCKS_NR_EPOLL_PWAIT __NR_epoll_pwait
#define TSOCKS_NR_EPOLL_CTL __NR_epoll_ctl
#define TSOCKS_NR_EVENTFD2 __NR_eventfd2
+#define TSOCKS_NR_INOTIFY_INIT1 __NR_inotify_init1
+#define TSOCKS_NR_INOTIFY_ADD_WATCH __NR_inotify_add_watch
+#define TSOCKS_NR_INOTIFY_RM_WATCH __NR_inotify_rm_watch
#endif /* __linux__ */
diff --git a/src/lib/syscall.c b/src/lib/syscall.c
index 55e2447..c3bbd56 100644
--- a/src/lib/syscall.c
+++ b/src/lib/syscall.c
@@ -312,6 +312,46 @@ static LIBC_SYSCALL_RET_TYPE handle_eventfd2(va_list args)
return eventfd(initval, flags);
}
+
+/*
+ * Handle inotify_init1(2) syscall.
+ */
+static LIBC_SYSCALL_RET_TYPE handle_inotify_init1(va_list args)
+{
+ int flags;
+ flags = va_arg(args, __typeof__(flags));
+
+ return inotify_init1(flags);
+}
+
+/*
+ * Handle inotify_add_watch(2) syscall.
+ */
+static LIBC_SYSCALL_RET_TYPE handle_inotify_add_watch(va_list args)
+{
+ int fd;
+ const char *pathname;
+ uint32_t mask;
+
+ fd = va_arg(args, __typeof__(fd));
+ pathname = va_arg(args, __typeof__(pathname));
+ mask = va_arg(args, __typeof__(mask));
+
+ return inotify_add_watch(fd, pathname, mask);
+}
+
+/*
+ * Handle inotify_rm_watch(2) syscall.
+ */
+static LIBC_SYSCALL_RET_TYPE handle_inotify_rm_watch(va_list args)
+{
+ int fd, wd;
+
+ fd = va_arg(args, __typeof__(fd));
+ wd = va_arg(args, __typeof__(wd));
+
+ return inotify_rm_watch(fd, wd);
+}
#endif /* __linux__ */
/*
@@ -406,6 +446,15 @@ LIBC_SYSCALL_RET_TYPE tsocks_syscall(long int number, va_list args)
case TSOCKS_NR_EVENTFD2:
ret = handle_eventfd2(args);
break;
+ case TSOCKS_NR_INOTIFY_INIT1:
+ ret = handle_inotify_init1(args);
+ break;
+ case TSOCKS_NR_INOTIFY_ADD_WATCH:
+ ret = handle_inotify_add_watch(args);
+ break;
+ case TSOCKS_NR_INOTIFY_RM_WATCH:
+ ret = handle_inotify_rm_watch(args);
+ break;
#endif /* __linux__ */
default:
/*
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits