From b7b5dfba2a9ece801604bb04f0b74603e570ebfb Mon Sep 17 00:00:00 2001 From: Sebastian Messmer Date: Mon, 27 Jun 2016 22:31:06 -0700 Subject: [PATCH] Fix generation of new file systems --- src/cryfs/filesystem/CryDevice.cpp | 13 ++++++++++++- src/cryfs/filesystem/CryDevice.h | 3 +++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/cryfs/filesystem/CryDevice.cpp b/src/cryfs/filesystem/CryDevice.cpp index 1298ab5f..0f0b0895 100644 --- a/src/cryfs/filesystem/CryDevice.cpp +++ b/src/cryfs/filesystem/CryDevice.cpp @@ -29,6 +29,7 @@ using fspp::fuse::FuseErrnoException; using blockstore::BlockStore; using blockstore::Key; using blockstore::encrypted::EncryptedBlockStore; +using blobstore::BlobStore; using blobstore::onblocks::BlobStoreOnBlocks; using blobstore::onblocks::BlobOnBlocks; using blockstore::caching::CachingBlockStore; @@ -63,7 +64,7 @@ unique_ref CryDevice::Crea auto blobStore = CreateBlobStore(std::move(blockStore), configFile, myClientId); #ifndef CRYFS_NO_COMPATIBILITY - auto fsBlobStore = FsBlobStore::migrateIfNeeded(std::move(blobStore), Key::FromString(configFile->config()->RootBlob())); + auto fsBlobStore = MigrateOrCreateFsBlobStore(std::move(blobStore), configFile); #else auto fsBlobStore = make_unique_ref(std::move(blobStore)); #endif @@ -75,6 +76,16 @@ unique_ref CryDevice::Crea ); } +#ifndef CRYFS_NO_COMPATIBILITY +unique_ref CryDevice::MigrateOrCreateFsBlobStore(unique_ref blobStore, CryConfigFile *configFile) { + string rootBlobKey = configFile->config()->RootBlob(); + if ("" == rootBlobKey) { + return make_unique_ref(std::move(blobStore)); + } + return FsBlobStore::migrateIfNeeded(std::move(blobStore), Key::FromString(rootBlobKey)); +} +#endif + unique_ref CryDevice::CreateBlobStore(unique_ref blockStore, CryConfigFile *configFile, uint32_t myClientId) { auto versionCountingEncryptedBlockStore = CreateVersionCountingEncryptedBlockStore(std::move(blockStore), configFile, myClientId); // Create versionCountingEncryptedBlockStore not in the same line as BlobStoreOnBlocks, because it can modify BlocksizeBytes diff --git a/src/cryfs/filesystem/CryDevice.h b/src/cryfs/filesystem/CryDevice.h index ddeb8441..de0ee069 100644 --- a/src/cryfs/filesystem/CryDevice.h +++ b/src/cryfs/filesystem/CryDevice.h @@ -50,6 +50,9 @@ private: blockstore::Key GetOrCreateRootKey(CryConfigFile *config); blockstore::Key CreateRootBlobAndReturnKey(); static cpputils::unique_ref CreateFsBlobStore(cpputils::unique_ref blockStore, CryConfigFile *configFile, uint32_t myClientId); +#ifndef CRYFS_NO_COMPATIBILITY + static cpputils::unique_ref MigrateOrCreateFsBlobStore(cpputils::unique_ref blobStore, CryConfigFile *configFile); +#endif static cpputils::unique_ref CreateBlobStore(cpputils::unique_ref blockStore, CryConfigFile *configFile, uint32_t myClientId); static cpputils::unique_ref CreateVersionCountingEncryptedBlockStore(cpputils::unique_ref blockStore, CryConfigFile *configFile, uint32_t myClientId); static cpputils::unique_ref CreateEncryptedBlockStore(const CryConfig &config, cpputils::unique_ref baseBlockStore);