s3: Pass "path" through vfs_notify_watch
authorVolker Lendecke <vl@samba.org>
Mon, 19 Mar 2012 20:57:50 +0000 (21:57 +0100)
committerVolker Lendecke <vl@samba.org>
Wed, 21 Mar 2012 11:52:09 +0000 (12:52 +0100)
12 files changed:
examples/VFS/skel_transparent.c
source3/include/vfs.h
source3/include/vfs_macros.h
source3/modules/vfs_default.c
source3/modules/vfs_full_audit.c
source3/modules/vfs_notify_fam.c
source3/modules/vfs_time_audit.c
source3/smbd/notify.c
source3/smbd/notify_inotify.c
source3/smbd/notify_internal.c
source3/smbd/proto.h
source3/smbd/vfs.c

index b38479003bb60988de4c4fa6f56d16d7063e3944..964ba6dc9ca955c2267b5246ce42084a792b2143 100644 (file)
@@ -357,12 +357,16 @@ static char *skel_realpath(vfs_handle_struct *handle,  const char *path)
        return SMB_VFS_NEXT_REALPATH(handle, path);
 }
 
-static NTSTATUS skel_notify_watch(struct vfs_handle_struct *handle,
-           struct sys_notify_context *ctx, struct notify_entry *e,
-           void (*callback)(struct sys_notify_context *ctx, void *private_data, struct notify_event *ev),
-           void *private_data, void *handle_p)
-{
-       return SMB_VFS_NEXT_NOTIFY_WATCH(handle, ctx, e, callback,
+static NTSTATUS skel_notify_watch(
+       struct vfs_handle_struct *handle,
+       struct sys_notify_context *ctx,
+       struct notify_entry *e,
+       const char *path,
+       void (*callback)(struct sys_notify_context *ctx, void *private_data,
+                        struct notify_event *ev),
+       void *private_data, void *handle_p)
+{
+       return SMB_VFS_NEXT_NOTIFY_WATCH(handle, ctx, e, path, callback,
                private_data, handle_p);
 }
 
index 62f9d1012973aecb27f718acc4ed441548ac8522..c038c56f469743b78c8112fb3a3ae96936d4885d 100644 (file)
@@ -285,6 +285,7 @@ struct vfs_fn_pointers {
        NTSTATUS (*notify_watch_fn)(struct vfs_handle_struct *handle,
                                    struct sys_notify_context *ctx,
                                    struct notify_entry *e,
+                                   const char *path,
                                    void (*callback)(struct sys_notify_context *ctx,
                                                     void *private_data,
                                                     struct notify_event *ev),
@@ -676,6 +677,7 @@ char *smb_vfs_call_realpath(struct vfs_handle_struct *handle, const char *path);
 NTSTATUS smb_vfs_call_notify_watch(struct vfs_handle_struct *handle,
                                   struct sys_notify_context *ctx,
                                   struct notify_entry *e,
+                                  const char *name,
                                   void (*callback)(struct sys_notify_context *ctx,
                                                    void *private_data,
                                                    struct notify_event *ev),
index 3bfda9fecb842bc05f6b3c209b4846225ab8c57b..5e184e3009373652cd70886ad3637316655808ad 100644 (file)
 #define SMB_VFS_NEXT_REALPATH(handle, path) \
        smb_vfs_call_realpath((handle)->next, (path))
 
-#define SMB_VFS_NOTIFY_WATCH(conn, ctx, e, callback, private_data, handle_p) \
-       smb_vfs_call_notify_watch((conn)->vfs_handles, (ctx), (e), (callback), (private_data), (handle_p))
-#define SMB_VFS_NEXT_NOTIFY_WATCH(conn, ctx, e, callback, private_data, handle_p) \
-       smb_vfs_call_notify_watch((conn)->next, (ctx), (e), (callback), (private_data), (handle_p))
+#define SMB_VFS_NOTIFY_WATCH(conn, ctx, e, path, callback, private_data, handle_p) \
+       smb_vfs_call_notify_watch((conn)->vfs_handles, (ctx), (e), (path), (callback), (private_data), (handle_p))
+#define SMB_VFS_NEXT_NOTIFY_WATCH(conn, ctx, e, path, callback, private_data, handle_p) \
+       smb_vfs_call_notify_watch((conn)->next, (ctx), (e), (path), (callback), (private_data), (handle_p))
 
 #define SMB_VFS_CHFLAGS(conn, path, flags) \
        smb_vfs_call_chflags((conn)->vfs_handles, (path), (flags))
index 1dbd308368d463fac66a52a314ec5b4b32dddb2c..37ec7e884d24fc4a40fcfe4be45fd54fd9d77257 100644 (file)
@@ -1633,6 +1633,7 @@ static char *vfswrap_realpath(vfs_handle_struct *handle,  const char *path)
 static NTSTATUS vfswrap_notify_watch(vfs_handle_struct *vfs_handle,
                                     struct sys_notify_context *ctx,
                                     struct notify_entry *e,
+                                    const char *path,
                                     void (*callback)(struct sys_notify_context *ctx, 
                                                      void *private_data,
                                                      struct notify_event *ev),
@@ -1648,7 +1649,8 @@ static NTSTATUS vfswrap_notify_watch(vfs_handle_struct *vfs_handle,
         */
 #ifdef HAVE_INOTIFY
        if (lp_kernel_change_notify(ctx->conn->params)) {
-               return inotify_watch(ctx, e, callback, private_data, handle);
+               return inotify_watch(ctx, e, path, callback, private_data,
+                                    handle);
        }
 #endif
        /*
index 3efa848d22d2970c66bc2ab5731e9e1e3780a5f7..24c2f8e323656c1d0bd8e59a747f33c6e909b45d 100644 (file)
@@ -1380,6 +1380,7 @@ static char *smb_full_audit_realpath(vfs_handle_struct *handle,
 static NTSTATUS smb_full_audit_notify_watch(struct vfs_handle_struct *handle,
                        struct sys_notify_context *ctx,
                        struct notify_entry *e,
+                       const char *path,
                        void (*callback)(struct sys_notify_context *ctx,
                                        void *private_data,
                                        struct notify_event *ev),
@@ -1387,7 +1388,8 @@ static NTSTATUS smb_full_audit_notify_watch(struct vfs_handle_struct *handle,
 {
        NTSTATUS result;
 
-       result = SMB_VFS_NEXT_NOTIFY_WATCH(handle, ctx, e, callback, private_data, handle_p);
+       result = SMB_VFS_NEXT_NOTIFY_WATCH(handle, ctx, e, path, callback,
+                                          private_data, handle_p);
 
        do_log(SMB_VFS_OP_NOTIFY_WATCH, NT_STATUS_IS_OK(result), handle, "");
 
index 343149423e8f324b57a53a2778d9dffb3ab28671..8a3487b9d35a9e250fe3e781fc92224e68afe3fb 100644 (file)
@@ -222,6 +222,7 @@ static int fam_watch_context_destructor(struct fam_watch_context *ctx)
 static NTSTATUS fam_watch(vfs_handle_struct *vfs_handle,
                          struct sys_notify_context *ctx,
                          struct notify_entry *e,
+                         const char *path,
                          void (*callback)(struct sys_notify_context *ctx, 
                                           void *private_data,
                                           struct notify_event *ev),
@@ -259,7 +260,8 @@ static NTSTATUS fam_watch(vfs_handle_struct *vfs_handle,
        watch->private_data = private_data;
        watch->sys_ctx = ctx;
 
-       if (!(watch->path = talloc_strdup(watch, e->path))) {
+       watch->path = talloc_strdup(watch, path);
+       if (watch->path == NULL) {
                DEBUG(0, ("talloc_asprintf failed\n"));
                TALLOC_FREE(watch);
                return NT_STATUS_NO_MEMORY;
index 734625e4e920451f8040b00afdf9ae534d2797e9..8ec434b5416541e09fbe9e70167f42e5e0dbab12 100644 (file)
@@ -1131,6 +1131,7 @@ static char *smb_time_audit_realpath(vfs_handle_struct *handle,
 static NTSTATUS smb_time_audit_notify_watch(struct vfs_handle_struct *handle,
                        struct sys_notify_context *ctx,
                        struct notify_entry *e,
+                       const char *path,
                        void (*callback)(struct sys_notify_context *ctx,
                                        void *private_data,
                                        struct notify_event *ev),
@@ -1141,7 +1142,7 @@ static NTSTATUS smb_time_audit_notify_watch(struct vfs_handle_struct *handle,
        double timediff;
 
        clock_gettime_mono(&ts1);
-       result = SMB_VFS_NEXT_NOTIFY_WATCH(handle, ctx, e, callback,
+       result = SMB_VFS_NEXT_NOTIFY_WATCH(handle, ctx, e, path, callback,
                                           private_data, handle_p);
        clock_gettime_mono(&ts2);
        timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
index 534ed8477bc2664c8310ac960fca44796bd11b5b..5a78a726b717b6b72db5536acbd1e986fd675378 100644 (file)
@@ -548,12 +548,13 @@ struct sys_notify_context *sys_notify_context_create(connection_struct *conn,
 
 NTSTATUS sys_notify_watch(struct sys_notify_context *ctx,
                          struct notify_entry *e,
+                         const char *path,
                          void (*callback)(struct sys_notify_context *ctx, 
                                           void *private_data,
                                           struct notify_event *ev),
                          void *private_data, void *handle)
 {
-       return SMB_VFS_NOTIFY_WATCH(ctx->conn, ctx, e, callback, private_data,
-                                   handle);
+       return SMB_VFS_NOTIFY_WATCH(ctx->conn, ctx, e, path, callback,
+                                   private_data, handle);
 }
 
index bccd093be4cee061177a44ecec9337810ca2cfbb..a074d019d9a4590d2ecde74c9eca502439a558de 100644 (file)
@@ -372,6 +372,7 @@ static int watch_destructor(struct inotify_watch_context *w)
 */
 NTSTATUS inotify_watch(struct sys_notify_context *ctx,
                       struct notify_entry *e,
+                      const char *path,
                       void (*callback)(struct sys_notify_context *ctx, 
                                        void *private_data,
                                        struct notify_event *ev),
@@ -405,7 +406,7 @@ NTSTATUS inotify_watch(struct sys_notify_context *ctx,
        mask |= (IN_MASK_ADD | IN_ONLYDIR);
 
        /* get a new watch descriptor for this path */
-       wd = inotify_add_watch(in->fd, e->path, mask);
+       wd = inotify_add_watch(in->fd, path, mask);
        if (wd == -1) {
                e->filter = filter;
                DEBUG(1, ("inotify_add_watch returned %s\n", strerror(errno)));
@@ -428,7 +429,7 @@ NTSTATUS inotify_watch(struct sys_notify_context *ctx,
        w->private_data = private_data;
        w->mask = mask;
        w->filter = filter;
-       w->path = talloc_strdup(w, e->path);
+       w->path = talloc_strdup(w, path);
        if (w->path == NULL) {
                inotify_rm_watch(in->fd, wd);
                e->filter = filter;
index 906f7674dead607af1b1acb6665f77f4214447f2..b12459c9d3359dde7331dc026f628951e4ba1859 100644 (file)
@@ -538,7 +538,7 @@ NTSTATUS notify_add(struct notify_context *notify, struct notify_entry *e0,
                  this call will modify e.filter and e.subdir_filter
                  to remove bits handled by the backend
                */
-               status = sys_notify_watch(notify->sys_notify_ctx, &e,
+               status = sys_notify_watch(notify->sys_notify_ctx, &e, e.path,
                                          sys_notify_callback, listel,
                                          &listel->sys_notify_handle);
                if (NT_STATUS_IS_OK(status)) {
index 0fbf9a0fcb46b54bdf41bbf16b6c461f239566d5..69655e7df6faa15aaf64d6ca8d35c50d75ff7b58 100644 (file)
@@ -524,6 +524,7 @@ struct sys_notify_context *sys_notify_context_create(connection_struct *conn,
                                                     struct event_context *ev);
 NTSTATUS sys_notify_watch(struct sys_notify_context *ctx,
                          struct notify_entry *e,
+                         const char *path,
                          void (*callback)(struct sys_notify_context *ctx,
                                           void *private_data,
                                           struct notify_event *ev),
@@ -533,6 +534,7 @@ NTSTATUS sys_notify_watch(struct sys_notify_context *ctx,
 
 NTSTATUS inotify_watch(struct sys_notify_context *ctx,
                       struct notify_entry *e,
+                      const char *path,
                       void (*callback)(struct sys_notify_context *ctx,
                                        void *private_data,
                                        struct notify_event *ev),
index 7da38818283961cadd255b774759f176c9b0087f..6b7b8691aaedfa6497dc5a484ebcbc9a23443935 100644 (file)
@@ -1834,13 +1834,14 @@ char *smb_vfs_call_realpath(struct vfs_handle_struct *handle, const char *path)
 NTSTATUS smb_vfs_call_notify_watch(struct vfs_handle_struct *handle,
                                   struct sys_notify_context *ctx,
                                   struct notify_entry *e,
+                                  const char *path,
                                   void (*callback)(struct sys_notify_context *ctx,
                                                    void *private_data,
                                                    struct notify_event *ev),
                                   void *private_data, void *handle_p)
 {
        VFS_FIND(notify_watch);
-       return handle->fns->notify_watch_fn(handle, ctx, e, callback,
+       return handle->fns->notify_watch_fn(handle, ctx, e, path, callback,
                                            private_data, handle_p);
 }