summaryrefslogtreecommitdiff
path: root/source4/ntvfs/sysdep/sys_notify.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/sys_notify.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/sys_notify.c')
-rw-r--r--source4/ntvfs/sysdep/sys_notify.c38
1 files changed, 24 insertions, 14 deletions
diff --git a/source4/ntvfs/sysdep/sys_notify.c b/source4/ntvfs/sysdep/sys_notify.c
index 1927ac61ce..1be57dd55a 100644
--- a/source4/ntvfs/sysdep/sys_notify.c
+++ b/source4/ntvfs/sysdep/sys_notify.c
@@ -31,7 +31,7 @@
/* list of registered backends */
static struct sys_notify_backend *backends;
-
+static uint32_t num_backends;
/*
initialise a system change notify backend
@@ -43,8 +43,9 @@ struct sys_notify_context *sys_notify_init(int snum,
struct sys_notify_context *ctx;
const char *bname;
struct sys_notify_backend *b;
+ int i;
- if (backends == NULL) {
+ if (num_backends == 0) {
return NULL;
}
@@ -61,16 +62,16 @@ struct sys_notify_context *sys_notify_init(int snum,
bname = lp_parm_string(snum, "notify", "backend");
if (!bname) {
- if (backends) {
- bname = backends->name;
+ if (num_backends) {
+ bname = backends[0].name;
} else {
bname = "__unknown__";
}
}
- for (b=backends;b;b=b->next) {
- if (strcasecmp(b->name, bname) == 0) {
- bname = b->name;
+ for (i=0;i<num_backends;i++) {
+ if (strcasecmp(backends[i].name, bname) == 0) {
+ bname = backends[i].name;
break;
}
}
@@ -78,8 +79,8 @@ struct sys_notify_context *sys_notify_init(int snum,
ctx->name = bname;
ctx->notify_watch = NULL;
- if (b != NULL) {
- ctx->notify_watch = b->notify_watch;
+ if (i < num_backends) {
+ ctx->notify_watch = backends[i].notify_watch;
}
return ctx;
@@ -87,15 +88,18 @@ struct sys_notify_context *sys_notify_init(int snum,
/*
add a watch
+
+ note that this call must modify the e->filter and e->subdir_filter
+ bits to remove ones handled by this backend. Any remaining bits will
+ be handled by the generic notify layer
*/
-NTSTATUS sys_notify_watch(struct sys_notify_context *ctx, const char *dirpath,
- uint32_t filter, sys_notify_callback_t callback,
- void *private, void **handle)
+NTSTATUS sys_notify_watch(struct sys_notify_context *ctx, struct notify_entry *e,
+ sys_notify_callback_t callback, void *private, void **handle)
{
if (!ctx->notify_watch) {
return NT_STATUS_NOT_IMPLEMENTED;
}
- return ctx->notify_watch(ctx, dirpath, filter, callback, private, handle);
+ return ctx->notify_watch(ctx, e, callback, private, handle);
}
/*
@@ -103,6 +107,12 @@ NTSTATUS sys_notify_watch(struct sys_notify_context *ctx, const char *dirpath,
*/
NTSTATUS sys_notify_register(struct sys_notify_backend *backend)
{
- DLIST_ADD(backends, backend);
+ struct sys_notify_backend *b;
+ b = talloc_realloc(talloc_autofree_context(), backends,
+ struct sys_notify_backend, num_backends+1);
+ NT_STATUS_HAVE_NO_MEMORY(b);
+ backends = b;
+ backends[num_backends] = *backend;
+ num_backends++;
return NT_STATUS_OK;
}