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, fname, 1); /* close the file we have open */ SAFE_CLOSE(cleanup, fd); if ((fd_notify = myfanotify_init(FAN_CLASS_NOTIF, O_RDONLY)) < 0) { if (errno == ENOSYS) { tst_brkm(TCONF, cleanup, "fanotify is not configured in this kernel."); } else { tst_brkm(TBROK | TERRNO, cleanup, "fanotify_init failed"); } } }
static void setup(void) { int fd; tst_sig(FORK, DEF_HANDLER, cleanup); TEST_PAUSE; tst_tmpdir(); sprintf(fname, "fname_%d", getpid()); fd = SAFE_OPEN(cleanup, fname, O_CREAT | O_RDWR, 0644); SAFE_WRITE(cleanup, 1, fd, fname, 1); SAFE_CLOSE(cleanup, fd); if ((fd_notify = myfanotify_init(FAN_CLASS_CONTENT, O_RDONLY)) < 0) { if (errno == ENOSYS) { tst_brkm(TCONF, cleanup, "fanotify is not configured in this kernel."); } else { tst_brkm(TBROK | TERRNO, cleanup, "fanotify_init failed"); } } if (myfanotify_mark(fd_notify, FAN_MARK_ADD, FAN_ACCESS_PERM | FAN_OPEN_PERM, AT_FDCWD, fname) < 0) { tst_brkm(TBROK | TERRNO, cleanup, "fanotify_mark (%d, FAN_MARK_ADD, FAN_ACCESS_PERM | " "FAN_OPEN_PERM, AT_FDCWD, %s) failed. " "CONFIG_FANOTIFY_ACCESS_PERMISSIONS not " "configured in kernel?", fd_notify, fname); } }
static void setup(void) { int fd; tst_sig(NOFORK, DEF_HANDLER, cleanup); TEST_PAUSE; tst_tmpdir(); sprintf(fname, "fname_%d", getpid()); fd = SAFE_OPEN(cleanup, fname, O_RDWR | O_CREAT, 0644); SAFE_CLOSE(cleanup, fd); sprintf(sname, "symlink_%d", getpid()); SAFE_SYMLINK(cleanup, fname, sname); sprintf(dir, "dir_%d", getpid()); SAFE_MKDIR(cleanup, dir, 0755); if ((fd_notify = myfanotify_init(FAN_CLASS_NOTIF | FAN_NONBLOCK, O_RDONLY)) < 0) { if (errno == ENOSYS) { tst_brkm(TCONF, cleanup, "fanotify is not configured in this kernel."); } else { tst_brkm(TBROK | TERRNO, cleanup, "fanotify_init failed"); } } }
static void setup(void) { tst_sig(NOFORK, DEF_HANDLER, cleanup); TEST_PAUSE; tst_tmpdir(); fd_notify = myfanotify_init(FAN_CLASS_NOTIF | FAN_NONBLOCK, O_RDONLY); if (fd_notify < 0) { if (errno == ENOSYS) { tst_brkm(TCONF, cleanup, "fanotify is not configured in this kernel."); } else { tst_brkm(TBROK | TERRNO, cleanup, "fanotify_init failed"); } } if (myfanotify_mark(fd_notify, FAN_MARK_MOUNT | FAN_MARK_ADD, FAN_OPEN, AT_FDCWD, ".") < 0) { tst_brkm(TBROK | TERRNO, cleanup, "fanotify_mark (%d, FAN_MARK_MOUNT | FAN_MARK_ADD, " "FAN_OPEN, AT_FDCWD, \".\") failed", fd_notify); } }
static void setup(void) { tst_sig(NOFORK, DEF_HANDLER, cleanup); TEST_PAUSE; tst_tmpdir(); sprintf(fname, "fname_%d", getpid()); if ((fd_notify = myfanotify_init(FAN_CLASS_NOTIF, O_RDONLY)) < 0) { if (errno == ENOSYS) { tst_brkm(TCONF, cleanup, "fanotify is not configured in this kernel."); } else { tst_brkm(TBROK | TERRNO, cleanup, "fanotify_init failed"); } } }