Storage: Virtual volume label is now set from Image Name

This commit is contained in:
Nick Shaw
2024-04-06 10:04:33 -04:00
parent 7869869fb9
commit aee2120dce
3 changed files with 13 additions and 1 deletions

View File

@@ -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);
}

View File

@@ -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);

View File

@@ -1,6 +1,7 @@
#include "fatfs.h"
#include "../filesystem_api_internal.h"
#include "storage_ext.h"
#include "storage/storage_glue.h"
#include <furi_hal.h>
#include "sd_notify.h"
#include <furi_hal_sd.h>
@@ -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;