--- /dev/null
+/// @file VfsXattrFactory.cpp
+/// @brief VFS Plugin entry point.
+#include <cstring>
+#include <dmlite/cpp/dmlite.h>
+#include <netdb.h>
+#include <stdlib.h>
+#include <sys/utsname.h>
+
+#include "Vfs.h"
+#include "VfsXattrFactory.h"
+#include "VfsAuthn.h"
+#include "VfsNs.h"
+#include "VfsDriver.h"
+#include "VfsIO.h"
+#include "VfsPool.h"
+
+
+using namespace dmlite;
+
+
+
+std::string VfsXattrFactory::getImplId() const throw ()
+{
+ return "VfsXattrFactory";
+}
+
+
+VfsXattrFactory::VfsXattrFactory() throw (DmException)
+{
+ struct utsname hname;
+
+ // Hostname
+ wrapCall(uname(&hname));
+
+ // Domain
+ struct hostent* hent = gethostbyname(hname.nodename);
+
+ this->hostName_ = hent->h_name;
+
+ openlog("dmlite-vfs-plugin", LOG_PID, LOG_USER);
+}
+
+
+
+VfsXattrFactory::~VfsXattrFactory()
+{
+ // Nothing
+}
+
+
+
+void VfsXattrFactory::configure(const std::string& key, const std::string& value) throw (DmException)
+{
+ if (key == "TokenPassword") {
+ this->tokenPasswd_ = value;
+ }
+ else if (key == "TokenId") {
+ if (strcasecmp(value.c_str(), "ip") == 0)
+ this->tokenUseIp_ = true;
+ else
+ this->tokenUseIp_ = false;
+ }
+ else if (key == "TokenLife") {
+ this->tokenLife_ = (unsigned)atoi(value.c_str());
+ }
+ else if (key == "Allow") {
+ this->allow_ = value;
+ }
+ else if (key == "Deny") {
+ this->deny_ = value;
+ }
+ else if (key == "AllowWrite") {
+ this->allowWrite_ = value;
+ }
+ else if (key == "DenyWrite") {
+ this->denyWrite_ = value;
+ }
+ else if (key == "NSPrefix") {
+ this->nsPrefix_ = value;
+ }
+ else if (key == "DiskPrefix") {
+ this->diskPrefix_ = value;
+ }
+ else
+ throw DmException(DMLITE_CFGERR(DMLITE_UNKNOWN_KEY),
+ "Unrecognised option " + key);
+}
+
+
+
+Catalog* VfsXattrFactory::createCatalog(PluginManager*) throw (DmException)
+{
+ debug("");
+ return new VfsCatalog(this->hostName_, this->nsPrefix_, this->allow_, this->deny_, this->allowWrite_, this->denyWrite_);
+}
+
+
+
+PoolManager* VfsXattrFactory::createPoolManager(PluginManager*) throw (DmException)
+{
+ debug("");
+ return new VfsPoolManager(this->hostName_,
+ this->tokenPasswd_, this->tokenUseIp_,
+ this->tokenLife_);
+}
+
+
+
+std::string VfsXattrFactory::implementedPool() throw ()
+{
+ return "vfs";
+}
+
+
+
+PoolDriver* VfsXattrFactory::createPoolDriver() throw (DmException)
+{
+ debug("");
+ return new VfsPoolDriver(this->hostName_, this->nsPrefix_,
+ this->tokenPasswd_, this->tokenUseIp_,
+ this->tokenLife_);
+}
+
+
+
+IODriver* VfsXattrFactory::createIODriver(PluginManager*) throw (DmException)
+{
+ debug("");
+ return new VfsIODriver(this->diskPrefix_, this->tokenPasswd_, this->tokenUseIp_);
+}
+
+
+
+Authn* VfsXattrFactory::createAuthn(PluginManager*) throw (DmException)
+{
+ debug("");
+ return new VfsAuthn(this->nsPrefix_);
+}
+
+
+
+static void registerPluginVfsAuthn(PluginManager* pm) throw(DmException)
+{
+ VfsXattrFactory* vfsXattrFactory = new VfsXattrFactory();
+
+ pm->registerAuthnFactory(vfsXattrFactory);
+}
+
+
+
+static void registerPluginVfsCatalog(PluginManager* pm) throw(DmException)
+{
+ VfsXattrFactory* vfsXattrFactory = new VfsXattrFactory();
+
+ pm->registerCatalogFactory(vfsXattrFactory);
+ pm->registerPoolManagerFactory(vfsXattrFactory);
+}
+
+
+
+static void registerPluginVfsDisk(PluginManager* pm) throw(DmException)
+{
+ VfsXattrFactory* vfsXattrFactory = new VfsXattrFactory();
+
+ pm->registerPoolDriverFactory(vfsXattrFactory);
+ pm->registerIOFactory(vfsXattrFactory);
+}
+
+
+
+
+/// This is what the PluginManager looks for
+PluginIdCard plugin_vfs_authn = {
+ PLUGIN_ID_HEADER,
+ registerPluginVfsAuthn
+};
+PluginIdCard plugin_vfs_ns = {
+ PLUGIN_ID_HEADER,
+ registerPluginVfsCatalog
+};
+PluginIdCard plugin_vfs_disk = {
+ PLUGIN_ID_HEADER,
+ registerPluginVfsDisk
+};
--- /dev/null
+/// @file VfsXattrFactory.h
+/// @brief Filesystem plugin with user extended attributes metadata extensions.
+#ifndef VFS_XATTR_FACTORY_H
+#define VFS_XATTR_FACTORY_H
+
+#include <syslog.h>
+#include <dmlite/cpp/authn.h>
+#include <dmlite/cpp/catalog.h>
+#include <dmlite/cpp/dmlite.h>
+#include <dmlite/cpp/io.h>
+#include <dmlite/cpp/poolmanager.h>
+
+
+namespace dmlite {
+
+ class VfsXattrFactory: public CatalogFactory, public IOFactory,
+ public PoolManagerFactory, public PoolDriverFactory,
+ public AuthnFactory
+ {
+ public:
+ VfsXattrFactory() throw (DmException);
+ ~VfsXattrFactory();
+
+ void configure(const std::string& key, const std::string& value) throw (DmException);
+
+ Catalog* createCatalog(PluginManager*) throw (DmException);
+ PoolManager* createPoolManager(PluginManager*) throw (DmException);
+
+ std::string implementedPool(void) throw();
+ PoolDriver* createPoolDriver(void) throw (DmException);
+
+ IODriver* createIODriver(PluginManager*) throw (DmException);
+
+ Authn* createAuthn(PluginManager *) throw (DmException);
+
+ protected:
+ std::string hostName_;
+ std::string nsPrefix_;
+ std::string diskPrefix_;
+
+ std::string tokenPasswd_;
+ bool tokenUseIp_;
+ unsigned tokenLife_;
+ std::string allow_, deny_, allowWrite_, denyWrite_;
+
+ private:
+ std::string getImplId(void) const throw ();
+ };
+
+};
+
+#endif // VFS_XATTR_FACTORY_H