From efffb62b362553a1542fda2757283350678f9732 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 2 Nov 2021 18:21:45 -0500 Subject: [PATCH] truncate boot_out.txt if it's long Now this boot.py: ```py for i in range(1000): print(i) ``` creates a 512-byte boot_out.txt that ends ``` 88 89 ... ``` --- supervisor/shared/micropython.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/supervisor/shared/micropython.c b/supervisor/shared/micropython.c index 24bc57ec12..6c850f9b00 100644 --- a/supervisor/shared/micropython.c +++ b/supervisor/shared/micropython.c @@ -60,7 +60,13 @@ void mp_hal_stdout_tx_strn(const char *str, size_t len) { #ifdef CIRCUITPY_BOOT_OUTPUT_FILE if (boot_output != NULL) { - vstr_add_strn(boot_output, str, len); + // Ensure boot_out.txt is capped at 1 filesystem block and ends with a newline + if (len + boot_output->len > 508) { + vstr_add_str(boot_output, "...\n"); + boot_output = NULL; + } else { + vstr_add_strn(boot_output, str, len); + } } #endif