| 262 | } |
| 263 | |
| 264 | long SysWrite(regs64_t* r){ |
| 265 | process_t* proc = Scheduler::GetCurrentProcess(); |
| 266 | |
| 267 | if(SC_ARG0(r) > proc->fileDescriptors.get_length()){ |
| 268 | Log::Warning("Invalid File Descriptor: %d", SC_ARG0(r)); |
| 269 | return -EBADF; |
| 270 | } |
| 271 | fs_fd_t* handle = proc->fileDescriptors[SC_ARG0(r)]; |
| 272 | if(!handle){ |
| 273 | Log::Warning("Invalid File Descriptor: %d", SC_ARG0(r)); |
| 274 | return -EBADF; |
| 275 | } |
| 276 | |
| 277 | uint8_t* buffer = (uint8_t*)SC_ARG1(r); |
| 278 | uint64_t count = SC_ARG2(r); |
| 279 | |
| 280 | if(!Memory::CheckUsermodePointer(SC_ARG1(r), count, proc->addressSpace)){ |
| 281 | Log::Warning("Invalid Memory Buffer: %x", SC_ARG1(r)); |
| 282 | return -EFAULT; |
| 283 | } |
| 284 | |
| 285 | ssize_t ret = fs::Write(handle, SC_ARG2(r), buffer); |
| 286 | return ret; |
| 287 | } |
| 288 | |
| 289 | /* |
| 290 | * SysOpen (path, flags) - Opens file at specified path with flags |
nothing calls this directly
no test coverage detected