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

Function SysMkdir

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

Source from the content-addressed store, hash-verified

650}
651
652long 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
685long SysRmdir(regs64_t* r){
686 process_t* proc = Scheduler::GetCurrentProcess();

Callers

nothing calls this directly

Calls 8

GetCurrentProcessFunction · 0.85
CheckUsermodePointerFunction · 0.85
WarningFunction · 0.85
ResolveParentFunction · 0.85
BaseNameFunction · 0.85
InfoFunction · 0.85
strcpyFunction · 0.85
CreateDirectoryMethod · 0.45

Tested by

no test coverage detected