diff --git a/src/Main/Forms/VolumeCreationWizard.cpp b/src/Main/Forms/VolumeCreationWizard.cpp index 6f1001e6..3f74c092 100644 --- a/src/Main/Forms/VolumeCreationWizard.cpp +++ b/src/Main/Forms/VolumeCreationWizard.cpp @@ -1044,7 +1044,12 @@ namespace VeraCrypt foreach_ref (const HostDevice &drive, Core->GetHostDevices()) { - if (drive.Path == SelectedVolumePath && !drive.Partitions.empty()) + bool selectedWholeDevice = drive.Path == SelectedVolumePath; +#ifdef TC_MACOSX + selectedWholeDevice = selectedWholeDevice + || IsSameMacOSXDevicePath (string (drive.Path), string (SelectedVolumePath)); +#endif + if (selectedWholeDevice && !drive.Partitions.empty()) { foreach_ref (const HostDevice &partition, drive.Partitions) { diff --git a/src/Main/MacOSXFormatterDevice.h b/src/Main/MacOSXFormatterDevice.h index a62898f6..d841ae2c 100644 --- a/src/Main/MacOSXFormatterDevice.h +++ b/src/Main/MacOSXFormatterDevice.h @@ -61,6 +61,11 @@ namespace VeraCrypt return deviceIdentifier; } + inline bool IsSameMacOSXDevicePath (const string &firstDeviceIdentifier, const string &secondDeviceIdentifier) + { + return GetMacOSXRawDevicePath (firstDeviceIdentifier) == GetMacOSXRawDevicePath (secondDeviceIdentifier); + } + inline string GetMacOSXFormatterName (const string &fsFormatter) { size_t namePos = fsFormatter.find_last_of ('/'); diff --git a/src/Main/TextUserInterface.cpp b/src/Main/TextUserInterface.cpp index 2d8871f8..b343155f 100644 --- a/src/Main/TextUserInterface.cpp +++ b/src/Main/TextUserInterface.cpp @@ -684,6 +684,28 @@ namespace VeraCrypt } while (options->Path.IsEmpty()); } + if (options->Path.IsDevice()) + { + foreach_ref (const HostDevice &drive, Core->GetHostDevices()) + { + bool selectedWholeDevice = drive.Path == options->Path; +#ifdef TC_MACOSX + selectedWholeDevice = selectedWholeDevice + || IsSameMacOSXDevicePath (string (drive.Path), string (options->Path)); +#endif + if (selectedWholeDevice && !drive.Partitions.empty()) + { + foreach_ref (const HostDevice &partition, drive.Partitions) + { + if (partition.MountPoint == "/") + throw_err (LangString["LINUX_ERROR_TRY_ENCRYPT_SYSTEM_DRIVE"]); + } + + throw_err (LangString["DEVICE_PARTITIONS_ERR"]); + } + } + } + // Sector size if (options->Path.IsDevice()) options->SectorSize = Core->GetDeviceSectorSize (options->Path);