#include "file/mmap.h"
Public Member Functions | |
MMap (const Entry &entry, bool readwrite=false, bool preload=true, int64_t mapped_size=-1) | |
create a new memory-mapping to file in entry More... | |
~MMap () | |
std::string | name () const |
int64_t | size () const |
uint8_t * | address () |
const uint8_t * | address () const |
bool | is_read_write () const |
bool | changed () const |
Protected Member Functions | |
void | map () |
Protected Member Functions inherited from MR::File::Entry | |
Entry (const std::string &fname, int64_t offset=0) | |
Entry (const Entry &)=default | |
Entry (Entry &&) noexcept=default | |
Entry & | operator= (Entry &&E) noexcept |
Protected Attributes | |
int | fd |
uint8_t * | addr |
uint8_t * | first |
int64_t | msize |
time_t | mtime |
bool | readwrite |
Protected Attributes inherited from MR::File::Entry | |
std::string | name |
int64_t | start |
Friends | |
std::ostream & | operator<< (std::ostream &stream, const MMap &m) |
MR::File::MMap::MMap | ( | const Entry & | entry, |
bool | readwrite = false , |
||
bool | preload = true , |
||
int64_t | mapped_size = -1 |
||
) |
create a new memory-mapping to file in entry
map file in entry at the offset in entry. By default, the file will be mapped read-only. If readwrite is set to true, the file will be accessed with read-write permissions, but the mechanism used depends on whether the file is detected as residing on a local or a networked filesystem, and whether the filesystem is mounted with synchronous IO. If the filesystem is local and asynchronous, the file is memory-mapped as-is with read-write permissions. Otherwise, a write-back RAM buffer is allocated to store the contents of the file, and written back when the constructor is invoked.
By default, if the file is mapped using the delayed write-back mechanism, its contents will be preloaded into the RAM buffer. If the file has just been created, preload should be set to false
to prevent this, in which case the contents will set to zero.
By default, the whole file is mapped. If mapped_size is non-zero, then only the region of size mapped_size starting from the byte offset specified in entry will be mapped.
MR::File::MMap::~MMap | ( | ) |
bool MR::File::MMap::changed | ( | ) | const |
|
protected |
|
friend |
|
protected |
|
protected |
|
protected |