Rename blobstore to blockstore

This commit is contained in:
Sebastian Messmer 2014-12-09 17:19:59 +01:00
parent ebc70cff53
commit e757da0ad3
16 changed files with 166 additions and 168 deletions

View File

@ -1,3 +1,3 @@
add_library(cryfs_lib CryDevice.cpp CryDir.cpp CryFile.cpp CryNode.cpp CryOpenFile.cpp CryConfig.cpp impl/DirBlob.cpp impl/FileBlob.cpp) add_library(cryfs_lib CryDevice.cpp CryDir.cpp CryFile.cpp CryNode.cpp CryOpenFile.cpp CryConfig.cpp impl/DirBlock.cpp impl/FileBlock.cpp)
target_link_libraries(cryfs_lib) target_link_libraries(cryfs_lib)

View File

@ -11,7 +11,7 @@ using boost::property_tree::ptree;
namespace cryfs { namespace cryfs {
CryConfig::CryConfig(const bf::path &configfile) CryConfig::CryConfig(const bf::path &configfile)
:_configfile(configfile), _root_blob("") { :_configfile(configfile), _root_block("") {
if (bf::exists(_configfile)) { if (bf::exists(_configfile)) {
load(); load();
} }
@ -21,23 +21,23 @@ void CryConfig::load() {
ptree pt; ptree pt;
read_json(_configfile.native(), pt); read_json(_configfile.native(), pt);
_root_blob = pt.get("cryfs.rootblob", ""); _root_block = pt.get("cryfs.rootblock", "");
} }
void CryConfig::save() const { void CryConfig::save() const {
ptree pt; ptree pt;
pt.put("cryfs.rootblob", _root_blob); pt.put("cryfs.rootblock", _root_block);
write_json(_configfile.native(), pt); write_json(_configfile.native(), pt);
} }
const std::string &CryConfig::RootBlob() const { const std::string &CryConfig::RootBlock() const {
return _root_blob; return _root_block;
} }
void CryConfig::SetRootBlob(const std::string &value) { void CryConfig::SetRootBlock(const std::string &value) {
_root_blob = value; _root_block = value;
} }
CryConfig::~CryConfig() { CryConfig::~CryConfig() {

View File

@ -13,8 +13,8 @@ public:
CryConfig(const boost::filesystem::path &configfile); CryConfig(const boost::filesystem::path &configfile);
virtual ~CryConfig(); virtual ~CryConfig();
const std::string &RootBlob() const; const std::string &RootBlock() const;
void SetRootBlob(const std::string &value); void SetRootBlock(const std::string &value);
private: private:
boost::filesystem::path _configfile; boost::filesystem::path _configfile;
@ -22,7 +22,7 @@ private:
void load(); void load();
void save() const; void save() const;
std::string _root_blob; std::string _root_block;
DISALLOW_COPY_AND_ASSIGN(CryConfig); DISALLOW_COPY_AND_ASSIGN(CryConfig);
}; };

View File

@ -4,7 +4,7 @@
#include "CryFile.h" #include "CryFile.h"
#include "fspp/fuse/FuseErrnoException.h" #include "fspp/fuse/FuseErrnoException.h"
#include "impl/DirBlob.h" #include "impl/DirBlock.h"
using std::unique_ptr; using std::unique_ptr;
@ -16,23 +16,23 @@ using std::string;
using fspp::fuse::CHECK_RETVAL; using fspp::fuse::CHECK_RETVAL;
using fspp::fuse::FuseErrnoException; using fspp::fuse::FuseErrnoException;
using blobstore::BlobStore; using blockstore::BlockStore;
namespace cryfs { namespace cryfs {
CryDevice::CryDevice(unique_ptr<CryConfig> config, unique_ptr<BlobStore> blobStore) CryDevice::CryDevice(unique_ptr<CryConfig> config, unique_ptr<BlockStore> blockStore)
: _blob_store(std::move(blobStore)), _root_key(config->RootBlob()) { : _block_store(std::move(blockStore)), _root_key(config->RootBlock()) {
if (_root_key == "") { if (_root_key == "") {
_root_key = CreateRootBlobAndReturnKey(); _root_key = CreateRootBlockAndReturnKey();
config->SetRootBlob(_root_key); config->SetRootBlock(_root_key);
} }
} }
string CryDevice::CreateRootBlobAndReturnKey() { string CryDevice::CreateRootBlockAndReturnKey() {
auto rootBlob = _blob_store->create(DIR_BLOBSIZE); auto rootBlock = _block_store->create(DIR_BLOCKSIZE);
DirBlob rootDir(std::move(rootBlob.blob)); DirBlock rootDir(std::move(rootBlock.block));
rootDir.InitializeEmptyDir(); rootDir.InitializeEmptyDir();
return rootBlob.key; return rootBlock.key;
} }
CryDevice::~CryDevice() { CryDevice::~CryDevice() {
@ -42,21 +42,21 @@ unique_ptr<fspp::Node> CryDevice::Load(const bf::path &path) {
printf("Loading %s\n", path.c_str()); printf("Loading %s\n", path.c_str());
assert(path.is_absolute()); assert(path.is_absolute());
auto current_blob = _blob_store->load(_root_key); auto current_block = _block_store->load(_root_key);
for (const bf::path &component : path.relative_path()) { for (const bf::path &component : path.relative_path()) {
if (!DirBlob::IsDir(*current_blob)) { if (!DirBlock::IsDir(*current_block)) {
throw FuseErrnoException(ENOTDIR); throw FuseErrnoException(ENOTDIR);
} }
unique_ptr<DirBlob> currentDir = make_unique<DirBlob>(std::move(current_blob)); unique_ptr<DirBlock> currentDir = make_unique<DirBlock>(std::move(current_block));
string childKey = currentDir->GetBlobKeyForName(component.c_str()); string childKey = currentDir->GetBlockKeyForName(component.c_str());
current_blob = _blob_store->load(childKey); current_block = _block_store->load(childKey);
} }
if (DirBlob::IsDir(*current_blob)) { if (DirBlock::IsDir(*current_block)) {
return make_unique<CryDir>(this, std::move(make_unique<DirBlob>(std::move(current_blob)))); return make_unique<CryDir>(this, std::move(make_unique<DirBlock>(std::move(current_block))));
} else if (FileBlob::IsFile(*current_blob)) { } else if (FileBlock::IsFile(*current_block)) {
return make_unique<CryFile>(std::move(make_unique<FileBlob>(std::move(current_blob)))); return make_unique<CryFile>(std::move(make_unique<FileBlock>(std::move(current_block))));
} else { } else {
throw FuseErrnoException(EIO); throw FuseErrnoException(EIO);
} }
@ -66,8 +66,8 @@ void CryDevice::statfs(const bf::path &path, struct statvfs *fsstat) {
throw FuseErrnoException(ENOTSUP); throw FuseErrnoException(ENOTSUP);
} }
blobstore::BlobWithKey CryDevice::CreateBlob(size_t size) { blockstore::BlockWithKey CryDevice::CreateBlock(size_t size) {
return _blob_store->create(size); return _block_store->create(size);
} }
} }

View File

@ -2,13 +2,12 @@
#ifndef CRYFS_LIB_CRYDEVICE_H_ #ifndef CRYFS_LIB_CRYDEVICE_H_
#define CRYFS_LIB_CRYDEVICE_H_ #define CRYFS_LIB_CRYDEVICE_H_
#include <blockstore/interface/BlockStore.h>
#include "CryConfig.h" #include "CryConfig.h"
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <fspp/fs_interface/Device.h> #include <fspp/fs_interface/Device.h>
#include "blobstore/interface/BlobStore.h"
#include "fspp/utils/macros.h" #include "fspp/utils/macros.h"
namespace cryfs { namespace cryfs {
@ -17,20 +16,20 @@ namespace bf = boost::filesystem;
class CryDevice: public fspp::Device { class CryDevice: public fspp::Device {
public: public:
static constexpr size_t DIR_BLOBSIZE = 4096; static constexpr size_t DIR_BLOCKSIZE = 4096;
CryDevice(std::unique_ptr<CryConfig> config, std::unique_ptr<blobstore::BlobStore> blobStore); CryDevice(std::unique_ptr<CryConfig> config, std::unique_ptr<blockstore::BlockStore> blockbStore);
virtual ~CryDevice(); virtual ~CryDevice();
void statfs(const boost::filesystem::path &path, struct ::statvfs *fsstat) override; void statfs(const boost::filesystem::path &path, struct ::statvfs *fsstat) override;
blobstore::BlobWithKey CreateBlob(size_t size); blockstore::BlockWithKey CreateBlock(size_t size);
private: private:
std::string CreateRootBlobAndReturnKey(); std::string CreateRootBlockAndReturnKey();
std::unique_ptr<fspp::Node> Load(const bf::path &path) override; std::unique_ptr<fspp::Node> Load(const bf::path &path) override;
std::unique_ptr<blobstore::BlobStore> _blob_store; std::unique_ptr<blockstore::BlockStore> _block_store;
std::string _root_key; std::string _root_key;

View File

@ -22,29 +22,29 @@ using std::vector;
namespace cryfs { namespace cryfs {
CryDir::CryDir(CryDevice *device, unique_ptr<DirBlob> blob) CryDir::CryDir(CryDevice *device, unique_ptr<DirBlock> block)
: _device(device), _blob(std::move(blob)) { : _device(device), _block(std::move(block)) {
} }
CryDir::~CryDir() { CryDir::~CryDir() {
} }
unique_ptr<fspp::File> CryDir::createFile(const string &name, mode_t mode) { unique_ptr<fspp::File> CryDir::createFile(const string &name, mode_t mode) {
auto child = _device->CreateBlob(0); auto child = _device->CreateBlock(0);
_blob->AddChild(name, child.key); _block->AddChild(name, child.key);
//TODO Di we need a return value in createDir for fspp? If not, change fspp! //TODO Di we need a return value in createDir for fspp? If not, change fspp!
auto fileblob = make_unique<FileBlob>(std::move(child.blob)); auto fileblock = make_unique<FileBlock>(std::move(child.block));
fileblob->InitializeEmptyFile(); fileblock->InitializeEmptyFile();
return make_unique<CryFile>(std::move(fileblob)); return make_unique<CryFile>(std::move(fileblock));
} }
unique_ptr<fspp::Dir> CryDir::createDir(const string &name, mode_t mode) { unique_ptr<fspp::Dir> CryDir::createDir(const string &name, mode_t mode) {
auto child = _device->CreateBlob(CryDevice::DIR_BLOBSIZE); auto child = _device->CreateBlock(CryDevice::DIR_BLOCKSIZE);
_blob->AddChild(name, child.key); _block->AddChild(name, child.key);
//TODO I don't think we need a return value in createDir for fspp. Change fspp! //TODO I don't think we need a return value in createDir for fspp. Change fspp!
auto dirblob = make_unique<DirBlob>(std::move(child.blob)); auto dirblock = make_unique<DirBlock>(std::move(child.block));
dirblob->InitializeEmptyDir(); dirblock->InitializeEmptyDir();
return make_unique<CryDir>(_device, std::move(dirblob)); return make_unique<CryDir>(_device, std::move(dirblock));
} }
void CryDir::rmdir() { void CryDir::rmdir() {
@ -52,7 +52,7 @@ void CryDir::rmdir() {
} }
unique_ptr<vector<string>> CryDir::children() const { unique_ptr<vector<string>> CryDir::children() const {
return _blob->GetChildren(); return _block->GetChildren();
} }
} }

View File

@ -4,13 +4,13 @@
#include <fspp/fs_interface/Dir.h> #include <fspp/fs_interface/Dir.h>
#include "CryNode.h" #include "CryNode.h"
#include "impl/DirBlob.h" #include "impl/DirBlock.h"
namespace cryfs { namespace cryfs {
class CryDir: public fspp::Dir, CryNode { class CryDir: public fspp::Dir, CryNode {
public: public:
CryDir(CryDevice *device, std::unique_ptr<DirBlob> blob); CryDir(CryDevice *device, std::unique_ptr<DirBlock> block);
virtual ~CryDir(); virtual ~CryDir();
//TODO return type variance to CryFile/CryDir? //TODO return type variance to CryFile/CryDir?
@ -22,7 +22,7 @@ public:
private: private:
CryDevice *_device; CryDevice *_device;
std::unique_ptr<DirBlob> _blob; std::unique_ptr<DirBlock> _block;
DISALLOW_COPY_AND_ASSIGN(CryDir); DISALLOW_COPY_AND_ASSIGN(CryDir);
}; };

View File

@ -15,8 +15,8 @@ using std::make_unique;
namespace cryfs { namespace cryfs {
CryFile::CryFile(unique_ptr<FileBlob> blob) CryFile::CryFile(unique_ptr<FileBlock> block)
: _blob(std::move(blob)) { : _block(std::move(block)) {
} }
CryFile::~CryFile() { CryFile::~CryFile() {

View File

@ -5,13 +5,13 @@
#include <fspp/fs_interface/File.h> #include <fspp/fs_interface/File.h>
#include "CryNode.h" #include "CryNode.h"
#include "impl/FileBlob.h" #include "impl/FileBlock.h"
namespace cryfs { namespace cryfs {
class CryFile: public fspp::File, CryNode { class CryFile: public fspp::File, CryNode {
public: public:
CryFile(std::unique_ptr<FileBlob> blob); CryFile(std::unique_ptr<FileBlock> block);
virtual ~CryFile(); virtual ~CryFile();
std::unique_ptr<fspp::OpenFile> open(int flags) const override; std::unique_ptr<fspp::OpenFile> open(int flags) const override;
@ -19,7 +19,7 @@ public:
void unlink() override; void unlink() override;
private: private:
std::unique_ptr<FileBlob> _blob; std::unique_ptr<FileBlock> _block;
DISALLOW_COPY_AND_ASSIGN(CryFile); DISALLOW_COPY_AND_ASSIGN(CryFile);
}; };

View File

@ -1,4 +1,4 @@
#include <cryfs_lib/impl/DirBlob.h> #include "DirBlock.h"
#include <cassert> #include <cassert>
@ -12,35 +12,35 @@ using std::make_unique;
using std::vector; using std::vector;
using std::string; using std::string;
using blobstore::Blob; using blockstore::Block;
namespace cryfs { namespace cryfs {
DirBlob::DirBlob(unique_ptr<Blob> blob) DirBlock::DirBlock(unique_ptr<Block> block)
: _blob(std::move(blob)) { : _block(std::move(block)) {
} }
DirBlob::~DirBlob() { DirBlock::~DirBlock() {
} }
void DirBlob::InitializeEmptyDir() { void DirBlock::InitializeEmptyDir() {
*magicNumber() = MagicNumbers::DIR; *magicNumber() = MagicNumbers::DIR;
*entryCounter() = 0; *entryCounter() = 0;
} }
unsigned char *DirBlob::magicNumber() { unsigned char *DirBlock::magicNumber() {
return const_cast<unsigned char*>(magicNumber(const_cast<const Blob&>(*_blob))); return const_cast<unsigned char*>(magicNumber(const_cast<const Block&>(*_block)));
} }
const unsigned char *DirBlob::magicNumber(const blobstore::Blob &blob) { const unsigned char *DirBlock::magicNumber(const blockstore::Block &block) {
return (unsigned char*)blob.data(); return (unsigned char*)block.data();
} }
bool DirBlob::IsDir(const blobstore::Blob &blob) { bool DirBlock::IsDir(const blockstore::Block &block) {
return *magicNumber(blob) == MagicNumbers::DIR; return *magicNumber(block) == MagicNumbers::DIR;
} }
unique_ptr<vector<string>> DirBlob::GetChildren() const { unique_ptr<vector<string>> DirBlock::GetChildren() const {
auto result = make_unique<vector<string>>(); auto result = make_unique<vector<string>>();
unsigned int entryCount = *entryCounter(); unsigned int entryCount = *entryCounter();
result->reserve(entryCount); result->reserve(entryCount);
@ -53,7 +53,7 @@ unique_ptr<vector<string>> DirBlob::GetChildren() const {
return result; return result;
} }
const char *DirBlob::readAndAddNextChild(const char *pos, vector<string> *result) const { const char *DirBlock::readAndAddNextChild(const char *pos, vector<string> *result) const {
size_t length = strlen(pos); size_t length = strlen(pos);
result->emplace_back(pos, length); result->emplace_back(pos, length);
const char *posAfterName = pos + length + 1; const char *posAfterName = pos + length + 1;
@ -61,21 +61,21 @@ const char *DirBlob::readAndAddNextChild(const char *pos, vector<string> *result
return posAfterKey; return posAfterKey;
} }
void DirBlob::AddChild(const std::string &name, const std::string &blobKey) { void DirBlock::AddChild(const std::string &name, const std::string &blockKey) {
char *insertPos = entriesEnd(); char *insertPos = entriesEnd();
assertEnoughSpaceLeft(insertPos, name.size() + 1 + blobKey.size() + 1); assertEnoughSpaceLeft(insertPos, name.size() + 1 + blockKey.size() + 1);
memcpy(insertPos, name.c_str(), name.size()+1); memcpy(insertPos, name.c_str(), name.size()+1);
memcpy(insertPos + name.size()+1, blobKey.c_str(), blobKey.size()+1); memcpy(insertPos + name.size()+1, blockKey.c_str(), blockKey.size()+1);
++(*entryCounter()); ++(*entryCounter());
} }
void DirBlob::assertEnoughSpaceLeft(char *insertPos, size_t insertSize) const { void DirBlock::assertEnoughSpaceLeft(char *insertPos, size_t insertSize) const {
size_t usedSize = insertPos - (char*)_blob->data(); size_t usedSize = insertPos - (char*)_block->data();
assert(usedSize + insertSize <= _blob->size()); assert(usedSize + insertSize <= _block->size());
} }
string DirBlob::GetBlobKeyForName(const string &name) const { string DirBlock::GetBlockKeyForName(const string &name) const {
unsigned int entryCount = *entryCounter(); unsigned int entryCount = *entryCounter();
const char *pos = entriesBegin(); const char *pos = entriesBegin();
for(unsigned int i = 0; i < entryCount; ++i) { for(unsigned int i = 0; i < entryCount; ++i) {
@ -90,23 +90,23 @@ string DirBlob::GetBlobKeyForName(const string &name) const {
throw fspp::fuse::FuseErrnoException(ENOENT); throw fspp::fuse::FuseErrnoException(ENOENT);
} }
unsigned int *DirBlob::entryCounter() { unsigned int *DirBlock::entryCounter() {
return const_cast<unsigned int*>(const_cast<const DirBlob*>(this)->entryCounter()); return const_cast<unsigned int*>(const_cast<const DirBlock*>(this)->entryCounter());
} }
const unsigned int *DirBlob::entryCounter() const { const unsigned int *DirBlock::entryCounter() const {
return (unsigned int*)((char*)_blob->data() + sizeof(unsigned char)); return (unsigned int*)((char*)_block->data() + sizeof(unsigned char));
} }
char *DirBlob::entriesBegin() { char *DirBlock::entriesBegin() {
return const_cast<char*>(const_cast<const DirBlob*>(this)->entriesBegin()); return const_cast<char*>(const_cast<const DirBlock*>(this)->entriesBegin());
} }
const char *DirBlob::entriesBegin() const { const char *DirBlock::entriesBegin() const {
return (char *)(_blob->data())+sizeof(unsigned char) + sizeof(unsigned int); return (char *)(_block->data())+sizeof(unsigned char) + sizeof(unsigned int);
} }
char *DirBlob::entriesEnd() { char *DirBlock::entriesEnd() {
unsigned int entryCount = *entryCounter(); unsigned int entryCount = *entryCounter();
char *pos = entriesBegin(); char *pos = entriesBegin();
for(unsigned int i = 0; i < entryCount; ++i) { for(unsigned int i = 0; i < entryCount; ++i) {

View File

@ -1,8 +1,8 @@
#pragma once #pragma once
#ifndef CRYFS_LIB_IMPL_DIRBLOB_H_ #ifndef CRYFS_LIB_IMPL_DIRBLOCK_H_
#define CRYFS_LIB_IMPL_DIRBLOB_H_ #define CRYFS_LIB_IMPL_DIRBLOCK_H_
#include "blobstore/interface/Blob.h" #include <blockstore/interface/Block.h>
#include "fspp/utils/macros.h" #include "fspp/utils/macros.h"
#include <memory> #include <memory>
@ -10,21 +10,21 @@
namespace cryfs{ namespace cryfs{
class DirBlob { class DirBlock {
public: public:
DirBlob(std::unique_ptr<blobstore::Blob> blob); DirBlock(std::unique_ptr<blockstore::Block> block);
virtual ~DirBlob(); virtual ~DirBlock();
void InitializeEmptyDir(); void InitializeEmptyDir();
std::unique_ptr<std::vector<std::string>> GetChildren() const; std::unique_ptr<std::vector<std::string>> GetChildren() const;
void AddChild(const std::string &name, const std::string &blobKey); void AddChild(const std::string &name, const std::string &blockKey);
std::string GetBlobKeyForName(const std::string &name) const; std::string GetBlockKeyForName(const std::string &name) const;
static bool IsDir(const blobstore::Blob &blob); static bool IsDir(const blockstore::Block &block);
private: private:
unsigned char *magicNumber(); unsigned char *magicNumber();
static const unsigned char *magicNumber(const blobstore::Blob &blob); static const unsigned char *magicNumber(const blockstore::Block &block);
unsigned int *entryCounter(); unsigned int *entryCounter();
const unsigned int *entryCounter() const; const unsigned int *entryCounter() const;
char *entriesBegin(); char *entriesBegin();
@ -34,9 +34,9 @@ private:
const char *readAndAddNextChild(const char *pos, std::vector<std::string> *result) const; const char *readAndAddNextChild(const char *pos, std::vector<std::string> *result) const;
void assertEnoughSpaceLeft(char *insertPos, size_t insertSize) const; void assertEnoughSpaceLeft(char *insertPos, size_t insertSize) const;
std::unique_ptr<blobstore::Blob> _blob; std::unique_ptr<blockstore::Block> _block;
DISALLOW_COPY_AND_ASSIGN(DirBlob); DISALLOW_COPY_AND_ASSIGN(DirBlock);
}; };
} }

View File

@ -1,33 +0,0 @@
#include <cryfs_lib/impl/FileBlob.h>
#include "MagicNumbers.h"
using std::unique_ptr;
using blobstore::Blob;
namespace cryfs {
FileBlob::FileBlob(unique_ptr<Blob> blob)
: _blob(std::move(blob)) {
}
FileBlob::~FileBlob() {
}
void FileBlob::InitializeEmptyFile() {
*magicNumber() = MagicNumbers::FILE;
}
unsigned char *FileBlob::magicNumber() {
return const_cast<unsigned char*>(magicNumber(const_cast<const Blob&>(*_blob)));
}
const unsigned char *FileBlob::magicNumber(const blobstore::Blob &blob) {
return (unsigned char*)blob.data();
}
bool FileBlob::IsFile(const Blob &blob) {
return *magicNumber(blob) == MagicNumbers::FILE;
}
}

View File

@ -1,29 +0,0 @@
#pragma once
#ifndef CRYFS_LIB_IMPL_FILEBLOB_H_
#define CRYFS_LIB_IMPL_FILEBLOB_H_
#include "blobstore/interface/Blob.h"
#include <memory>
namespace cryfs {
class FileBlob {
public:
FileBlob(std::unique_ptr<blobstore::Blob> blob);
virtual ~FileBlob();
static bool IsFile(const blobstore::Blob &blob);
void InitializeEmptyFile();
private:
std::unique_ptr<blobstore::Blob> _blob;
unsigned char *magicNumber();
static const unsigned char *magicNumber(const blobstore::Blob &blob);
};
}
#endif

View File

@ -0,0 +1,33 @@
#include "FileBlock.h"
#include "MagicNumbers.h"
using std::unique_ptr;
using blockstore::Block;
namespace cryfs {
FileBlock::FileBlock(unique_ptr<Block> block)
: _block(std::move(block)) {
}
FileBlock::~FileBlock() {
}
void FileBlock::InitializeEmptyFile() {
*magicNumber() = MagicNumbers::FILE;
}
unsigned char *FileBlock::magicNumber() {
return const_cast<unsigned char*>(magicNumber(const_cast<const Block&>(*_block)));
}
const unsigned char *FileBlock::magicNumber(const blockstore::Block &block) {
return (unsigned char*)block.data();
}
bool FileBlock::IsFile(const Block &block) {
return *magicNumber(block) == MagicNumbers::FILE;
}
}

View File

@ -0,0 +1,28 @@
#pragma once
#ifndef CRYFS_LIB_IMPL_FILEBLOCK_H_
#define CRYFS_LIB_IMPL_FILEBLOCK_H_
#include <blockstore/interface/Block.h>
#include <memory>
namespace cryfs {
class FileBlock {
public:
FileBlock(std::unique_ptr<blockstore::Block> block);
virtual ~FileBlock();
static bool IsFile(const blockstore::Block &block);
void InitializeEmptyFile();
private:
std::unique_ptr<blockstore::Block> _block;
unsigned char *magicNumber();
static const unsigned char *magicNumber(const blockstore::Block &block);
};
}
#endif

View File

@ -1,3 +1,4 @@
#include <blockstore/implementations/ondisk/OnDiskBlockStore.h>
#include <cmath> #include <cmath>
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>
@ -7,20 +8,19 @@
#include "fspp/impl/FilesystemImpl.h" #include "fspp/impl/FilesystemImpl.h"
#include "copyfs/CopyDevice.h" #include "copyfs/CopyDevice.h"
#include "cryfs_lib/CryDevice.h" #include "cryfs_lib/CryDevice.h"
#include "blobstore/implementations/ondisk/OnDiskBlobStore.h"
namespace bf = boost::filesystem; namespace bf = boost::filesystem;
using blobstore::ondisk::OnDiskBlobStore; using blockstore::ondisk::OnDiskBlockStore;
using std::make_unique; using std::make_unique;
int main (int argc, char *argv[]) int main (int argc, char *argv[])
{ {
printf("Version: %d\n", buildconfig::VERSION::MAJOR); printf("Version: %d\n", buildconfig::VERSION::MAJOR);
auto blobStore = make_unique<OnDiskBlobStore>(bf::path("/home/heinzi/cryfstest/root")); auto blockStore = make_unique<OnDiskBlockStore>(bf::path("/home/heinzi/cryfstest/root"));
auto config = make_unique<cryfs::CryConfig>(bf::path("/home/heinzi/cryfstest/config.json")); auto config = make_unique<cryfs::CryConfig>(bf::path("/home/heinzi/cryfstest/config.json"));
cryfs::CryDevice device(std::move(config), std::move(blobStore)); cryfs::CryDevice device(std::move(config), std::move(blockStore));
fspp::FilesystemImpl fsimpl(&device); fspp::FilesystemImpl fsimpl(&device);
fspp::fuse::Fuse fuse(&fsimpl); fspp::fuse::Fuse fuse(&fsimpl);
fuse.run(argc, argv); fuse.run(argc, argv);