资源简介
Lsyncd 远程、本地目录自动同步
简介:
Lsyncd是由谷歌公司开发的一款轻量级目录同步工具。采用(inotify或fsevents)监控目录树的变化。rsync+ssh是一个先进的功能配置,这种配置利用SSH来执行文件和目录直接移动到目标上,而不是通过网络再次传送这个到目标,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 “lsyncd.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
- 上一篇:《计算机应用基础》试卷及参考答案
- 下一篇:MBR-BOOTKIT分析,样本
评论
共有 条评论