r14797: added checking of the filter in notify requests
authorAndrew Tridgell <tridge@samba.org>
Thu, 30 Mar 2006 03:51:49 +0000 (03:51 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:59:20 +0000 (13:59 -0500)
(This used to be commit 1db0a5a7f4c1ff915d91bc15d8e40cc90a78961d)

source4/ntvfs/common/notify.c
source4/ntvfs/posix/pvfs_mkdir.c
source4/ntvfs/posix/pvfs_open.c
source4/ntvfs/posix/pvfs_read.c
source4/ntvfs/posix/pvfs_unlink.c
source4/ntvfs/posix/pvfs_write.c

index bc04c830f162096bb36a4a5b11fb48ce4a1cb6c4..c5acf9decb015dea055fcd5c42b62a5da2772dc0 100644 (file)
@@ -322,11 +322,15 @@ static NTSTATUS notify_remove_all(struct notify_context *notify)
   see if a notify event matches
 */
 static BOOL notify_match(struct notify_context *notify, struct notify_entry *e,
-                        const char *path, uint32_t action)
+                        const char *path, uint32_t filter)
 {
-       size_t len = strlen(e->path);
+       size_t len;
 
-       /* TODO: check action */
+       if (!(filter & e->filter)) {
+               return False;
+       }
+
+       len = strlen(e->path);
 
        if (strncmp(path, e->path, len) != 0) {
                return False;
@@ -379,7 +383,7 @@ static void notify_send(struct notify_context *notify, struct notify_entry *e,
   trigger a notify message for anyone waiting on a matching event
 */
 void notify_trigger(struct notify_context *notify,
-                   uint32_t action, const char *path)
+                   uint32_t action, uint32_t filter, const char *path)
 {
        NTSTATUS status;
        int i;
@@ -391,7 +395,7 @@ void notify_trigger(struct notify_context *notify,
 
        /* this needs to be changed to a log(n) search */
        for (i=0;i<notify->array->num_entries;i++) {
-               if (notify_match(notify, &notify->array->entries[i], path, action)) {
+               if (notify_match(notify, &notify->array->entries[i], path, filter)) {
                        notify_send(notify, &notify->array->entries[i], 
                                    path + strlen(notify->array->entries[i].path) + 1, 
                                    action);
index 5ec7df3b9d3cebb7d21cbb5f5571ad9efd3b5bdf..cd83c9de43f86c1685cd64723460ec5e82794fbc 100644 (file)
@@ -83,7 +83,10 @@ static NTSTATUS pvfs_t2mkdir(struct pvfs_state *pvfs,
                return status;
        }
 
-       notify_trigger(pvfs->notify_context, NOTIFY_ACTION_ADDED, name->full_name);
+       notify_trigger(pvfs->notify_context, 
+                      NOTIFY_ACTION_ADDED, 
+                      FILE_NOTIFY_CHANGE_FILE_NAME|FILE_NOTIFY_CHANGE_DIR_NAME,
+                      name->full_name);
 
        return NT_STATUS_OK;
 }
@@ -137,7 +140,10 @@ NTSTATUS pvfs_mkdir(struct ntvfs_module_context *ntvfs,
                return status;
        }
 
-       notify_trigger(pvfs->notify_context, NOTIFY_ACTION_ADDED, name->full_name);
+       notify_trigger(pvfs->notify_context, 
+                      NOTIFY_ACTION_ADDED, 
+                      FILE_NOTIFY_CHANGE_FILE_NAME|FILE_NOTIFY_CHANGE_DIR_NAME,
+                      name->full_name);
 
        return NT_STATUS_OK;
 }
@@ -176,7 +182,10 @@ NTSTATUS pvfs_rmdir(struct ntvfs_module_context *ntvfs,
                return pvfs_map_errno(pvfs, errno);
        }
 
-       notify_trigger(pvfs->notify_context, NOTIFY_ACTION_REMOVED, name->full_name);
+       notify_trigger(pvfs->notify_context, 
+                      NOTIFY_ACTION_REMOVED, 
+                      FILE_NOTIFY_CHANGE_FILE_NAME|FILE_NOTIFY_CHANGE_DIR_NAME,
+                      name->full_name);
 
        return NT_STATUS_OK;
 }
index 38123c3a9eb73c9f96e5cb3d3efd78fe3d949748..264234a09bd3c8e35148c08ffb151d3f78dff1c0 100644 (file)
@@ -378,6 +378,11 @@ static NTSTATUS pvfs_open_directory(struct pvfs_state *pvfs,
                f->handle->have_opendb_entry = True;
 
                create_action = NTCREATEX_ACTION_CREATED;
+
+               notify_trigger(pvfs->notify_context, 
+                              NOTIFY_ACTION_REMOVED, 
+                              FILE_NOTIFY_CHANGE_FILE_NAME|FILE_NOTIFY_CHANGE_DIR_NAME,
+                              name->full_name);
        } else {
                create_action = NTCREATEX_ACTION_EXISTED;
        }
@@ -461,6 +466,11 @@ static int pvfs_handle_destructor(void *p)
                if (unlink(path) != 0) {
                        DEBUG(0,("pvfs_close: failed to delete '%s' - %s\n", 
                                 path, strerror(errno)));
+               } else {
+                       notify_trigger(h->pvfs->notify_context, 
+                                      NOTIFY_ACTION_REMOVED, 
+                                      FILE_NOTIFY_CHANGE_FILE_NAME,
+                                      path);
                }
        }
 
@@ -730,7 +740,10 @@ static NTSTATUS pvfs_create_file(struct pvfs_state *pvfs,
        /* success - keep the file handle */
        talloc_steal(pvfs, f);
 
-       notify_trigger(pvfs->notify_context, NOTIFY_ACTION_ADDED, name->full_name);
+       notify_trigger(pvfs->notify_context, 
+                      NOTIFY_ACTION_ADDED, 
+                      FILE_NOTIFY_CHANGE_FILE_NAME,
+                      name->full_name);
 
        return NT_STATUS_OK;
 
index 411fbd9c27c63bbe12e762283d2f477e52bc9828..f30c4d6e38b0b8d22f225a7e46c4b8a22b8b2c59 100644 (file)
@@ -90,5 +90,10 @@ NTSTATUS pvfs_read(struct ntvfs_module_context *ntvfs,
        rd->readx.out.remaining = 0xFFFF;
        rd->readx.out.compaction_mode = 0; 
 
+       notify_trigger(pvfs->notify_context, 
+                      NOTIFY_ACTION_MODIFIED, 
+                      FILE_NOTIFY_CHANGE_LAST_ACCESS,
+                      f->handle->name->full_name);
+
        return NT_STATUS_OK;
 }
index 3a6e4bba2f89f3d71cf951f47d674dbe4a60a5b6..4477360deb8535ba0996311ccd5e21948c8cfbbe 100644 (file)
@@ -104,7 +104,9 @@ static NTSTATUS pvfs_unlink_one(struct pvfs_state *pvfs,
        }
 
        if (NT_STATUS_IS_OK(status)) {
-               notify_trigger(pvfs->notify_context, NOTIFY_ACTION_REMOVED, 
+               notify_trigger(pvfs->notify_context, 
+                              NOTIFY_ACTION_REMOVED, 
+                              FILE_NOTIFY_CHANGE_FILE_NAME,
                               name->full_name);
        }
 
index 9c23b3e4fdadb59ce842a97d52b277d72f2db41e..15e352617619bba00b77f9e9a0246a594811342b 100644 (file)
@@ -84,6 +84,11 @@ NTSTATUS pvfs_write(struct ntvfs_module_context *ntvfs,
        
        wr->writex.out.nwritten = ret;
        wr->writex.out.remaining = 0; /* should fill this in? */
+
+       notify_trigger(pvfs->notify_context, 
+                      NOTIFY_ACTION_MODIFIED, 
+                      FILE_NOTIFY_CHANGE_SIZE | FILE_NOTIFY_CHANGE_LAST_WRITE,
+                      f->handle->name->full_name);
        
        return NT_STATUS_OK;
 }