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) { 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) { 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) { 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) { 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) { 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) { 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) { 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 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 do_setup(int argc, char *argv[]) { if (!tst_test) tst_brk(TBROK, "No tests to run"); if (!tst_test->test && !tst_test->test_all) tst_brk(TBROK, "No test function speficied"); if (tst_test->test && tst_test->test_all) tst_brk(TBROK, "You can define either test() or test_all()"); if (tst_test->test && !tst_test->tcnt) tst_brk(TBROK, "Number of tests (tcnt) must not be > 0"); if (tst_test->test_all && tst_test->tcnt) tst_brk(TBROK, "You can't define tcnt for test_all()"); if (tst_test->needs_root && geteuid() != 0) tst_brk(TCONF, "Test needs to be run as root"); if (tst_test->min_kver) check_kver(); parse_opts(argc, argv); setup_ipc(); if (needs_tmpdir()) { tst_tmpdir(); tmpdir_created = 1; } if (tst_test->needs_device) { tdev.dev = tst_acquire_device(NULL); tdev.fs_type = tst_dev_fs_type(); if (!tdev.dev) tst_brk(TCONF, "Failed to acquire device"); tst_device = &tdev; } if (tst_test->resource_files) copy_resources(); main_pid = getpid(); if (tst_test->setup) tst_test->setup(); if (main_pid != getpid()) tst_brk(TBROK, "Runaway child in setup()!"); }
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) { 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) { 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) { 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"); }
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) { 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) { 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) { 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); }
static void setup(void) { int i; const char *fs_type; tst_require_root(NULL); tst_sig(NOFORK, DEF_HANDLER, cleanup); TEST_EXP_ENOS(exp_enos); 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"); memset(long_dir, 'a', PATH_MAX+1); SAFE_TOUCH(cleanup, TST_EEXIST, MODE, NULL); SAFE_TOUCH(cleanup, "tst_enotdir", MODE, NULL); SAFE_MKDIR(cleanup, "test_eloop", DIR_MODE); SAFE_SYMLINK(cleanup, "../test_eloop", "test_eloop/test_eloop"); for (i = 0; i < 43; i++) strcat(loop_dir, "/test_eloop"); tst_mkfs(cleanup, device, fs_type, NULL); 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; }
static void setup(void) { tst_sig(NOFORK, DEF_HANDLER, cleanup); tst_require_root(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); if (mkdir(mntpoint, DIR_MODE) < 0) { tst_brkm(TBROK, cleanup, "mkdir(%s, %#o) failed; " "errno = %d: %s", mntpoint, DIR_MODE, errno, strerror(errno)); } TEST_PAUSE; }
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); }
static void setup(void) { char *tmpdir; const char *fs_type; int i; 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 obtain block device"); TEST_PAUSE; SAFE_TOUCH(cleanup, TESTFILE, FILEMODE, NULL); SAFE_TOUCH(cleanup, TESTFILE2, FILEMODE, NULL); tmpdir = tst_get_tmpdir(); sprintf(absoldpath, "%s/%s", tmpdir, TESTFILE2); sprintf(absnewpath, "%s/%s", tmpdir, NEW_TESTFILE2); free(tmpdir); SAFE_MKDIR(cleanup, TESTDIR, DIRMODE); SAFE_TOUCH(cleanup, TESTFILE3, FILEMODE, NULL); SAFE_MKDIR(cleanup, NEW_TESTDIR, DIRMODE); olddirfd = SAFE_OPEN(cleanup, TESTDIR, O_DIRECTORY); newdirfd = SAFE_OPEN(cleanup, NEW_TESTDIR, O_DIRECTORY); filefd = SAFE_OPEN(cleanup, TESTFILE4, O_RDWR | O_CREAT, FILEMODE); /* * NOTE: the ELOOP test is written based on that the * consecutive symlinks limit in kernel is hardwired * to 40. */ SAFE_MKDIR(cleanup, "loopdir", DIRMODE); SAFE_SYMLINK(cleanup, "../loopdir", "loopdir/loopdir"); for (i = 0; i < 43; i++) strcat(looppathname, TESTDIR2); tst_mkfs(cleanup, device, fs_type, NULL, NULL); SAFE_MKDIR(cleanup, MNTPOINT, DIRMODE); 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, TESTFILE5, FILEMODE, NULL); if (mount(device, MNTPOINT, fs_type, MS_REMOUNT | MS_RDONLY, NULL) < 0) { tst_brkm(TBROK | TERRNO, cleanup, "mount device:%s failed", device); } SAFE_MKDIR(cleanup, TESTDIR3, DIRMODE); max_subdirs = tst_fs_fill_subdirs(cleanup, "testemlinkdir"); }