فهرست منبع

Utilities/mount: Resolve regression on mounting non-storage-backed FSes

Without this patch, we fail on manually mounting RAMFS (which I tested
for) but any filesystem that is not backed by actual storage will fail.
This bug was introduced in 0739b5df11f2125f2f4b592e19c0d240620c5df6 and
now is resolved by checking if the source fd is negative, to avoid fail
of the fstat call on it.
Liav A. 1 سال پیش
والد
کامیت
476b3703fd
1فایلهای تغییر یافته به همراه8 افزوده شده و 5 حذف شده
  1. 8 5
      Userland/Utilities/mount.cpp

+ 8 - 5
Userland/Utilities/mount.cpp

@@ -262,11 +262,14 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
         } else {
             if (fs_type.is_empty())
                 fs_type = "ext2"sv;
-            auto stat = TRY(Core::System::fstat(fd));
-            if (!S_ISBLK(stat.st_mode))
-                TRY(mount_using_loop_device(fd, mountpoint, fs_type, flags));
-            else
-                TRY(Core::System::mount(fd, mountpoint, fs_type, flags));
+            if (fd >= 0) {
+                auto stat = TRY(Core::System::fstat(fd));
+                if (!S_ISBLK(stat.st_mode)) {
+                    TRY(mount_using_loop_device(fd, mountpoint, fs_type, flags));
+                    return 0;
+                }
+            }
+            TRY(Core::System::mount(fd, mountpoint, fs_type, flags));
         }
         return 0;
     }