[LTP] [PATCH 1/5] syscalls/fanotify01: check events also on mountpoint mark

Amir Goldstein amir73il@gmail.com
Wed Nov 21 17:18:12 CET 2018


On Wed, Nov 21, 2018 at 2:02 PM Cyril Hrubis <chrubis@suse.cz> wrote:
>
> Hi!
> >       /* This event should be ignored */
> > @@ -181,13 +200,13 @@ void test01(void)
> >
> >       /* Now remove open and close from ignored mask */
> >       if (fanotify_mark(fd_notify,
> > -                       FAN_MARK_REMOVE | FAN_MARK_IGNORED_MASK,
> > +                       FAN_MARK_REMOVE | mark->flag | FAN_MARK_IGNORED_MASK,
> >                         FAN_OPEN | FAN_CLOSE, AT_FDCWD, fname) < 0) {
> >               tst_brk(TBROK | TERRNO,
> > -                     "fanotify_mark (%d, FAN_MARK_REMOVE | "
> > -                     "FAN_MARK_IGNORED_MASK, FAN_OPEN | "
> > -                     "FAN_CLOSE, AT_FDCWD, %s) failed", fd_notify,
> > -                     fname);
> > +                     "fanotify_mark (%d, FAN_MARK_REMOVE | %s | "
> > +                     "FAN_MARK_IGNORED_MASK, FAN_OPEN | FAN_CLOSE, "
> > +                     "AT_FDCWD, %s) failed", fd_notify,
> > +                     mark->name, fname);
> >       }
> >
> >       SAFE_CLOSE(fd);
> > @@ -283,12 +302,13 @@ pass:
> >
> >       }
> >       /* Remove mark to clear FAN_MARK_IGNORED_SURV_MODIFY */
> > -     if (fanotify_mark(fd_notify, FAN_MARK_REMOVE, FAN_ACCESS | FAN_MODIFY |
> > -                         FAN_CLOSE | FAN_OPEN, AT_FDCWD, fname) < 0) {
> > +     if (fanotify_mark(fd_notify, FAN_MARK_REMOVE | mark->flag,
> > +                       FAN_ACCESS | FAN_MODIFY | FAN_CLOSE | FAN_OPEN,
> > +                       AT_FDCWD, fname) < 0) {
> >               tst_brk(TBROK | TERRNO,
> > -                     "fanotify_mark (%d, FAN_MARK_REMOVE, FAN_ACCESS | "
> > +                     "fanotify_mark (%d, FAN_MARK_REMOVE | %s, FAN_ACCESS | "
> >                       "FAN_MODIFY | FAN_CLOSE | FAN_OPEN, AT_FDCWD, %s) "
> > -                     "failed", fd_notify, fname);
> > +                     "failed", fd_notify, mark->name, fname);
> >       }
> >  }
> >
> > @@ -296,8 +316,6 @@ static void setup(void)
> >  {
> >       sprintf(fname, "tfile_%d", getpid());
> >       SAFE_FILE_PRINTF(fname, "1");
> > -
> > -     fd_notify = SAFE_FANOTIFY_INIT(FAN_CLASS_NOTIF, O_RDONLY);
>
> I've added SAFE_CLOSE(fd_notify) here so that we do not use all
> available file descriptors with large enough -i parameter and pushed.
>
> I do wonder what is the reason to move the fanotify_init() from setup
> the the test_fanotify(), is there a problem with recycling the same fd
> for different tests?
>

Closing fd_notify is an easier and better cleanup between test cases.
Otherwise we would need to FAN_MARK_FLUSH all the individual marks
that we added.

Thanks,
Amir.


More information about the ltp mailing list