1313 * Date Author Notes
1414 * 2012-11-23 Yihui The first version
1515 * 2013-11-24 aozima fixed _sys_read()/_sys_write() issues.
16- * 2014-08-03 bernard If using msh, use system() implementation
16+ * 2014-08-03 bernard If using msh, use system() implementation
1717 * in msh.
1818 */
1919
@@ -48,11 +48,11 @@ const char __stderr_name[] = "STDERR";
4848 */
4949FILEHANDLE _sys_open (const char * name , int openmode )
5050{
51- #ifdef RT_USING_DFS
51+ #ifdef RT_USING_DFS
5252 int fd ;
5353 int mode = O_RDONLY ;
5454#endif
55-
55+
5656 /* Register standard Input Output devices. */
5757 if (strcmp (name , __stdin_name ) == 0 )
5858 return (STDIN );
@@ -64,34 +64,34 @@ FILEHANDLE _sys_open(const char *name, int openmode)
6464#ifndef RT_USING_DFS
6565 return -1 ;
6666#else
67- /* Correct openmode from fopen to open */
68- if (openmode & OPEN_PLUS )
69- {
70- if (openmode & OPEN_W )
71- {
72- mode |= (O_RDWR | O_TRUNC | O_CREAT );
73- }
74- else if (openmode & OPEN_A )
75- {
76- mode |= (O_RDWR | O_APPEND | O_CREAT );
77- }
78- else
79- mode |= O_RDWR ;
80- }
81- else
82- {
83- if (openmode & OPEN_W )
84- {
85- mode |= (O_WRONLY | O_TRUNC | O_CREAT );
86- }
87- else if (openmode & OPEN_A )
88- {
67+ /* Correct openmode from fopen to open */
68+ if (openmode & OPEN_PLUS )
69+ {
70+ if (openmode & OPEN_W )
71+ {
72+ mode |= (O_RDWR | O_TRUNC | O_CREAT );
73+ }
74+ else if (openmode & OPEN_A )
75+ {
76+ mode |= (O_RDWR | O_APPEND | O_CREAT );
77+ }
78+ else
79+ mode |= O_RDWR ;
80+ }
81+ else
82+ {
83+ if (openmode & OPEN_W )
84+ {
85+ mode |= (O_WRONLY | O_TRUNC | O_CREAT );
86+ }
87+ else if (openmode & OPEN_A )
88+ {
8989 mode |= (O_WRONLY | O_APPEND | O_CREAT );
90- }
91- }
90+ }
91+ }
9292
9393 fd = open (name , mode , 0 );
94- if (fd < 0 )
94+ if (fd < 0 )
9595 return -1 ;
9696 else
9797 return fd + STDERR + 1 ;
@@ -121,10 +121,10 @@ int _sys_close(FILEHANDLE fh)
121121 */
122122int _sys_read (FILEHANDLE fh , unsigned char * buf , unsigned len , int mode )
123123{
124- #ifdef RT_USING_DFS
124+ #ifdef RT_USING_DFS
125125 int size ;
126126#endif
127-
127+
128128 if (fh == STDIN )
129129 {
130130 /* TODO */
@@ -138,7 +138,7 @@ int _sys_read(FILEHANDLE fh, unsigned char *buf, unsigned len, int mode)
138138 return 0 ;
139139#else
140140 size = read (fh - STDERR - 1 , buf , len );
141- if (size >= 0 )
141+ if (size >= 0 )
142142 return len - size ;
143143 else
144144 return -1 ;
@@ -159,7 +159,7 @@ int _sys_write(FILEHANDLE fh, const unsigned char *buf, unsigned len, int mode)
159159#ifdef RT_USING_DFS
160160 int size ;
161161#endif
162-
162+
163163 if ((fh == STDOUT ) || (fh == STDERR ))
164164 {
165165#ifndef RT_USING_CONSOLE
@@ -170,18 +170,18 @@ int _sys_write(FILEHANDLE fh, const unsigned char *buf, unsigned len, int mode)
170170 console_device = rt_console_get_device ();
171171 if (console_device != 0 ) rt_device_write (console_device , 0 , buf , len );
172172
173- return 0 ;
173+ return 0 ;
174174#endif
175175 }
176176
177- if (fh == STDIN )
177+ if (fh == STDIN )
178178 return -1 ;
179179
180180#ifndef RT_USING_DFS
181181 return 0 ;
182182#else
183183 size = write (fh - STDERR - 1 , buf , len );
184- if (size >= 0 )
184+ if (size >= 0 )
185185 return len - size ;
186186 else
187187 return -1 ;
@@ -270,6 +270,6 @@ int remove(const char *filename)
270270int system (const char * string )
271271{
272272 RT_ASSERT (0 );
273- for (;;);
273+ for (;;);
274274}
275275#endif
0 commit comments