[PATCH] O_CLOEXEC and epoll_create1()

Tilman Sauerbeck <[email protected]>
Newsgroups gmane.linux.lib.dietlibc
Message-ID <[email protected]>
Hi,
I patched dietlibc to a) support the O_CLOEXEC flag and b) to support
the epoll_create1() call. The diffs are available at
http://files.code-monkey.de/dietlibc/o_cloexec.diff and
http://files.code-monkey.de/dietlibc/epoll_create1.diff.

Both patches were tested on x86 only. Feedback welcome.

Regards,
Tilman

-- 
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?

Index: include/fcntl.h
===================================================================
RCS file: /cvs/dietlibc/include/fcntl.h,v
retrieving revision 1.24
diff -u -p -r1.24 fcntl.h
--- include/fcntl.h	19 Jan 2010 20:38:56 -0000	1.24
+++ include/fcntl.h	27 Mar 2010 09:17:43 -0000
@@ -34,6 +34,7 @@ __BEGIN_DECLS
 #define O_DIRECTORY	0200000	/* must be a directory */
 #define O_NOFOLLOW	0400000 /* don't follow links */
 #define O_NOATIME	01000000
+#define O_CLOEXEC	02000000 /* set close_on_exec */
 
 #define F_DUPFD		0	/* dup */
 #define F_GETFD		1	/* get close_on_exec */
@@ -117,6 +118,7 @@ struct flock64 {
 #define O_LARGEFILE	0400000 /* will be set by the kernel on every open */
 #define O_DIRECT	02000000	/* direct disk access - should check with OSF/1 */
 #define O_NOATIME	04000000
+#define O_CLOEXEC	010000000 /* set close_on_exec */
 
 #define F_DUPFD		0	/* dup */
 #define F_GETFD		1	/* get close_on_exec */
@@ -186,6 +188,7 @@ struct flock {
 #define O_DIRECTORY	0x10000	/* must be a directory */
 #define O_NOFOLLOW	0x20000	/* don't follow links */
 #define O_NOATIME	0x40000
+#define O_CLOEXEC	0x80000 /* set close_on_exec */
 
 #define O_NDELAY	O_NONBLOCK
 
@@ -286,6 +289,7 @@ struct flock {
 #define O_LARGEFILE	0x40000
 #define O_DIRECT        0x100000 /* direct disk access hint */
 #define O_NOATIME	0x200000
+#define O_CLOEXEC	0x400000 /* set close_on_exec */
 
 #define F_DUPFD		0	/* dup */
 #define F_GETFD		1	/* get close_on_exec */
@@ -375,6 +379,7 @@ struct flock64 {
 #define O_LARGEFILE     0200000
 #define O_DIRECT	0400000	/* direct disk access hint - currently ignored */
 #define O_NOATIME	01000000
+#define O_CLOEXEC	02000000 /* set close_on_exec */
 
 #define F_DUPFD		0	/* dup */
 #define F_GETFD		1	/* get close_on_exec */
@@ -459,6 +464,7 @@ struct flock64 {
 #define O_DIRECT	0200000	/* direct disk access hint - currently ignored */
 #define O_LARGEFILE	0400000
 #define O_NOATIME	01000000
+#define O_CLOEXEC	02000000 /* set close_on_exec */
 
 #define F_DUPFD		0	/* dup */
 #define F_GETFD		1	/* get close_on_exec */
@@ -544,6 +550,7 @@ struct flock64 {
 #define O_RSYNC     02000000 /* HPUX only */
 #define O_NOATIME   04000000
 #define O_DIRECTORY  00010000
+#define O_CLOEXEC	010000000 /* set close_on_exec */
 
 #define O_DIRECT    00040000 /* direct disk access hint - currently ignored */
 #define O_NOFOLLOW  00000200 /* don't follow links */

Index: arm/dyn_syscalls.S
===================================================================
RCS file: /cvs/dietlibc/arm/dyn_syscalls.S,v
retrieving revision 1.31
diff -u -p -r1.31 dyn_syscalls.S
--- arm/dyn_syscalls.S	7 Jul 2008 12:31:53 -0000	1.31
+++ arm/dyn_syscalls.S	27 Mar 2010 14:59:58 -0000
@@ -205,6 +205,7 @@ __unified_syscall:
 #include "../syscalls.s/truncate64.S"
 #include "../syscalls.s/ustat.S"
 #include "../syscalls.s/epoll_create.S"
+#include "../syscalls.s/epoll_create1.S"
 #include "../syscalls.s/epoll_ctl.S"
 #include "../syscalls.s/epoll_wait.S"
 #include "../syscalls.s/fcntl64.S"
Index: arm/syscalls.h
===================================================================
RCS file: /cvs/dietlibc/arm/syscalls.h,v
retrieving revision 1.18
diff -u -p -r1.18 syscalls.h
--- arm/syscalls.h	30 Sep 2008 21:02:35 -0000	1.18
+++ arm/syscalls.h	27 Mar 2010 14:59:58 -0000
@@ -365,6 +365,7 @@
 #define __NR_fallocate			(__NR_SYSCALL_BASE+352)
 #define __NR_timerfd_settime		(__NR_SYSCALL_BASE+353)
 #define __NR_timerfd_gettime		(__NR_SYSCALL_BASE+354)
+#define __NR_epoll_create1		(__NR_SYSCALL_BASE+357)
 
 /*
  * The following SWIs are ARM private.
Index: i386/dyn_syscalls.S
===================================================================
RCS file: /cvs/dietlibc/i386/dyn_syscalls.S,v
retrieving revision 1.41
diff -u -p -r1.41 dyn_syscalls.S
--- i386/dyn_syscalls.S	27 Dec 2008 19:53:16 -0000	1.41
+++ i386/dyn_syscalls.S	27 Mar 2010 14:59:58 -0000
@@ -273,6 +273,7 @@ __unified_syscall:
 #include "../syscalls.s/truncate64.S"
 #include "../syscalls.s/ftruncate64.S"
 #include "../syscalls.s/epoll_create.S"
+#include "../syscalls.s/epoll_create1.S"
 #include "../syscalls.s/epoll_ctl.S"
 #include "../syscalls.s/epoll_wait.S"
 #include "../syscalls.s/sendfile64.S"
Index: ia64/syscalls.h
===================================================================
RCS file: /cvs/dietlibc/ia64/syscalls.h,v
retrieving revision 1.10
diff -u -p -r1.10 syscalls.h
--- ia64/syscalls.h	30 Sep 2008 21:02:35 -0000	1.10
+++ ia64/syscalls.h	27 Mar 2010 14:59:58 -0000
@@ -289,6 +289,7 @@
 #define __NR_timerfd_create		1310
 #define __NR_timerfd_settime		1311
 #define __NR_timerfd_gettime		1312
+#define __NR_epoll_create1		1315
 
 #define syscall(name, sym) \
 .text; \
Index: include/sys/epoll.h
===================================================================
RCS file: /cvs/dietlibc/include/sys/epoll.h,v
retrieving revision 1.11
diff -u -p -r1.11 epoll.h
--- include/sys/epoll.h	20 Feb 2008 00:45:12 -0000	1.11
+++ include/sys/epoll.h	27 Mar 2010 14:59:58 -0000
@@ -46,6 +46,9 @@ enum EPOLL_EVENTS {
 #define EPOLLET EPOLLET
 };
 
+/* Flags used in epoll_create1() */
+#define EPOLL_CLOEXEC	O_CLOEXEC
+
 typedef union epoll_data {
   void *ptr;
   int fd;
@@ -63,6 +66,7 @@ __attribute__((__packed__))
 ;
 
 int epoll_create(int size) __THROW;
+int epoll_create1(int flags) __THROW;
 int epoll_ctl(int epfd, int op, int fd, struct epoll_event* event) __THROW;
 int epoll_wait(int epfd, struct epoll_event *events, int maxevents,
 	       int timeout) __THROW;
Index: mips/syscalls.h
===================================================================
RCS file: /cvs/dietlibc/mips/syscalls.h,v
retrieving revision 1.9
diff -u -p -r1.9 syscalls.h
--- mips/syscalls.h	30 Sep 2008 21:02:35 -0000	1.9
+++ mips/syscalls.h	27 Mar 2010 14:59:58 -0000
@@ -327,6 +327,7 @@
 #define __NR_timerfd_create		(__NR_Linux + 284)
 #define __NR_timerfd_gettime		(__NR_Linux + 285)
 #define __NR_timerfd_settime		(__NR_Linux + 286)
+#define __NR_epoll_create		(__NR_Linux + 289)
 
 #define syscall_weak(name,wsym,sym) \
 .text; \
Index: parisc/syscalls.h
===================================================================
RCS file: /cvs/dietlibc/parisc/syscalls.h,v
retrieving revision 1.8
diff -u -p -r1.8 syscalls.h
--- parisc/syscalls.h	30 Sep 2008 21:02:35 -0000	1.8
+++ parisc/syscalls.h	27 Mar 2010 14:59:58 -0000
@@ -323,6 +323,7 @@
 #define __NR_timerfd_create	(__NR_Linux + 306)
 #define __NR_timerfd_settime	(__NR_Linux + 307)
 #define __NR_timerfd_gettime	(__NR_Linux + 308)
+#define __NR_epoll_create1       (__NR_Linux + 311)
 
 #define __NR_Linux_syscalls	(__NR_fallocate + 1)
 
Index: ppc/syscalls.h
===================================================================
RCS file: /cvs/dietlibc/ppc/syscalls.h,v
retrieving revision 1.9
diff -u -p -r1.9 syscalls.h
--- ppc/syscalls.h	30 Sep 2008 21:02:35 -0000	1.9
+++ ppc/syscalls.h	27 Mar 2010 14:59:58 -0000
@@ -311,6 +311,7 @@
 #define __NR_subpage_prot	310
 #define __NR_timerfd_settime	311
 #define __NR_timerfd_gettime	312
+#define __NR_epoll_create1	315
 
 
 #define syscall_weak(name,wsym,sym) \
Index: ppc64/syscalls.h
===================================================================
RCS file: /cvs/dietlibc/ppc64/syscalls.h,v
retrieving revision 1.7
diff -u -p -r1.7 syscalls.h
--- ppc64/syscalls.h	30 Sep 2008 21:02:35 -0000	1.7
+++ ppc64/syscalls.h	27 Mar 2010 14:59:58 -0000
@@ -311,6 +311,7 @@
 #define __NR_subpage_prot	310
 #define __NR_timerfd_settime	311
 #define __NR_timerfd_gettime	312
+#define __NR_epoll_create1	315
 
 
 #define __diet_proto_common(sym) \
Index: s390/syscalls.h
===================================================================
RCS file: /cvs/dietlibc/s390/syscalls.h,v
retrieving revision 1.10
diff -u -p -r1.10 syscalls.h
--- s390/syscalls.h	30 Sep 2008 21:02:35 -0000	1.10
+++ s390/syscalls.h	27 Mar 2010 14:59:58 -0000
@@ -305,6 +305,7 @@
 #define __NR_timerfd_create	319
 #define __NR_timerfd_settime	320
 #define __NR_timerfd_gettime	321
+#define __NR_epoll_create	327
 
 
 #define syscall_weak(name,wsym,sym) \
Index: s390x/syscalls.h
===================================================================
RCS file: /cvs/dietlibc/s390x/syscalls.h,v
retrieving revision 1.8
diff -u -p -r1.8 syscalls.h
--- s390x/syscalls.h	30 Sep 2008 21:02:35 -0000	1.8
+++ s390x/syscalls.h	27 Mar 2010 14:59:58 -0000
@@ -305,6 +305,7 @@
 #define __NR_timerfd_create	319
 #define __NR_timerfd_settime	320
 #define __NR_timerfd_gettime	321
+#define __NR_epoll_create1	327
 
 
 /* 
Index: sparc/syscalls.h
===================================================================
RCS file: /cvs/dietlibc/sparc/syscalls.h,v
retrieving revision 1.10
diff -u -p -r1.10 syscalls.h
--- sparc/syscalls.h	30 Sep 2008 21:02:35 -0000	1.10
+++ sparc/syscalls.h	27 Mar 2010 14:59:58 -0000
@@ -315,6 +315,7 @@
 #define __NR_fallocate		314
 #define __NR_timerfd_settime	315
 #define __NR_timerfd_gettime	316
+#define __NR_epoll_create1	319
 
 #define syscall_weak(name,wsym,sym) \
 .text; \
Index: sparc64/syscalls.h
===================================================================
RCS file: /cvs/dietlibc/sparc64/syscalls.h,v
retrieving revision 1.5
diff -u -p -r1.5 syscalls.h
--- sparc64/syscalls.h	30 Sep 2008 21:02:35 -0000	1.5
+++ sparc64/syscalls.h	27 Mar 2010 14:59:58 -0000
@@ -314,6 +314,7 @@
 #define __NR_fallocate		314
 #define __NR_timerfd_settime	315
 #define __NR_timerfd_gettime	316
+#define __NR_epoll_create1	319
 
 #define syscall_weak(name,wsym,sym) \
 .text; \
Index: syscalls.s/epoll_create1.S
===================================================================
RCS file: syscalls.s/epoll_create1.S
diff -N syscalls.s/epoll_create1.S
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ syscalls.s/epoll_create1.S	27 Mar 2010 14:59:58 -0000
@@ -0,0 +1,5 @@
+#include "syscalls.h"
+
+#ifdef __NR_epoll_create1
+syscall(epoll_create1,epoll_create1)
+#endif
Index: x86_64/dyn_syscalls.S
===================================================================
RCS file: /cvs/dietlibc/x86_64/dyn_syscalls.S,v
retrieving revision 1.6
diff -u -p -r1.6 dyn_syscalls.S
--- x86_64/dyn_syscalls.S	27 Dec 2008 19:53:16 -0000	1.6
+++ x86_64/dyn_syscalls.S	27 Mar 2010 14:59:58 -0000
@@ -64,6 +64,7 @@ _unified_syscall:
 #include "../syscalls.s/dup2.S"
 #include "../syscalls.s/environ.S"
 #include "../syscalls.s/epoll_create.S"
+#include "../syscalls.s/epoll_create1.S"
 #include "../syscalls.s/epoll_ctl.S"
 #include "../syscalls.s/epoll_wait.S"
 #include "../syscalls.s/errno.S"




----- End forwarded message -----
Regards,
Tilman

-- 
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.