35 lines
992 B
C++
35 lines
992 B
C++
#include "fs/VFS.h"
|
|
#include "fs/tmpfs/FileSystem.h"
|
|
#include "memory/MemoryManager.h"
|
|
#include "sys/Syscall.h"
|
|
#include "thread/Scheduler.h"
|
|
|
|
Result<u64> sys_mount(Registers*, SyscallArgs args)
|
|
{
|
|
auto target = TRY(MemoryManager::strdup_from_user(args[0]));
|
|
auto fstype = TRY(MemoryManager::strdup_from_user(args[1]));
|
|
|
|
auto* current = Scheduler::current();
|
|
if (current->auth.euid != 0) return err(EPERM);
|
|
|
|
// Right now we only support one file system.
|
|
if (fstype.view() != "tmpfs") return err(ENODEV);
|
|
|
|
auto fs = TRY(TmpFS::FileSystem::create());
|
|
TRY(VFS::mount(target.chars(), fs, current->auth, current->current_directory));
|
|
|
|
return 0;
|
|
}
|
|
|
|
Result<u64> sys_umount(Registers*, SyscallArgs args)
|
|
{
|
|
auto target = TRY(MemoryManager::strdup_from_user(args[0]));
|
|
|
|
auto* current = Scheduler::current();
|
|
if (current->auth.euid != 0) return err(EPERM);
|
|
|
|
TRY(VFS::umount(target.chars(), current->auth, current->current_directory));
|
|
|
|
return 0;
|
|
}
|