| 607 | } |
| 608 | |
| 609 | long SysLSeek(regs64_t* r){ |
| 610 | long ret = 0; |
| 611 | int fd = SC_ARG0(r); |
| 612 | |
| 613 | if(fd >= static_cast<int>(Scheduler::GetCurrentProcess()->fileDescriptors.get_length()) || !Scheduler::GetCurrentProcess()->fileDescriptors[fd]){ |
| 614 | Log::Warning("sys_lseek: Invalid File Descriptor, %d", fd); |
| 615 | return -EINVAL; |
| 616 | } |
| 617 | |
| 618 | switch(SC_ARG2(r)){ |
| 619 | case 0: // SEEK_SET |
| 620 | ret = Scheduler::GetCurrentProcess()->fileDescriptors[fd]->pos = SC_ARG1(r); |
| 621 | return ret; |
| 622 | break; |
| 623 | case 1: // SEEK_CUR |
| 624 | ret = Scheduler::GetCurrentProcess()->fileDescriptors[fd]->pos; |
| 625 | return ret; |
| 626 | break; |
| 627 | case 2: // SEEK_END |
| 628 | ret = Scheduler::GetCurrentProcess()->fileDescriptors[fd]->pos = Scheduler::GetCurrentProcess()->fileDescriptors[fd]->node->size; |
| 629 | return ret; |
| 630 | break; |
| 631 | default: |
| 632 | Log::Info("Invalid seek: %d, mode: %d", fd, SC_ARG2(r)); |
| 633 | return -EINVAL; // Invalid seek mode |
| 634 | break; |
| 635 | } |
| 636 | |
| 637 | return ret; |
| 638 | } |
| 639 | |
| 640 | long SysGetPID(regs64_t* r){ |
| 641 | uint64_t* pid = (uint64_t*)SC_ARG0(r); |
nothing calls this directly
no test coverage detected