Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Storage: USB Mass Storage enhancement for setting volume label #80

Merged
merged 6 commits into from
Apr 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion applications/services/storage/storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ Storage* storage_app_alloc(void) {
}

#ifndef FURI_RAM_EXEC
storage_mnt_init(&app->storage[ST_MNT]);
storage_int_init(&app->storage[ST_INT]);
#endif
storage_ext_init(&app->storage[ST_EXT]);
#ifndef FURI_RAM_EXEC
storage_mnt_init(&app->storage[ST_MNT]);
#endif

// sd icon gui
app->sd_gui.enabled = false;
Expand Down
6 changes: 6 additions & 0 deletions applications/services/storage/storage_glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
StorageFile* storage_file_ref = storage_get_file(file, storage);
if(!storage_file_ref) return "";
return furi_string_get_cstr(storage_file_ref->path);
}
1 change: 1 addition & 0 deletions applications/services/storage/storage_glue.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
15 changes: 15 additions & 0 deletions applications/services/storage/storages/storage_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <furi_hal.h>
#include "sd_notify.h"
#include <furi_hal_sd.h>
#include <toolbox/path.h>

typedef FIL SDFile;
typedef DIR SDDir;
Expand Down Expand Up @@ -741,6 +742,20 @@ FS_Error storage_process_virtual_format(StorageData* storage) {
SDError error = f_mkfs(sd_data->path, FM_ANY, 0, work, _MAX_SS);
free(work);
if(error != FR_OK) return FSE_INTERNAL;

if(storage_process_virtual_mount(storage) == FSE_OK) {
// Image file path
const char* img_path = storage_file_get_path(mnt_image, mnt_image_storage);
// Image file name
FuriString* img_name = furi_string_alloc();
path_extract_filename_no_ext(img_path, img_name);
// Label with drive id prefix
char* label = storage_ext_drive_path(storage, furi_string_get_cstr(img_name));
furi_string_free(img_name);
f_setlabel(label);
free(label);
storage_process_virtual_unmount(storage);
}
return FSE_OK;
#endif
}
Expand Down
Loading