| 395 | } |
| 396 | |
| 397 | long SysLink(regs64_t* r){ |
| 398 | const char* oldpath = (const char*)SC_ARG0(r); |
| 399 | const char* newpath = (const char*)SC_ARG1(r); |
| 400 | |
| 401 | process_t* proc = Scheduler::GetCurrentProcess(); |
| 402 | |
| 403 | if(!(Memory::CheckUsermodePointer(SC_ARG0(r), 1, proc->addressSpace) && Memory::CheckUsermodePointer(SC_ARG1(r), 1, proc->addressSpace))){ |
| 404 | Log::Warning("sys_link: Invalid path pointer"); |
| 405 | return -EFAULT; |
| 406 | } |
| 407 | |
| 408 | FsNode* file = fs::ResolvePath(oldpath); |
| 409 | if(!file){ |
| 410 | Log::Warning("sys_link: Could not resolve path: %s", oldpath); |
| 411 | return -ENOENT; |
| 412 | } |
| 413 | |
| 414 | FsNode* parentDirectory = fs::ResolveParent(newpath, proc->workingDir); |
| 415 | char* linkName = fs::BaseName(newpath); |
| 416 | |
| 417 | Log::Info("sys_link: Attempting to create link %s at path %s", linkName, newpath); |
| 418 | |
| 419 | if(!parentDirectory){ |
| 420 | Log::Warning("sys_link: Could not resolve path: %s", newpath); |
| 421 | return -ENOENT; |
| 422 | } |
| 423 | |
| 424 | if((parentDirectory->flags & FS_NODE_TYPE) != FS_NODE_DIRECTORY){ |
| 425 | Log::Warning("sys_link: Could not resolve path: Parent not a directory: %s", newpath); |
| 426 | return -ENOTDIR; |
| 427 | } |
| 428 | |
| 429 | DirectoryEntry entry; |
| 430 | strcpy(entry.name, linkName); |
| 431 | return parentDirectory->Link(file, &entry); |
| 432 | } |
| 433 | |
| 434 | long SysUnlink(regs64_t* r){ |
| 435 | const char* path = (const char*)SC_ARG0(r); |
nothing calls this directly
no test coverage detected