shithub: gefs

Download patch

ref: e890a999ee2142ff650df78730bff516d347ec66
parent: 076b2649290d831a8f67ae58e0add8cb1e3750e2
author: Ori Bernstein <[email protected]>
date: Tue Jan 2 10:18:42 EST 2024

check: add isfree checks

--- a/check.c
+++ b/check.c
@@ -198,26 +198,22 @@
 }
 
 static int
-checkdata(int, Tree *t)
+checkdlist(int fd)
 {
 	char pfx[1];
-	Bptr bp;
+	Dlist dl;
 	Scan s;
-	Blk *b;
 
-	pfx[0] = Klabel;
+	checklog(fd, fs->snapdl.hd);
+	pfx[0] = Kdlist;
 	btnewscan(&s, pfx, 1);
-	btenter(t, &s);
+	btenter(&fs->snap, &s);
 	while(1){
 		if(!btnext(&s, &s.kv))
 			break;
-		bp = unpackbp(s.kv.v, s.kv.nv);
-		if(isfree(bp.addr)){
-			fprint(2, "free block in use: %B\n", bp);
-			error("free block in use");
-		}
-		b = getblk(bp, GBraw);
-		dropblk(b);
+		kv2dlist(&s.kv, &dl);
+		if(!checklog(fd, dl.hd))
+			print("bad dlist %P: %s\n", &s.kv, errmsg());
 	}
 	btexit(&s);
 	return 0;
@@ -224,22 +220,26 @@
 }
 
 static int
-checkdlist(int fd)
+checkdata(int, Tree *t)
 {
 	char pfx[1];
-	Dlist dl;
+	Bptr bp;
 	Scan s;
+	Blk *b;
 
-	checklog(fd, fs->snapdl.hd);
-	pfx[0] = Kdlist;
+	pfx[0] = Klabel;
 	btnewscan(&s, pfx, 1);
-	btenter(&fs->snap, &s);
+	btenter(t, &s);
 	while(1){
 		if(!btnext(&s, &s.kv))
 			break;
-		kv2dlist(&s.kv, &dl);
-		if(!checklog(fd, dl.hd))
-			print("bad dlist %P: %s\n", &s.kv, errmsg());
+		bp = unpackbp(s.kv.v, s.kv.nv);
+		if(isfree(bp.addr)){
+			fprint(2, "free block in use: %B\n", bp);
+			error("free block in use");
+		}
+		b = getblk(bp, GBraw);
+		dropblk(b);
 	}
 	btexit(&s);
 	return 0;