If you use MAP_PRIVATE, then after your process modifies the mapped
page, you have the data for sure. This includes calling read() over a
page that raises a SIGBUS -- the page is "modified" by this operation,
although the contents should hopefully be the correct file contents if
read() succeeds. Any subsequent change to the file, including
permission changes and data changes, won't affect the data you have in
memory.
If you do not modify the pages (and usually, for efficiency, you
wouldn't), then yes a change in file permissions can mean you can read
data one second and will get a SIGBUS later. You're not guaranteed to
get a SIGBUS, but you might get one -- it depends on whether the OS
decides to reclaim the page's memory temporarily in between.
If you want to do something like an Editor's "Load File" operation, then
you need to read the whole file. Either call read(), or call mmap() and
then modify every page by reading one byte from each page and writing
the same value back to the same place. read() is probably quicker, but
I've never checked.
-- Jamie
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/