This commit is contained in:
Axel Kittenberger 2010-10-27 10:03:48 +00:00
parent 50defac7c6
commit 40ce23235c
2 changed files with 26 additions and 14 deletions

View File

@ -19,24 +19,24 @@ slowbash = {
startup = function(source, target) startup = function(source, target)
log(NORMAL, "cp -r from "..source.." -> "..target) log(NORMAL, "cp -r from "..source.." -> "..target)
return exec("/bin/bash", "-c", "cp -r \"$1\"* \"$2\"", "/bin/bash", return exec("/bin/bash", "-c", [[if [ "$(ls -A $1)" ]; then cp -r "$1"* "$2"; fi]],
source, target) "/bin/bash", source, target)
end, end,
create = function(source, path, name, target) create = function(source, path, name, target)
local src = source..path..name local src = source..path..name
local trg = target..path..name local trg = target..path..name
log(NORMAL, "create from "..src.." -> "..trg) log(NORMAL, "create from "..src.." -> "..trg)
return exec("/bin/bash", "-c", slower.."cp \"$1\" \"$2\"", "/bin/bash", return exec("/bin/bash", "-c", slower..[[cp "$1" "$2"]],
src, trg) "/bin/bash", src, trg)
end, end,
modify = function(source, path, name, target) modify = function(source, path, name, target)
local src = source..path..name local src = source..path..name
local trg = target..path..name local trg = target..path..name
log(NORMAL, "modify from "..src.." -> "..trg) log(NORMAL, "modify from "..src.." -> "..trg)
return exec("/bin/bash", "-c", slower.."cp \"$1\" \"$2\"", "/bin/bash", return exec("/bin/bash", "-c", slower..[[cp "$1" "$2"]],
src, trg) "/bin/bash", src, trg)
end, end,
attrib = function(source, path, name, target) attrib = function(source, path, name, target)
@ -46,8 +46,8 @@ slowbash = {
delete = function(source, path, name, target) delete = function(source, path, name, target)
log(NORMAL, "delete "..target..path..name) log(NORMAL, "delete "..target..path..name)
return exec("/bin/bash", "-c", slower.."rm \"$1\"", "/bin/bash", return exec("/bin/bash", "-c", slower..[[rm "$1"]],
target..path..name) "/bin/bash", target..path..name)
end, end,
-- move = function(source, path, name, destpath, destname, target) -- move = function(source, path, name, destpath, destname, target)

View File

@ -38,6 +38,18 @@
#include <lualib.h> #include <lualib.h>
#include <lauxlib.h> #include <lauxlib.h>
/**
* Extended debugging, undefine these to enable respective parts.
*/
#define DBG_MASTERLOOP(x)
/**
* Debugging definitions
*/
#ifndef DBG_MASTERLOOP
#define DBG_MASTERLOOP(x) { logstring(DEBUG, x); }
#endif
/** /**
* Macros to compare times() values * Macros to compare times() values
* (borrowed from linux/jiffies.h) * (borrowed from linux/jiffies.h)
@ -881,7 +893,7 @@ masterloop(lua_State *L)
if (have_alarm && time_before(alarm_time, now)) { if (have_alarm && time_before(alarm_time, now)) {
/* there is a delay that wants to be handled already /* there is a delay that wants to be handled already
* thus do not read from inotify_fd and jump directly to its handling */ * thus do not read from inotify_fd and jump directly to its handling */
logstring(DEBUG, "immediately handling delays."); DBG_MASTERLOOP("immediately handling delays.");
do_read = 0; do_read = 0;
} else { } else {
/* use select() to determine what happens next /* use select() to determine what happens next
@ -894,11 +906,11 @@ masterloop(lua_State *L)
sigemptyset(&sigset); sigemptyset(&sigset);
if (have_alarm) { if (have_alarm) {
logstring(DEBUG, "going into timed select."); DBG_MASTERLOOP("going into timed select.");
tv.tv_sec = (alarm_time - now) / clocks_per_sec; tv.tv_sec = (alarm_time - now) / clocks_per_sec;
tv.tv_nsec = (alarm_time - now) * 1000000000 / clocks_per_sec % 1000000000; tv.tv_nsec = (alarm_time - now) * 1000000000 / clocks_per_sec % 1000000000;
} else { } else {
logstring(DEBUG, "going into blocking select."); DBG_MASTERLOOP("going into blocking select.");
} }
/* if select returns a positive number there is data on inotify /* if select returns a positive number there is data on inotify
* on zero the timemout occured. */ * on zero the timemout occured. */
@ -908,9 +920,9 @@ masterloop(lua_State *L)
&sigset); &sigset);
if (do_read > 0) { if (do_read > 0) {
logstring(DEBUG, "theres data on inotify."); DBG_MASTERLOOP("theres data on inotify.");
} else { } else {
logstring(DEBUG, "core: select() timeout or signal."); DBG_MASTERLOOP("core: select() timeout or signal.");
} }
} }
@ -943,7 +955,7 @@ masterloop(lua_State *L)
FD_SET(inotify_fd, &readfds); FD_SET(inotify_fd, &readfds);
do_read = pselect(inotify_fd + 1, &readfds, NULL, NULL, &tv, NULL); do_read = pselect(inotify_fd + 1, &readfds, NULL, NULL, &tv, NULL);
if (do_read > 0) { if (do_read > 0) {
logstring(DEBUG, "there is more data on inotify."); DBG_MASTERLOOP("there is more data on inotify.");
} }
} }
} }