From a241d97c3b262a4309e2016fb6ff1eaa23ea1802 Mon Sep 17 00:00:00 2001 From: Mattias Axelsson Date: Mon, 8 Apr 2024 11:08:44 +0200 Subject: [PATCH] Ignore SD card state changes when not SD card is not used Prevent SD card state change from restarting dockerd when SD card is not being used. Also clarifying the comment about SD card unmounting. --- app/dockerdwrapperwithcompose.c | 6 ++++-- app/sd_disk_storage.h | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/dockerdwrapperwithcompose.c b/app/dockerdwrapperwithcompose.c index 5c5c27d..2b32d90 100644 --- a/app/dockerdwrapperwithcompose.c +++ b/app/dockerdwrapperwithcompose.c @@ -743,10 +743,12 @@ static void sd_card_callback(const char *sd_card_area, void *app_state_void_ptr) { struct app_state *app_state = app_state_void_ptr; - if (!sd_card_area) + const bool using_sd_card = is_parameter_yes(PARAM_SD_CARD_SUPPORT); + if (using_sd_card && !sd_card_area) stop_dockerd(); // Block here until dockerd has stopped using the SD card. app_state->sd_card_area = sd_card_area ? strdup(sd_card_area) : NULL; - g_main_loop_quit(loop); // Trigger a restart of dockerd from main() + if (using_sd_card) + g_main_loop_quit(loop); // Trigger a restart of dockerd from main() } // Stop the application and start it from an SSH prompt with diff --git a/app/sd_disk_storage.h b/app/sd_disk_storage.h index 54dbb66..ff65019 100644 --- a/app/sd_disk_storage.h +++ b/app/sd_disk_storage.h @@ -2,8 +2,10 @@ typedef void (*SdDiskCallback)(const char *area_path, void *user_data); -// Call sd_disk_callback with a path to the SD card when it has become available -// and with NULL when it is about to be unmounted. +// Call sd_disk_callback with a path to the SD card when it has become +// available. Call sd_disk_callback with NULL when it is about to be unmounted. +// Unmounting will fail if the SD card area contains open files when the +// callback returns. struct sd_disk_storage *sd_disk_storage_init(SdDiskCallback sd_disk_callback, void *user_data);