資源簡介
Lsyncd 遠程、本地目錄自動同步
簡介:
Lsyncd是由谷歌公司開發(fā)的一款輕量級目錄同步工具。采用(inotify或fsevents)監(jiān)控目錄樹的變化。rsync+ssh是一個先進的功能配置,這種配置利用SSH來執(zhí)行文件和目錄直接移動到目標上,而不是通過網(wǎng)絡(luò)再次傳送這個到目標,lua語言格定義配置文件。
代碼片段和文件信息
/**?fsevents.c?from?Lsyncd?-?Live?(Mirror)?Syncing?Demon
?*
?*?License:?GPLv2?(see?COPYING)?or?any?later?version
?*
?*?Authors:?Axel?Kittenberger?
?*??????????Damian?Steward?
?*
?*?-----------------------------------------------------------------------
?*
?*?Event?interface?for?MacOS?10.5?(Leopard)?/dev/fsevents?interface.
?*
?*?Special?thanks?go?to?Amit?Singh?and?his?fslogger?demonstration?that?showed
?*?how?apples?/dev/fsevents?can?be?used.??http://osxbook.com/software/fslogger/
?*
?*?--?WARNING?--?Quoting?http://www.osxbook.com/software/fslogger/?--
?*
?*?The?interface?that?fslogger?[and?thus?Lsyncd]?uses?is?private?to?Apple.
?*?Currently?there?is?a?caveat?regarding?the?use?of?this?interface?by?third
?*?parties?(including?fslogger?[and?thus?Lsyncd]).?While?the?change
?*?notification?interface?supports?multiple?clients?there?is?a?single?kernel
?*?buffer?for?holding?events?that?are?to?be?delivered?to?one?or?more
?*?subscribers?with?the?primary?subscriber?being?Spotlight.?Now?the?kernel
?*?must?hold?events?until?it?has?notified?all?subscribers?that?are?interested
?*?in?them.?Since?there?is?a?single?buffer?a?slow?subscriber?can?cause?it?to
?*?overflow.?If?this?happens?events?will?be?dropped?—?for?all?subscribers
?*?including?Spotlight.??Consequently?Spotlight?may?need?to?look?at?the?entire
?*?volume?to?determine?“what?changed“.
?*/
#include?“l(fā)syncd.h“
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?“bsd/sys/fsevents.h“
#include?
#include?
#include?
/*?the?fsevents?pseudo-device?*/
#define?DEV_FSEVENTS?????“/dev/fsevents“
/*?buffer?for?reading?from?the?device?*/
#define?FSEVENT_BUFSIZ???131072?
/*?limited?by?MAX_KFS_EVENTS?*/
#define?EVENT_QUEUE_SIZE?4096??
#define?KFS_NUM_ARGS??FSE_MAX_ARGS
/*?OS?10.5?structuce?*/
/*?an?event?argument?*/
struct?kfs_event_arg?{
/*?argument?type?*/
????u_int16_t??type;
????/*?size?of?argument?data?that?follows?this?field?*/
????u_int16_t??len;
????union?{
????????struct?vnode?*vp;
????????char????*str;
????????void????*ptr;
????????int32_t??int32;
????????dev_t????dev;
????????ino_t????ino;
????????int32_t??mode;
????????uid_t????uid;
????????gid_t????gid;
????????uint64_t?timestamp;
????}?data;
};
/*?OS?10.5?structuce?*/
/*?an?event?*/
struct?kfs_event?{
/*?event?type?*/
????int32_t??type;
/*?pid?of?the?process?that?performed?the?operation?*/
????pid_t????pid;
/*?event?arguments?*/
????struct?kfs_event_arg*?args[FSE_MAX_ARGS];
};
/**
?*?fsevents?(cloned)?filedescriptor
?*/
static?int?fsevents_fd?=?-1;
/*?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“
};*/
/*?argument?names*/
/*static?
評論
共有 條評論