summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHung-Te Lin <hungte@chromium.org>2022-05-12 14:16:31 +0800
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-05-15 13:02:14 +0000
commite399c71caa6f2b1fccc6dd6ee6e1f07dc7fc7aab (patch)
tree9117ec2787d270ffbdd19a7468d9b4ee6a3a0d59
parent8f851be54880fd941f2b49f5fa0419071eb89d81 (diff)
downloadvboot-e399c71caa6f2b1fccc6dd6ee6e1f07dc7fc7aab.tar.gz
futility: updater: refactor 'archive' structure name
Rename 'struct archive' to 'struct u_archive' as 'updater archive' so in future we can support libarchive (which needs 'struct archive'). BUG=None TEST=make; run test BRANCH=None Change-Id: Id4e5b425044b6f1e64f504373c264dba05da62f4 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3644539 Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
-rw-r--r--futility/updater.c6
-rw-r--r--futility/updater.h22
-rw-r--r--futility/updater_archive.c46
-rw-r--r--futility/updater_utils.c2
-rw-r--r--futility/updater_utils.h4
5 files changed, 40 insertions, 40 deletions
diff --git a/futility/updater.c b/futility/updater.c
index b8bb48b0..dcbc4450 100644
--- a/futility/updater.c
+++ b/futility/updater.c
@@ -1290,7 +1290,7 @@ static int updater_load_images(struct updater_config *cfg,
const char *pd_image)
{
int errorcnt = 0;
- struct archive *ar = cfg->archive;
+ struct u_archive *ar = cfg->archive;
if (!cfg->image.data && image) {
if (image && strcmp(image, "-") == 0) {
@@ -1379,7 +1379,7 @@ static int updater_setup_archive(
int is_factory)
{
int errorcnt = 0;
- struct archive *ar = cfg->archive;
+ struct u_archive *ar = cfg->archive;
const struct model_config *model;
if (arg->do_manifest) {
@@ -1540,7 +1540,7 @@ int updater_setup_config(struct updater_config *cfg,
/* Process archives which may not have valid contents. */
if (arg->repack || arg->unpack) {
const char *work_name = arg->repack ? arg->repack : arg->unpack;
- struct archive *from, *to, *work;
+ struct u_archive *from, *to, *work;
work = archive_open(work_name);
if (arg->repack) {
diff --git a/futility/updater.h b/futility/updater.h
index 77f47260..3dee7195 100644
--- a/futility/updater.h
+++ b/futility/updater.h
@@ -65,7 +65,7 @@ struct updater_config {
struct firmware_image ec_image, pd_image;
struct system_property system_properties[SYS_PROP_MAX];
struct quirk_entry quirks[QUIRK_MAX];
- struct archive *archive;
+ struct u_archive *archive;
struct tempfile tempfiles;
int try_update;
int force_update;
@@ -112,7 +112,7 @@ struct model_config {
struct manifest {
int num;
struct model_config *models;
- struct archive *archive;
+ struct u_archive *archive;
int default_model;
int has_keyset;
};
@@ -208,26 +208,26 @@ int quirk_override_signature_id(struct updater_config *cfg,
* Returns a pointer to reference to archive (must be released by archive_close
* when not used), otherwise NULL on error.
*/
-struct archive *archive_open(const char *path);
+struct u_archive *archive_open(const char *path);
/*
* Closes an archive reference.
* Returns 0 on success, otherwise non-zero as failure.
*/
-int archive_close(struct archive *ar);
+int archive_close(struct u_archive *ar);
/*
* Checks if an entry (either file or directory) exists in archive.
* Returns 1 if exists, otherwise 0
*/
-int archive_has_entry(struct archive *ar, const char *name);
+int archive_has_entry(struct u_archive *ar, const char *name);
/*
* Reads a file from archive.
* Returns 0 on success (data and size reflects the file content),
* otherwise non-zero as failure.
*/
-int archive_read_file(struct archive *ar, const char *fname,
+int archive_read_file(struct u_archive *ar, const char *fname,
uint8_t **data, uint32_t *size, int64_t *mtime);
/*
@@ -236,20 +236,20 @@ int archive_read_file(struct archive *ar, const char *fname,
* file system.
* Returns 0 on success, otherwise non-zero as failure.
*/
-int archive_write_file(struct archive *ar, const char *fname,
+int archive_write_file(struct u_archive *ar, const char *fname,
uint8_t *data, uint32_t size, int64_t mtime);
/*
* Copies all entries from one archive to another.
* Returns 0 on success, otherwise non-zero as failure.
*/
-int archive_copy(struct archive *from, struct archive *to);
+int archive_copy(struct u_archive *from, struct u_archive *to);
/*
* Creates a new manifest object by scanning files in archive.
* Returns the manifest on success, otherwise NULL for failure.
*/
-struct manifest *new_manifest_from_archive(struct archive *archive);
+struct manifest *new_manifest_from_archive(struct u_archive *archive);
/* Releases all resources allocated by given manifest object. */
void delete_manifest(struct manifest *manifest);
@@ -263,7 +263,7 @@ void print_json_manifest(const struct manifest *manifest);
*/
int patch_image_by_model(
struct firmware_image *image, const struct model_config *model,
- struct archive *archive);
+ struct u_archive *archive);
/*
* Finds the existing model_config from manifest that best matches current
@@ -281,7 +281,7 @@ const struct model_config *manifest_find_model(const struct manifest *manifest,
*/
int model_apply_custom_label(
struct model_config *model,
- struct archive *archive,
+ struct u_archive *archive,
const char *signature_id,
const char *image);
diff --git a/futility/updater_archive.c b/futility/updater_archive.c
index 03f1827a..aa3e2f93 100644
--- a/futility/updater_archive.c
+++ b/futility/updater_archive.c
@@ -88,7 +88,7 @@ static const char * const SETVARS_IMAGE_MAIN = "IMAGE_MAIN",
* const PATH_SIGNER_CONFIG = "signer_config.csv",
* const PATH_ENDSWITH_SETVARS = "/setvars.sh";
-struct archive {
+struct u_archive {
void *handle;
void * (*open)(const char *name);
@@ -358,17 +358,17 @@ static int archive_zip_write_file(void *handle, const char *fname,
* Returns a pointer to reference to archive (must be released by archive_close
* when not used), otherwise NULL on error.
*/
-struct archive *archive_open(const char *path)
+struct u_archive *archive_open(const char *path)
{
struct stat path_stat;
- struct archive *ar;
+ struct u_archive *ar;
if (stat(path, &path_stat) != 0) {
ERROR("Cannot identify type of path: %s\n", path);
return NULL;
}
- ar = (struct archive *)malloc(sizeof(*ar));
+ ar = (struct u_archive *)malloc(sizeof(*ar));
if (!ar) {
ERROR("Internal error: allocation failure.\n");
return NULL;
@@ -412,7 +412,7 @@ struct archive *archive_open(const char *path)
* Closes an archive reference.
* Returns 0 on success, otherwise non-zero as failure.
*/
-int archive_close(struct archive *ar)
+int archive_close(struct u_archive *ar)
{
int r = ar->close(ar->handle);
free(ar);
@@ -425,7 +425,7 @@ int archive_close(struct archive *ar)
* with real file system.
* Returns 1 if exists, otherwise 0
*/
-int archive_has_entry(struct archive *ar, const char *name)
+int archive_has_entry(struct u_archive *ar, const char *name)
{
if (!ar || *name == '/')
return archive_fallback_has_entry(NULL, name);
@@ -439,7 +439,7 @@ int archive_has_entry(struct archive *ar, const char *name)
* The arg argument will also be passed to callback.
* Returns 0 on success otherwise non-zero as failure.
*/
-static int archive_walk(struct archive *ar, void *arg,
+static int archive_walk(struct u_archive *ar, void *arg,
int (*callback)(const char *path, void *arg))
{
if (!ar)
@@ -456,7 +456,7 @@ static int archive_walk(struct archive *ar, void *arg,
* Returns 0 on success (data and size reflects the file content),
* otherwise non-zero as failure.
*/
-int archive_read_file(struct archive *ar, const char *fname,
+int archive_read_file(struct u_archive *ar, const char *fname,
uint8_t **data, uint32_t *size, int64_t *mtime)
{
if (!ar || *fname == '/')
@@ -470,7 +470,7 @@ int archive_read_file(struct archive *ar, const char *fname,
* file system.
* Returns 0 on success, otherwise non-zero as failure.
*/
-int archive_write_file(struct archive *ar, const char *fname,
+int archive_write_file(struct u_archive *ar, const char *fname,
uint8_t *data, uint32_t size, int64_t mtime)
{
if (!ar || *fname == '/')
@@ -479,7 +479,7 @@ int archive_write_file(struct archive *ar, const char *fname,
}
struct _copy_arg {
- struct archive *from, *to;
+ struct u_archive *from, *to;
};
/* Callback for archive_copy. */
@@ -506,7 +506,7 @@ static int archive_copy_callback(const char *path, void *_arg)
* Copies all entries from one archive to another.
* Returns 0 on success, otherwise non-zero as failure.
*/
-int archive_copy(struct archive *from, struct archive *to)
+int archive_copy(struct u_archive *from, struct u_archive *to)
{
struct _copy_arg arg = { .from = from, .to = to };
return archive_walk(from, &arg, archive_copy_callback);
@@ -566,7 +566,7 @@ static char *vpd_get_value(const char *fpath, const char *key)
* Returns 0 on success (at least one entry found), otherwise failure.
*/
static int model_config_parse_setvars_file(
- struct model_config *cfg, struct archive *archive,
+ struct model_config *cfg, struct u_archive *archive,
const char *fpath)
{
uint8_t *data;
@@ -680,7 +680,7 @@ static int change_vblock(struct firmware_image *image, const char *section_name,
*/
static int apply_key_file(
struct firmware_image *image, const char *path,
- struct archive *archive, const char *section_name,
+ struct u_archive *archive, const char *section_name,
int (*apply)(struct firmware_image *image, const char *section,
const uint8_t *data, uint32_t len))
{
@@ -707,7 +707,7 @@ static int apply_key_file(
*/
int patch_image_by_model(
struct firmware_image *image, const struct model_config *model,
- struct archive *archive)
+ struct u_archive *archive)
{
int err = 0;
if (model->patches.rootkey)
@@ -730,7 +730,7 @@ int patch_image_by_model(
* Updates `model` argument with path of patch files.
*/
static void find_patches_for_model(struct model_config *model,
- struct archive *archive,
+ struct u_archive *archive,
const char *signature_id)
{
char *path;
@@ -786,7 +786,7 @@ static struct model_config *manifest_add_model(
static int manifest_scan_entries(const char *name, void *arg)
{
struct manifest *manifest = (struct manifest *)arg;
- struct archive *archive = manifest->archive;
+ struct u_archive *archive = manifest->archive;
struct model_config model = {0};
char *slash;
@@ -833,7 +833,7 @@ static int manifest_scan_entries(const char *name, void *arg)
static int manifest_scan_raw_entries(const char *name, void *arg)
{
struct manifest *manifest = (struct manifest *)arg;
- struct archive *archive = manifest->archive;
+ struct u_archive *archive = manifest->archive;
struct model_config model = {0};
char *ec_name = NULL, *zephyr_name = NULL;
int chars_read = 0;
@@ -887,7 +887,7 @@ static struct model_config *manifest_get_model_config(
*/
static int manifest_from_signer_config(struct manifest *manifest)
{
- struct archive *archive = manifest->archive;
+ struct u_archive *archive = manifest->archive;
uint32_t size;
uint8_t *data;
char *s, *tok_ptr = NULL;
@@ -991,7 +991,7 @@ static int manifest_from_simple_folder(struct manifest *manifest)
* const old_host_image_name = "bios.bin",
* const ec_name = "ec.bin",
* const pd_name = "pd.bin";
- struct archive *archive = manifest->archive;
+ struct u_archive *archive = manifest->archive;
const char *image_name = NULL;
struct firmware_image image = {0};
struct model_config model = {0};
@@ -1169,7 +1169,7 @@ static char *resolve_signature_id(struct model_config *model, const char *image)
*/
int model_apply_custom_label(
struct model_config *model,
- struct archive *archive,
+ struct u_archive *archive,
const char *signature_id,
const char *image)
{
@@ -1204,7 +1204,7 @@ int model_apply_custom_label(
* Creates a new manifest object by scanning files in archive.
* Returns the manifest on success, otherwise NULL for failure.
*/
-struct manifest *new_manifest_from_archive(struct archive *archive)
+struct manifest *new_manifest_from_archive(struct u_archive *archive)
{
struct manifest manifest = {0}, *new_manifest;
@@ -1279,7 +1279,7 @@ static const char *get_gbb_key_hash(const struct vb2_gbb_header *gbb,
/* Prints the information of given image file in JSON format. */
static void print_json_image(
const char *name, const char *fpath, struct model_config *m,
- struct archive *archive, int indent, int is_host)
+ struct u_archive *archive, int indent, int is_host)
{
struct firmware_image image = {0};
const struct vb2_gbb_header *gbb = NULL;
@@ -1313,7 +1313,7 @@ static void print_json_image(
void print_json_manifest(const struct manifest *manifest)
{
int i, indent;
- struct archive *ar = manifest->archive;
+ struct u_archive *ar = manifest->archive;
printf("{\n");
for (i = 0, indent = 2; i < manifest->num; i++) {
diff --git a/futility/updater_utils.c b/futility/updater_utils.c
index 37f3be31..d879f783 100644
--- a/futility/updater_utils.c
+++ b/futility/updater_utils.c
@@ -209,7 +209,7 @@ static int parse_firmware_image(struct firmware_image *image)
* failure, or IMAGE_PARSE_FAILURE for non-vboot images.
*/
int load_firmware_image(struct firmware_image *image, const char *file_name,
- struct archive *archive)
+ struct u_archive *archive)
{
if (!file_name) {
ERROR("No file name given\n");
diff --git a/futility/updater_utils.h b/futility/updater_utils.h
index a433ead1..a99c38c4 100644
--- a/futility/updater_utils.h
+++ b/futility/updater_utils.h
@@ -16,7 +16,7 @@
ERROR("Failed to allocate memory, abort.\n"); exit(1); } while (0)
/* Structure(s) declared in updater_archive */
-struct archive;
+struct u_archive;
/* flashrom programmers. */
static const char * const PROG_HOST = "host",
@@ -89,7 +89,7 @@ enum {
* failure, or IMAGE_PARSE_FAILURE for non-vboot images.
*/
int load_firmware_image(struct firmware_image *image, const char *file_name,
- struct archive *archive);
+ struct u_archive *archive);
/* Structure(s) declared in updater.h */
struct updater_config;