예제 #1
0
파일: mkdirat02.c 프로젝트: JanyHuang/ltp
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();
}
예제 #2
0
파일: mount05.c 프로젝트: kraj/ltp
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();
}
예제 #3
0
파일: mount01.c 프로젝트: 1587/ltp
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();
}
예제 #4
0
파일: tst_test.c 프로젝트: sathnaga/ltp
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;
}
예제 #5
0
파일: inotify03.c 프로젝트: sathnaga/ltp
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;
}
예제 #6
0
파일: hugemmap05.c 프로젝트: kraj/ltp
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);
	}
}
예제 #7
0
static void cleanup(void)
{
	if (seteuid(0))
		tst_res(TWARN | TERRNO, "seteuid(0) Failed");

	if (mount_flag)
		tst_umount(MNTPOINT);
}
예제 #8
0
파일: mount05.c 프로젝트: kraj/ltp
void cleanup(void)
{
	if (dflag)
		if (tst_umount(mntpoint_src) != 0)
			tst_brkm(TBROK | TTERRNO, NULL, "umount(2) failed");

	tst_rmdir();
}
예제 #9
0
파일: fanotify09.c 프로젝트: kraj/ltp
static void cleanup(void)
{
	cleanup_fanotify_groups();

	SAFE_CHDIR("../");

	if (mount_created && tst_umount(MOUNT_NAME) < 0)
		tst_brk(TBROK | TERRNO, "umount failed");
}
예제 #10
0
파일: mmap16.c 프로젝트: AiprNick/ltp
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();
}
예제 #11
0
파일: link08.c 프로젝트: JanyHuang/ltp
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();
}
예제 #12
0
파일: open12.c 프로젝트: CSRedRat/ltp
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();
}
예제 #13
0
파일: rmdir02.c 프로젝트: 1587/ltp
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();
}
예제 #14
0
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();
}
예제 #15
0
파일: umount2_02.c 프로젝트: JanyHuang/ltp
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();
}
예제 #16
0
파일: inotify03.c 프로젝트: sathnaga/ltp
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);
	}
}
예제 #17
0
파일: mknodat02.c 프로젝트: AiprNick/ltp
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();
}
예제 #18
0
파일: umount03.c 프로젝트: AbhiramiP/ltp
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();
}
예제 #19
0
파일: umount02.c 프로젝트: JanyHuang/ltp
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();
}
예제 #20
0
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();
}
예제 #21
0
파일: tst_test.c 프로젝트: sathnaga/ltp
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();
}
예제 #22
0
파일: umount2_03.c 프로젝트: 1587/ltp
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;
	}
}
예제 #23
0
파일: renameat01.c 프로젝트: AiprNick/ltp
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();
}
예제 #24
0
파일: mount03.c 프로젝트: 1587/ltp
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();
}
예제 #25
0
파일: mount04.c 프로젝트: JanyHuang/ltp
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);
}
예제 #26
0
파일: umount2_01.c 프로젝트: 1587/ltp
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;
	}
}
예제 #27
0
파일: quotactl02.c 프로젝트: bsbrp/ltp
static void cleanup(void)
{
    if (mount_flag && tst_umount(mntpoint) < 0)
        tst_res(TWARN | TERRNO, "umount() failed");
}
예제 #28
0
파일: inotify03.c 프로젝트: sathnaga/ltp
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);
}
예제 #29
0
파일: mount02.c 프로젝트: AbhiramiP/ltp
static void do_umount(void)
{
	if (tst_umount(mntpoint))
		tst_brkm(TBROK | TERRNO, cleanup, "Failed to umount(mntpoint)");
}
예제 #30
0
static void cleanup(void)
{
	if (mount_flag)
		tst_umount(MNTPOINT);
}