From 70acd33956196cfd8d304bcb830032fe98bffd6c Mon Sep 17 00:00:00 2001 From: randomdan Date: Sun, 24 Oct 2010 17:38:40 +0000 Subject: Store the fuse config and initialise the Ice proxies as needed --- netfs/fuse.cpp | 64 +++++++++++++++++++++++++++++++++------------------------- netfs/fuse.h | 4 +++- 2 files changed, 39 insertions(+), 29 deletions(-) diff --git a/netfs/fuse.cpp b/netfs/fuse.cpp index faa2c65..ac35af4 100644 --- a/netfs/fuse.cpp +++ b/netfs/fuse.cpp @@ -8,7 +8,6 @@ #include #include #include "fuse.h" -#include "fuseConfig.h" static FuseAppBase * fuseApp; @@ -78,7 +77,10 @@ static void fuseDestroy(void * x) int NetFS::opt_parse(void *, const char * arg, int key, struct fuse_args *) { - if (arg[0] == '-') { + if (strncmp(arg, "--Ice.", 6) == 0) { + return 0; + } + else if (arg[0] == '-') { return 1; } else if (exportName.empty()) { @@ -95,8 +97,38 @@ NetFS::opt_parse(void *, const char * arg, int key, struct fuse_args *) } NetFS::ReqEnv -NetFS::reqEnv() const +NetFS::reqEnv() { + if (!service || !files || !dirs || !misc || !system) { + FuseConfig::ExportPtr e = fc->exports[exportName]; + const std::string & ep = *e->endpoints.begin(); + + service = NetFSComms::ServicePrx::checkedCast(ic->stringToProxy("Service:" + ep)); + if (!service) { + throw "Invalid service proxy"; + } + authtok = service->connect(exportName, "bar"); + + files = NetFSComms::FilesPrx::checkedCast(ic->stringToProxy("Files:" + ep)); + if (!files) { + throw "Invalid files proxy"; + } + + dirs = NetFSComms::DirsPrx::checkedCast(ic->stringToProxy("Dirs:" + ep)); + if (!dirs) { + throw "Invalid directories proxy"; + } + + misc = NetFSComms::MiscPrx::checkedCast(ic->stringToProxy("Misc:" + ep)); + if (!misc) { + throw "Invalid misc proxy"; + } + + system = NetFSComms::SystemPrx::checkedCast(ic->stringToProxy("System:" + ep)); + if (!files) { + throw "Invalid system proxy"; + } + } return ReqEnv(authtok); } @@ -142,31 +174,7 @@ void * NetFS::init(struct fuse_conn_info *) { ic = Ice::initialize(_argc, _argv); - FuseConfigPtr fc = FuseConfig::Load(configPath); - FuseConfig::ExportPtr e = fc->exports[exportName]; - const std::string & ep = *e->endpoints.begin(); - - service = NetFSComms::ServicePrx::checkedCast(ic->stringToProxy("Service:" + ep)); - if (!service) { - throw "Invalid service proxy"; - } - files = NetFSComms::FilesPrx::checkedCast(ic->stringToProxy("Files:" + ep)); - if (!files) { - throw "Invalid files proxy"; - } - dirs = NetFSComms::DirsPrx::checkedCast(ic->stringToProxy("Dirs:" + ep)); - if (!dirs) { - throw "Invalid directories proxy"; - } - misc = NetFSComms::MiscPrx::checkedCast(ic->stringToProxy("Misc:" + ep)); - if (!misc) { - throw "Invalid misc proxy"; - } - system = NetFSComms::SystemPrx::checkedCast(ic->stringToProxy("System:" + ep)); - if (!files) { - throw "Invalid system proxy"; - } - authtok = service->connect(exportName, "bar"); + fc = FuseConfig::Load(configPath); return NULL; } diff --git a/netfs/fuse.h b/netfs/fuse.h index 6bcc3ae..a4e6335 100644 --- a/netfs/fuse.h +++ b/netfs/fuse.h @@ -4,6 +4,7 @@ #include #include "netfsComms.h" #include "fuseapp.h" +#include "fuseConfig.h" class NetFS : public FuseAppBase { @@ -50,11 +51,12 @@ class NetFS : public FuseAppBase int statfs(const char *, struct statvfs *); // stuff - ReqEnv reqEnv() const; + ReqEnv reqEnv(); int & _argc; char ** _argv; Ice::CommunicatorPtr ic; + FuseConfigPtr fc; NetFSComms::FilesPrx files; NetFSComms::DirsPrx dirs; -- cgit v1.2.3