-
Notifications
You must be signed in to change notification settings - Fork 0
/
subfs.c
58 lines (50 loc) · 1.29 KB
/
subfs.c
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "subfs.h"
#include "tagdb_fs.h"
#include "search_fs.h"
static int next_component_id = 0;
int subfs_number_of_components = 0;
subfs_component **subfs_comps;
static void subfs_register_component (subfs_component *comp);
void subfs_init (void)
{
subfs_comps = g_malloc0_n(sizeof(subfs_component*), 20);
subfs_register_component(&tagdb_fs_subfs);
}
gboolean subfs_component_handles_path (subfs_component *comp, const char *path)
{
return subfs_component_get_path_matcher(comp)(path);
}
int subfs_get_path_handler (const char *path)
{
int i;
for (i = 0; i < subfs_number_of_components; i++)
{
if (subfs_component_handles_path(subfs_comps[i], path))
{
return i;
}
}
return -1;
}
struct fuse_operations *subfs_get_opstruct (const char *path_to_check)
{
int component_number = subfs_get_path_handler(path_to_check);
if (component_number >= 0)
{
return &subfs_comps[component_number]->operations;
}
else
{
return NULL;
}
}
subfs_path_check_fn subfs_component_get_path_matcher (subfs_component *comp)
{
return comp->path_checker;
}
static void subfs_register_component (subfs_component *comp)
{
subfs_comps[next_component_id] = comp;
next_component_id++;
subfs_number_of_components++;
}