From aee2120dceb43fdd2ea631a898818d5bcb0da10b Mon Sep 17 00:00:00 2001 From: Nick Shaw Date: Sat, 6 Apr 2024 10:04:33 -0400 Subject: [PATCH] Storage: Virtual volume label is now set from Image Name --- applications/services/storage/storage_glue.c | 6 ++++++ applications/services/storage/storage_glue.h | 1 + applications/services/storage/storages/storage_ext.c | 7 ++++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/applications/services/storage/storage_glue.c b/applications/services/storage/storage_glue.c index 41da6c3f4..63bb017fd 100644 --- a/applications/services/storage/storage_glue.c +++ b/applications/services/storage/storage_glue.c @@ -156,3 +156,9 @@ size_t storage_open_files_count(StorageData* storage) { size_t count = StorageFileList_size(storage->files); return count; } + +const char* storage_file_get_path(File* file, StorageData* storage) { + if(!storage_has_file(file, storage)) return ""; + StorageFile* storage_file_ref = storage_get_file(file, storage); + return furi_string_get_cstr(storage_file_ref->path); +} \ No newline at end of file diff --git a/applications/services/storage/storage_glue.h b/applications/services/storage/storage_glue.h index fbc08ebbf..9a19ae815 100644 --- a/applications/services/storage/storage_glue.h +++ b/applications/services/storage/storage_glue.h @@ -35,6 +35,7 @@ void storage_file_init(StorageFile* obj); void storage_file_init_set(StorageFile* obj, const StorageFile* src); void storage_file_set(StorageFile* obj, const StorageFile* src); void storage_file_clear(StorageFile* obj); +const char* storage_file_get_path(File* file, StorageData* storage); void storage_data_init(StorageData* storage); StorageStatus storage_data_status(StorageData* storage); diff --git a/applications/services/storage/storages/storage_ext.c b/applications/services/storage/storages/storage_ext.c index dfd13f00b..0114d8dcc 100644 --- a/applications/services/storage/storages/storage_ext.c +++ b/applications/services/storage/storages/storage_ext.c @@ -1,6 +1,7 @@ #include "fatfs.h" #include "../filesystem_api_internal.h" #include "storage_ext.h" +#include "storage/storage_glue.h" #include #include "sd_notify.h" #include @@ -740,7 +741,11 @@ FS_Error storage_process_virtual_format(StorageData* storage) { uint8_t* work = malloc(_MAX_SS); SDError error = f_mkfs(sd_data->path, FM_ANY, 0, work, _MAX_SS); storage_process_virtual_mount(storage); - f_setlabel("DOLPHIN"); + const char* path = storage_file_get_path(mnt_image, mnt_image_storage); + char* label = basename(path); + int len = strlen(label); + label[len - 4] = '\0'; // truncate the .img extension + f_setlabel(label); storage_process_virtual_unmount(storage); free(work); if(error != FR_OK) return FSE_INTERNAL;