Skip to content

Commit a9f57a8

Browse files
committed
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
1 parent fe41e58 commit a9f57a8

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/posix.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,14 +240,15 @@ int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, off64_t offset
240240
{
241241
GIT_MMAP_VALIDATE(out, len, prot, flags);
242242

243-
out->data = NULL;
244-
out->len = 0;
245-
246-
if ((prot & GIT_PROT_WRITE) && ((flags & GIT_MAP_TYPE) == GIT_MAP_SHARED)) {
247-
git_error_set(GIT_ERROR_OS, "trying to map shared-writeable");
243+
/* writes cannot be emulated without handling pagefaults since write happens by
244+
* writing to mapped memory */
245+
if (prot & GIT_PROT_WRITE) {
246+
git_error_set(GIT_ERROR_OS, "trying to map %s-writeable",
247+
((flags & GIT_MAP_TYPE) == GIT_MAP_SHARED) ? "shared": "private");
248248
return -1;
249249
}
250250

251+
out->len = 0;
251252
out->data = git__malloc(len);
252253
GIT_ERROR_CHECK_ALLOC(out->data);
253254

0 commit comments

Comments
 (0)