44
44
#include <sys/statfs.h>
45
45
#include <sys/types.h>
46
46
#include <sys/poll.h>
47
+ #include <sys/wait.h>
47
48
48
49
/****************************************************************************
49
50
* Pre-processor Definitions
@@ -178,6 +179,10 @@ static void fastboot_memdump(FAR struct fastboot_ctx_s *context,
178
179
FAR const char * arg );
179
180
static void fastboot_filedump (FAR struct fastboot_ctx_s * context ,
180
181
FAR const char * arg );
182
+ #ifdef CONFIG_SYSTEM_FASTBOOTD_SHELL
183
+ static void fastboot_shell (FAR struct fastboot_ctx_s * context ,
184
+ FAR const char * arg );
185
+ #endif
181
186
182
187
/****************************************************************************
183
188
* Private Data
@@ -198,7 +203,10 @@ static const struct fastboot_cmd_s g_fast_cmd[] =
198
203
static const struct fastboot_cmd_s g_oem_cmd [] =
199
204
{
200
205
{ "filedump" , fastboot_filedump },
201
- { "memdump" , fastboot_memdump }
206
+ { "memdump" , fastboot_memdump },
207
+ #ifdef CONFIG_SYSTEM_FASTBOOTD_SHELL
208
+ { "shell" , fastboot_shell },
209
+ #endif
202
210
};
203
211
204
212
/****************************************************************************
@@ -774,6 +782,37 @@ static void fastboot_filedump(FAR struct fastboot_ctx_s *context,
774
782
fastboot_okay (context , "" );
775
783
}
776
784
785
+ #ifdef CONFIG_SYSTEM_FASTBOOTD_SHELL
786
+ static void fastboot_shell (FAR struct fastboot_ctx_s * context ,
787
+ FAR const char * arg )
788
+ {
789
+ char response [FASTBOOT_MSG_LEN - 4 ];
790
+ FILE * fp ;
791
+ int ret ;
792
+
793
+ fp = popen (arg , "r" );
794
+ if (fp == NULL )
795
+ {
796
+ fastboot_fail (context , "popen() fails %d" , errno );
797
+ return ;
798
+ }
799
+
800
+ while (fgets (response , sizeof (response ), fp ))
801
+ {
802
+ fastboot_ack (context , "TEXT" , response );
803
+ }
804
+
805
+ ret = pclose (fp );
806
+ if (WIFEXITED (ret ) && WEXITSTATUS (ret ) == 0 )
807
+ {
808
+ fastboot_okay (context , "" );
809
+ return ;
810
+ }
811
+
812
+ fastboot_fail (context , "error detected 0x%x %d" , ret , errno );
813
+ }
814
+ #endif
815
+
777
816
static void fastboot_upload (FAR struct fastboot_ctx_s * context ,
778
817
FAR const char * arg )
779
818
{
0 commit comments