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

Function SysUnlink

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

Source from the content-addressed store, hash-verified

432}
433
434long SysUnlink(regs64_t* r){
435 const char* path = (const char*)SC_ARG0(r);
436
437 process_t* proc = Scheduler::GetCurrentProcess();
438
439 if(!Memory::CheckUsermodePointer(SC_ARG0(r), 1, proc->addressSpace)){
440 Log::Warning("sys_unlink: Invalid path pointer");
441 return -EFAULT;
442 }
443
444 FsNode* parentDirectory = fs::ResolveParent(path, proc->workingDir);
445 char* linkName = fs::BaseName(path);
446
447 if(!parentDirectory){
448 Log::Warning("sys_unlink: Could not resolve path: %s", path);
449 return -EINVAL;
450 }
451
452 if((parentDirectory->flags & FS_NODE_TYPE) != FS_NODE_DIRECTORY){
453 Log::Warning("sys_unlink: Could not resolve path: Not a directory: %s", path);
454 return -ENOTDIR;
455 }
456
457 DirectoryEntry entry;
458 strcpy(entry.name, linkName);
459 return parentDirectory->Unlink(&entry);
460}
461
462long SysChdir(regs64_t* r){
463 if(SC_ARG0(r)){

Callers

nothing calls this directly

Calls 7

GetCurrentProcessFunction · 0.85
CheckUsermodePointerFunction · 0.85
WarningFunction · 0.85
ResolveParentFunction · 0.85
BaseNameFunction · 0.85
strcpyFunction · 0.85
UnlinkMethod · 0.45

Tested by

no test coverage detected