disabled fanotify, no moves

This commit is contained in:
Axel Kittenberger 2010-11-28 10:47:57 +00:00
parent 45df73c4c0
commit 67381778d8
5 changed files with 149 additions and 32 deletions

View File

@ -5,9 +5,10 @@ lsyncd_SOURCES = lsyncd.h lsyncd.c lsyncd.lua
if INOTIFY if INOTIFY
lsyncd_SOURCES += inotify.c lsyncd_SOURCES += inotify.c
endif endif
if FANOTIFY #if FANOTIFY
lsyncd_SOURCES += fanotify.c #lsyncd_SOURCES += fanotify.c
endif #endif
if FSEVENTS if FSEVENTS
lsyncd_SOURCES += fsevents.c lsyncd_SOURCES += fsevents.c
endif endif

View File

@ -40,18 +40,19 @@ fi
AM_CONDITIONAL([INOTIFY], [test x${with_inotify} != xno]) AM_CONDITIONAL([INOTIFY], [test x${with_inotify} != xno])
### ###
# --without-inotify option # --with-fanotify option
AC_ARG_WITH([fanotify], ##
[ --with-fanotify Uses Linux new fanotify event interface. EXPERIMENTAL! #AC_ARG_WITH([fanotify],
Off by default.]) #[ --with-fanotify Uses Linux new fanotify event interface. EXPERIMENTAL!
if test "x${with_fanotify}" == xno; then # Off by default.])
echo "compiling without fanotify" ##if test "x${with_fanotify}" == xno; then
else # echo "compiling without fanotify"
echo "compiling with fanotify - WARNING experimental!" #else
AC_DEFINE(LSYNCD_WITH_FANOTIFY,,"descr") # echo "compiling with fanotify - WARNING experimental!"
fi # AC_DEFINE(LSYNCD_WITH_FANOTIFY,,"descr")
AM_CONDITIONAL([FANOTIFY], ##fi
[test x${with_fanotify} != x -a x${with_fanotify} != xno]) #AM_CONDITIONAL([FANOTIFY],
# [test x${with_fanotify} != x -a x${with_fanotify} != xno])
### ###
# --with-fsevents # --with-fsevents

View File

@ -31,10 +31,24 @@
*/ */
static int fanotify_fd = -1; static int fanotify_fd = -1;
/**
* Adds a filesystem to watch
*
* @param dir (Lua stack) the dir to watch the filesystem of.
* @return nil
*/
static int
l_watchfs(lua_State *L)
{
// const char *path = luaL_checkstring(L, 1);
return 0;
}
/** /**
* Cores fanotify functions. * Cores fanotify functions.
*/ */
static const luaL_reg lfanotifylib[] = { static const luaL_reg lfanotifylib[] = {
{"watchfs", l_watchfs },
{NULL, NULL} {NULL, NULL}
}; };

View File

@ -255,8 +255,12 @@ static char * readbuf = NULL;
* to the runner. * to the runner.
*/ */
static void static void
inotify_ready(lua_State *L, int fd, void *extra) inotify_ready(lua_State *L, struct observance *obs)
{ {
if (obs->fd != inotify_fd) {
logstring("Error", "Internal, inotify_fd != ob->fd");
exit(-1); // ERRNO
}
while(true) { while(true) {
ptrdiff_t len; ptrdiff_t len;
int err; int err;
@ -323,8 +327,8 @@ register_inotify(lua_State *L) {
* closes inotify * closes inotify
*/ */
static void static void
inotify_tidy(struct observance *ob) { inotify_tidy(struct observance *obs) {
if (ob->fd != inotify_fd) { if (obs->fd != inotify_fd) {
logstring("Error", "Internal, inotify_fd != ob->fd"); logstring("Error", "Internal, inotify_fd != ob->fd");
exit(-1); // ERRNO exit(-1); // ERRNO
} }

View File

@ -36,6 +36,12 @@ _l = nil
log = lsyncd.log log = lsyncd.log
terminate = lsyncd.terminate terminate = lsyncd.terminate
------
-- Predeclarations
--
local Monitors
--============================================================================ --============================================================================
-- Lsyncd Prototypes -- Lsyncd Prototypes
--============================================================================ --============================================================================
@ -885,7 +891,7 @@ local Sync = (function()
if delay.status then if delay.status then
-- collected an event -- collected an event
if delay.status ~= "active" then if delay.status ~= "active" then
error("internal fail, collecting a non-active process") error("collecting a non-active process")
end end
InletControl.setSync(self) InletControl.setSync(self)
local rc = self.config.collect(InletControl.d2e(delay), exitcode) local rc = self.config.collect(InletControl.d2e(delay), exitcode)
@ -1420,6 +1426,18 @@ local Syncs = (function()
end end
end end
-- the monitor to use
config.monitor =
settings.monitor or config.monitor or Monitors.default()
if config.monitor ~= "inotify"
-- and config.monitor ~= "fanotify"
then
local info = debug.getinfo(3, "Sl")
log("Error", info.short_src, ":", info.currentline,
": event monitor '",config.monitor,"' unknown.")
terminate(-1) -- ERRNO
end
--- creates the new sync --- creates the new sync
local s = Sync.new(config) local s = Sync.new(config)
table.insert(list, s) table.insert(list, s)
@ -1464,8 +1482,6 @@ end
-- sends events. -- sends events.
-- --
-- All inotify specific implementation should be enclosed here. -- All inotify specific implementation should be enclosed here.
-- So lsyncd can work with other notifications mechanisms just
-- by changing this.
-- --
local Inotify = (function() local Inotify = (function()
@ -1572,15 +1588,15 @@ local Inotify = (function()
----- -----
-- adds a Sync to receive events -- adds a Sync to receive events
-- --
-- @param root root dir to watch
-- @param sync Object to receive events -- @param sync Object to receive events
-- @param rootdir root dir to watch
-- --
local function addSync(sync, root) local function addSync(sync, rootdir)
if syncRoots[sync] then if syncRoots[sync] then
error("internal fail, duplicate sync in Inotify.addSync()") error("duplicate sync in Inotify.addSync()")
end end
syncRoots[sync] = root syncRoots[sync] = rootdir
addWatch(root, true) addWatch(rootdir, true)
end end
----- -----
@ -1683,7 +1699,7 @@ local Inotify = (function()
-- Writes a status report about inotifies to a filedescriptor -- Writes a status report about inotifies to a filedescriptor
-- --
local function statusReport(f) local function statusReport(f)
f:write("Watching ",wdpaths:size()," directories\n") f:write("Inotify watching ",wdpaths:size()," directories\n")
for wd, path in wdpaths:walk() do for wd, path in wdpaths:walk() do
f:write(" ",wd,": ",path,"\n") f:write(" ",wd,": ",path,"\n")
end end
@ -1697,15 +1713,84 @@ local Inotify = (function()
} }
end)() end)()
-----
-- Interface to fanotify, watches a whole filesystems
--
-- NOT USED.
--
-- All fanotify specific implementation should be enclosed here.
--
--[[
local Fanotify = (function()
-----
-- A list indexed by sync's containing the root path this
-- sync is interested in.
--
local syncPaths = {}
-----
-- adds a Sync to receive events
--
-- @param sync Object to receive events
-- @param dir dir to watch
--
local function addSync(sync, dir)
if syncRoots[sync] then
error("duplicate sync in Fanotify.addSync()")
end
-- TODO for non subdirs adddir only
lsyncd.fanotify.watchfs(dir)
syncRoots[sync] = dir
end
-----
-- Called when any event has occured.
--
-- @param etype "Attrib", "Mofify", "Create", "Delete", "Move")
-- @param wd watch descriptor (matches lsyncd.inotifyadd())
-- @param isdir true if filename is a directory
-- @param time time of event
-- @param filename string filename without path
-- @param filename2
--
local function event(etype, isdir, time, filename, filename2)
print("FANOTIFY", etype, isdir, time, filename, filename2)
end
-----
-- Writes a status report about inotifies to a filedescriptor
--
local function statusReport(f)
-- TODO
end
-- public interface
return {
addSync = addSync,
event = event,
statusReport = statusReport
}
end)()
]]--
----- -----
-- Holds information about the event monitor capabilities -- Holds information about the event monitor capabilities
-- of the core. -- of the core.
-- --
local Monitors = (function() Monitors = (function()
----- -----
-- The cores monitor list -- The cores monitor list
--
local list = {} local list = {}
-----
-- The default event monitor.
--
local function default()
return list[1]
end
----- -----
-- initializes with info received from core -- initializes with info received from core
-- --
@ -1716,7 +1801,8 @@ local Monitors = (function()
end end
-- public interface -- public interface
return { list = list, return { default = default,
list = list,
initialize = initialize initialize = initialize
} }
end)() end)()
@ -2104,8 +2190,6 @@ OPTIONS:
-log scarce Logs errors only -log scarce Logs errors only
-log [Category] Turns on logging for a debug category -log [Category] Turns on logging for a debug category
-logfile FILE Writes log to FILE (DEFAULT: uses syslog) -logfile FILE Writes log to FILE (DEFAULT: uses syslog)
-monitor NAME Uses operating systems event montior NAME
(inotify/fanotify/fsevents)
-nodaemon Does not detach and logs to stdout/stderr -nodaemon Does not detach and logs to stdout/stderr
-pidfile FILE Writes Lsyncds PID into FILE -pidfile FILE Writes Lsyncds PID into FILE
-runner FILE Loads Lsyncds lua part from FILE -runner FILE Loads Lsyncds lua part from FILE
@ -2118,6 +2202,11 @@ SEE:
`man lsyncd` for further information. `man lsyncd` for further information.
]]) ]])
--
-- -monitor NAME Uses operating systems event montior NAME
-- (inotify/fanotify/fsevents)
os.exit(-1) -- ERRNO os.exit(-1) -- ERRNO
end end
@ -2328,7 +2417,15 @@ function runner.initialize()
-- runs through the Syncs created by users -- runs through the Syncs created by users
for _, s in Syncs.iwalk() do for _, s in Syncs.iwalk() do
Inotify.addSync(s, s.source) if s.config.monitor == "inotify" then
Inotify.addSync(s, s.source)
-- elseif s.config.monitor == "fanotify" then
-- Fanotify.addSync(s, s.source)
else
error("sync "..s.config.name..
" has no known event monitor interface.")
end
if s.config.init then if s.config.init then
InletControl.setSync(s) InletControl.setSync(s)
s.config.init(Inlet) s.config.init(Inlet)