Luna/kernel/src/sys/mkdir.cpp
apio b0506bf88f
All checks were successful
continuous-integration/drone/push Build is passing
kernel: Add umask
2023-05-26 22:27:49 +02:00

20 lines
544 B
C++

#include "Log.h"
#include "fs/VFS.h"
#include "memory/MemoryManager.h"
#include "sys/Syscall.h"
#include "thread/Scheduler.h"
Result<u64> 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();
auto inode = TRY(VFS::create_directory(path.chars(), current->auth, current->current_directory));
inode->chmod(mode & ~current->umask);
inode->chown(current->auth.euid, current->auth.egid);
return 0;
}