shithub: fsgen

Download patch

ref: a976de46123b51045a1ea123ad452e8465e71b08
parent: bbb0304c787f639192e9882710d6c8896eaea7b9
author: sirjofri <sirjofri@sirjofri.de>
date: Tue Dec 16 09:08:18 EST 2025

fix filehierarchy, first successful walks

--- a/code.c
+++ b/code.c
@@ -128,6 +128,9 @@
 		for (cv = v->children; cv; cv = cv->next) {
 			pathtostring(cbuf, sizeof(cbuf), cv->name);
 			print("		filehierarchy[Q%s][%d] = Q%s;\n", buf, i++, cbuf);
+		}
+		print("		filehierarchy[Q%s][%d] = 0;\n", buf, i);
+		for (cv = v->children; cv; cv = cv->next) {
 			printfilehierarchy(cv);
 		}
 	}
@@ -170,7 +173,7 @@
 	
 	print(
 	"static void\n"
-	"buildfilehierarchy()\n"
+	"buildfilehierarchy(void)\n"
 	"{\n");
 	
 	n = getnfiles();
--- a/fsfunc.inc
+++ b/fsfunc.inc
@@ -1,4 +1,5 @@
 {
+	buildfilehierarchy();
 	fs.write = fswrite;
 	return &fs;
 }
--- a/fshandler.inc
+++ b/fshandler.inc
@@ -68,8 +68,11 @@
 	Filedata *fd;
 	char *s;
 	int n;
-	fprint(2, "qid: %d, root: %d, max: %d, name: %s\n", qid, Qroot, Qmax, name);
+	
 	assert(qid >= Qroot && qid < Qmax);
+	if (!filehierarchy[qid]) {
+		return qid;
+	}
 	for (int *i = filehierarchy[qid]; *i; i++) {
 		fd = &filedata[*i];
 		s = fd->dir.name;
@@ -92,12 +95,12 @@
 	char *s;
 	
 	if (strcmp(name, ".") == 0) {
-		*qid = fid->qid;
+		fid->qid = *qid;
 		return nil;
 	}
 	
-	qt = breakqid(fid->qid.path);
-	id = getqidid(fid->qid.path);
+	qt = breakqid(qid->path);
+	id = getqidid(qid->path);
 	
 	if (strcmp(name, "..") == 0) {
 		qt = findparent(qt);
--