From deb9c94bcde52372d9456ef9c4f3a845e0bfb5ac Mon Sep 17 00:00:00 2001 From: CTCaer Date: Wed, 28 Aug 2019 02:25:48 +0300 Subject: [PATCH] nyx: Check if split restore files are 4MB aligned This is a mitigation for cluster version of FastFS. During a split restore, it is allowed only once to write a cluster that is not full. --- nyx/nyx_gui/frontend/fe_emmc_tools.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/nyx/nyx_gui/frontend/fe_emmc_tools.c b/nyx/nyx_gui/frontend/fe_emmc_tools.c index 7b8da16..17a47b3 100644 --- a/nyx/nyx_gui/frontend/fe_emmc_tools.c +++ b/nyx/nyx_gui/frontend/fe_emmc_tools.c @@ -922,6 +922,7 @@ static int _restore_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_pa manual_system_maintenance(true); bool use_multipart = false; + bool check_4MB_aligned = true; if (allow_multi_part) { @@ -968,8 +969,21 @@ static int _restore_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_pa totalSectors = (u32)((u64)totalCheckFileSize >> (u64)9); } else + { totalCheckFileSize += (u64)fno.fsize; + if (check_4MB_aligned && (((u64)fno.fsize) % 0x400000)) + { + s_printf(gui->txt_buf, "#FFDD00 The split file must be a#\n#FFDD00 multiple of 4 MiB.#\n#FFDD00 Aborting...#", res, outFilename); + lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf); + manual_system_maintenance(true); + + return 0; + } + + check_4MB_aligned = false; + } + numSplitParts++; }