clsync
sync.h
Go to the documentation of this file.
1 /*
2  clsync - file tree sync utility based on fanotify and 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 #include <glib.h> // GHashTable
21 
22 
24  char *excfpath;
25  char *incfpath;
26 };
28 
30 struct threadinfo {
32  uint32_t iteration;
35  char **argv;
36  pthread_t pthread;
37  int exitcode;
38  int errcode;
41  time_t starttime;
42  time_t expiretime;
43  int child_pid;
44 
45  GHashTable *fpath2ei_ht; // file path -> event information
46 
47  int try_n;
48 
49  // for so-synchandler
50  int n;
52 };
53 typedef struct threadinfo threadinfo_t;
54 
55 struct threadsinfo {
56  pthread_mutex_t mutex[PTHREAD_MUTEX_MAX];
57  pthread_cond_t cond [PTHREAD_MUTEX_MAX];
58  char mutex_init;
59  int allocated;
60  int used;
62  threadinfo_t **threadsstack; // stack of threadinfo_t to be used on thread_new()
63  int stacklen;
64 };
65 typedef struct threadsinfo threadsinfo_t;
66 
67 
68 extern int sync_run ( struct ctx *ctx );
69 extern int sync_dump ( struct ctx *ctx, const char *const dest_dir );
70 extern int sync_term ( int exitcode );
71 extern int threads_foreach ( int ( *funct ) ( threadinfo_t *, void * ), state_t state, void *arg );
72 extern threadsinfo_t *thread_info();
73 extern time_t thread_nextexpiretime();
74 extern int sync_prequeue_loadmark
75 (
76  int fsmon_d,
77 
78  struct ctx *ctx_p,
79  struct indexes *indexes_p,
80 
81  const char *path_full,
82  const char *path_rel,
83 
84  stat64_t *lst_p,
85 
86  eventobjtype_t objtype_old,
87  eventobjtype_t objtype_new,
88 
89  uint32_t event_mask,
90  int event_wd,
91  mode_t st_mode,
92  off_t st_size,
93 
94  char **path_buf_p,
95  size_t *path_buf_len_p,
96 
97  struct eventinfo *evinfo
98 );
99 extern int sync_prequeue_unload ( struct ctx *ctx_p, struct indexes *indexes_p );
100 extern const char *sync_parameter_get ( const char *variable_name, void *_dosync_arg_p );
101 extern pthread_t pthread_sighandler;
102 
ctx
Definition: ctx.h:315
thread_info
threadsinfo_t * thread_info()
Definition: sync.c:190
sync_run
int sync_run(struct ctx *ctx)
Definition: sync.c:3998
api_eventinfo
Definition: clsync.h:39
threadsinfo::used
int used
Definition: sync.h:60
eventobjtype_t
enum eventobjtype eventobjtype_t
Definition: clsync.h:37
indexes
Definition: indexes.h:34
threadsinfo::threads
threadinfo_t * threads
Definition: sync.h:61
thread_callbackfunct_arg::excfpath
char * excfpath
Definition: sync.h:24
threadinfo::callback
thread_callbackfunct_t callback
Definition: sync.h:33
PTHREAD_MUTEX_MAX
@ PTHREAD_MUTEX_MAX
Definition: common.h:156
threadinfo::n
int n
Definition: sync.h:50
sync_term
int sync_term(int exitcode)
Definition: sync.c:3991
threadinfo::callback_arg
thread_callbackfunct_arg_t * callback_arg
Definition: sync.h:34
threadinfo::fpath2ei_ht
GHashTable * fpath2ei_ht
Definition: sync.h:45
sync_dump
int sync_dump(struct ctx *ctx, const char *const dest_dir)
Definition: sync.c:3773
threads_foreach
int threads_foreach(int(*funct)(threadinfo_t *, void *), state_t state, void *arg)
thread_callbackfunct_t
int(* thread_callbackfunct_t)(ctx_t *ctx_p, thread_callbackfunct_arg_t *arg_p)
Definition: sync.h:29
state_t
enum state_enum state_t
Definition: ctx.h:272
sync_prequeue_unload
int sync_prequeue_unload(struct ctx *ctx_p, struct indexes *indexes_p)
Definition: sync.c:2564
threadinfo::ctx_p
ctx_t * ctx_p
Definition: sync.h:40
sync_prequeue_loadmark
int sync_prequeue_loadmark(int fsmon_d, struct ctx *ctx_p, struct indexes *indexes_p, const char *path_full, const char *path_rel, stat64_t *lst_p, eventobjtype_t objtype_old, eventobjtype_t objtype_new, uint32_t event_mask, int event_wd, mode_t st_mode, off_t st_size, char **path_buf_p, size_t *path_buf_len_p, struct eventinfo *evinfo)
Definition: sync.c:2143
threadsinfo
Definition: sync.h:55
thread_callbackfunct_arg::incfpath
char * incfpath
Definition: sync.h:25
threadinfo::errcode
int errcode
Definition: sync.h:38
sync_parameter_get
const char * sync_parameter_get(const char *variable_name, void *_dosync_arg_p)
Definition: sync.c:1548
threadinfo::argv
char ** argv
Definition: sync.h:35
threadsinfo::allocated
int allocated
Definition: sync.h:59
threadinfo::ei
api_eventinfo_t * ei
Definition: sync.h:51
threadinfo
Definition: sync.h:30
threadinfo::thread_num
int thread_num
Definition: sync.h:31
pthread_sighandler
pthread_t pthread_sighandler
Definition: sync.c:59
threadsinfo::threadsstack
threadinfo_t ** threadsstack
Definition: sync.h:62
threadinfo::pthread
pthread_t pthread
Definition: sync.h:36
eventinfo
Definition: common.h:140
threadinfo::child_pid
int child_pid
Definition: sync.h:43
threadinfo::state
state_t state
Definition: sync.h:39
threadinfo::exitcode
int exitcode
Definition: sync.h:37
threadinfo::starttime
time_t starttime
Definition: sync.h:41
thread_nextexpiretime
time_t thread_nextexpiretime()
stat64_t
struct stat64 stat64_t
Definition: port-hacks.h:65
threadinfo::expiretime
time_t expiretime
Definition: sync.h:42
threadinfo::iteration
uint32_t iteration
Definition: sync.h:32
exitcode
volatile int exitcode
Definition: sync.c:547
threadsinfo::cond
pthread_cond_t cond[PTHREAD_MUTEX_MAX]
Definition: sync.h:57
threadsinfo::mutex_init
char mutex_init
Definition: sync.h:58
thread_callbackfunct_arg
Definition: sync.h:23
threadsinfo::stacklen
int stacklen
Definition: sync.h:63
threadsinfo::mutex
pthread_mutex_t mutex[PTHREAD_MUTEX_MAX]
Definition: sync.h:56
threadinfo::try_n
int try_n
Definition: sync.h:47
ctx_p
ctx_t * ctx_p
Definition: mon_kqueue.c:85