aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/library.js2
-rw-r--r--tests/fcntl-misc/src.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/src/library.js b/src/library.js
index 3597891e..f9cfe68f 100644
--- a/src/library.js
+++ b/src/library.js
@@ -1379,7 +1379,7 @@ LibraryManager.library = {
posix_fallocate: function(fd, offset, len) {
// int posix_fallocate(int fd, off_t offset, off_t len);
// http://pubs.opengroup.org/onlinepubs/009695399/functions/posix_fallocate.html
- if (!FS.streams[fd] || FS.streams[fd].link ||
+ if (!FS.streams[fd] || !FS.streams[fd].isWrite || FS.streams[fd].link ||
FS.streams[fd].isFolder || FS.streams[fd].isDevice) {
___setErrNo(ERRNO_CODES.EBADF);
return -1;
diff --git a/tests/fcntl-misc/src.c b/tests/fcntl-misc/src.c
index 73734969..7cdbbcd6 100644
--- a/tests/fcntl-misc/src.c
+++ b/tests/fcntl-misc/src.c
@@ -6,7 +6,7 @@
int main() {
struct stat s;
- int f = open("/test", O_RDONLY, 0777);
+ int f = open("/test", O_RDWR, 0777);
printf("posix_fadvise: %d\n", posix_fadvise(f, 3, 2, POSIX_FADV_DONTNEED));
printf("errno: %d\n", errno);