mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andreas Gruenbacher <agruen@suse.de>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	Eric Paris <eparis@redhat.com>
Subject: Re: [BUGFIX] dnotify: handle_event shouldn't match on FS_EVENT_ON_CHILD
Date: Sun, 18 Oct 2009 14:49:22 +0200	[thread overview]
Message-ID: <200910181449.23267.agruen@suse.de> (raw)
In-Reply-To: <200910181446.44625.agruen@suse.de>

Test case demonstrating the bug:


#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) + 2);
	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()) {
		creat(file, 0600);

		/* Spurious event triggered below! */

		unlink(file);
	} else {
		sleep(1);
		rmdir(tmpdir);
	}

	return 0;
}

  reply	other threads:[~2009-10-18 12:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-18 12:46 Andreas Gruenbacher
2009-10-18 12:49 ` Andreas Gruenbacher [this message]
2009-10-18 15:52 ` Eric Paris
2009-10-18 19:22   ` Andreas Gruenbacher

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200910181449.23267.agruen@suse.de \
    --to=agruen@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=eparis@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome