From 506f2f556e2ad09b40980e2e578ca5039850b4ca Mon Sep 17 00:00:00 2001 From: Andrew Jeffery Date: Tue, 27 Mar 2018 12:13:25 +1030 Subject: test: vpnor: Use MAP_SHARED for read-only file memory map It's not well defined whether a private mapping of a resource that is MAP_SHARED on a separate file descriptor will see the updates done via the shared mapping, though under Linux if the private mapping is not written then we can expect updates from the shared mapping to propagate (copy-on-write). However, we get a concrete guarantee of the desired behaviour (observing the effects of the write) if we use MAP_SHARED. Change-Id: If6a053209a979ee5b96ed09c60fbbd9bdb060a32 Signed-off-by: Andrew Jeffery --- vpnor/test/write_rw.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'vpnor/test/write_rw.cpp') diff --git a/vpnor/test/write_rw.cpp b/vpnor/test/write_rw.cpp index 1ee5c6c..1c4bd38 100644 --- a/vpnor/test/write_rw.cpp +++ b/vpnor/test/write_rw.cpp @@ -47,7 +47,7 @@ int main(void) rc = write_flash(ctx, 0x1000, src, sizeof(src)); assert(rc == 0); fd = open((root.rw() / "TEST1").c_str(), O_RDONLY); - map = mmap(NULL, sizeof(src), PROT_READ, MAP_PRIVATE, fd, 0); + map = mmap(NULL, sizeof(src), PROT_READ, MAP_SHARED, fd, 0); assert(map != MAP_FAILED); rc = memcmp(src, map, sizeof(src)); assert(rc == 0); -- cgit v1.2.1