File tree 1 file changed +32
-3
lines changed
1 file changed +32
-3
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ FILEHANDLE _sys_open(const char *name, int openmode)
48
48
{
49
49
#ifdef RT_USING_DFS
50
50
int fd ;
51
+ int mode = O_RDONLY ;
51
52
#endif
52
53
53
54
/* Register standard Input Output devices. */
@@ -61,8 +62,33 @@ FILEHANDLE _sys_open(const char *name, int openmode)
61
62
#ifndef RT_USING_DFS
62
63
return -1 ;
63
64
#else
64
- /* TODO: adjust open file mode */
65
- fd = open (name , openmode , 0 );
65
+ /* Correct openmode from fopen to open */
66
+ if (openmode & OPEN_PLUS )
67
+ {
68
+ if (openmode & OPEN_W )
69
+ {
70
+ mode |= (O_RDWR | O_TRUNC | O_CREAT );
71
+ }
72
+ else if (openmode & OPEN_A )
73
+ {
74
+ mode |= (O_RDWR | O_APPEND | O_CREAT );
75
+ }
76
+ else
77
+ mode |= O_RDWR ;
78
+ }
79
+ else
80
+ {
81
+ if (openmode & OPEN_W )
82
+ {
83
+ mode |= (O_WRONLY | O_TRUNC | O_CREAT );
84
+ }
85
+ else if (openmode & OPEN_A )
86
+ {
87
+ mode |= (O_WRONLY | O_APPEND | O_CREAT );
88
+ }
89
+ }
90
+
91
+ fd = open (name , mode , 0 );
66
92
if (fd < 0 )
67
93
return -1 ;
68
94
else
@@ -196,7 +222,10 @@ char *_sys_command_string(char *cmd, int len)
196
222
197
223
void _ttywrch (int ch )
198
224
{
199
- /* TODO */
225
+ char c ;
226
+
227
+ c = (char )ch ;
228
+ rt_kprintf (& c );
200
229
}
201
230
202
231
void _sys_exit (int return_code )
You can’t perform that action at this time.
0 commit comments