Skip to content

Commit

Permalink
fix: handle mmap offset
Browse files Browse the repository at this point in the history
  • Loading branch information
petersalomonsen committed Dec 23, 2019
1 parent 9de3bd4 commit e41d357
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -443,4 +443,5 @@ a license to everyone to use it as detailed in LICENSE.)
* John Granström <[email protected]>
* Clemens Backes <[email protected]> (copyright owned by Google, Inc.)
* Tibor Klajnscek <[email protected]>
* Benjamin Golinvaux <[email protected]>
* Benjamin Golinvaux <[email protected]>
* Peter Salomonsen <[email protected]>
10 changes: 5 additions & 5 deletions src/library_syscall.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ var SyscallsLibrary = {
{{{ makeSetValue('buf', C_STRUCTS.stat.st_ino, 'stat.ino', 'i64') }}};
return 0;
},
doMsync: function(addr, stream, len, flags) {
doMsync: function(addr, stream, len, flags, offset) {
var buffer = new Uint8Array(HEAPU8.subarray(addr, addr + len));
FS.msync(stream, buffer, 0, len, flags);
FS.msync(stream, buffer, offset, len, flags);
},
doMkdir: function(path, mode) {
// remove a trailing slash, if one - /a/b/ has basename of '', but
Expand Down Expand Up @@ -254,7 +254,7 @@ var SyscallsLibrary = {
ptr = res.ptr;
allocated = res.allocated;
}
SYSCALLS.mappings[ptr] = { malloc: ptr, len: len, allocated: allocated, fd: fd, flags: flags };
SYSCALLS.mappings[ptr] = { malloc: ptr, len: len, allocated: allocated, fd: fd, flags: flags, offset: off };
return ptr;
},

Expand All @@ -272,7 +272,7 @@ var SyscallsLibrary = {
if (!info) return 0;
if (len === info.len) {
var stream = FS.getStream(info.fd);
SYSCALLS.doMsync(addr, stream, len, info.flags);
SYSCALLS.doMsync(addr, stream, len, info.flags, info.offset);
FS.munmap(stream);
SYSCALLS.mappings[addr] = null;
if (info.allocated) {
Expand Down Expand Up @@ -855,7 +855,7 @@ var SyscallsLibrary = {
var addr = SYSCALLS.get(), len = SYSCALLS.get(), flags = SYSCALLS.get();
var info = SYSCALLS.mappings[addr];
if (!info) return 0;
SYSCALLS.doMsync(addr, FS.getStream(info.fd), len, info.flags);
SYSCALLS.doMsync(addr, FS.getStream(info.fd), len, info.flags, 0);
return 0;
},
__syscall147__deps: ['$PROCINFO'],
Expand Down

0 comments on commit e41d357

Please sign in to comment.