mirror of
https://github.com/RGBCube/serenity
synced 2025-05-19 00:45:08 +00:00
Kernel: Simplify Ext2FS mount code path
Instead of looking up device metadata and then looking up a device by that metadata explicitly, just use VFS::open(). This also means that attempting to mount a device residing on a MS_NODEV file system will properly fail.
This commit is contained in:
parent
3393b78623
commit
b620ed25ab
1 changed files with 7 additions and 16 deletions
|
@ -3757,27 +3757,18 @@ int Process::sys$mount(const Syscall::SC_mount_params* user_params)
|
|||
}
|
||||
|
||||
if (fs_type == "ext2" || fs_type == "Ext2FS") {
|
||||
auto metadata_or_error = VFS::the().lookup_metadata(source, current_directory());
|
||||
if (metadata_or_error.is_error())
|
||||
return metadata_or_error.error();
|
||||
auto source_or_error = VFS::the().open(source, O_RDWR, 0, current_directory());
|
||||
if (source_or_error.is_error())
|
||||
return source_or_error.error();
|
||||
|
||||
auto major = metadata_or_error.value().major_device;
|
||||
auto minor = metadata_or_error.value().minor_device;
|
||||
|
||||
auto* device = Device::get_device(major, minor);
|
||||
if (!device) {
|
||||
dbg() << "mount: device (" << major << "," << minor << ") not found";
|
||||
auto* device = source_or_error.value()->device();
|
||||
if (!device || !device->is_disk_device()) {
|
||||
dbg() << "mount: this is not a DiskDevice";
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
if (!device->is_disk_device()) {
|
||||
dbg() << "mount: device (" << major << "," << minor << ") is not a DiskDevice";
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
auto& disk_device = static_cast<DiskDevice&>(*device);
|
||||
|
||||
dbg() << "mount: attempting to mount device (" << major << "," << minor << ") on " << target;
|
||||
dbg() << "mount: attempting to mount " << disk_device.absolute_path() << " on " << target;
|
||||
|
||||
fs = Ext2FS::create(disk_device);
|
||||
} else if (fs_type == "proc" || fs_type == "ProcFS") {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue