Module Name: src
Committed By: riastradh
Date: Sat Mar 28 16:17:25 UTC 2015
Modified Files:
src/tests/fs/vfs: t_io.c
Log Message:
Test that read fails with EFAULT even if O_SYNC|O_RSYNC are set.
To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/tests/fs/vfs/t_io.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/tests/fs/vfs/t_io.c
diff -u src/tests/fs/vfs/t_io.c:1.12 src/tests/fs/vfs/t_io.c:1.13
--- src/tests/fs/vfs/t_io.c:1.12 Sun Aug 4 11:02:02 2013
+++ src/tests/fs/vfs/t_io.c Sat Mar 28 16:17:25 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: t_io.c,v 1.12 2013/08/04 11:02:02 pooka Exp $ */
+/* $NetBSD: t_io.c,v 1.13 2015/03/28 16:17:25 riastradh Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -222,6 +222,30 @@ wrrd_after_unlink(const atf_tc_t *tc, co
FSTEST_EXIT();
}
+static void
+read_fault(const atf_tc_t *tc, const char *mp)
+{
+ char ch = 123;
+ int fd;
+
+ FSTEST_ENTER();
+ RL(fd = rump_sys_open("file", O_CREAT | O_RDWR, 0777));
+ ATF_REQUIRE_EQ(rump_sys_write(fd, &ch, 1), 1);
+ RL(rump_sys_close(fd));
+ RL(fd = rump_sys_open("file", O_RDONLY | O_SYNC | O_RSYNC));
+ if (FSTYPE_EXT2FS(tc) ||
+ FSTYPE_FFS(tc) ||
+ FSTYPE_FFSLOG(tc) ||
+ FSTYPE_LFS(tc) ||
+ FSTYPE_MSDOS(tc) ||
+ FSTYPE_P2K_FFS(tc) ||
+ FSTYPE_SYSVBFS(tc))
+ atf_tc_expect_fail("bad sync atime update code path");
+ ATF_REQUIRE_ERRNO(EFAULT, rump_sys_read(fd, NULL, 1) == -1);
+ RL(rump_sys_close(fd));
+ FSTEST_EXIT();
+}
+
ATF_TC_FSAPPLY(holywrite, "create a sparse file and fill hole");
ATF_TC_FSAPPLY(extendfile, "check that extending a file works");
ATF_TC_FSAPPLY(extendfile_append, "check that extending a file works "
@@ -232,6 +256,7 @@ ATF_TC_FSAPPLY(overwrite_trunc, "write 6
ATF_TC_FSAPPLY(shrinkfile, "shrink file");
ATF_TC_FSAPPLY(read_after_unlink, "contents can be read off disk after unlink");
ATF_TC_FSAPPLY(wrrd_after_unlink, "file can be written and read after unlink");
+ATF_TC_FSAPPLY(read_fault, "read at bad address must return EFAULT");
ATF_TP_ADD_TCS(tp)
{
@@ -245,6 +270,7 @@ ATF_TP_ADD_TCS(tp)
ATF_TP_FSAPPLY(shrinkfile);
ATF_TP_FSAPPLY(read_after_unlink);
ATF_TP_FSAPPLY(wrrd_after_unlink);
+ ATF_TP_FSAPPLY(read_fault);
return atf_no_error();
}