From 21d3776ce2b28b1bf89fd758507aeea59b97bd54 Mon Sep 17 00:00:00 2001 From: pumnflqv2 Date: Sun, 26 Jun 2022 22:42:53 +0800 Subject: [PATCH] ADD file via upload --- lib/open.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 lib/open.c diff --git a/lib/open.c b/lib/open.c new file mode 100644 index 0000000..8c3fc58 --- /dev/null +++ b/lib/open.c @@ -0,0 +1,25 @@ +/* + * linux/lib/open.c + * + * (C) 1991 Linus Torvalds + */ + +#define __LIBRARY__ +#include +#include + +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; +}