msgproc_injector_req(NULL, &msg);
}
-static bool do_push_package(char *cmd)
+static bool do_execute_command(char *cmd)
{
char buf[MAX_PKGS_LIST];
FILE *fp = popen(cmd, "r");
LOG_INFO("[pkgs] SDB push command: %s\n", cmd);
- if (do_push_package(cmd)) {
+ if (do_execute_command(cmd)) {
LOG_INFO("[pkgs] SDB push SUCCESS\n");
return true;
}
#endif
while (index != MAX_SDB_TRIAL) {
- if (do_push_package(cmd)) {
+ if (do_execute_command(cmd)) {
LOG_INFO("[pkgs] SDB push SUCCESS.\n");
return true;
}
error_report("%s", fail_msg);
}
+static void set_read_write_mode(void)
+{
+#ifndef CONFIG_WIN32
+ const char *sdb_path = "../../../../../tools/sdb";
+#else
+ const char *sdb_path = "..\\..\\..\\..\\..\\tools\\sdb.exe";
+#endif
+ const char *bin_dir = get_bin_path();
+ char cmd[MAX_PKGS_LIST];
+ int ret = 0;
+
+ memset(cmd, 0, sizeof(cmd));
+#ifndef CONFIG_WIN32
+ ret = sprintf(cmd, "\"%s%s\" -s emulator-%d root on",
+#else
+ ret = sprintf(cmd, "cmd /S /C \"\"%s%s\" -s emulator-%d root on\"",
+#endif
+ bin_dir, sdb_path, get_vm_device_serial_number());
+ if (ret < 0) {
+ LOG_SEVERE("SDB root on command is Wrong : %s\n", cmd);
+ return;
+ }
+ if (!do_execute_command(cmd)) {
+ LOG_SEVERE("SDB root on FAILED");
+ return;
+ }
+
+ memset(cmd, 0, sizeof(cmd));
+#ifndef CONFIG_WIN32
+ ret = sprintf(cmd, "\"%s%s\" -s emulator-%d shell \"mount -o remount,rw /\"",
+#else
+ ret = sprintf(cmd, "cmd /S /C \"\"%s%s\" -s emulator-%d shell \"mount -o remount,rw /\"\"",
+#endif
+ bin_dir, sdb_path, get_vm_device_serial_number());
+ if (ret < 0) {
+ LOG_INFO("SDB mount command is wrong: %s\n", cmd);
+ return;
+ }
+ if (!do_execute_command(cmd)) {
+ LOG_INFO("mount FAILED\n");
+ return;
+ }
+}
+
+static void *set_read_mode(void *args)
+{
+#ifndef CONFIG_WIN32
+ const char *sdb_path = "../../../../../tools/sdb";
+#else
+ const char *sdb_path = "..\\..\\..\\..\\..\\tools\\sdb.exe";
+#endif
+ const char *bin_dir = get_bin_path();
+ char cmd[MAX_PKGS_LIST];
+ int ret = 0;
+
+ memset(cmd, 0, sizeof(cmd));
+#ifndef CONFIG_WIN32
+ ret = sprintf(cmd, "\"%s%s\" -s emulator-%d shell \"mount -o remount,ro /\"",
+#else
+ ret = sprintf(cmd, "cmd /S /C \"\"%s%s\" -s emulator-%d shell \"mount -o remount,ro /\"\"",
+#endif
+ bin_dir, sdb_path, get_vm_device_serial_number());
+ if (ret < 0) {
+ LOG_INFO("SDB mount command is wrong: %s\n", cmd);
+ return NULL;
+ }
+ if (!do_execute_command(cmd)) {
+ LOG_INFO("mount FAILED\n");
+ return NULL;
+ }
+ memset(cmd, 0, sizeof(cmd));
+#ifndef CONFIG_WIN32
+ ret = sprintf(cmd, "\"%s%s\" -s emulator-%d root off",
+#else
+ ret = sprintf(cmd, "cmd /S /C \"\"%s%s\" -s emulator-%d root off\"",
+#endif
+ bin_dir, sdb_path, get_vm_device_serial_number());
+ if (ret < 0) {
+ LOG_SEVERE("SDB root off command is Wrong : %s\n", cmd);
+ return NULL;
+ }
+ if (!do_execute_command(cmd)) {
+ LOG_SEVERE("SDB root off FAILED");
+ return NULL;
+ }
+ return NULL;
+}
+
static void *push_pkgs_thread(void *args)
{
char *pkg_data = (char *)args;
return NULL;
}
+ /*Set read write mode */
+ set_read_write_mode();
+
/* request to install rpms */
LOG_INFO("[pkgs] Request to install : %s\n", data);
send_msg_to_guest(MSG_TYPE_PACKAGE, 0, 2, data, strlen(data) + 1);
qemu_thread_create(&sdb_thread_id, "sdb_push", push_pkgs_thread, (void *)pkgs, QEMU_THREAD_DETACHED);
} else if (action == 3) {
LOG_INFO("[pkgs] Package Installation Success: %s\n", data);
+
+ /*Set read mode */
+ qemu_thread_create(&sdb_thread_id, "sdb_push", set_read_mode, NULL, QEMU_THREAD_DETACHED);
+
} else if (action == 4) {
LOG_INFO("[pkgs] Package Installation Failed: %s\n", data);
+
+ /*Set read mode */
+ qemu_thread_create(&sdb_thread_id, "sdb_push", set_read_mode, NULL, QEMU_THREAD_DETACHED);
+
show_error_popup((char *)data);
} else {
LOG_SEVERE("unknown pkgs action: %d\n", action);