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; }
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; }
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; }
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; }
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; }
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; }
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; }
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; }
static void setup(void) { char nobody_uid[] = "nobody"; struct passwd *ltpuser; tst_sig(FORK, DEF_HANDLER, cleanup); tst_require_root(NULL); tst_mkfs(NULL, device, fstype, NULL); ltpuser = getpwnam(nobody_uid); if (seteuid(ltpuser->pw_uid) == -1) { tst_brkm(TBROK, cleanup, "seteuid() failed to change euid to %d " "errno = %d : %s", ltpuser->pw_uid, TEST_ERRNO, strerror(TEST_ERRNO)); } tst_tmpdir(); if (mkdir(mntpoint, DIR_MODE)) { tst_brkm(TBROK, cleanup, "mkdir(%s, %#o) failed; " "errno = %d: %s", mntpoint, DIR_MODE, errno, strerror(errno)); } TEST_EXP_ENOS(exp_enos); TEST_PAUSE; return; }
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; }
void safe_mkfs(const int lineno, const char *fname, const char *dev, const char *fs_type, const char *const fs_opts[], const char *extra_opt) { /* ignore for now, will fix once all tst_mkfs() users are converted */ (void)lineno; (void)fname; tst_mkfs(NULL, dev, fs_type, fs_opts, extra_opt); }
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); }
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); }
static void setup(void) { int fd; tst_require_root(NULL); check_acct_in_kernel(); tst_tmpdir(); ltpuser = SAFE_GETPWNAM(cleanup, "nobody"); fd = SAFE_CREAT(cleanup, TEST_FILE5, 0777); SAFE_CLOSE(cleanup, fd); if (acct(TEST_FILE5) == -1) tst_brkm(TBROK | TERRNO, cleanup, "acct failed unexpectedly"); /* turn off acct, so we are in a known state */ if (acct(NULL) == -1) 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 */ 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) < 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", fs_type, MS_REMOUNT | MS_RDONLY, NULL) < 0) { tst_brkm(TBROK | TERRNO, cleanup, "mount device:%s failed", device); } }
static void setup(void) { struct passwd *ltpuser; 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 obtain block device"); SAFE_TOUCH(cleanup, TESTFILE1, FILE_MODE, NULL); ltpuser = SAFE_GETPWNAM(cleanup, LTPUSER1); SAFE_CHOWN(cleanup, TESTFILE1, ltpuser->pw_uid, ltpuser->pw_gid); SAFE_TOUCH(cleanup, TESTFILE2, FILE_MODE, NULL); ltpuser = SAFE_GETPWNAM(cleanup, LTPUSER2); SAFE_CHOWN(cleanup, TESTFILE2, ltpuser->pw_uid, ltpuser->pw_gid); tst_mkfs(cleanup, device, fs_type, 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); } mount_flag = 1; SAFE_TOUCH(cleanup, TESTFILE3, FILE_MODE, NULL); ltpuser = SAFE_GETPWNAM(cleanup, LTPUSER1); SAFE_CHOWN(cleanup, TESTFILE3, ltpuser->pw_uid, ltpuser->pw_gid); if (mount(device, MNTPOINT, fs_type, MS_REMOUNT | MS_RDONLY, NULL) == -1) { tst_brkm(TBROK | TERRNO, cleanup, "mount device:%s failed", device); } ltpuser = SAFE_GETPWNAM(cleanup, LTPUSER1); SAFE_SETEUID(cleanup, ltpuser->pw_uid); }
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); }
static void setup(void) { tst_sig(FORK, DEF_HANDLER, cleanup); tst_require_root(NULL); tst_mkfs(NULL, device, fstype, NULL); tst_tmpdir(); if (mkdir(mntpoint, DIR_MODE) == -1) tst_brkm(TBROK | TERRNO, cleanup, "mkdir(%s, %#o) failed", mntpoint, DIR_MODE); TEST_EXP_ENOS(exp_enos); TEST_PAUSE; }
static void setup(void) { tst_require_root(NULL); TEST_PAUSE; tst_tmpdir(); SAFE_MKDIR(cleanup, mntpoint, 0755); tst_mkfs(NULL, block_dev, "xfs", NULL); if (mount(block_dev, mntpoint, "xfs", 0, "uquota") < 0) tst_brkm(TFAIL | TERRNO, NULL, "mount(2) fail"); }
void setup(void) { int i; int fd; tst_require_root(NULL); tst_mkfs(NULL, device, fstype, NULL); tst_sig(FORK, DEF_HANDLER, cleanup); ltpuser = getpwnam("nobody"); if (ltpuser == NULL) tst_brkm(TBROK | TERRNO, NULL, "getpwnam(\"nobody\") failed"); if (seteuid(ltpuser->pw_uid) == -1) tst_brkm(TBROK | TERRNO, NULL, "seteuid(%d) failed", ltpuser->pw_uid); TEST_PAUSE; tst_tmpdir(); bad_addr = mmap(0, 1, PROT_NONE, MAP_PRIVATE_EXCEPT_UCLINUX | MAP_ANONYMOUS, 0, 0); if (bad_addr == MAP_FAILED) tst_brkm(TBROK | TERRNO, cleanup, "mmap failed"); test_cases[3].pathname = bad_addr; SAFE_SYMLINK(cleanup, "test_eloop1", "test_eloop2"); SAFE_SYMLINK(cleanup, "test_eloop2", "test_eloop1"); SAFE_SETEUID(cleanup, 0); SAFE_MKDIR(cleanup, "mntpoint", DIR_MODE); if (mount(device, "mntpoint", fstype, MS_RDONLY, NULL) < 0) { tst_brkm(TBROK | TERRNO, cleanup, "mount device:%s failed", device); } mount_flag = 1; SAFE_SETEUID(cleanup, ltpuser->pw_uid); for (i = 0; i < TST_TOTAL; i++) if (test_cases[i].setupfunc != NULL) test_cases[i].setupfunc(); }
static void setup(void) { char path[PATH_MAX]; struct stat file_stat; 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); SAFE_MOUNT(cleanup, device, mntpoint, fs_type, 0, NULL); TST_RESOURCE_COPY(cleanup, "mount03_setuid_test", path_name); snprintf(file, PATH_MAX, "%smount03_setuid_test", path_name); SAFE_STAT(cleanup, file, &file_stat); if (file_stat.st_mode != SUID_MODE && chmod(file, SUID_MODE) < 0) tst_brkm(TBROK, cleanup, "setuid for setuid_test failed"); SAFE_UMOUNT(cleanup, mntpoint); TEST_PAUSE; }
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); }
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"); }
/* * void * setup(void) - performs all ONE TIME setup for this test. * Exit the test program on receipt of unexpected signals. * Create a temporary directory and change directory to it. * Invoke iividual test setup functions according to the order * set in struct. definition. */ void setup(void) { int i; tst_sig(FORK, DEF_HANDLER, cleanup); test_home = get_current_dir_name(); tst_require_root(NULL); TEST_PAUSE; tst_tmpdir(); tst_mkfs(NULL, device, fstype, NULL); SAFE_MKDIR(cleanup, MNT_POINT, DIR_MODE); /* * mount a read-only file system for test EROFS */ if (mount(device, MNT_POINT, fstype, MS_RDONLY, NULL) < 0) { tst_brkm(TBROK | TERRNO, cleanup, "mount device:%s failed", device); } mount_flag = 1; bad_addr = mmap(0, 1, PROT_NONE, MAP_PRIVATE_EXCEPT_UCLINUX | MAP_ANONYMOUS, 0, 0); if (bad_addr == MAP_FAILED) tst_brkm(TBROK | TERRNO, cleanup, "mmap failed"); test_cases[3].pathname = bad_addr; for (i = 0; i < TST_TOTAL; i++) if (test_cases[i].setupfunc != NULL) test_cases[i].setupfunc(); /* * create two symbolic links who point to each other for * test ELOOP. */ SAFE_SYMLINK(cleanup, "test_file4", "test_file5"); SAFE_SYMLINK(cleanup, "test_file5", "test_file4"); }
static void setup(void) { struct statvfs fs; srand(getpid()); tst_tmpdir(); SAFE_MKDIR(tst_rmdir, MOUNT_DIR, 0777); TST_CHECKPOINT_INIT(tst_rmdir); if (statvfs(".", &fs) == -1) tst_brkm(TFAIL | TERRNO, tst_rmdir, "statvfs failed"); if ((fs.f_flag & MS_MANDLOCK)) return; tst_resm(TINFO, "TMPDIR does not support mandatory locks"); fs_type = tst_dev_fs_type(); device = tst_acquire_device(cleanup); if (!device) tst_brkm(TCONF, cleanup, "Failed to obtain block device"); /* the kernel returns EPERM when CONFIG_MANDATORY_FILE_LOCKING is not * supported - to avoid false negatives, mount the fs first without * flags and then remount it as MS_MANDLOCK */ tst_mkfs(cleanup, device, fs_type, NULL, NULL); SAFE_MOUNT(cleanup, device, MOUNT_DIR, fs_type, 0, NULL); mount_flag = 1; if (mount(NULL, MOUNT_DIR, NULL, MS_REMOUNT|MS_MANDLOCK, NULL) == -1) { if (errno == EPERM) { tst_brkm(TCONF, cleanup, "Mandatory locking (likely) " "not supported by this system"); } else { tst_brkm(TBROK | TERRNO, cleanup, "Remount with MS_MANDLOCK failed"); } } }
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, MNTPOINT, DIR_MODE); TEST_PAUSE; }
static void setup(void) { tst_sig(FORK, DEF_HANDLER, cleanup); tst_require_root(NULL); tst_mkfs(NULL, device, fstype, NULL); tst_tmpdir(); if (mkdir(mntpoint, DIR_MODE)) { tst_brkm(TBROK, cleanup, "mkdir(%s, %#o) failed; " "errno = %d: %s", mntpoint, DIR_MODE, errno, strerror(errno)); } TEST_EXP_ENOS(exp_enos); TEST_PAUSE; }
static void setup(void) { const char *mount_flags[] = {"noatime", "relatime", NULL}; TEST_PAUSE; tst_sig(FORK, DEF_HANDLER, cleanup); tst_tmpdir(); SAFE_MKDIR(cleanup, MNTPOINT, DIR_MODE); if (tst_path_has_mnt_flags(cleanup, NULL, mount_flags)) { const char *fs_type; if ((tst_kvercmp(2, 6, 30)) < 0) { tst_resm(TCONF, "MS_STRICTATIME flags for mount(2) needs kernel 2.6.30 " "or higher"); skip_noatime = 1; return; } fs_type = tst_dev_fs_type(); device = tst_acquire_device(cleanup); if (!device) { tst_resm(TINFO, "Failed to obtain block device"); skip_noatime = 1; goto end; } tst_mkfs(cleanup, device, fs_type, NULL, NULL); SAFE_MOUNT(cleanup, device, MNTPOINT, fs_type, MS_STRICTATIME, NULL); mount_flag = 1; } end: SAFE_FILE_PRINTF(cleanup, TEST_FILE, TEST_FILE); }
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); } }
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); }
void setup(void) { tst_require_root(); tst_sig(NOFORK, DEF_HANDLER, cleanup); tst_tmpdir(); SAFE_MKDIR(cleanup, mntpoint_src, DIR_MODE); SAFE_MKDIR(cleanup, mntpoint_des, DIR_MODE); if (dflag) { tst_mkfs(NULL, device, fstype, NULL, NULL); SAFE_MOUNT(cleanup, device, mntpoint_src, fstype, 0, NULL); } SAFE_FILE_PRINTF(cleanup, file_src, "TEST FILE"); TEST_PAUSE; }