1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
| void traversal_recursive(struct dentry* node, const char* path, struct vnode** target_node, char* target_path) {
// ... skip for simplicity
// find in node's child
struct list_head* p;
int found = 0;
list_for_each(p, &node->childs) {
struct dentry* dent = list_entry(p, struct dentry, list);
if (!strcmp(dent->name, target_path)) {
if (dent->mountpoint != NULL) {
traversal_recursive(dent->mountpoint->root, path + i, target_node, target_path);
}
else if (dent->type == DIRECTORY) {
traversal_recursive(dent, path + i, target_node, target_path);
}
found = 1;
break;
}
}
// not found in vnode tree, then try to load dentry in real hard disk
if (!found) {
int ret = node->vnode->v_ops->load_dentry(node, target_path);
if (ret == 0) { // load success, traversal again
traversal_recursive(node, path, target_node, target_path);
}
}
}
|