Commit 311f9ff6 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 71d54d36
......@@ -60,6 +60,7 @@ const Tid TidHead = -1ULL;
static string h(uint64_t v); // v -> 016x hex representation
#define h_(v) (h(v).c_str())
static error mmap_zero_into_ro(void *addr, size_t size);
static error mmap_into_ro(void *addr, size_t size, const os::File &f, off_t offset);
// XXX ok?
struct IContext {
......@@ -423,7 +424,7 @@ error Conn::resync(Tid at) {
mmap->mem_start + (headfsize - mmap->blk_start*f.blksize));
if (mem_unzero_stop - mem_unzero_start > 0) {
err = mm::map_into(mem_unzero_start, mem_unzero_stop-mem_unzero_start, PROT_READ, MAP_SHARED, f.headf, f.headfsize);
err = mmap_into_ro(mem_unzero_start, mem_unzero_stop-mem_unzero_start, f.headf, f.headfsize);
if (err != nil)
return err;
}
......@@ -494,7 +495,7 @@ error _Mapping::_remmapblk(int64_t blk, Tid at) {
}
// block is inside file - mmap file data
else {
err = mm::map_into(blkmem, 1*f->blksize, PROT_READ, MAP_SHARED, fsfile, blk*f->blksize);
err = mmap_into_ro(blkmem, 1*f->blksize, fsfile, blk*f->blksize);
if (err != nil)
return err;
}
......@@ -899,7 +900,7 @@ static string h(uint64_t v) {
return fmt::sprintf("%016lx", v);
}
// map_zero_ro mmaps read-only zeros into [addr +size) so that region as all zeros.
// mmap_zero_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) {
......@@ -924,3 +925,9 @@ static error _mmap_zero_into_ro(void *addr, size_t size) {
return err;
return nil;
}
// mmap_into_ro mmaps read-only fd[offset +size) into [addr +size).
// The mapping is created with MAP_SHARED.
static error mmap_into_ro(void *addr, size_t size, const os::File &f, off_t offset) {
return mm::map_into(addr, size, PROT_READ, MAP_SHARED, f, offset);
}
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