sandbox: remove ram buffer file when U-Boot is loaded by SPL
PATCH 1/1 sandbox: remove ram buffer file when U-Boot is loaded by SPL
Update management of "--rm_memory" sandbox's option and force this option when U-Boot is loaded by SPL in os_spl_to_uboot() and remove the ram file after reading in main() as described in option help message: "Remove memory file after reading".
This patch avoids that the file "/tmp/u-boot.mem.XXXXXX" [created in os_jump_to_file() when U-Boot is loaded by SPL] is never deleted because state_uninit() is not called after U-Boot execution (CtrlC or with running pytest for example).
This issue is reproduced by
Quoted 1 line
build-sandbox_spl/spl/u-boot-spl
and CtrlC in U-Bot console
Quoted 1 line
make qcheck
One temp file is created after each SPL and U-Boot execution (7 tims in qcheck after test_handoff.py, test_ofplatdata.py,
test_spl.py execution).
---
arch/sandbox/cpu/os.c | 5 +++++ arch/sandbox/cpu/start.c | 7 +++++++ arch/sandbox/cpu/state.c | 4 ---- 3 files changed, 12 insertions(+), 4 deletions(-)
arch/sandbox/cpu/os.c +5 -0
@@ -750,6 +750,11 @@ int os_find_u_boot(char *fname, int maxlen)int os_spl_to_uboot (const char *fname) { +struct sandbox_state *state =state_get_current (); + +printf ("%s\n" , __func__); +/* U-Boot will delete ram buffer after read: "--rm_memory"*/ + state->ram_buf_rm = true;return os_jump_to_file (fname); }
arch/sandbox/cpu/start.c +7 -0
@@ -447,6 +447,13 @@ int main(int argc, char *argv[])if (os_parse_args (state, argc, argv))return 1 ; +/* Remove old memory file if required */ +if (state->ram_buf_rm && state->ram_buf_fname) { +os_unlink (state->ram_buf_fname); + state->write_ram_buf = false; + state->ram_buf_fname =NULL ; + } + ret =sandbox_read_state (state, state->state_fname);if (ret) goto err;
arch/sandbox/cpu/state.c +0 -4
@@ -415,10 +415,6 @@ int state_uninit(void) } } -/* Remove old memory file if required */ -if (state->ram_buf_rm && state->ram_buf_fname) -os_unlink (state->ram_buf_fname); -/* Delete this at the last moment so as not to upset gdb too much */ if (state->jumped_fname)os_unlink (state->jumped_fname);
Signature · 1 line
2.17.1
PATCH 1/1 sandbox: remove ram buffer file when U-Boot is loaded by SPL
Quoted 21 lines · Patrick Delaunay
Update management of "--rm_memory" sandbox's option and force this option when U-Boot is loaded by SPL in
os_spl_to_uboot()and remove the ram file after reading inmain()as described in option help message: "Remove memory file after reading".This patch avoids that the file "
/tmp/u-boot.mem.XXXXXX" [created inos_jump_to_file()when U-Boot is loaded by SPL] is never deleted becausestate_uninit()is not called after U-Boot execution (CtrlC or with running pytest for example).This issue is reproduced by
Quoted 1 line
build-sandbox_spl/spl/u-boot-spl
and CtrlC in U-Bot console
Quoted 1 line
make qcheck
One temp file is created after each SPL and U-Boot execution (7 tims in qcheck after
test_handoff.py,test_ofplatdata.py,
test_spl.pyexecution).
Quoted 7 lines
Signed-off-by Patrick Delaunay <[email protected]>---
arch/sandbox/cpu/os.c | 5 +++++ arch/sandbox/cpu/start.c | 7 +++++++ arch/sandbox/cpu/state.c | 4 ---- 3 files changed, 12 insertions(+), 4 deletions(-)