mortbopet / Ripes

A graphical processor simulator and assembly editor for the RISC-V ISA
https://ripes.me/
MIT License
2.52k stars 270 forks source link

Fix write syscall #296

Open JackWilli opened 1 year ago

JackWilli commented 1 year ago

The fdInUse function passed in O_WRONLY | O_RDWR as flags and then checked fileFlags[fd] & flags == flags. This is only true if all of the bits set in flags are also set in fileFlags[fd]. Since O_WRONLY | O_RDWR are mutually exclusive the fdInUse function always returns false in this case and the write syscall fails.

I fixed the expression and passed in an enum instead to make it more explicit about what we are testing for.