public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: chrubis@suse.cz
To: Jan Kara <jack@suse.cz>
Cc: ltp-list@lists.sourceforge.net
Subject: Re: [LTP] [PATCH 1/2] syscalls/inotify: Test generation of overflow events
Date: Mon, 24 Feb 2014 13:14:46 +0100	[thread overview]
Message-ID: <20140224121446.GC23596@rei> (raw)
In-Reply-To: <1393233450-22698-1-git-send-email-jack@suse.cz>

Hi!
> +static void setup(void)
> +{
> +	tst_sig(NOFORK, DEF_HANDLER, cleanup);
> +
> +	TEST_PAUSE;
> +
> +	tst_tmpdir();
> +
> +	sprintf(fname, "tfile_%d", getpid());
> +	fd = SAFE_OPEN(cleanup, fname, O_RDWR | O_CREAT, 0700);
> +	SAFE_WRITE(cleanup, 1, fd, buf, BUF_SIZE);
> +	SAFE_CLOSE(cleanup, fd);
> +
> +	if ((fd_notify = syscall(__NR_inotify_init1, O_NONBLOCK)) < 0) {
> +		if (errno == ENOSYS) {
> +			tst_brkm(TCONF, cleanup,
> +				 "inotify is not configured in this kernel.");
> +		} else {
> +			tst_brkm(TBROK | TERRNO, cleanup,
> +				 "inotify_init failed");
> +		}
> +	}
> +
> +	if ((wd = myinotify_add_watch(fd_notify, fname, IN_ALL_EVENTS)) < 0) {
> +		tst_brkm(TBROK | TERRNO, cleanup,
> +			 "inotify_add_watch (%d, %s, IN_ALL_EVENTS) failed",
> +			 fd_notify, fname);
> +	};
> +
> +	fd = SAFE_OPEN(cleanup, "/proc/sys/fs/inotify/max_queued_events", O_RDONLY);
> +	SAFE_READ(cleanup, 0, fd, buf, BUF_SIZE);
> +	if (sscanf(buf, "%d", &max_events) != 1) {
> +		tst_brkm(TBROK, cleanup,
> +			 "cannot parse max_queued_events file");
> +	}
> +	SAFE_CLOSE(cleanup, fd);
> +}
> +
> +static void cleanup(void)
> +{
> +	if (myinotify_rm_watch(fd_notify, wd) < 0) {
> +		tst_resm(TWARN | TERRNO, "inotify_rm_watch (%d, %d) failed",
> +			 fd_notify, wd);
> +
> +	}
> +
> +	if (close(fd_notify) == -1) {
> +		tst_resm(TWARN, "close(%d) failed", fd_notify);
> +	}


And I guess that we need to change this to:

	if (fd_notify > 0 && close(fd_notify) == -1)


because the fd_notify may be set to -1 in case that the syscall above
failed with ENOSYS which would generate a bogus warning. And I guess
that the same goes for the removing the inotify watch.

> +	TEST_CLEANUP;
> +	tst_rmdir();
> +}
> +
> +#else
> +
> +int main(void)
> +{
> +	tst_brkm(TCONF, NULL, "system doesn't have required inotify support");
> +}
> +
> +#endif
> -- 
> 1.8.1.4
> 

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
Flow-based real-time traffic analytics software. Cisco certified tool.
Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer
Customize your own dashboards, set traffic alerts and generate reports.
Network behavioral analysis & security monitoring. All-in-one tool.
http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

  parent reply	other threads:[~2014-02-24 12:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1393233450-22698-1-git-send-email-jack@suse.cz>
2014-02-24 12:04 ` [LTP] [PATCH 1/2] syscalls/inotify: Test generation of overflow events chrubis
     [not found] ` <1393233450-22698-2-git-send-email-jack@suse.cz>
2014-02-24 12:10   ` [LTP] [PATCH 2/2] syscalls/fanotify: " chrubis
     [not found]     ` <20140224123723.GA26687@quack.suse.cz>
2014-02-24 13:25       ` chrubis
2014-02-24 12:14 ` chrubis [this message]
     [not found]   ` <20140224123955.GB26687@quack.suse.cz>
2014-02-24 13:12     ` [LTP] [PATCH 1/2] syscalls/inotify: " chrubis

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=20140224121446.GC23596@rei \
    --to=chrubis@suse.cz \
    --cc=jack@suse.cz \
    --cc=ltp-list@lists.sourceforge.net \
    /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