diff mbox series

[V2,03/10] util: Remove unused function extract_next_file

Message ID 20231204100620.27789-4-Michael.Glembotzki@iris-sensing.com
State Changes Requested
Headers show
Series [V2,01/10] util: BUG: set_aes_key does not fail on invalid aes key or ivt | expand

Commit Message

Michael Glembotzki Dec. 4, 2023, 10:05 a.m. UTC
---
 core/cpio_utils.c | 46 ----------------------------------------------
 include/util.h    |  2 --
 2 files changed, 48 deletions(-)

Comments

Stefano Babic Dec. 11, 2023, 7:41 p.m. UTC | #1
Hi Michael,

On 04.12.23 11:05, Michael Glembotzki wrote:
> ---
>   core/cpio_utils.c | 46 ----------------------------------------------
>   include/util.h    |  2 --
>   2 files changed, 48 deletions(-)
> 
> diff --git a/core/cpio_utils.c b/core/cpio_utils.c
> index 7049f73..0a6ebc1 100644
> --- a/core/cpio_utils.c
> +++ b/core/cpio_utils.c
> @@ -807,52 +807,6 @@ int extract_img_from_cpio(int fd, unsigned long offset, struct filehdr *fdh)
>   	return 0;
>   }
>   
> -off_t extract_next_file(int fd, int fdout, off_t start, int compressed,
> -		int encrypted, char *ivt, unsigned char *hash)
> -{
> -	int ret;
> -	struct filehdr fdh;
> -	uint32_t checksum = 0;
> -	unsigned long offset = start;
> -
> -	ret = lseek(fd, offset, SEEK_SET);
> -	if (ret < 0) {
> -		ERROR("CPIO file corrupted : %s",
> -		strerror(errno));
> -		return ret;
> -	}
> -
> -	ret = extract_cpio_header(fd, &fdh, &offset);
> -	if (ret) {
> -		ERROR("CPIO Header wrong");
> -		return ret;
> -	}
> -
> -	ret = lseek(fd, offset, SEEK_SET);
> -	if (ret < 0) {
> -		ERROR("CPIO file corrupted : %s", strerror(errno));
> -		return ret;
> -	}
> -
> -	ret = copyfile(fd, &fdout, fdh.size, &offset, 0, 0, compressed, &checksum, hash, encrypted, ivt, NULL);
> -	if (ret < 0) {
> -		ERROR("Error copying extracted file");
> -		return ret;
> -	}
> -
> -	TRACE("Copied file:\n\tfilename %s\n\tsize %u\n\tchecksum 0x%lx %s",
> -		fdh.filename,
> -		(unsigned int)fdh.size,
> -		(unsigned long)checksum,
> -		(checksum == fdh.chksum) ? "VERIFIED" : "WRONG");
> -
> -	if (!swupdate_verify_chksum(checksum, &fdh)) {
> -		return -EINVAL;
> -	}
> -
> -	return offset;
> -}
> -
>   int cpio_scan(int fd, struct swupdate_cfg *cfg, off_t start)
>   {
>   	struct filehdr fdh;
> diff --git a/include/util.h b/include/util.h
> index afe3a4f..958274c 100644
> --- a/include/util.h
> +++ b/include/util.h
> @@ -207,8 +207,6 @@ int copyfile(int fdin, void *out, size_t nbytes, unsigned long *offs,
>   int copyimage(void *out, struct img_type *img, writeimage callback);
>   int copybuffer(unsigned char *inbuf, void *out, size_t nbytes, int compressed,
>   	unsigned char *hash, bool encrypted, const char *imgivt, writeimage callback);
> -off_t extract_next_file(int fd, int fdout, off_t start, int compressed,
> -			int encrypted, char *ivt, unsigned char *hash);
>   int openfileoutput(const char *filename);
>   int mkpath(char *dir, mode_t mode);
>   int swupdate_file_setnonblock(int fd, bool block);

Acked-by: Stefano Babic <stefano.babic@swupdate.org>

Michael, you do not need to repost this. It is orthogonal, I will apply 
directly to the tree.

Best regards,
Stefano
Stefano Babic Dec. 19, 2023, 3:10 p.m. UTC | #2
Hi Michael,

On 04.12.23 11:05, Michael Glembotzki wrote:
> ---
>   core/cpio_utils.c | 46 ----------------------------------------------
>   include/util.h    |  2 --
>   2 files changed, 48 deletions(-)
> 
> diff --git a/core/cpio_utils.c b/core/cpio_utils.c
> index 7049f73..0a6ebc1 100644
> --- a/core/cpio_utils.c
> +++ b/core/cpio_utils.c
> @@ -807,52 +807,6 @@ int extract_img_from_cpio(int fd, unsigned long offset, struct filehdr *fdh)
>   	return 0;
>   }
>   
> -off_t extract_next_file(int fd, int fdout, off_t start, int compressed,
> -		int encrypted, char *ivt, unsigned char *hash)
> -{
> -	int ret;
> -	struct filehdr fdh;
> -	uint32_t checksum = 0;
> -	unsigned long offset = start;
> -
> -	ret = lseek(fd, offset, SEEK_SET);
> -	if (ret < 0) {
> -		ERROR("CPIO file corrupted : %s",
> -		strerror(errno));
> -		return ret;
> -	}
> -
> -	ret = extract_cpio_header(fd, &fdh, &offset);
> -	if (ret) {
> -		ERROR("CPIO Header wrong");
> -		return ret;
> -	}
> -
> -	ret = lseek(fd, offset, SEEK_SET);
> -	if (ret < 0) {
> -		ERROR("CPIO file corrupted : %s", strerror(errno));
> -		return ret;
> -	}
> -
> -	ret = copyfile(fd, &fdout, fdh.size, &offset, 0, 0, compressed, &checksum, hash, encrypted, ivt, NULL);
> -	if (ret < 0) {
> -		ERROR("Error copying extracted file");
> -		return ret;
> -	}
> -
> -	TRACE("Copied file:\n\tfilename %s\n\tsize %u\n\tchecksum 0x%lx %s",
> -		fdh.filename,
> -		(unsigned int)fdh.size,
> -		(unsigned long)checksum,
> -		(checksum == fdh.chksum) ? "VERIFIED" : "WRONG");
> -
> -	if (!swupdate_verify_chksum(checksum, &fdh)) {
> -		return -EINVAL;
> -	}
> -
> -	return offset;
> -}
> -
>   int cpio_scan(int fd, struct swupdate_cfg *cfg, off_t start)
>   {
>   	struct filehdr fdh;
> diff --git a/include/util.h b/include/util.h
> index afe3a4f..958274c 100644
> --- a/include/util.h
> +++ b/include/util.h
> @@ -207,8 +207,6 @@ int copyfile(int fdin, void *out, size_t nbytes, unsigned long *offs,
>   int copyimage(void *out, struct img_type *img, writeimage callback);
>   int copybuffer(unsigned char *inbuf, void *out, size_t nbytes, int compressed,
>   	unsigned char *hash, bool encrypted, const char *imgivt, writeimage callback);
> -off_t extract_next_file(int fd, int fdout, off_t start, int compressed,
> -			int encrypted, char *ivt, unsigned char *hash);
>   int openfileoutput(const char *filename);
>   int mkpath(char *dir, mode_t mode);
>   int swupdate_file_setnonblock(int fd, bool block);


Applied to -master, thanks !

Best regards,
Stefano
diff mbox series

Patch

diff --git a/core/cpio_utils.c b/core/cpio_utils.c
index 7049f73..0a6ebc1 100644
--- a/core/cpio_utils.c
+++ b/core/cpio_utils.c
@@ -807,52 +807,6 @@  int extract_img_from_cpio(int fd, unsigned long offset, struct filehdr *fdh)
 	return 0;
 }
 
-off_t extract_next_file(int fd, int fdout, off_t start, int compressed,
-		int encrypted, char *ivt, unsigned char *hash)
-{
-	int ret;
-	struct filehdr fdh;
-	uint32_t checksum = 0;
-	unsigned long offset = start;
-
-	ret = lseek(fd, offset, SEEK_SET);
-	if (ret < 0) {
-		ERROR("CPIO file corrupted : %s",
-		strerror(errno));
-		return ret;
-	}
-
-	ret = extract_cpio_header(fd, &fdh, &offset);
-	if (ret) {
-		ERROR("CPIO Header wrong");
-		return ret;
-	}
-
-	ret = lseek(fd, offset, SEEK_SET);
-	if (ret < 0) {
-		ERROR("CPIO file corrupted : %s", strerror(errno));
-		return ret;
-	}
-
-	ret = copyfile(fd, &fdout, fdh.size, &offset, 0, 0, compressed, &checksum, hash, encrypted, ivt, NULL);
-	if (ret < 0) {
-		ERROR("Error copying extracted file");
-		return ret;
-	}
-
-	TRACE("Copied file:\n\tfilename %s\n\tsize %u\n\tchecksum 0x%lx %s",
-		fdh.filename,
-		(unsigned int)fdh.size,
-		(unsigned long)checksum,
-		(checksum == fdh.chksum) ? "VERIFIED" : "WRONG");
-
-	if (!swupdate_verify_chksum(checksum, &fdh)) {
-		return -EINVAL;
-	}
-
-	return offset;
-}
-
 int cpio_scan(int fd, struct swupdate_cfg *cfg, off_t start)
 {
 	struct filehdr fdh;
diff --git a/include/util.h b/include/util.h
index afe3a4f..958274c 100644
--- a/include/util.h
+++ b/include/util.h
@@ -207,8 +207,6 @@  int copyfile(int fdin, void *out, size_t nbytes, unsigned long *offs,
 int copyimage(void *out, struct img_type *img, writeimage callback);
 int copybuffer(unsigned char *inbuf, void *out, size_t nbytes, int compressed,
 	unsigned char *hash, bool encrypted, const char *imgivt, writeimage callback);
-off_t extract_next_file(int fd, int fdout, off_t start, int compressed,
-			int encrypted, char *ivt, unsigned char *hash);
 int openfileoutput(const char *filename);
 int mkpath(char *dir, mode_t mode);
 int swupdate_file_setnonblock(int fd, bool block);