#include "fs/VFS.h" #include "fs/tmpfs/FileSystem.h" #include "memory/MemoryManager.h" #include "sys/Syscall.h" #include "thread/Scheduler.h" Result 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); SharedPtr fs; if (fstype.view() == "tmpfs") fs = TRY(TmpFS::FileSystem::create()); else if (fstype.view() == "devfs") fs = TRY(DeviceRegistry::create_devfs_instance()); else return err(ENODEV); TRY(VFS::mount(target.chars(), fs, current->auth, current->current_directory)); return 0; } Result 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; }