Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -271,3 +271,4 @@ a license to everyone to use it as detailed in LICENSE.)
* Vladimir Davidovich <[email protected]>
* Christophe Gragnic <[email protected]>
* Murphy McCauley <[email protected]>
* Anatoly Trosinenko <[email protected]>
5 changes: 1 addition & 4 deletions src/library_syscall.js
Original file line number Diff line number Diff line change
Expand Up @@ -838,11 +838,8 @@ var SyscallsLibrary = {
return FS.read(stream, {{{ heapAndOffset('HEAP8', 'buf') }}}, count, offset);
},
__syscall181: function(which, varargs) { // pwrite64
#if SYSCALL_DEBUG
Module.printErr('warning: untested syscall');
#endif
var stream = SYSCALLS.getStreamFromFD(), buf = SYSCALLS.get(), count = SYSCALLS.get(), zero = SYSCALLS.getZero(), offset = SYSCALLS.get64();
return FS.write(stream, {{{ heapAndOffset('HEAP8', 'buf') }}}, nbyte, offset);
return FS.write(stream, {{{ heapAndOffset('HEAP8', 'buf') }}}, count, offset);
},
__syscall183: function(which, varargs) { // getcwd
var buf = SYSCALLS.get(), size = SYSCALLS.get();
Expand Down
10 changes: 10 additions & 0 deletions tests/unistd/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,16 @@ int main() {
printf("errno: %d\n\n", errno);
errno = 0;

printf("pwrite to the middle of file: %d\n", pwrite(f, writeBuffer + 2, 3, 17));
printf("errno: %d\n", errno);
printf("seek: %d\n\n", lseek(f, 0, SEEK_CUR));
errno = 0;

printf("pwrite past end of file: %d\n", pwrite(f, writeBuffer, 5, 32));
printf("errno: %d\n", errno);
printf("seek: %d\n\n", lseek(f, 0, SEEK_CUR));
errno = 0;

int bytesRead;
printf("seek: %d\n", lseek(f, 0, SEEK_SET));
printf("read after write: %d\n", bytesRead = read(f, readBuffer, sizeof readBuffer));
Expand Down
12 changes: 10 additions & 2 deletions tests/unistd/io.out
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,15 @@ seek: 23
write after end of file: 8
errno: 0

pwrite to the middle of file: 3
errno: 0
seek: 31

pwrite past end of file: 5
errno: 0
seek: 31

seek: 0
read after write: 31
read after write: 37
errno: 0
final: wri4567890wri\0\0\0\0\0\0\0\0\0\0writeme\0
final: wri4567890wri\0\0\0\0ite\0\0\0writeme\0\0write