libcryfs/src/main.cpp

63 lines
2.4 KiB
C++
Raw Normal View History

2015-02-17 01:02:15 +01:00
#include <messmer/blockstore/implementations/ondisk/OnDiskBlockStore.h>
2015-04-08 14:15:11 +02:00
#include <messmer/blockstore/implementations/inmemory/InMemoryBlockStore.h>
#include <messmer/blockstore/implementations/inmemory/InMemoryBlock.h>
2014-11-04 02:32:06 +01:00
#include <cmath>
#include <cstdio>
#include <cstdlib>
2015-09-29 22:44:19 +02:00
#include <messmer/cpp-utils/assert/backtrace.h>
2014-11-04 02:32:06 +01:00
2015-02-17 01:02:15 +01:00
#include "messmer/fspp/fuse/Fuse.h"
#include "messmer/fspp/impl/FilesystemImpl.h"
2015-09-12 20:16:13 +02:00
#include "filesystem/CryDevice.h"
#include "config/CryConfigLoader.h"
#include "program_options/Parser.h"
2015-09-19 01:02:42 +02:00
#include <gitversion/version.h>
2015-09-16 22:54:07 +02:00
using namespace cryfs;
namespace bf = boost::filesystem;
2014-12-09 17:19:59 +01:00
using blockstore::ondisk::OnDiskBlockStore;
2015-04-08 14:15:11 +02:00
using blockstore::inmemory::InMemoryBlockStore;
using program_options::ProgramOptions;
2014-12-07 08:57:23 +01:00
using cpputils::make_unique_ref;
2015-09-16 22:54:07 +02:00
using std::cout;
using std::endl;
using std::vector;
2014-12-07 08:57:23 +01:00
2015-09-29 22:44:19 +02:00
//TODO Support files > 4GB
//TODO cryfs process doesn't seem to react to "kill". Needs "kill -9". Why? Furthermore, calling "fusermount -u" unmounts the fs, but the cryfs process keeps running. Why?
//TODO CryFS is only using 100% CPU (not parallel) when running bonnie. Furthermore, when calling "ls" in the mount/Bonnie.../ dir while bonnie runs, ls blocks and doesn't return. Probable reason: fsblobstore locks blobs instead of allowing parallel access. Use something like parallelaccessstore. Also generally improve parallelity.
2015-09-29 22:44:19 +02:00
2015-09-28 13:41:23 +02:00
void showVersion() {
2015-09-19 01:02:42 +02:00
cout << "CryFS Version " << version::VERSION_STRING << endl;
if (version::IS_DEV_VERSION) {
cout << "WARNING! This is a development version based on git commit " << version::GIT_COMMIT_ID <<
2015-09-28 13:41:23 +02:00
". Please do not use in production!" << endl;
2015-09-19 01:02:42 +02:00
} else if (!version::IS_STABLE_VERSION) {
cout << "WARNING! This is an experimental version. Please backup your data frequently!" << endl;
}
cout << endl;
2015-09-28 13:41:23 +02:00
}
void runFilesystem(const ProgramOptions &options) {
auto config = CryConfigLoader().loadOrCreate(bf::path(options.configFile()));
auto blockStore = make_unique_ref<OnDiskBlockStore>(bf::path(options.baseDir()));
CryDevice device(std::move(config), std::move(blockStore));
fspp::FilesystemImpl fsimpl(&device);
fspp::fuse::Fuse fuse(&fsimpl);
vector<char*> fuseOptions = options.fuseOptions();
fuse.run(fuseOptions.size(), fuseOptions.data());
2015-09-28 13:41:23 +02:00
}
int main(int argc, char *argv[]) {
2015-09-29 22:44:19 +02:00
cpputils::showBacktraceOnSigSegv();
2015-09-28 13:41:23 +02:00
showVersion();
ProgramOptions options = program_options::Parser(argc, argv).parse();
runFilesystem(options);
return 0;
2014-11-04 02:32:06 +01:00
}