mirror of
https://github.com/octoleo/lsyncd.git
synced 2024-12-12 14:17:47 +00:00
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
|
||||
lsyncd_SOURCES += inotify.c
|
||||
endif
|
||||
if FANOTIFY
|
||||
lsyncd_SOURCES += fanotify.c
|
||||
endif
|
||||
if FSEVENTS
|
||||
lsyncd_SOURCES += fsevents.c
|
||||
endif
|
||||
|
28
configure.ac
28
configure.ac
@ -29,7 +29,7 @@ AM_CONDITIONAL([RUNNER], [test x${with_runner} != x])
|
||||
###
|
||||
# --without-inotify option
|
||||
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
|
||||
echo "compiling without inotify"
|
||||
else
|
||||
@ -38,21 +38,33 @@ else
|
||||
fi
|
||||
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
|
||||
AC_ARG_WITH([fsevents],
|
||||
[ --with-fsevents=DIR Uses MacOS (10.5) /dev/fsevents, experimental! Off by default.
|
||||
As DIR specify dir where xnu headers can be found.])
|
||||
if test "x${with_fsevents}" == xno; then
|
||||
with_fsevents=
|
||||
fi
|
||||
[ --with-fsevents Uses MacOS (10.5) /dev/fsevents. EXPERIMENTAL!
|
||||
Off by default.])
|
||||
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")
|
||||
else
|
||||
echo "compiling without fsevents"
|
||||
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 library functions.
|
||||
|
46
fanotify.c
Normal file
46
fanotify.c
Normal file
@ -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;
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* The default notification system to use.
|
||||
* Makes sure there is one monitor.
|
||||
*/
|
||||
#if defined LSYNCD_WITH_INOTIFY
|
||||
static char *default_notify = "Inotify";
|
||||
#elif defined LSYNCD_WITH_FSEVENTS
|
||||
static char *default_notify = "FsEvents";
|
||||
#else
|
||||
#ifndef LSYNCD_WITH_INOTIFY
|
||||
#ifndef LSYNCD_WITH_FANOTIFY
|
||||
#ifndef LSYNCD_WITH_FSEVENTS
|
||||
# error "need at least one notifcation system. please rerun ./configure"
|
||||
#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
|
||||
@ -1542,10 +1557,16 @@ main1(int argc, char *argv[])
|
||||
}
|
||||
|
||||
{
|
||||
int idx = 1;
|
||||
/* runs initialitions from runner
|
||||
* lua code will set configuration and add watches */
|
||||
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)) {
|
||||
exit(-1); // ERRNO
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user