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
102
103
115
122
129
130/*
131struct 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};
138typedef struct eventinfo eventinfo_t;
139*/
140struct eventinfo {
141 uint32_t evmask;
142 unsigned int seqid_min;
143 unsigned int seqid_max;
146 int wd;
147 size_t fsize;
148 uint32_t flags;
149};
150typedef struct eventinfo eventinfo_t;
151
158
159
162 char excf_path[PATH_MAX + 1];
163 char outf_path[PATH_MAX + 1];
164 FILE *outf;
166 struct indexes *indexes_p;
167 void *data;
168 unsigned int linescount;
171 char buf[BUFSIZ + 1];
172
173// for be read by sync_parameter_get():
174 const char *include_list[MAXARGUMENTS + 2];
176 const char *list_type_str;
177 const char *evmask_str;
178};
179
181 size_t size0;
182 size_t size1;
183 size_t alloc0;
184 size_t alloc1;
185 void *dat0;
186 void *dat1;
187};
188
195
196struct myentry {
197 size_t size;
198 size_t alloc;
199 void *dat;
200};
201
204 int total;
205 size_t size;
206 struct myentry *entry;
207};
208
214typedef enum initsync initsync_t;
215
218// indexes_t *indexes_p;
219 pthread_t pthread_parent;
221 sigset_t *sigset_p;
222};
224
225#endif
226
enum eventobjtype eventobjtype_t
Definition clsync.h:37
notifyengine_enum
Definition common.h:104
@ NE_UNDEFINED
Definition common.h:105
@ NE_INOTIFY
Definition common.h:107
@ NE_FANOTIFY
Definition common.h:106
@ NE_KQUEUE
Definition common.h:108
@ NE_GIO
Definition common.h:112
@ NE_BSM_PREFETCH
Definition common.h:110
@ NE_DTRACEPIPE
Definition common.h:111
@ NE_BSM
Definition common.h:109
enum initsync initsync_t
Definition common.h:214
splittingmode_enum
Definition common.h:123
@ SM_PROCESS
Definition common.h:126
@ SM_OFF
Definition common.h:124
@ SM_THREAD
Definition common.h:125
enum splittingmode_enum splittingmode_t
Definition common.h:128
pthread_mutex_id
Definition common.h:152
@ PTHREAD_MUTEX_MAX
Definition common.h:156
@ PTHREAD_MUTEX_STATE
Definition common.h:153
@ PTHREAD_MUTEX_SELECT
Definition common.h:154
@ PTHREAD_MUTEX_THREADSINFO
Definition common.h:155
enum paramsource_enum paramsource_t
Definition common.h:101
enum threadingmode threadingmode_t
Definition common.h:121
paramsource_enum
Definition common.h:92
@ PS_UNKNOWN
Definition common.h:93
@ PS_CONTROL
Definition common.h:96
@ PS_DEFAULTS
Definition common.h:97
@ PS_ARGUMENT
Definition common.h:94
@ PS_CORRECTION
Definition common.h:99
@ PS_CONFIG
Definition common.h:95
initsync
Definition common.h:209
@ INITSYNC_FULL
Definition common.h:211
@ INITSYNC_SUBDIR
Definition common.h:212
@ INITSYNC_UNKNOWN
Definition common.h:210
threadingmode
Definition common.h:116
@ PM_SAFE
Definition common.h:118
@ PM_OFF
Definition common.h:117
@ PM_FULL
Definition common.h:119
enum notifyengine_enum notifyengine_t
Definition common.h:114
#define MAXARGUMENTS
#define BUFSIZ
Definition ctx.h:315
char buf[(1<< 16)+1]
Definition common.h:171
int evcount
Definition common.h:161
unsigned int linescount
Definition common.h:168
const char * evmask_str
Definition common.h:177
char excf_path[PATH_MAX+1]
Definition common.h:162
const char * list_type_str
Definition common.h:176
char outf_path[PATH_MAX+1]
Definition common.h:163
FILE * outf
Definition common.h:164
int api_ei_count
Definition common.h:170
api_eventinfo_t * api_ei
Definition common.h:169
size_t include_list_count
Definition common.h:175
ctx_t * ctx_p
Definition common.h:165
void * data
Definition common.h:167
const char * include_list[(1<< 8)+2]
Definition common.h:174
void * dat0
Definition common.h:185
size_t size1
Definition common.h:182
size_t size0
Definition common.h:181
size_t alloc1
Definition common.h:184
size_t alloc0
Definition common.h:183
void * dat1
Definition common.h:186
uint32_t flags
Definition common.h:148
size_t fsize
Definition common.h:147
unsigned int seqid_min
Definition common.h:142
uint32_t evmask
Definition common.h:141
eventobjtype_t objtype_new
Definition common.h:145
int wd
Definition common.h:146
eventobjtype_t objtype_old
Definition common.h:144
unsigned int seqid_max
Definition common.h:143
size_t alloc
Definition common.h:198
void * dat
Definition common.h:199
size_t size
Definition common.h:197
struct doubleentry * entry
Definition common.h:193
struct myentry * entry
Definition common.h:206
size_t size
Definition common.h:205
int allocated
Definition common.h:203
int * exitcode_p
Definition common.h:220
ctx_t * ctx_p
Definition common.h:217
pthread_t pthread_parent
Definition common.h:219
sigset_t * sigset_p
Definition common.h:221