notify: Add "dir" to notify_event
authorVolker Lendecke <vl@samba.org>
Wed, 5 Nov 2014 11:44:42 +0000 (11:44 +0000)
committerJeremy Allison <jra@samba.org>
Tue, 9 Dec 2014 03:12:09 +0000 (04:12 +0100)
"notify_event" only reports names relative to some path that is only
implicitly known via "private_data". Right now "private_data" is the fsp
of the directory holding this notify. I want to use inotify_watch in a
notify-daemon that does not have a fsp available and has more problems
getting the path right out of "private_data". notify_inotify has the
directory under which the event happened available, so make it known to
the callback. Right now no caller uses it yet.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
librpc/idl/notify.idl
source3/smbd/notify_inotify.c
source3/smbd/notify_internal.c
source4/ntvfs/common/notify.c
source4/ntvfs/sysdep/inotify.c

index ec81e8c64ac065c58e424af4c47737a273e52de5..66422ec9f9e56f03c5052d796585d25886ae6264 100644 (file)
@@ -65,6 +65,7 @@ interface notify
        /* structure sent between servers in notify messages */
        typedef [public] struct {
                uint32 action;
+               utf8string dir;
                utf8string path;
                pointer private_data;
        } notify_event;
index ad670affcde19627ca86d87c7c9728534ad6630b..a3c30f1431e7d1bcb79a0f664ac790cb0ff9a129 100644 (file)
@@ -165,6 +165,7 @@ static void inotify_dispatch(struct inotify_private *in,
        for (w=in->watches;w;w=next) {
                next = w->next;
                if (w->wd == e->wd && filter_match(w, e)) {
+                       ne.dir = w->path;
                        w->callback(in->ctx, w->private_data, &ne);
                }
        }
@@ -184,6 +185,7 @@ static void inotify_dispatch(struct inotify_private *in,
                next = w->next;
                if (w->wd == e->wd && filter_match(w, e) &&
                    !(w->filter & FILE_NOTIFY_CHANGE_CREATION)) {
+                       ne.dir = w->path;
                        w->callback(in->ctx, w->private_data, &ne);
                }
        }
index 9d548911528514465658aabe3ea3d0809455aa93..9c0b1901f8c9e71609af4e3eb16283ab382933f5 100644 (file)
@@ -831,9 +831,13 @@ static void notify_handler(struct messaging_context *msg_ctx,
        }
 
        m = (struct notify_msg *)data->data;
-       e.action = m->action;
-       e.path = m->path;
-       e.private_data = m->private_data;
+
+       e = (struct notify_event) {
+               .action = m->action,
+               .path = m->path,
+               .private_data = m->private_data,
+               .dir = discard_const_p(char, "")
+       };
 
        for (listel=notify->list;listel;listel=listel->next) {
                if (listel->private_data == m->private_data) {
index 57142c7f38c8fe0782eef00a02221a08fa60abe4..61da0b8291d1090adfcb201f3cffab6fbee36ca4 100644 (file)
@@ -550,6 +550,7 @@ static void notify_send(struct notify_context *notify, struct notify_entry *e,
        TALLOC_CTX *tmp_ctx;
 
        ev.action = action;
+       ev.dir = discard_const_p(char, "");
        ev.path = path;
        ev.private_data = e->private_data;
 
index 0680b4b52bfc94a4097b381ba20f0b911727fc87..091ca1da2834c2ae9719ba931861c225d24fb374 100644 (file)
@@ -144,6 +144,7 @@ static void inotify_dispatch(struct inotify_private *in,
        for (w=in->watches;w;w=next) {
                next = w->next;
                if (w->wd == e->wd && filter_match(w, e)) {
+                       ne.dir = w->path;
                        w->callback(in->ctx, w->private_data, &ne);
                }
        }
@@ -163,6 +164,7 @@ static void inotify_dispatch(struct inotify_private *in,
                next = w->next;
                if (w->wd == e->wd && filter_match(w, e) &&
                    !(w->filter & FILE_NOTIFY_CHANGE_CREATION)) {
+                       ne.dir = w->path;
                        w->callback(in->ctx, w->private_data, &ne);
                }
        }