Andreas Gruenbacher 945526846a dnotify: ignore FS_EVENT_ON_CHILD
Mask off FS_EVENT_ON_CHILD in dnotify_handle_event().  Otherwise, when there
is more than one watch on a directory and dnotify_should_send_event()
succeeds, events with FS_EVENT_ON_CHILD set will trigger all watches and cause
spurious events.

This case was overlooked in commit e42e2773.

	#define _GNU_SOURCE

	#include <stdio.h>
	#include <stdlib.h>
	#include <unistd.h>
	#include <signal.h>
	#include <sys/types.h>
	#include <sys/stat.h>
	#include <fcntl.h>
	#include <string.h>

	static void create_event(int s, siginfo_t* si, void* p)
	{
		printf("create\n");
	}

	static void delete_event(int s, siginfo_t* si, void* p)
	{
		printf("delete\n");
	}

	int main (void) {
		struct sigaction action;
		char *tmpdir, *file;
		int fd1, fd2;

		sigemptyset (&action.sa_mask);
		action.sa_flags = SA_SIGINFO;

		action.sa_sigaction = create_event;
		sigaction (SIGRTMIN + 0, &action, NULL);

		action.sa_sigaction = delete_event;
		sigaction (SIGRTMIN + 1, &action, NULL);

	#	define TMPDIR "/tmp/test.XXXXXX"
		tmpdir = malloc(strlen(TMPDIR) + 1);
		strcpy(tmpdir, TMPDIR);
		mkdtemp(tmpdir);

	#	define TMPFILE "/file"
		file = malloc(strlen(tmpdir) + strlen(TMPFILE) + 1);
		sprintf(file, "%s/%s", tmpdir, TMPFILE);

		fd1 = open (tmpdir, O_RDONLY);
		fcntl(fd1, F_SETSIG, SIGRTMIN);
		fcntl(fd1, F_NOTIFY, DN_MULTISHOT | DN_CREATE);

		fd2 = open (tmpdir, O_RDONLY);
		fcntl(fd2, F_SETSIG, SIGRTMIN + 1);
		fcntl(fd2, F_NOTIFY, DN_MULTISHOT | DN_DELETE);

		if (fork()) {
			/* This triggers a create event */
			creat(file, 0600);
			/* This triggers a create and delete event (!) */
			unlink(file);
		} else {
			sleep(1);
			rmdir(tmpdir);
		}

		return 0;
	}

Signed-off-by: Andreas Gruenbacher <agruen@suse.de>
Signed-off-by: Eric Paris <eparis@redhat.com>
2009-10-20 18:02:33 -04:00
..
2009-09-23 13:03:46 -05:00
2009-06-11 21:36:14 -04:00
2009-10-01 16:11:16 -07:00
2009-07-12 12:22:34 -07:00
2009-10-04 15:05:10 -07:00
2009-09-23 07:39:28 -07:00
2009-09-30 12:19:44 -05:00
2009-06-17 00:36:36 -04:00
2009-07-12 12:22:34 -07:00
2009-07-12 12:22:34 -07:00
2009-09-23 18:13:10 -07:00
2009-10-12 10:25:12 -07:00
2009-10-20 18:02:33 -04:00
2009-10-08 07:36:39 -07:00
2009-09-23 07:39:30 -07:00
2009-09-24 08:41:47 -04:00
2009-06-17 00:36:37 -04:00
2009-06-18 13:03:46 -07:00
2009-09-24 08:41:47 -04:00
2009-09-24 07:21:01 -07:00
2009-09-24 07:21:03 -07:00
2009-06-18 13:03:41 -07:00
2009-09-24 07:21:01 -07:00
2009-03-31 23:00:26 -04:00
2009-09-24 07:47:27 -04:00
2009-09-22 07:17:41 -07:00
2009-04-07 08:31:16 -07:00
2009-10-04 15:05:10 -07:00
2009-04-20 23:02:52 -04:00
2009-09-23 07:39:29 -07:00
2009-02-18 15:37:53 -08:00