author | Tero Marttila <terom@fixme.fi> |
Sat, 13 Dec 2008 20:58:27 +0200 | |
branch | new-evsql |
changeset 55 | 0b92d553400a |
parent 31 | 7804cd7b5cd5 |
permissions | -rw-r--r-- |
24 | 1 |
|
2 |
/* |
|
3 |
* A simple PostgreSQL-based filesystem. |
|
4 |
*/ |
|
5 |
||
26
61668c57f4bb
preliminary *dir implementation
Tero Marttila <terom@fixme.fi>
parents:
25
diff
changeset
|
6 |
#include <stdlib.h> |
24 | 7 |
#include <string.h> |
8 |
#include <errno.h> |
|
26
61668c57f4bb
preliminary *dir implementation
Tero Marttila <terom@fixme.fi>
parents:
25
diff
changeset
|
9 |
#include <assert.h> |
24 | 10 |
|
11 |
#include <event2/event.h> |
|
12 |
||
28
e944453ca924
split off dbfs components into a separate dir, improve dirop docs, error handling, etc
Tero Marttila <terom@fixme.fi>
parents:
27
diff
changeset
|
13 |
#include "dbfs.h" |
24 | 14 |
#include "evfuse.h" |
15 |
#include "evsql.h" |
|
16 |
#include "lib/log.h" |
|
17 |
#include "lib/signals.h" |
|
18 |
#include "lib/misc.h" |
|
19 |
||
31 | 20 |
#define CONNINFO_DEFAULT "dbname=dbfs port=5433" |
24 | 21 |
|
22 |
int main (int argc, char **argv) { |
|
28
e944453ca924
split off dbfs components into a separate dir, improve dirop docs, error handling, etc
Tero Marttila <terom@fixme.fi>
parents:
27
diff
changeset
|
23 |
struct event_base *ev_base = NULL; |
e944453ca924
split off dbfs components into a separate dir, improve dirop docs, error handling, etc
Tero Marttila <terom@fixme.fi>
parents:
27
diff
changeset
|
24 |
struct signals *signals = NULL; |
e944453ca924
split off dbfs components into a separate dir, improve dirop docs, error handling, etc
Tero Marttila <terom@fixme.fi>
parents:
27
diff
changeset
|
25 |
struct dbfs *ctx = NULL; |
e944453ca924
split off dbfs components into a separate dir, improve dirop docs, error handling, etc
Tero Marttila <terom@fixme.fi>
parents:
27
diff
changeset
|
26 |
const char *db_conninfo; |
24 | 27 |
struct fuse_args fuse_args = FUSE_ARGS_INIT(argc, argv); |
28 |
||
29 |
// parse args, XXX: fuse_args |
|
28
e944453ca924
split off dbfs components into a separate dir, improve dirop docs, error handling, etc
Tero Marttila <terom@fixme.fi>
parents:
27
diff
changeset
|
30 |
db_conninfo = CONNINFO_DEFAULT; |
24 | 31 |
|
32 |
// init libevent |
|
28
e944453ca924
split off dbfs components into a separate dir, improve dirop docs, error handling, etc
Tero Marttila <terom@fixme.fi>
parents:
27
diff
changeset
|
33 |
if ((ev_base = event_base_new()) == NULL) |
24 | 34 |
ERROR("event_base_new"); |
35 |
||
36 |
// setup signals |
|
28
e944453ca924
split off dbfs components into a separate dir, improve dirop docs, error handling, etc
Tero Marttila <terom@fixme.fi>
parents:
27
diff
changeset
|
37 |
if ((signals = signals_default(ev_base)) == NULL) |
24 | 38 |
ERROR("signals_default"); |
39 |
||
28
e944453ca924
split off dbfs components into a separate dir, improve dirop docs, error handling, etc
Tero Marttila <terom@fixme.fi>
parents:
27
diff
changeset
|
40 |
// setup dbfs |
30
d8fabd347a8e
working open+read+flush+release
Tero Marttila <terom@fixme.fi>
parents:
28
diff
changeset
|
41 |
if ((ctx = dbfs_new(ev_base, &fuse_args, db_conninfo)) == NULL) |
d8fabd347a8e
working open+read+flush+release
Tero Marttila <terom@fixme.fi>
parents:
28
diff
changeset
|
42 |
ERROR("dbfs_new"); |
24 | 43 |
|
44 |
// run libevent |
|
45 |
INFO("running libevent loop"); |
|
46 |
||
28
e944453ca924
split off dbfs components into a separate dir, improve dirop docs, error handling, etc
Tero Marttila <terom@fixme.fi>
parents:
27
diff
changeset
|
47 |
if (event_base_dispatch(ev_base)) |
24 | 48 |
PERROR("event_base_dispatch"); |
49 |
||
50 |
// clean shutdown |
|
51 |
||
52 |
error : |
|
28
e944453ca924
split off dbfs components into a separate dir, improve dirop docs, error handling, etc
Tero Marttila <terom@fixme.fi>
parents:
27
diff
changeset
|
53 |
if (ctx) |
30
d8fabd347a8e
working open+read+flush+release
Tero Marttila <terom@fixme.fi>
parents:
28
diff
changeset
|
54 |
dbfs_free(ctx); |
28
e944453ca924
split off dbfs components into a separate dir, improve dirop docs, error handling, etc
Tero Marttila <terom@fixme.fi>
parents:
27
diff
changeset
|
55 |
|
e944453ca924
split off dbfs components into a separate dir, improve dirop docs, error handling, etc
Tero Marttila <terom@fixme.fi>
parents:
27
diff
changeset
|
56 |
if (signals) |
e944453ca924
split off dbfs components into a separate dir, improve dirop docs, error handling, etc
Tero Marttila <terom@fixme.fi>
parents:
27
diff
changeset
|
57 |
signals_free(signals); |
24 | 58 |
|
28
e944453ca924
split off dbfs components into a separate dir, improve dirop docs, error handling, etc
Tero Marttila <terom@fixme.fi>
parents:
27
diff
changeset
|
59 |
if (ev_base) |
e944453ca924
split off dbfs components into a separate dir, improve dirop docs, error handling, etc
Tero Marttila <terom@fixme.fi>
parents:
27
diff
changeset
|
60 |
event_base_free(ev_base); |
24 | 61 |
|
62 |
fuse_opt_free_args(&fuse_args); |
|
63 |
} |
|
64 |