equal
deleted
inserted
replaced
1 |
|
2 /* |
|
3 * A simple PostgreSQL-based filesystem. |
|
4 */ |
|
5 |
|
6 #include <stdlib.h> |
|
7 #include <string.h> |
|
8 #include <errno.h> |
|
9 #include <assert.h> |
|
10 |
|
11 #include <event2/event.h> |
|
12 |
|
13 #include "dbfs.h" |
|
14 #include "evfuse.h" |
|
15 #include "evsql.h" |
|
16 #include "lib/log.h" |
|
17 #include "lib/signals.h" |
|
18 #include "lib/misc.h" |
|
19 |
|
20 #define CONNINFO_DEFAULT "dbname=dbfs port=5433" |
|
21 |
|
22 int main (int argc, char **argv) { |
|
23 struct event_base *ev_base = NULL; |
|
24 struct signals *signals = NULL; |
|
25 struct dbfs *ctx = NULL; |
|
26 const char *db_conninfo; |
|
27 struct fuse_args fuse_args = FUSE_ARGS_INIT(argc, argv); |
|
28 |
|
29 // parse args, XXX: fuse_args |
|
30 db_conninfo = CONNINFO_DEFAULT; |
|
31 |
|
32 // init libevent |
|
33 if ((ev_base = event_base_new()) == NULL) |
|
34 ERROR("event_base_new"); |
|
35 |
|
36 // setup signals |
|
37 if ((signals = signals_default(ev_base)) == NULL) |
|
38 ERROR("signals_default"); |
|
39 |
|
40 // setup dbfs |
|
41 if ((ctx = dbfs_new(ev_base, &fuse_args, db_conninfo)) == NULL) |
|
42 ERROR("dbfs_new"); |
|
43 |
|
44 // run libevent |
|
45 INFO("running libevent loop"); |
|
46 |
|
47 if (event_base_dispatch(ev_base)) |
|
48 PERROR("event_base_dispatch"); |
|
49 |
|
50 // clean shutdown |
|
51 |
|
52 error : |
|
53 if (ctx) |
|
54 dbfs_free(ctx); |
|
55 |
|
56 if (signals) |
|
57 signals_free(signals); |
|
58 |
|
59 if (ev_base) |
|
60 event_base_free(ev_base); |
|
61 |
|
62 fuse_opt_free_args(&fuse_args); |
|
63 } |
|
64 |
|