2004-10-06  Roland McGrath  <roland@redhat.com>

	* desc.c [LINUX] (sys_epoll_create, sys_epoll_ctl, sys_epoll_wait):
	New functions.
	* linux/syscall.h: Declare them.
	* linux/syscallent.h: Use those for epoll_* syscalls.
	* linux/alpha/syscallent.h: Likewise.
	* linux/hppa/syscallent.h: Likewise.
	* linux/ia64/syscallent.h: Likewise.
	* linux/powerpc/syscallent.h: Likewise.
	* linux/s390/syscallent.h: Likewise.
	* linux/s390x/syscallent.h: Likewise.
	* linux/sparc/syscallent.h: Likewise.
	* linux/sparc64/syscallent.h: Likewise.
	* linux/sparc64/syscallent2.h: Likewise.
	* linux/x86_64/syscallent.h: Likewise.
	From Ulrich Drepper <drepper@redhat.com>.
	Fixes RH#134463.
diff --git a/desc.c b/desc.c
index f4e9257..d93952d 100644
--- a/desc.c
+++ b/desc.c
@@ -34,6 +34,10 @@
 
 #include <fcntl.h>
 #include <sys/file.h>
+#ifdef LINUX
+#include <inttypes.h>
+#include <sys/epoll.h>
+#endif
 
 #if HAVE_LONG_LONG_OFF_T
 /*
@@ -549,6 +553,100 @@
 }
 #endif
 
+static struct xlat epollctls[] = {
+	{ EPOLL_CTL_ADD,	"EPOLL_CTL_ADD"	},
+	{ EPOLL_CTL_MOD,	"EPOLL_CTL_MOD"	},
+	{ EPOLL_CTL_DEL,	"EPOLL_CTL_DEL"	},
+	{ 0,			NULL		}
+};
+
+static struct xlat epollevents[] = {
+	{ EPOLLIN,	"EPOLLIN"	},
+	{ EPOLLPRI,	"EPOLLPRI"	},
+	{ EPOLLOUT,	"EPOLLOUT"	},
+	{ EPOLLRDNORM,	"EPOLLRDNORM"	},
+	{ EPOLLRDBAND,	"EPOLLRDBAND"	},
+	{ EPOLLWRNORM,	"EPOLLWRNORM"	},
+	{ EPOLLWRBAND,	"EPOLLWRBAND"	},
+	{ EPOLLMSG,	"EPOLLMSG"	},
+	{ EPOLLERR,	"EPOLLERR"	},
+	{ EPOLLHUP,	"EPOLLHUP"	},
+	{ EPOLLONESHOT,	"EPOLLONESHOT"	},
+	{ EPOLLET,	"EPOLLET"	},
+	{ 0,		NULL		}
+};
+
+int
+sys_epoll_create(tcp)
+struct tcb *tcp;
+{
+	if (entering(tcp))
+		tprintf("%ld", tcp->u_arg[0]);
+	return 0;
+}
+
+static void
+print_epoll_event(ev)
+struct epoll_event *ev;
+{
+	tprintf("{");
+	if (printflags(epollevents, ev->events) == 0)
+		tprintf("0");
+	/* We cannot know what format the program uses, so print u32 and u64
+	   which will cover every value.  */
+	tprintf(", {u32=%" PRIu32 ", u64=%" PRIu64 "}}",
+		ev->data.u32, ev->data.u64);
+}
+
+int
+sys_epoll_ctl(tcp)
+struct tcb *tcp;
+{
+	if (entering(tcp)) {
+		struct epoll_event ev;
+		tprintf("%ld, ", tcp->u_arg[0]);
+                printxval(epollctls, tcp->u_arg[1], "EPOLL_CTL_???");
+		tprintf(", %ld, ", tcp->u_arg[2]);
+		if (tcp->u_arg[3] == 0)
+			tprintf("NULL");
+		else if (umove(tcp, tcp->u_arg[3], &ev) < 0)
+			tprintf("{...}");
+		else
+			print_epoll_event(&ev);
+	}
+	return 0;
+}
+
+int
+sys_epoll_wait(tcp)
+struct tcb *tcp;
+{
+	if (entering(tcp))
+		tprintf("%ld, ", tcp->u_arg[0]);
+	else {
+		if (syserror(tcp))
+			tprintf("%lx", tcp->u_arg[1]);
+		else if (tcp->u_rval == 0)
+			tprintf("{}");
+		else {
+			struct epoll_event evs[tcp->u_rval];
+			if (umove(tcp, tcp->u_arg[1], evs) < 0)
+				tprintf("{...}");
+			else {
+				unsigned long i;
+				tprintf("{");
+				for (i = 0; i < tcp->u_rval; ++i) {
+					if (i > 0)
+						tprintf(", ");
+					print_epoll_event(&evs[i]);
+				}
+				tprintf("}");
+			}
+		}
+		tprintf(", %ld, %ld", tcp->u_arg[2], tcp->u_arg[3]);
+	}
+	return 0;
+}
 #endif /* LINUX */
 
 int
diff --git a/linux/alpha/syscallent.h b/linux/alpha/syscallent.h
index bd9e4ef..2264fc1 100644
--- a/linux/alpha/syscallent.h
+++ b/linux/alpha/syscallent.h
@@ -435,9 +435,9 @@
 	{ 5,	0,	printargs,		"SYS_404"		}, /* 404 */
 	{ 1,	TP,	sys_exit,		"exit_group"		}, /* 405 */
 	{ 4,	0,	printargs,		"lookup_dcookie"	}, /* 406 */
-	{ 1,	0,	printargs,		"epoll_create"		}, /* 407 */
-	{ 4,	0,	printargs,		"epoll_ctl"		}, /* 408 */
-	{ 4,	0,	printargs,		"epoll_wait"		}, /* 409 */
+	{ 1,	0,	sys_epoll_create,	"epoll_create"		}, /* 407 */
+	{ 4,	0,	sys_epoll_ctl,		"epoll_ctl"		}, /* 408 */
+	{ 4,	0,	sys_epoll_wait,		"epoll_wait"		}, /* 409 */
 	{ 5,	0,	sys_remap_file_pages,	"remap_file_pages"	}, /* 410 */
 	{ 1,	0,	printargs,		"set_tid_address"	}, /* 411 */
 	{ 0,	0,	printargs,		"restart_syscall"	}, /* 412 */
diff --git a/linux/hppa/syscallent.h b/linux/hppa/syscallent.h
index 31ade6e..a81f4ca 100644
--- a/linux/hppa/syscallent.h
+++ b/linux/hppa/syscallent.h
@@ -229,9 +229,9 @@
 	{ 1,	0,	printargs,		"free_hugepages"	}, /* 221 */
 	{ 1,	TP,	sys_exit,		"exit_group"		}, /* 222 */
 	{ 4,	0,	printargs,		"lookup_dcookie"	}, /* 223 */
-	{ 1,	0,	printargs,		"epoll_create"		}, /* 224 */
-	{ 4,	0,	printargs,		"epoll_ctl"		}, /* 225 */
-	{ 4,	0,	printargs,		"epoll_wait"		}, /* 226 */
+	{ 1,	0,	sys_epoll_create,	"epoll_create"		}, /* 224 */
+	{ 4,	0,	sys_epoll_ctl,		"epoll_ctl"		}, /* 225 */
+	{ 4,	0,	sys_epoll_wait,		"epoll_wait"		}, /* 226 */
 	{ 5,	0,	printargs,		"remap_file_pages"	}, /* 227 */
 	{ 5,	0,	printargs,		"semtimedop"		}, /* 228 */
 	{ 5,	0,	printargs,		"SYS_229"		}, /* 229 */
diff --git a/linux/ia64/syscallent.h b/linux/ia64/syscallent.h
index 099a398..507b6fa 100644
--- a/linux/ia64/syscallent.h
+++ b/linux/ia64/syscallent.h
@@ -1146,9 +1146,9 @@
 	{ 5,	0,	printargs,		"io_getevents"	}, /* 1240 */
 	{ 3,	0,	printargs,		"io_submit"	}, /* 1241 */
 	{ 3,	0,	printargs,		"io_cancel"	}, /* 1242 */
-	{ 1,	0,	printargs,		"epoll_create"	}, /* 1243 */
-	{ 4,	0,	printargs,		"epoll_ctl"	}, /* 1244 */
-	{ 4,	0,	printargs,		"epoll_wait"	}, /* 1245 */
+	{ 1,	0,	sys_epoll_create,	"epoll_create"	}, /* 1243 */
+	{ 4,	0,	sys_epoll_ctl,		"epoll_ctl"	}, /* 1244 */
+	{ 4,	0,	sys_epoll_wait,		"epoll_wait"	}, /* 1245 */
 	{ 8,	0,	printargs,		"SYS_1246"	}, /* 1246 */
 	{ 8,	0,	printargs,		"SYS_1247"	}, /* 1247 */
 	{ 8,	0,	printargs,		"SYS_1248"	}, /* 1248 */
diff --git a/linux/powerpc/syscallent.h b/linux/powerpc/syscallent.h
index 1e22690..31a3e39 100644
--- a/linux/powerpc/syscallent.h
+++ b/linux/powerpc/syscallent.h
@@ -265,9 +265,9 @@
 	{ 6,	0,	printargs,		"fadvise64"		}, /* 233 */
 	{ 1,	TP,	sys_exit,		"exit_group"		}, /* 234 */
 	{ 4,	0,	printargs,		"lookup_dcookie"	}, /* 235 */
-	{ 1,	0,	printargs,		"epoll_create"		}, /* 236 */
-	{ 4,	0,	printargs,		"epoll_ctl"		}, /* 237 */
-	{ 4,	0,	printargs,		"epoll_wait"		}, /* 238 */
+	{ 1,	0,	sys_epoll_create,	"epoll_create"		}, /* 236 */
+	{ 4,	0,	sys_epoll_ctl,		"epoll_ctl"		}, /* 237 */
+	{ 4,	0,	sys_epoll_wait,		"epoll_wait"		}, /* 238 */
 	{ 5,	0,	sys_remap_file_pages,	"remap_file_pages"	}, /* 239 */
 	{ 3,	0,	sys_timer_create,	"timer_create"		}, /* 240 */
 	{ 4,	0,	sys_timer_settime,	"timer_settime"		}, /* 241 */
diff --git a/linux/s390/syscallent.h b/linux/s390/syscallent.h
index b04c02e..238fec4 100644
--- a/linux/s390/syscallent.h
+++ b/linux/s390/syscallent.h
@@ -277,9 +277,9 @@
 	{ 3,	0,	printargs,		"io_submit"	}, /* 246 */
 	{ 3,	0,	printargs,		"io_cancel"	}, /* 247 */
 	{ 1,	TP,	sys_exit,		"exit_group"	}, /* 248 */
-	{ 1,	0,	printargs,		"epoll_create"	}, /* 249 */
-	{ 4,	0,	printargs,		"epoll_ctl"	}, /* 250 */
-	{ 4,	0,	printargs,		"epoll_wait"	}, /* 251 */
+	{ 1,	0,	sys_epoll_create,	"epoll_create"	}, /* 249 */
+	{ 4,	0,	sys_epoll_ctl,		"epoll_ctl"	}, /* 250 */
+	{ 4,	0,	sys_epoll_wait,		"epoll_wait"	}, /* 251 */
 	{ 1,	0,	printargs,		"set_tid_address"}, /* 252 */
 	{ 5,	0,	printargs,		"fadvise64"	}, /* 253 */
 	{ 3,	0,	sys_timer_create,	"timer_create"	}, /* 254 */
diff --git a/linux/s390x/syscallent.h b/linux/s390x/syscallent.h
index f56f232..438a39c 100644
--- a/linux/s390x/syscallent.h
+++ b/linux/s390x/syscallent.h
@@ -276,9 +276,9 @@
 	{ 3,	0,	printargs,		"io_submit"	}, /* 246 */
 	{ 3,	0,	printargs,		"io_cancel"	}, /* 247 */
 	{ 1,	TP,	sys_exit,		"exit_group"	}, /* 248 */
-	{ 1,	0,	printargs,		"epoll_create"	}, /* 249 */
-	{ 4,	0,	printargs,		"epoll_ctl"	}, /* 250 */
-	{ 4,	0,	printargs,		"epoll_wait"	}, /* 251 */
+	{ 1,	0,	sys_epoll_create,	"epoll_create"	}, /* 249 */
+	{ 4,	0,	sys_epoll_ctl,		"epoll_ctl"	}, /* 250 */
+	{ 4,	0,	sys_epoll_wait,		"epoll_wait"	}, /* 251 */
 	{ 1,	0,	printargs,		"set_tid_address"}, /* 252 */
 	{ 5,	0,	printargs,		"fadvise64"	}, /* 253 */
 	{ 3,	0,	sys_timer_create,	"timer_create"	}, /* 254 */
diff --git a/linux/sparc/syscallent.h b/linux/sparc/syscallent.h
index 8e1555f..2872946 100644
--- a/linux/sparc/syscallent.h
+++ b/linux/sparc/syscallent.h
@@ -191,9 +191,9 @@
 	{ 2,	0,	sys_init_module,"init_module" },	/* 190 */
 	{ 1,	0,	sys_personality,"personality" },	/* 191 */
 	{ 5,	0,	sys_remap_file_pages,"remap_file_pages" },/* 192 */
-	{ 1,	0,	printargs,	"epoll_create" },		/* 193 */
-	{ 4,	0,	printargs,	"epoll_ctl" },		/* 194 */
-	{ 4,	0,	printargs,	"epoll_wait" },		/* 195 */
+	{ 1,	0,	sys_epoll_create,"epoll_create" },	/* 193 */
+	{ 4,	0,	sys_epoll_ctl,	"epoll_ctl" },		/* 194 */
+	{ 4,	0,	sys_epoll_wait,	"epoll_wait" },		/* 195 */
 	{ 2,	0,	sys_ulimit,	"ulimit" },		/* 196 */
 	{ 0,	0,	sys_getppid,	"getppid" },		/* 197 */
 	{ 3,	TS,	sys_sigaction,	"sigaction" },		/* 198 */
diff --git a/linux/sparc64/syscallent.h b/linux/sparc64/syscallent.h
index 8e1555f..2872946 100644
--- a/linux/sparc64/syscallent.h
+++ b/linux/sparc64/syscallent.h
@@ -191,9 +191,9 @@
 	{ 2,	0,	sys_init_module,"init_module" },	/* 190 */
 	{ 1,	0,	sys_personality,"personality" },	/* 191 */
 	{ 5,	0,	sys_remap_file_pages,"remap_file_pages" },/* 192 */
-	{ 1,	0,	printargs,	"epoll_create" },		/* 193 */
-	{ 4,	0,	printargs,	"epoll_ctl" },		/* 194 */
-	{ 4,	0,	printargs,	"epoll_wait" },		/* 195 */
+	{ 1,	0,	sys_epoll_create,"epoll_create" },	/* 193 */
+	{ 4,	0,	sys_epoll_ctl,	"epoll_ctl" },		/* 194 */
+	{ 4,	0,	sys_epoll_wait,	"epoll_wait" },		/* 195 */
 	{ 2,	0,	sys_ulimit,	"ulimit" },		/* 196 */
 	{ 0,	0,	sys_getppid,	"getppid" },		/* 197 */
 	{ 3,	TS,	sys_sigaction,	"sigaction" },		/* 198 */
diff --git a/linux/sparc64/syscallent2.h b/linux/sparc64/syscallent2.h
index 8e1555f..2872946 100644
--- a/linux/sparc64/syscallent2.h
+++ b/linux/sparc64/syscallent2.h
@@ -191,9 +191,9 @@
 	{ 2,	0,	sys_init_module,"init_module" },	/* 190 */
 	{ 1,	0,	sys_personality,"personality" },	/* 191 */
 	{ 5,	0,	sys_remap_file_pages,"remap_file_pages" },/* 192 */
-	{ 1,	0,	printargs,	"epoll_create" },		/* 193 */
-	{ 4,	0,	printargs,	"epoll_ctl" },		/* 194 */
-	{ 4,	0,	printargs,	"epoll_wait" },		/* 195 */
+	{ 1,	0,	sys_epoll_create,"epoll_create" },	/* 193 */
+	{ 4,	0,	sys_epoll_ctl,	"epoll_ctl" },		/* 194 */
+	{ 4,	0,	sys_epoll_wait,	"epoll_wait" },		/* 195 */
 	{ 2,	0,	sys_ulimit,	"ulimit" },		/* 196 */
 	{ 0,	0,	sys_getppid,	"getppid" },		/* 197 */
 	{ 3,	TS,	sys_sigaction,	"sigaction" },		/* 198 */
diff --git a/linux/syscall.h b/linux/syscall.h
index 13326cf..0afdc70 100644
--- a/linux/syscall.h
+++ b/linux/syscall.h
@@ -96,6 +96,7 @@
 int sys_semtimedop(), sys_statfs64(), sys_fstatfs64(), sys_tgkill();
 int sys_mq_open(), sys_mq_timedsend(), sys_mq_timedreceive();
 int sys_mq_notify(), sys_mq_getsetattr();
+int sys_epoll_create(), sys_epoll_ctl(), sys_epoll_wait();
 int sys_waitid();
 
 /* sys_socketcall subcalls */
diff --git a/linux/syscallent.h b/linux/syscallent.h
index 67fcfa2..7fcaf6d 100644
--- a/linux/syscallent.h
+++ b/linux/syscallent.h
@@ -300,9 +300,9 @@
 	{ 5,	0,	printargs,		"SYS_251"	}, /* 251 */
 	{ 1,	TP,	sys_exit,		"exit_group"	}, /* 252 */
 	{ 4,	0,	printargs,		"lookup_dcookie"}, /* 253 */
-	{ 1,	0,	printargs,		"epoll_create"	}, /* 254 */
-	{ 4,	0,	printargs,		"epoll_ctl"	}, /* 255 */
-	{ 4,	0,	printargs,		"epoll_wait"	}, /* 256 */
+	{ 1,	0,	sys_epoll_create,	"epoll_create"	}, /* 254 */
+	{ 4,	0,	sys_epoll_ctl,		"epoll_ctl"	}, /* 255 */
+	{ 4,	0,	sys_epoll_wait,		"epoll_wait"	}, /* 256 */
 	{ 5,	0,	sys_remap_file_pages,	"remap_file_pages"}, /* 257 */
 	{ 1,	0,	printargs,		"set_tid_address"}, /* 258 */
 	{ 3,	0,	sys_timer_create,	"timer_create"	}, /* 259 */
diff --git a/linux/x86_64/syscallent.h b/linux/x86_64/syscallent.h
index 9c1deec..87ee170 100644
--- a/linux/x86_64/syscallent.h
+++ b/linux/x86_64/syscallent.h
@@ -211,9 +211,9 @@
 	{ 3,	0,	printargs,		"io_cancel"	}, /* 210 */
 	{ 1,	0,	sys_get_thread_area,	"get_thread_area" }, /* 211 */
 	{ 4,	0,	printargs,		"lookup_dcookie"}, /* 212 */
-	{ 1,	0,	printargs,		"epoll_create"	}, /* 213 */
-	{ 4,	0,	printargs,		"epoll_ctl"	}, /* 214 */
-	{ 4,	0,	printargs,		"epoll_wait"	}, /* 215 */
+	{ 1,	0,	sys_epoll_create,	"epoll_create"	}, /* 213 */
+	{ 4,	0,	printargs,		"epoll_ctl_old"	}, /* 214 */
+	{ 4,	0,	printargs,		"epoll_wait_old"}, /* 215 */
 	{ 5,	0,	sys_remap_file_pages,	"remap_file_pages"}, /* 216 */
 	{ 4,	0,	sys_getdents64,		"getdents64"	}, /* 217 */
 	{ 5,	0,	printargs,		"SYS_218"	}, /* 218 */
@@ -244,8 +244,8 @@
 	{ 2,	0,	sys_clock_getres,	"clock_getres"	}, /* 229 */
 	{ 4,	0,	sys_clock_nanosleep,	"clock_nanosleep"}, /* 230 */
 	{ 5,	0,	printargs,		"exit_group"	}, /* 231 */
-	{ 5,	0,	printargs,		"epoll_wait"	}, /* 232 */
-	{ 5,	0,	printargs,		"epoll_ctl"	}, /* 233 */
+	{ 5,	0,	sys_epoll_wait,		"epoll_wait"	}, /* 232 */
+	{ 5,	0,	sys_epoll_ctl,		"epoll_ctl"	}, /* 233 */
 	{ 5,	0,	printargs,		"tgkill"	}, /* 234 */
 	{ 5,	0,	printargs,		"utimes"	}, /* 235 */
 	{ 5,	0,	printargs,		"vserver"	}, /* 236 */