update_operation.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #pragma once
  2. #include <stdbool.h>
  3. #include <m-string.h>
  4. #include <storage/storage.h>
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8. #define UPDATE_OPERATION_ROOT_DIR_PACKAGE_MAGIC 0
  9. #define UPDATE_OPERATION_MAX_MANIFEST_PATH_LEN 255u
  10. #define UPDATE_OPERATION_MIN_MANIFEST_VERSION 2
  11. /*
  12. * Checks if supplied full manifest path is valid
  13. * @param full_path Full path to manifest file. Must be named UPDATE_MANIFEST_DEFAULT_NAME
  14. * @param out_manifest_dir Directory to apply update from, if supplied path is valid.
  15. * May be empty if update is in root update directory
  16. * @return bool if supplied path is valid and out_manifest_dir contains dir to apply
  17. */
  18. bool update_operation_get_package_dir_name(const char* full_path, string_t out_manifest_dir);
  19. /* When updating this enum, also update assets/protobuf/system.proto */
  20. typedef enum {
  21. UpdatePrepareResultOK,
  22. UpdatePrepareResultManifestPathInvalid,
  23. UpdatePrepareResultManifestFolderNotFound,
  24. UpdatePrepareResultManifestInvalid,
  25. UpdatePrepareResultStageMissing,
  26. UpdatePrepareResultStageIntegrityError,
  27. UpdatePrepareResultManifestPointerError,
  28. UpdatePrepareResultTargetMismatch,
  29. UpdatePrepareResultOutdatedManifestVersion,
  30. UpdatePrepareResultIntFull,
  31. UpdatePrepareResultUnspecifiedError,
  32. } UpdatePrepareResult;
  33. const char* update_operation_describe_preparation_result(const UpdatePrepareResult value);
  34. /*
  35. * Validates next stage and sets up registers to apply update after restart
  36. * @param manifest_dir_path Full path to manifest for update to apply
  37. * @return UpdatePrepareResult validation & arm result
  38. */
  39. UpdatePrepareResult update_operation_prepare(const char* manifest_file_path);
  40. /*
  41. * Gets filesystem path for current update package
  42. * @param storage Storage API
  43. * @param out_path Path to manifest. Must be initialized
  44. * @return true if path was restored successfully
  45. */
  46. bool update_operation_get_current_package_manifest_path(Storage* storage, string_t out_path);
  47. /*
  48. * Checks if an update operation step is pending after reset
  49. */
  50. bool update_operation_is_armed();
  51. /*
  52. * Cancels pending update operation
  53. */
  54. void update_operation_disarm();
  55. #ifdef __cplusplus
  56. }
  57. #endif