1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 14:48:14 +00:00

Kernel: Added unmount ability to VFS

It is now possible to unmount file systems from the VFS via `umount`.
It works via looking up the `fsid` of the filesystem from the `Inode`'s
metatdata so I'm not sure how fragile it is. It seems to work for now
though as something to get us going.
This commit is contained in:
Jesse Buhagiar 2019-08-11 23:56:39 +10:00 committed by Andreas Kling
parent f7251c74a9
commit bc22456f89
13 changed files with 98 additions and 3 deletions

View file

@ -2786,6 +2786,25 @@ int Process::sys$mount(const char* device_path, const char* mountpoint)
return result;
}
int Process::sys$umount(const char* mountpoint)
{
if (!is_superuser())
return -EPERM;
if (!validate_read_str(mountpoint))
return -EFAULT;
auto metadata_or_error = VFS::the().lookup_metadata(mountpoint, current_directory());
if (metadata_or_error.is_error())
return metadata_or_error.error();
auto fsid = metadata_or_error.value().inode.fsid();
auto fs = Ext2FS::from_fsid(fsid);
auto ret = VFS::the().unmount(*fs);
return ret;
}
ProcessTracer& Process::ensure_tracer()
{
if (!m_tracer)