unleashed-firmware/applications/storage/storage_internal_api.c
hedger 056446dfed
[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>
2022-07-26 21:21:51 +09:00

22 lines
898 B
C

#include <core/record.h>
#include <m-string.h>
#include "storage.h"
#include <toolbox/tar/tar_archive.h>
FS_Error storage_int_backup(Storage* api, const char* dstname) {
TarArchive* archive = tar_archive_alloc(api);
bool success = tar_archive_open(archive, dstname, TAR_OPEN_MODE_WRITE) &&
tar_archive_add_dir(archive, STORAGE_INT_PATH_PREFIX, "") &&
tar_archive_finalize(archive);
tar_archive_free(archive);
return success ? FSE_OK : FSE_INTERNAL;
}
FS_Error storage_int_restore(Storage* api, const char* srcname, Storage_name_converter converter) {
TarArchive* archive = tar_archive_alloc(api);
bool success = tar_archive_open(archive, srcname, TAR_OPEN_MODE_READ) &&
tar_archive_unpack_to(archive, STORAGE_INT_PATH_PREFIX, converter);
tar_archive_free(archive);
return success ? FSE_OK : FSE_INTERNAL;
}