MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / SysLSeek

Function SysLSeek

Kernel/src/arch/x86_64/syscalls.cpp:609–638  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

607}
608
609long 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
640long SysGetPID(regs64_t* r){
641 uint64_t* pid = (uint64_t*)SC_ARG0(r);

Callers

nothing calls this directly

Calls 4

GetCurrentProcessFunction · 0.85
WarningFunction · 0.85
InfoFunction · 0.85
get_lengthMethod · 0.45

Tested by

no test coverage detected