Skip to content

Commit f128891

Browse files
authored
Merge pull request #9397 from yossi2le/fix_default_storage_type
Fixing folder path for KVStore FILESYSTEM configuration.
2 parents c598a93 + 5de92ca commit f128891

File tree

4 files changed

+34
-11
lines changed

4 files changed

+34
-11
lines changed

features/storage/TESTS/kvstore/static_tests/main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,7 @@ static void iterator_close_right_after_iterator_open()
910910
utest::v1::status_t greentea_failure_handler(const Case *const source, const failure_t reason)
911911
{
912912
greentea_case_failure_abort_handler(source, reason);
913+
UnityConcludeTest();
913914
return STATUS_CONTINUE;
914915
}
915916

features/storage/kvstore/conf/kv_config.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ int _storage_config_FILESYSTEM_NO_RBP();
134134
int _storage_config_tdb_external_common();
135135
int _storage_config_filesystem_common();
136136

137+
static const char *filesystemstore_folder_path = NULL;
138+
137139
using namespace mbed;
138140

139141

@@ -881,6 +883,9 @@ int _storage_config_FILESYSTEM()
881883
#if !SECURESTORE_ENABLED
882884
return MBED_ERROR_UNSUPPORTED;
883885
#endif
886+
887+
filesystemstore_folder_path = STR(MBED_CONF_STORAGE_FILESYSTEM_FOLDER_PATH);
888+
884889
bd_size_t internal_rbp_size = MBED_CONF_STORAGE_FILESYSTEM_RBP_INTERNAL_SIZE;
885890
bd_addr_t internal_start_address = MBED_CONF_STORAGE_FILESYSTEM_INTERNAL_BASE_ADDRESS;
886891

@@ -962,6 +967,12 @@ int _storage_config_FILESYSTEM()
962967

963968
int _storage_config_FILESYSTEM_NO_RBP()
964969
{
970+
#if !SECURESTORE_ENABLED
971+
return MBED_ERROR_UNSUPPORTED;
972+
#endif
973+
974+
filesystemstore_folder_path = STR(MBED_CONF_STORAGE_FILESYSTEM_NO_RBP_FOLDER_PATH);
975+
965976
bd_size_t size = MBED_CONF_STORAGE_FILESYSTEM_NO_RBP_EXTERNAL_SIZE;
966977
bd_addr_t address = MBED_CONF_STORAGE_FILESYSTEM_NO_RBP_EXTERNAL_BASE_ADDRESS;
967978
const char *mount_point = STR(MBED_CONF_STORAGE_FILESYSTEM_NO_RBP_MOUNT_POINT);
@@ -1062,6 +1073,11 @@ int _storage_config_default()
10621073
#endif
10631074
}
10641075

1076+
const char *get_filesystemstore_folder_path()
1077+
{
1078+
return filesystemstore_folder_path;
1079+
}
1080+
10651081
MBED_WEAK int kv_init_storage_config()
10661082
{
10671083

features/storage/kvstore/conf/kv_config.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@
2020
extern "C" {
2121
#endif
2222

23-
#if MBED_CONF_STORAGE_STORAGE_TYPE == FILESYSTEM
24-
#define FSST_FOLDER_PATH MBED_CONF_STORAGE_FILESYSTEM_FOLDER_PATH
25-
#elif MBED_CONF_STORAGE_STORAGE_TYPE == FILESYSTEM_NO_RBP
26-
#define FSST_FOLDER_PATH MBED_CONF_STORAGE_FILESYSTEM_NO_RBP_FOLDER_PATH
27-
#endif
28-
2923
#ifndef MBED_CONF_STORAGE_STORAGE
3024
#define MBED_CONF_STORAGE_STORAGE USER_DEFINED
3125
#endif
@@ -41,6 +35,13 @@ extern "C" {
4135
*/
4236
int kv_init_storage_config();
4337

38+
/**
39+
* @brief A getter for filesystemstore folder path configuration
40+
*
41+
* @returns string with the file folder path or NULL if not set
42+
*/
43+
const char *get_filesystemstore_folder_path();
44+
4445
#ifdef __cplusplus
4546
} // closing brace for extern "C"
4647
#endif

features/storage/kvstore/filesystemstore/FileSystemStore.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818

1919
#include "FileSystemStore.h"
20+
#include "kv_config.h"
2021
#include "Dir.h"
2122
#include "File.h"
2223
#include "BlockDevice.h"
@@ -31,9 +32,7 @@
3132
#define FSST_REVISION 1
3233
#define FSST_MAGIC 0x46535354 // "FSST" hex 'magic' signature
3334

34-
#ifndef FSST_FOLDER_PATH
35-
#define FSST_FOLDER_PATH "kvstore" //default FileSystemStore folder path on fs
36-
#endif
35+
#define FSST_DEFAULT_FOLDER_PATH "kvstore" //default FileSystemStore folder path on fs
3736

3837
static const uint32_t supported_flags = mbed::KVStore::WRITE_ONCE_FLAG;
3938

@@ -73,9 +72,15 @@ int FileSystemStore::init()
7372
int status = MBED_SUCCESS;
7473

7574
_mutex.lock();
75+
const char *temp_path = get_filesystemstore_folder_path();
76+
if (temp_path == NULL) {
77+
_cfg_fs_path_size = strlen(FSST_DEFAULT_FOLDER_PATH);
78+
_cfg_fs_path = string_ndup(FSST_DEFAULT_FOLDER_PATH, _cfg_fs_path_size);
79+
} else {
80+
_cfg_fs_path_size = strlen(temp_path);
81+
_cfg_fs_path = string_ndup(temp_path, _cfg_fs_path_size);
82+
}
7683

77-
_cfg_fs_path_size = strlen(FSST_FOLDER_PATH);
78-
_cfg_fs_path = string_ndup(FSST_FOLDER_PATH, _cfg_fs_path_size);
7984
_full_path_key = new char[_cfg_fs_path_size + KVStore::MAX_KEY_SIZE + 1];
8085
memset(_full_path_key, 0, (_cfg_fs_path_size + KVStore::MAX_KEY_SIZE + 1));
8186
strncpy(_full_path_key, _cfg_fs_path, _cfg_fs_path_size);

0 commit comments

Comments
 (0)