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-09-24 07:21:05 -07:00
2009-06-11 21:36:14 -04:00
2009-10-01 16:11:16 -07:00
2009-09-21 15:14:58 +02:00
2009-08-31 17:44:05 -10:00
2009-09-24 07:47:42 -04:00
2009-07-12 12:22:34 -07:00
2009-10-15 15:06:37 -07:00
2009-06-11 21:36:06 -04:00
2009-09-26 10:10:35 -07:00
2009-10-04 15:05:10 -07:00
2009-09-11 09:20:26 +02:00
2009-06-15 21:30:28 -07:00
2009-09-23 07:39:28 -07:00
2009-09-30 12:19:44 -05:00
2009-10-08 11:31:38 -05:00
2009-06-17 00:36:36 -04:00
2009-09-24 07:47:38 -04:00
2009-09-24 07:53:22 -07:00
2009-10-13 00:06:43 +02:00
2009-10-03 11:24:19 -07:00
2009-09-30 09:31:14 -07:00
2009-07-12 12:22:34 -07:00
2009-05-27 10:20:13 -07:00
2009-09-27 11:39:25 -07:00
2009-09-27 11:39:25 -07:00
2009-09-24 07:47:42 -04:00
2009-09-24 07:47:42 -04:00
2009-06-30 18:56:03 -07:00
2009-07-12 12:22:34 -07:00
2009-09-24 08:32:11 -07:00
2009-09-24 07:47:42 -04:00
2009-09-16 17:44:10 +02:00
2009-10-01 16:11:11 -07:00
2009-09-23 10:07:49 -07:00
2009-09-24 07:47:42 -04:00
2009-09-23 18:13:10 -07:00
2009-09-23 07:39:57 -07:00
2009-09-27 11:39:25 -07:00
2009-10-12 10:25:12 -07:00
2009-10-01 16:11:11 -07:00
2009-10-01 16:11:11 -07:00
2009-09-30 09:31:14 -07:00
2009-10-20 18:02:33 -04:00
2009-09-24 08:32:11 -07:00
2009-10-01 16:11:11 -07:00
2009-10-01 16:11:11 -07:00
2009-10-06 20:16:55 +02:00
2009-10-08 07:36:39 -07:00
2009-09-23 07:39:30 -07:00
2009-09-22 07:17:24 -07:00
2009-09-24 08:41:47 -04:00
2009-09-22 07:17:24 -07:00
2009-10-11 11:33:56 -07:00
2009-09-24 07:47:42 -04:00
2009-09-22 07:17:24 -07:00
2009-10-14 15:16:25 -07:00
2009-06-17 00:36:37 -04:00
2009-09-27 11:39:25 -07:00
2009-09-14 19:13:01 +02:00
2009-06-18 13:03:46 -07:00
2009-10-09 13:29:42 -07:00
2009-09-23 07:39:29 -07:00
2009-10-04 15:05:10 -07:00
2009-09-24 08:41:47 -04:00
2009-09-24 07:21:02 -07:00
2009-09-24 07:21:01 -07:00
2009-09-24 07:21:03 -07:00
2009-07-01 10:56:25 +02:00
2009-10-01 21:15:46 +02:00
2009-09-24 07:47:41 -04:00
2009-09-25 09:27:30 -07:00
2009-09-24 07:21:03 -07:00
2009-08-07 10:39:56 -07:00
2009-09-24 08:40:15 -04:00
2009-07-18 15:51:44 +02:00
2009-09-24 07:21:04 -07:00
2009-09-23 07:39:29 -07:00
2009-06-18 13:03:41 -07:00
2009-09-24 07:21:05 -07:00
2009-09-24 07:21:01 -07:00
2009-09-24 07:21:04 -07:00
2009-10-11 11:20:58 -07:00
2009-09-26 00:10:40 +02:00
2009-09-24 07:47:27 -04:00
2009-09-24 08:40:15 -04:00
2009-09-24 07:47:31 -04:00
2009-09-22 07:17:41 -07:00
2009-09-24 07:47:30 -04:00
2009-09-22 07:17:25 -07:00
2009-09-11 08:55:49 -07:00
2009-09-24 08:40:15 -04:00
2009-09-23 09:21:05 -07:00
2009-07-22 21:14:14 +02:00
2009-09-24 07:47:34 -04:00
2009-10-04 15:05:10 -07:00
2009-09-24 07:47:35 -04:00
2009-09-14 17:55:15 -07:00
2009-09-24 07:47:41 -04:00
2009-09-23 07:39:29 -07:00
2009-09-10 10:11:22 +10:00