diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-01-12 02:22:15 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-01-12 02:22:15 +0000 |
commit | 155bb1c6cc1227232e0c50469f31bed9c06497f3 (patch) | |
tree | 2f4b0db1113d0271f70ef9bd9d65a1d92b2173a4 /netfs/fuse | |
parent | Use definedDirs (diff) | |
download | netfs-155bb1c6cc1227232e0c50469f31bed9c06497f3.tar.bz2 netfs-155bb1c6cc1227232e0c50469f31bed9c06497f3.tar.xz netfs-155bb1c6cc1227232e0c50469f31bed9c06497f3.zip |
Basic support for configuring the client just with a URLnetfs-1.1.5.3
Diffstat (limited to 'netfs/fuse')
-rw-r--r-- | netfs/fuse/fuseApp.cpp | 37 | ||||
-rw-r--r-- | netfs/fuse/fuseApp.h | 8 |
2 files changed, 37 insertions, 8 deletions
diff --git a/netfs/fuse/fuseApp.cpp b/netfs/fuse/fuseApp.cpp index 4766360..d05bcc0 100644 --- a/netfs/fuse/fuseApp.cpp +++ b/netfs/fuse/fuseApp.cpp @@ -6,6 +6,7 @@ #include <entCache.h> #include <slicer/slicer.h> #include <xml/serializer.h> +#include <uriParse.h> namespace AdHoc { template class Cache<struct stat, std::string>; @@ -69,13 +70,33 @@ void * NetFS::FuseApp::init(struct fuse_conn_info *) { ic = Ice::initialize(args); + fcr = configurator(); + return NULL; +} + +NetFS::Client::ResourcePtr +NetFS::FuseApp::configureFromFile(const std::string & configPath, const std::string & resourceName) const +{ auto fc = ReadConfiguration(configPath); auto e = fc->Resources.find(resourceName); if (e == fc->Resources.end()) { throw std::runtime_error("No such resource: " + resourceName); } - fcr = e->second; - return NULL; + return e->second; +} + +NetFS::Client::ResourcePtr +NetFS::FuseApp::configureFromUri(const std::string & uriString) const +{ + AdHoc::Uri uri(uriString); + + NetFS::Client::ResourcePtr r = new NetFS::Client::Resource(); + r->ExportName = uri.path->string(); + r->Endpoints.push_back(stringbf("%s -h %s -p %d", uri.scheme, uri.host, uri.port ? *uri.port : 4000)); + if (uri.password) { + r->AuthToken = *uri.password; + } + return r; } int @@ -90,10 +111,14 @@ NetFS::FuseApp::opt_parse(void *, const char * arg, int, struct fuse_args *) else if (arg[0] == '-') { return 1; } - else if (resourceName.empty()) { - const char * colon = strchr(arg, ':'); - resourceName = colon + 1; - configPath.assign(arg, colon); + else if (!configurator) { + if (strstr(arg, "://")) { + configurator = boost::bind(&NetFS::FuseApp::configureFromUri, this, arg); + } + else { + const char * colon = strchr(arg, ':'); + configurator = boost::bind(&NetFS::FuseApp::configureFromFile, this, std::string(arg, colon), colon + 1); + } return 0; } else if (mountPoint.empty()) { diff --git a/netfs/fuse/fuseApp.h b/netfs/fuse/fuseApp.h index 3e9f1c4..a97d271 100644 --- a/netfs/fuse/fuseApp.h +++ b/netfs/fuse/fuseApp.h @@ -2,6 +2,7 @@ #define NETFS_FUSE_H #include <boost/thread/shared_mutex.hpp> +#include <boost/function.hpp> #include <Ice/Ice.h> #include <Glacier2/Session.h> #include <service.h> @@ -85,9 +86,14 @@ namespace NetFS { virtual struct fuse_context * fuse_get_context() = 0; protected: + typedef boost::function<Client::ResourcePtr()> Configurator; + Configurator configurator; virtual NetFS::Client::ConfigurationPtr ReadConfiguration(const std::string &) const; + virtual NetFS::Client::ResourcePtr configureFromFile(const std::string &, const std::string &) const; + virtual NetFS::Client::ResourcePtr configureFromUri(const std::string &) const; private: + void setProxy(OpenFilePtr, uint64_t & fh); OpenFilePtr getFileProxy(uint64_t localID) const; void clearFileProxy(uint64_t localID); @@ -109,8 +115,6 @@ namespace NetFS { bool sessionOpened; std::string mountPoint; - std::string resourceName; - std::string configPath; OpenDirs openDirs; int openDirID; |