1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-09 17:44:56 +09:00

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 0739b5df11 and
now is resolved by checking if the source fd is negative, to avoid fail
of the fstat call on it.
This commit is contained in:
Liav A. 2024-04-29 08:47:02 +03:00 committed by Andrew Kaster
parent 1a1191cc6e
commit 476b3703fd
Notes: sideshowbarker 2024-07-17 04:32:07 +09:00

View file

@ -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;
}