#define MSG_GROUP_HDS 100
bool valid_hds_path(char* path);
int try_mount(char* tag, char* path);
+void hds_unmount_all(void);
#define IJTYPE_SUSPEND "suspend"
#define IJTYPE_HDS "hds"
return 0;
}
+enum emuld_system_action {
+ EMULD_SYSTEM_ACTION_FORCE_CLOSE,
+ EMULD_SYSTEM_ACTION_REBOOT
+};
+
void powerdown_by_force(void)
{
struct timeval now;
void msgproc_system(ijcommand* ijcmd)
{
- LOGDEBUG("msgproc_system");
+ int action = ijcmd->msg.action;
+ LOGDEBUG("msgproc_system with %d action", action);
- LOGINFO("/etc/rc.d/rc.shutdown, sync, reboot(RB_POWER_OFF)");
+ if (action == EMULD_SYSTEM_ACTION_FORCE_CLOSE) {
+ LOGINFO("/etc/rc.d/rc.shutdown, sync, reboot(RB_POWER_OFF)");
- sync();
+ sync();
+
+ systemcall("/etc/rc.d/rc.shutdown &");
+
+ gettimeofday(&tv_start_poweroff, NULL);
- systemcall("/etc/rc.d/rc.shutdown &");
+ powerdown_by_force();
+ } else if (action == EMULD_SYSTEM_ACTION_REBOOT) {
+ LOGINFO("sync, unmount all hds");
- gettimeofday(&tv_start_poweroff, NULL);
+ sync();
- powerdown_by_force();
+ hds_unmount_all();
+ } else {
+ LOGERR("unknown system action %d", action);
+ }
}
static int lock_state = SUSPEND_UNLOCK;
return ret;
}
+void hds_unmount_all(void)
+{
+ char tmp[MAX_DATA_BUF];
+ snprintf(tmp, sizeof(tmp), "%s", "umount -a -t 9p");
+ systemcall(tmp);
+}
+
static bool get_tag_path(char* data, char** tag, char** path)
{
char token[] = "\n";