| 650 | } |
| 651 | |
| 652 | long SysMkdir(regs64_t* r){ |
| 653 | char* path = (char*)SC_ARG0(r); |
| 654 | mode_t mode = SC_ARG1(r); |
| 655 | |
| 656 | process_t* proc = Scheduler::GetCurrentProcess(); |
| 657 | |
| 658 | if(!Memory::CheckUsermodePointer(SC_ARG0(r), 0, proc->addressSpace)){ |
| 659 | Log::Warning("sys_mkdir: Invalid path pointer %x", SC_ARG0(r)); |
| 660 | return -EFAULT; |
| 661 | } |
| 662 | |
| 663 | FsNode* parentDirectory = fs::ResolveParent(path, proc->workingDir); |
| 664 | char* dirPath = fs::BaseName(path); |
| 665 | |
| 666 | Log::Info("sys_mkdir: Attempting to create %s at path %s", dirPath, path); |
| 667 | |
| 668 | if(!parentDirectory){ |
| 669 | Log::Warning("sys_mkdir: Could not resolve path: %s", path); |
| 670 | return -EINVAL; |
| 671 | } |
| 672 | |
| 673 | if((parentDirectory->flags & FS_NODE_TYPE) != FS_NODE_DIRECTORY){ |
| 674 | Log::Warning("sys_mkdir: Could not resolve path: Not a directory: %s", path); |
| 675 | return -ENOTDIR; |
| 676 | } |
| 677 | |
| 678 | DirectoryEntry dir; |
| 679 | strcpy(dir.name, dirPath); |
| 680 | int ret = parentDirectory->CreateDirectory(&dir, mode); |
| 681 | |
| 682 | return ret; |
| 683 | } |
| 684 | |
| 685 | long SysRmdir(regs64_t* r){ |
| 686 | process_t* proc = Scheduler::GetCurrentProcess(); |
nothing calls this directly
no test coverage detected