2008-10-23  Dmitry V. Levin  <ldv@altlinux.org>

	Implement parsers for new linux syscalls.
	* desc.c (do_dup2, [LINUX] sys_dup3): New functions.
	(sys_dup2): Use do_dup2.
	[LINUX] (sys_epoll_create1): New function.
	[LINUX] (do_eventfd, sys_eventfd2): New functions.
	[LINUX] (sys_eventfd): Use do_eventfd.
	* net.c (do_pipe, [LINUX] sys_pipe2): New functions.
	(sys_pipe): Use do_pipe.
	* signal.c [LINUX] (do_signalfd, sys_signalfd4): New functions.
	[LINUX] (sys_signalfd): Use do_signalfd.
	* linux/syscall.h: Declare new sys_* functions.
	* linux/syscallent.h: Hook up signalfd4, eventfd2, epoll_create1,
	dup3, pipe2, inotify_init1.
	* linux/x86_64/syscallent.h: Hook up paccept, signalfd4, eventfd2,
	epoll_create1, dup3, pipe2, inotify_init1.
diff --git a/desc.c b/desc.c
index 951ccf9..379950b 100644
--- a/desc.c
+++ b/desc.c
@@ -242,6 +242,8 @@
 }
 #endif
 
+extern const struct xlat open_mode_flags[];
+
 /*
  * low bits of the open(2) flags define access mode,
  * other bits are real flags.
@@ -250,7 +252,6 @@
 sprint_open_modes(mode_t flags)
 {
 	extern const struct xlat open_access_modes[];
-	extern const struct xlat open_mode_flags[];
 	static char outstr[1024];
 	const char *str = xlookup(open_access_modes, flags & 3);
 	const char *sep = "";
@@ -396,16 +397,33 @@
 	return 0;
 }
 
-int
-sys_dup2(tcp)
-struct tcb *tcp;
+static int
+do_dup2(struct tcb *tcp, int flags_arg)
 {
 	if (entering(tcp)) {
 		tprintf("%ld, %ld", tcp->u_arg[0], tcp->u_arg[1]);
+		if (flags_arg >= 0) {
+			tprintf(", ");
+			printflags(open_mode_flags, tcp->u_arg[flags_arg], "O_???");
+		}
 	}
 	return 0;
 }
 
+int
+sys_dup2(struct tcb *tcp)
+{
+	return do_dup2(tcp, -1);
+}
+
+#ifdef LINUX
+int
+sys_dup3(struct tcb *tcp)
+{
+	return do_dup2(tcp, 2);
+}
+#endif
+
 #if defined(ALPHA) || defined(FREEBSD) || defined(SUNOS4)
 int
 sys_getdtablesize(tcp)
@@ -605,14 +623,21 @@
 };
 
 int
-sys_epoll_create(tcp)
-struct tcb *tcp;
+sys_epoll_create(struct tcb *tcp)
 {
 	if (entering(tcp))
 		tprintf("%ld", tcp->u_arg[0]);
 	return 0;
 }
 
+int
+sys_epoll_create1(struct tcb *tcp)
+{
+	if (entering(tcp))
+		printflags(open_mode_flags, tcp->u_arg[0], "O_???");
+	return 0;
+}
+
 #ifdef HAVE_SYS_EPOLL_H
 static void
 print_epoll_event(ev)
@@ -889,12 +914,28 @@
 	return rc;
 }
 
-int
-sys_eventfd(tcp)
-struct tcb *tcp;
+static int
+do_eventfd(struct tcb *tcp, int flags_arg)
 {
-	if (entering(tcp))
+	if (entering(tcp)) {
 		tprintf("%lu", tcp->u_arg[0]);
+		if (flags_arg >= 0) {
+			tprintf(", ");
+			printflags(open_mode_flags, tcp->u_arg[flags_arg], "O_???");
+		}
+	}
 	return 0;
 }
+
+int
+sys_eventfd(struct tcb *tcp)
+{
+	return do_eventfd(tcp, -1);
+}
+
+int
+sys_eventfd2(struct tcb *tcp)
+{
+	return do_eventfd(tcp, 1);
+}
 #endif