annotate pirollback/treewalk.c @ 224:148b5fd6c10e

pirelli/charging/i2v: note added
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 28 Nov 2017 02:14:44 +0000
parents 9f4469766c74
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
43
9f4469766c74 pirollback: tree walk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 #include <sys/types.h>
9f4469766c74 pirollback: tree walk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 #include <stdio.h>
9f4469766c74 pirollback: tree walk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 #include <stdlib.h>
9f4469766c74 pirollback: tree walk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4 #include "types.h"
9f4469766c74 pirollback: tree walk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5 #include "struct.h"
9f4469766c74 pirollback: tree walk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6
9f4469766c74 pirollback: tree walk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 extern struct inode_info inode[];
9f4469766c74 pirollback: tree walk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 extern int last_inode;
9f4469766c74 pirollback: tree walk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9
9f4469766c74 pirollback: tree walk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10 static void
9f4469766c74 pirollback: tree walk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11 walk_level(curlev)
9f4469766c74 pirollback: tree walk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12 {
9f4469766c74 pirollback: tree walk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13 int child;
9f4469766c74 pirollback: tree walk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14
9f4469766c74 pirollback: tree walk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15 for (child = inode[curlev].descend; child;
9f4469766c74 pirollback: tree walk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16 child = inode[child].sibling) {
9f4469766c74 pirollback: tree walk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17 inode[child].parent = curlev;
9f4469766c74 pirollback: tree walk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18 walk_level(child);
9f4469766c74 pirollback: tree walk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19 }
9f4469766c74 pirollback: tree walk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20 }
9f4469766c74 pirollback: tree walk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21
9f4469766c74 pirollback: tree walk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22 walk_tree()
9f4469766c74 pirollback: tree walk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23 {
9f4469766c74 pirollback: tree walk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24 if (inode[1].type != 0xF2 || *(inode[1].dataptr) != '/' ||
9f4469766c74 pirollback: tree walk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25 inode[1].sibling) {
9f4469766c74 pirollback: tree walk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 fprintf(stderr, "error: inode #1 is not the active root\n");
9f4469766c74 pirollback: tree walk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27 exit(1);
9f4469766c74 pirollback: tree walk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
28 }
9f4469766c74 pirollback: tree walk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
29 walk_level(1);
9f4469766c74 pirollback: tree walk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30 }