diff --git a/libc/include/open.h b/libc/include/open.h index 459dfb434f968d6a77e8f4f990ba2c8b7e838fac..72d53d6093b1c1ec850e02c6c64b973b84233eac 100644 --- a/libc/include/open.h +++ b/libc/include/open.h @@ -23,7 +23,70 @@ #include <stdint.h> -int open(char *file, int mode); +/* open/fcntl. */ +#define O_ACCMODE 0003 +#define O_RDONLY 00 +#define O_WRONLY 01 +#define O_RDWR 02 +#ifndef O_CREAT +# define O_CREAT 0100 /* Not fcntl. */ +#endif +#ifndef O_EXCL +# define O_EXCL 0200 /* Not fcntl. */ +#endif +#ifndef O_NOCTTY +# define O_NOCTTY 0400 /* Not fcntl. */ +#endif +#ifndef O_TRUNC +# define O_TRUNC 01000 /* Not fcntl. */ +#endif +#ifndef O_APPEND +# define O_APPEND 02000 +#endif +#ifndef O_NONBLOCK +# define O_NONBLOCK 04000 +#endif +#ifndef O_NDELAY +# define O_NDELAY O_NONBLOCK +#endif +#ifndef O_SYNC +# define O_SYNC 04010000 +#endif +#define O_FSYNC O_SYNC +#ifndef O_ASYNC +# define O_ASYNC 020000 +#endif + +/* Protection bits. */ + +#define __S_ISUID 04000 /* Set user ID on execution. */ +#define __S_ISGID 02000 /* Set group ID on execution. */ +#define __S_ISVTX 01000 /* Save swapped text after use (sticky). */ +#define __S_IREAD 0400 /* Read by owner. */ +#define __S_IWRITE 0200 /* Write by owner. */ +#define __S_IEXEC 0100 /* Execute by owner. */ + + +# define S_IRUSR __S_IREAD /* Read by owner. */ +# define S_IWUSR __S_IWRITE /* Write by owner. */ +# define S_IXUSR __S_IEXEC /* Execute by owner. */ +/* Read, write, and execute by owner. */ +# define S_IRWXU (__S_IREAD|__S_IWRITE|__S_IEXEC) + +# define S_IRGRP (S_IRUSR >> 3) /* Read by group. */ +# define S_IWGRP (S_IWUSR >> 3) /* Write by group. */ +# define S_IXGRP (S_IXUSR >> 3) /* Execute by group. */ +/* Read, write, and execute by group. */ +# define S_IRWXG (S_IRWXU >> 3) + +# define S_IROTH (S_IRGRP >> 3) /* Read by others. */ +# define S_IWOTH (S_IWGRP >> 3) /* Write by others. */ +# define S_IXOTH (S_IXGRP >> 3) /* Execute by others. */ +/* Read, write, and execute by others. */ +# define S_IRWXO (S_IRWXG >> 3) + +//int open(char *file, int flags, ...); +int open(char *file, int flags, int mode); #endif diff --git a/libc/include/stdlib.h b/libc/include/stdlib.h index 8b39fa1ccd5aeb8be863d2e37d73026795d3ebcd..82a3323ffbca15ecf7c273ec5dd697083415159e 100644 --- a/libc/include/stdlib.h +++ b/libc/include/stdlib.h @@ -28,5 +28,11 @@ void __stack_chk_fail(void); #include <malloc.h> +#include <open.h> +#include <close.h> +#include <read.h> +#include <write.h> +#include <mkfifo.h> +#include <syscall.h> #endif diff --git a/libc/include/syscall.h b/libc/include/syscall.h index 115c35dd9617452e606ecc9d051cf0020551a166..6a467b1af637c4a75108760184257d7ca76461ef 100644 --- a/libc/include/syscall.h +++ b/libc/include/syscall.h @@ -23,6 +23,7 @@ #define SYS_write 1 #define SYS_open 2 #define SYS_close 3 +#define SYS_mknod 133 #else #define SYS_read 3 #define SYS_write 4 diff --git a/libc/src/Makefile.in b/libc/src/Makefile.in index 1560c20d7bfd88fa8a9da3d951a7c8c06dbbcef4..f428d84f666be4c5b7ffc479602b94b16463477a 100644 --- a/libc/src/Makefile.in +++ b/libc/src/Makefile.in @@ -7,7 +7,7 @@ AR=@AR@ AS=@AS@ ASFLAGS=@ASFLAGS@ -OBJS=malloc.o read.o write.o itoa.o strlen.o cgc.o open.o close.o stdlib.o +OBJS=malloc.o read.o write.o itoa.o strlen.o cgc.o open.o close.o stdlib.o mkfifo.o # note: cgc.s is empty when -DCGC is not in ASFLAGS, so it's an empty object file that's created.. diff --git a/libc/src/open.c b/libc/src/open.c index 21b943f1fa8fe0f96a6799f6ce42d800aa798f58..f5428d209a00125ecc5f4c4e459d3cb28c4854be 100644 --- a/libc/src/open.c +++ b/libc/src/open.c @@ -21,10 +21,17 @@ #include <open.h> #include <syscall.h> -int open(char *file, int mode) +/* +int open(char *file, int flags) { #ifndef CGC - syscall(SYS_open,file,mode); + syscall(SYS_open,file,flags); +#endif +} +*/ +int open(char *file, int flags, int mode) +{ +#ifndef CGC + syscall(SYS_open,file,flags,mode); #endif } -