7070 ****************************************************************************/
7171
7272int nsh_fileapp (FAR struct nsh_vtbl_s * vtbl , FAR const char * cmd ,
73- FAR char * * argv , FAR const char * redirfile_in ,
74- FAR const char * redirfile_out , int oflags )
73+ FAR char * * argv , FAR const struct nsh_param_s * param )
7574{
7675 posix_spawn_file_actions_t file_actions ;
7776 posix_spawnattr_t attr ;
@@ -107,39 +106,46 @@ int nsh_fileapp(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd,
107106 goto errout_with_actions ;
108107 }
109108
110- /* Handle redirection of input */
111-
112- if (redirfile_in )
109+ if (param )
113110 {
114- /* Set up to close open redirfile and set to stdin (0) */
111+ /* Handle redirection of input */
115112
116- ret = posix_spawn_file_actions_addopen (& file_actions , 0 ,
117- redirfile_in , O_RDONLY , 0 );
118- if (ret != 0 )
113+ if (param -> file_in )
119114 {
120- nsh_error (vtbl , g_fmtcmdfailed , cmd ,
121- "posix_spawn_file_actions_addopen" ,
122- NSH_ERRNO );
123- goto errout_with_actions ;
115+ /* Set up to close open redirfile and set to stdin (0) */
116+
117+ ret = posix_spawn_file_actions_addopen (& file_actions , 0 ,
118+ param -> file_in ,
119+ param -> oflags_in ,
120+ 0 );
121+ if (ret != 0 )
122+ {
123+ nsh_error (vtbl , g_fmtcmdfailed , cmd ,
124+ "posix_spawn_file_actions_addopen" ,
125+ NSH_ERRNO );
126+ goto errout_with_actions ;
127+ }
124128 }
125- }
126129
127- /* Handle re-direction of output */
130+ /* Handle re-direction of output */
128131
129- if (redirfile_out )
130- {
131- ret = posix_spawn_file_actions_addopen (& file_actions , 1 , redirfile_out ,
132- oflags , 0644 );
133- if (ret != 0 )
132+ if (param -> file_out )
134133 {
135- /* posix_spawn_file_actions_addopen returns a positive errno
136- * value on failure.
137- */
134+ ret = posix_spawn_file_actions_addopen (& file_actions , 1 ,
135+ param -> file_out ,
136+ param -> oflags_out ,
137+ 0644 );
138+ if (ret != 0 )
139+ {
140+ /* posix_spawn_file_actions_addopen returns a positive errno
141+ * value on failure.
142+ */
138143
139- nsh_error (vtbl , g_fmtcmdfailed , cmd ,
140- "posix_spawn_file_actions_addopen" ,
141- NSH_ERRNO );
142- goto errout_with_attrs ;
144+ nsh_error (vtbl , g_fmtcmdfailed , cmd ,
145+ "posix_spawn_file_actions_addopen" ,
146+ NSH_ERRNO );
147+ goto errout_with_attrs ;
148+ }
143149 }
144150 }
145151
@@ -151,7 +157,7 @@ int nsh_fileapp(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd,
151157 if (index >= 0 )
152158 {
153159 FAR const struct builtin_s * builtin ;
154- struct sched_param param ;
160+ struct sched_param sched ;
155161
156162 /* Get information about the builtin */
157163
@@ -164,8 +170,8 @@ int nsh_fileapp(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd,
164170
165171 /* Set the correct task size and priority */
166172
167- param .sched_priority = builtin -> priority ;
168- ret = posix_spawnattr_setschedparam (& attr , & param );
173+ sched .sched_priority = builtin -> priority ;
174+ ret = posix_spawnattr_setschedparam (& attr , & sched );
169175 if (ret != 0 )
170176 {
171177 goto errout_with_actions ;
@@ -298,9 +304,9 @@ int nsh_fileapp(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd,
298304
299305#if !defined(CONFIG_SCHED_WAITPID ) || !defined(CONFIG_NSH_DISABLEBG )
300306 {
301- struct sched_param param ;
302- sched_getparam (ret , & param );
303- nsh_output (vtbl , "%s [%d:%d]\n" , cmd , ret , param .sched_priority );
307+ struct sched_param sched ;
308+ sched_getparam (ret , & sched );
309+ nsh_output (vtbl , "%s [%d:%d]\n" , cmd , ret , sched .sched_priority );
304310
305311 /* Backgrounded commands always 'succeed' as long as we can start
306312 * them.
0 commit comments