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>
|
2015-02-27 00:51:51 +01:00
|
|
|
#include <messmer/blobstore/interface/BlobStore.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 {
|
2015-03-11 00:23:52 +01:00
|
|
|
class DirBlob;
|
2014-11-15 16:33:24 +01:00
|
|
|
|
|
|
|
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:
|
2015-03-06 02:06:31 +01:00
|
|
|
static constexpr uint32_t BLOCKSIZE_BYTES = 4096;
|
|
|
|
|
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-02-27 00:51:51 +01:00
|
|
|
std::unique_ptr<blobstore::Blob> CreateBlob();
|
2015-03-08 03:51:19 +01:00
|
|
|
std::unique_ptr<blobstore::Blob> LoadBlob(const blockstore::Key &key);
|
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);
|
2015-02-27 00:51:51 +01:00
|
|
|
blockstore::Key CreateRootBlobAndReturnKey();
|
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
|
|
|
|
2015-03-11 00:23:52 +01:00
|
|
|
std::unique_ptr<DirBlob> LoadDirBlob(const bf::path &path);
|
|
|
|
|
2015-02-27 00:51:51 +01:00
|
|
|
std::unique_ptr<blobstore::BlobStore> _blobStore;
|
2014-12-07 10:42:16 +01:00
|
|
|
|
2015-02-27 00:51:51 +01:00
|
|
|
blockstore::Key _rootKey;
|
2014-11-15 16:33:24 +01:00
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(CryDevice);
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-12-07 08:57:23 +01:00
|
|
|
#endif
|