shithub: 9ferno

Download patch

ref: 916fe767404498e0108f7b1d3fd0994ae19913f3
parent: 7c22230886134121893f02ee283da85f3a6807e6
author: 9ferno <gophone2015@gmail.com>
date: Tue Sep 7 22:47:44 EDT 2021

ulong pointers bug fixed

--- a/appl/cmd/disk/kfs64.b	Tue Sep  7 08:48:31 2021
+++ b/appl/cmd/disk/kfs64.b	Tue Sep  7 22:47:44 2021
@@ -3581,6 +3581,13 @@
 #
 # kfs check, could be a separate module if that seemed important
 #
+# check() kicks off the fsck() on the root directory
+# fsck() walks through each child file and directory
+#	and marks every block and qid that are being used
+#	in amap and qmap. If the child is a directory, then fsck()
+#	descends into it and fsck()'s each child.
+#	if a bit has already been marked, then we have a duplicate
+#	if a block number is <= fstart and >= fsize, then bad
 
 MAXDEPTH: con 100;
 MAXNAME: con 4000;
@@ -3602,8 +3609,8 @@
 Check: adt {
 	dev:	ref Device;
 
-	amap:	ref Map;
-	qmap:	ref Map;
+	amap:	ref Map;	# bit map of all blocks
+	qmap:	ref Map;	# bit map of max qid used + 100
 
 	name:	string;
 	nfiles:	big;
--- a/libinterp/dec.c	Tue Sep  7 08:48:31 2021
+++ b/libinterp/dec.c	Tue Sep  7 22:47:44 2021
@@ -4,7 +4,7 @@
 #include "isa.h"
 #include "interp.h"
 
-#define DIND(reg, xxx) (uchar*)((*(ulong*)(R.reg+R.PC->xxx.i.f))+R.PC->xxx.i.s)
+#define DIND(reg, xxx) (uchar*)((*(uintptr*)(R.reg+R.PC->xxx.i.f))+R.PC->xxx.i.s)
 static void
 D00(void)
 {
--- a/libinterp/xec.c	Tue Sep  7 08:48:31 2021
+++ b/libinterp/xec.c	Tue Sep  7 22:47:44 2021
@@ -215,60 +215,60 @@
 }
 OP(indx)
 {
-	ulong i;
+	uintptr i;
 	Array *a;
 
 	a = A(s);
 	i = W(d);
-	DP("indx a %p a->len %lld i %ld\n", a, a->len, i);
+	DP("indx a %p a->len %zd i %zd\n", a, a->len, i);
 	if(a == H || i >= a->len)
 		error(exBounds);
 	W(m) = (WORD)(a->data+i*a->t->size);
 }
 OP(indw)
 {
-	ulong i;
+	uintptr i;
 	Array *a;
 
 	a = A(s);
 	i = W(d);
-	DP("indw a %p a->len %lld i %ld\n", a, a->len, i);
+	DP("indw a %p a->len %zd i %zd\n", a, a->len, i);
 	if(a == H || i >= a->len)
 		error(exBounds);
 	W(m) = (WORD)(a->data+i*sizeof(WORD));
 }
 OP(indf)
 {
-	ulong i;
+	uintptr i;
 	Array *a;
 
 	a = A(s);
 	i = W(d);
-	DP("indf a %p a->len %lld i %ld\n", a, a->len, i);
+	DP("indf a %p a->len %zd i %zd\n", a, a->len, i);
 	if(a == H || i >= a->len)
 		error(exBounds);
 	W(m) = (WORD)(a->data+i*sizeof(REAL));
 }
 OP(indl)
 {
-	ulong i;
+	uintptr i;
 	Array *a;
 
 	a = A(s);
 	i = W(d);
-	DP("indl a %p a->len %lld i %ld\n", a, a->len, i);
+	DP("indl a %p a->len %zd i %zd\n", a, a->len, i);
 	if(a == H || i >= a->len)
 		error(exBounds);
 	W(m) = (WORD)(a->data+i*sizeof(LONG));
 }
 OP(indb)
 {
-	ulong i;
+	uintptr i;
 	Array *a;
 
 	a = A(s);
 	i = W(d);
-	DP("indb a %p a->len %lld i %ld\n", a, a->len, i);
+	DP("indb a %p a->len %zd a->data 0x%p i %zd\n", a, a->len, a->data, i);
 	if(a == H || i >= a->len)
 		error(exBounds);
 	W(m) = (WORD)(a->data+i*sizeof(BYTE));
--- a/os/port/alloc.c	Tue Sep  7 08:48:31 2021
+++ b/os/port/alloc.c	Tue Sep  7 22:47:44 2021
@@ -18,7 +18,7 @@
 	char*	name;
 	int	pnum;
 	uintptr	maxsize;
-	int	quanta;
+	intptr	quanta;
 	int	chunk;
 	uintptr	ressize;
 	uintptr	cursize;
@@ -29,8 +29,8 @@
 	Bhdr*	chain;
 	uintptr	nalloc;
 	uintptr	nfree;
-	int	nbrk;
-	int	lastfree;
+	intptr	nbrk;
+	intptr	lastfree;
 	int	warn;
 	void	(*move)(void*, void*);
 };
@@ -955,7 +955,7 @@
 	char *fmsg, *msg;
 	uintptr fsz;
 
-	SET(fsz, fmsg);
+	SET(fsz, fmsg, nb);
 	for (p = &table.pool[0]; p < &table.pool[nelem(table.pool)]; p++) {
 		ilock(&p->l);
 		for (bc = p->chain; bc != nil; bc = bc->clink) {
--- a/os/port/devcons.c	Tue Sep  7 08:48:31 2021
+++ b/os/port/devcons.c	Tue Sep  7 22:47:44 2021
@@ -457,7 +457,7 @@
 
 	if(size > 64) size = 64;
 
-	snprint(tmp, sizeof(tmp), "%*.0lud ", size, val);
+	snprint(tmp, sizeof(tmp), "%*.0ld ", size, val);
 	if(off >= size)
 		return 0;
 	if(off+n > size)