summaryrefslogtreecommitdiff
path: root/source4/ntvfs/sysdep/inotify.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2006-04-05 05:54:10 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:00:17 -0500
commit416d7b421001d00c4d494fceb4f2d0ab3e30cfaf (patch)
tree5551bf9f5e19d758417dff28b6b80fea16ad7b0c /source4/ntvfs/sysdep/inotify.c
parentbacf1152fc711560ed141fa8e6e470cbd9de6efc (diff)
downloadsamba-416d7b421001d00c4d494fceb4f2d0ab3e30cfaf.tar.gz
samba-416d7b421001d00c4d494fceb4f2d0ab3e30cfaf.tar.bz2
samba-416d7b421001d00c4d494fceb4f2d0ab3e30cfaf.zip
r14920: allow a notify backend to separately specify if it has handled the
given mask for the current directory and sub-directories. This allows us to setup the less efficient internal handling for subdirectories, while using the kernel inotify service for the current directory if available. It also allows inotify to handle only some of the filter bits, leaving the other filter bits for the user space handler. (This used to be commit 7c3d989fa44c7f57853a825337159f476d7dff80)
Diffstat (limited to 'source4/ntvfs/sysdep/inotify.c')
-rw-r--r--source4/ntvfs/sysdep/inotify.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/source4/ntvfs/sysdep/inotify.c b/source4/ntvfs/sysdep/inotify.c
index ec8669306e..c95c39ff01 100644
--- a/source4/ntvfs/sysdep/inotify.c
+++ b/source4/ntvfs/sysdep/inotify.c
@@ -190,13 +190,15 @@ static NTSTATUS inotify_setup(struct sys_notify_context *ctx)
/*
- map from a change notify mask to a inotify mask. Approximate only :(
+ map from a change notify mask to a inotify mask. Remove any bits
+ which we can handle
*/
static const struct {
uint32_t notify_mask;
uint32_t inotify_mask;
} inotify_mapping[] = {
{FILE_NOTIFY_CHANGE_FILE_NAME, IN_CREATE|IN_DELETE|IN_MOVED_FROM|IN_MOVED_TO},
+ {FILE_NOTIFY_CHANGE_DIR_NAME, IN_CREATE|IN_DELETE|IN_MOVED_FROM|IN_MOVED_TO},
{FILE_NOTIFY_CHANGE_ATTRIBUTES, IN_ATTRIB},
{FILE_NOTIFY_CHANGE_SIZE, IN_MODIFY},
{FILE_NOTIFY_CHANGE_LAST_WRITE, IN_ATTRIB},
@@ -204,13 +206,14 @@ static const struct {
{FILE_NOTIFY_CHANGE_SECURITY, IN_ATTRIB}
};
-static uint32_t inotify_map(uint32_t mask)
+static uint32_t inotify_map(struct notify_entry *e)
{
int i;
uint32_t out=0;
for (i=0;i<ARRAY_SIZE(inotify_mapping);i++) {
- if (inotify_mapping[i].notify_mask & mask) {
+ if (inotify_mapping[i].notify_mask & e->filter) {
out |= inotify_mapping[i].inotify_mask;
+ e->filter &= ~inotify_mapping[i].notify_mask;
}
}
return out;
@@ -241,14 +244,15 @@ static int watch_destructor(void *ptr)
add a watch. The watch is removed when the caller calls
talloc_free() on *handle
*/
-static NTSTATUS inotify_watch(struct sys_notify_context *ctx, const char *dirpath,
- uint32_t filter, sys_notify_callback_t callback,
- void *private, void **handle)
+static NTSTATUS inotify_watch(struct sys_notify_context *ctx, struct notify_entry *e,
+ sys_notify_callback_t callback, void *private,
+ void **handle)
{
struct inotify_private *in;
int wd;
uint32_t mask;
struct watch_context *w;
+ uint32_t filter = e->filter;
/* maybe setup the inotify fd */
if (ctx->private == NULL) {
@@ -259,7 +263,7 @@ static NTSTATUS inotify_watch(struct sys_notify_context *ctx, const char *dirpat
in = talloc_get_type(ctx->private, struct inotify_private);
- mask = inotify_map(filter);
+ mask = inotify_map(e);
if (mask == 0) {
/* this filter can't be handled by inotify */
return NT_STATUS_INVALID_PARAMETER;
@@ -270,14 +274,16 @@ static NTSTATUS inotify_watch(struct sys_notify_context *ctx, const char *dirpat
mask |= (IN_MASK_ADD | IN_ONLYDIR);
/* get a new watch descriptor for this path */
- wd = inotify_add_watch(in->fd, dirpath, mask);
+ wd = inotify_add_watch(in->fd, e->path, mask);
if (wd == -1) {
+ e->filter = filter;
return map_nt_error_from_unix(errno);
}
w = talloc(in, struct watch_context);
if (w == NULL) {
inotify_rm_watch(in->fd, wd);
+ e->filter = filter;
return NT_STATUS_NO_MEMORY;
}