Commit 7203f542 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent b37023b6
......@@ -510,7 +510,9 @@ void _Mapping::remmap_blk(int64_t blk) {
if (!ok)
blkrev = TidHead;
mmap._remmapblk(blk, blkrev); // XXX err
error err = mmap._remmapblk(blk, blkrev);
if (err != nil)
panic(v(err)); // XXX
}
// unmap removes mapping memory from address space.
......@@ -558,27 +560,22 @@ tuple<os::File, error> WCFS::_open(const string &path, int flags) {
// mmap_zero_into_ro mmaps read-only zeros into [addr +size) so that region as all zeros.
// created mapping, even after it is accessed, does not consume memory.
static error _mmap_zero_into_ro(void *addr, size_t size);
static error mmap_zero_into_ro(void *addr, size_t size) {
error err = _mmap_zero_into_ro(addr, size);
if (err != nil)
err = fmt::errorf("mmap zero"); // XXX -> xerr::contextf?
return err;
}
static error _mmap_zero_into_ro(void *addr, size_t size) {
xerr::Contextf E("mmap zero");
// mmap /dev/zero with MAP_NORESERVE and MAP_SHARED
// this way the mapping will be able to be read, but no memory will be allocated to keep it.
os::File z;
error err;
tie(z, err) = os::open("/dev/zero");
if (err != nil)
return err;
return E(err);
defer([&]() {
z->close();
});
err = mm::map_into(addr, size, PROT_READ, MAP_SHARED | MAP_NORESERVE, z, 0);
if (err != nil)
return err;
return E(err);
return nil;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment