diff mbox series

[1/3] cpio_util: remove unused cpio_scan

Message ID 20241031055741.91045-1-dominique.martinet@atmark-techno.com
State Accepted
Headers show
Series [1/3] cpio_util: remove unused cpio_scan | expand

Commit Message

Dominique MARTINET Oct. 31, 2024, 5:57 a.m. UTC
Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com>
---
Feel free to ignore this if you already cleaned the function up in your
tree

 core/cpio_utils.c  | 59 ----------------------------------------------
 include/swupdate.h | 17 -------------
 2 files changed, 76 deletions(-)
diff mbox series

Patch

diff --git a/core/cpio_utils.c b/core/cpio_utils.c
index 382b22c36434..1ed5c707c081 100644
--- a/core/cpio_utils.c
+++ b/core/cpio_utils.c
@@ -772,65 +772,6 @@  int extract_img_from_cpio(int fd, unsigned long offset, struct filehdr *fdh)
 	return 0;
 }
 
-int cpio_scan(int fd, struct swupdate_cfg *cfg, off_t start)
-{
-	struct filehdr fdh;
-	unsigned long offset = start;
-	int file_listed;
-	uint32_t checksum;
-
-	while (1) {
-		file_listed = 0;
-		start = offset;
-		if (extract_cpio_header(fd, &fdh, &offset)) {
-			return -1;
-		}
-		if (strcmp("TRAILER!!!", fdh.filename) == 0) {
-			return 0;
-		}
-
-		struct img_type *img = NULL;
-		SEARCH_FILE(img, cfg->images, file_listed, start);
-		SEARCH_FILE(img, cfg->scripts, file_listed, start);
-		SEARCH_FILE(img, cfg->bootscripts, file_listed, start);
-
-		TRACE("Found file:\n\tfilename %s\n\tsize %lu\n\t%s",
-			fdh.filename,
-			fdh.size,
-			file_listed ? "REQUIRED" : "not required");
-
-		/*
-		 * use copyfile for checksum and hash verification, as we skip file
-		 * we do not have to provide fdout
-		 */
-		struct swupdate_copy copy = {
-			.fdin = fd,
-			.nbytes = fdh.size,
-			.offs = &offset,
-			.skip_file = 1,
-			.checksum = &checksum,
-			.hash = img ? img->sha256 : NULL,
-		};
-		if (copyfile(&copy) != 0) {
-			ERROR("invalid archive");
-			return -1;
-		}
-
-		if (!swupdate_verify_chksum(checksum, &fdh)) {
-			return -1;
-		}
-
-		/* Next header must be 4-bytes aligned */
-		offset += NPAD_BYTES(offset);
-		if (lseek(fd, offset, SEEK_SET) < 0) {
-			ERROR("CPIO file corrupted : %s", strerror(errno));
-			return -1;
-		}
-	}
-
-	return 0;
-}
-
 bool swupdate_verify_chksum(const uint32_t chk1, struct filehdr *fhdr) {
 	bool ret = (chk1 == fhdr->chksum);
 	if (fhdr->format == CPIO_NEWASCII)
diff --git a/include/swupdate.h b/include/swupdate.h
index 7cf421047187..6a60d357d2fd 100644
--- a/include/swupdate.h
+++ b/include/swupdate.h
@@ -88,22 +88,5 @@  struct swupdate_cfg {
 	char gpgme_protocol[SWUPDATE_GENERAL_STRING_SIZE];
 };
 
-#define SEARCH_FILE(img, list, found, offs) do { \
-	if (!found) { \
-		for (img = list.lh_first; img != NULL; \
-			img = img->next.le_next) { \
-			if (strcmp(img->fname, fdh.filename) == 0) { \
-				found = 1; \
-				img->offset = offs; \
-				img->provided = 1; \
-				img->size = fdh.size; \
-			} \
-		} \
-		if (!found) \
-			img = NULL; \
-	} \
-} while(0)
-
-int cpio_scan(int fd, struct swupdate_cfg *cfg, off_t start);
 struct swupdate_cfg *get_swupdate_cfg(void);
 void free_image(struct img_type *img);