[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

@@ -33,7 +33,7 @@ static void bt_cli_command_carrier_tx(Cli* cli, string_t args, void* context) {
break;
}
Bt* bt = furi_record_open("bt");
Bt* bt = furi_record_open(RECORD_BT);
bt_disconnect(bt);
furi_hal_bt_reinit();
printf("Transmitting carrier at %d channel at %d dB power\r\n", channel, power);
@@ -46,7 +46,7 @@ static void bt_cli_command_carrier_tx(Cli* cli, string_t args, void* context) {
furi_hal_bt_stop_tone_tx();
bt_set_profile(bt, BtProfileSerial);
furi_record_close("bt");
furi_record_close(RECORD_BT);
} while(false);
}
@@ -60,7 +60,7 @@ static void bt_cli_command_carrier_rx(Cli* cli, string_t args, void* context) {
break;
}
Bt* bt = furi_record_open("bt");
Bt* bt = furi_record_open(RECORD_BT);
bt_disconnect(bt);
furi_hal_bt_reinit();
printf("Receiving carrier at %d channel\r\n", channel);
@@ -77,7 +77,7 @@ static void bt_cli_command_carrier_rx(Cli* cli, string_t args, void* context) {
furi_hal_bt_stop_packet_test();
bt_set_profile(bt, BtProfileSerial);
furi_record_close("bt");
furi_record_close(RECORD_BT);
} while(false);
}
@@ -107,7 +107,7 @@ static void bt_cli_command_packet_tx(Cli* cli, string_t args, void* context) {
break;
}
Bt* bt = furi_record_open("bt");
Bt* bt = furi_record_open(RECORD_BT);
bt_disconnect(bt);
furi_hal_bt_reinit();
printf(
@@ -125,7 +125,7 @@ static void bt_cli_command_packet_tx(Cli* cli, string_t args, void* context) {
printf("Transmitted %lu packets", furi_hal_bt_get_transmitted_packets());
bt_set_profile(bt, BtProfileSerial);
furi_record_close("bt");
furi_record_close(RECORD_BT);
} while(false);
}
@@ -144,7 +144,7 @@ static void bt_cli_command_packet_rx(Cli* cli, string_t args, void* context) {
break;
}
Bt* bt = furi_record_open("bt");
Bt* bt = furi_record_open(RECORD_BT);
bt_disconnect(bt);
furi_hal_bt_reinit();
printf("Receiving packets at %d channel at %d M datarate\r\n", channel, datarate);
@@ -160,7 +160,7 @@ static void bt_cli_command_packet_rx(Cli* cli, string_t args, void* context) {
printf("Received %hu packets", packets_received);
bt_set_profile(bt, BtProfileSerial);
furi_record_close("bt");
furi_record_close(RECORD_BT);
} while(false);
}
@@ -180,7 +180,7 @@ static void bt_cli_print_usage() {
static void bt_cli(Cli* cli, string_t args, void* context) {
UNUSED(context);
furi_record_open("bt");
furi_record_open(RECORD_BT);
string_t cmd;
string_init(cmd);
@@ -223,14 +223,14 @@ static void bt_cli(Cli* cli, string_t args, void* context) {
}
string_clear(cmd);
furi_record_close("bt");
furi_record_close(RECORD_BT);
}
void bt_on_system_start() {
#ifdef SRV_CLI
Cli* cli = furi_record_open("cli");
cli_add_command(cli, "bt", CliCommandFlagDefault, bt_cli, NULL);
furi_record_close("cli");
Cli* cli = furi_record_open(RECORD_CLI);
cli_add_command(cli, RECORD_BT, CliCommandFlagDefault, bt_cli, NULL);
furi_record_close(RECORD_CLI);
#else
UNUSED(bt_cli);
#endif

View File

@@ -35,7 +35,7 @@ BtDebugApp* bt_debug_app_alloc() {
bt_settings_load(&app->settings);
// Gui
app->gui = furi_record_open("gui");
app->gui = furi_record_open(RECORD_GUI);
// View dispatcher
app->view_dispatcher = view_dispatcher_alloc();
@@ -88,7 +88,7 @@ void bt_debug_app_free(BtDebugApp* app) {
view_dispatcher_free(app->view_dispatcher);
// Close gui record
furi_record_close("gui");
furi_record_close(RECORD_GUI);
app->gui = NULL;
// Free rest
@@ -99,7 +99,7 @@ int32_t bt_debug_app(void* p) {
UNUSED(p);
if(!furi_hal_bt_is_testing_supported()) {
FURI_LOG_E(TAG, "Incorrect radio stack: radio testing fetures are absent.");
DialogsApp* dialogs = furi_record_open("dialogs");
DialogsApp* dialogs = furi_record_open(RECORD_DIALOGS);
dialog_message_show_storage_error(dialogs, "Incorrect\nRadioStack");
return 255;
}

View File

@@ -70,13 +70,13 @@ BtHid* bt_hid_app_alloc() {
BtHid* app = malloc(sizeof(BtHid));
// Gui
app->gui = furi_record_open("gui");
app->gui = furi_record_open(RECORD_GUI);
// Bt
app->bt = furi_record_open("bt");
app->bt = furi_record_open(RECORD_BT);
// Notifications
app->notifications = furi_record_open("notification");
app->notifications = furi_record_open(RECORD_NOTIFICATION);
// View dispatcher
app->view_dispatcher = view_dispatcher_alloc();
@@ -161,11 +161,11 @@ void bt_hid_app_free(BtHid* app) {
view_dispatcher_free(app->view_dispatcher);
// Close records
furi_record_close("gui");
furi_record_close(RECORD_GUI);
app->gui = NULL;
furi_record_close("notification");
furi_record_close(RECORD_NOTIFICATION);
app->notifications = NULL;
furi_record_close("bt");
furi_record_close(RECORD_BT);
app->bt = NULL;
// Free rest

View File

@@ -124,23 +124,23 @@ Bt* bt_alloc() {
// Pin code view port
bt->pin_code_view_port = bt_pin_code_view_port_alloc(bt);
// Notification
bt->notification = furi_record_open("notification");
bt->notification = furi_record_open(RECORD_NOTIFICATION);
// Gui
bt->gui = furi_record_open("gui");
bt->gui = furi_record_open(RECORD_GUI);
gui_add_view_port(bt->gui, bt->statusbar_view_port, GuiLayerStatusBarLeft);
gui_add_view_port(bt->gui, bt->pin_code_view_port, GuiLayerFullscreen);
// Dialogs
bt->dialogs = furi_record_open("dialogs");
bt->dialogs = furi_record_open(RECORD_DIALOGS);
bt->dialog_message = dialog_message_alloc();
// Power
bt->power = furi_record_open("power");
bt->power = furi_record_open(RECORD_POWER);
FuriPubSub* power_pubsub = power_get_pubsub(bt->power);
furi_pubsub_subscribe(power_pubsub, bt_battery_level_changed_callback, bt);
// RPC
bt->rpc = furi_record_open("rpc");
bt->rpc = furi_record_open(RECORD_RPC);
bt->rpc_event = furi_event_flag_alloc();
// API evnent
@@ -353,7 +353,7 @@ int32_t bt_srv() {
if(furi_hal_rtc_get_boot_mode() != FuriHalRtcBootModeNormal) {
FURI_LOG_W(TAG, "Skipped BT init: device in special startup mode");
ble_glue_wait_for_c2_start(FURI_HAL_BT_C2_START_TIMEOUT);
furi_record_create("bt", bt);
furi_record_create(RECORD_BT, bt);
return 0;
}
@@ -381,7 +381,7 @@ int32_t bt_srv() {
bt->status = BtStatusUnavailable;
}
furi_record_create("bt", bt);
furi_record_create(RECORD_BT, bt);
BtMessage message;
while(1) {

View File

@@ -7,6 +7,8 @@
extern "C" {
#endif
#define RECORD_BT "bt"
typedef struct Bt Bt;
typedef enum {

View File

@@ -0,0 +1,3 @@
#pragma once
#define BT_KEYS_STORAGE_FILE_NAME ".bt.keys"

View File

@@ -2,8 +2,9 @@
#include <furi.h>
#include <lib/toolbox/saved_struct.h>
#include <storage/storage.h>
#define BT_KEYS_STORAGE_PATH "/int/bt.keys"
#define BT_KEYS_STORAGE_PATH INT_PATH(BT_KEYS_STORAGE_FILE_NAME)
#define BT_KEYS_STORAGE_VERSION (0)
#define BT_KEYS_STORAGE_MAGIC (0x18)

View File

@@ -1,6 +1,7 @@
#pragma once
#include "bt_i.h"
#include "bt_keys_filename.h"
bool bt_keys_storage_load(Bt* bt);

View File

@@ -2,8 +2,9 @@
#include <furi.h>
#include <lib/toolbox/saved_struct.h>
#include <storage/storage.h>
#define BT_SETTINGS_PATH "/int/bt.settings"
#define BT_SETTINGS_PATH INT_PATH(BT_SETTINGS_FILE_NAME)
#define BT_SETTINGS_VERSION (0)
#define BT_SETTINGS_MAGIC (0x19)

View File

@@ -1,5 +1,7 @@
#pragma once
#include "bt_settings_filename.h"
#include <stdint.h>
#include <stdbool.h>

View File

@@ -17,8 +17,8 @@ BtSettingsApp* bt_settings_app_alloc() {
// Load settings
bt_settings_load(&app->settings);
app->gui = furi_record_open("gui");
app->bt = furi_record_open("bt");
app->gui = furi_record_open(RECORD_GUI);
app->bt = furi_record_open(RECORD_BT);
// View Dispatcher and Scene Manager
app->view_dispatcher = view_dispatcher_alloc();
@@ -70,8 +70,8 @@ void bt_settings_app_free(BtSettingsApp* app) {
scene_manager_free(app->scene_manager);
// Records
furi_record_close("gui");
furi_record_close("bt");
furi_record_close(RECORD_GUI);
furi_record_close(RECORD_BT);
free(app);
}

View File

@@ -0,0 +1,3 @@
#pragma once
#define BT_SETTINGS_FILE_NAME ".bt.settings"