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

Function SysPRead

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

Source from the content-addressed store, hash-verified

957}
958
959long SysPRead(regs64_t* r){
960 if(SC_ARG0(r) > Scheduler::GetCurrentProcess()->fileDescriptors.get_length()){
961 return -EBADF;
962 }
963 FsNode* node;
964 if(Scheduler::GetCurrentProcess()->fileDescriptors.get_at(SC_ARG0(r)) || !(node = Scheduler::GetCurrentProcess()->fileDescriptors.get_at(SC_ARG0(r))->node)){
965 Log::Warning("sys_pread: Invalid file descriptor: %d", SC_ARG0(r));
966 return -EBADF;
967 }
968
969 if(!Memory::CheckUsermodePointer(SC_ARG1(r), SC_ARG2(r), Scheduler::GetCurrentProcess()->addressSpace)) {
970 return -EFAULT;
971 }
972
973 uint8_t* buffer = (uint8_t*)SC_ARG1(r);
974 uint64_t count = SC_ARG2(r);
975 uint64_t off = SC_ARG4(r);
976 return fs::Read(node, off, count, buffer);
977}
978
979long SysPWrite(regs64_t* r){
980 if(SC_ARG0(r) > Scheduler::GetCurrentProcess()->fileDescriptors.get_length()){

Callers

nothing calls this directly

Calls 6

GetCurrentProcessFunction · 0.85
WarningFunction · 0.85
CheckUsermodePointerFunction · 0.85
get_atMethod · 0.80
ReadFunction · 0.70
get_lengthMethod · 0.45

Tested by

no test coverage detected