From b621d4ed5e07cdc17fee79011c21c62cd995ae2b Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Sat, 4 Feb 2023 17:04:17 +0100 Subject: libtar: simplfy parsing of old GNU sparse format There was some code duplication for extracting the sparse entry fields from the start record and the subsequent extended record. This commit introduces a data structure for both and unifies the parsing code paths. Signed-off-by: David Oberhollenzer --- include/tar/format.h | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'include') diff --git a/include/tar/format.h b/include/tar/format.h index c3e372d..9f60ef3 100644 --- a/include/tar/format.h +++ b/include/tar/format.h @@ -9,6 +9,17 @@ #include "sqfs/predef.h" +typedef struct { + char offset[12]; + char numbytes[12]; +} gnu_old_sparse_t; + +typedef struct { + gnu_old_sparse_t sparse[21]; + char isextended; + char padding[7]; +} gnu_old_sparse_record_t; + typedef struct { char name[100]; char mode[8]; @@ -37,10 +48,7 @@ typedef struct { char offset[12]; char deprecated[4]; char unused; - struct { - char offset[12]; - char numbytes[12]; - } sparse[4]; + gnu_old_sparse_t sparse[4]; char isextended; char realsize[12]; char padding[17]; @@ -48,15 +56,6 @@ typedef struct { } tail; } tar_header_t; -typedef struct { - struct { - char offset[12]; - char numbytes[12]; - } sparse[21]; - char isextended; - char padding[7]; -} gnu_sparse_t; - #define TAR_TYPE_FILE '0' #define TAR_TYPE_LINK '1' #define TAR_TYPE_SLINK '2' -- cgit v1.2.3