libc: track O_ACCMODE flags from open

Fix #2457
This commit is contained in:
Emery Hemingway 2017-06-24 16:42:30 -05:00 committed by Christian Helmuth
parent 87c19cb11a
commit c5c9d71df3

View File

@ -230,7 +230,7 @@ Libc::File_descriptor *Libc::Vfs_plugin::open(char const *path, int flags,
return nullptr;
}
fd->flags = flags & (O_NONBLOCK|O_APPEND);
fd->flags = flags & (O_ACCMODE|O_NONBLOCK|O_APPEND);
if ((flags & O_TRUNC) && (ftruncate(fd, 0) == -1)) {
errno = EINVAL; /* XXX which error code fits best ? */