#include "Log.h" #include "Pledge.h" #include "fs/VFS.h" #include "memory/MemoryManager.h" #include "sys/Syscall.h" #include "thread/Scheduler.h" Result sys_mkdir(Registers*, SyscallArgs args) { auto path = TRY(MemoryManager::strdup_from_user(args[0])); mode_t mode = (mode_t)args[1]; Thread* current = Scheduler::current(); TRY(check_pledge(current, Promise::p_cpath)); auto inode = TRY(VFS::create_directory(path.chars(), mode & ~current->umask, current->auth, current->current_directory)); auto metadata = inode->metadata(); metadata.uid = current->auth.euid; metadata.gid = current->auth.egid; TRY(inode->set_metadata(metadata)); return 0; }