/* * setup() - performs all ONE TIME setup for this test. */ void setup() { tst_sig(NOFORK, DEF_HANDLER, cleanup); TEST_PAUSE; tst_tmpdir(); if ((fd_notify = myinotify_init()) < 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, ".", IN_ALL_EVENTS)) < 0) { tst_brkm(TBROK|TERRNO, cleanup, "inotify_add_watch (%d, \".\", IN_ALL_EVENTS) failed", fd_notify); }; }
static void setup(void) { tst_sig(NOFORK, DEF_HANDLER, cleanup); TEST_PAUSE; tst_tmpdir(); fd_notify = myinotify_init(); if (fd_notify == -1) tst_brkm(TBROK|TERRNO, cleanup, "inotify_init() failed"); SAFE_MKDIR(cleanup, TEST_DIR, 00700); close(SAFE_CREAT(cleanup, TEST_FILE, 00600)); wd_dir = myinotify_add_watch(fd_notify, TEST_DIR, IN_ALL_EVENTS); if (wd_dir == -1) { tst_brkm(TBROK|TERRNO, cleanup, "inotify_add_watch(%d, \"%s\", IN_ALL_EVENTS) [1] failed", fd_notify, TEST_DIR); } reap_wd_dir = 1; wd_file = myinotify_add_watch(fd_notify, TEST_FILE, IN_ALL_EVENTS); if (wd_file == -1) tst_brkm(TBROK|TERRNO, cleanup, "inotify_add_watch(%d, \"%s\", IN_ALL_EVENTS) [2] failed", fd_notify, TEST_FILE); reap_wd_file = 1; }
static void setup(void) { int ret; SAFE_MKDIR(mntpoint, DIR_MODE); SAFE_MOUNT(tst_device->dev, mntpoint, tst_device->fs_type, 0, NULL); mount_flag = 1; sprintf(fname, "%s/tfile_%d", mntpoint, getpid()); fd = SAFE_OPEN(fname, O_RDWR | O_CREAT, 0700); ret = write(fd, fname, 1); if (ret == -1) { tst_brk(TBROK | TERRNO, "write(%d, %s, 1) failed", fd, fname); } /* close the file we have open */ SAFE_CLOSE(fd); fd_notify = myinotify_init(); if (fd_notify < 0) { if (errno == ENOSYS) tst_brk(TCONF, "inotify is not configured in this kernel."); else tst_brk(TBROK | TERRNO, "inotify_init failed"); } tst_umount(mntpoint); mount_flag = 0; }
/* * setup() - performs all ONE TIME setup for this test. */ void setup() { /* capture signals */ tst_sig(NOFORK, DEF_HANDLER, cleanup); /* Pause if that option was specified */ TEST_PAUSE; /* make a temp directory and cd to it */ tst_tmpdir(); if ((fd_notify = myinotify_init()) < 0) { if (errno == ENOSYS) { tst_resm(TCONF, "inotify is not configured in this kernel."); tst_resm(TCONF, "Test will not run."); tst_exit(); } else { tst_brkm(TBROK, cleanup, "inotify_init () Failed, errno=%d : %s", errno, strerror(errno)); } } if ((wd = myinotify_add_watch(fd_notify, ".", IN_ALL_EVENTS)) < 0) { tst_brkm(TBROK, cleanup, "inotify_add_watch (%d, \".\", IN_ALL_EVENTS)" "Failed, errno=%d : %s", fd_notify, errno, strerror(errno)); }; } /* End setup() */
static void setup(void) { tst_sig(NOFORK, DEF_HANDLER, cleanup); TEST_PAUSE; tst_tmpdir(); sprintf(fname, "tfile_%d", getpid()); if ((fd = open(fname, O_RDWR | O_CREAT, 0700)) == -1) { tst_brkm(TBROK | TERRNO, cleanup, "open(%s, O_RDWR|O_CREAT,0700) failed", fname); } if ((write(fd, fname, 1)) == -1) { tst_brkm(TBROK | TERRNO, cleanup, "write(%d, %s, 1) failed", fd, fname); } /* close the file we have open */ if (close(fd) == -1) { tst_brkm(TBROK, cleanup, "close(%s) failed", fname); } if ((fd_notify = myinotify_init()) < 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); }; }
static void setup(void) { int ret; tst_sig(NOFORK, DEF_HANDLER, cleanup); TEST_PAUSE; fs_type = tst_dev_fs_type(); tst_tmpdir(); device = tst_acquire_device(cleanup); if (!device) tst_brkm(TCONF, cleanup, "Failed to obtain block device"); tst_mkfs(cleanup, device, fs_type, NULL); if (mkdir(mntpoint, DIR_MODE) < 0) { tst_brkm(TBROK | TERRNO, cleanup, "mkdir(%s, %#o) failed", mntpoint, DIR_MODE); } /* Call mount(2) */ tst_resm(TINFO, "mount %s to %s fs_type=%s", device, mntpoint, fs_type); TEST(mount(device, mntpoint, fs_type, 0, NULL)); /* check return code */ if (TEST_RETURN != 0) { TEST_ERROR_LOG(TEST_ERRNO); tst_brkm(TBROK | TTERRNO, cleanup, "mount(2) failed"); } mount_flag = 1; sprintf(fname, "%s/tfile_%d", mntpoint, getpid()); fd = open(fname, O_RDWR | O_CREAT, 0700); if (fd == -1) { tst_brkm(TBROK | TERRNO, cleanup, "open(%s, O_RDWR|O_CREAT,0700) failed", fname); } ret = write(fd, fname, 1); if (ret == -1) { tst_brkm(TBROK | TERRNO, cleanup, "write(%d, %s, 1) failed", fd, fname); } /* close the file we have open */ if (close(fd) == -1) tst_brkm(TBROK | TERRNO, cleanup, "close(%s) failed", fname); fd_notify = myinotify_init(); if (fd_notify < 0) { if (errno == ENOSYS) tst_brkm(TCONF, cleanup, "inotify is not configured in this kernel."); else tst_brkm(TBROK | TERRNO, cleanup, "inotify_init failed"); } wd = myinotify_add_watch(fd_notify, fname, IN_ALL_EVENTS); if (wd < 0) tst_brkm(TBROK | TERRNO, cleanup, "inotify_add_watch (%d, %s, IN_ALL_EVENTS) failed.", fd_notify, fname); }