25 lines
703 B
C++
25 lines
703 B
C++
#include "Log.h"
|
|
#include "Pledge.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();
|
|
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;
|
|
}
|