2014-11-15 16:33:24 +01:00
|
|
|
#pragma once
|
|
|
|
#ifndef CRYFS_LIB_CRYDEVICE_H_
|
|
|
|
#define CRYFS_LIB_CRYDEVICE_H_
|
|
|
|
|
2015-02-17 01:02:15 +01:00
|
|
|
#include <messmer/blockstore/interface/BlockStore.h>
|
2014-12-07 22:26:16 +01:00
|
|
|
#include "CryConfig.h"
|
|
|
|
|
2014-11-15 16:33:24 +01:00
|
|
|
#include <boost/filesystem.hpp>
|
2015-02-17 01:02:15 +01:00
|
|
|
#include <messmer/fspp/fs_interface/Device.h>
|
2014-11-15 16:33:24 +01:00
|
|
|
|
2015-02-17 01:02:15 +01:00
|
|
|
#include "messmer/cpp-utils/macros.h"
|
2014-11-15 16:33:24 +01:00
|
|
|
|
|
|
|
namespace cryfs {
|
|
|
|
|
|
|
|
namespace bf = boost::filesystem;
|
|
|
|
|
2014-11-16 00:05:28 +01:00
|
|
|
class CryDevice: public fspp::Device {
|
2014-11-15 16:33:24 +01:00
|
|
|
public:
|
2014-12-09 17:19:59 +01:00
|
|
|
static constexpr size_t DIR_BLOCKSIZE = 4096;
|
2014-12-07 10:42:16 +01:00
|
|
|
|
2014-12-09 20:36:32 +01:00
|
|
|
CryDevice(std::unique_ptr<CryConfig> config, std::unique_ptr<blockstore::BlockStore> blockStore);
|
2014-11-15 16:33:24 +01:00
|
|
|
virtual ~CryDevice();
|
|
|
|
|
2014-11-15 17:24:07 +01:00
|
|
|
void statfs(const boost::filesystem::path &path, struct ::statvfs *fsstat) override;
|
2014-11-15 16:33:24 +01:00
|
|
|
|
2015-01-24 22:27:14 +01:00
|
|
|
std::unique_ptr<blockstore::Block> CreateBlock(size_t size);
|
2014-12-07 10:42:16 +01:00
|
|
|
|
2014-11-15 16:33:24 +01:00
|
|
|
private:
|
2014-12-09 20:36:32 +01:00
|
|
|
blockstore::Key GetOrCreateRootKey(CryConfig *config);
|
|
|
|
blockstore::Key CreateRootBlockAndReturnKey();
|
2014-11-16 00:05:28 +01:00
|
|
|
std::unique_ptr<fspp::Node> Load(const bf::path &path) override;
|
2014-11-15 16:33:24 +01:00
|
|
|
|
2014-12-09 17:19:59 +01:00
|
|
|
std::unique_ptr<blockstore::BlockStore> _block_store;
|
2014-12-07 10:42:16 +01:00
|
|
|
|
2014-12-09 20:36:32 +01:00
|
|
|
blockstore::Key _root_key;
|
2014-11-15 16:33:24 +01:00
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(CryDevice);
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-12-07 08:57:23 +01:00
|
|
|
#endif
|