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

Function SysRead

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

Source from the content-addressed store, hash-verified

238}
239
240long SysRead(regs64_t* r){
241 process_t* proc = Scheduler::GetCurrentProcess();
242 if(SC_ARG0(r) >= proc->fileDescriptors.get_length()){
243 Log::Warning("Invalid File Descriptor: %d", SC_ARG0(r));
244 return -EBADF;
245 }
246 fs_fd_t* handle = proc->fileDescriptors[SC_ARG0(r)];
247 if(!handle){
248 Log::Warning("Invalid File Descriptor: %d", SC_ARG0(r));
249 return -EBADF;
250 }
251
252 uint8_t* buffer = (uint8_t*)SC_ARG1(r);
253 uint64_t count = SC_ARG2(r);
254
255 if(!Memory::CheckUsermodePointer(SC_ARG1(r), count, proc->addressSpace)){
256 Log::Warning("Invalid Memory Buffer: %x", SC_ARG1(r));
257 return -EFAULT;
258 }
259
260 ssize_t ret = fs::Read(handle, count, buffer);
261 return ret;
262}
263
264long SysWrite(regs64_t* r){
265 process_t* proc = Scheduler::GetCurrentProcess();

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected