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

Function SysIoctl

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

Source from the content-addressed store, hash-verified

996}
997
998long SysIoctl(regs64_t* r){
999 int fd = SC_ARG0(r);
1000 uint64_t request = SC_ARG1(r);
1001 uint64_t arg = SC_ARG2(r);
1002 int* result = (int*)SC_ARG3(r);
1003
1004 if(result && !Memory::CheckUsermodePointer((uintptr_t)result, sizeof(int), Scheduler::GetCurrentProcess()->addressSpace)){
1005 return -EFAULT;
1006 }
1007
1008 if(fd >= static_cast<int>(Scheduler::GetCurrentProcess()->fileDescriptors.get_length())){
1009 return -EINVAL;
1010 }
1011 fs_fd_t* handle = Scheduler::GetCurrentProcess()->fileDescriptors[SC_ARG0(r)];
1012 if(!handle){
1013 Log::Warning("sys_ioctl: Invalid File Descriptor: %d", SC_ARG0(r));
1014 return -EINVAL;
1015 }
1016
1017 int ret = fs::Ioctl(handle, request, arg);
1018
1019 if(result && ret > 0){
1020 *result = ret;
1021 }
1022
1023 return ret;
1024}
1025
1026long SysInfo(regs64_t* r){
1027 lemon_sysinfo_t* s = (lemon_sysinfo_t*)SC_ARG0(r);

Callers

nothing calls this directly

Calls 5

CheckUsermodePointerFunction · 0.85
GetCurrentProcessFunction · 0.85
WarningFunction · 0.85
IoctlFunction · 0.85
get_lengthMethod · 0.45

Tested by

no test coverage detected