ソースを参照

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.
Sergey Bugaev 5 年 前
コミット
b620ed25ab
1 ファイル変更7 行追加16 行削除
  1. 7 16
      Kernel/Process.cpp

+ 7 - 16
Kernel/Process.cpp

@@ -3757,27 +3757,18 @@ int Process::sys$mount(const Syscall::SC_mount_params* user_params)
     }
     }
 
 
     if (fs_type == "ext2" || fs_type == "Ext2FS") {
     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 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";
-            return -ENODEV;
-        }
+        auto source_or_error = VFS::the().open(source, O_RDWR, 0, current_directory());
+        if (source_or_error.is_error())
+            return source_or_error.error();
 
 
-        if (!device->is_disk_device()) {
-            dbg() << "mount: device (" << major << "," << minor << ") is not a DiskDevice";
+        auto* device = source_or_error.value()->device();
+        if (!device || !device->is_disk_device()) {
+            dbg() << "mount: this is not a DiskDevice";
             return -ENODEV;
             return -ENODEV;
         }
         }
-
         auto& disk_device = static_cast<DiskDevice&>(*device);
         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);
         fs = Ext2FS::create(disk_device);
     } else if (fs_type == "proc" || fs_type == "ProcFS") {
     } else if (fs_type == "proc" || fs_type == "ProcFS") {