summaryrefslogtreecommitdiff
path: root/netfs/fuse
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2015-06-13 15:17:54 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2015-06-13 15:17:54 +0100
commit5ef75bd1080dafa1c269a2cd1f4e16ae9a7da813 (patch)
tree9a826feaae98a55e013d0e96972ec0df4f6f6372 /netfs/fuse
parentMove to C++0y (diff)
parentMove sandbox setup/teardown into a global fixture. (diff)
downloadnetfs-5ef75bd1080dafa1c269a2cd1f4e16ae9a7da813.tar.bz2
netfs-5ef75bd1080dafa1c269a2cd1f4e16ae9a7da813.tar.xz
netfs-5ef75bd1080dafa1c269a2cd1f4e16ae9a7da813.zip
Merge branch 'netfs-test-refactor'
Diffstat (limited to 'netfs/fuse')
-rw-r--r--netfs/fuse/Jamfile.jam41
-rw-r--r--netfs/fuse/fuseApp.cpp (renamed from netfs/fuse/fuse.cpp)25
-rw-r--r--netfs/fuse/fuseApp.h (renamed from netfs/fuse/fuse.h)9
-rw-r--r--netfs/fuse/fuseConfig.ice (renamed from netfs/fuse/configuration.ice)0
-rw-r--r--netfs/fuse/fuseDirs.cpp6
-rw-r--r--netfs/fuse/fuseFiles.cpp6
-rw-r--r--netfs/fuse/fuseMisc.cpp6
-rw-r--r--netfs/fuse/fuseSystem.cpp4
-rw-r--r--netfs/fuse/netfs.cpp29
-rw-r--r--netfs/fuse/pch.hpp5
10 files changed, 90 insertions, 41 deletions
diff --git a/netfs/fuse/Jamfile.jam b/netfs/fuse/Jamfile.jam
index 8223aa7..c5d3a7a 100644
--- a/netfs/fuse/Jamfile.jam
+++ b/netfs/fuse/Jamfile.jam
@@ -1,5 +1,4 @@
-lib slicer : : : : <include>/usr/include/slicer ;
-lib slicer-xml : : : : <include>/usr/include/slicer ;
+lib fuse : : <name>fuse ;
cpp-pch pch : pch.hpp :
<define>_FILE_OFFSET_BITS=64
@@ -8,46 +7,60 @@ cpp-pch pch : pch.hpp :
<implicit-dependency>../ice//netfsComms
<library>../ice//netfsComms
<library>..//boost_thread
- <library>..//fuse
+ <library>fuse
<library>..//Ice
;
-obj configuration :
- configuration.ice
+lib netfsClientConfiguration :
+ fuseConfig.ice
:
<slicer>yes
<library>..//Ice
<library>..//IceUtil
<library>..//pthread
- <library>slicer
+ <library>..//slicer
: :
<library>..//IceUtil
<library>..//Ice
<library>..//boost_system
- <library>slicer
+ <library>..//slicer
;
-exe netfs :
+lib netfsClient :
pch
- configuration
- [ glob *.cpp ]
+ netfsClientConfiguration
+ [ glob *.cpp : netfs.cpp ]
[ glob ../../libfusepp/fuse*.cpp ]
:
<define>_FILE_OFFSET_BITS=64
<include>../../libmisc
<include>../../libfusepp
<implicit-dependency>../ice//netfsComms
- <implicit-dependency>configuration
+ <library>netfsClientConfiguration
+ <implicit-dependency>netfsClientConfiguration
<library>../ice//netfsComms
<library>../lib//netfsCommon
<library>..//boost_thread
<library>..//boost_system
- <library>..//fuse
<library>..//Ice
<library>..//IceUtil
<library>..//pthread
- <library>slicer
+ <library>..//slicer
<library>..//libxmlpp
- <library>slicer-xml
+ <library>..//slicer-xml
+ : :
+ <include>.
+ <include>../../libfusepp
+ <library>../ice//netfsComms
+ <implicit-dependency>../ice//netfsComms
+ <library>netfsClientConfiguration
+ <implicit-dependency>netfsClientConfiguration
+ <define>_FILE_OFFSET_BITS=64
+ ;
+
+exe netfs :
+ netfs.cpp :
+ <library>netfsClient
+ <library>fuse
;
diff --git a/netfs/fuse/fuse.cpp b/netfs/fuse/fuseApp.cpp
index 7f90710..fdcce57 100644
--- a/netfs/fuse/fuse.cpp
+++ b/netfs/fuse/fuseApp.cpp
@@ -1,6 +1,6 @@
-#include "pch.hpp"
+#include <pch.hpp>
#include <string.h>
-#include "fuse.h"
+#include "fuseApp.h"
#include "lockHelpers.h"
#include "cache.impl.h"
#include <entCache.h>
@@ -34,11 +34,17 @@ NetFS::FuseApp::~FuseApp()
}
}
+NetFS::Client::ConfigurationPtr
+NetFS::FuseApp::ReadConfiguration(const std::string & path) const
+{
+ return Slicer::Deserialize<Slicer::XmlFileDeserializer, NetFS::Client::Configuration>(path);
+}
+
void *
NetFS::FuseApp::init(struct fuse_conn_info *)
{
ic = Ice::initialize(_argc, _argv);
- fc = Slicer::Deserialize<Slicer::XmlFileDeserializer, NetFS::Client::Configuration>(configPath);
+ fc = ReadConfiguration(configPath);
return NULL;
}
@@ -98,7 +104,7 @@ NetFS::FuseApp::connectToVolume()
}
volume = service->connect(e->second->ExportName, "bar");
if (!volume) {
- throw "Invalid filesystem proxy";
+ throw std::runtime_error("Invalid filesystem proxy");
}
}
}
@@ -165,12 +171,9 @@ NetFS::FuseApp::reqEnv()
connectToService();
connectToVolume();
struct fuse_context * c = fuse_get_context();
- return { UserEntCache::instance.getName(c->uid), GroupEntCache::instance.getName(c->gid) };
-}
-
-int
-main(int argc, char* argv[])
-{
- return FuseAppBase::run(argc, argv, new NetFS::FuseApp(argc, argv));
+ NetFS::ReqEnv re;
+ UserEntCache::instance.getName(c->uid, &re.user);
+ GroupEntCache::instance.getName(c->gid, &re.grp);
+ return re;
}
diff --git a/netfs/fuse/fuse.h b/netfs/fuse/fuseApp.h
index 3821285..e514b55 100644
--- a/netfs/fuse/fuse.h
+++ b/netfs/fuse/fuseApp.h
@@ -4,8 +4,8 @@
#include <boost/thread/shared_mutex.hpp>
#include <Ice/Ice.h>
#include <service.h>
-#include "fuseapp.h"
-#include "configuration.h"
+#include "fuseAppBase.h"
+#include "fuseConfig.h"
#include "cache.h"
namespace NetFS {
@@ -78,6 +78,11 @@ namespace NetFS {
// stuff
int onError(const std::exception & err) throw();
+ virtual struct fuse_context * fuse_get_context() = 0;
+
+ protected:
+ virtual NetFS::Client::ConfigurationPtr ReadConfiguration(const std::string &) const;
+
private:
void setProxy(OpenFilePtr, uint64_t & fh);
OpenFilePtr getFileProxy(uint64_t localID) const;
diff --git a/netfs/fuse/configuration.ice b/netfs/fuse/fuseConfig.ice
index db37770..db37770 100644
--- a/netfs/fuse/configuration.ice
+++ b/netfs/fuse/fuseConfig.ice
diff --git a/netfs/fuse/fuseDirs.cpp b/netfs/fuse/fuseDirs.cpp
index 75cb5a5..1da9484 100644
--- a/netfs/fuse/fuseDirs.cpp
+++ b/netfs/fuse/fuseDirs.cpp
@@ -1,5 +1,5 @@
-#include "pch.hpp"
-#include "fuse.h"
+#include <pch.hpp>
+#include "fuseApp.h"
#include "misc.h"
#include "lockHelpers.h"
#include <typeConvert.h>
@@ -79,7 +79,7 @@ NetFS::FuseApp::readdir(const char * p, void * buf, fuse_fill_dir_t filler, off_
statCache.Add(new OptimisticCallCacheable<struct stat, std::string, IceUtil::Shared>(
[asga,this]() {
struct stat s;
- s << AttrSource { volume->end_getattr(asga), boost::bind(&UserEntCache::getID, &UserEntCache::instance, _1), boost::bind(&GroupEntCache::getID, &GroupEntCache::instance, _1) };
+ s << AttrSource { volume->end_getattr(asga), boost::bind(&UserEntCache::getID, &UserEntCache::instance, _1, _2), boost::bind(&GroupEntCache::getID, &GroupEntCache::instance, _1, _2) };
return s;
}, epath, time_t(NULL) + 2));
}
diff --git a/netfs/fuse/fuseFiles.cpp b/netfs/fuse/fuseFiles.cpp
index 9ce260c..c6d4283 100644
--- a/netfs/fuse/fuseFiles.cpp
+++ b/netfs/fuse/fuseFiles.cpp
@@ -1,7 +1,7 @@
-#include "pch.hpp"
+#include <pch.hpp>
#include <string.h>
#include <typeConvert.h>
-#include "fuse.h"
+#include "fuseApp.h"
#include "lockHelpers.h"
#include <entCache.h>
@@ -135,7 +135,7 @@ NetFS::FuseApp::fgetattr(const char *, struct stat * s, fuse_file_info * fi)
{
try {
auto remote = getFileProxy(fi->fh)->remote;
- *s << AttrSource { remote->fgetattr(reqEnv()), boost::bind(&UserEntCache::getID, &UserEntCache::instance, _1), boost::bind(&GroupEntCache::getID, &GroupEntCache::instance, _1) };
+ *s << AttrSource { remote->fgetattr(reqEnv()), boost::bind(&UserEntCache::getID, &UserEntCache::instance, _1, _2), boost::bind(&GroupEntCache::getID, &GroupEntCache::instance, _1, _2) };
return 0;
}
catch (NetFS::SystemError & e) {
diff --git a/netfs/fuse/fuseMisc.cpp b/netfs/fuse/fuseMisc.cpp
index 0e366be..1f999bd 100644
--- a/netfs/fuse/fuseMisc.cpp
+++ b/netfs/fuse/fuseMisc.cpp
@@ -1,5 +1,5 @@
-#include "pch.hpp"
-#include "fuse.h"
+#include <pch.hpp>
+#include "fuseApp.h"
#include <string.h>
#include <typeConvert.h>
#include <entCache.h>
@@ -19,7 +19,7 @@ NetFS::FuseApp::getattr(const char * p, struct stat * s)
*s = *cacehedStat;
}
else {
- *s << AttrSource { volume->getattr(reqEnv(), p), boost::bind(&UserEntCache::getID, &UserEntCache::instance, _1), boost::bind(&GroupEntCache::getID, &GroupEntCache::instance, _1) };
+ *s << AttrSource { volume->getattr(reqEnv(), p), boost::bind(&UserEntCache::getID, &UserEntCache::instance, _1, _2), boost::bind(&GroupEntCache::getID, &GroupEntCache::instance, _1, _2) };
}
return 0;
}
diff --git a/netfs/fuse/fuseSystem.cpp b/netfs/fuse/fuseSystem.cpp
index 0b29d86..e2a9ab7 100644
--- a/netfs/fuse/fuseSystem.cpp
+++ b/netfs/fuse/fuseSystem.cpp
@@ -1,6 +1,6 @@
-#include "pch.hpp"
+#include <pch.hpp>
#include <typeConvert.h>
-#include "fuse.h"
+#include "fuseApp.h"
int
NetFS::FuseApp::statfs(const char * p, struct statvfs * vfs)
diff --git a/netfs/fuse/netfs.cpp b/netfs/fuse/netfs.cpp
new file mode 100644
index 0000000..f700a74
--- /dev/null
+++ b/netfs/fuse/netfs.cpp
@@ -0,0 +1,29 @@
+#include "fuseApp.h"
+
+class FuseImpl : public NetFS::FuseApp {
+ public:
+ FuseImpl(int & argc, char ** argv) : NetFS::FuseApp(argc, argv) { }
+
+ 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
+ {
+ return ::fuse_main(argc, argv, ops, this);
+ }
+
+};
+
+int
+main(int argc, char* argv[])
+{
+ return FuseAppBase::run(argc, argv, new FuseImpl(argc, argv));
+}
+
diff --git a/netfs/fuse/pch.hpp b/netfs/fuse/pch.hpp
index 7cb79ed..2342973 100644
--- a/netfs/fuse/pch.hpp
+++ b/netfs/fuse/pch.hpp
@@ -3,11 +3,10 @@
#define NETFS_FUSE_PCH
#include "../lib/pch.hpp"
-#include "../../libfusepp/fuseapp.h"
+#include "../../libfusepp/fuseAppBase.h"
#include <fuse.h>
+#include <Ice/Ice.h>
#endif
#endif
-
-