shithub: gefs

Download patch

ref: c5b298956bde7c034464c88be0c85d9e12bc5d0a
parent: a0a4524bbb03bfa4902c6aa7102d912d403eef6b
author: Ori Bernstein <ori@eigenstate.org>
date: Fri Dec 3 11:11:51 EST 2021

cons: add 'show free' to show free ranges

--- a/check.c
+++ b/check.c
@@ -307,7 +307,7 @@
 }
 
 void
-showfree(char *m)
+showfree(int fd, char *m)
 {
 	Arange *r;
 	int i;
@@ -314,8 +314,8 @@
 
 	print("=== %s\n", m);
 	for(i = 0; i < fs->narena; i++){
-		print("arena %d:\n", i);
+		fprint(fd, "arena %d:\n", i);
 		for(r = (Arange*)avlmin(fs->arenas[i].free); r != nil; r = (Arange*)avlnext(r))
-			print("\t%llx+%llx\n", r->off, r->len);
+			fprint(fd, "\t%llx+%llx\n", r->off, r->len);
 	}
 }
--- a/cons.c
+++ b/cons.c
@@ -34,6 +34,10 @@
 					showcache(fd);
 					break;
 				}
+				if(strcmp(arg[1], "free") == 0){
+					showfree(fd, "free");
+					break;
+				}
 				/* wet floor */
 			default:
 				fprint(fd, "show me yours first\n");
--- a/dump.c
+++ b/dump.c
@@ -39,7 +39,7 @@
 }
 
 static int
-showval(Fmt *fmt, Kvp *v, int op, int wsop)
+showval(Fmt *fmt, Kvp *v, int op)
 {
 	char *p;
 	Dir d;
@@ -66,15 +66,15 @@
 			break;
 		case Owstat:
 			p = v->v;
-			if(wsop & Owmtime){
+			if(op & Owmtime){
 				n += fmtprint(fmt, "mtime:%llx ", GBIT64(p));
 				p += 8;
 			}
-			if(wsop & Owsize){
+			if(op & Owsize){
 				n += fmtprint(fmt, "size:%llx ", GBIT64(p));
 				p += 8;
 			}
-			if(wsop & Owmode){
+			if(op & Owmode){
 				n += fmtprint(fmt, "mode:%o ", GBIT32(p));
 				p += 4;
 			}
@@ -124,7 +124,7 @@
 	n = fmtprint(fmt, "Msg(%s, ", opname[m->op]);
 	n += showkey(fmt, m);
 	n += fmtprint(fmt, ") => (");
-	n += showval(fmt, m, m->op, m->statop);
+	n += showval(fmt, m, m->statop);
 	n += fmtprint(fmt, ")");
 	return n;
 }
@@ -142,7 +142,7 @@
 	n += showkey(fmt, kv);
 	n += fmtprint(fmt, ") => (");
 	if(kv->type == Vinl)
-		n += showval(fmt, kv, Onop, 0);
+		n += showval(fmt, kv, Onop);
 	else
 		n += fmtprint(fmt, "(%B,%ud))", kv->bp, kv->fill);
 	n += fmtprint(fmt, ")");
--- a/fns.h
+++ b/fns.h
@@ -63,7 +63,7 @@
 void	showfs(int, char*);
 void	showfids(int);
 void	showcache(int);
-void	showfree(char*);
+void	showfree(int, char*);
 int	checkfs(void);
 
 #define dprint(...) \