shithub: gefs

Download patch

ref: 28bf51b393100742747e41dce318a2b7a9597821
parent: 6ae4eceba4094a3a408f3c9d7959b4a0853b1c2d
author: Michael Forney <mforney@mforney.org>
date: Tue Feb 1 16:56:54 EST 2022

snap: fix scandead with DlChain

--- a/snap.c
+++ b/snap.c
@@ -23,8 +23,9 @@
 		return 0;
 	if(b == nil)
 		return -1;
-	p = b->data + Loghdsz;
+Nextblk:
 	for(i = Loghdsz; i < Logspc; i += 16){
+		p = b->data + i;
 		op = GBIT64(p) & 0xff;
 		switch(op){
 		case DlEnd:
@@ -38,12 +39,11 @@
 				fn(b->bp, dat);
 			if((b = getblk(bp, 0)) == nil)
 				return -1;
-			p = b->data + Loghdsz;
-			break;
+			goto Nextblk;
 		case DlGraft:
 			t.head.addr = GBIT64(p);	p += 8;
 			t.head.addr &= ~0xffULL;
-			t.head.hash = GBIT64(p);	p += 8;
+			t.head.hash = GBIT64(p);
 			t.head.gen = -1;
 			t.ins = nil;
 			scandead(&t, lblk, fn, dat);
@@ -51,7 +51,7 @@
 		case DlKill:
 			bp.addr = GBIT64(p);	p += 8;
 			bp.hash = -1;
-			bp.gen = GBIT64(p);	p += 8;
+			bp.gen = GBIT64(p);
 			bp.addr &= ~0xffULL;
 			fn(bp, dat);
 			break;