From 525c6618db00195a2f267749e9c9dfcd4f1db8de Mon Sep 17 00:00:00 2001 From: Sebastian Messmer Date: Mon, 21 Jan 2019 22:53:28 -0800 Subject: [PATCH] Exit cryfs-stats if filesystem is wrong version --- src/stats/main.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/stats/main.cpp b/src/stats/main.cpp index 6012d97f..f5da47ee 100644 --- a/src/stats/main.cpp +++ b/src/stats/main.cpp @@ -163,6 +163,18 @@ int main(int argc, char* argv[]) { std::cerr << "Error loading config file" << std::endl; exit(1); } + const auto& config_ = config->configFile.config(); + std::cout << "Loading filesystem of version " << config_->Version() << std::endl; +#ifndef CRYFS_NO_COMPATIBILITY + const bool is_correct_format = config_->Version() == CryConfig::FilesystemFormatVersion && !config_->HasParentPointers() && !config_->HasVersionNumbers(); +#else + const bool is_correct_format = config_->Version() == CryConfig::FilesystemFormatVersion; +#endif + if (!is_correct_format) { + // TODO At this point, the cryfs.config file was already switched to 0.10 format. We should probably not do that. + std::cerr << "The filesystem is not in the 0.10 format. It needs to be migrated. The cryfs-stats tool unfortunately can't handle this, please mount and unmount the filesystem once." << std::endl; + exit(1); + } cout << "Listing all blocks..." << flush; set unaccountedBlocks = _getAllBlockIds(basedir, *config, localStateDir);