diff pirollback/treewalk.c @ 43:9f4469766c74

pirollback: tree walk implemented
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sat, 06 Jul 2013 20:52:09 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pirollback/treewalk.c	Sat Jul 06 20:52:09 2013 +0000
@@ -0,0 +1,30 @@
+#include <sys/types.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "types.h"
+#include "struct.h"
+
+extern struct inode_info inode[];
+extern int last_inode;
+
+static void
+walk_level(curlev)
+{
+	int child;
+
+	for (child = inode[curlev].descend; child;
+	     child = inode[child].sibling) {
+		inode[child].parent = curlev;
+		walk_level(child);
+	}
+}
+
+walk_tree()
+{
+	if (inode[1].type != 0xF2 || *(inode[1].dataptr) != '/' ||
+	    inode[1].sibling) {
+		fprintf(stderr, "error: inode #1 is not the active root\n");
+		exit(1);
+	}
+	walk_level(1);
+}