[FL-2675] /int space reservation (#1448)

* storage: added global #defines for /int, /ext & /any
* storage: introduced PATH_EXT, PATH_INT& PATH_ANY macros
* core apps: moved hardcoded config files names to separate headers; prefixed them with "."; updater: added file name migration to new naming convention on backup extraction
* storage: fixed storage_merge_recursive handling of complex directory structures; storage_move_to_sd: changed data migration logic to all non-dot files & all folders
* core: added macro aliases for core record names
* Bumped protobuf commit pointer
* storage: reserved 5 pages in /int; denying write&creation of non-dot files when running out of free space

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
hedger
2022-07-26 15:21:51 +03:00
committed by GitHub
parent 52a83fc929
commit 056446dfed
171 changed files with 1111 additions and 910 deletions

View File

@@ -95,7 +95,7 @@ SubGhz* subghz_alloc() {
string_init(subghz->file_path_tmp);
// GUI
subghz->gui = furi_record_open("gui");
subghz->gui = furi_record_open(RECORD_GUI);
// View Dispatcher
subghz->view_dispatcher = view_dispatcher_alloc();
@@ -111,7 +111,7 @@ SubGhz* subghz_alloc() {
subghz->view_dispatcher, subghz_tick_event_callback, 100);
// Open Notification record
subghz->notifications = furi_record_open("notification");
subghz->notifications = furi_record_open(RECORD_NOTIFICATION);
// SubMenu
subghz->submenu = submenu_alloc();
@@ -141,7 +141,7 @@ SubGhz* subghz_alloc() {
subghz->view_dispatcher, SubGhzViewIdWidget, widget_get_view(subghz->widget));
//Dialog
subghz->dialogs = furi_record_open("dialogs");
subghz->dialogs = furi_record_open(RECORD_DIALOGS);
// Transmitter
subghz->subghz_transmitter = subghz_view_transmitter_alloc();
@@ -194,7 +194,7 @@ SubGhz* subghz_alloc() {
//init setting
subghz->setting = subghz_setting_alloc();
subghz_setting_load(subghz->setting, "/ext/subghz/assets/setting_user");
subghz_setting_load(subghz->setting, EXT_PATH("subghz/assets/setting_user"));
//init Worker & Protocol & History & KeyBoard
subghz->lock = SubGhzLockOff;
@@ -210,9 +210,9 @@ SubGhz* subghz_alloc() {
subghz->txrx->environment = subghz_environment_alloc();
subghz_environment_set_came_atomo_rainbow_table_file_name(
subghz->txrx->environment, "/ext/subghz/assets/came_atomo");
subghz->txrx->environment, EXT_PATH("subghz/assets/came_atomo"));
subghz_environment_set_nice_flor_s_rainbow_table_file_name(
subghz->txrx->environment, "/ext/subghz/assets/nice_flor_s");
subghz->txrx->environment, EXT_PATH("subghz/assets/nice_flor_s"));
subghz->txrx->receiver = subghz_receiver_alloc_init(subghz->txrx->environment);
subghz_receiver_set_filter(subghz->txrx->receiver, SubGhzProtocolFlag_Decodable);
@@ -263,7 +263,7 @@ void subghz_free(SubGhz* subghz) {
widget_free(subghz->widget);
//Dialog
furi_record_close("dialogs");
furi_record_close(RECORD_DIALOGS);
// Transmitter
view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdTransmitter);
@@ -296,7 +296,7 @@ void subghz_free(SubGhz* subghz) {
view_dispatcher_free(subghz->view_dispatcher);
// GUI
furi_record_close("gui");
furi_record_close(RECORD_GUI);
subghz->gui = NULL;
//setting
@@ -314,7 +314,7 @@ void subghz_free(SubGhz* subghz) {
string_clear(subghz->error_str);
// Notifications
furi_record_close("notification");
furi_record_close(RECORD_NOTIFICATION);
subghz->notifications = NULL;
// Path strings
@@ -330,9 +330,9 @@ int32_t subghz_app(void* p) {
//Load database
bool load_database = subghz_environment_load_keystore(
subghz->txrx->environment, "/ext/subghz/assets/keeloq_mfcodes");
subghz->txrx->environment, EXT_PATH("subghz/assets/keeloq_mfcodes"));
subghz_environment_load_keystore(
subghz->txrx->environment, "/ext/subghz/assets/keeloq_mfcodes_user");
subghz->txrx->environment, EXT_PATH("subghz/assets/keeloq_mfcodes_user"));
// Check argument and run corresponding scene
if(p) {
uint32_t rpc_ctx = 0;

View File

@@ -245,12 +245,12 @@ void subghz_cli_command_rx(Cli* cli, string_t args, void* context) {
furi_check(instance->stream);
SubGhzEnvironment* environment = subghz_environment_alloc();
subghz_environment_load_keystore(environment, "/ext/subghz/assets/keeloq_mfcodes");
subghz_environment_load_keystore(environment, "/ext/subghz/assets/keeloq_mfcodes_user");
subghz_environment_load_keystore(environment, EXT_PATH("subghz/assets/keeloq_mfcodes"));
subghz_environment_load_keystore(environment, EXT_PATH("subghz/assets/keeloq_mfcodes_user"));
subghz_environment_set_came_atomo_rainbow_table_file_name(
environment, "/ext/subghz/assets/came_atomo");
environment, EXT_PATH("subghz/assets/came_atomo"));
subghz_environment_set_nice_flor_s_rainbow_table_file_name(
environment, "/ext/subghz/assets/nice_flor_s");
environment, EXT_PATH("subghz/assets/nice_flor_s"));
SubGhzReceiver* receiver = subghz_receiver_alloc_init(environment);
subghz_receiver_set_filter(receiver, SubGhzProtocolFlag_Decodable);
@@ -304,9 +304,9 @@ void subghz_cli_command_decode_raw(Cli* cli, string_t args, void* context) {
UNUSED(context);
string_t file_name;
string_init(file_name);
string_set_str(file_name, "/any/subghz/test.sub");
string_set_str(file_name, ANY_PATH("subghz/test.sub"));
Storage* storage = furi_record_open("storage");
Storage* storage = furi_record_open(RECORD_STORAGE);
FlipperFormat* fff_data_file = flipper_format_file_alloc(storage);
string_t temp_str;
string_init(temp_str);
@@ -346,29 +346,30 @@ void subghz_cli_command_decode_raw(Cli* cli, string_t args, void* context) {
string_clear(temp_str);
flipper_format_free(fff_data_file);
furi_record_close("storage");
furi_record_close(RECORD_STORAGE);
if(check_file) {
// Allocate context
SubGhzCliCommandRx* instance = malloc(sizeof(SubGhzCliCommandRx));
SubGhzEnvironment* environment = subghz_environment_alloc();
if(subghz_environment_load_keystore(environment, "/ext/subghz/assets/keeloq_mfcodes")) {
if(subghz_environment_load_keystore(
environment, EXT_PATH("subghz/assets/keeloq_mfcodes"))) {
printf("SubGhz decode_raw: Load_keystore keeloq_mfcodes \033[0;32mOK\033[0m\r\n");
} else {
printf("SubGhz decode_raw: Load_keystore keeloq_mfcodes \033[0;31mERROR\033[0m\r\n");
}
if(subghz_environment_load_keystore(
environment, "/ext/subghz/assets/keeloq_mfcodes_user")) {
environment, EXT_PATH("subghz/assets/keeloq_mfcodes_user"))) {
printf("SubGhz decode_raw: Load_keystore keeloq_mfcodes_user \033[0;32mOK\033[0m\r\n");
} else {
printf(
"SubGhz decode_raw: Load_keystore keeloq_mfcodes_user \033[0;31mERROR\033[0m\r\n");
}
subghz_environment_set_came_atomo_rainbow_table_file_name(
environment, "/ext/subghz/assets/came_atomo");
environment, EXT_PATH("subghz/assets/came_atomo"));
subghz_environment_set_nice_flor_s_rainbow_table_file_name(
environment, "/ext/subghz/assets/nice_flor_s");
environment, EXT_PATH("subghz/assets/nice_flor_s"));
SubGhzReceiver* receiver = subghz_receiver_alloc_init(environment);
subghz_receiver_set_filter(receiver, SubGhzProtocolFlag_Decodable);
@@ -569,7 +570,7 @@ static void subghz_cli_command_chat(Cli* cli, string_t args) {
bool exit = false;
SubGhzChatEvent chat_event;
NotificationApp* notification = furi_record_open("notification");
NotificationApp* notification = furi_record_open(RECORD_NOTIFICATION);
string_printf(name, "\033[0;33m%s\033[0m: ", furi_hal_version_get_name_ptr());
string_set(input, name);
@@ -688,7 +689,7 @@ static void subghz_cli_command_chat(Cli* cli, string_t args) {
string_clear(output);
string_clear(sysmsg);
furi_hal_power_suppress_charge_exit();
furi_record_close("notification");
furi_record_close(RECORD_NOTIFICATION);
if(subghz_chat_worker_is_running(subghz_chat)) {
subghz_chat_worker_stop(subghz_chat);
@@ -757,11 +758,11 @@ static void subghz_cli_command(Cli* cli, string_t args, void* context) {
void subghz_on_system_start() {
#ifdef SRV_CLI
Cli* cli = furi_record_open("cli");
Cli* cli = furi_record_open(RECORD_CLI);
cli_add_command(cli, "subghz", CliCommandFlagDefault, subghz_cli_command, NULL);
furi_record_close("cli");
furi_record_close(RECORD_CLI);
#else
UNUSED(subghz_cli_command);
#endif

View File

@@ -226,7 +226,7 @@ bool subghz_key_load(SubGhz* subghz, const char* file_path, bool show_dialog) {
furi_assert(subghz);
furi_assert(file_path);
Storage* storage = furi_record_open("storage");
Storage* storage = furi_record_open(RECORD_STORAGE);
FlipperFormat* fff_data_file = flipper_format_file_alloc(storage);
Stream* fff_data_stream = flipper_format_get_raw_stream(subghz->txrx->fff_data);
@@ -308,7 +308,7 @@ bool subghz_key_load(SubGhz* subghz, const char* file_path, bool show_dialog) {
string_clear(temp_str);
flipper_format_free(fff_data_file);
furi_record_close("storage");
furi_record_close(RECORD_STORAGE);
switch(load_key_state) {
case SubGhzLoadKeyStateParseErr:
@@ -335,7 +335,7 @@ bool subghz_key_load(SubGhz* subghz, const char* file_path, bool show_dialog) {
bool subghz_get_next_name_file(SubGhz* subghz, uint8_t max_len) {
furi_assert(subghz);
Storage* storage = furi_record_open("storage");
Storage* storage = furi_record_open(RECORD_STORAGE);
string_t temp_str;
string_t file_name;
string_t file_path;
@@ -372,7 +372,7 @@ bool subghz_get_next_name_file(SubGhz* subghz, uint8_t max_len) {
string_clear(temp_str);
string_clear(file_path);
string_clear(file_name);
furi_record_close("storage");
furi_record_close(RECORD_STORAGE);
return res;
}
@@ -385,7 +385,7 @@ bool subghz_save_protocol_to_file(
furi_assert(flipper_format);
furi_assert(dev_file_name);
Storage* storage = furi_record_open("storage");
Storage* storage = furi_record_open(RECORD_STORAGE);
Stream* flipper_format_stream = flipper_format_get_raw_stream(flipper_format);
bool saved = false;
@@ -414,7 +414,7 @@ bool subghz_save_protocol_to_file(
saved = true;
} while(0);
string_clear(file_dir);
furi_record_close("storage");
furi_record_close(RECORD_STORAGE);
return saved;
}
@@ -447,7 +447,7 @@ bool subghz_rename_file(SubGhz* subghz) {
furi_assert(subghz);
bool ret = true;
Storage* storage = furi_record_open("storage");
Storage* storage = furi_record_open(RECORD_STORAGE);
if(string_cmp(subghz->file_path_tmp, subghz->file_path)) {
FS_Error fs_result = storage_common_rename(
@@ -458,7 +458,7 @@ bool subghz_rename_file(SubGhz* subghz) {
ret = false;
}
}
furi_record_close("storage");
furi_record_close(RECORD_STORAGE);
return ret;
}
@@ -466,9 +466,9 @@ bool subghz_rename_file(SubGhz* subghz) {
bool subghz_delete_file(SubGhz* subghz) {
furi_assert(subghz);
Storage* storage = furi_record_open("storage");
Storage* storage = furi_record_open(RECORD_STORAGE);
bool result = storage_simply_remove(storage, string_get_cstr(subghz->file_path_tmp));
furi_record_close("storage");
furi_record_close(RECORD_STORAGE);
subghz_file_name_clear(subghz);

View File

@@ -229,7 +229,7 @@ void subghz_setting_load_default(SubGhzSetting* instance) {
void subghz_setting_load(SubGhzSetting* instance, const char* file_path) {
furi_assert(instance);
Storage* storage = furi_record_open("storage");
Storage* storage = furi_record_open(RECORD_STORAGE);
FlipperFormat* fff_data_file = flipper_format_file_alloc(storage);
string_t temp_str;
@@ -318,7 +318,7 @@ void subghz_setting_load(SubGhzSetting* instance, const char* file_path) {
string_clear(temp_str);
flipper_format_free(fff_data_file);
furi_record_close("storage");
furi_record_close(RECORD_STORAGE);
if(!FrequencyList_size(instance->frequencies) ||
!FrequencyList_size(instance->hopper_frequencies)) {

View File

@@ -93,7 +93,7 @@ bool subghz_test_static_input(InputEvent* event, void* context) {
model->real_frequency = subghz_frequencies_testing[model->frequency];
if(event->key == InputKeyOk) {
NotificationApp* notification = furi_record_open("notification");
NotificationApp* notification = furi_record_open(RECORD_NOTIFICATION);
if(event->type == InputTypePress) {
furi_hal_subghz_idle();
furi_hal_subghz_set_frequency_and_path(
@@ -126,7 +126,7 @@ bool subghz_test_static_input(InputEvent* event, void* context) {
}
instance->status_tx = SubGhzTestStaticStatusIDLE;
}
furi_record_close("notification");
furi_record_close(RECORD_NOTIFICATION);
}
return true;