Fix daemonize() behaviour. CryFS now works correctly when called without '-f'
This commit is contained in:
parent
ff8eae5293
commit
daf330a07f
@ -5,6 +5,7 @@
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <messmer/cpp-utils/assert/backtrace.h>
|
||||
#include <messmer/cpp-utils/daemon/daemonize.h>
|
||||
|
||||
#include "messmer/fspp/fuse/Fuse.h"
|
||||
#include "messmer/fspp/impl/FilesystemImpl.h"
|
||||
@ -27,7 +28,6 @@ using std::endl;
|
||||
using std::vector;
|
||||
|
||||
//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 Improve parallelity.
|
||||
//TODO Seems to deadlock in bonnie++ second run (in the create files sequentially) - maybe also in a later run or different step?
|
||||
|
||||
@ -58,9 +58,13 @@ void runFilesystem(const ProgramOptions &options) {
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
cpputils::showBacktraceOnSigSegv();
|
||||
|
||||
showVersion();
|
||||
|
||||
ProgramOptions options = program_options::Parser(argc, argv).parse();
|
||||
if (!options.foreground()) {
|
||||
cpputils::daemonize();
|
||||
}
|
||||
|
||||
runFilesystem(options);
|
||||
return 0;
|
||||
}
|
||||
|
@ -26,8 +26,9 @@ ProgramOptions Parser::parse() const {
|
||||
string baseDir = vm["base-dir"].as<string>();
|
||||
string mountDir = vm["mount-dir"].as<string>();
|
||||
string configFile = vm["config"].as<string>();
|
||||
bool foreground = vm.count("foreground");
|
||||
|
||||
return ProgramOptions(baseDir, mountDir, configFile, options.second);
|
||||
return ProgramOptions(baseDir, mountDir, configFile, foreground, options.second);
|
||||
}
|
||||
|
||||
po::variables_map Parser::_parseOptionsOrShowHelp(const vector<char*> options) {
|
||||
@ -60,6 +61,7 @@ void Parser::_addAllowedOptions(po::options_description *desc) {
|
||||
options.add_options()
|
||||
("help,h", "show help message")
|
||||
("config,c", po::value<string>()->required(), "Config file")
|
||||
("foreground,f", "Run CryFS in foreground.")
|
||||
;
|
||||
desc->add(options);
|
||||
}
|
||||
|
@ -6,8 +6,8 @@ using namespace cryfs::program_options;
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
ProgramOptions::ProgramOptions(const string &baseDir, const string &mountDir, const std::string &configFile, const vector<char*> &fuseOptions)
|
||||
:_baseDir(baseDir), _mountDir(new char[mountDir.size()+1]), _configFile(configFile), _fuseOptions(fuseOptions) {
|
||||
ProgramOptions::ProgramOptions(const string &baseDir, const string &mountDir, const std::string &configFile, bool foreground, const vector<char*> &fuseOptions)
|
||||
:_baseDir(baseDir), _mountDir(new char[mountDir.size()+1]), _configFile(configFile), _foreground(foreground), _fuseOptions(fuseOptions) {
|
||||
std::memcpy(_mountDir, mountDir.c_str(), mountDir.size()+1);
|
||||
// Fuse needs the mountDir passed as first option (first option = position 1, since 0 is the executable name)
|
||||
ASSERT(_fuseOptions.size() >= 1, "There has to be one parameter at least for the executable name");
|
||||
@ -30,6 +30,10 @@ const string &ProgramOptions::configFile() const {
|
||||
return _configFile;
|
||||
}
|
||||
|
||||
bool ProgramOptions::foreground() const {
|
||||
return _foreground;
|
||||
}
|
||||
|
||||
const vector<char *> &ProgramOptions::fuseOptions() const {
|
||||
return _fuseOptions;
|
||||
}
|
||||
|
@ -8,18 +8,20 @@ namespace cryfs {
|
||||
namespace program_options {
|
||||
class ProgramOptions {
|
||||
public:
|
||||
ProgramOptions(const std::string &baseDir, const std::string &mountDir, const std::string &configFile, const std::vector<char *> &fuseOptions);
|
||||
ProgramOptions(const std::string &baseDir, const std::string &mountDir, const std::string &configFile, bool foreground, const std::vector<char *> &fuseOptions);
|
||||
~ProgramOptions();
|
||||
|
||||
const std::string &baseDir() const;
|
||||
std::string mountDir() const;
|
||||
const std::string &configFile() const;
|
||||
bool foreground() const;
|
||||
const std::vector<char *> &fuseOptions() const;
|
||||
|
||||
private:
|
||||
std::string _baseDir;
|
||||
char *_mountDir;
|
||||
std::string _configFile;
|
||||
bool _foreground;
|
||||
std::vector<char *> _fuseOptions;
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user