- Catch exceptions in initialization

- Show unmount command after successfully mounted
This commit is contained in:
Sebastian Messmer 2015-10-30 20:32:25 +01:00
parent 030adc4b89
commit 057113df00

View File

@ -29,6 +29,7 @@
using namespace cryfs; using namespace cryfs;
namespace bf = boost::filesystem; namespace bf = boost::filesystem;
using namespace cpputils::logging;
using blockstore::ondisk::OnDiskBlockStore; using blockstore::ondisk::OnDiskBlockStore;
using blockstore::inmemory::InMemoryBlockStore; using blockstore::inmemory::InMemoryBlockStore;
@ -116,18 +117,26 @@ namespace cryfs {
} }
void Cli::_runFilesystem(const ProgramOptions &options) { void Cli::_runFilesystem(const ProgramOptions &options) {
auto blockStore = make_unique_ref<OnDiskBlockStore>(bf::path(options.baseDir())); try {
auto config = _loadOrCreateConfig(options); auto blockStore = make_unique_ref<OnDiskBlockStore>(bf::path(options.baseDir()));
CryDevice device(std::move(config), std::move(blockStore)); auto config = _loadOrCreateConfig(options);
fspp::FilesystemImpl fsimpl(&device); CryDevice device(std::move(config), std::move(blockStore));
fspp::fuse::Fuse fuse(&fsimpl); fspp::FilesystemImpl fsimpl(&device);
fspp::fuse::Fuse fuse(&fsimpl);
_initLogfile(options); _initLogfile(options);
_goToBackgroundIfSpecified(options);
vector<char *> fuseOptions = options.fuseOptions(); std::cout << "\nFilesystem is running. To unmount, call:\n$ fusermount -u " << options.mountDir() << "\n" << std::endl;
std::cout << "\nFilesystem is running." << std::endl;
fuse.run(fuseOptions.size(), fuseOptions.data()); _goToBackgroundIfSpecified(options);
vector<char *> fuseOptions = options.fuseOptions();
fuse.run(fuseOptions.size(), fuseOptions.data());
} catch (const std::exception &e) {
LOG(ERROR) << "Crashed: " << e.what();
} catch (...) {
LOG(ERROR) << "Crashed";
}
} }
void Cli::_goToBackgroundIfSpecified(const ProgramOptions &options) { void Cli::_goToBackgroundIfSpecified(const ProgramOptions &options) {