static void cleanup(void) { if (mount_flag_dir && tst_umount("mntpoint") < 0) tst_resm(TWARN | TERRNO, "umount device:%s failed", device); if (mount_flag_cur && tst_umount("test_dir/mntpoint") < 0) tst_resm(TWARN | TERRNO, "umount device:%s failed", device); if (device) tst_release_device(NULL, device); tst_rmdir(); }
int main(int argc, char *argv[]) { int lc; tst_parse_opts(argc, argv, options, &help); setup(); for (lc = 0; TEST_LOOPING(lc); lc++) { tst_count = 0; TEST(mount(mntpoint_src, mntpoint_des, fstype, MS_BIND, NULL)); if (TEST_RETURN != 0) { tst_resm(TFAIL | TTERRNO, "mount(2) failed"); } else { if (open(file_des, O_CREAT | O_EXCL, S_IRWXU) == -1 && errno == EEXIST) tst_resm(TPASS, "bind mount is ok"); else tst_resm(TFAIL, "file %s is not available", file_des); TEST(tst_umount(mntpoint_des)); if (TEST_RETURN != 0) tst_brkm(TBROK | TTERRNO, cleanup, "umount(2) failed"); } } cleanup(); tst_exit(); }
int main(int ac, char **av) { int lc; tst_parse_opts(ac, av, NULL, NULL); setup(); for (lc = 0; TEST_LOOPING(lc); lc++) { tst_count = 0; TEST(mount(device, MNTPOINT, fs_type, 0, NULL)); if (TEST_RETURN != 0) { tst_resm(TFAIL | TTERRNO, "mount(2) failed"); } else { tst_resm(TPASS, "mount(2) passed "); TEST(tst_umount(MNTPOINT)); if (TEST_RETURN != 0) { tst_brkm(TBROK | TTERRNO, cleanup, "umount(2) failed"); } } } cleanup(); tst_exit(); }
static int run_tcases_per_fs(void) { int ret = 0; unsigned int i; const char *const *filesystems = tst_get_supported_fs_types(); if (!filesystems[0]) tst_brk(TCONF, "There are no supported filesystems"); for (i = 0; filesystems[i]; i++) { tdev.fs_type = filesystems[i]; prepare_device(); ret = fork_testrun(); if (mntpoint_mounted) { tst_umount(tst_test->mntpoint); mntpoint_mounted = 0; } if (ret == TCONF) { update_results(ret); continue; } if (ret == 0) continue; do_exit(ret); } return ret; }
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; }
static void cleanup(void) { if (opt_shmid && shmid != -1) SAFE_SHMCTL(shmid, IPC_RMID, NULL); if (!opt_shmid && fd != -1) { SAFE_CLOSE(fd); SAFE_UNLINK(TEST_FILE); } if (mounted) tst_umount(MOUNT_DIR); if (restore_nr_hgpgs) { tst_res(TINFO, "restore nr_hugepages to %ld.", nr_hugepages); SAFE_FILE_PRINTF(path, "%ld", nr_hugepages); } if (restore_shmmax) SAFE_FILE_PRINTF(PATH_SHMMAX, "%llu", shmmax); if (restore_overcomm_hgpgs) { tst_res(TINFO, "restore nr_overcommit_hugepages to %ld.", nr_overcommit_hugepages); SAFE_FILE_PRINTF(pathover, "%ld", nr_overcommit_hugepages); } }
static void cleanup(void) { if (seteuid(0)) tst_res(TWARN | TERRNO, "seteuid(0) Failed"); if (mount_flag) tst_umount(MNTPOINT); }
void cleanup(void) { if (dflag) if (tst_umount(mntpoint_src) != 0) tst_brkm(TBROK | TTERRNO, NULL, "umount(2) failed"); tst_rmdir(); }
static void cleanup(void) { cleanup_fanotify_groups(); SAFE_CHDIR("../"); if (mount_created && tst_umount(MOUNT_NAME) < 0) tst_brk(TBROK | TERRNO, "umount failed"); }
static void cleanup(void) { if (chdir_flag && chdir("..")) tst_resm(TWARN | TERRNO, "chdir('..') failed"); if (mount_flag && tst_umount(MNTPOINT) < 0) tst_resm(TWARN | TERRNO, "umount device:%s failed", device); if (device) tst_release_device(device); tst_rmdir(); }
static void cleanup(void) { if (mount_flag && tst_umount(MNT_POINT) < 0) tst_resm(TWARN | TERRNO, "umount device:%s failed", device); if (device) tst_release_device(NULL, device); tst_rmdir(); }
static void cleanup(void) { if (mount_flag && tst_umount(MNTPOINT) == -1) tst_brkm(TWARN | TERRNO, NULL, "umount(2) failed"); if (device) tst_release_device(NULL, device); tst_rmdir(); }
static void cleanup(void) { if (mount_flag && tst_umount(MNTPOINT) == -1) tst_resm(TWARN | TERRNO, "umount %s failed", MNTPOINT); if (device) tst_release_device(device); tst_rmdir(); }
static void cleanup(void) { if (mount_flag && tst_umount(MOUNT_DIR)) tst_resm(TWARN | TERRNO, "umount(%s) failed", device); if (device) tst_release_device(device); tst_rmdir(); }
static void cleanup(void) { if (mount_flag && tst_umount(MNTPOINT)) tst_resm(TWARN | TERRNO, "Failed to unmount"); if (device) tst_release_device(NULL, device); tst_rmdir(); }
static void cleanup(void) { if (fd_notify > 0) SAFE_CLOSE(fd_notify); if (mount_flag) { TEST(tst_umount(mntpoint)); if (TEST_RETURN != 0) tst_res(TWARN | TTERRNO, "umount(%s) failed", mntpoint); } }
static void cleanup(void) { if (dir_fd > 0 && close(dir_fd) < 0) tst_resm(TWARN | TERRNO, "close(%d) failed", dir_fd); if (mount_flag && tst_umount(MNT_POINT) < 0) tst_resm(TWARN | TERRNO, "umount device:%s failed", device); if (device) tst_release_device(device); tst_rmdir(); }
static void cleanup(void) { if (seteuid(0)) tst_resm(TWARN | TERRNO, "seteuid(0) failed"); if (mount_flag && tst_umount(MNTPOINT)) tst_resm(TWARN | TERRNO, "umount() failed"); if (device) tst_release_device(NULL, device); tst_rmdir(); }
static void cleanup(void) { if (fd > 0 && close(fd)) tst_resm(TWARN | TERRNO, "Failed to close file"); if (mount_flag && tst_umount(MNTPOINT)) tst_resm(TWARN | TERRNO, "umount() failed"); if (device) tst_release_device(NULL, device); tst_rmdir(); }
static void cleanup(void) { if (fd_notify > 0 && close(fd_notify) == -1) tst_resm(TWARN | TERRNO, "close(%d) failed", fd_notify); if (mount_flag) { TEST(tst_umount(mntpoint)); if (TEST_RETURN != 0) tst_resm(TWARN | TTERRNO, "umount(%s) failed", mntpoint); } tst_release_device(device); tst_rmdir(); }
static void do_cleanup(void) { if (mntpoint_mounted) tst_umount(tst_test->mntpoint); if (tst_test->needs_device && tdev.dev) tst_release_device(tdev.dev); if (tst_tmpdir_created()) { /* avoid munmap() on wrong pointer in tst_rmdir() */ tst_futexes = NULL; tst_rmdir(); } cleanup_ipc(); }
static void test_umount2(int i) { SAFE_MOUNT(cleanup, device, MNTPOINT, fs_type, 0, NULL); mount_flag = 1; TEST(umount2_retry(test_cases[i].mntpoint, UMOUNT_NOFOLLOW)); if (test_cases[i].exp_errno != 0) verify_failure(i); else verify_success(i); if (mount_flag) { if (tst_umount(MNTPOINT)) tst_brkm(TBROK, cleanup, "umount() failed"); mount_flag = 0; } }
static void cleanup(void) { if (olddirfd > 0 && close(olddirfd) < 0) tst_resm(TWARN | TERRNO, "close olddirfd failed"); if (newdirfd > 0 && close(newdirfd) < 0) tst_resm(TWARN | TERRNO, "close newdirfd failed"); if (filefd > 0 && close(filefd) < 0) tst_resm(TWARN | TERRNO, "close filefd failed"); if (mount_flag && tst_umount(MNTPOINT) < 0) tst_resm(TWARN | TERRNO, "umount %s failed", MNTPOINT); if (device) tst_release_device(device); tst_rmdir(); }
int main(int argc, char *argv[]) { int lc, i; tst_parse_opts(argc, argv, NULL, NULL); setup(); for (lc = 0; TEST_LOOPING(lc); lc++) { tst_count = 0; for (i = 0; i < TST_TOTAL; ++i) { TEST(mount(device, mntpoint, fs_type, rwflags[i], NULL)); if (TEST_RETURN != 0) { tst_resm(TFAIL | TTERRNO, "mount(2) failed"); continue; } /* Validate the rwflag */ if (test_rwflag(i, lc) == 1) tst_resm(TFAIL, "mount(2) failed while" " validating %ld", rwflags[i]); else tst_resm(TPASS, "mount(2) passed with " "rwflag = %ld", rwflags[i]); TEST(tst_umount(mntpoint)); if (TEST_RETURN != 0) tst_brkm(TBROK | TTERRNO, cleanup, "umount(2) failed for %s", mntpoint); } } cleanup(); tst_exit(); }
static void verify_mount(void) { TEST(mount(device, mntpoint, fs_type, 0, NULL)); if (TEST_RETURN == -1) { if (TEST_ERRNO == EPERM) tst_resm(TPASS | TTERRNO, "mount() failed expectedly"); else tst_resm(TFAIL | TTERRNO, "mount() was expected to fail with EPERM"); return; } if (TEST_RETURN == 0) { tst_resm(TFAIL, "mount() succeeded unexpectedly"); if (tst_umount(mntpoint)) tst_brkm(TBROK, cleanup, "umount() failed"); return; } tst_resm(TFAIL | TTERRNO, "mount() returned %li", TEST_RETURN); }
static void umount2_verify(void) { int ret; char buf[256]; const char *str = "abcdefghijklmnopqrstuvwxyz"; SAFE_MOUNT(cleanup, device, MNTPOINT, fs_type, 0, NULL); mount_flag = 1; fd = SAFE_CREAT(cleanup, MNTPOINT "/file", FILE_MODE); TEST(umount2(MNTPOINT, MNT_DETACH)); if (TEST_RETURN != 0) { tst_resm(TFAIL | TTERRNO, "umount2(2) Failed"); goto EXIT; } mount_flag = 0; /* check the unavailability for new access */ ret = access(MNTPOINT "/file", F_OK); if (ret != -1) { tst_resm(TFAIL, "umount2(2) MNT_DETACH flag " "performed abnormally"); goto EXIT; } /* * check the old fd still points to the file * in previous mount point and is available */ SAFE_WRITE(cleanup, 1, fd, str, strlen(str)); SAFE_CLOSE(cleanup, fd); SAFE_MOUNT(cleanup, device, MNTPOINT, fs_type, 0, NULL); mount_flag = 1; fd = SAFE_OPEN(cleanup, MNTPOINT "/file", O_RDONLY); memset(buf, 0, sizeof(buf)); SAFE_READ(cleanup, 1, fd, buf, strlen(str)); if (strcmp(str, buf)) { tst_resm(TFAIL, "umount2(2) MNT_DETACH flag " "performed abnormally"); goto EXIT; } tst_resm(TPASS, "umount2(2) Passed"); EXIT: SAFE_CLOSE(cleanup, fd); fd = 0; if (mount_flag) { if (tst_umount(MNTPOINT)) tst_brkm(TBROK, cleanup, "umount() failed"); mount_flag = 0; } }
static void cleanup(void) { if (mount_flag && tst_umount(mntpoint) < 0) tst_res(TWARN | TERRNO, "umount() failed"); }
void verify_inotify(void) { int ret; int len, i, test_num; int test_cnt = 0; SAFE_MOUNT(tst_device->dev, mntpoint, tst_device->fs_type, 0, NULL); mount_flag = 1; wd = myinotify_add_watch(fd_notify, fname, IN_ALL_EVENTS); if (wd < 0) { tst_brk(TBROK | TERRNO, "inotify_add_watch (%d, %s, IN_ALL_EVENTS) failed.", fd_notify, fname); } event_set[test_cnt] = IN_UNMOUNT; test_cnt++; event_set[test_cnt] = IN_IGNORED; test_cnt++; /*check exit code from inotify_rm_watch */ test_cnt++; tst_res(TINFO, "umount %s", tst_device->dev); TEST(tst_umount(mntpoint)); if (TEST_RETURN != 0) { tst_brk(TBROK, "umount(2) Failed " "while unmounting errno = %d : %s", TEST_ERRNO, strerror(TEST_ERRNO)); } mount_flag = 0; len = read(fd_notify, event_buf, EVENT_BUF_LEN); if (len < 0) { tst_brk(TBROK | TERRNO, "read(%d, buf, %zu) failed", fd_notify, EVENT_BUF_LEN); } /* check events */ test_num = 0; i = 0; while (i < len) { struct inotify_event *event; event = (struct inotify_event *)&event_buf[i]; if (test_num >= (test_cnt - 1)) { tst_res(TFAIL, "get unnecessary event: wd=%d mask=%x " "cookie=%u len=%u", event->wd, event->mask, event->cookie, event->len); } else if (event_set[test_num] == event->mask) { tst_res(TPASS, "get event: wd=%d mask=%x" " cookie=%u len=%u", event->wd, event->mask, event->cookie, event->len); } else { tst_res(TFAIL, "get event: wd=%d mask=%x " "(expected %x) cookie=%u len=%u", event->wd, event->mask, event_set[test_num], event->cookie, event->len); } test_num++; i += EVENT_SIZE + event->len; } for (; test_num < test_cnt - 1; test_num++) { tst_res(TFAIL, "don't get event: mask=%x ", event_set[test_num]); } ret = myinotify_rm_watch(fd_notify, wd); if (ret != -1 || errno != EINVAL) tst_res(TFAIL | TERRNO, "inotify_rm_watch (%d, %d) didn't return EINVAL", fd_notify, wd); else tst_res(TPASS, "inotify_rm_watch (%d, %d) returned EINVAL", fd_notify, wd); }
static void do_umount(void) { if (tst_umount(mntpoint)) tst_brkm(TBROK | TERRNO, cleanup, "Failed to umount(mntpoint)"); }
static void cleanup(void) { if (mount_flag) tst_umount(MNTPOINT); }