From f1b693c51274c6dd4debd2a18c528f10f799a57f Mon Sep 17 00:00:00 2001 From: Sorgelig Date: Thu, 17 Feb 2022 02:40:59 +0800 Subject: [PATCH] INI option to wait for specific mount before core start. --- MiSTer.ini | 6 ++++++ cfg.cpp | 1 + cfg.h | 1 + user_io.cpp | 13 +++++++++++++ 4 files changed, 21 insertions(+) diff --git a/MiSTer.ini b/MiSTer.ini index e9f1400..1d7faf2 100644 --- a/MiSTer.ini +++ b/MiSTer.ini @@ -188,3 +188,9 @@ bt_reset_before_pair=0 ;default shadow mask mode: ; 0 - none, 1 - 1x, 2 - 2x, 3 - 1x Rotated, 4 - 2x Rotated ;shmask_mode_default=1 + +; Wait for specific mount before start the core. +; Attention: waiting is performing BEFORE core start, so no message will be displayed on screen! +; This is debug option. It's useful when core is loaded from USB blaster and games folder is on USB or Network drive. +; This option cannot be used in specific core section as it's parsed before name of core! +;waitmount=/media/usb0 diff --git a/cfg.cpp b/cfg.cpp index 479f651..a9f59e9 100644 --- a/cfg.cpp +++ b/cfg.cpp @@ -90,6 +90,7 @@ static const ini_var_t ini_vars[] = { "LOG_FILE_ENTRY", (void*)(&(cfg.log_file_entry)), UINT8, 0, 1 }, { "BT_AUTO_DISCONNECT", (void*)(&(cfg.bt_auto_disconnect)), UINT32, 0, 180 }, { "BT_RESET_BEFORE_PAIR", (void*)(&(cfg.bt_reset_before_pair)), UINT8, 0, 1 }, + { "WAITMOUNT", (void*)(&(cfg.waitmount)), STRING, 0, sizeof(cfg.waitmount) - 1 }, }; static const int nvars = (int)(sizeof(ini_vars) / sizeof(ini_var_t)); diff --git a/cfg.h b/cfg.h index 6795a7d..7004ae0 100644 --- a/cfg.h +++ b/cfg.h @@ -62,6 +62,7 @@ typedef struct { char video_conf_ntsc[1024]; char font[1024]; char shared_folder[1024]; + char waitmount[1024]; char custom_aspect_ratio[2][16]; char afilter_default[1023]; char vfilter_default[1023]; diff --git a/user_io.cpp b/user_io.cpp index 243a9a5..56df96e 100644 --- a/user_io.cpp +++ b/user_io.cpp @@ -1103,6 +1103,18 @@ void user_io_init(const char *path, const char *xml) user_io_set_core_name("sharpmz"); } + // parse INI before CONFSTR, no core-specific settings possible at theis time! + cfg_parse(); + while (cfg.waitmount[0]) + { + printf("> > > wait for %s mount < < <\n", cfg.waitmount); + static char str[256]; + snprintf(str, sizeof(str), "exit $(mount | grep \"%s\" | wc -c)", cfg.waitmount); + int ret = system(str); + if (!(ret & 0xFF) && ret) break; + sleep(1); + } + user_io_read_confstr(); user_io_read_core_name(); parse_config(); @@ -1116,6 +1128,7 @@ void user_io_init(const char *path, const char *xml) printf("Using default MRA: %s\n", xml); } + // parse INI again with core-specific settings. cfg_parse(); if (cfg.log_file_entry) MakeFile("/tmp/STARTPATH", core_path);