]> Zhao Yanbai Git Server - minix.git/commitdiff
added missing m_closefrom.c
authorBen Gras <ben@minix3.org>
Wed, 3 Aug 2011 10:51:28 +0000 (12:51 +0200)
committerBen Gras <ben@minix3.org>
Wed, 3 Aug 2011 10:51:28 +0000 (12:51 +0200)
lib/nbsd_libc/sys-minix/m_closefrom.c [new file with mode: 0644]

diff --git a/lib/nbsd_libc/sys-minix/m_closefrom.c b/lib/nbsd_libc/sys-minix/m_closefrom.c
new file mode 100644 (file)
index 0000000..962e84a
--- /dev/null
@@ -0,0 +1,23 @@
+#include <sys/cdefs.h>
+#include "namespace.h"
+#include <lib.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+PUBLIC int closefrom(int fd)
+{
+       int f, ok = 0, e;
+       for(f = fd; f < __MINIX_OPEN_MAX; f++) {
+               if(close(f) >= 0)
+                       ok = 1;
+               else
+                       e = errno;
+       }
+
+       if(ok)
+               return 0;
+
+       /* all failed - return last valid error */
+       errno = e;
+       return -1;
+}