diff options
author | Dhruva Krishnamurthy <dhruvakm@gmail.com> | 2020-11-23 10:14:00 -0800 |
---|---|---|
committer | Dhruva Krishnamurthy <dhruvakm@gmail.com> | 2020-12-27 12:27:21 -0800 |
commit | a9f57a8919f264fa184320d1f5c3ed7a35b7576a (patch) | |
tree | 45bd5df906bc7abc57aa71945a2ebacb44e16c95 | |
parent | fe41e5823986aff01054b7db4b869b2896ea4c30 (diff) | |
download | libgit2-a9f57a8919f264fa184320d1f5c3ed7a35b7576a.tar.gz |
Remove broken support for write in emulated mmap
* Emulated mmap based write without pagefault handling is not
possible since IO happens outside of call to mmap and data is
written to mapped memory
* Potential emulation using userfaultfd() might be possible
-rw-r--r-- | src/posix.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/posix.c b/src/posix.c index 9cd96d2c8..debd8d2c8 100644 --- a/src/posix.c +++ b/src/posix.c @@ -240,14 +240,15 @@ int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, off64_t offset { GIT_MMAP_VALIDATE(out, len, prot, flags); - out->data = NULL; - out->len = 0; - - if ((prot & GIT_PROT_WRITE) && ((flags & GIT_MAP_TYPE) == GIT_MAP_SHARED)) { - git_error_set(GIT_ERROR_OS, "trying to map shared-writeable"); + /* writes cannot be emulated without handling pagefaults since write happens by + * writing to mapped memory */ + if (prot & GIT_PROT_WRITE) { + git_error_set(GIT_ERROR_OS, "trying to map %s-writeable", + ((flags & GIT_MAP_TYPE) == GIT_MAP_SHARED) ? "shared": "private"); return -1; } + out->len = 0; out->data = git__malloc(len); GIT_ERROR_CHECK_ALLOC(out->data); |