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
[email protected]

------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to