[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:
@@ -50,7 +50,7 @@
|
||||
* const uint16_t array_size = 4;
|
||||
* const uint8_t* array[array_size] = {0x00, 0x01, 0xFF, 0xA3};
|
||||
*
|
||||
* if(!flipper_format_file_open_new(format, "/ext/flipper_format_test")) break;
|
||||
* if(!flipper_format_file_open_new(format, EXT_PATH("flipper_format_test"))) break;
|
||||
* if(!flipper_format_write_header_cstr(format, "Flipper Test File", version)) break;
|
||||
* if(!flipper_format_write_comment_cstr(format, "Just test file")) break;
|
||||
* if(!flipper_format_write_string_cstr(format, "String", string_value)) break;
|
||||
@@ -78,7 +78,7 @@
|
||||
* string_init(file_type);
|
||||
* string_init(string_value);
|
||||
*
|
||||
* if(!flipper_format_file_open_existing(file, "/ext/flipper_format_test")) break;
|
||||
* if(!flipper_format_file_open_existing(file, EXT_PATH("flipper_format_test"))) break;
|
||||
* if(!flipper_format_read_header(file, file_type, &version)) break;
|
||||
* if(!flipper_format_read_string(file, "String", string_value)) break;
|
||||
* if(!flipper_format_read_uint32(file, "UINT", &uint32_value, 1)) break;
|
||||
|
||||
@@ -236,7 +236,7 @@ InfraredWorker* infrared_worker_alloc() {
|
||||
instance->infrared_decoder = infrared_alloc_decoder();
|
||||
instance->infrared_encoder = infrared_alloc_encoder();
|
||||
instance->blink_enable = false;
|
||||
instance->notification = furi_record_open("notification");
|
||||
instance->notification = furi_record_open(RECORD_NOTIFICATION);
|
||||
instance->state = InfraredWorkerStateIdle;
|
||||
|
||||
return instance;
|
||||
@@ -246,7 +246,7 @@ void infrared_worker_free(InfraredWorker* instance) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->state == InfraredWorkerStateIdle);
|
||||
|
||||
furi_record_close("notification");
|
||||
furi_record_close(RECORD_NOTIFICATION);
|
||||
infrared_free_decoder(instance->infrared_decoder);
|
||||
infrared_free_encoder(instance->infrared_encoder);
|
||||
vStreamBufferDelete(instance->stream);
|
||||
|
||||
@@ -87,7 +87,7 @@ bool subghz_protocol_raw_save_to_file_init(
|
||||
FuriHalSubGhzPreset preset) {
|
||||
furi_assert(instance);
|
||||
|
||||
instance->storage = furi_record_open("storage");
|
||||
instance->storage = furi_record_open(RECORD_STORAGE);
|
||||
instance->flipper_file = flipper_format_file_alloc(instance->storage);
|
||||
|
||||
string_t temp_str;
|
||||
@@ -181,7 +181,7 @@ void subghz_protocol_raw_save_to_file_stop(SubGhzProtocolDecoderRAW* instance) {
|
||||
instance->upload_raw = NULL;
|
||||
flipper_format_file_close(instance->flipper_file);
|
||||
flipper_format_free(instance->flipper_file);
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
}
|
||||
|
||||
instance->file_is_open = RAWFileIsOpenClose;
|
||||
|
||||
@@ -183,7 +183,7 @@ SubGhzFileEncoderWorker* subghz_file_encoder_worker_alloc() {
|
||||
furi_thread_set_callback(instance->thread, subghz_file_encoder_worker_thread);
|
||||
instance->stream = xStreamBufferCreate(sizeof(int32_t) * 2048, sizeof(int32_t));
|
||||
|
||||
instance->storage = furi_record_open("storage");
|
||||
instance->storage = furi_record_open(RECORD_STORAGE);
|
||||
instance->flipper_format = flipper_format_file_alloc(instance->storage);
|
||||
|
||||
string_init(instance->str_data);
|
||||
@@ -204,7 +204,7 @@ void subghz_file_encoder_worker_free(SubGhzFileEncoderWorker* instance) {
|
||||
string_clear(instance->file_path);
|
||||
|
||||
flipper_format_free(instance->flipper_format);
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
|
||||
free(instance);
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ bool subghz_keystore_load(SubGhzKeystore* instance, const char* file_name) {
|
||||
|
||||
FURI_LOG_I(TAG, "Loading keystore %s", file_name);
|
||||
|
||||
Storage* storage = furi_record_open("storage");
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
|
||||
FlipperFormat* flipper_format = flipper_format_file_alloc(storage);
|
||||
do {
|
||||
@@ -229,7 +229,7 @@ bool subghz_keystore_load(SubGhzKeystore* instance, const char* file_name) {
|
||||
} while(0);
|
||||
flipper_format_free(flipper_format);
|
||||
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
|
||||
string_clear(filetype);
|
||||
|
||||
@@ -240,7 +240,7 @@ bool subghz_keystore_save(SubGhzKeystore* instance, const char* file_name, uint8
|
||||
furi_assert(instance);
|
||||
bool result = false;
|
||||
|
||||
Storage* storage = furi_record_open("storage");
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
char* decrypted_line = malloc(SUBGHZ_KEYSTORE_FILE_DECRYPTED_LINE_SIZE);
|
||||
char* encrypted_line = malloc(SUBGHZ_KEYSTORE_FILE_ENCRYPTED_LINE_SIZE);
|
||||
|
||||
@@ -326,7 +326,7 @@ bool subghz_keystore_save(SubGhzKeystore* instance, const char* file_name, uint8
|
||||
|
||||
free(encrypted_line);
|
||||
free(decrypted_line);
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -346,7 +346,7 @@ bool subghz_keystore_raw_encrypted_save(
|
||||
string_init(filetype);
|
||||
SubGhzKeystoreEncryption encryption;
|
||||
|
||||
Storage* storage = furi_record_open("storage");
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
|
||||
char* encrypted_line = malloc(SUBGHZ_KEYSTORE_FILE_ENCRYPTED_LINE_SIZE);
|
||||
|
||||
@@ -470,7 +470,7 @@ bool subghz_keystore_raw_encrypted_save(
|
||||
|
||||
free(encrypted_line);
|
||||
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
|
||||
return encrypted;
|
||||
}
|
||||
@@ -484,7 +484,7 @@ bool subghz_keystore_raw_get_data(const char* file_name, size_t offset, uint8_t*
|
||||
string_t str_temp;
|
||||
string_init(str_temp);
|
||||
|
||||
Storage* storage = furi_record_open("storage");
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
char* decrypted_line = malloc(SUBGHZ_KEYSTORE_FILE_DECRYPTED_LINE_SIZE);
|
||||
|
||||
FlipperFormat* flipper_format = flipper_format_file_alloc(storage);
|
||||
@@ -594,7 +594,7 @@ bool subghz_keystore_raw_get_data(const char* file_name, size_t offset, uint8_t*
|
||||
} while(0);
|
||||
flipper_format_free(flipper_format);
|
||||
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
|
||||
free(decrypted_line);
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
#include <furi.h>
|
||||
#include <furi_hal.h>
|
||||
|
||||
#define SUBGHZ_APP_FOLDER "/any/subghz"
|
||||
#define SUBGHZ_RAW_FOLDER "/ext/subghz"
|
||||
#define SUBGHZ_APP_FOLDER ANY_PATH("subghz")
|
||||
#define SUBGHZ_RAW_FOLDER EXT_PATH("subghz")
|
||||
#define SUBGHZ_APP_EXTENSION ".sub"
|
||||
|
||||
#define SUBGHZ_KEY_FILE_VERSION 1
|
||||
|
||||
@@ -55,7 +55,7 @@ static bool dir_walk_filter(DirWalk* dir_walk, const char* name, FileInfo* filei
|
||||
|
||||
static DirWalkResult dir_walk_iter(DirWalk* dir_walk, string_t return_path, FileInfo* fileinfo) {
|
||||
DirWalkResult result = DirWalkError;
|
||||
char* name = malloc(256);
|
||||
char* name = malloc(256); // FIXME: remove magic number
|
||||
FileInfo info;
|
||||
bool end = false;
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ void path_extract_basename(const char* path, string_t basename) {
|
||||
path_cleanup(basename);
|
||||
size_t pos = string_search_rchar(basename, '/');
|
||||
if(pos != STRING_FAILURE) {
|
||||
string_right(basename, pos);
|
||||
string_right(basename, pos + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ bool saved_struct_save(const char* path, void* data, size_t size, uint8_t magic,
|
||||
FURI_LOG_I(TAG, "Saving \"%s\"", path);
|
||||
|
||||
// Store
|
||||
Storage* storage = furi_record_open("storage");
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
File* file = storage_file_alloc(storage);
|
||||
bool result = true;
|
||||
bool saved = storage_file_open(file, path, FSAM_WRITE, FSOM_CREATE_ALWAYS);
|
||||
@@ -58,7 +58,7 @@ bool saved_struct_save(const char* path, void* data, size_t size, uint8_t magic,
|
||||
|
||||
storage_file_close(file);
|
||||
storage_file_free(file);
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ bool saved_struct_load(const char* path, void* data, size_t size, uint8_t magic,
|
||||
SavedStructHeader header;
|
||||
|
||||
uint8_t* data_read = malloc(size);
|
||||
Storage* storage = furi_record_open("storage");
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
File* file = storage_file_alloc(storage);
|
||||
bool result = true;
|
||||
bool loaded = storage_file_open(file, path, FSAM_READ, FSOM_OPEN_EXISTING);
|
||||
@@ -120,7 +120,7 @@ bool saved_struct_load(const char* path, void* data, size_t size, uint8_t magic,
|
||||
|
||||
storage_file_close(file);
|
||||
storage_file_free(file);
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
free(data_read);
|
||||
|
||||
return result;
|
||||
|
||||
@@ -176,8 +176,9 @@ static bool file_stream_delete_and_insert(
|
||||
string_t scratch_name;
|
||||
string_t tmp_name;
|
||||
string_init(tmp_name);
|
||||
storage_get_next_filename(_stream->storage, "/any", ".scratch", ".pad", tmp_name, 255);
|
||||
string_init_printf(scratch_name, "/any/%s.pad", string_get_cstr(tmp_name));
|
||||
storage_get_next_filename(
|
||||
_stream->storage, STORAGE_ANY_PATH_PREFIX, ".scratch", ".pad", tmp_name, 255);
|
||||
string_init_printf(scratch_name, ANY_PATH("%s.pad"), string_get_cstr(tmp_name));
|
||||
string_clear(tmp_name);
|
||||
|
||||
do {
|
||||
|
||||
@@ -165,12 +165,12 @@ bool tar_archive_file_finalize(TarArchive* archive) {
|
||||
typedef struct {
|
||||
TarArchive* archive;
|
||||
const char* work_dir;
|
||||
Storage_name_converter converter;
|
||||
} TarArchiveDirectoryOpParams;
|
||||
|
||||
static int archive_extract_foreach_cb(mtar_t* tar, const mtar_header_t* header, void* param) {
|
||||
TarArchiveDirectoryOpParams* op_params = param;
|
||||
TarArchive* archive = op_params->archive;
|
||||
string_t fname;
|
||||
|
||||
bool skip_entry = false;
|
||||
if(archive->unpack_cb) {
|
||||
@@ -183,12 +183,14 @@ static int archive_extract_foreach_cb(mtar_t* tar, const mtar_header_t* header,
|
||||
return 0;
|
||||
}
|
||||
|
||||
string_t full_extracted_fname;
|
||||
if(header->type == MTAR_TDIR) {
|
||||
string_init(fname);
|
||||
path_concat(op_params->work_dir, header->name, fname);
|
||||
string_init(full_extracted_fname);
|
||||
path_concat(op_params->work_dir, header->name, full_extracted_fname);
|
||||
|
||||
bool create_res = storage_simply_mkdir(archive->storage, string_get_cstr(fname));
|
||||
string_clear(fname);
|
||||
bool create_res =
|
||||
storage_simply_mkdir(archive->storage, string_get_cstr(full_extracted_fname));
|
||||
string_clear(full_extracted_fname);
|
||||
return create_res ? 0 : -1;
|
||||
}
|
||||
|
||||
@@ -197,8 +199,16 @@ static int archive_extract_foreach_cb(mtar_t* tar, const mtar_header_t* header,
|
||||
return 0;
|
||||
}
|
||||
|
||||
string_init(fname);
|
||||
path_concat(op_params->work_dir, header->name, fname);
|
||||
string_init(full_extracted_fname);
|
||||
|
||||
string_t converted_fname;
|
||||
string_init_set(converted_fname, header->name);
|
||||
if(op_params->converter) {
|
||||
op_params->converter(converted_fname);
|
||||
}
|
||||
path_concat(op_params->work_dir, string_get_cstr(converted_fname), full_extracted_fname);
|
||||
string_clear(converted_fname);
|
||||
|
||||
FURI_LOG_I(TAG, "Extracting %d bytes to '%s'", header->size, header->name);
|
||||
File* out_file = storage_file_alloc(archive->storage);
|
||||
uint8_t* readbuf = malloc(FILE_BLOCK_SIZE);
|
||||
@@ -208,10 +218,17 @@ static int archive_extract_foreach_cb(mtar_t* tar, const mtar_header_t* header,
|
||||
do {
|
||||
while(n_tries-- > 0) {
|
||||
if(storage_file_open(
|
||||
out_file, string_get_cstr(fname), FSAM_WRITE, FSOM_CREATE_ALWAYS)) {
|
||||
out_file,
|
||||
string_get_cstr(full_extracted_fname),
|
||||
FSAM_WRITE,
|
||||
FSOM_CREATE_ALWAYS)) {
|
||||
break;
|
||||
}
|
||||
FURI_LOG_W(TAG, "Failed to open '%s', reties: %d", string_get_cstr(fname), n_tries);
|
||||
FURI_LOG_W(
|
||||
TAG,
|
||||
"Failed to open '%s', reties: %d",
|
||||
string_get_cstr(full_extracted_fname),
|
||||
n_tries);
|
||||
storage_file_close(out_file);
|
||||
furi_delay_ms(FILE_OPEN_RETRY_DELAY);
|
||||
}
|
||||
@@ -232,15 +249,19 @@ static int archive_extract_foreach_cb(mtar_t* tar, const mtar_header_t* header,
|
||||
|
||||
storage_file_free(out_file);
|
||||
free(readbuf);
|
||||
string_clear(fname);
|
||||
string_clear(full_extracted_fname);
|
||||
return failed ? -1 : 0;
|
||||
}
|
||||
|
||||
bool tar_archive_unpack_to(TarArchive* archive, const char* destination) {
|
||||
bool tar_archive_unpack_to(
|
||||
TarArchive* archive,
|
||||
const char* destination,
|
||||
Storage_name_converter converter) {
|
||||
furi_assert(archive);
|
||||
TarArchiveDirectoryOpParams param = {
|
||||
.archive = archive,
|
||||
.work_dir = destination,
|
||||
.converter = converter,
|
||||
};
|
||||
|
||||
FURI_LOG_I(TAG, "Restoring '%s'", destination);
|
||||
@@ -313,6 +334,7 @@ bool tar_archive_add_dir(TarArchive* archive, const char* fs_full_path, const ch
|
||||
string_t element_name, element_fs_abs_path;
|
||||
string_init(element_name);
|
||||
string_init(element_fs_abs_path);
|
||||
|
||||
path_concat(fs_full_path, name, element_fs_abs_path);
|
||||
if(strlen(path_prefix)) {
|
||||
path_concat(path_prefix, name, element_name);
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <m-string.h>
|
||||
#include <storage/storage.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -24,7 +26,10 @@ bool tar_archive_open(TarArchive* archive, const char* path, TarOpenMode mode);
|
||||
void tar_archive_free(TarArchive* archive);
|
||||
|
||||
/* High-level API - assumes archive is open */
|
||||
bool tar_archive_unpack_to(TarArchive* archive, const char* destination);
|
||||
bool tar_archive_unpack_to(
|
||||
TarArchive* archive,
|
||||
const char* destination,
|
||||
Storage_name_converter converter);
|
||||
|
||||
bool tar_archive_add_file(
|
||||
TarArchive* archive,
|
||||
|
||||
@@ -2,7 +2,36 @@
|
||||
|
||||
#include <toolbox/tar/tar_archive.h>
|
||||
|
||||
#define LFS_BACKUP_DEFAULT_LOCATION "/ext/" LFS_BACKUP_DEFAULT_FILENAME
|
||||
#include <bt/bt_settings_filename.h>
|
||||
#include <bt/bt_service/bt_keys_filename.h>
|
||||
#include <dolphin/helpers/dolphin_state_filename.h>
|
||||
#include <desktop/helpers/slideshow_filename.h>
|
||||
#include <desktop/desktop_settings/desktop_settings_filename.h>
|
||||
#include <notification/notification_settings_filename.h>
|
||||
|
||||
#define LFS_BACKUP_DEFAULT_LOCATION EXT_PATH(LFS_BACKUP_DEFAULT_FILENAME)
|
||||
|
||||
static void backup_name_converter(string_t filename) {
|
||||
if(string_empty_p(filename) || (string_get_char(filename, 0) == '.')) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Filenames are already prefixed with '.' */
|
||||
const char* const names[] = {
|
||||
BT_SETTINGS_FILE_NAME,
|
||||
BT_KEYS_STORAGE_FILE_NAME,
|
||||
DESKTOP_SETTINGS_FILE_NAME,
|
||||
NOTIFICATION_SETTINGS_FILE_NAME,
|
||||
SLIDESHOW_FILE_NAME,
|
||||
};
|
||||
|
||||
for(size_t i = 0; i < COUNT_OF(names); i++) {
|
||||
if(string_equal_str_p(filename, &names[i][1])) {
|
||||
string_set_str(filename, names[i]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool lfs_backup_create(Storage* storage, const char* destination) {
|
||||
const char* final_destination =
|
||||
@@ -18,5 +47,5 @@ bool lfs_backup_exists(Storage* storage, const char* source) {
|
||||
|
||||
bool lfs_backup_unpack(Storage* storage, const char* source) {
|
||||
const char* final_source = source && strlen(source) ? source : LFS_BACKUP_DEFAULT_LOCATION;
|
||||
return storage_int_restore(storage, final_source) == FSE_OK;
|
||||
return storage_int_restore(storage, final_source, backup_name_converter) == FSE_OK;
|
||||
}
|
||||
|
||||
@@ -157,14 +157,14 @@ bool update_manifest_has_obdata(UpdateManifest* update_manifest) {
|
||||
}
|
||||
|
||||
bool update_manifest_init(UpdateManifest* update_manifest, const char* manifest_filename) {
|
||||
Storage* storage = furi_record_open("storage");
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
FlipperFormat* flipper_file = flipper_format_file_alloc(storage);
|
||||
if(flipper_format_file_open_existing(flipper_file, manifest_filename)) {
|
||||
update_manifest_init_from_ff(update_manifest, flipper_file);
|
||||
}
|
||||
|
||||
flipper_format_free(flipper_file);
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
|
||||
return update_manifest->valid;
|
||||
}
|
||||
|
||||
@@ -9,8 +9,7 @@ extern "C" {
|
||||
#include <m-string.h>
|
||||
#include <furi_hal_flash.h>
|
||||
|
||||
/* Paths don't include /ext -- because at startup SD card is mounted as root */
|
||||
#define UPDATE_DIR_DEFAULT_REL_PATH "/update"
|
||||
/* Paths don't include /ext -- because at startup SD card is mounted as FS root */
|
||||
#define UPDATE_MANIFEST_DEFAULT_NAME "update.fuf"
|
||||
#define UPDATE_MANIFEST_POINTER_FILE_NAME ".fupdate"
|
||||
|
||||
|
||||
@@ -9,9 +9,8 @@
|
||||
#include <lib/toolbox/path.h>
|
||||
#include <lib/toolbox/crc32_calc.h>
|
||||
|
||||
#define UPDATE_ROOT_DIR "/ext" UPDATE_DIR_DEFAULT_REL_PATH
|
||||
#define UPDATE_PREFIX "/ext" UPDATE_DIR_DEFAULT_REL_PATH "/"
|
||||
#define UPDATE_SUFFIX "/" UPDATE_MANIFEST_DEFAULT_NAME
|
||||
#define UPDATE_ROOT_DIR EXT_PATH("update")
|
||||
|
||||
/* Need at least 4 free LFS pages before update */
|
||||
#define UPDATE_MIN_INT_FREE_SPACE 4 * 4 * 1024
|
||||
|
||||
@@ -70,7 +69,7 @@ static bool update_operation_get_current_package_path_rtc(Storage* storage, stri
|
||||
return found;
|
||||
}
|
||||
|
||||
#define UPDATE_FILE_POINTER_FN "/ext/" UPDATE_MANIFEST_POINTER_FILE_NAME
|
||||
#define UPDATE_FILE_POINTER_FN EXT_PATH(UPDATE_MANIFEST_POINTER_FILE_NAME)
|
||||
#define UPDATE_MANIFEST_MAX_PATH_LEN 256u
|
||||
|
||||
bool update_operation_get_current_package_manifest_path(Storage* storage, string_t out_path) {
|
||||
@@ -137,7 +136,7 @@ static bool update_operation_persist_manifest_path(Storage* storage, const char*
|
||||
|
||||
UpdatePrepareResult update_operation_prepare(const char* manifest_file_path) {
|
||||
UpdatePrepareResult result = UpdatePrepareResultIntFull;
|
||||
Storage* storage = furi_record_open("storage");
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
UpdateManifest* manifest = update_manifest_alloc();
|
||||
File* file = storage_file_alloc(storage);
|
||||
|
||||
@@ -145,7 +144,8 @@ UpdatePrepareResult update_operation_prepare(const char* manifest_file_path) {
|
||||
string_t stage_path;
|
||||
string_init(stage_path);
|
||||
do {
|
||||
if((storage_common_fs_info(storage, "/int", NULL, &free_int_space) != FSE_OK) ||
|
||||
if((storage_common_fs_info(storage, STORAGE_INT_PATH_PREFIX, NULL, &free_int_space) !=
|
||||
FSE_OK) ||
|
||||
(free_int_space < UPDATE_MIN_INT_FREE_SPACE)) {
|
||||
break;
|
||||
}
|
||||
@@ -197,7 +197,7 @@ UpdatePrepareResult update_operation_prepare(const char* manifest_file_path) {
|
||||
storage_file_free(file);
|
||||
|
||||
update_manifest_free(manifest);
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -206,10 +206,10 @@ bool update_operation_is_armed() {
|
||||
FuriHalRtcBootMode boot_mode = furi_hal_rtc_get_boot_mode();
|
||||
const uint32_t rtc_upd_index =
|
||||
furi_hal_rtc_get_register(FuriHalRtcRegisterUpdateFolderFSIndex);
|
||||
Storage* storage = furi_record_open("storage");
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
const bool upd_fn_ptr_exists =
|
||||
(storage_common_stat(storage, UPDATE_FILE_POINTER_FN, NULL) == FSE_OK);
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
return (boot_mode >= FuriHalRtcBootModePreUpdate) &&
|
||||
(boot_mode <= FuriHalRtcBootModePostUpdate) &&
|
||||
((rtc_upd_index != INT_MAX) || upd_fn_ptr_exists);
|
||||
@@ -218,7 +218,7 @@ bool update_operation_is_armed() {
|
||||
void update_operation_disarm() {
|
||||
furi_hal_rtc_set_boot_mode(FuriHalRtcBootModeNormal);
|
||||
furi_hal_rtc_set_register(FuriHalRtcRegisterUpdateFolderFSIndex, INT_MAX);
|
||||
Storage* storage = furi_record_open("storage");
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
storage_simply_remove(storage, UPDATE_FILE_POINTER_FN);
|
||||
furi_record_close("storage");
|
||||
}
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user