summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2010-10-24 17:38:40 +0000
committerrandomdan <randomdan@localhost>2010-10-24 17:38:40 +0000
commit70acd33956196cfd8d304bcb830032fe98bffd6c (patch)
tree0c042daca1f8e1bda24d73deb74a3dfe227063cc
parentSend a request environment object container the auth token, and now with cont... (diff)
downloadnetfs-70acd33956196cfd8d304bcb830032fe98bffd6c.tar.bz2
netfs-70acd33956196cfd8d304bcb830032fe98bffd6c.tar.xz
netfs-70acd33956196cfd8d304bcb830032fe98bffd6c.zip
Store the fuse config and initialise the Ice proxies as needed
-rw-r--r--netfs/fuse.cpp64
-rw-r--r--netfs/fuse.h4
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 <pwd.h>
#include <grp.h>
#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 <Ice/Ice.h>
#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;