mirror of https://github.com/octoleo/lsyncd.git
preparing fanotify
This commit is contained in:
parent
4cc58347f8
commit
91bad8bf46
|
@ -5,6 +5,9 @@ lsyncd_SOURCES = lsyncd.h lsyncd.c lsyncd.lua
|
||||||
if INOTIFY
|
if INOTIFY
|
||||||
lsyncd_SOURCES += inotify.c
|
lsyncd_SOURCES += inotify.c
|
||||||
endif
|
endif
|
||||||
|
if FANOTIFY
|
||||||
|
lsyncd_SOURCES += fanotify.c
|
||||||
|
endif
|
||||||
if FSEVENTS
|
if FSEVENTS
|
||||||
lsyncd_SOURCES += fsevents.c
|
lsyncd_SOURCES += fsevents.c
|
||||||
endif
|
endif
|
||||||
|
|
28
configure.ac
28
configure.ac
|
@ -29,7 +29,7 @@ AM_CONDITIONAL([RUNNER], [test x${with_runner} != x])
|
||||||
###
|
###
|
||||||
# --without-inotify option
|
# --without-inotify option
|
||||||
AC_ARG_WITH([inotify],
|
AC_ARG_WITH([inotify],
|
||||||
[ --without-inotify Do not compile Linux inotify event interface. On by default.])
|
[ --without-inotify Do not use Linux inotify event interface. On by default.])
|
||||||
if test "x${with_inotify}" == xno; then
|
if test "x${with_inotify}" == xno; then
|
||||||
echo "compiling without inotify"
|
echo "compiling without inotify"
|
||||||
else
|
else
|
||||||
|
@ -38,21 +38,33 @@ else
|
||||||
fi
|
fi
|
||||||
AM_CONDITIONAL([INOTIFY], [test x${with_inotify} != xno])
|
AM_CONDITIONAL([INOTIFY], [test x${with_inotify} != xno])
|
||||||
|
|
||||||
|
###
|
||||||
|
# --without-inotify option
|
||||||
|
AC_ARG_WITH([fanotify],
|
||||||
|
[ --with-fanotify Uses Linux new fanotify event interface. EXPERIMENTAL!
|
||||||
|
Off by default.])
|
||||||
|
if test "x${with_fanotify}" == xno; then
|
||||||
|
echo "compiling without fanotify"
|
||||||
|
else
|
||||||
|
echo "compiling with fanotify - WARNING experimental!"
|
||||||
|
AC_DEFINE(LSYNCD_WITH_FANOTIFY,,"descr")
|
||||||
|
fi
|
||||||
|
AM_CONDITIONAL([FANOTIFY],
|
||||||
|
[test x${with_fanotify} != x -a x${with_fanotify} != xno])
|
||||||
|
|
||||||
###
|
###
|
||||||
# --with-fsevents
|
# --with-fsevents
|
||||||
AC_ARG_WITH([fsevents],
|
AC_ARG_WITH([fsevents],
|
||||||
[ --with-fsevents=DIR Uses MacOS (10.5) /dev/fsevents, experimental! Off by default.
|
[ --with-fsevents Uses MacOS (10.5) /dev/fsevents. EXPERIMENTAL!
|
||||||
As DIR specify dir where xnu headers can be found.])
|
Off by default.])
|
||||||
if test "x${with_fsevents}" == xno; then
|
|
||||||
with_fsevents=
|
|
||||||
fi
|
|
||||||
if test "x${with_fsevents}" != x; then
|
if test "x${with_fsevents}" != x; then
|
||||||
echo "compiling with fsevents. Warning experimental!"
|
echo "compiling with fsevents. WARNING experimental!"
|
||||||
AC_DEFINE(LSYNCD_WITH_FSEVENTS,,"descr")
|
AC_DEFINE(LSYNCD_WITH_FSEVENTS,,"descr")
|
||||||
else
|
else
|
||||||
echo "compiling without fsevents"
|
echo "compiling without fsevents"
|
||||||
fi
|
fi
|
||||||
AM_CONDITIONAL([FSEVENTS], [test x${with_fsevents} != x])
|
AM_CONDITIONAL([FSEVENTS],
|
||||||
|
[test x${with_fsevents} != x -a xno${with_fsevents} != xno])
|
||||||
|
|
||||||
# Checks for typedefs, structures, and compiler characteristics.
|
# Checks for typedefs, structures, and compiler characteristics.
|
||||||
# Checks for library functions.
|
# Checks for library functions.
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
/**
|
||||||
|
* fsevents.c from Lsyncd - Live (Mirror) Syncing Demon
|
||||||
|
*
|
||||||
|
* License: GPLv2 (see COPYING) or any later version
|
||||||
|
*
|
||||||
|
* Authors: Axel Kittenberger <axkibe@gmail.com>
|
||||||
|
*
|
||||||
|
* -----------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
* Interface to Linux' new filesystem monitor - fanotify.
|
||||||
|
*/
|
||||||
|
#include "lsyncd.h"
|
||||||
|
|
||||||
|
#include <lua.h>
|
||||||
|
#include <lualib.h>
|
||||||
|
#include <lauxlib.h>
|
||||||
|
|
||||||
|
static const luaL_reg lfanotifylib[] = {
|
||||||
|
{NULL, NULL}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* registers fanoitfy functions.
|
||||||
|
*/
|
||||||
|
extern void
|
||||||
|
register_fanotify(lua_State *L) {
|
||||||
|
lua_pushstring(L, "fanotify");
|
||||||
|
luaL_register(L, "fanotify", lfanotifylib);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* opens and initalizes fsevents.
|
||||||
|
*/
|
||||||
|
extern void
|
||||||
|
open_fanotify(lua_State *L) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* closes fsevents
|
||||||
|
*/
|
||||||
|
extern void
|
||||||
|
close_fanotify() {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
37
lsyncd.c
37
lsyncd.c
|
@ -44,17 +44,32 @@
|
||||||
extern char _binary_luac_out_end;
|
extern char _binary_luac_out_end;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default notification system to use.
|
* Makes sure there is one monitor.
|
||||||
*/
|
*/
|
||||||
#if defined LSYNCD_WITH_INOTIFY
|
#ifndef LSYNCD_WITH_INOTIFY
|
||||||
static char *default_notify = "Inotify";
|
#ifndef LSYNCD_WITH_FANOTIFY
|
||||||
#elif defined LSYNCD_WITH_FSEVENTS
|
#ifndef LSYNCD_WITH_FSEVENTS
|
||||||
static char *default_notify = "FsEvents";
|
|
||||||
#else
|
|
||||||
# error "need at least one notifcation system. please rerun ./configure"
|
# error "need at least one notifcation system. please rerun ./configure"
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* All monitors supported by this Lsyncd.
|
||||||
|
*/
|
||||||
|
static char *monitors[] = {
|
||||||
|
#ifdef LSYNCD_WITH_INOTIFY
|
||||||
|
"inotify",
|
||||||
|
#endif
|
||||||
|
#ifdef LSYNCD_WITH_FANOTIFY
|
||||||
|
"fanotify",
|
||||||
|
#endif
|
||||||
|
#ifdef LSYNCD_WITH_FSEVENTS
|
||||||
|
"fsevents",
|
||||||
|
#endif
|
||||||
|
NULL,
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* configuration parameters
|
* configuration parameters
|
||||||
|
@ -1542,10 +1557,16 @@ main1(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
int idx = 1;
|
||||||
/* runs initialitions from runner
|
/* runs initialitions from runner
|
||||||
* lua code will set configuration and add watches */
|
* lua code will set configuration and add watches */
|
||||||
load_runner_func(L, "initialize");
|
load_runner_func(L, "initialize");
|
||||||
lua_pushstring(L, default_notify);
|
lua_newtable(L);
|
||||||
|
while (monitors[idx]) {
|
||||||
|
lua_pushnumber(L, idx);
|
||||||
|
lua_pushstring(L, monitors[idx++]);
|
||||||
|
lua_settable(L, -3);
|
||||||
|
}
|
||||||
if (lua_pcall(L, 1, 0, -3)) {
|
if (lua_pcall(L, 1, 0, -3)) {
|
||||||
exit(-1); // ERRNO
|
exit(-1); // ERRNO
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue