Toggle navigation
Toggle navigation
This project
Loading...
Sign in
UT
/
clsync
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
redmine
2014-10-06 14:52:50 +0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
903f3c6f05b7d20baba85801053526c5119c8d3c
903f3c6f
1 parent
9a1c373f
Added GIO and monitor engine
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
148 additions
and
4 deletions
Makefile.am
common.h
configuration.h
configure.ac
main.c
man/man1/clsync.1
mon_gio.c
mon_gio.h
sync.c
Makefile.am
View file @
903f3c6
...
...
@@ -11,7 +11,8 @@ clsync_SOURCES = calc.c cluster.c error.c fileutils.c glibex.c \
stringex.h sync.h common.h control.h privileged.h rules.h
\
syscalls.h
clsync_CFLAGS
=
$(AM_CFLAGS)
clsync_CFLAGS
=
$(AM_CFLAGS)
clsync_LDFLAGS
=
$(AM_LDFLAGS)
if
HAVE_KQUEUE
clsync_CFLAGS
+=
-DKQUEUE_SUPPORT
...
...
@@ -32,6 +33,11 @@ if HAVE_BSM
clsync_CFLAGS
+=
-DBSM_SUPPORT
clsync_SOURCES
+=
mon_bsm.c mon_bsm.h
endif
if
HAVE_GIO
clsync_CFLAGS
+=
-DGIO_SUPPORT
$(GIO_CFLAGS)
clsync_LDFLAGS
+=
$(GIO_LIBS)
clsync_SOURCES
+=
mon_gio.c mon_gio.h
endif
if
HAVE_DTRACEPIPE
clsync_CFLAGS
+=
-DDTRACEPIPE_SUPPORT
clsync_SOURCES
+=
mon_dtracepipe.c mon_dtracepipe.h
...
...
common.h
View file @
903f3c6
...
...
@@ -162,6 +162,7 @@ enum notifyengine_enum {
NE_KQUEUE
,
NE_BSM
,
NE_BSM_PREFETCH
,
NE_GIO
,
NE_DTRACEPIPE
,
};
typedef
enum
notifyengine_enum
notifyengine_t
;
...
...
configuration.h
View file @
903f3c6
...
...
@@ -205,5 +205,6 @@ expire-after:20M\n\
#define WAITPID_TIMED_GRANULARITY (30*1000*1000)
#define BSM_QUEUE_LENGTH_MAX (1024*1024)
#define GIO_QUEUE_LENGTH_MAX BSM_QUEUE_LENGTH_MAX
#endif
...
...
configure.ac
View file @
903f3c6
...
...
@@ -272,6 +272,13 @@ AC_ARG_WITH(inotify,
[with_inotify=check]
)
AC_ARG_WITH(gio,
AS_HELP_STRING(--with-gio,
[Enable GIO support as FS monitor subsystem; values: no, lib, check; default: check]),
[],
[with_gio=check]
)
AC_ARG_WITH(bsm,
AS_HELP_STRING(--with-bsm,
[Enable BSM (Sun/*BSD audit) support as FS monitor subsystem; values: no, lib, check; default: check]),
...
...
@@ -365,6 +372,25 @@ case "$with_inotify" in
;;
esac
case "$with_gio" in
check)
PKG_CHECK_MODULES(GIO, [gio-2.0], [
HAVE_GIO=1
AC_SUBST([GIO_CFLAGS])
AC_SUBST([GIO_LIBS])
])
;;
lib)
PKG_CHECK_MODULES(GIO, [gio-2.0], [
HAVE_GIO=1
AC_SUBST([GIO_CFLAGS])
AC_SUBST([GIO_LIBS])
], [
AC_MSG_FAILURE([Cannot find libgio-2.0])
])
;;
esac
case "$with_bsm" in
check)
AC_CHECK_FUNC([au_fetch_tok],
...
...
@@ -429,6 +455,7 @@ AM_CONDITIONAL([HAVE_INOTIFY], [test "x$HAVE_INOTIFY" != "x"])
AM_CONDITIONAL([INOTIFY_OLD], [test "x$INOTIFY_OLD" != "x"])
AM_CONDITIONAL([HAVE_FANOTIFY], [test "x$HAVE_FANOTIFY" != "x"])
AM_CONDITIONAL([HAVE_BSM], [test "x$HAVE_BSM" != "x"])
AM_CONDITIONAL([HAVE_GIO], [test "x$HAVE_GIO" != "x"])
AM_CONDITIONAL([HAVE_DTRACEPIPE], [test "x$HAVE_DTRACEPIPE" != "x"])
AM_CONDITIONAL([HAVE_BACKTRACE], [test "x$HAVE_BACKTRACE" != "x"])
AM_CONDITIONAL([HAVE_CAPABILITIES], [test "x$HAVE_CAPABILITIES" != "x"])
...
...
main.c
View file @
903f3c6
...
...
@@ -322,6 +322,7 @@ static char *const notify_engines[] = {
[
NE_BSM
]
=
"bsm"
,
[
NE_BSM_PREFETCH
]
=
"bsm_prefetch"
,
[
NE_DTRACEPIPE
]
=
"dtracepipe"
,
[
NE_GIO
]
=
"gio"
,
NULL
};
...
...
@@ -494,6 +495,9 @@ int version() {
#ifdef BSM_SUPPORT
" -DBSM_SUPPORT"
#endif
#ifdef GIO_SUPPORT
" -DGIO_SUPPORT"
#endif
#ifdef DTRACEPIPE_SUPPORT
" -DDTRACEPIPE_SUPPORT"
#endif
...
...
@@ -1367,6 +1371,9 @@ int parse_parameter(ctx_t *ctx_p, uint16_t param_id, char *arg, paramsource_t pa
case
NE_BSM
:
case
NE_BSM_PREFETCH
:
#endif
#ifdef GIO_SUPPORT
case
NE_GIO
:
#endif
#ifdef DTRACEPIPE_SUPPORT
case
NE_DTRACEPIPE
:
#endif
...
...
@@ -2008,6 +2015,9 @@ int ctx_check(ctx_t *ctx_p) {
case
NE_BSM
:
case
NE_BSM_PREFETCH
:
#endif
#ifdef GIO_SUPPORT
case
NE_GIO
:
#endif
#ifdef DTRACEPIPE_SUPPORT
case
NE_DTRACEPIPE
:
#endif
...
...
@@ -2027,6 +2037,9 @@ int ctx_check(ctx_t *ctx_p) {
#ifdef BSM_SUPPORT
"
\"
--monitor=bsm
\"
"
#endif
#ifdef GIO_SUPPORT
"
\"
--monitor=gio
\"
"
#endif
#ifdef DTRACEPIPE_SUPPORT
"
\"
--monitor=dtracepipe
\"
"
#endif
...
...
man/man1/clsync.1
View file @
903f3c6
...
...
@@ -1032,6 +1032,22 @@ FreeBSD users: The libinotify on FreeBSD is still not ready and unusable for
to sync a lot of files and directories.
.RE
.IR gio
.RS
Use
.B gio
library.
Crossplatform and tested library that backends to kqueue on FreeBSD and
inotify on Linux. See
.B inotify
and
.B kqueue
sections here for details.
.B Not well tested. Use with caution!
.RE
.IR kqueue
.RS
.BR kqueue "(2) [FreeBSD, (Linux via libkqueue)]"
...
...
mon_gio.c
0 → 100644
View file @
903f3c6
This diff is collapsed. Click to expand it.
mon_gio.h
0 → 100644
View file @
903f3c6
/*
clsync - file tree sync utility based on gio/kqueue/bsm/gio
Copyright (C) 2013-2014 Dmitry Yu Okunev <dyokunev@ut.mephi.ru> 0x8E30679C
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 3 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, see <http://www.gnu.org/licenses/>.
*/
extern
int
gio_wait
(
struct
ctx
*
ctx_p
,
struct
indexes
*
indexes_p
,
struct
timeval
*
tv_p
);
extern
int
gio_handle
(
struct
ctx
*
ctx_p
,
struct
indexes
*
indexes_p
);
extern
int
gio_add_watch_dir
(
struct
ctx
*
ctx_p
,
struct
indexes
*
indexes_p
,
const
char
*
const
accpath
);
extern
int
gio_init
(
ctx_t
*
ctx_p
);
extern
int
gio_deinit
(
ctx_t
*
ctx_p
);
...
...
sync.c
View file @
903f3c6
...
...
@@ -32,6 +32,10 @@
# include "mon_bsm.h"
# include <bsm/audit_kevents.h>
#endif
#if GIO_SUPPORT
# include <gio/gio.h>
# include "mon_gio.h"
#endif
#include "main.h"
#include "error.h"
...
...
@@ -129,14 +133,21 @@ static inline void evinfo_merge(ctx_t *ctx_p, eventinfo_t *evinfo_dst, eventinfo
if
(
SEQID_GE
(
evinfo_src
->
seqid_max
,
evinfo_dst
->
seqid_max
))
{
evinfo_dst
->
objtype_new
=
evinfo_src
->
objtype_new
;
evinfo_dst
->
seqid_max
=
evinfo_src
->
seqid_max
;
#ifdef BSM_SUPPORT
switch
(
ctx_p
->
flags
[
MONITOR
])
{
#ifdef GIO_SUPPORT
case
NE_GIO
:
evinfo_dst
->
evmask
=
evinfo_src
->
evmask
;
break
;
#endif
#ifdef BSM_SUPPORT
case
NE_BSM
:
case
NE_BSM_PREFETCH
:
evinfo_dst
->
evmask
=
evinfo_src
->
evmask
;
break
;
}
#endif
default:
break
;
}
}
return
;
...
...
@@ -1219,6 +1230,11 @@ static inline void evinfo_initialevmask(ctx_t *ctx_p, eventinfo_t *evinfo_p, int
evinfo_p
->
evmask
=
(
isdir
?
AUE_MKDIR
:
AUE_OPEN_RWC
);
break
;
#endif
#ifdef GIO_SUPPORT
case
NE_GIO
:
evinfo_p
->
evmask
=
G_FILE_MONITOR_EVENT_CREATED
;
break
;
#endif
#ifdef VERYPARANOID
default:
critical
(
"Unknown monitor subsystem: %u"
,
ctx_p
->
flags
[
MONITOR
]);
...
...
@@ -1838,6 +1854,12 @@ int sync_notify_init(ctx_t *ctx_p) {
return
0
;
}
#endif
#ifdef GIO_SUPPORT
case
NE_GIO
:
{
critical_on
(
gio_init
(
ctx_p
)
==
-
1
);
return
0
;
}
#endif
}
error
(
"unknown notify-engine: %i"
,
ctx_p
->
flags
[
MONITOR
]);
errno
=
EINVAL
;
...
...
@@ -1949,7 +1971,23 @@ int sync_prequeue_loadmark
eventinfo_t
*
evinfo
)
{
debug
(
5
,
""
);
debug
(
10
,
"%i %p %p %p %p %p %i %i 0x%o %i %i %i %p %p %p"
,
monitored
,
ctx_p
,
indexes_p
,
path_full
,
path_rel
,
lstat_p
,
objtype_old
,
objtype_new
,
event_mask
,
event_wd
,
st_mode
,
st_size
,
path_buf_p
,
path_buf_len_p
,
evinfo
);
#ifdef PARANOID
// &path_buf and &path_buf_len are passed to do not reallocate memory for path_rel/path_full each time
if
((
path_buf_p
==
NULL
||
path_buf_len_p
==
NULL
)
&&
(
path_full
==
NULL
||
path_rel
==
NULL
))
{
...
...
@@ -2078,6 +2116,11 @@ int sync_prequeue_loadmark
evinfo
->
evmask
=
event_mask
;
break
;
#endif
#ifdef GIO_SUPPORT
case
NE_GIO
:
evinfo
->
evmask
=
event_mask
;
break
;
#endif
}
evinfo
->
objtype_new
=
objtype_new
;
...
...
@@ -3815,6 +3858,13 @@ int sync_run(ctx_t *ctx_p) {
ctx_p
->
notifyenginefunct
.
handle
=
bsm_handle
;
break
;
#endif
#ifdef GIO_SUPPORT
case
NE_GIO
:
ctx_p
->
notifyenginefunct
.
add_watch_dir
=
gio_add_watch_dir
;
ctx_p
->
notifyenginefunct
.
wait
=
gio_wait
;
ctx_p
->
notifyenginefunct
.
handle
=
gio_handle
;
break
;
#endif
#ifdef DTRACEPIPE_SUPPORT
case
NE_DTRACEPIPE
:
ctx_p
->
notifyenginefunct
.
add_watch_dir
=
dtracepipe_add_watch_dir
;
...
...
@@ -3895,6 +3945,11 @@ int sync_run(ctx_t *ctx_p) {
bsm_deinit
(
ctx_p
);
break
;
#endif
#ifdef GIO_SUPPORT
case
NE_GIO
:
gio_deinit
(
ctx_p
);
break
;
#endif
#ifdef DTRACEPIPE_SUPPORT
case
NE_DTRACEPIPE
:
dtracepipe_deinit
(
ctx_p
);
...
...
Please
register
or
login
to post a comment