static void rename_dotdot(const atf_tc_t *tc, const char *mp) { if (FSTYPE_RUMPFS(tc)) atf_tc_skip("rename not supported by file system"); USES_DIRS; if (rump_sys_chdir(mp) == -1) atf_tc_fail_errno("chdir mountpoint"); if (rump_sys_mkdir("dir1", 0777) == -1) atf_tc_fail_errno("mkdir 1"); if (rump_sys_mkdir("dir2", 0777) == -1) atf_tc_fail_errno("mkdir 2"); if (rump_sys_rename("dir1", "dir1/..") != -1 || errno != EINVAL) atf_tc_fail_errno("self-dotdot to"); if (rump_sys_rename("dir1/..", "sometarget") != -1 || errno != EINVAL) atf_tc_fail_errno("self-dotdot from"); if (rump_sys_rename("dir1", "dir2/..") != -1 || errno != EINVAL) atf_tc_fail("other-dotdot"); rump_sys_chdir("/"); }
static void dir_rmdirdotdot(const atf_tc_t *tc, const char *mp) { char pb[MAXPATHLEN]; int xerrno; USES_DIRS; FSTEST_ENTER(); RL(rump_sys_mkdir("test", 0777)); RL(rump_sys_chdir("test")); RL(rump_sys_mkdir("subtest", 0777)); RL(rump_sys_chdir("subtest")); md(pb, mp, "test/subtest"); RL(rump_sys_rmdir(pb)); md(pb, mp, "test"); RL(rump_sys_rmdir(pb)); if (FSTYPE_NFS(tc)) xerrno = ESTALE; else xerrno = ENOENT; ATF_REQUIRE_ERRNO(xerrno, rump_sys_chdir("..") == -1); FSTEST_EXIT(); }
static void * wrkwrkwrk(void *unused) { int fd, fail; fail = 0; rump_sys_chdir(FSTEST_MNTNAME); while (!quit) { fd = rump_sys_open("file", O_RDWR | O_CREAT); if (fd == -1) { if (errno == EACCES) { fail++; break; } } rump_sys_close(fd); if (rump_sys_unlink("file") == -1) { if (errno == EACCES) { fail++; break; } } } rump_sys_chdir("/"); quit = 1; return fail ? wrkwrkwrk : NULL; }
static void symlink_root(const atf_tc_t *tc, const char *mp) { USES_SYMLINKS; RL(rump_sys_chdir(mp)); RL(rump_sys_symlink("/", "foo")); RL(rump_sys_chdir("foo")); }
static void symlink_zerolen(const atf_tc_t *tc, const char *mp) { USES_SYMLINKS; RL(rump_sys_chdir(mp)); RL(rump_sys_symlink("", "afile")); RL(rump_sys_chdir("/")); }
static void rename_nametoolong(const atf_tc_t *tc, const char *mp) { char *name; int res, fd; long val; size_t len; if (FSTYPE_RUMPFS(tc)) atf_tc_skip("rename not supported by file system"); if (rump_sys_chdir(mp) == -1) atf_tc_fail_errno("chdir mountpoint"); val = rump_sys_pathconf(".", _PC_NAME_MAX); if (val == -1) atf_tc_fail_errno("pathconf"); len = val + 1; name = malloc(len+1); if (name == NULL) atf_tc_fail_errno("malloc"); memset(name, 'a', len); *(name+len) = '\0'; fd = rump_sys_open("dummy", O_RDWR|O_CREAT, 0666); if (fd == -1) atf_tc_fail_errno("open"); if (rump_sys_close(fd) == -1) atf_tc_fail_errno("close"); val = rump_sys_pathconf(".", _PC_NO_TRUNC); if (val == -1) atf_tc_fail_errno("pathconf"); res = rump_sys_rename("dummy", name); if (val != 0 && (res != -1 || errno != ENAMETOOLONG)) atf_tc_fail_errno("rename"); if (val == 0 && rump_sys_unlink(name) == -1) atf_tc_fail_errno("unlink"); free(name); rump_sys_chdir("/"); }
static void create_exist(const atf_tc_t *tc, const char *mp) { const char *name = "hoge"; int fd; RL(rump_sys_chdir(mp)); RL(fd = rump_sys_open(name, O_RDWR|O_CREAT|O_EXCL, 0666)); RL(rump_sys_close(fd)); RL(rump_sys_unlink(name)); RL(fd = rump_sys_open(name, O_RDWR|O_CREAT, 0666)); RL(rump_sys_close(fd)); RL(fd = rump_sys_open(name, O_RDWR|O_CREAT, 0666)); RL(rump_sys_close(fd)); ATF_REQUIRE_ERRNO(EEXIST, (fd = rump_sys_open(name, O_RDWR|O_CREAT|O_EXCL, 0666))); RL(rump_sys_unlink(name)); RL(rump_sys_chdir("/")); }
static void create_nametoolong(const atf_tc_t *tc, const char *mp) { char *name; int fd; long val; size_t len; if (rump_sys_chdir(mp) == -1) atf_tc_fail_errno("chdir mountpoint"); val = rump_sys_pathconf(".", _PC_NAME_MAX); if (val == -1) atf_tc_fail_errno("pathconf"); len = val + 1; name = malloc(len+1); if (name == NULL) atf_tc_fail_errno("malloc"); memset(name, 'a', len); *(name+len) = '\0'; val = rump_sys_pathconf(".", _PC_NO_TRUNC); if (val == -1) atf_tc_fail_errno("pathconf"); fd = rump_sys_open(name, O_RDWR|O_CREAT, 0666); if (val != 0 && (fd != -1 || errno != ENAMETOOLONG)) atf_tc_fail_errno("open"); if (val == 0 && rump_sys_close(fd) == -1) atf_tc_fail_errno("close"); if (val == 0 && rump_sys_unlink(name) == -1) atf_tc_fail_errno("unlink"); free(name); rump_sys_chdir("/"); }
static void otrunc_mtime_update(const atf_tc_t *tc, const char *path) { time_t last_ts = 0; int res; /* atf_tc_expect_fail("PR kern/51762"); */ res = rump_sys_chdir(path); if (res == -1) atf_tc_fail("chdir failed"); for (int i = 0; i < 5; i++) { time_t l = lock_it(); printf("last lock: %ld\n", (long)l); ATF_REQUIRE_MSG(i == 0 || l > last_ts, "iteration %d: lock time did not increase, old time %lu, " "new time %lu", i, (unsigned long)last_ts, (unsigned long)l); last_ts = l; sleep(2); } rump_sys_chdir("/"); }
/* * Test creating a symlink whose length is "len" bytes, not including * the terminating NUL. */ static void symlink_len(const atf_tc_t *tc, const char *mp, size_t len) { char *buf; int r; USES_SYMLINKS; RL(rump_sys_chdir(mp)); buf = malloc(len + 1); ATF_REQUIRE(buf); memset(buf, 'a', len); buf[len] = '\0'; r = rump_sys_symlink(buf, "afile"); if (r == -1) { ATF_REQUIRE_ERRNO(ENAMETOOLONG, r); } else { RL(rump_sys_unlink("afile")); } free(buf); RL(rump_sys_chdir("/")); }
static int precall(struct ukfs *ukfs, struct lwp **curlwp) { /* save previous. ensure start from pristine context */ *curlwp = rump_pub_lwproc_curlwp(); if (*curlwp) rump_pub_lwproc_switch(ukfs->ukfs_lwp); rump_pub_lwproc_rfork(RUMP_RFCFDG); if (rump_sys_chroot(ukfs->ukfs_mountpath) == -1) return errno; if (rump_sys_chdir(ukfs->ukfs_cwd) == -1) return errno; return 0; }
static void rename_reg_nodir(const atf_tc_t *tc, const char *mp) { bool haslinks; struct stat sb; ino_t f1ino, f2ino; if (FSTYPE_RUMPFS(tc)) atf_tc_skip("rename not supported by file system"); if (rump_sys_chdir(mp) == -1) atf_tc_fail_errno("chdir mountpoint"); if (FSTYPE_MSDOS(tc) || FSTYPE_SYSVBFS(tc)) haslinks = false; else haslinks = true; if (rump_sys_mknod("file1", S_IFREG | 0777, -1) == -1) atf_tc_fail_errno("create file"); if (rump_sys_mknod("file2", S_IFREG | 0777, -1) == -1) atf_tc_fail_errno("create file"); if (rump_sys_stat("file1", &sb) == -1) atf_tc_fail_errno("stat"); f1ino = sb.st_ino; if (haslinks) { if (rump_sys_link("file1", "file_link") == -1) atf_tc_fail_errno("link"); if (rump_sys_stat("file_link", &sb) == -1) atf_tc_fail_errno("stat"); ATF_REQUIRE_EQ(sb.st_ino, f1ino); ATF_REQUIRE_EQ(sb.st_nlink, 2); } if (rump_sys_stat("file2", &sb) == -1) atf_tc_fail_errno("stat"); f2ino = sb.st_ino; if (rump_sys_rename("file1", "file3") == -1) atf_tc_fail_errno("rename 1"); if (rump_sys_stat("file3", &sb) == -1) atf_tc_fail_errno("stat 1"); if (haslinks) { ATF_REQUIRE_EQ(sb.st_ino, f1ino); } if (rump_sys_stat("file1", &sb) != -1 || errno != ENOENT) atf_tc_fail_errno("source 1"); if (rump_sys_rename("file3", "file2") == -1) atf_tc_fail_errno("rename 2"); if (rump_sys_stat("file2", &sb) == -1) atf_tc_fail_errno("stat 2"); if (haslinks) { ATF_REQUIRE_EQ(sb.st_ino, f1ino); } if (rump_sys_stat("file3", &sb) != -1 || errno != ENOENT) atf_tc_fail_errno("source 2"); if (haslinks) { if (rump_sys_rename("file2", "file_link") == -1) atf_tc_fail_errno("rename hardlink"); if (rump_sys_stat("file2", &sb) != -1 || errno != ENOENT) atf_tc_fail_errno("source 3"); if (rump_sys_stat("file_link", &sb) == -1) atf_tc_fail_errno("stat 2"); ATF_REQUIRE_EQ(sb.st_ino, f1ino); ATF_REQUIRE_EQ(sb.st_nlink, 1); } rump_sys_chdir("/"); }