-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmmap.cpp
27 lines (25 loc) · 830 Bytes
/
mmap.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include "lib.h"
#include "utils/timer.h"
namespace madfs {
extern "C" {
void* mmap(void* addr, size_t length, int prot, int flags, int fd,
off_t offset) {
if (auto file = get_file(fd)) {
void* ret =
file->mmap(addr, length, prot, flags, static_cast<size_t>(offset));
LOG_DEBUG("madfs::mmap(%p, %zu, %x, %x, %d, %ld) = %p", addr, length, prot,
flags, fd, offset, ret);
return ret;
} else {
void* ret = posix::mmap(addr, length, prot, flags, fd, offset);
LOG_DEBUG("posix::mmap(%p, %zu, %x, %x, %d, %ld) = %p", addr, length, prot,
flags, fd, offset, ret);
return ret;
}
}
void* mmap64(void* addr, size_t length, int prot, int flags, int fd,
off64_t offset) {
return mmap(addr, length, prot, flags, fd, offset);
}
}
} // namespace madfs