Commit 6249dcd1 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 160e1e90
......@@ -239,7 +239,7 @@ void Conn::_pin1(SrvReq *req) {
// at=None means unpin to head/ . XXX -> C
// NOTE this does not check wrt virtmem already mapped blk as RW.
error _Mapping::_remmapblk(int64_t blk, Tid at) {
// XXX err context?
// XXX err context? blk #<blk> @<at>
_Mapping *mmap = this;
ASSERT(mmap->blk_start <= blk && blk < mmap->blk_stop());
......@@ -271,16 +271,22 @@ error _Mapping::_remmapblk(int64_t blk, Tid at) {
return err;
ASSERT(st.st_blksize == f->blksize); // FIXME assert
#if 0
// block is beyond file size - mmap with zeros (assumes head/f size ↑=)
// block is beyond file size - mmap with zeros - else access to memory
// after file.size will raise SIGBUS. (assumes head/f size ↑=)
if ((blk+1)*f->blksize > st.st_size) {
mm.map_zero_into_ro(blkmem); // XXX err
}
// block is inside file - mmap file data
else {
mm.map_into_ro(blkmem, fsfile.fd, blk*f->blksize); // XXX err
mm.map_into_ro(blkmem, fsfile.fd(), blk*f->blksize); // XXX err
err = mmap_into_ro(blkmem, f->blksize, fsfile, blk*f->blksize);
err = fsfile.mmapfix(blkmem, f->blksize, PROT_READ, MAP_SHARED, blk*f->blksize);
mmap(blkmem, f->blksize, PROT_READ, MAP_FIXED | MAP_SHARED,
fsfile.fd(), blk*f->blksize);
}
#endif
return nil;
}
......@@ -308,3 +314,14 @@ tuple<os::File, error> WCFS::_open(const string &path, int flags) {
string h(uint64_t v) {
return fmt::sprintf("%016x", v);
}
// map_into_ro memory-maps f.fd[offset +size) as read-only into [addr +size).
// The mapping is created with MAP_SHARED.
error mmap_into_ro(void *addr, size_t size, const File &f. off_t offset) {
void *addr2;
addr2 = mmap(blkmem, size, PROT_READ, MAP_FIXED | MAP_SHARED, f.fd(), offset);
// XXX -> err
// XXX assert addr2 == addr
}
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