shithub: gefs

Download patch

ref: f63d327c4223b5e02226c2a843da81c9ba42871a
parent: d8f3576e5dc6793b98314f202cfba0c65bfbee12
author: Ori Bernstein <ori@eigenstate.org>
date: Mon Oct 4 00:38:48 EDT 2021

all: replace error returns with constants.

--- a/dat.h
+++ b/dat.h
@@ -79,6 +79,7 @@
 };
 
 #define Efs	"i will not buy this fs, it is scratched"
+#define Eio	"i/o error"
 #define Efid	"bad fid"
 #define Edscan	"invalid dir scan offset"
 #define Eexist	"does not exist"
@@ -375,9 +376,9 @@
 	int	sz;	/* size of range */
 
 	/* Flowing up from flush */
+	Blk	*n;	/* shadowed node */
 	Blk	*l;	/* left of split */
 	Blk	*r;	/* right of split */
-	Blk	*n;	/* shadowed node */
 	/*
 	 * If we merged or rotated, at least
 	 * one of these nodes is not nil,
--- a/fs.c
+++ b/fs.c
@@ -645,7 +645,6 @@
 	r.qid = d.qid;
 	r.iounit = f->iounit;
 	respond(m, &r);
-		
 }
 
 void
@@ -757,7 +756,7 @@
 	if(s == nil || m->offset == 0){
 		print("scan starting\n");
 		if((s = mallocz(sizeof(Scan), 1)) == nil)
-			return "out of memory";
+			return Enomem;
 
 		pfx[0] = Kent;
 		PBIT64(pfx+1, f->qpath);
@@ -902,7 +901,6 @@
 		rerror(m, Efid);
 		return;
 	}
-//showfs("fs contents before read");
 	fprint(2, "\n");
 	r.type = Rread;
 	r.count = 0;
@@ -958,6 +956,7 @@
 			return -1;
 		}
 		memcpy(b->buf, t->buf, Blksz);
+		freeblk(t);
 		putblk(t);
 	}
 	if(fo+n > Blksz)
--- a/tree.c
+++ b/tree.c
@@ -1262,7 +1262,7 @@
 
 	p = s->path;
 	if((b = getblk(s->root.bp, 0)) == nil)
-		return "error reading block";
+		return Eio;
 	p[0].b = b;
 	for(i = 0; i < s->root.ht; i++){
 		p[i].vi = blksearch(b, &s->kv, &v, &same);
@@ -1274,7 +1274,7 @@
 			if(p[i].bi == -1 || !same)
 				p[i].bi++;
 			if((b = getblk(v.bp, 0)) == nil)
-				return "error reading block";
+				return Eio;
 			p[i+1].b = b;
 		}
 	}