Allow libfuse daemonization again

This commit is contained in:
Sebastian Messmer 2015-10-30 21:40:11 +01:00
parent 440387e522
commit 5efc5c5537
2 changed files with 0 additions and 15 deletions

View File

@ -217,23 +217,9 @@ Fuse::Fuse(Filesystem *fs)
void Fuse::run(int argc, char **argv) {
vector<char*> _argv(argv, argv + argc);
//If we allow fuse to fork the process, it wouldn't fork our threads with it (fork() only forks the main thread).
//So we always run it in foreground, and can do our own daemonization before calling this.
_addRunInForegroundOption(&_argv);
fuse_main(_argv.size(), _argv.data(), operations(), (void*)this);
}
void Fuse::_addRunInForegroundOption(vector<char*> *argv) {
//TODO Is this without the const_cast hack possible? Can I pass (const char*) to fuse_main?
static char *foregroundOption = const_cast<char*>("-f");
bool hasRunInForegroundOption = std::find_if(argv->begin(), argv->end(),
[] (char *elem) {return string(elem) == string(foregroundOption);}
) != argv->end();
if (!hasRunInForegroundOption) {
argv->push_back(foregroundOption);
}
}
bool Fuse::running() const {
return _running;
}

View File

@ -57,7 +57,6 @@ public:
private:
Filesystem *_fs;
void _addRunInForegroundOption(std::vector<char*> *argv);
bool _running;
DISALLOW_COPY_AND_ASSIGN(Fuse);