Skip to content
Snippets Groups Projects
Commit e226d50f authored by whh8b's avatar whh8b
Browse files

Add support for open modes and for mkfifo.

parent 7bb7ec09
No related branches found
No related tags found
No related merge requests found
...@@ -23,7 +23,70 @@ ...@@ -23,7 +23,70 @@
#include <stdint.h> #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 #endif
...@@ -28,5 +28,11 @@ ...@@ -28,5 +28,11 @@
void __stack_chk_fail(void); void __stack_chk_fail(void);
#include <malloc.h> #include <malloc.h>
#include <open.h>
#include <close.h>
#include <read.h>
#include <write.h>
#include <mkfifo.h>
#include <syscall.h>
#endif #endif
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#define SYS_write 1 #define SYS_write 1
#define SYS_open 2 #define SYS_open 2
#define SYS_close 3 #define SYS_close 3
#define SYS_mknod 133
#else #else
#define SYS_read 3 #define SYS_read 3
#define SYS_write 4 #define SYS_write 4
......
...@@ -7,7 +7,7 @@ AR=@AR@ ...@@ -7,7 +7,7 @@ AR=@AR@
AS=@AS@ AS=@AS@
ASFLAGS=@ASFLAGS@ 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.. # note: cgc.s is empty when -DCGC is not in ASFLAGS, so it's an empty object file that's created..
......
...@@ -21,10 +21,17 @@ ...@@ -21,10 +21,17 @@
#include <open.h> #include <open.h>
#include <syscall.h> #include <syscall.h>
int open(char *file, int mode) /*
int open(char *file, int flags)
{ {
#ifndef CGC #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 #endif
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment