From 8e3ccf2c012258a1695ecc7d30fbf311d2af78c3 Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Sun, 10 Feb 2019 23:37:52 +1000 Subject: [PATCH] BootManager Disallow install to read-only drive (Bug #14596 & Bug #7200) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Test for read-only devices during drive scan if read-only detected, flag it in ui and disallow installation Change-Id: Idd9e8e94d4a4840df97939154e1bbec70d0c0ece Reviewed-on: https://review.haiku-os.org/c/1026 Reviewed-by: Adrien Destugues Reviewed-by: Axel Dörfler --- src/apps/bootmanager/DrivesPage.cpp | 4 ++++ src/apps/bootmanager/LegacyBootMenu.cpp | 3 +++ 2 files changed, 7 insertions(+) diff --git a/src/apps/bootmanager/DrivesPage.cpp b/src/apps/bootmanager/DrivesPage.cpp index 0babdb7d4a..1bb9acfbee 100644 --- a/src/apps/bootmanager/DrivesPage.cpp +++ b/src/apps/bootmanager/DrivesPage.cpp @@ -195,6 +195,10 @@ DriveItem::DrawItem(BView* owner, BRect frame, bool complete) message = B_TRANSLATE_COMMENT("Incompatible format!", "Cannot install"); break; + case B_READ_ONLY_DEVICE: + message = B_TRANSLATE_COMMENT("Read only!", + "Cannot install"); + break; default: message = B_TRANSLATE_COMMENT("Cannot access!", "Cannot install"); diff --git a/src/apps/bootmanager/LegacyBootMenu.cpp b/src/apps/bootmanager/LegacyBootMenu.cpp index 185b31d376..297e29789c 100644 --- a/src/apps/bootmanager/LegacyBootMenu.cpp +++ b/src/apps/bootmanager/LegacyBootMenu.cpp @@ -325,6 +325,9 @@ LegacyBootMenu::CanBeInstalled(const BootDrive& drive) if (visitor.FirstOffset() < (int)sizeof(kBootLoader)) return B_PARTITION_TOO_SMALL; + if (device.IsReadOnlyMedia()) + return B_READ_ONLY_DEVICE; + return B_OK; }