File tree Expand file tree Collapse file tree 1 file changed +32
-3
lines changed Expand file tree Collapse file tree 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)
4848{
4949#ifdef  RT_USING_DFS     
5050    int  fd ;
51+     int  mode  =  O_RDONLY ;
5152#endif 
5253
5354    /* Register standard Input Output devices. */ 
@@ -61,8 +62,33 @@ FILEHANDLE _sys_open(const char *name, int openmode)
6162#ifndef  RT_USING_DFS 
6263    return  -1 ;
6364#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 );
6692    if (fd  <  0 )
6793        return  -1 ;
6894    else 
@@ -196,7 +222,10 @@ char *_sys_command_string(char *cmd, int len)
196222
197223void  _ttywrch (int  ch )
198224{
199-    /* TODO */ 
225+     char  c ;
226+ 
227+     c  =  (char )ch ;
228+     rt_kprintf (& c );
200229}
201230
202231void  _sys_exit (int  return_code )
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments