smbd: There's only one notify_callback
[kai/samba-autobuild/.git] / source3 / smbd / notify.c
index d7382db69381a7a442fe55420c4a9869956686ac..f493f11aa69a558389689b2fe3fc271b297adf32 100644 (file)
@@ -240,8 +240,8 @@ void change_notify_reply(struct smb_request *req,
        notify_buf->num_changes = 0;
 }
 
-static void notify_callback(void *private_data, struct timespec when,
-                           const struct notify_event *e)
+void notify_callback(void *private_data, struct timespec when,
+                    const struct notify_event *e)
 {
        files_struct *fsp = (files_struct *)private_data;
        DEBUG(10, ("notify_callback called for %s\n", fsp_str_dbg(fsp)));
@@ -251,8 +251,8 @@ static void notify_callback(void *private_data, struct timespec when,
 NTSTATUS change_notify_create(struct files_struct *fsp, uint32_t filter,
                              bool recursive)
 {
-       char *fullpath;
-       size_t len;
+       size_t len = fsp_fullbasepath(fsp, NULL, 0);
+       char fullpath[len+1];
        uint32_t subdir_filter;
        NTSTATUS status = NT_STATUS_NOT_IMPLEMENTED;
 
@@ -267,20 +267,11 @@ NTSTATUS change_notify_create(struct files_struct *fsp, uint32_t filter,
                return NT_STATUS_NO_MEMORY;
        }
 
-       /* Do notify operations on the base_name. */
-       fullpath = talloc_asprintf(
-               talloc_tos(), "%s/%s", fsp->conn->connectpath,
-               fsp->fsp_name->base_name);
-       if (fullpath == NULL) {
-               DEBUG(0, ("talloc_asprintf failed\n"));
-               TALLOC_FREE(fsp->notify);
-               return NT_STATUS_NO_MEMORY;
-       }
+       fsp_fullbasepath(fsp, fullpath, sizeof(fullpath));
 
        /*
         * Avoid /. at the end of the path name. notify can't deal with it.
         */
-       len = strlen(fullpath);
        if (len > 1 && fullpath[len-1] == '.' && fullpath[len-2] == '/') {
                fullpath[len-2] = '\0';
        }
@@ -289,10 +280,9 @@ NTSTATUS change_notify_create(struct files_struct *fsp, uint32_t filter,
 
        if ((filter != 0) || (subdir_filter != 0)) {
                status = notify_add(fsp->conn->sconn->notify_ctx,
-                                   fullpath, filter, subdir_filter,
-                                   notify_callback, fsp);
+                                   fullpath, filter, subdir_filter, fsp);
        }
-       TALLOC_FREE(fullpath);
+
        return status;
 }