From 93d99e8353208d2919cc0f0fc841066adec00a36 Mon Sep 17 00:00:00 2001 From: Freeman Lou Date: Sat, 7 Dec 2013 04:48:21 +0000 Subject: [PATCH] DriveSetup: propose to force unmount if umount failed * Propose to repeat unmount attemp with force unmount flag in case the unmount attempt was unsuccsessful; * Fixes #8548; - GCI 2013 --- src/apps/drivesetup/MainWindow.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/apps/drivesetup/MainWindow.cpp b/src/apps/drivesetup/MainWindow.cpp index 6f2fe01848..682a3621d9 100644 --- a/src/apps/drivesetup/MainWindow.cpp +++ b/src/apps/drivesetup/MainWindow.cpp @@ -39,6 +39,7 @@ #include #include +#include #include #include "ChangeParametersPanel.h" @@ -864,6 +865,25 @@ MainWindow::_Unmount(BDiskDevice* disk, partition_id selectedPartition) BPath path; partition->GetMountPoint(&path); status_t status = partition->Unmount(); + if (status != B_OK) { + BString message = B_TRANSLATE("Could not unmount partition"); + message << " \"" << partition->ContentName() << "\":\n\t" + << strerror(status) << "\n\n" + << B_TRANSLATE("Should unmounting be forced?\n\n" + "Note: If an application is currently writing to the volume, " + "unmounting it now might result in loss of data.\n"); + + BAlert* alert = new BAlert(B_TRANSLATE("Force unmount"), message, + B_TRANSLATE("Cancel"), B_TRANSLATE("Force unmount"), NULL, + B_WIDTH_AS_USUAL, B_WARNING_ALERT); + alert->SetShortcut(0, B_ESCAPE); + + if (alert->Go() == 1) + status = partition->Unmount(B_FORCE_UNMOUNT); + else + return; + } + if (status != B_OK) { _DisplayPartitionError( B_TRANSLATE("Could not unmount partition %s."),