r14948: add testing of truncate events, and add truncate support to inotify
authorAndrew Tridgell <tridge@samba.org>
Thu, 6 Apr 2006 11:09:24 +0000 (11:09 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:00:21 +0000 (14:00 -0500)
backend
(This used to be commit b80523a631ec57c7d19e9a23dca4594d71036138)

source4/ntvfs/sysdep/inotify.c
source4/torture/raw/notify.c

index ead2211c8e790ec8df79dc76a44914ed3715d189..f86e3c1913081f5dc2c571f881a019939576814c 100644 (file)
@@ -116,6 +116,10 @@ static BOOL filter_match(struct watch_context *w, struct inotify_event *e)
                                  FILE_NOTIFY_CHANGE_SECURITY))) {
                        return True;
                }
+               if ((e->mask & IN_MODIFY) && 
+                   (w->filter & FILE_NOTIFY_CHANGE_ATTRIBUTES)) {
+                       return True;
+               }
                if ((w->filter & FILE_NOTIFY_CHANGE_FILE_NAME) == 0) {
                        return False;
                }
@@ -281,8 +285,7 @@ static const struct {
 } inotify_mapping[] = {
        {FILE_NOTIFY_CHANGE_FILE_NAME,   IN_CREATE|IN_DELETE|IN_MOVED_FROM|IN_MOVED_TO},
        {FILE_NOTIFY_CHANGE_DIR_NAME,    IN_CREATE|IN_DELETE|IN_MOVED_FROM|IN_MOVED_TO},
-       {FILE_NOTIFY_CHANGE_ATTRIBUTES,  IN_ATTRIB | IN_MOVED_TO | IN_MOVED_FROM},
-       {FILE_NOTIFY_CHANGE_SIZE,        IN_MODIFY},
+       {FILE_NOTIFY_CHANGE_ATTRIBUTES,  IN_ATTRIB|IN_MOVED_TO|IN_MOVED_FROM|IN_MODIFY},
        {FILE_NOTIFY_CHANGE_LAST_WRITE,  IN_ATTRIB},
        {FILE_NOTIFY_CHANGE_LAST_ACCESS, IN_ATTRIB},
        {FILE_NOTIFY_CHANGE_EA,          IN_ATTRIB},
index 8a982a721117a29eeb3b22cd23d0f5df5ebdb3a5..0e79a7ce07e6fa755b6d62bec101bc992898959d 100644 (file)
@@ -205,7 +205,7 @@ static BOOL test_notify_dir(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        status = smbcli_unlink(cli->tree, BASEDIR "\\test*.txt");
        CHECK_STATUS(status, NT_STATUS_OK);
 
-       /* recev the 3rd notify */
+       /* receive the 3rd notify */
        status = smb_raw_changenotify_recv(req, mem_ctx, &notify);
        CHECK_STATUS(status, NT_STATUS_OK);
        CHECK_VAL(notify.out.num_changes, 1);
@@ -214,6 +214,7 @@ static BOOL test_notify_dir(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
 
        /* and we now see the rest of the unlink calls on both directory handles */
        notify.in.file.fnum = fnum;
+       msleep(10);
        req = smb_raw_changenotify_send(cli->tree, &notify);
        status = smb_raw_changenotify_recv(req, mem_ctx, &notify);
        CHECK_STATUS(status, NT_STATUS_OK);
@@ -578,6 +579,14 @@ static BOOL test_notify_mask(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
                NOTIFY_ACTION_MODIFIED,
                0, 1);
 
+       printf("testing truncate\n");
+       NOTIFY_MASK_TEST(
+               fnum2 = create_complex_file(cli, mem_ctx, BASEDIR "\\tname1");,
+               smbcli_ftruncate(cli->tree, fnum2, 10000);,
+               (smbcli_close(cli->tree, fnum2), smbcli_unlink(cli->tree, BASEDIR "\\tname1"));,
+               NOTIFY_ACTION_MODIFIED,
+               FILE_NOTIFY_CHANGE_SIZE | FILE_NOTIFY_CHANGE_ATTRIBUTES, 1);
+
 done:
        smb_raw_exit(cli->session);
        return ret;