-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathfuse-loop-epoll-mt.h
101 lines (77 loc) · 2.49 KB
/
fuse-loop-epoll-mt.h
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
2010, 2011 Stef Bon <[email protected]>
fuse-loop-epoll-mt.h
This is an alternative main eventloop for the fuse filesystem using epoll and threads.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef FUSE_LOOP_EPOLL_MT_H
#define FUSE_LOOP_EPOLL_MT_H
// epoll parameters
#define MAX_EPOLL_NREVENTS 32
#define MAX_EPOLL_NRFDS 32
// types of fd's
#define TYPE_FD_SIGNAL 1
#define TYPE_FD_FUSE 2
#define TYPE_FD_TIMER 3
// types of threads
#define TYPE_WORKER_PERMANENT 1
#define TYPE_WORKER_TEMPORARY 2
// number of threads
#ifndef NUM_WORKER_THREADS
#define NUM_WORKER_THREADS 10
#endif
#include <sys/wait.h>
#include <sys/epoll.h>
#include <sys/signalfd.h>
#include <pthread.h>
#include <semaphore.h>
// struct to identify the fd when epoll singals activity on that fd
struct fuse_epoll_data_struct {
int type_fd;
int fd;
struct fuse_chan *ch;
struct fuse_session *se;
size_t buffsize;
char *buff;
int res;
struct fuse_epoll_data_struct *next;
};
// struct for the threads (permanent and temporary)
struct fuse_worker_thread_data_struct {
pthread_t threadid;
int busy;
int nr;
int typeworker;
sem_t busy_sem;
struct fuse_event_data_struct *fuse_event_data;
struct fuse_worker_thread_data_struct *next;
struct fuse_worker_thread_data_struct *prev;
struct global_data_struct *global_data;
};
// struct to store the fuse event in when receiving data on fuse channel
struct fuse_event_data_struct {
struct fuse_chan *ch;
struct fuse_session *se;
char *buff;
size_t buffsize;
int res;
};
// struct with all the global data, used to have a reference to it in threads
struct global_data_struct {
struct fuse_epoll_data_struct *epoll_data;
struct fuse_worker_thread_data_struct *temp_worker_data;
unsigned char loglevel;
};
// Prototypes
int fuse_session_loop_epoll_mt(struct fuse_session *se, unsigned char loglevel);
#endif