Add accessor to return associated SRC chunk
authorStefano Babic <sbabic@denx.de>
Fri, 17 Sep 2021 11:15:45 +0000 (13:15 +0200)
committerStefano Babic <sbabic@denx.de>
Tue, 12 Oct 2021 09:11:41 +0000 (11:11 +0200)
If a chunk with the same hash is already present on device, it is
recorded in the src pointer. Add accessor to return this chunk.

Signed-off-by: Stefano Babic <sbabic@denx.de>
include/zck.h.in
src/lib/index/index_read.c

index ed646b78271bda4d98c215762bcac653cc36ff99..3be82ff2d44b17b212f03a369572edb83a3e231d 100644 (file)
@@ -280,7 +280,9 @@ ssize_t zck_get_chunk_comp_data(zckChunk *idx, char *dst, size_t dst_size)
 /* Find out if two chunk digests are the same */
 bool zck_compare_chunk_digest(zckChunk *a, zckChunk *b)
     __attribute__ ((warn_unused_result));
-
+/* Get associate src chunk if any */
+zckChunk *zck_get_src_chunk(zckChunk *idx)
+    __attribute__ ((warn_unused_result));
 
 /*******************************************************************
  * Advanced hash functions
index 8c90137c426376919c921e2556820fa24545b569..9b2c43505c7ba75dff1d98e012dfc3d47765eb88 100644 (file)
@@ -183,6 +183,17 @@ zckChunk PUBLIC *zck_get_next_chunk(zckChunk *idx) {
     return idx->next;
 }
 
+zckChunk PUBLIC *zck_get_src_chunk(zckChunk *idx) {
+    if(idx && idx->zck) {
+        VALIDATE_PTR(idx->zck);
+        ALLOCD_PTR(idx->zck, idx);
+    } else {
+        ALLOCD_PTR(NULL, idx);
+    }
+
+    return idx->src;
+}
+
 ssize_t PUBLIC zck_get_chunk_start(zckChunk *idx) {
     if(idx && idx->zck) {
         VALIDATE_INT(idx->zck);