clsync
Loading...
Searching...
No Matches
common.h
Go to the documentation of this file.
1
/*
2
clsync - file tree sync utility based on inotify
3
4
Copyright (C) 2013 Dmitry Yu Okunev <dyokunev@ut.mephi.ru> 0x8E30679C
5
6
This program is free software: you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation, either version 3 of the License, or
9
(at your option) any later version.
10
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
15
16
You should have received a copy of the GNU General Public License
17
along with this program. If not, see <http://www.gnu.org/licenses/>.
18
*/
19
20
21
#ifndef __CLSYNC_COMMON_H
22
#define __CLSYNC_COMMON_H
23
24
#ifndef __linux__
25
# ifdef HAVE_CAPABILITIES
26
# undef HAVE_CAPABILITIES
27
# warning Capabilities support can be built only on Linux
28
# endif
29
#endif
30
31
#define _GNU_SOURCE
32
//#define _XOPEN_SOURCE 700
33
#define _LARGEFILE64_SOURCE
34
35
#include <stdio.h>
36
#include <stdlib.h>
37
#include <stdint.h>
38
#include <string.h>
39
#include <strings.h>
40
#include <unistd.h>
41
#include <getopt.h>
42
#include <limits.h>
43
#include <stdarg.h>
44
#include <sys/types.h>
45
#include <sys/stat.h>
46
#include <fcntl.h>
47
#include <sys/mman.h>
48
#include <errno.h>
49
#include <ctype.h>
50
#include <signal.h>
51
#ifdef KQUEUE_SUPPORT
52
# include <sys/event.h>
53
#endif
54
#ifdef INOTIFY_SUPPORT
55
# include <sys/inotify.h>
56
#endif
57
#ifdef FANOTIFY_SUPPORT
58
# include <sys/fanotify.h>
59
#endif
60
#include <sys/wait.h>
61
#include <fts.h>
62
#include <sys/time.h>
63
#include <dirent.h>
64
#include <sys/utsname.h>
65
#include <sys/socket.h>
66
#include <arpa/inet.h>
67
#include <netinet/in.h>
68
#include <libgen.h>
69
#include <pthread.h>
70
71
#define CLSYNC_ITSELF
72
73
#include "
configuration.h
"
74
#ifdef HAVE_CONFIG_H
75
# include "
config.h
"
76
#endif
77
78
#include "
clsync.h
"
79
#include "
port-hacks.h
"
80
#include "
posix-hacks.h
"
81
#include "
ctx.h
"
82
#include "
program.h
"
83
84
#include <sys/param.h>
85
86
#ifndef IN_CREATE_SELF
87
# define IN_CREATE_SELF IN_CREATE
88
#endif
89
90
#include "
macros.h
"
91
92
enum
paramsource_enum
{
93
PS_UNKNOWN
= 0,
94
PS_ARGUMENT
,
95
PS_CONFIG
,
96
PS_CONTROL
,
97
PS_DEFAULTS
,
98
// PS_REHASH,
99
PS_CORRECTION
,
100
};
101
typedef
enum
paramsource_enum
paramsource_t
;
102
103
104
enum
notifyengine_enum
{
105
NE_UNDEFINED
= 0,
106
NE_FANOTIFY
,
107
NE_INOTIFY
,
108
NE_KQUEUE
,
109
NE_BSM
,
110
NE_BSM_PREFETCH
,
111
NE_DTRACEPIPE
,
112
NE_GIO
,
113
};
114
typedef
enum
notifyengine_enum
notifyengine_t
;
115
116
enum
threadingmode
{
117
PM_OFF
= 0,
118
PM_SAFE
,
119
PM_FULL
120
};
121
typedef
enum
threadingmode
threadingmode_t
;
122
123
enum
splittingmode_enum
{
124
SM_OFF
= 0,
125
SM_THREAD
,
126
SM_PROCESS
,
127
};
128
typedef
enum
splittingmode_enum
splittingmode_t
;
129
130
/*
131
struct excludeinfo {
132
unsigned int seqid_min;
133
unsigned int seqid_max;
134
eventobjtype_t objtype_old;
135
eventobjtype_t objtype_new;
136
uint32_t flags;
137
};
138
typedef struct eventinfo eventinfo_t;
139
*/
140
struct
eventinfo
{
141
uint32_t
evmask
;
142
unsigned
int
seqid_min
;
143
unsigned
int
seqid_max
;
144
eventobjtype_t
objtype_old
;
145
eventobjtype_t
objtype_new
;
146
int
wd
;
147
size_t
fsize
;
148
uint32_t
flags
;
149
};
150
typedef
struct
eventinfo
eventinfo_t
;
151
152
enum
pthread_mutex_id
{
153
PTHREAD_MUTEX_STATE
,
154
PTHREAD_MUTEX_SELECT
,
155
PTHREAD_MUTEX_THREADSINFO
,
156
PTHREAD_MUTEX_MAX
157
};
158
159
160
struct
dosync_arg
{
161
int
evcount
;
162
char
excf_path
[PATH_MAX + 1];
163
char
outf_path
[PATH_MAX + 1];
164
FILE *
outf
;
165
ctx_t
*
ctx_p
;
166
struct
indexes
*indexes_p;
167
void
*
data
;
168
unsigned
int
linescount
;
169
api_eventinfo_t
*
api_ei
;
170
int
api_ei_count
;
171
char
buf
[
BUFSIZ
+ 1];
172
173
// for be read by sync_parameter_get():
174
const
char
*
include_list
[
MAXARGUMENTS
+ 2];
175
size_t
include_list_count
;
176
const
char
*
list_type_str
;
177
const
char
*
evmask_str
;
178
};
179
180
struct
doubleentry
{
181
size_t
size0
;
182
size_t
size1
;
183
size_t
alloc0
;
184
size_t
alloc1
;
185
void
*
dat0
;
186
void
*
dat1
;
187
};
188
189
struct
pushdoubleentry_arg
{
190
int
allocated
;
191
int
total
;
192
size_t
size
;
193
struct
doubleentry
*
entry
;
194
};
195
196
struct
myentry
{
197
size_t
size
;
198
size_t
alloc
;
199
void
*
dat
;
200
};
201
202
struct
pushentry_arg
{
203
int
allocated
;
204
int
total
;
205
size_t
size
;
206
struct
myentry
*
entry
;
207
};
208
209
enum
initsync
{
210
INITSYNC_UNKNOWN
= 0,
211
INITSYNC_FULL
,
212
INITSYNC_SUBDIR
213
};
214
typedef
enum
initsync
initsync_t
;
215
216
struct
sighandler_arg
{
217
ctx_t
*
ctx_p
;
218
// indexes_t *indexes_p;
219
pthread_t
pthread_parent
;
220
int
*
exitcode_p
;
221
sigset_t *
sigset_p
;
222
};
223
typedef
struct
sighandler_arg
sighandler_arg_t
;
224
225
#endif
226
clsync.h
eventobjtype_t
enum eventobjtype eventobjtype_t
Definition
clsync.h:37
notifyengine_enum
notifyengine_enum
Definition
common.h:104
NE_UNDEFINED
@ NE_UNDEFINED
Definition
common.h:105
NE_INOTIFY
@ NE_INOTIFY
Definition
common.h:107
NE_FANOTIFY
@ NE_FANOTIFY
Definition
common.h:106
NE_KQUEUE
@ NE_KQUEUE
Definition
common.h:108
NE_GIO
@ NE_GIO
Definition
common.h:112
NE_BSM_PREFETCH
@ NE_BSM_PREFETCH
Definition
common.h:110
NE_DTRACEPIPE
@ NE_DTRACEPIPE
Definition
common.h:111
NE_BSM
@ NE_BSM
Definition
common.h:109
initsync_t
enum initsync initsync_t
Definition
common.h:214
splittingmode_enum
splittingmode_enum
Definition
common.h:123
SM_PROCESS
@ SM_PROCESS
Definition
common.h:126
SM_OFF
@ SM_OFF
Definition
common.h:124
SM_THREAD
@ SM_THREAD
Definition
common.h:125
splittingmode_t
enum splittingmode_enum splittingmode_t
Definition
common.h:128
pthread_mutex_id
pthread_mutex_id
Definition
common.h:152
PTHREAD_MUTEX_MAX
@ PTHREAD_MUTEX_MAX
Definition
common.h:156
PTHREAD_MUTEX_STATE
@ PTHREAD_MUTEX_STATE
Definition
common.h:153
PTHREAD_MUTEX_SELECT
@ PTHREAD_MUTEX_SELECT
Definition
common.h:154
PTHREAD_MUTEX_THREADSINFO
@ PTHREAD_MUTEX_THREADSINFO
Definition
common.h:155
paramsource_t
enum paramsource_enum paramsource_t
Definition
common.h:101
threadingmode_t
enum threadingmode threadingmode_t
Definition
common.h:121
paramsource_enum
paramsource_enum
Definition
common.h:92
PS_UNKNOWN
@ PS_UNKNOWN
Definition
common.h:93
PS_CONTROL
@ PS_CONTROL
Definition
common.h:96
PS_DEFAULTS
@ PS_DEFAULTS
Definition
common.h:97
PS_ARGUMENT
@ PS_ARGUMENT
Definition
common.h:94
PS_CORRECTION
@ PS_CORRECTION
Definition
common.h:99
PS_CONFIG
@ PS_CONFIG
Definition
common.h:95
initsync
initsync
Definition
common.h:209
INITSYNC_FULL
@ INITSYNC_FULL
Definition
common.h:211
INITSYNC_SUBDIR
@ INITSYNC_SUBDIR
Definition
common.h:212
INITSYNC_UNKNOWN
@ INITSYNC_UNKNOWN
Definition
common.h:210
threadingmode
threadingmode
Definition
common.h:116
PM_SAFE
@ PM_SAFE
Definition
common.h:118
PM_OFF
@ PM_OFF
Definition
common.h:117
PM_FULL
@ PM_FULL
Definition
common.h:119
notifyengine_t
enum notifyengine_enum notifyengine_t
Definition
common.h:114
config.h
configuration.h
MAXARGUMENTS
#define MAXARGUMENTS
Definition
configuration.h:13
BUFSIZ
#define BUFSIZ
Definition
configuration.h:6
ctx.h
macros.h
port-hacks.h
posix-hacks.h
program.h
api_eventinfo
Definition
clsync.h:39
ctx
Definition
ctx.h:315
dosync_arg
Definition
common.h:160
dosync_arg::buf
char buf[(1<< 16)+1]
Definition
common.h:171
dosync_arg::evcount
int evcount
Definition
common.h:161
dosync_arg::linescount
unsigned int linescount
Definition
common.h:168
dosync_arg::evmask_str
const char * evmask_str
Definition
common.h:177
dosync_arg::excf_path
char excf_path[PATH_MAX+1]
Definition
common.h:162
dosync_arg::list_type_str
const char * list_type_str
Definition
common.h:176
dosync_arg::outf_path
char outf_path[PATH_MAX+1]
Definition
common.h:163
dosync_arg::outf
FILE * outf
Definition
common.h:164
dosync_arg::api_ei_count
int api_ei_count
Definition
common.h:170
dosync_arg::api_ei
api_eventinfo_t * api_ei
Definition
common.h:169
dosync_arg::include_list_count
size_t include_list_count
Definition
common.h:175
dosync_arg::ctx_p
ctx_t * ctx_p
Definition
common.h:165
dosync_arg::data
void * data
Definition
common.h:167
dosync_arg::include_list
const char * include_list[(1<< 8)+2]
Definition
common.h:174
doubleentry
Definition
common.h:180
doubleentry::dat0
void * dat0
Definition
common.h:185
doubleentry::size1
size_t size1
Definition
common.h:182
doubleentry::size0
size_t size0
Definition
common.h:181
doubleentry::alloc1
size_t alloc1
Definition
common.h:184
doubleentry::alloc0
size_t alloc0
Definition
common.h:183
doubleentry::dat1
void * dat1
Definition
common.h:186
eventinfo
Definition
common.h:140
eventinfo::flags
uint32_t flags
Definition
common.h:148
eventinfo::fsize
size_t fsize
Definition
common.h:147
eventinfo::seqid_min
unsigned int seqid_min
Definition
common.h:142
eventinfo::evmask
uint32_t evmask
Definition
common.h:141
eventinfo::objtype_new
eventobjtype_t objtype_new
Definition
common.h:145
eventinfo::wd
int wd
Definition
common.h:146
eventinfo::objtype_old
eventobjtype_t objtype_old
Definition
common.h:144
eventinfo::seqid_max
unsigned int seqid_max
Definition
common.h:143
indexes
Definition
indexes.h:34
myentry
Definition
common.h:196
myentry::alloc
size_t alloc
Definition
common.h:198
myentry::dat
void * dat
Definition
common.h:199
myentry::size
size_t size
Definition
common.h:197
pushdoubleentry_arg
Definition
common.h:189
pushdoubleentry_arg::size
size_t size
Definition
common.h:192
pushdoubleentry_arg::entry
struct doubleentry * entry
Definition
common.h:193
pushdoubleentry_arg::total
int total
Definition
common.h:191
pushdoubleentry_arg::allocated
int allocated
Definition
common.h:190
pushentry_arg
Definition
common.h:202
pushentry_arg::entry
struct myentry * entry
Definition
common.h:206
pushentry_arg::total
int total
Definition
common.h:204
pushentry_arg::size
size_t size
Definition
common.h:205
pushentry_arg::allocated
int allocated
Definition
common.h:203
sighandler_arg
Definition
common.h:216
sighandler_arg::exitcode_p
int * exitcode_p
Definition
common.h:220
sighandler_arg::ctx_p
ctx_t * ctx_p
Definition
common.h:217
sighandler_arg::pthread_parent
pthread_t pthread_parent
Definition
common.h:219
sighandler_arg::sigset_p
sigset_t * sigset_p
Definition
common.h:221
Generated on Wed Nov 15 2023 13:38:28 for clsync by
1.12.0