mirror of
https://github.com/veracrypt/VeraCrypt
synced 2024-11-10 13:13:34 +01:00
Linux/MacOSX: Allow choosing a filesystem other than FAT for outer volume but display warning about risks and implement an estimation of maximum possible size of hidden volume in this case.
This commit is contained in:
parent
2ca867ef5d
commit
5f04e5abd0
@ -14,6 +14,7 @@
|
|||||||
#include "Platform/SystemInfo.h"
|
#include "Platform/SystemInfo.h"
|
||||||
#ifdef TC_UNIX
|
#ifdef TC_UNIX
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <sys/statvfs.h> // header for statvfs
|
||||||
#include "Platform/Unix/Process.h"
|
#include "Platform/Unix/Process.h"
|
||||||
#endif
|
#endif
|
||||||
#include "Core/RandomNumberGenerator.h"
|
#include "Core/RandomNumberGenerator.h"
|
||||||
@ -822,15 +823,6 @@ namespace VeraCrypt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip PIM
|
|
||||||
if (forward && OuterVolume)
|
|
||||||
{
|
|
||||||
// Use FAT to prevent problems with free space
|
|
||||||
QuickFormatEnabled = false;
|
|
||||||
SelectedFilesystemType = VolumeCreationOptions::FilesystemType::FAT;
|
|
||||||
return Step::CreationProgress;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (VolumeSize > 4 * BYTES_PER_GB)
|
if (VolumeSize > 4 * BYTES_PER_GB)
|
||||||
{
|
{
|
||||||
if (VolumeSize <= TC_MAX_FAT_SECTOR_COUNT * SectorSize)
|
if (VolumeSize <= TC_MAX_FAT_SECTOR_COUNT * SectorSize)
|
||||||
@ -901,15 +893,6 @@ namespace VeraCrypt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (forward && OuterVolume)
|
|
||||||
{
|
|
||||||
// Use FAT to prevent problems with free space
|
|
||||||
QuickFormatEnabled = false;
|
|
||||||
SelectedFilesystemType = VolumeCreationOptions::FilesystemType::FAT;
|
|
||||||
return Step::CreationProgress;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (VolumeSize > 4 * BYTES_PER_GB)
|
if (VolumeSize > 4 * BYTES_PER_GB)
|
||||||
{
|
{
|
||||||
if (VolumeSize <= TC_MAX_FAT_SECTOR_COUNT * SectorSize)
|
if (VolumeSize <= TC_MAX_FAT_SECTOR_COUNT * SectorSize)
|
||||||
@ -945,6 +928,22 @@ namespace VeraCrypt
|
|||||||
case Step::FormatOptions:
|
case Step::FormatOptions:
|
||||||
{
|
{
|
||||||
VolumeFormatOptionsWizardPage *page = dynamic_cast <VolumeFormatOptionsWizardPage *> (GetCurrentPage());
|
VolumeFormatOptionsWizardPage *page = dynamic_cast <VolumeFormatOptionsWizardPage *> (GetCurrentPage());
|
||||||
|
|
||||||
|
if (forward && OuterVolume)
|
||||||
|
{
|
||||||
|
if (page->GetFilesystemType() != VolumeCreationOptions::FilesystemType::FAT)
|
||||||
|
{
|
||||||
|
if (!Gui->AskYesNo (_("WARNING: You have selected a filesystem other than FAT for the outer volume.\n"
|
||||||
|
"Please Note that in this case VeraCrypt can't calculate the exact maximum allowed size for the hidden volume and it will use only an estimation that can be wrong.\n"
|
||||||
|
"Thus, it is your responsibility to use an adequate value for the size of the hidden volume so that it doesn\'t overlap the outer volume.\n\n"
|
||||||
|
"Do you want to continue using the selected filesystem for the outer volume?")
|
||||||
|
, false, true))
|
||||||
|
{
|
||||||
|
return GetCurrentStep();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SelectedFilesystemType = page->GetFilesystemType();
|
SelectedFilesystemType = page->GetFilesystemType();
|
||||||
QuickFormatEnabled = page->IsQuickFormatEnabled();
|
QuickFormatEnabled = page->IsQuickFormatEnabled();
|
||||||
|
|
||||||
@ -1098,12 +1097,23 @@ namespace VeraCrypt
|
|||||||
// require using FUSE and loop device which cannot be used for devices with sectors larger than 512.
|
// require using FUSE and loop device which cannot be used for devices with sectors larger than 512.
|
||||||
|
|
||||||
wxBusyCursor busy;
|
wxBusyCursor busy;
|
||||||
|
bool outerVolumeAvailableSpaceValid = false;
|
||||||
|
uint64 outerVolumeAvailableSpace = 0;
|
||||||
MaxHiddenVolumeSize = 0;
|
MaxHiddenVolumeSize = 0;
|
||||||
|
|
||||||
Gui->SetActiveFrame (this);
|
Gui->SetActiveFrame (this);
|
||||||
|
|
||||||
if (MountedOuterVolume)
|
if (MountedOuterVolume)
|
||||||
{
|
{
|
||||||
|
#ifdef TC_UNIX
|
||||||
|
const DirectoryPath &outerVolumeMountPoint = MountedOuterVolume->MountPoint;
|
||||||
|
struct statvfs stat;
|
||||||
|
if (statvfs(((string)outerVolumeMountPoint).c_str(), &stat) == 0)
|
||||||
|
{
|
||||||
|
outerVolumeAvailableSpace = (uint64) stat.f_bsize * (uint64) stat.f_bavail;
|
||||||
|
outerVolumeAvailableSpaceValid = true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
Core->DismountVolume (MountedOuterVolume);
|
Core->DismountVolume (MountedOuterVolume);
|
||||||
MountedOuterVolume.reset();
|
MountedOuterVolume.reset();
|
||||||
}
|
}
|
||||||
@ -1126,7 +1136,21 @@ namespace VeraCrypt
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
shared_ptr <Volume> outerVolume = Core->OpenVolume (make_shared <VolumePath> (SelectedVolumePath), true, Password, Pim, Kdf, false, Keyfiles, VolumeProtection::ReadOnly);
|
shared_ptr <Volume> outerVolume = Core->OpenVolume (make_shared <VolumePath> (SelectedVolumePath), true, Password, Pim, Kdf, false, Keyfiles, VolumeProtection::ReadOnly);
|
||||||
MaxHiddenVolumeSize = Core->GetMaxHiddenVolumeSize (outerVolume);
|
try
|
||||||
|
{
|
||||||
|
MaxHiddenVolumeSize = Core->GetMaxHiddenVolumeSize (outerVolume);
|
||||||
|
}
|
||||||
|
catch (ParameterIncorrect& )
|
||||||
|
{
|
||||||
|
// Outer volume not using FAT
|
||||||
|
// estimate maximum hidden volume size as 80% of available size of outer volume
|
||||||
|
if (outerVolumeAvailableSpaceValid)
|
||||||
|
{
|
||||||
|
MaxHiddenVolumeSize =(4ULL * outerVolumeAvailableSpace) / 5ULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
// Add a reserve (in case the user mounts the outer volume and creates new files
|
// Add a reserve (in case the user mounts the outer volume and creates new files
|
||||||
// on it by accident or OS writes some new data behind his or her back, such as
|
// on it by accident or OS writes some new data behind his or her back, such as
|
||||||
|
Loading…
Reference in New Issue
Block a user