git: 9front

Download patch

ref: e056624897daf8446708a73bf7eecb136fb441eb
parent: 0443812b5e6ced1f099b9ec2a919ac67cee9a57d
author: cinap_lenrek <cinap_lenrek@centraldogma>
date: Mon Jun 6 03:16:00 EDT 2011

cwfs: restore backup block even if directory block didnt got a new address

--- a/sys/src/cmd/cwfs/cw.c
+++ b/sys/src/cmd/cwfs/cw.c
@@ -1448,19 +1448,21 @@
 
 	cw->depth--;
 
-	if(na){
-		if(b){
-			p = getbuf(cw->dev, na, Brd);
-			if(!p || checktag(p, tag, qp)){
-				fprint(2, "cwrecur: b/p null %s\n", cw->name);
-				na = 0;
-			} else {
-				memmove(p->iobuf, b->iobuf, RBUFSIZE);
-				p->flags |= Bmod|Bimm;
-			}
-			if(p)
-				putbuf(p);
+	if(b){
+		p = getbuf(cw->dev, na ? na : addr, Brd);
+		if(!p || checktag(p, tag, qp)){
+			fprint(2, "cwrecur: b/p null\n");
+			na = 0;
+		} else {
+			memmove(p->iobuf, b->iobuf, RBUFSIZE);
+			p->flags |= Bmod|Bimm;
 		}
+		if(p)
+			putbuf(p);
+		putbuf(b);
+	}
+
+	if(na){
 		if(shouldstop){
 			if(cw->falsehits < 10)
 				fprint(2, "shouldstop %lld %lld t=%s %s\n",
@@ -1469,8 +1471,6 @@
 			cw->falsehits++;
 		}
 	}
-	if(b)
-		putbuf(b);
 
 	return na;
 }
--