From b9a583cdb51bb3550c325e6928d23c314eb84b1d Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Tue, 21 May 2024 18:31:51 +0200 Subject: [PATCH] swapped out to use bigbuff memory allocation and also show an empty message --- CHANGELOG.md | 3 ++- armsrc/spiffs.c | 18 +++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a4710aeae..ff3639ea6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,8 @@ All notable changes to this project will be documented in this file. This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log... ## [unreleased][unreleased] -- Change `lf hitag info` - now tries to identify different key fob emulators (@iceman1001) +- Changed `mem spiffs tree` - adapted to bigbuff and show if empty (@iceman1001) +- Changed `lf hitag info` - now tries to identify different key fob emulators (@iceman1001) - Added `lf hitag reader` - act as a Hitag2 reader (@iceman1001) - Fixed `lf hitag crack2` - now works. (@iceman1001) - Fixed wrong use of free() in desfire crypto on arm src, thanks @jlitewski! (@iceman1001) diff --git a/armsrc/spiffs.c b/armsrc/spiffs.c index 3154bfc0f..fbbf95672 100644 --- a/armsrc/spiffs.c +++ b/armsrc/spiffs.c @@ -639,24 +639,32 @@ void rdv40_spiffs_safe_print_tree(void) { struct spiffs_dirent e; struct spiffs_dirent *pe = &e; + char *resolvedlink = (char *)BigBuf_calloc(11 + SPIFFS_OBJ_NAME_LEN); + char *linkdest = (char *)BigBuf_calloc(SPIFFS_OBJ_NAME_LEN); + bool printed = false; + SPIFFS_opendir(&fs, "/", &d); while ((pe = SPIFFS_readdir(&d, pe))) { - char resolvedlink[11 + SPIFFS_OBJ_NAME_LEN]; + memset(resolvedlink, 0, sizeof(resolvedlink)); + if (rdv40_spiffs_is_symlink((const char *)pe->name)) { - char linkdest[SPIFFS_OBJ_NAME_LEN]; + read_from_spiffs((char *)pe->name, (uint8_t *)linkdest, SPIFFS_OBJ_NAME_LEN); sprintf(resolvedlink, "(.lnk) --> %s", linkdest); // Kind of stripping the .lnk extension strtok((char *)pe->name, "."); - } else { - memset(resolvedlink, 0, sizeof(resolvedlink)); } - Dbprintf("[%04x]\t " _YELLOW_("%i") " B |-- %s%s", pe->obj_id, pe->size, pe->name, resolvedlink); + Dbprintf("[%04x] " _YELLOW_("%5i") " B |-- %s%s", pe->obj_id, pe->size, pe->name, resolvedlink); + printed = true; + } + if (printed == false) { + DbpString(""); } SPIFFS_closedir(&d); rdv40_spiffs_lazy_mount_rollback(changed); + BigBuf_free(); } void rdv40_spiffs_safe_wipe(void) {