aboutsummaryrefslogtreecommitdiff
path: root/linux/lib/open.c
diff options
context:
space:
mode:
Diffstat (limited to 'linux/lib/open.c')
-rw-r--r--linux/lib/open.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/linux/lib/open.c b/linux/lib/open.c
new file mode 100644
index 0000000..057039c
--- /dev/null
+++ b/linux/lib/open.c
@@ -0,0 +1,19 @@
+#define __LIBRARY__
+#include <unistd.h>
+#include <stdarg.h>
+
+int open(const char * filename, int flag, ...)
+{
+ register int res;
+ va_list arg;
+
+ va_start(arg,flag);
+ __asm__("int $0x80"
+ :"=a" (res)
+ :"0" (__NR_open),"b" (filename),"c" (flag),
+ "d" (va_arg(arg,int)));
+ if (res>=0)
+ return res;
+ errno = -res;
+ return -1;
+}