mirror of
https://github.com/octoleo/lsyncd.git
synced 2024-12-13 14:43:09 +00:00
and some work on the fsevents front
This commit is contained in:
parent
a28bea5048
commit
ea9e8498e0
38
fsevents.c
38
fsevents.c
@ -100,6 +100,20 @@ static const luaL_reg lfseventslib[] = {
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
// event names
|
||||
static const char *eventNames[FSE_MAX_EVENTS] = {
|
||||
"CREATE_FILE",
|
||||
"DELETE",
|
||||
"STAT_CHANGED",
|
||||
"RENAME",
|
||||
"CONTENT_MODIFIED",
|
||||
"EXCHANGE",
|
||||
"FINDER_INFO_CHANGED",
|
||||
"CREATE_DIR",
|
||||
"CHOWN",
|
||||
"XATTR_MODIFIED",
|
||||
"XATTR_REMOVED",
|
||||
};
|
||||
|
||||
static size_t const readbuf_size = 131072;
|
||||
static char * readbuf = NULL;
|
||||
@ -154,8 +168,21 @@ fsevents_ready(lua_State *L, struct observance *obs)
|
||||
}
|
||||
atype = event->type & FSE_TYPE_MASK;
|
||||
aflags = FSE_GET_FLAGS(event->type);
|
||||
}
|
||||
|
||||
if ((atype < FSE_MAX_EVENTS) && (atype >= -1)) {
|
||||
printlogf(L, "Fsevents", "got event %s", eventNames[atype]);
|
||||
if (aflags & FSE_COMBINED_EVENTS) {
|
||||
logstring("Fsevents", "combined events");
|
||||
}
|
||||
if (aflags & FSE_CONTAINS_DROPPED_EVENTS) {
|
||||
logstring("Fsevents", "contains dropped events");
|
||||
}
|
||||
} else {
|
||||
printlogf(L, "Error", "unknown event(%d) in fsevents.",
|
||||
atype);
|
||||
exit(-1); // ERRNO
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -171,6 +198,8 @@ fsevents_tidy(struct observance *obs)
|
||||
exit(-1); // ERRNO
|
||||
}
|
||||
close(fsevents_fd);
|
||||
free(readbuf);
|
||||
readbuf = NULL;
|
||||
}
|
||||
|
||||
|
||||
@ -225,6 +254,13 @@ open_fsevents(lua_State *L)
|
||||
exit(-1); // ERRNO
|
||||
}
|
||||
|
||||
if (readbuf) {
|
||||
logstring("Error",
|
||||
"internal fail, inotify readbuf!=NULL in open_inotify()")
|
||||
exit(-1); // ERRNO
|
||||
}
|
||||
readbuf = s_malloc(readbuf_size);
|
||||
|
||||
/* fd has been cloned, closes access fd */
|
||||
close(fd);
|
||||
close_exec_fd(fsevents_fd);
|
||||
|
@ -318,7 +318,8 @@ inotify_ready(lua_State *L, struct observance *obs)
|
||||
* registers inotify functions.
|
||||
*/
|
||||
extern void
|
||||
register_inotify(lua_State *L) {
|
||||
register_inotify(lua_State *L)
|
||||
{
|
||||
lua_pushstring(L, "inotify");
|
||||
luaL_register(L, "inotify", linotfylib);
|
||||
}
|
||||
@ -327,7 +328,8 @@ register_inotify(lua_State *L) {
|
||||
* closes inotify
|
||||
*/
|
||||
static void
|
||||
inotify_tidy(struct observance *obs) {
|
||||
inotify_tidy(struct observance *obs)
|
||||
{
|
||||
if (obs->fd != inotify_fd) {
|
||||
logstring("Error", "Internal, inotify_fd != ob->fd");
|
||||
exit(-1); // ERRNO
|
||||
@ -341,7 +343,8 @@ inotify_tidy(struct observance *obs) {
|
||||
* opens and initalizes inotify.
|
||||
*/
|
||||
extern void
|
||||
open_inotify(lua_State *L) {
|
||||
open_inotify(lua_State *L)
|
||||
{
|
||||
if (readbuf) {
|
||||
logstring("Error",
|
||||
"internal fail, inotify readbuf!=NULL in open_inotify()")
|
||||
|
Loading…
Reference in New Issue
Block a user