equal
deleted
inserted
replaced
|
1 #include <event2/event.h> |
|
2 #include <fuse/fuse_opt.h> |
|
3 |
|
4 #include "lib/common.h" |
|
5 #include "evfuse.h" |
|
6 |
|
7 struct hello { |
|
8 struct event_base *ev_base; |
|
9 |
|
10 struct evfuse *ev_fuse; |
|
11 } ctx; |
|
12 |
|
13 void hello_init (void *userdata, struct fuse_conn_info *conn) { |
|
14 INFO("[hello.init] userdata=%p, conn=%p", userdata, conn); |
|
15 } |
|
16 |
|
17 void hello_destroy (void *userdata) { |
|
18 INFO("[hello.destroy] userdata=%p", userdata); |
|
19 } |
|
20 |
|
21 struct fuse_lowlevel_ops hello_llops = { |
|
22 .init = &hello_init, |
|
23 .destroy = &hello_destroy, |
|
24 }; |
|
25 |
|
26 |
|
27 int main (int argc, char **argv) { |
|
28 struct fuse_args fuse_args = FUSE_ARGS_INIT(argc, argv); |
|
29 |
|
30 // init libevent |
|
31 if ((ctx.ev_base = event_base_new()) == NULL) |
|
32 FATAL("event_base_new"); |
|
33 |
|
34 // open fuse |
|
35 if ((ctx.ev_fuse = evfuse_new(ctx.ev_base, &fuse_args, &hello_llops, &ctx)) == NULL) |
|
36 FATAL("evfuse_new"); |
|
37 |
|
38 // run libevent |
|
39 INFO("running libevent loop"); |
|
40 |
|
41 if (event_base_dispatch(ctx.ev_base)) |
|
42 PWARNING("event_base_dispatch"); |
|
43 |
|
44 // cleanup |
|
45 event_base_free(ctx.ev_base); |
|
46 } |
|
47 |