Luna/kernel/src/sys/mkdir.cpp

20 lines
544 B
C++
Raw Normal View History

2023-03-12 14:32:09 +00:00
#include "Log.h"
#include "fs/VFS.h"
#include "memory/MemoryManager.h"
#include "sys/Syscall.h"
#include "thread/Scheduler.h"
2023-03-12 14:32:09 +00:00
Result<u64> sys_mkdir(Registers*, SyscallArgs args)
{
2023-03-12 15:30:36 +00:00
auto path = TRY(MemoryManager::strdup_from_user(args[0]));
2023-03-12 15:55:46 +00:00
mode_t mode = (mode_t)args[1];
2023-03-12 14:32:09 +00:00
Thread* current = Scheduler::current();
auto inode = TRY(VFS::create_directory(path.chars(), current->auth, current->current_directory));
2023-05-26 20:27:49 +00:00
inode->chmod(mode & ~current->umask);
inode->chown(current->auth.euid, current->auth.egid);
2023-03-12 14:32:09 +00:00
return 0;
}