[git commit] libc/sysdeps: add dup3 syscall wrapper

Mike Frysinger vapier at gentoo.org
Wed Nov 14 05:10:32 UTC 2012


commit: http://git.uclibc.org/uClibc/commit/?id=dbaa240832c159e395e8b3104ecdb551c8f96b5d
branch: http://git.uclibc.org/uClibc/commit/?id=refs/heads/master

Some projects (like udev) are starting to use this.

Signed-off-by: Mike Frysinger <vapier at gentoo.org>
---
 include/unistd.h                      |    6 ++++++
 libc/sysdeps/linux/common/Makefile.in |    1 +
 libc/sysdeps/linux/common/dup3.c      |   13 +++++++++++++
 3 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/include/unistd.h b/include/unistd.h
index aa8e1e6..787f9e5 100644
--- a/include/unistd.h
+++ b/include/unistd.h
@@ -563,6 +563,12 @@ extern int dup (int __fd) __THROW __wur;
 extern int dup2 (int __fd, int __fd2) __THROW;
 libc_hidden_proto(dup2)
 
+#ifdef __USE_GNU
+/* Duplicate FD to FD2, closing FD2 and making it open on the same
+   file while setting flags according to FLAGS.  */
+extern int dup3 (int __fd, int __fd2, int __flags) __THROW;
+#endif
+
 /* NULL-terminated array of "NAME=VALUE" environment variables.  */
 extern char **__environ;
 #ifdef __USE_GNU
diff --git a/libc/sysdeps/linux/common/Makefile.in b/libc/sysdeps/linux/common/Makefile.in
index b40bb78..7a5fb59 100644
--- a/libc/sysdeps/linux/common/Makefile.in
+++ b/libc/sysdeps/linux/common/Makefile.in
@@ -23,6 +23,7 @@ CSRC-$(UCLIBC_LINUX_SPECIFIC) += \
 	bdflush.c \
 	capget.c \
 	capset.c \
+	dup3.c \
 	eventfd.c \
 	inotify.c \
 	ioperm.c \
diff --git a/libc/sysdeps/linux/common/dup3.c b/libc/sysdeps/linux/common/dup3.c
new file mode 100644
index 0000000..539c071
--- /dev/null
+++ b/libc/sysdeps/linux/common/dup3.c
@@ -0,0 +1,13 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * dup2() for uClibc
+ *
+ * Copyright (C) 2000-2006 Erik Andersen <andersen at uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sys/syscall.h>
+#include <unistd.h>
+
+_syscall3(int, dup3, int, oldfd, int, newfd, int, flags)


More information about the uClibc-cvs mailing list