s3: Pass filters explicitly through vfs notify watch
authorVolker Lendecke <vl@samba.org>
Mon, 26 Mar 2012 10:46:11 +0000 (12:46 +0200)
committerVolker Lendecke <vl@samba.org>
Mon, 26 Mar 2012 15:45:43 +0000 (17:45 +0200)
This removes a dependency on "struct notify_entry" and makes the nature of the
API more explicit. We depend upon the VFS module to mask out elements from
e->filter and e->subdir_filter that it took over to handle.

Autobuild-User: Volker Lendecke <vl@samba.org>
Autobuild-Date: Mon Mar 26 17:45:44 CEST 2012 on sn-devel-104

12 files changed:
examples/VFS/skel_opaque.c
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/proto.h
source3/smbd/vfs.c

index 7b67e56352270fbda6b2cccdf8058730c9ab4d60..5c97e2304e4e8380a7237ff10b93d336fccbf9ed 100644 (file)
@@ -383,7 +383,10 @@ static char *skel_realpath(vfs_handle_struct *handle,  const char *path)
 }
 
 static NTSTATUS skel_notify_watch(struct vfs_handle_struct *handle,
-           struct sys_notify_context *ctx, struct notify_entry *e,
+           struct sys_notify_context *ctx,
+           const char *path,
+           uint32_t *filter,
+           uint32_t *subdir_filter,
            void (*callback)(struct sys_notify_context *ctx, void *private_data, struct notify_event *ev),
            void *private_data, void *handle_p)
 {
index 964ba6dc9ca955c2267b5246ce42084a792b2143..c57545c2e5421c06e81d99c7a1e557d6602897d1 100644 (file)
@@ -360,13 +360,15 @@ static char *skel_realpath(vfs_handle_struct *handle,  const char *path)
 static NTSTATUS skel_notify_watch(
        struct vfs_handle_struct *handle,
        struct sys_notify_context *ctx,
-       struct notify_entry *e,
        const char *path,
+       uint32_t *filter,
+       uint32_t *subdir_filter,
        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,
+       return SMB_VFS_NEXT_NOTIFY_WATCH(handle, ctx, path,
+                                        filter, subdir_filter, callback,
                private_data, handle_p);
 }
 
index c038c56f469743b78c8112fb3a3ae96936d4885d..212da7e51409acabe626504fc245a6b46aa1a89a 100644 (file)
@@ -284,8 +284,9 @@ struct vfs_fn_pointers {
        char *(*realpath_fn)(struct vfs_handle_struct *handle, const char *path);
        NTSTATUS (*notify_watch_fn)(struct vfs_handle_struct *handle,
                                    struct sys_notify_context *ctx,
-                                   struct notify_entry *e,
                                    const char *path,
+                                   uint32_t *filter,
+                                   uint32_t *subdir_filter,
                                    void (*callback)(struct sys_notify_context *ctx,
                                                     void *private_data,
                                                     struct notify_event *ev),
@@ -676,8 +677,9 @@ int smb_vfs_call_mknod(struct vfs_handle_struct *handle, const char *path,
 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,
+                                  uint32_t *filter,
+                                  uint32_t *subdir_filter,
                                   void (*callback)(struct sys_notify_context *ctx,
                                                    void *private_data,
                                                    struct notify_event *ev),
index 5e184e3009373652cd70886ad3637316655808ad..68165fe092cb59961e81eac419a3ac3e69cf44c5 100644 (file)
 #define SMB_VFS_NEXT_REALPATH(handle, path) \
        smb_vfs_call_realpath((handle)->next, (path))
 
-#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_NOTIFY_WATCH(conn, ctx, path, filter, subdir_filter, callback, private_data, handle_p) \
+       smb_vfs_call_notify_watch((conn)->vfs_handles, (ctx), (path), (filter), (subdir_filter), (callback), (private_data), (handle_p))
+#define SMB_VFS_NEXT_NOTIFY_WATCH(conn, ctx, path, filter, subdir_filter, callback, private_data, handle_p) \
+       smb_vfs_call_notify_watch((conn)->next, (ctx), (path), (filter), (subdir_filter), (callback), (private_data), (handle_p))
 
 #define SMB_VFS_CHFLAGS(conn, path, flags) \
        smb_vfs_call_chflags((conn)->vfs_handles, (path), (flags))
index 7b80df890435e726b8bb01493758fcc860187396..568f3464520fe863c1781d2ad4a8e0de07e6fd6c 100644 (file)
@@ -1632,8 +1632,9 @@ 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,
+                                    uint32_t *filter,
+                                    uint32_t *subdir_filter,
                                     void (*callback)(struct sys_notify_context *ctx, 
                                                      void *private_data,
                                                      struct notify_event *ev),
@@ -1649,8 +1650,8 @@ static NTSTATUS vfswrap_notify_watch(vfs_handle_struct *vfs_handle,
         */
 #ifdef HAVE_INOTIFY
        if (lp_kernel_change_notify(vfs_handle->conn->params)) {
-               return inotify_watch(ctx, e, path, callback, private_data,
-                                    handle);
+               return inotify_watch(ctx, path, filter, subdir_filter,
+                                    callback, private_data, handle);
        }
 #endif
        /*
index 24c2f8e323656c1d0bd8e59a747f33c6e909b45d..770d21f9efcc86e1829c391a7cb5228badfd5a21 100644 (file)
@@ -1379,8 +1379,9 @@ 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,
+                       uint32_t *filter,
+                       uint32_t *subdir_filter,
                        void (*callback)(struct sys_notify_context *ctx,
                                        void *private_data,
                                        struct notify_event *ev),
@@ -1388,7 +1389,8 @@ static NTSTATUS smb_full_audit_notify_watch(struct vfs_handle_struct *handle,
 {
        NTSTATUS result;
 
-       result = SMB_VFS_NEXT_NOTIFY_WATCH(handle, ctx, e, path, callback,
+       result = SMB_VFS_NEXT_NOTIFY_WATCH(handle, ctx, path,
+                                          filter, subdir_filter, callback,
                                           private_data, handle_p);
 
        do_log(SMB_VFS_OP_NOTIFY_WATCH, NT_STATUS_IS_OK(result), handle, "");
index 7ac6609c5304fb744da61059d1777600345a5c8e..dcc843f6d8d0a484480be217bb59878bc3895efb 100644 (file)
@@ -221,8 +221,9 @@ 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,
+                         uint32_t *filter,
+                         uint32_t *subdir_filter,
                          void (*callback)(struct sys_notify_context *ctx, 
                                           void *private_data,
                                           struct notify_event *ev),
@@ -234,8 +235,8 @@ static NTSTATUS fam_watch(vfs_handle_struct *vfs_handle,
        struct fam_watch_context *watch;
        void **handle = (void **)handle_p;
 
-       if ((e->filter & fam_mask) == 0) {
-               DEBUG(10, ("filter = %u, ignoring in FAM\n", e->filter));
+       if ((*filter & fam_mask) == 0) {
+               DEBUG(10, ("filter = %u, ignoring in FAM\n", *filter));
                return NT_STATUS_OK;
        }
 
@@ -274,7 +275,7 @@ static NTSTATUS fam_watch(vfs_handle_struct *vfs_handle,
         */
 
        watch->filter = fam_mask;
-       e->filter &= ~fam_mask;
+       *filter &= ~fam_mask;
 
        DLIST_ADD(fam_notify_list, watch);
        talloc_set_destructor(watch, fam_watch_context_destructor);
index 8ec434b5416541e09fbe9e70167f42e5e0dbab12..0066e075a2269485737fa8fdb2eeda34d0519459 100644 (file)
@@ -1130,8 +1130,9 @@ 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,
+                       uint32_t *filter,
+                       uint32_t *subdir_filter,
                        void (*callback)(struct sys_notify_context *ctx,
                                        void *private_data,
                                        struct notify_event *ev),
@@ -1142,7 +1143,8 @@ 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, path, callback,
+       result = SMB_VFS_NEXT_NOTIFY_WATCH(handle, ctx, path,
+                                          filter, subdir_filter, callback,
                                           private_data, handle_p);
        clock_gettime_mono(&ts2);
        timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
index 53ae2d68e7911f05b140e03bb549f9f83c690c72..fd9e5524a7c8e25fde66732fc971fafe9dbc3d22 100644 (file)
@@ -235,8 +235,8 @@ NTSTATUS change_notify_create(struct files_struct *fsp, uint32 filter,
 
                status = SMB_VFS_NOTIFY_WATCH(
                        fsp->conn, fsp->conn->sconn->sys_notify_ctx,
-                       &e, e.path, sys_notify_callback, fsp,
-                       &sys_notify_handle);
+                       e.path, &e.filter, &e.subdir_filter,
+                       sys_notify_callback, fsp, &sys_notify_handle);
 
                if (NT_STATUS_IS_OK(status)) {
                        talloc_steal(fsp->notify, sys_notify_handle);
index 967c223adae279c0ad93f5abbd595be361fd6d04..20f709831a72aeb14059ea8bf273160724fe80ac 100644 (file)
@@ -371,8 +371,9 @@ static int watch_destructor(struct inotify_watch_context *w)
   talloc_free() on *handle
 */
 NTSTATUS inotify_watch(struct sys_notify_context *ctx,
-                      struct notify_entry *e,
                       const char *path,
+                      uint32_t *filter,
+                      uint32_t *subdir_filter,
                       void (*callback)(struct sys_notify_context *ctx, 
                                        void *private_data,
                                        struct notify_event *ev),
@@ -383,7 +384,7 @@ NTSTATUS inotify_watch(struct sys_notify_context *ctx,
        int wd;
        uint32_t mask;
        struct inotify_watch_context *w;
-       uint32_t orig_filter = e->filter;
+       uint32_t orig_filter = *filter;
        void **handle = (void **)handle_p;
 
        /* maybe setup the inotify fd */
@@ -395,7 +396,7 @@ NTSTATUS inotify_watch(struct sys_notify_context *ctx,
 
        in = talloc_get_type(ctx->private_data, struct inotify_private);
 
-       mask = inotify_map(&e->filter);
+       mask = inotify_map(filter);
        if (mask == 0) {
                /* this filter can't be handled by inotify */
                return NT_STATUS_INVALID_PARAMETER;
@@ -408,18 +409,18 @@ NTSTATUS inotify_watch(struct sys_notify_context *ctx,
        /* get a new watch descriptor for this path */
        wd = inotify_add_watch(in->fd, path, mask);
        if (wd == -1) {
-               e->filter = orig_filter;
+               *filter = orig_filter;
                DEBUG(1, ("inotify_add_watch returned %s\n", strerror(errno)));
                return map_nt_error_from_unix(errno);
        }
 
        DEBUG(10, ("inotify_add_watch for %s mask %x returned wd %d\n",
-                  e->path, mask, wd));
+                  path, mask, wd));
 
        w = talloc(in, struct inotify_watch_context);
        if (w == NULL) {
                inotify_rm_watch(in->fd, wd);
-               e->filter = orig_filter;
+               *filter = orig_filter;
                return NT_STATUS_NO_MEMORY;
        }
 
@@ -432,7 +433,7 @@ NTSTATUS inotify_watch(struct sys_notify_context *ctx,
        w->path = talloc_strdup(w, path);
        if (w->path == NULL) {
                inotify_rm_watch(in->fd, wd);
-               e->filter = orig_filter;
+               *filter = orig_filter;
                return NT_STATUS_NO_MEMORY;
        }
 
index 70c34ce35a3863b0722779dfe76ba5f684880e81..4bb57c0d5c4321f92814fdd45280702546fdad86 100644 (file)
@@ -526,8 +526,9 @@ struct sys_notify_context *sys_notify_context_create(TALLOC_CTX *mem_ctx,
 /* The following definitions come from smbd/notify_inotify.c  */
 
 NTSTATUS inotify_watch(struct sys_notify_context *ctx,
-                      struct notify_entry *e,
                       const char *path,
+                      uint32_t *filter,
+                      uint32_t *subdir_filter,
                       void (*callback)(struct sys_notify_context *ctx,
                                        void *private_data,
                                        struct notify_event *ev),
index 6b7b8691aaedfa6497dc5a484ebcbc9a23443935..4c5e52be1ba448c50a73c5d92beb2a9b7cabc25c 100644 (file)
@@ -1833,15 +1833,17 @@ 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,
+                                  uint32_t *filter,
+                                  uint32_t *subdir_filter,
                                   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, path, callback,
+       return handle->fns->notify_watch_fn(handle, ctx, path,
+                                           filter, subdir_filter, callback,
                                            private_data, handle_p);
 }