move setting of fuse options to Fuse class
This commit is contained in:
parent
183d6a9d06
commit
92d8f939ac
@ -227,7 +227,7 @@ namespace cryfs {
|
||||
CryDevice device(std::move(config), std::move(blockStore));
|
||||
_sanityCheckFilesystem(&device);
|
||||
fspp::FilesystemImpl fsimpl(&device);
|
||||
fspp::fuse::Fuse fuse(&fsimpl, "cryfs");
|
||||
fspp::fuse::Fuse fuse(&fsimpl, "cryfs", "cryfs@"+options.baseDir().native());
|
||||
|
||||
_initLogfile(options);
|
||||
|
||||
|
@ -16,20 +16,6 @@ ProgramOptions::ProgramOptions(const bf::path &baseDir, const bf::path &mountDir
|
||||
:_baseDir(baseDir), _mountDir(mountDir), _configFile(configFile), _foreground(foreground),
|
||||
_cipher(cipher), _blocksizeBytes(blocksizeBytes), _unmountAfterIdleMinutes(unmountAfterIdleMinutes),
|
||||
_logFile(logFile), _fuseOptions(fuseOptions) {
|
||||
|
||||
auto hasNoOption = [&](const char *opt) {
|
||||
for (const string& it : _fuseOptions) {
|
||||
if (std::strncmp(it.c_str(), opt, std::strlen(opt))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
if (hasNoOption("subtype=cryfs") && hasNoOption("fsname=cryfs@")) {
|
||||
_fuseOptions.push_back("-ofsname=cryfs@"+baseDir.native());
|
||||
_fuseOptions.push_back("-osubtype=cryfs");
|
||||
}
|
||||
}
|
||||
|
||||
const bf::path &ProgramOptions::baseDir() const {
|
||||
|
@ -217,8 +217,8 @@ Fuse::~Fuse() {
|
||||
_argv.clear();
|
||||
}
|
||||
|
||||
Fuse::Fuse(Filesystem *fs, const std::string &fsname)
|
||||
:_fs(fs), _mountdir(), _running(false), _fsname(fsname) {
|
||||
Fuse::Fuse(Filesystem *fs, const std::string &fstype, const std::string &fsname)
|
||||
:_fs(fs), _mountdir(), _running(false), _fstype(fstype), _fsname(fsname) {
|
||||
}
|
||||
|
||||
void Fuse::_logException(const std::exception &e) {
|
||||
@ -235,11 +235,27 @@ void Fuse::run(const bf::path &mountdir, const vector<string> &fuseOptions) {
|
||||
ASSERT(_argv.size() == 0, "Filesystem already started");
|
||||
|
||||
_argv.reserve(2 + fuseOptions.size());
|
||||
_argv.push_back(_create_c_string(_fsname)); // The first argument is the file system name
|
||||
_argv.push_back(_create_c_string(_fstype)); // The first argument is the file system name
|
||||
_argv.push_back(_create_c_string(mountdir.native())); // The second argument is the mountdir
|
||||
for (const string &option : fuseOptions) {
|
||||
_argv.push_back(_create_c_string(option));
|
||||
}
|
||||
if(!_fsname.empty()) {
|
||||
auto hasNoOption = [&](const char *opt) {
|
||||
for (const string& it : fuseOptions) {
|
||||
if (std::strncmp(it.c_str(), opt, std::strlen(opt))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
if (hasNoOption("subtype=") && hasNoOption("fsname=")) {
|
||||
_argv.push_back(_create_c_string("-o"));
|
||||
_argv.push_back(_create_c_string("fsname="+_fsname));
|
||||
_argv.push_back(_create_c_string("-o"));
|
||||
_argv.push_back(_create_c_string("subtype="+_fstype));
|
||||
}
|
||||
}
|
||||
fuse_main(_argv.size(), _argv.data(), operations(), (void*)this);
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ class Filesystem;
|
||||
|
||||
class Fuse final {
|
||||
public:
|
||||
explicit Fuse(Filesystem *fs, const std::string &fsname);
|
||||
explicit Fuse(Filesystem *fs, const std::string &fstype, const std::string &fsname=std::string());
|
||||
~Fuse();
|
||||
|
||||
void run(const boost::filesystem::path &mountdir, const std::vector<std::string> &fuseOptions);
|
||||
@ -65,6 +65,7 @@ private:
|
||||
boost::filesystem::path _mountdir;
|
||||
std::vector<char*> _argv;
|
||||
bool _running;
|
||||
std::string _fstype;
|
||||
std::string _fsname;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(Fuse);
|
||||
|
Loading…
Reference in New Issue
Block a user