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

Function SysReadDir

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

Source from the content-addressed store, hash-verified

838}
839
840long SysReadDir(regs64_t* r){
841 int fd = SC_ARG0(r);
842
843 if(fd >= static_cast<int>(Scheduler::GetCurrentProcess()->fileDescriptors.get_length())){
844 return -EBADF;
845 }
846
847 fs_dirent_t* direntPointer = (fs_dirent_t*)SC_ARG1(r);
848
849 if(!Memory::CheckUsermodePointer(SC_ARG1(r), sizeof(fs_dirent_t), Scheduler::GetCurrentProcess()->addressSpace)){
850 return -EFAULT;
851 }
852
853 unsigned int count = SC_ARG2(r);
854
855 if((Scheduler::GetCurrentProcess()->fileDescriptors[fd]->node->flags & FS_NODE_TYPE) != FS_NODE_DIRECTORY){
856 return -ENOTDIR;
857 }
858
859 DirectoryEntry tempent;
860 int ret = fs::ReadDir(Scheduler::GetCurrentProcess()->fileDescriptors[fd], &tempent, count);
861
862 strcpy(direntPointer->name, tempent.name);
863 direntPointer->type = tempent.flags;
864
865 return ret;
866}
867
868long SysSetFsBase(regs64_t* r){
869 asm volatile ("wrmsr" :: "a"(SC_ARG0(r) & 0xFFFFFFFF) /*Value low*/, "d"((SC_ARG0(r) >> 32) & 0xFFFFFFFF) /*Value high*/, "c"(0xC0000100) /*Set FS Base*/);

Callers

nothing calls this directly

Calls 5

GetCurrentProcessFunction · 0.85
CheckUsermodePointerFunction · 0.85
strcpyFunction · 0.85
ReadDirFunction · 0.50
get_lengthMethod · 0.45

Tested by

no test coverage detected