| 432 | } |
| 433 | |
| 434 | long 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 | |
| 462 | long SysChdir(regs64_t* r){ |
| 463 | if(SC_ARG0(r)){ |
nothing calls this directly
no test coverage detected