summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2014-06-27 18:31:36 +0000
committerrandomdan <randomdan@localhost>2014-06-27 18:31:36 +0000
commit5931fef7b0cb2317850f5f007dec2f3bbd6a7004 (patch)
treefea2b2dedc47bf9956fb8ace78410160aeb2bca8
parentSwallow _netdev option so it can be used in fstab (diff)
downloadnetfs-5931fef7b0cb2317850f5f007dec2f3bbd6a7004.tar.bz2
netfs-5931fef7b0cb2317850f5f007dec2f3bbd6a7004.tar.xz
netfs-5931fef7b0cb2317850f5f007dec2f3bbd6a7004.zip
Slice configuration for clientnetfs-1.0.0
-rw-r--r--netfs/etc/client.xml30
-rw-r--r--netfs/fuse/Jamfile.jam24
-rw-r--r--netfs/fuse/configuration.ice24
-rw-r--r--netfs/fuse/fuse.cpp23
-rw-r--r--netfs/fuse/fuse.h10
-rw-r--r--netfs/fuse/fuseConfig.cpp29
-rw-r--r--netfs/fuse/fuseConfig.h33
7 files changed, 84 insertions, 89 deletions
diff --git a/netfs/etc/client.xml b/netfs/etc/client.xml
index 9eab8fc..b3af798 100644
--- a/netfs/etc/client.xml
+++ b/netfs/etc/client.xml
@@ -1,18 +1,24 @@
<?xml version="1.0" encoding="ascii"?>
<config>
- <exports>
- <export>
+ <resources>
+ <resource>
<name>portage</name>
- <endpoints>
- <endpoint>tcp -p 4000 -h localhost</endpoint>
- </endpoints>
- </export>
- <export>
+ <resource>
+ <export>portage</export>
+ <endpoints>
+ <endpoint>tcp -p 4000 -h localhost</endpoint>
+ </endpoints>
+ </resource>
+ </resource>
+ <resource>
<name>store</name>
- <endpoints>
- <endpoint>tcp -p 4000 -h defiant</endpoint>
- </endpoints>
- </export>
- </exports>
+ <resource>
+ <export>store</export>
+ <endpoints>
+ <endpoint>tcp -p 4000 -h defiant</endpoint>
+ </endpoints>
+ </resource>
+ </resource>
+ </resources>
</config>
diff --git a/netfs/fuse/Jamfile.jam b/netfs/fuse/Jamfile.jam
index 40a86f3..8814a9d 100644
--- a/netfs/fuse/Jamfile.jam
+++ b/netfs/fuse/Jamfile.jam
@@ -1,3 +1,6 @@
+lib slicer : : : : <include>/usr/include/slicer ;
+lib slicer-xml : : : : <include>/usr/include/slicer ;
+
cpp-pch pch : pch.hpp :
<define>_FILE_OFFSET_BITS=64
<include>../../libmisc
@@ -7,13 +10,26 @@ cpp-pch pch : pch.hpp :
<library>..//boost_thread
<library>..//fuse
<library>..//Ice
- <library>..//libxml2
;
+obj configuration :
+ configuration.ice
+ :
+ <slicer>yes
+ <library>..//Ice
+ <library>..//IceUtil
+ <library>..//pthread
+ <library>slicer
+ : :
+ <library>..//IceUtil
+ <library>..//Ice
+ <library>..//boost_system
+ <library>slicer
+ ;
exe netfs :
pch
- ../../libmisc/xml.cpp
+ configuration
[ glob *.cpp ]
[ glob ../../libfusepp/fuse*.cpp ]
:
@@ -21,6 +37,7 @@ exe netfs :
<include>../../libmisc
<include>../../libfusepp
<implicit-dependency>../ice//netfsComms
+ <implicit-dependency>configuration
<library>../ice//netfsComms
<library>../lib//netfsCommon
<library>..//boost_thread
@@ -29,6 +46,7 @@ exe netfs :
<library>..//Ice
<library>..//IceUtil
<library>..//pthread
- <library>..//libxml2
+ <library>slicer
+ <library>slicer-xml
;
diff --git a/netfs/fuse/configuration.ice b/netfs/fuse/configuration.ice
new file mode 100644
index 0000000..6f76b37
--- /dev/null
+++ b/netfs/fuse/configuration.ice
@@ -0,0 +1,24 @@
+module NetFS {
+ module Client {
+ ["slicer:element:endpoint"]
+ sequence<string> EndpointList;
+
+ class Resource {
+ ["slicer:name:export"]
+ string ExportName;
+
+ ["slicer:name:endpoints"]
+ EndpointList Endpoints;
+ };
+
+ ["slicer:key:name","slicer:value:resource","slicer:item:resource"]
+ dictionary<string, Resource> ResourceMap;
+
+ ["slicer:root:config"]
+ class Configuration {
+ ["slicer:name:resources"]
+ ResourceMap Resources;
+ };
+ };
+};
+
diff --git a/netfs/fuse/fuse.cpp b/netfs/fuse/fuse.cpp
index 9887e7b..c0aca45 100644
--- a/netfs/fuse/fuse.cpp
+++ b/netfs/fuse/fuse.cpp
@@ -5,6 +5,8 @@
#include "lockHelpers.h"
#include "cache.impl.h"
#include <entCache.h>
+#include <slicer/slicer.h>
+#include <xml/serializer.h>
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>;
@@ -35,7 +37,7 @@ void *
NetFS::FuseApp::init(struct fuse_conn_info *)
{
ic = Ice::initialize(_argc, _argv);
- fc = FuseConfig::Load(configPath);
+ fc = Slicer::Deserialize<Slicer::Xml, NetFS::Client::Configuration>(configPath);
return NULL;
}
@@ -51,9 +53,9 @@ NetFS::FuseApp::opt_parse(void *, const char * arg, int, struct fuse_args *)
else if (arg[0] == '-') {
return 1;
}
- else if (exportName.empty()) {
+ else if (resourceName.empty()) {
const char * colon = strchr(arg, ':');
- exportName = colon + 1;
+ resourceName = colon + 1;
configPath.assign(arg, colon);
return 0;
}
@@ -69,12 +71,15 @@ NetFS::FuseApp::connectToService()
{
if (!service) {
Lock(_lock);
- FuseConfig::ExportPtr e = fc->exports[exportName];
- const std::string & ep = *e->endpoints.begin();
+ auto e = fc->Resources.find(resourceName);
+ if (e == fc->Resources.end()) {
+ throw std::runtime_error("No such resource: " + resourceName);
+ }
+ const std::string & ep = e->second->Endpoints.front();
service = NetFS::ServicePrx::checkedCast(ic->stringToProxy("Service:" + ep));
if (!service) {
- throw "Invalid service proxy";
+ throw std::runtime_error("Invalid service proxy: " + ep);
}
}
}
@@ -83,7 +88,11 @@ void
NetFS::FuseApp::connectToVolume()
{
if (!volume) {
- volume = service->connect(exportName, "bar");
+ auto e = fc->Resources.find(resourceName);
+ if (e == fc->Resources.end()) {
+ throw std::runtime_error("No such export: " + resourceName);
+ }
+ volume = service->connect(e->second->ExportName, "bar");
if (!volume) {
throw "Invalid filesystem proxy";
}
diff --git a/netfs/fuse/fuse.h b/netfs/fuse/fuse.h
index 859c3e6..1f80686 100644
--- a/netfs/fuse/fuse.h
+++ b/netfs/fuse/fuse.h
@@ -1,11 +1,11 @@
-#ifndef FUSE_H
-#define FUSE_H
+#ifndef NETFS_FUSE_H
+#define NETFS_FUSE_H
#include <boost/thread/shared_mutex.hpp>
#include <Ice/Ice.h>
#include <service.h>
#include "fuseapp.h"
-#include "fuseConfig.h"
+#include "configuration.h"
#include "cache.h"
namespace NetFS {
@@ -91,14 +91,14 @@ namespace NetFS {
int & _argc;
char ** _argv;
Ice::CommunicatorPtr ic;
- FuseConfigPtr fc;
+ Client::ConfigurationPtr fc;
mutable boost::shared_mutex _lock;
NetFS::VolumePrx volume;
NetFS::ServicePrx service;
std::string mountPoint;
- std::string exportName;
+ std::string resourceName;
std::string configPath;
OpenDirs openDirs;
diff --git a/netfs/fuse/fuseConfig.cpp b/netfs/fuse/fuseConfig.cpp
deleted file mode 100644
index 168550e..0000000
--- a/netfs/fuse/fuseConfig.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-#include "pch.hpp"
-#include "fuseConfig.h"
-#include <string.h>
-
-FuseConfigPtr
-FuseConfig::Load(const std::string & path)
-{
- xmlDoc * doc = xmlReadFile(path.c_str(), NULL, 0);
- FuseConfigPtr dc = new FuseConfig(doc->children);
- xmlFreeDoc(doc);
- return dc;
-}
-
-FuseConfig::FuseConfig(xmlNodePtr conf)
-{
- foreachxml(exp, xmlGetNode(conf, "exports"), "export") {
- ExportPtr e = new Export(exp);
- exports[e->name] = e;
- }
-}
-
-FuseConfig::Export::Export(xmlNodePtr conf) :
- name(xmlGetNodeValue(conf, "name"))
-{
- foreachxml(ep, xmlGetNode(conf, "endpoints"), "endpoint") {
- endpoints.insert(xmlGetNodeValue(ep));
- }
-}
-
diff --git a/netfs/fuse/fuseConfig.h b/netfs/fuse/fuseConfig.h
deleted file mode 100644
index 32f25b4..0000000
--- a/netfs/fuse/fuseConfig.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef FUSECONFIG_H
-#define FUSECONFIG_H
-
-#include <string>
-#include <map>
-#include <set>
-#include <IceUtil/Shared.h>
-#include "xml.h"
-
-class FuseConfig : public IceUtil::Shared {
- public:
- class Export;
- typedef IceUtil::Handle<Export> ExportPtr;
- typedef std::map<std::string, ExportPtr> ExportMap;
- class Export : public IceUtil::Shared {
- public:
- typedef std::set<std::string> Endpoints;
- Export(xmlNodePtr);
-
- std::string name;
- Endpoints endpoints;
- };
-
- FuseConfig(xmlNodePtr);
- static IceUtil::Handle<FuseConfig> Load(const std::string & path);
-
- ExportMap exports;
-};
-typedef IceUtil::Handle<FuseConfig> FuseConfigPtr;
-
-#endif
-
-