diff options
| author | Andrew Lee <alee14498@protonmail.com> | 2021-08-15 00:16:45 -0400 |
|---|---|---|
| committer | Andrew Lee <alee14498@protonmail.com> | 2021-08-15 00:16:45 -0400 |
| commit | 723428bebe3105ad3c3406e416402d1831b482c4 (patch) | |
| tree | ff990e306163515973746ddfb261f29ba8765441 /linux/lib/open.c | |
| download | linux-0.01-distro-723428bebe3105ad3c3406e416402d1831b482c4.tar.gz linux-0.01-distro-723428bebe3105ad3c3406e416402d1831b482c4.tar.bz2 linux-0.01-distro-723428bebe3105ad3c3406e416402d1831b482c4.zip | |
Inital commit
Diffstat (limited to 'linux/lib/open.c')
| -rw-r--r-- | linux/lib/open.c | 19 |
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; +} |
