示例#1
0
文件: rename06.c 项目: kraj/ltp
/*
 * setup() - performs all ONE TIME setup for this test.
 */
void setup(void)
{

	tst_sig(NOFORK, DEF_HANDLER, cleanup);

	TEST_PAUSE;

	/* Create a temporary directory and make it current. */
	tst_tmpdir();

	sprintf(fdir, "./tdir_%d", getpid());
	sprintf(mdir, "%s/rndir_%d", fdir, getpid());

	/* create "old" directory */
	if (stat(fdir, &buf1) != -1) {
		tst_brkm(TBROK, cleanup, "tmp directory %s found!", fdir);
	}
	SAFE_MKDIR(cleanup, fdir, 00770);
	SAFE_STAT(cleanup, fdir, &buf1);
	/* save "old"'s dev and ino */
	olddev = buf1.st_dev;
	oldino = buf1.st_ino;

	/* create another directory */
	if (stat(mdir, &buf2) != -1) {
		tst_brkm(TBROK, cleanup, "tmp directory %s found!", mdir);
	}
	SAFE_MKDIR(cleanup, mdir, 00770);

	SAFE_STAT(cleanup, mdir, &buf2);

	/* save "new"'s dev and ino */
	olddev1 = buf2.st_dev;
	oldino1 = buf2.st_ino;
}
示例#2
0
文件: statx04.c 项目: kraj/ltp
static void setup(void)
{
	SAFE_MKDIR(TESTDIR_FLAGGED, 0777);
	SAFE_MKDIR(TESTDIR_UNFLAGGED, 0777);

	if (!strcmp(tst_device->fs_type, "btrfs") && tst_kvercmp(4, 13, 0) < 0)
		tst_brk(TCONF, "Btrfs statx() supported since 4.13");

	caid_flags_setup();
}
示例#3
0
文件: rmdir02.c 项目: 1587/ltp
static void setup(void)
{
	int i;
	const char *fs_type;

	tst_require_root();

	tst_sig(NOFORK, DEF_HANDLER, cleanup);

	TEST_PAUSE;

	tst_tmpdir();

	fs_type = tst_dev_fs_type();
	device = tst_acquire_device(cleanup);

	if (!device)
		tst_brkm(TCONF, cleanup, "Failed to acquire device");

	tst_mkfs(cleanup, device, fs_type, NULL, NULL);
	SAFE_MKDIR(cleanup, MNTPOINT, DIR_MODE);
	if (mount(device, MNTPOINT, fs_type, 0, NULL) == -1) {
		tst_brkm(TBROK | TERRNO, cleanup,
			"mount device:%s failed", device);
	}
	SAFE_MKDIR(cleanup, TESTDIR5, DIR_MODE);
	if (mount(device, MNTPOINT, fs_type, MS_REMOUNT | MS_RDONLY,
			NULL) == -1) {
		tst_brkm(TBROK | TERRNO, cleanup,
			"mount device:%s failed", device);
	}
	mount_flag = 1;

	SAFE_MKDIR(cleanup, TESTDIR, DIR_MODE);
	SAFE_TOUCH(cleanup, TESTFILE, FILE_MODE, NULL);

	memset(longpathname, 'a', PATH_MAX + 1);

	SAFE_TOUCH(cleanup, TESTFILE2, FILE_MODE, NULL);

#if !defined(UCLINUX)
	test_cases[4].dir = SAFE_MMAP(cleanup, 0, 1, PROT_NONE,
		MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
#endif

	/*
	 * NOTE: the ELOOP test is written based on that the
	 * consecutive symlinks limit in kernel is hardwired
	 * to 40.
	 */
	SAFE_MKDIR(cleanup, "loopdir", DIR_MODE);
	SAFE_SYMLINK(cleanup, "../loopdir", "loopdir/loopdir");
	for (i = 0; i < 43; i++)
		strcat(looppathname, TESTDIR4);
}
示例#4
0
文件: fanotify09.c 项目: kraj/ltp
static void setup(void)
{
	SAFE_MKDIR(MOUNT_NAME, 0755);
	SAFE_MOUNT(MOUNT_NAME, MOUNT_NAME, "none", MS_BIND, NULL);
	mount_created = 1;
	SAFE_CHDIR(MOUNT_NAME);
	SAFE_MKDIR(DIR_NAME, 0755);

	sprintf(fname, "tfile_%d", getpid());
	SAFE_FILE_PRINTF(fname, "1");
}
示例#5
0
文件: mkdirat02.c 项目: MohdVara/ltp
static void setup(void)
{
	int i;
	const char *fs_type;

	tst_require_root(NULL);

	tst_sig(NOFORK, DEF_HANDLER, cleanup);

	TEST_PAUSE;

	tst_tmpdir();

	fs_type = tst_dev_fs_type();
	device = tst_acquire_device(cleanup);

	if (!device)
		tst_brkm(TCONF, cleanup, "Failed to acquire device");

	SAFE_MKDIR(cleanup, "test_dir", DIR_MODE);
	dir_fd = SAFE_OPEN(cleanup, "test_dir", O_DIRECTORY);

	SAFE_MKDIR(cleanup, "test_eloop", DIR_MODE);
	SAFE_SYMLINK(cleanup, "../test_eloop", "test_eloop/test_eloop");

	SAFE_MKDIR(cleanup, "test_dir/test_eloop", DIR_MODE);
	SAFE_SYMLINK(cleanup, "../test_eloop",
		     "test_dir/test_eloop/test_eloop");
	/*
	 * NOTE: the ELOOP test is written based on that the consecutive
	 * symlinks limits in kernel is hardwired to 40.
	 */
	for (i = 0; i < 43; i++)
		strcat(test_file2, "/test_eloop");

	tst_mkfs(cleanup, device, fs_type, NULL);

	SAFE_MKDIR(cleanup, "test_dir/mntpoint", DIR_MODE);
	if (mount(device, "test_dir/mntpoint", fs_type, MS_RDONLY, NULL) < 0) {
		tst_brkm(TBROK | TERRNO, cleanup,
			 "mount device:%s failed", device);
	}
	mount_flag_dir = 1;

	SAFE_MKDIR(cleanup, "mntpoint", DIR_MODE);
	if (mount(device, "mntpoint", fs_type, MS_RDONLY, NULL) < 0) {
		tst_brkm(TBROK | TERRNO, cleanup,
			 "mount device:%s failed", device);
	}
	mount_flag_cur = 1;

	TEST_EXP_ENOS(exp_enos);
}
示例#6
0
文件: mmap16.c 项目: AiprNick/ltp
static void setup(void)
{
	const char *fs_opts[3] = {"-b", "1024", NULL};

	tst_sig(FORK, DEF_HANDLER, NULL);
	tst_require_root();

	TEST_PAUSE;
	tst_tmpdir();

	TST_CHECKPOINT_INIT(tst_rmdir);

	page_size = getpagesize();

	device = tst_acquire_device(cleanup);
	if (!device)
		tst_brkm(TCONF, cleanup, "Failed to obtain block device");
	tst_mkfs(cleanup, device, fs_type, fs_opts, "10240");

	SAFE_MKDIR(cleanup, MNTPOINT, 0755);
	/*
	 * Disable ext4 delalloc feature, so block will be allocated
	 * as soon as possible
	 */
	SAFE_MOUNT(cleanup, device, MNTPOINT, fs_type, 0, "nodelalloc");
	mount_flag = 1;

	SAFE_CHDIR(cleanup, MNTPOINT);
	chdir_flag = 1;

}
示例#7
0
文件: mknodat01.c 项目: 1587/ltp
static void setup(void)
{
	char *tmpdir;

	if (tst_kvercmp(2, 6, 16) < 0)
		tst_brkm(TCONF, NULL, "This test needs kernel 2.6.16 or newer");

	tst_sig(NOFORK, DEF_HANDLER, cleanup);

	TEST_PAUSE;

	tst_tmpdir();

	/* Initialize test dir and file names */
	tmpdir = tst_get_tmpdir();
	sprintf(testfilepath, PATHNAME"/mknodattestfile%d", getpid());
	sprintf(testfile, "mknodattestfile%d", getpid());
	sprintf(testfile2, "mknodattestfile2%d", getpid());
	sprintf(testfile3, "%s/mknodattestfile3%d", tmpdir, getpid());
	free(tmpdir);

	SAFE_MKDIR(cleanup, PATHNAME, 0700);

	dir_fd = SAFE_OPEN(cleanup, PATHNAME, O_DIRECTORY);
	fd = SAFE_OPEN(cleanup, testfile2, O_CREAT | O_RDWR, 0600);
}
示例#8
0
文件: mem.c 项目: sathnaga/ltp
void mount_mem(char *name, char *fs, char *options, char *path, char *path_new)
{
	SAFE_MKDIR(path, 0777);
	if (mount(name, path, fs, 0, options) == -1) {
		if (errno == ENODEV) {
			if (rmdir(path) == -1)
				tst_res(TWARN | TERRNO, "rmdir %s failed",
					 path);
			tst_brk(TCONF,
				 "file system %s is not configured in kernel",
				 fs);
		}
		tst_brk(TBROK | TERRNO, "mount %s", path);
	}
	SAFE_MKDIR(path_new, 0777);
}
示例#9
0
文件: mount03.c 项目: 1587/ltp
static void setup(void)
{
	char path[PATH_MAX];

	tst_sig(FORK, DEF_HANDLER, cleanup);

	tst_require_root();

	tst_tmpdir();

	fs_type = tst_dev_fs_type();
	device = tst_acquire_device(cleanup);

	if (!device)
		tst_brkm(TCONF, cleanup, "Failed to obtain block device");

	tst_mkfs(cleanup, device, fs_type, NULL, NULL);

	SAFE_MKDIR(cleanup, mntpoint, DIR_MODE);

	if (getcwd(path_name, sizeof(path_name)) == NULL)
		tst_brkm(TBROK, cleanup, "getcwd failed");

	if (chmod(path_name, DIR_MODE) != 0)
		tst_brkm(TBROK, cleanup, "chmod(%s, %#o) failed",
			 path_name, DIR_MODE);

	strncpy(path, path_name, PATH_MAX);
	snprintf(path_name, PATH_MAX, "%s/%s/", path, mntpoint);

	TEST_PAUSE;
}
示例#10
0
文件: umount03.c 项目: AbhiramiP/ltp
static void setup(void)
{
	const char *fs_type;
	struct passwd *ltpuser;

	tst_sig(FORK, DEF_HANDLER, cleanup);

	tst_require_root(NULL);

	ltpuser = SAFE_GETPWNAM(NULL, "nobody");

	tst_tmpdir();

	fs_type = tst_dev_fs_type();
	device = tst_acquire_device(cleanup);
	if (!device)
		tst_brkm(TCONF, cleanup, "Failed to obtain block device");

	tst_mkfs(cleanup, device, fs_type, NULL);

	SAFE_MKDIR(cleanup, MNTPOINT, DIR_MODE);

	if (mount(device, MNTPOINT, fs_type, 0, NULL))
		tst_brkm(TBROK | TERRNO, cleanup, "mount() failed");
	mount_flag = 1;

	SAFE_SETEUID(cleanup, ltpuser->pw_uid);
	TEST_PAUSE;
}
示例#11
0
文件: madvise01.c 项目: sathnaga/ltp
static void setup(void)
{
	unsigned int i;
	int fd;

	SAFE_MKDIR(TMP_DIR, 0664);
	SAFE_MOUNT(TMP_DIR, TMP_DIR, "tmpfs", 0, NULL);

	fd = SAFE_OPEN(TEST_FILE, O_RDWR | O_CREAT, 0664);

	/* Writing 40 KB of random data into this file [32 * 1280 = 40960] */
	for (i = 0; i < 1280; i++)
		SAFE_WRITE(1, fd, STR, strlen(STR));

	SAFE_FSTAT(fd, &st);

	/* Map the input file into shared memory */
	sfile = SAFE_MMAP(NULL, st.st_size,
			PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);

	/* Map the input file into private memory. MADV_HUGEPAGE only works
	 * with private anonymous pages */
	amem = SAFE_MMAP(NULL, st.st_size,
			PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);

	SAFE_CLOSE(fd);
}
示例#12
0
文件: fanotify04.c 项目: gibertre/ltp
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");
		}
	}
}
示例#13
0
文件: access06.c 项目: 1587/ltp
static void setup(void)
{
	tst_sig(NOFORK, DEF_HANDLER, cleanup);

	tst_require_root();
	tst_tmpdir();

	fs_type = tst_dev_fs_type();
	device = tst_acquire_device(cleanup);

	if (!device)
		tst_brkm(TCONF, cleanup, "Failed to obtain block device");

	tst_mkfs(cleanup, device, fs_type, NULL, NULL);
	SAFE_MKDIR(cleanup, MNT_POINT, DIR_MODE);

	TEST_PAUSE;

	/*
	 * mount a read-only file system for test EROFS
	 */
	if (mount(device, MNT_POINT, fs_type, MS_RDONLY, NULL) < 0) {
		tst_brkm(TBROK | TERRNO, cleanup,
			 "mount device:%s failed", device);
	}
	mount_flag = 1;
}
示例#14
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;
}
示例#15
0
static void setup(void)
{
	tst_require_root();

	if ((tst_kvercmp(2, 6, 8)) < 0) {
		tst_brkm(TCONF, NULL, "This test can only run on kernels "
			 "that are 2.6.8 or higher");
	}

	tst_sig(NOFORK, DEF_HANDLER, NULL);

	tst_tmpdir();

	fs_type = tst_dev_fs_type();
	device = tst_acquire_device(cleanup);

	if (!device)
		tst_brkm(TCONF, cleanup, "Failed to obtain block device");

	tst_mkfs(cleanup, device, fs_type, NULL);

	SAFE_MKDIR(cleanup, MNTPOINT, DIR_MODE);

	TEST_PAUSE;
}
示例#16
0
文件: umount02.c 项目: JanyHuang/ltp
static void setup(void)
{
	const char *fs_type;

	tst_sig(FORK, DEF_HANDLER, cleanup);

	tst_require_root();

	tst_tmpdir();

	fs_type = tst_dev_fs_type();
	device = tst_acquire_device(cleanup);

	if (!device)
		tst_brkm(TCONF, cleanup, "Failed to obtain block device");

	tst_mkfs(cleanup, device, fs_type, NULL);

	memset(long_path, 'a', PATH_MAX + 1);

	SAFE_MKDIR(cleanup, MNTPOINT, DIR_MODE);

	if (mount(device, MNTPOINT, fs_type, 0, NULL))
		tst_brkm(TBROK | TERRNO, cleanup, "mount() failed");
	mount_flag = 1;

	fd = SAFE_OPEN(cleanup, MNTPOINT "/file", O_CREAT | O_RDWR);

	TEST_PAUSE;
}
示例#17
0
文件: mount04.c 项目: JanyHuang/ltp
static void setup(void)
{
	char nobody_uid[] = "nobody";
	struct passwd *ltpuser;

	tst_sig(FORK, DEF_HANDLER, cleanup);

	tst_require_root();

	tst_tmpdir();

	fs_type = tst_dev_fs_type();
	device = tst_acquire_device(cleanup);

	if (!device)
		tst_brkm(TCONF, cleanup, "Failed to obtain block device");

	tst_mkfs(cleanup, device, fs_type, NULL);

	ltpuser = SAFE_GETPWNAM(cleanup, nobody_uid);
	SAFE_SETEUID(cleanup, ltpuser->pw_uid);
	SAFE_MKDIR(cleanup, mntpoint, DIR_MODE);

	TEST_PAUSE;
}
示例#18
0
文件: fstatat01.c 项目: JevonQ/ltp
void setup(void)
{
	tst_sig(NOFORK, DEF_HANDLER, cleanup);

	tst_tmpdir();

	char *abs_path = tst_get_tmpdir();

	SAFE_ASPRINTF(cleanup, &testfile3, "%s/fstatattestfile3.txt", abs_path);
	free(abs_path);

	SAFE_MKDIR(cleanup, pathname, 0700);

	fds[0] = SAFE_OPEN(cleanup, pathname, O_DIRECTORY);
	fds[1] = fds[4] = fds[0];

	SAFE_OPEN(cleanup, testfile, O_CREAT | O_RDWR, 0600);
	SAFE_OPEN(cleanup, testfile2, O_CREAT | O_RDWR, 0600);

	fds[2] =  SAFE_OPEN(cleanup, testfile3, O_CREAT | O_RDWR, 0600);

	fds[3] = 100;
	fds[5] = AT_FDCWD;

	filenames[0] = filenames[2] = filenames[3] = filenames[4] =
	    filenames[5] = testfile;
	filenames[1] = testfile3;

	TEST_PAUSE;
}
示例#19
0
void setup(void)
{
	tst_sig(NOFORK, DEF_HANDLER, cleanup);

	tst_tmpdir();

	/* Initialize test dir and file names */
	char *abs_path = tst_get_tmpdir();
	int p = getpid();

	sprintf(pathname, "fchmodattestdir%d", p);
	sprintf(testfile, "fchmodattest%d.txt", p);
	sprintf(testfile2, "%s/fchmodattest%d.txt", abs_path, p);
	sprintf(testfile3, "fchmodattestdir%d/fchmodattest%d.txt", p, p);

	free(abs_path);

	SAFE_MKDIR(cleanup, pathname, 0700);

	fds[0] = SAFE_OPEN(cleanup, pathname, O_DIRECTORY);
	fds[1] = fds[4] = fds[0];

	SAFE_OPEN(cleanup, testfile, O_CREAT | O_RDWR, 0600);
	SAFE_OPEN(cleanup, testfile2, O_CREAT | O_RDWR, 0600);

	fds[2] = SAFE_OPEN(cleanup, testfile3, O_CREAT | O_RDWR, 0600);
	fds[3] = 100;
	fds[5] = AT_FDCWD;

	filenames[0] = filenames[2] = filenames[3] = filenames[4] = testfile;
	filenames[1] = testfile2;
	filenames[5] = testfile3;

	TEST_PAUSE;
}
示例#20
0
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;
}
示例#21
0
文件: mount02.c 项目: AbhiramiP/ltp
static void setup(void)
{
	tst_sig(FORK, DEF_HANDLER, cleanup);

	tst_require_root(NULL);

	tst_tmpdir();

	SAFE_TOUCH(cleanup, file, FILE_MODE, NULL);

	fs_type = tst_dev_fs_type();
	device = tst_acquire_device(cleanup);

	if (!device)
		tst_brkm(TCONF, cleanup, "Failed to obtain block device");

	tst_mkfs(cleanup, device, fs_type, NULL);

	SAFE_MKDIR(cleanup, mntpoint, DIR_MODE);

	memset(path, 'a', PATH_MAX + 1);

	if (mknod(char_dev, S_IFCHR | FILE_MODE, 0)) {
		tst_brkm(TBROK | TERRNO, cleanup,
		         "failed to mknod(char_dev, S_IFCHR | FILE_MODE, 0)");
	}

	TEST_PAUSE;
}
示例#22
0
文件: hugemmap05.c 项目: kraj/ltp
static void setup(void)
{
	check_hugepage();
	hugepagesize = SAFE_READ_MEMINFO("Hugepagesize:") * 1024;
	init_sys_sz_paths();

	if (opt_sysfs) {
		path = path_sys_sz_huge;
		pathover = path_sys_sz_over;
	} else {
		path = PATH_PROC_HUGE;
		pathover = PATH_PROC_OVER;
	}

	if (opt_alloc) {
		size = atoi(opt_alloc);
		length = (size + size * 0.5) * 2;
	}

	if (opt_shmid) {
		SAFE_FILE_SCANF(PATH_SHMMAX, "%llu", &shmmax);
		if (shmmax < (unsigned long long)(length / 2 * hugepagesize)) {
			restore_shmmax = 1;
			SAFE_FILE_PRINTF(PATH_SHMMAX, "%ld",
					(length / 2 * hugepagesize));
		}
	}

	SAFE_FILE_SCANF(path, "%ld", &nr_hugepages);
	tst_res(TINFO, "original nr_hugepages is %ld", nr_hugepages);

	/* Reset. */
	SAFE_FILE_PRINTF(path, "%ld", size);
	restore_nr_hgpgs = 1;

	if (access(pathover, F_OK)) {
		tst_brk(TCONF, "file %s does not exist in the system",
			pathover);
	}

	SAFE_FILE_SCANF(pathover, "%ld", &nr_overcommit_hugepages);
	tst_res(TINFO, "original nr_overcommit_hugepages is %ld",
		nr_overcommit_hugepages);

	/* Reset. */
	SAFE_FILE_PRINTF(pathover, "%ld", size);
	restore_overcomm_hgpgs = 1;

	SAFE_MKDIR(MOUNT_DIR, 0700);
	SAFE_MOUNT(NULL, MOUNT_DIR, "hugetlbfs", 0, NULL);
	mounted = 1;

	if (opt_shmid) {
		/* Use /proc/meminfo to generate an IPC key. */
		key = ftok(PATH_MEMINFO, strlen(PATH_MEMINFO));
		if (key == -1)
			tst_brk(TBROK | TERRNO, "ftok");
	}
}
示例#23
0
文件: acct01.c 项目: disdi/ltp
static void setup(void)
{
	int fd;

	tst_require_root(NULL);

	tst_tmpdir();

	ltpuser = SAFE_GETPWNAM(cleanup, "nobody");

	fd = SAFE_CREAT(cleanup, TEST_FILE5, 0777);
	SAFE_CLOSE(cleanup, fd);

	if (acct(TEST_FILE5) == -1) {
		if (errno == ENOSYS) {
			tst_brkm(TCONF, cleanup,
				 "BSD process accounting is not configured in "
				 "this kernel");
		} else {
			tst_brkm(TBROK | TERRNO, cleanup, "acct failed unexpectedly");
		}
	}

	/* turn off acct, so we are in a known state */
	if (acct(NULL) == -1) {
		if (errno == ENOSYS) {
			tst_brkm(TCONF, cleanup,
				 "BSD process accounting is not configured in "
				 "this kernel");
		} else {
			tst_brkm(TBROK | TERRNO, cleanup, "acct(NULL) failed");
		}
	}

	/* ELOOP SETTING */
	SAFE_SYMLINK(cleanup, TEST_FILE6, "test_file_eloop2");
	SAFE_SYMLINK(cleanup, "test_file_eloop2", TEST_FILE6);

	/* ENAMETOOLONG SETTING */
	memset(nametoolong, 'a', PATH_MAX+1);

	/* EROFS SETTING */
	tst_mkfs(NULL, device, fstype, NULL);
	SAFE_MKDIR(cleanup, "mntpoint", DIR_MODE);
	if (mount(device, "mntpoint", fstype, 0, NULL) < 0) {
		tst_brkm(TBROK | TERRNO, cleanup,
			 "mount device:%s failed", device);
	}
	mount_flag = 1;
	/* Create a file in the file system, then remount it as read-only */
	fd = SAFE_CREAT(cleanup, TEST_FILE8, 0644);
	SAFE_CLOSE(cleanup, fd);
	if (mount(device, "mntpoint", fstype,
		  MS_REMOUNT | MS_RDONLY, NULL) < 0) {
		tst_brkm(TBROK | TERRNO, cleanup,
			 "mount device:%s failed", device);
	}
	mount_flag = 1;
}
示例#24
0
文件: mknodat02.c 项目: AiprNick/ltp
static void setup(void)
{
	int i;
	const char *fs_type;

	if (tst_kvercmp(2, 6, 16) < 0) {
		tst_brkm(TCONF, NULL, "This test can only run on kernels "
			 "that are 2.6.16 and higher");
	}

	tst_require_root();

	tst_sig(NOFORK, DEF_HANDLER, cleanup);

	tst_tmpdir();

	fs_type = tst_dev_fs_type();
	device = tst_acquire_device(cleanup);

	if (!device)
		tst_brkm(TCONF, cleanup, "Failed to acquire device");

	tst_mkfs(cleanup, device, fs_type, NULL, NULL);

	TEST_PAUSE;

	/*
	 * mount a read-only file system for EROFS test
	 */
	SAFE_MKDIR(cleanup, MNT_POINT, DIR_MODE);
	if (mount(device, MNT_POINT, fs_type, MS_RDONLY, NULL) < 0) {
		tst_brkm(TBROK | TERRNO, cleanup,
			 "mount device:%s failed", device);
	}
	mount_flag = 1;
	dir_fd = SAFE_OPEN(cleanup, MNT_POINT, O_DIRECTORY);

	/*
	 * NOTE: the ELOOP test is written based on that the consecutive
	 * symlinks limits in kernel is hardwired to 40.
	 */
	SAFE_MKDIR(cleanup, "test_eloop", DIR_MODE);
	SAFE_SYMLINK(cleanup, "../test_eloop", "test_eloop/test_eloop");
	for (i = 0; i < 43; i++)
		strcat(elooppathname, ELOPFILE);
}
示例#25
0
文件: mknod07.c 项目: AbhiramiP/ltp
static void setup(void)
{
	int i;
	struct passwd *ltpuser;
	const char *fs_type;

	tst_require_root(NULL);

	tst_sig(NOFORK, DEF_HANDLER, cleanup);

	tst_tmpdir();

	fs_type = tst_dev_fs_type();
	device = tst_acquire_device(cleanup);

	if (!device)
		tst_brkm(TCONF, cleanup, "Failed to acquire device");

	tst_mkfs(cleanup, device, fs_type, NULL);

	TEST_PAUSE;

	/* mount a read-only file system for EROFS test */
	SAFE_MKDIR(cleanup, MNT_POINT, DIR_MODE);
	if (mount(device, MNT_POINT, fs_type, MS_RDONLY, NULL) < 0) {
		tst_brkm(TBROK | TERRNO, cleanup,
			 "mount device:%s failed", device);
	}
	mount_flag = 1;

	ltpuser = SAFE_GETPWNAM(cleanup, "nobody");
	SAFE_SETEUID(cleanup, ltpuser->pw_uid);

	SAFE_MKDIR(cleanup, DIR_TEMP, DIR_TEMP_MODE);

	/*
	 * NOTE: the ELOOP test is written based on that the consecutive
	 * symlinks limits in kernel is hardwired to 40.
	 */
	SAFE_MKDIR(cleanup, "test_eloop", DIR_MODE);
	SAFE_SYMLINK(cleanup, "../test_eloop", "test_eloop/test_eloop");
	for (i = 0; i < 43; i++)
		strcat(elooppathname, ELOPFILE);
}
示例#26
0
文件: linkat02.c 项目: AbhiramiP/ltp
static void setup(void)
{
	if ((tst_kvercmp(2, 6, 16)) < 0)
		tst_brkm(TCONF, NULL, "This test needs kernel 2.6.16 or newer");

	tst_require_root(NULL);

	tst_sig(NOFORK, DEF_HANDLER, cleanup);

	tst_tmpdir();

	fs_type = tst_dev_fs_type();
	device = tst_acquire_device(cleanup);

	if (!device)
		tst_brkm(TCONF, cleanup, "Failed to acquire device");

	TEST_PAUSE;

	ltpuser = SAFE_GETPWNAM(cleanup, "nobody");

	SAFE_TOUCH(cleanup, TEST_FILE, 0644, NULL);

	memset(nametoolong, 'a', PATH_MAX+1);

	SAFE_TOUCH(cleanup, TEST_EXIST, 0644, NULL);

	SAFE_SYMLINK(cleanup, TEST_ELOOP, "test_file_eloop2");
	SAFE_SYMLINK(cleanup, "test_file_eloop2", TEST_ELOOP);

	SAFE_MKDIR(cleanup, "./tmp", DIR_MODE);
	SAFE_TOUCH(cleanup, TEST_EACCES, 0666, NULL);

	tst_mkfs(cleanup, device, fs_type, NULL);
	SAFE_MKDIR(cleanup, "mntpoint", DIR_MODE);

	if (mount(device, "mntpoint", fs_type, 0, NULL) < 0) {
		tst_brkm(TBROK | TERRNO, cleanup,
			 "mount device:%s failed", device);
	}
	mount_flag = 1;

	max_hardlinks = tst_fs_fill_hardlinks(cleanup, "emlink_dir");
}
示例#27
0
文件: fchdir03.c 项目: sathnaga/ltp
void setup(void)
{
	struct passwd *pw;

	pw = SAFE_GETPWNAM("nobody");
	SAFE_SETEUID(pw->pw_uid);
	SAFE_MKDIR(DIRNAME, 0400);

	fd = SAFE_OPEN(DIRNAME, O_RDONLY);
}
示例#28
0
文件: quotactl02.c 项目: bsbrp/ltp
static void setup(void)
{
    SAFE_MKDIR(mntpoint, 0755);

    SAFE_MKFS(tst_device->dev, "xfs", NULL, NULL);

    SAFE_MOUNT(tst_device->dev, mntpoint, "xfs", 0, "usrquota");
    mount_flag = 1;

    test_id = geteuid();
}
示例#29
0
文件: link08.c 项目: JanyHuang/ltp
static void setup(void)
{
	int i;
	const char *fs_type;

	tst_require_root();

	tst_sig(NOFORK, DEF_HANDLER, cleanup);

	TEST_PAUSE;

	tst_tmpdir();

	fs_type = tst_dev_fs_type();
	device = tst_acquire_device(cleanup);

	if (!device)
		tst_brkm(TCONF, cleanup, "Failed to acquire device");

	SAFE_MKDIR(cleanup, TEST_FILE1, DIR_MODE);

	SAFE_MKDIR(cleanup, "test_eloop", DIR_MODE);
	SAFE_SYMLINK(cleanup, "../test_eloop", "test_eloop/test_eloop");
	for (i = 0; i < 43; i++)
		strcat(test_file4, "/test_eloop");

	tst_mkfs(cleanup, device, fs_type, NULL);
	SAFE_MKDIR(cleanup, MNT_POINT, DIR_MODE);
	if (mount(device, MNT_POINT, fs_type, 0, NULL) < 0) {
		tst_brkm(TBROK | TERRNO, cleanup,
			 "mount device:%s failed", device);
	}
	mount_flag = 1;

	SAFE_TOUCH(cleanup, TEST_FILE2, 0644, NULL);
	if (mount(device, MNT_POINT, fs_type,
		  MS_REMOUNT | MS_RDONLY, NULL) < 0) {
		tst_brkm(TBROK | TERRNO, cleanup,
			 "mount device:%s failed", device);
	}
}
示例#30
0
文件: rename11.c 项目: MohdVara/ltp
static void setup(void)
{
	int i;

	tst_sig(NOFORK, DEF_HANDLER, cleanup);

	tst_require_root(NULL);

	tst_tmpdir();

	TEST_EXP_ENOS(exp_enos);

	TEST_PAUSE;

	fs_type = tst_dev_fs_type();
	device = tst_acquire_device(cleanup);

	if (!device)
		tst_brkm(TCONF, cleanup, "Failed to obtain block device");

	tst_mkfs(cleanup, device, fs_type, NULL);

	SAFE_MKDIR(cleanup, MNTPOINT, 0755);
	if (mount(device, MNTPOINT, fs_type, 0, NULL) < 0) {
		tst_brkm(TBROK | TERRNO, cleanup,
			 "mount device:%s failed", device);
	}
	mount_flag = 1;
	SAFE_TOUCH(cleanup, TEST_EROFS, 0644, NULL);

	SAFE_MKDIR(cleanup, TEST_EMLINK, 0755);
	max_subdirs = tst_fs_fill_subdirs(cleanup, "emlink_dir");
	/*
	 * NOTE: the ELOOP test is written based on that the consecutive
	 * symlinks limits in kernel is hardwired to 40.
	 */
	SAFE_MKDIR(cleanup, "test_eloop", 0644);
	SAFE_SYMLINK(cleanup, "../test_eloop", "test_eloop/test_eloop");
	for (i = 0; i < 43; i++)
		strcat(elooppathname, ELOPFILE);
}