summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libfusepp/fuseAppBase.cpp2
-rw-r--r--libfusepp/fuseAppBase.h6
-rw-r--r--netfs/fuse/fuseApp.cpp7
-rw-r--r--netfs/fuse/fuseApp.h5
-rw-r--r--netfs/fuse/netfs.cpp9
-rw-r--r--netfs/unittests/mockFuse.cpp17
-rw-r--r--netfs/unittests/mockFuse.h9
-rw-r--r--netfs/unittests/testCore.cpp12
-rw-r--r--netfs/unittests/testEdgeCases.cpp10
-rw-r--r--netfs/unittests/testGlacier.cpp12
10 files changed, 41 insertions, 48 deletions
diff --git a/libfusepp/fuseAppBase.cpp b/libfusepp/fuseAppBase.cpp
index a1ea491..49f2d6b 100644
--- a/libfusepp/fuseAppBase.cpp
+++ b/libfusepp/fuseAppBase.cpp
@@ -198,7 +198,7 @@ void FuseAppBase::fuseDestroy(void *)
}
struct fuse_args
-FuseAppBase::runint(int & argc, char** & argv)
+FuseAppBase::runint(int argc, char ** argv)
{
struct fuse_opt fuse_opts[] = {
{ NULL, 0, 0 }
diff --git a/libfusepp/fuseAppBase.h b/libfusepp/fuseAppBase.h
index d76fbff..ccd2027 100644
--- a/libfusepp/fuseAppBase.h
+++ b/libfusepp/fuseAppBase.h
@@ -57,11 +57,11 @@ class FuseAppBase {
virtual int onError(const std::exception & err) throw();
virtual int fuse_opt_parse(struct fuse_args *args, void *data, const struct fuse_opt opts[], fuse_opt_proc_t proc) = 0;
- virtual int main(int &, char **, const struct fuse_operations *) = 0;
+ virtual int main(int, char **, const struct fuse_operations *) = 0;
#define GetHelper(func) getHelper<&FuseAppBase::func>(typeid(&FuseAppBase::func) != typeid(&FuseApp::func))
template <typename FuseApp>
- static int run(int & argc, char** & argv, FuseApp * fa)
+ static int run(int argc, char ** argv, FuseApp * fa)
{
auto args = fa->runint(argc, argv);
struct fuse_operations operations = {
@@ -124,7 +124,7 @@ class FuseAppBase {
};
return fa->main(args.argc, args.argv, &operations);
}
- struct fuse_args runint(int &, char ** &);
+ struct fuse_args runint(int, char **);
private:
static void * fuseInit(struct fuse_conn_info *conn);
diff --git a/netfs/fuse/fuseApp.cpp b/netfs/fuse/fuseApp.cpp
index 964f412..ac0dab5 100644
--- a/netfs/fuse/fuseApp.cpp
+++ b/netfs/fuse/fuseApp.cpp
@@ -11,9 +11,8 @@
template class Cache<struct stat, std::string, IceUtil::Shared, IceUtil::Handle<Cacheable<struct stat, std::string, IceUtil::Shared>>>;
template class OptimisticCallCacheable<struct stat, std::string, IceUtil::Shared>;
-NetFS::FuseApp::FuseApp(int & argc, char ** argv) :
- _argc(argc),
- _argv(argv),
+NetFS::FuseApp::FuseApp(const Ice::StringSeq & a) :
+ args(a),
sessionOpened(false),
openDirID(0),
openFileID(0)
@@ -48,7 +47,7 @@ NetFS::FuseApp::ReadConfiguration(const std::string & path) const
void *
NetFS::FuseApp::init(struct fuse_conn_info *)
{
- ic = Ice::initialize(_argc, _argv);
+ ic = Ice::initialize(args);
auto fc = ReadConfiguration(configPath);
auto e = fc->Resources.find(resourceName);
if (e == fc->Resources.end()) {
diff --git a/netfs/fuse/fuseApp.h b/netfs/fuse/fuseApp.h
index 70dd335..3ab1cb0 100644
--- a/netfs/fuse/fuseApp.h
+++ b/netfs/fuse/fuseApp.h
@@ -34,7 +34,7 @@ namespace NetFS {
typedef std::map<int, OpenFilePtr> OpenFiles;
public:
- FuseApp(int & argc, char ** argv);
+ FuseApp(const Ice::StringSeq &);
~FuseApp();
private:
@@ -96,8 +96,7 @@ namespace NetFS {
ReqEnv reqEnv();
- int & _argc;
- char ** _argv;
+ Ice::StringSeq args;
Ice::CommunicatorPtr ic;
Client::ResourcePtr fcr;
mutable boost::shared_mutex _lock;
diff --git a/netfs/fuse/netfs.cpp b/netfs/fuse/netfs.cpp
index f700a74..23996c2 100644
--- a/netfs/fuse/netfs.cpp
+++ b/netfs/fuse/netfs.cpp
@@ -2,28 +2,27 @@
class FuseImpl : public NetFS::FuseApp {
public:
- FuseImpl(int & argc, char ** argv) : NetFS::FuseApp(argc, argv) { }
+ FuseImpl(const Ice::StringSeq & a) : NetFS::FuseApp(a) { }
struct fuse_context * fuse_get_context() override
{
return ::fuse_get_context();
}
-
+
int fuse_opt_parse(struct fuse_args * args, void * data, const struct fuse_opt opts[], fuse_opt_proc_t proc) override
{
return ::fuse_opt_parse(args, data, opts, proc);
}
- int main(int & argc, char ** argv, const struct fuse_operations * ops) override
+ int main(int argc, char ** argv, const struct fuse_operations * ops) override
{
return ::fuse_main(argc, argv, ops, this);
}
-
};
int
main(int argc, char* argv[])
{
- return FuseAppBase::run(argc, argv, new FuseImpl(argc, argv));
+ return FuseAppBase::run(argc, argv, new FuseImpl(Ice::argsToStringSeq(argc, argv)));
}
diff --git a/netfs/unittests/mockFuse.cpp b/netfs/unittests/mockFuse.cpp
index 2b9edad..a9e2cc1 100644
--- a/netfs/unittests/mockFuse.cpp
+++ b/netfs/unittests/mockFuse.cpp
@@ -1,7 +1,7 @@
#include "mockFuse.h"
-FuseMock::FuseMock(const std::string & ep, int & argc, char ** argv) :
- NetFS::FuseApp(argc, argv),
+FuseMock::FuseMock(const std::string & ep, const Ice::StringSeq & a) :
+ NetFS::FuseApp(a),
testEndpoint(ep)
{
::memset(&context, 0, sizeof(fuse_context));
@@ -26,7 +26,7 @@ FuseMock::fuse_opt_parse(struct fuse_args * args, void * data, const struct fuse
}
int
-FuseMock::main(int &, char **, const struct fuse_operations * o)
+FuseMock::main(int, char **, const struct fuse_operations * o)
{
o->init(NULL);
ops = *o;
@@ -45,12 +45,15 @@ FuseMock::ReadConfiguration(const std::string & path) const
return c;
}
-FuseMockHost::FuseMockHost(const std::string & ep, int c, char ** v) :
- argc(c),
- app(new FuseMock(ep, c, v)),
+FuseMockHost::FuseMockHost(const std::string & ep, const Ice::StringSeq & a) :
+ app(new FuseMock(ep, a)),
fuse(&app->ops)
{
- FuseAppBase::run(argc, v, app);
+ std::vector<char *> argv;
+ for (auto & arg : a) {
+ argv.push_back(const_cast<char *>(arg.c_str()));
+ }
+ FuseAppBase::run(a.size(), &argv.front(), app);
}
FuseMockHost::~FuseMockHost()
diff --git a/netfs/unittests/mockFuse.h b/netfs/unittests/mockFuse.h
index 3ca88fe..e28fd5a 100644
--- a/netfs/unittests/mockFuse.h
+++ b/netfs/unittests/mockFuse.h
@@ -5,11 +5,11 @@
class FuseMock : public NetFS::FuseApp {
public:
- FuseMock(const std::string &, int & argc, char ** argv);
+ FuseMock(const std::string &, const Ice::StringSeq &);
struct fuse_context * fuse_get_context() override;
int fuse_opt_parse(struct fuse_args * args, void * data, const struct fuse_opt [], fuse_opt_proc_t proc) override;
- int main(int &, char **, const struct fuse_operations * o) override;
+ int main(int, char **, const struct fuse_operations * o) override;
fuse_operations ops;
@@ -23,15 +23,14 @@ class FuseMock : public NetFS::FuseApp {
class FuseMockHost {
public:
- FuseMockHost(const std::string &, int c, char ** v);
+ FuseMockHost(const std::string &, const Ice::StringSeq &);
~FuseMockHost();
private:
- int argc;
FuseMock * app;
public:
- fuse_operations * fuse;
+ const fuse_operations * fuse;
};
diff --git a/netfs/unittests/testCore.cpp b/netfs/unittests/testCore.cpp
index d13708c..07590b6 100644
--- a/netfs/unittests/testCore.cpp
+++ b/netfs/unittests/testCore.cpp
@@ -13,18 +13,16 @@
const boost::filesystem::path RootDir(XSTR(ROOT));
const std::string testEndpoint("tcp -h localhost -p 12012");
-char * defaultFuseArgv[] = {
- strdup((RootDir / "defaultFuse.xml:testvol").string().c_str()),
- strdup((RootDir / "test").string().c_str())
-};
-
class Core {
public:
Core() :
daemonHost(testEndpoint, {
"--NetFSD.ConfigPath=" + (RootDir / "defaultDaemon.xml").string()
}),
- fuseHost(testEndpoint, 2, defaultFuseArgv),
+ fuseHost(testEndpoint, {
+ (RootDir / "defaultFuse.xml:testvol").string(),
+ (RootDir / "test").string()
+ }),
ic(daemonHost.ic),
fuse(fuseHost.fuse)
{
@@ -35,7 +33,7 @@ class Core {
FuseMockHost fuseHost;
Ice::CommunicatorPtr ic;
- fuse_operations * fuse;;
+ const fuse_operations * fuse;
};
BOOST_FIXTURE_TEST_SUITE( NetfsCore, Core )
diff --git a/netfs/unittests/testEdgeCases.cpp b/netfs/unittests/testEdgeCases.cpp
index 5c5f671..b1b7a44 100644
--- a/netfs/unittests/testEdgeCases.cpp
+++ b/netfs/unittests/testEdgeCases.cpp
@@ -13,17 +13,15 @@
const boost::filesystem::path RootDir(XSTR(ROOT));
const std::string testEndpoint("tcp -h localhost -p 12014");
-char * defaultFuseArgv[] = {
- strdup((RootDir / "defaultFuse.xml:testvol").string().c_str()),
- strdup((RootDir / "test").string().c_str())
-};
-
BOOST_AUTO_TEST_CASE ( createAndDaemonRestart )
{
MockDaemonHost daemon(testEndpoint, {
"--NetFSD.ConfigPath=" + (RootDir / "defaultDaemon.xml").string()
});
- FuseMockHost fuse(testEndpoint, 2, defaultFuseArgv);
+ FuseMockHost fuse(testEndpoint, {
+ (RootDir / "defaultFuse.xml:testvol").string(),
+ (RootDir / "test").string()
+ });
struct statvfs s;
BOOST_REQUIRE_EQUAL(0, fuse.fuse->statfs("/", &s));
diff --git a/netfs/unittests/testGlacier.cpp b/netfs/unittests/testGlacier.cpp
index 8ee055d..90daaef 100644
--- a/netfs/unittests/testGlacier.cpp
+++ b/netfs/unittests/testGlacier.cpp
@@ -25,16 +25,14 @@ BOOST_AUTO_TEST_CASE ( withRouter )
} BOOST_SCOPE_EXIT_END;
{
- char * glacierFuseArgv[] = {
- strdup((RootDir / "defaultFuse.xml:testvol").string().c_str()),
- strdup((RootDir / "test").string().c_str()),
- strdup("--Ice.Default.Router=Glacier2/router:tcp -h localhost -p 4063")
- };
-
MockDaemonHost daemon(testEndpoint, {
"--NetFSD.ConfigPath=" + (RootDir / "defaultDaemon.xml").string()
});
- FuseMockHost fuse(testEndpoint, 3, glacierFuseArgv);
+ FuseMockHost fuse(testEndpoint, {
+ (RootDir / "defaultFuse.xml:testvol").string(),
+ (RootDir / "test").string(),
+ "--Ice.Default.Router=Glacier2/router:tcp -h localhost -p 4063"
+ });
struct statvfs s;
BOOST_REQUIRE_EQUAL(0, fuse.fuse->statfs("/", &s));