notify_inotify: Make inotify_watch return 0/errno
authorVolker Lendecke <vl@samba.org>
Mon, 27 Oct 2014 13:26:35 +0000 (13:26 +0000)
committerJeremy Allison <jra@samba.org>
Tue, 9 Dec 2014 03:12:09 +0000 (04:12 +0100)
More like a cleanup, but I want to use inotify_watch in notifyd
that I would like to keep as light as possible

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/modules/vfs_default.c
source3/smbd/notify_inotify.c
source3/smbd/proto.h

index dad6bb7440fa12d6002a902d7996cca5f7d2b3e5..eaa1c2be4f45786850c27cf22d9a34c758e9f71d 100644 (file)
@@ -2119,11 +2119,16 @@ static NTSTATUS vfswrap_notify_watch(vfs_handle_struct *vfs_handle,
         */
 #ifdef HAVE_INOTIFY
        if (lp_kernel_change_notify(vfs_handle->conn->params)) {
+               int ret;
                if (!lp_parm_bool(-1, "notify", "inotify", True)) {
                        return NT_STATUS_INVALID_SYSTEM_SERVICE;
                }
-               return inotify_watch(ctx, path, filter, subdir_filter,
-                                    callback, private_data, handle);
+               ret = inotify_watch(ctx, path, filter, subdir_filter,
+                                   callback, private_data, handle);
+               if (ret != 0) {
+                       return map_nt_error_from_unix(ret);
+               }
+               return NT_STATUS_OK;
        }
 #endif
        /*
index 3e4e2e6a566544b89f78cf2f23530b0deb147220..ad670affcde19627ca86d87c7c9728534ad6630b 100644 (file)
@@ -346,15 +346,15 @@ static int watch_destructor(struct inotify_watch_context *w)
   add a watch. The watch is removed when the caller calls
   talloc_free() on *handle
 */
-NTSTATUS inotify_watch(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)
+int inotify_watch(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)
 {
        struct inotify_private *in;
        uint32_t mask;
@@ -367,7 +367,7 @@ NTSTATUS inotify_watch(struct sys_notify_context *ctx,
                int ret;
                ret = inotify_setup(ctx);
                if (ret != 0) {
-                       return map_nt_error_from_unix(ret);
+                       return ret;
                }
        }
 
@@ -376,7 +376,7 @@ NTSTATUS inotify_watch(struct sys_notify_context *ctx,
        mask = inotify_map(filter);
        if (mask == 0) {
                /* this filter can't be handled by inotify */
-               return NT_STATUS_INVALID_PARAMETER;
+               return EINVAL;
        }
 
        /* using IN_MASK_ADD allows us to cope with inotify() returning the same
@@ -386,7 +386,7 @@ NTSTATUS inotify_watch(struct sys_notify_context *ctx,
        w = talloc(in, struct inotify_watch_context);
        if (w == NULL) {
                *filter = orig_filter;
-               return NT_STATUS_NO_MEMORY;
+               return ENOMEM;
        }
 
        w->in = in;
@@ -398,7 +398,7 @@ NTSTATUS inotify_watch(struct sys_notify_context *ctx,
        if (w->path == NULL) {
                *filter = orig_filter;
                TALLOC_FREE(w);
-               return NT_STATUS_NO_MEMORY;
+               return ENOMEM;
        }
 
        /* get a new watch descriptor for this path */
@@ -408,7 +408,7 @@ NTSTATUS inotify_watch(struct sys_notify_context *ctx,
                *filter = orig_filter;
                TALLOC_FREE(w);
                DEBUG(1, ("inotify_add_watch returned %s\n", strerror(err)));
-               return map_nt_error_from_unix(err);
+               return err;
        }
 
        DEBUG(10, ("inotify_add_watch for %s mask %x returned wd %d\n",
@@ -421,7 +421,7 @@ NTSTATUS inotify_watch(struct sys_notify_context *ctx,
        /* the caller frees the handle to stop watching */
        talloc_set_destructor(w, watch_destructor);
 
-       return NT_STATUS_OK;
+       return 0;
 }
 
 #endif
index 9980d0313255127a1453bc45876c4e1c5aa852c0..0e43aaf0dfa0b87341f1e4f32aebfc886c5a8924 100644 (file)
@@ -531,15 +531,15 @@ 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,
-                      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);
+int inotify_watch(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);
 
 /* The following definitions come from smbd/notify_internal.c  */