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

Function SysReadDirNext

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

* SysReadDirNext(fd, direntPointer) - Read directory using the file descriptor offset as an index * * fd - File descriptor of directory * direntPointer - Pointer to fs_dirent_t * * Return Value: * 1 on Success * 0 on End of directory * Negative value on failure * */

Source from the content-addressed store, hash-verified

755 *
756 */
757long SysReadDirNext(regs64_t* r){
758 unsigned int fd = SC_ARG0(r);
759 if(fd > Scheduler::GetCurrentProcess()->fileDescriptors.get_length()){
760 return -EBADF;
761 }
762
763 fs_dirent_t* direntPointer = (fs_dirent_t*)SC_ARG1(r);
764 fs_fd_t* handle = Scheduler::GetCurrentProcess()->fileDescriptors[fd];
765
766 if(!handle){
767 return -EBADF;
768 }
769
770 if(!Memory::CheckUsermodePointer((uintptr_t)direntPointer, sizeof(fs_dirent_t), Scheduler::GetCurrentProcess()->addressSpace)){
771 return -EFAULT;
772 }
773
774 if((Scheduler::GetCurrentProcess()->fileDescriptors[fd]->node->flags & FS_NODE_TYPE) != FS_NODE_DIRECTORY){
775 return -ENOTDIR;
776 }
777
778 DirectoryEntry tempent;
779 int ret = fs::ReadDir(handle, &tempent, handle->pos++);
780
781 strcpy(direntPointer->name, tempent.name);
782 direntPointer->type = tempent.flags;
783
784 return ret;
785}
786
787long SysRenameAt(regs64_t* r){
788 Log::Warning("SysRenameAt is a stub!");

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