2 FUSE: Filesystem in Userspace
3 Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu>
5 This program can be distributed under the terms of the GNU LGPLv2.
6 See the file COPYING.LIB
10 #include "fuse_misc.h"
19 struct fuse_chan_ops op
;
21 struct fuse_session
*se
;
26 struct fuse_session
*fuse_session_new(void *data
)
28 struct fuse_session
*se
= (struct fuse_session
*) malloc(sizeof(*se
));
30 fprintf(stderr
, "fuse: failed to allocate session\n");
34 memset(se
, 0, sizeof(*se
));
40 void fuse_session_add_chan(struct fuse_session
*se
, struct fuse_chan
*ch
)
42 assert(se
->ch
== NULL
);
43 assert(ch
->se
== NULL
);
48 void fuse_session_remove_chan(struct fuse_chan
*ch
)
50 struct fuse_session
*se
= ch
->se
;
58 struct fuse_chan
*fuse_session_chan(struct fuse_session
*se
)
63 void fuse_session_process_buf(struct fuse_session
*se
,
64 const struct fuse_buf
*buf
, struct fuse_chan
*ch
)
66 se
->process_buf(se
->data
, buf
, ch
);
69 int fuse_session_receive_buf(struct fuse_session
*se
, struct fuse_buf
*buf
,
72 return se
->receive_buf(se
, buf
, ch
);
75 int fuse_chan_clearfd(struct fuse_chan
*ch
)
82 void fuse_session_destroy(struct fuse_session
*se
)
84 se
->destroy(se
->data
);
86 fuse_chan_destroy(se
->ch
);
90 void fuse_session_exit(struct fuse_session
*se
)
95 void fuse_session_reset(struct fuse_session
*se
)
100 int fuse_session_exited(struct fuse_session
*se
)
105 void *fuse_session_data(struct fuse_session
*se
)
110 struct fuse_chan
*fuse_chan_new(struct fuse_chan_ops
*op
, int fd
)
112 struct fuse_chan
*ch
= (struct fuse_chan
*) malloc(sizeof(*ch
));
114 fprintf(stderr
, "fuse: failed to allocate channel\n");
118 memset(ch
, 0, sizeof(*ch
));
125 int fuse_chan_fd(struct fuse_chan
*ch
)
130 struct fuse_session
*fuse_chan_session(struct fuse_chan
*ch
)
135 void fuse_chan_destroy(struct fuse_chan
*ch
)
137 fuse_session_remove_chan(ch
);