diff --git a/src/magic_mount.c b/src/magic_mount.c index 6c3c831..0f16e9f 100644 --- a/src/magic_mount.c +++ b/src/magic_mount.c @@ -20,6 +20,7 @@ void magic_mount_init(MagicMount *ctx) memset(ctx, 0, sizeof(*ctx)); ctx->module_dir = DEFAULT_MODULE_DIR; ctx->mount_source = DEFAULT_MOUNT_SOURCE; + ctx->enable_unmountable = true; } void magic_mount_cleanup(MagicMount *ctx) @@ -163,7 +164,9 @@ static int mm_apply_node_recursive(MagicMount *ctx, strerror(errno)); return -1; } else if (!strstr(target, ".magic_mount/workdir/")) { - ksu_send_unmountable(target); + if (ctx->enable_unmountable) + ksu_send_unmountable(path); + } (void)mount(NULL, target, NULL, @@ -384,7 +387,9 @@ static int mm_apply_node_recursive(MagicMount *ctx, LOGI("move mountpoint success: %s -> %s", wpath, path); (void)mount(NULL, path, NULL, MS_REC | MS_PRIVATE, NULL); - ksu_send_unmountable(path); + if (ctx->enable_unmountable) + ksu_send_unmountable(path); + } ctx->stats.nodes_mounted++; diff --git a/src/magic_mount.h b/src/magic_mount.h index 39610f3..db9d983 100644 --- a/src/magic_mount.h +++ b/src/magic_mount.h @@ -2,6 +2,7 @@ #define MAGIC_MOUNT_H #include +#include #define DISABLE_FILE_NAME "disable" #define REMOVE_FILE_NAME "remove" @@ -35,6 +36,8 @@ typedef struct MagicMount { char **extra_parts; int extra_parts_count; + + bool enable_unmountable; } MagicMount; /* Initialization ctx (module_dir/mount_source) */ diff --git a/src/main.c b/src/main.c index e3dc982..cd32451 100644 --- a/src/main.c +++ b/src/main.c @@ -25,6 +25,7 @@ typedef struct { const char *log_file; const char *partitions; bool debug; + bool umount; } Config; /* --- Forward declarations --- */ @@ -51,6 +52,7 @@ static void usage(const char *prog) " -l, --log-file FILE Log file (default: stderr, '-' for stdout)\n" " -c, --config FILE Config file (default: %s)\n" " -v, --verbose Enable debug logging\n" + " --no_umount Disable umount\n" " -h, --help Show this help message\n" "\n", VERSION, prog, DEFAULT_MODULE_DIR, DEFAULT_MOUNT_SOURCE, @@ -109,6 +111,9 @@ static int load_config_file(const char *path, Config *cfg, MagicMount *ctx) } else if (!strcasecmp(key, "debug")) { cfg->debug = str_is_true(val); + } else if (!strcasecmp(key, "umount")) { + cfg->umount = str_is_true(val); + } else if (!strcasecmp(key, "partitions")) { cfg->partitions = strdup(val); @@ -213,6 +218,7 @@ int main(int argc, char **argv) { MagicMount ctx; Config cfg = {0}; + cfg.umount = true; char auto_tmp[PATH_MAX] = {0}; const char *config_path = DEFAULT_CONFIG_PATH; @@ -254,6 +260,11 @@ int main(int argc, char **argv) tmp_dir = cfg.temp_dir; if (cfg.debug) log_set_level(LOG_DEBUG); + if (cfg.umount) + ctx.enable_unmountable = true; + else + ctx.enable_unmountable = false; + for (int i = 1; i < argc; i++) { const char *arg = argv[i]; @@ -273,6 +284,9 @@ int main(int argc, char **argv) } else if (!strcmp(arg, "-v") || !strcmp(arg, "--verbose")) { log_set_level(LOG_DEBUG); + } else if (!strcmp(arg, "--no-umount")) { + ctx.enable_unmountable = false; + } else if ((!strcmp(arg, "-p") || !strcmp(arg, "--partitions")) && i + 1 < argc) { cli_has_partitions = true; if (parse_partitions(argv[++i], &ctx) < 0) { diff --git a/webui/src/App.svelte b/webui/src/App.svelte index fe934ae..d888d4f 100644 --- a/webui/src/App.svelte +++ b/webui/src/App.svelte @@ -10,6 +10,7 @@ mountsource: 'KSU', logfile: '/data/adb/magic_mount/mm.log', verbose: false, + umount: false, partitions: [] }; @@ -121,6 +122,9 @@ case 'debug': result.verbose = isTrueValue(value); break; + case 'umount': + result.umount = isTrueValue(value); + break; case 'partitions': result.partitions = value .split(',') @@ -158,6 +162,8 @@ lines.push(`debug=${cfg.verbose ? 'true' : 'false'}`); + lines.push(`umount=${cfg.umount ? 'true' : 'false'}`); + if (cfg.partitions.length > 0) { lines.push(`partitions=${cfg.partitions.join(',')}`); } @@ -497,6 +503,26 @@ +
+ +
+ + +
+
+