2014-11-15 16:33:24 +01:00
|
|
|
#pragma once
|
2015-10-15 13:06:51 +02:00
|
|
|
#ifndef MESSMER_CRYFS_FILESYSTEM_CRYDEVICE_H_
|
|
|
|
#define MESSMER_CRYFS_FILESYSTEM_CRYDEVICE_H_
|
2014-11-15 16:33:24 +01:00
|
|
|
|
2015-02-17 01:02:15 +01:00
|
|
|
#include <messmer/blockstore/interface/BlockStore.h>
|
2015-10-24 19:35:37 +02:00
|
|
|
#include "../config/CryConfigFile.h"
|
2014-12-07 22:26:16 +01:00
|
|
|
|
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-10-04 17:20:14 +02:00
|
|
|
#include "parallelaccessfsblobstore/ParallelAccessFsBlobStore.h"
|
|
|
|
#include "parallelaccessfsblobstore/DirBlobRef.h"
|
|
|
|
#include "parallelaccessfsblobstore/FileBlobRef.h"
|
|
|
|
#include "parallelaccessfsblobstore/SymlinkBlobRef.h"
|
2014-11-15 16:33:24 +01:00
|
|
|
|
|
|
|
namespace cryfs {
|
|
|
|
|
2015-10-19 02:46:47 +02:00
|
|
|
class CryDevice final: public fspp::Device {
|
2014-11-15 16:33:24 +01:00
|
|
|
public:
|
2015-04-15 20:42:14 +02:00
|
|
|
static constexpr uint32_t BLOCKSIZE_BYTES = 32 * 1024;
|
2015-03-06 02:06:31 +01:00
|
|
|
|
2015-10-19 02:46:47 +02:00
|
|
|
CryDevice(CryConfigFile config, cpputils::unique_ref<blockstore::BlockStore> blockStore);
|
2014-11-15 16:33:24 +01:00
|
|
|
|
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-10-04 17:20:14 +02:00
|
|
|
cpputils::unique_ref<parallelaccessfsblobstore::FileBlobRef> CreateFileBlob();
|
|
|
|
cpputils::unique_ref<parallelaccessfsblobstore::DirBlobRef> CreateDirBlob();
|
|
|
|
cpputils::unique_ref<parallelaccessfsblobstore::SymlinkBlobRef> CreateSymlinkBlob(const boost::filesystem::path &target);
|
|
|
|
cpputils::unique_ref<parallelaccessfsblobstore::FsBlobRef> LoadBlob(const blockstore::Key &key); //TODO Do I still need this function?
|
|
|
|
cpputils::unique_ref<parallelaccessfsblobstore::FsBlobRef> LoadBlob(const boost::filesystem::path &path);
|
|
|
|
cpputils::unique_ref<parallelaccessfsblobstore::DirBlobRef> LoadDirBlob(const boost::filesystem::path &path);
|
2015-04-10 00:52:00 +02:00
|
|
|
void RemoveBlob(const blockstore::Key &key);
|
2014-12-07 10:42:16 +01:00
|
|
|
|
2015-06-18 19:36:05 +02:00
|
|
|
boost::optional<cpputils::unique_ref<fspp::Node>> Load(const boost::filesystem::path &path) override;
|
2014-11-15 16:33:24 +01:00
|
|
|
|
2015-03-11 00:23:52 +01:00
|
|
|
|
2015-04-11 01:42:20 +02:00
|
|
|
private:
|
|
|
|
|
2015-10-04 17:20:14 +02:00
|
|
|
cpputils::unique_ref<parallelaccessfsblobstore::ParallelAccessFsBlobStore> _fsBlobStore;
|
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
|
|
|
|
2015-10-19 02:46:47 +02:00
|
|
|
blockstore::Key GetOrCreateRootKey(CryConfigFile *config);
|
2015-07-29 12:08:39 +02:00
|
|
|
blockstore::Key CreateRootBlobAndReturnKey();
|
|
|
|
static cpputils::unique_ref<blockstore::BlockStore> CreateEncryptedBlockStore(const CryConfig &config, cpputils::unique_ref<blockstore::BlockStore> baseBlockStore);
|
|
|
|
|
2014-11-15 16:33:24 +01:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(CryDevice);
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-12-07 08:57:23 +01:00
|
|
|
#endif
|