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

Function SysRename

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

Source from the content-addressed store, hash-verified

712}
713
714long SysRename(regs64_t* r){
715 char* oldpath = (char*)SC_ARG0(r);
716 char* newpath = (char*)SC_ARG1(r);
717
718 process_t* proc = Scheduler::GetCurrentProcess();
719
720 if(!Memory::CheckUsermodePointer(SC_ARG0(r), 0, proc->addressSpace)){
721 Log::Warning("sys_rename: Invalid oldpath pointer %x", SC_ARG0(r));
722 return -EFAULT;
723 }
724
725 if(!Memory::CheckUsermodePointer(SC_ARG1(r), 0, proc->addressSpace)){
726 Log::Warning("sys_rename: Invalid newpath pointer %x", SC_ARG0(r));
727 return -EFAULT;
728 }
729
730 FsNode* olddir = fs::ResolveParent(oldpath, proc->workingDir);
731 FsNode* newdir = fs::ResolveParent(newpath, proc->workingDir);
732
733 if(!(olddir && newdir)){
734 return -ENOENT;
735 }
736
737 return fs::Rename(olddir, fs::BaseName(oldpath), newdir, fs::BaseName(newpath));
738}
739
740long SysYield(regs64_t* r){
741 Scheduler::Yield();

Callers

nothing calls this directly

Calls 6

GetCurrentProcessFunction · 0.85
CheckUsermodePointerFunction · 0.85
WarningFunction · 0.85
ResolveParentFunction · 0.85
RenameFunction · 0.85
BaseNameFunction · 0.85

Tested by

no test coverage detected