diff options
-rw-r--r-- | Jamroot.jam | 2 | ||||
-rw-r--r-- | netfs/Jamfile.jam | 7 | ||||
-rw-r--r-- | netfs/daemon/Jamfile.jam | 5 | ||||
-rw-r--r-- | netfs/daemon/daemon.cpp | 6 | ||||
-rw-r--r-- | netfs/daemon/daemonFile.cpp | 6 | ||||
-rw-r--r-- | netfs/daemon/daemonFile.h | 6 | ||||
-rw-r--r-- | netfs/daemon/daemonService.cpp | 8 | ||||
-rw-r--r-- | netfs/daemon/daemonService.h | 2 | ||||
-rw-r--r-- | netfs/daemon/daemonVolume.cpp | 54 | ||||
-rw-r--r-- | netfs/daemon/daemonVolume.h | 36 | ||||
-rw-r--r-- | netfs/fuse/Jamfile.jam | 9 | ||||
-rw-r--r-- | netfs/fuse/fuseApp.cpp | 10 | ||||
-rw-r--r-- | netfs/fuse/fuseApp.h | 19 | ||||
-rw-r--r-- | netfs/fuse/fuseDirs.cpp | 4 | ||||
-rw-r--r-- | netfs/fuse/fuseFiles.cpp | 27 | ||||
-rw-r--r-- | netfs/fuse/fuseFiles.h | 17 | ||||
-rw-r--r-- | netfs/ice/Jamfile.jam | 15 | ||||
-rw-r--r-- | netfs/lib/Jamfile.jam | 1 | ||||
-rw-r--r-- | netfs/unittests/Jamfile.jam | 7 | ||||
-rw-r--r-- | netfs/unittests/mockDaemon.cpp | 2 | ||||
-rw-r--r-- | netfs/unittests/testCore.cpp | 13 |
21 files changed, 131 insertions, 125 deletions
diff --git a/Jamroot.jam b/Jamroot.jam index c008f28..0edd310 100644 --- a/Jamroot.jam +++ b/Jamroot.jam @@ -7,6 +7,8 @@ variant coverage : debug ; project : requirements + <define>ICE_CPP11_MAPPING + <define>_FILE_OFFSET_BITS=64 <cxxflags>"-std=c++17 -fvisibility=hidden -fvisibility-inlines-hidden" <linkflags>"-Wl,-z,defs,--warn-once,--gc-sections" <variant>release:<cxxflags>"-flto=3" diff --git a/netfs/Jamfile.jam b/netfs/Jamfile.jam index e115fe6..fcd463d 100644 --- a/netfs/Jamfile.jam +++ b/netfs/Jamfile.jam @@ -2,10 +2,9 @@ lib boost_filesystem : : <name>boost_filesystem ; lib boost_system : : <name>boost_system ; lib boost_random : : <name>boost_random ; lib boost_thread : : <name>boost_thread ; -lib Ice : : <name>Ice ; -lib IceUtil : : <name>IceUtil ; -lib IceBox : : <name>IceBox ; -lib pthread : : <name>pthread ; +lib Ice : : <name>Ice++11 ; +lib IceBox : : <name>IceBox++11 ; +lib pthread ; lib slicer : : : : <include>/usr/include/slicer ; lib slicer-xml : : : : <include>/usr/include/slicer ; lib adhocutil : : : : <include>/usr/include/adhocutil ; diff --git a/netfs/daemon/Jamfile.jam b/netfs/daemon/Jamfile.jam index af015a5..4669c66 100644 --- a/netfs/daemon/Jamfile.jam +++ b/netfs/daemon/Jamfile.jam @@ -7,8 +7,6 @@ lib netfsd-configuration : <library>../ice//netfs-api <implicit-dependency>../ice//netfs-api <library>..//Ice - <library>..//IceUtil - <library>..//pthread <library>..//boost_filesystem <library>..//boost_system <library>..//slicer @@ -16,7 +14,6 @@ lib netfsd-configuration : <slicer>yes : : <include>. - <library>..//IceUtil <library>..//Ice <library>..//boost_system <library>..//slicer @@ -25,7 +22,6 @@ lib netfsd-configuration : lib netfsd : [ glob *.cpp : daemonConfigImpl.cpp ] : - <define>_FILE_OFFSET_BITS=64 <implicit-dependency>../ice//netfs-api <implicit-dependency>netfsd-configuration <library>netfsd-configuration @@ -36,7 +32,6 @@ lib netfsd : <library>..//boost_filesystem <library>..//boost_system <library>..//Ice - <library>..//IceUtil <library>..//IceBox <library>..//adhocutil <library>..//slicer-xml diff --git a/netfs/daemon/daemon.cpp b/netfs/daemon/daemon.cpp index 8ab7bfe..89843a4 100644 --- a/netfs/daemon/daemon.cpp +++ b/netfs/daemon/daemon.cpp @@ -40,21 +40,21 @@ NetFSDaemon::start(const std::string & name, const Ice::CommunicatorPtr & ic, co LoadConfiguration(props->getProperty("NetFSD.ConfigPath")); adapter = ic->createObjectAdapterWithEndpoints(name, dc->Self->Endpoint); - adapter->add(new ServiceServer(dc->CurrentConfiguration), ic->stringToIdentity("Service")); + adapter->add(std::make_shared<ServiceServer>(dc->CurrentConfiguration), Ice::stringToIdentity("Service")); adapter->activate(); } NetFS::Daemon::ConfigurationPtr NetFSDaemon::ReadConfiguration(const boost::filesystem::path & path) const { - auto s = Slicer::FileDeserializerFactory::createNew(path.extension().string(), path); + auto s = Slicer::DeserializerPtr(Slicer::FileDeserializerFactory::createNew(path.extension().string(), path)); return Slicer::DeserializeAnyWith<NetFS::Daemon::ConfigurationPtr>(s); } void NetFSDaemon::LoadConfiguration(const boost::filesystem::path & path) { - dc = new NetFS::Daemon::RuntimeConfiguration(); + dc = std::make_shared<NetFS::Daemon::RuntimeConfiguration>(); dc->CurrentConfiguration = ReadConfiguration(path); dc->Self = AdHoc::safeMapLookup<NetFS::Daemon::HostNotConfigured>(dc->CurrentConfiguration->Hosts, hostname()); } diff --git a/netfs/daemon/daemonFile.cpp b/netfs/daemon/daemonFile.cpp index a4c903d..ceee92f 100644 --- a/netfs/daemon/daemonFile.cpp +++ b/netfs/daemon/daemonFile.cpp @@ -18,7 +18,7 @@ FileServer::~FileServer() } void -FileServer::ftruncate(const NetFS::ReqEnv & re, Ice::Long size, const Ice::Current&) +FileServer::ftruncate(NetFS::ReqEnv re, Ice::Long size, const Ice::Current&) { (void)re; errno = 0; @@ -28,7 +28,7 @@ FileServer::ftruncate(const NetFS::ReqEnv & re, Ice::Long size, const Ice::Curre } NetFS::Attr -FileServer::fgetattr(const NetFS::ReqEnv & re, const Ice::Current &) +FileServer::fgetattr(NetFS::ReqEnv re, const Ice::Current &) { (void)re; struct stat s; @@ -65,7 +65,7 @@ FileServer::read(Ice::Long offset, Ice::Long size, const Ice::Current&) } void -FileServer::write(Ice::Long offset, Ice::Long size, const NetFS::Buffer & data, const Ice::Current&) +FileServer::write(Ice::Long offset, Ice::Long size, NetFS::Buffer data, const Ice::Current&) { errno = 0; if (pwrite(fd, &data.front(), size, offset) != size) { diff --git a/netfs/daemon/daemonFile.h b/netfs/daemon/daemonFile.h index 5bf20f3..a53301c 100644 --- a/netfs/daemon/daemonFile.h +++ b/netfs/daemon/daemonFile.h @@ -10,11 +10,11 @@ class FileServer : public NetFS::File, EntryTypeConverter { virtual ~FileServer(); virtual void close(const Ice::Current&) override; - virtual void ftruncate(const NetFS::ReqEnv &, Ice::Long size, const Ice::Current&) override; - virtual NetFS::Attr fgetattr(const NetFS::ReqEnv &, const Ice::Current&) override; + virtual void ftruncate(NetFS::ReqEnv, Ice::Long size, const Ice::Current&) override; + virtual NetFS::Attr fgetattr(NetFS::ReqEnv, const Ice::Current&) override; virtual NetFS::Buffer read(Ice::Long offset, Ice::Long size, const Ice::Current&) override; - virtual void write(Ice::Long offset, Ice::Long size, const NetFS::Buffer & data, const Ice::Current&) override; + virtual void write(Ice::Long offset, Ice::Long size, NetFS::Buffer data, const Ice::Current&) override; private: const int fd; diff --git a/netfs/daemon/daemonService.cpp b/netfs/daemon/daemonService.cpp index 20082f1..ec21bac 100644 --- a/netfs/daemon/daemonService.cpp +++ b/netfs/daemon/daemonService.cpp @@ -8,14 +8,14 @@ ServiceServer::ServiceServer(NetFS::Daemon::ConfigurationPtr c) : { } -NetFS::VolumePrx -ServiceServer::connect(const std::string & share, const std::string & authtoken, const Ice::Current & ice) +NetFS::VolumePrxPtr +ServiceServer::connect(std::string share, std::string authtoken, const Ice::Current & ice) { auto ex = AdHoc::safeMapLookup<NetFS::ExportNotFound>(config->Exports, share); if (!ex->AuthToken.empty() && ex->AuthToken != authtoken) { throw NetFS::AuthError(); } - return NetFS::VolumePrx::uncheckedCast(ice.adapter->addFacetWithUUID( - new VolumeServer(ex->RootPath, userLookup, groupLookup), "v01")); + return Ice::uncheckedCast<NetFS::VolumePrx>(ice.adapter->addFacetWithUUID( + std::make_shared<VolumeServer>(ex->RootPath, userLookup, groupLookup), "v01")); } diff --git a/netfs/daemon/daemonService.h b/netfs/daemon/daemonService.h index 09058b6..83684c8 100644 --- a/netfs/daemon/daemonService.h +++ b/netfs/daemon/daemonService.h @@ -10,7 +10,7 @@ class ServiceServer : public NetFS::Service { public: ServiceServer(NetFS::Daemon::ConfigurationPtr c); - virtual NetFS::VolumePrx connect(const std::string & share, const std::string & auth, const Ice::Current&) override; + virtual NetFS::VolumePrxPtr connect(std::string share, std::string auth, const Ice::Current&) override; private: EntCache<User> userLookup; diff --git a/netfs/daemon/daemonVolume.cpp b/netfs/daemon/daemonVolume.cpp index e1295d6..e57c806 100644 --- a/netfs/daemon/daemonVolume.cpp +++ b/netfs/daemon/daemonVolume.cpp @@ -36,7 +36,7 @@ VolumeServer::disconnect(const Ice::Current & ice) } Ice::Int -VolumeServer::access(const NetFS::ReqEnv & re, const std::string & path, Ice::Int mode, const Ice::Current &) +VolumeServer::access(NetFS::ReqEnv re, std::string path, Ice::Int mode, const Ice::Current &) { ModeCheck mc(re, root, userLookup, groupLookup); struct stat s; @@ -62,7 +62,7 @@ VolumeServer::access(const NetFS::ReqEnv & re, const std::string & path, Ice::In } NetFS::Attr -VolumeServer::getattr(const NetFS::ReqEnv & re, const std::string & path, const Ice::Current &) +VolumeServer::getattr(NetFS::ReqEnv re, std::string path, const Ice::Current &) { ModeCheck mc(re, root, userLookup, groupLookup); struct stat s; @@ -75,7 +75,7 @@ VolumeServer::getattr(const NetFS::ReqEnv & re, const std::string & path, const } void -VolumeServer::mknod(const NetFS::ReqEnv & re, const std::string & path, Ice::Int mode, Ice::Int dev, const Ice::Current&) +VolumeServer::mknod(NetFS::ReqEnv re, std::string path, Ice::Int mode, Ice::Int dev, const Ice::Current&) { ModeCheck mc(re, root, userLookup, groupLookup); errno = 0; @@ -87,7 +87,7 @@ VolumeServer::mknod(const NetFS::ReqEnv & re, const std::string & path, Ice::Int } void -VolumeServer::symlink(const NetFS::ReqEnv & re, const std::string & path1, const std::string & path2, const Ice::Current &) +VolumeServer::symlink(NetFS::ReqEnv re, std::string path1, std::string path2, const Ice::Current &) { ModeCheck mc(re, root, userLookup, groupLookup); errno = 0; @@ -103,7 +103,7 @@ VolumeServer::symlink(const NetFS::ReqEnv & re, const std::string & path1, const } void -VolumeServer::link(const NetFS::ReqEnv & re, const std::string & path1, const std::string & path2, const Ice::Current &) +VolumeServer::link(NetFS::ReqEnv re, std::string path1, std::string path2, const Ice::Current &) { ModeCheck mc(re, root, userLookup, groupLookup); errno = 0; @@ -119,7 +119,7 @@ VolumeServer::link(const NetFS::ReqEnv & re, const std::string & path1, const st } void -VolumeServer::rename(const NetFS::ReqEnv & re, const std::string & from, const std::string & to, const Ice::Current &) +VolumeServer::rename(NetFS::ReqEnv re, std::string from, std::string to, const Ice::Current &) { ModeCheck mc(re, root, userLookup, groupLookup); errno = 0; @@ -133,7 +133,7 @@ VolumeServer::rename(const NetFS::ReqEnv & re, const std::string & from, const s } std::string -VolumeServer::readlink(const NetFS::ReqEnv & re, const std::string & path, const Ice::Current &) +VolumeServer::readlink(NetFS::ReqEnv re, std::string path, const Ice::Current &) { ModeCheck mc(re, root, userLookup, groupLookup); errno = 0; @@ -148,7 +148,7 @@ VolumeServer::readlink(const NetFS::ReqEnv & re, const std::string & path, const } void -VolumeServer::chmod(const NetFS::ReqEnv & re, const std::string & path, Ice::Int mode, const Ice::Current &) +VolumeServer::chmod(NetFS::ReqEnv re, std::string path, Ice::Int mode, const Ice::Current &) { ModeCheck mc(re, root, userLookup, groupLookup); errno = 0; @@ -160,7 +160,7 @@ VolumeServer::chmod(const NetFS::ReqEnv & re, const std::string & path, Ice::Int } void -VolumeServer::chown(const NetFS::ReqEnv & re, const std::string & path, Ice::Int uid, Ice::Int gid, const Ice::Current &) +VolumeServer::chown(NetFS::ReqEnv re, std::string path, Ice::Int uid, Ice::Int gid, const Ice::Current &) { ModeCheck mc(re, root, userLookup, groupLookup); errno = 0; @@ -172,7 +172,7 @@ VolumeServer::chown(const NetFS::ReqEnv & re, const std::string & path, Ice::Int } void -VolumeServer::utimens(const NetFS::ReqEnv & re, const std::string & path, +VolumeServer::utimens(NetFS::ReqEnv re, std::string path, Ice::Long s0, Ice::Long ns0, Ice::Long s1, Ice::Long ns1, const Ice::Current&) { ModeCheck mc(re, root, userLookup, groupLookup); @@ -190,7 +190,7 @@ VolumeServer::utimens(const NetFS::ReqEnv & re, const std::string & path, } NetFS::VFS -VolumeServer::statfs(const NetFS::ReqEnv & re, const std::string & path, const Ice::Current&) +VolumeServer::statfs(NetFS::ReqEnv re, std::string path, const Ice::Current&) { ModeCheck mc(re, root, userLookup, groupLookup); errno = 0; @@ -204,7 +204,7 @@ VolumeServer::statfs(const NetFS::ReqEnv & re, const std::string & path, const I } void -VolumeServer::truncate(const NetFS::ReqEnv & re, const std::string & path, Ice::Long size, const Ice::Current&) +VolumeServer::truncate(NetFS::ReqEnv re, std::string path, Ice::Long size, const Ice::Current&) { ModeCheck mc(re, root, userLookup, groupLookup); errno = 0; @@ -216,7 +216,7 @@ VolumeServer::truncate(const NetFS::ReqEnv & re, const std::string & path, Ice:: } void -VolumeServer::unlink(const NetFS::ReqEnv & re, const std::string & path, const Ice::Current&) +VolumeServer::unlink(NetFS::ReqEnv re, std::string path, const Ice::Current&) { ModeCheck mc(re, root, userLookup, groupLookup); errno = 0; @@ -227,8 +227,8 @@ VolumeServer::unlink(const NetFS::ReqEnv & re, const std::string & path, const I } } -NetFS::FilePrx -VolumeServer::open(const NetFS::ReqEnv & re, const std::string & path, Ice::Int flags, const Ice::Current & ice) +NetFS::FilePrxPtr +VolumeServer::open(NetFS::ReqEnv re, std::string path, Ice::Int flags, const Ice::Current & ice) { ModeCheck mc(re, root, userLookup, groupLookup); errno = 0; @@ -241,12 +241,12 @@ VolumeServer::open(const NetFS::ReqEnv & re, const std::string & path, Ice::Int if (fd == -1) { throw NetFS::SystemError(errno); } - return NetFS::FilePrx::uncheckedCast(ice.adapter->addFacetWithUUID( - new FileServer(fd, converter), "v01")); + return Ice::uncheckedCast<NetFS::FilePrx>(ice.adapter->addFacetWithUUID( + std::make_shared<FileServer>(fd, converter), "v01")); } -NetFS::FilePrx -VolumeServer::create(const NetFS::ReqEnv & re, const std::string & path, Ice::Int flags, Ice::Int mode, const Ice::Current & ice) +NetFS::FilePrxPtr +VolumeServer::create(NetFS::ReqEnv re, std::string path, Ice::Int flags, Ice::Int mode, const Ice::Current & ice) { ModeCheck mc(re, root, userLookup, groupLookup); errno = 0; @@ -261,12 +261,12 @@ VolumeServer::create(const NetFS::ReqEnv & re, const std::string & path, Ice::In ::unlink(p.c_str()); throw NetFS::SystemError(errno); } - return NetFS::FilePrx::uncheckedCast(ice.adapter->addFacetWithUUID( - new FileServer(fd, converter), "v01")); + return Ice::uncheckedCast<NetFS::FilePrx>(ice.adapter->addFacetWithUUID( + std::make_shared<FileServer>(fd, converter), "v01")); } -NetFS::DirectoryPrx -VolumeServer::opendir(const NetFS::ReqEnv & re, const std::string & path, const Ice::Current & ice) +NetFS::DirectoryPrxPtr +VolumeServer::opendir(NetFS::ReqEnv re, std::string path, const Ice::Current & ice) { ModeCheck mc(re, root, userLookup, groupLookup); errno = 0; @@ -276,12 +276,12 @@ VolumeServer::opendir(const NetFS::ReqEnv & re, const std::string & path, const if (!od) { throw NetFS::SystemError(errno); } - return NetFS::DirectoryPrx::uncheckedCast(ice.adapter->addFacetWithUUID( - new DirectoryServer(od, converter), "v02")); + return Ice::uncheckedCast<NetFS::DirectoryPrx>(ice.adapter->addFacetWithUUID( + std::make_shared<DirectoryServer>(od, converter), "v02")); } void -VolumeServer::mkdir(const NetFS::ReqEnv & re, const std::string & path, Ice::Int mode, const Ice::Current&) +VolumeServer::mkdir(NetFS::ReqEnv re, std::string path, Ice::Int mode, const Ice::Current&) { ModeCheck mc(re, root, userLookup, groupLookup); errno = 0; @@ -297,7 +297,7 @@ VolumeServer::mkdir(const NetFS::ReqEnv & re, const std::string & path, Ice::Int } void -VolumeServer::rmdir(const NetFS::ReqEnv & re, const std::string & path, const Ice::Current&) +VolumeServer::rmdir(NetFS::ReqEnv re, std::string path, const Ice::Current&) { ModeCheck mc(re, root, userLookup, groupLookup); errno = 0; diff --git a/netfs/daemon/daemonVolume.h b/netfs/daemon/daemonVolume.h index af0e36d..7c27821 100644 --- a/netfs/daemon/daemonVolume.h +++ b/netfs/daemon/daemonVolume.h @@ -12,30 +12,30 @@ class VolumeServer : public NetFS::Volume { VolumeServer(const boost::filesystem::path & root, const EntCache<User> &, const EntCache<Group> &); virtual ~VolumeServer(); - virtual NetFS::DirectoryPrx opendir(const NetFS::ReqEnv &, const std::string & path, const Ice::Current&) override; + virtual NetFS::DirectoryPrxPtr opendir(NetFS::ReqEnv, std::string path, const Ice::Current&) override; - virtual void mkdir(const NetFS::ReqEnv &, const std::string & path, Ice::Int id, const Ice::Current&) override; - virtual void rmdir(const NetFS::ReqEnv &, const std::string & path, const Ice::Current&) override; + virtual void mkdir(NetFS::ReqEnv, std::string path, Ice::Int id, const Ice::Current&) override; + virtual void rmdir(NetFS::ReqEnv, std::string path, const Ice::Current&) override; - virtual void truncate(const NetFS::ReqEnv &, const std::string & path, Ice::Long size, const Ice::Current&) override; + virtual void truncate(NetFS::ReqEnv, std::string path, Ice::Long size, const Ice::Current&) override; - virtual void unlink(const NetFS::ReqEnv &, const std::string & path, const Ice::Current&) override; + virtual void unlink(NetFS::ReqEnv, std::string path, const Ice::Current&) override; - virtual NetFS::FilePrx open(const NetFS::ReqEnv &, const std::string & path, Ice::Int flags, const Ice::Current&) override; - virtual NetFS::FilePrx create(const NetFS::ReqEnv &, const std::string & path, Ice::Int flags, Ice::Int mode, const Ice::Current&) override; + virtual NetFS::FilePrxPtr open(NetFS::ReqEnv, std::string path, Ice::Int flags, const Ice::Current&) override; + virtual NetFS::FilePrxPtr create(NetFS::ReqEnv, std::string path, Ice::Int flags, Ice::Int mode, const Ice::Current&) override; - virtual NetFS::VFS statfs(const NetFS::ReqEnv &, const std::string & path, const Ice::Current&) override; + virtual NetFS::VFS statfs(NetFS::ReqEnv, std::string path, const Ice::Current&) override; - virtual Ice::Int access(const NetFS::ReqEnv &, const std::string & path, Ice::Int mode, const Ice::Current&) override; - virtual NetFS::Attr getattr(const NetFS::ReqEnv &, const std::string & path, const Ice::Current&) override; - virtual void mknod(const NetFS::ReqEnv &, const std::string & path, Ice::Int mode, Ice::Int dev, const Ice::Current&) override; - virtual void symlink(const NetFS::ReqEnv &, const std::string & path1, const std::string & path2, const Ice::Current&) override; - virtual void link(const NetFS::ReqEnv &, const std::string & path1, const std::string & path2, const Ice::Current&) override; - virtual void rename(const NetFS::ReqEnv &, const std::string & path1, const std::string & path2, const Ice::Current&) override; - virtual std::string readlink(const NetFS::ReqEnv &, const std::string & path, const Ice::Current&) override; - virtual void chmod(const NetFS::ReqEnv &, const std::string & path, Ice::Int mode, const Ice::Current&) override; - virtual void chown(const NetFS::ReqEnv &, const std::string & path, Ice::Int uid, Ice::Int gid, const Ice::Current&) override; - virtual void utimens(const NetFS::ReqEnv &, const std::string & path, Ice::Long, Ice::Long, Ice::Long, Ice::Long, const Ice::Current&) override; + virtual Ice::Int access(NetFS::ReqEnv, std::string path, Ice::Int mode, const Ice::Current&) override; + virtual NetFS::Attr getattr(NetFS::ReqEnv, std::string path, const Ice::Current&) override; + virtual void mknod(NetFS::ReqEnv, std::string path, Ice::Int mode, Ice::Int dev, const Ice::Current&) override; + virtual void symlink(NetFS::ReqEnv, std::string path1, std::string path2, const Ice::Current&) override; + virtual void link(NetFS::ReqEnv, std::string path1, std::string path2, const Ice::Current&) override; + virtual void rename(NetFS::ReqEnv, std::string path1, std::string path2, const Ice::Current&) override; + virtual std::string readlink(NetFS::ReqEnv, std::string path, const Ice::Current&) override; + virtual void chmod(NetFS::ReqEnv, std::string path, Ice::Int mode, const Ice::Current&) override; + virtual void chown(NetFS::ReqEnv, std::string path, Ice::Int uid, Ice::Int gid, const Ice::Current&) override; + virtual void utimens(NetFS::ReqEnv, std::string path, Ice::Long, Ice::Long, Ice::Long, Ice::Long, const Ice::Current&) override; virtual void disconnect(const Ice::Current&) override; diff --git a/netfs/fuse/Jamfile.jam b/netfs/fuse/Jamfile.jam index 9df3e89..8e25090 100644 --- a/netfs/fuse/Jamfile.jam +++ b/netfs/fuse/Jamfile.jam @@ -1,7 +1,7 @@ import package ; lib fuse : : <name>fuse ; -lib Glacier2 : : <name>Glacier2 ; +lib Glacier2 : : <name>Glacier2++11 ; lib netfs-client-configuration : fuseConfig.ice @@ -11,12 +11,9 @@ lib netfs-client-configuration : <library>../ice//netfs-api <implicit-dependency>../ice//netfs-api <library>..//Ice - <library>..//IceUtil - <library>..//pthread <library>..//slicer <library>..//adhocutil : : - <library>..//IceUtil <library>..//Ice <library>..//boost_system <library>..//slicer @@ -26,7 +23,6 @@ lib netfs-client : netfs-client-configuration [ glob *.cpp : fuseConfigImpl.cpp netfs.cpp ] : - <define>_FILE_OFFSET_BITS=64 <implicit-dependency>../ice//netfs-api <library>netfs-client-configuration <implicit-dependency>netfs-client-configuration @@ -37,8 +33,6 @@ lib netfs-client : <library>..//boost_filesystem <library>..//Ice <library>Glacier2 - <library>..//IceUtil - <library>..//pthread <library>..//slicer <library>..//adhocutil <library>..//slicer-xml @@ -49,7 +43,6 @@ lib netfs-client : <implicit-dependency>../ice//netfs-api <library>netfs-client-configuration <implicit-dependency>netfs-client-configuration - <define>_FILE_OFFSET_BITS=64 ; exe netfs : diff --git a/netfs/fuse/fuseApp.cpp b/netfs/fuse/fuseApp.cpp index 436df25..32de9a5 100644 --- a/netfs/fuse/fuseApp.cpp +++ b/netfs/fuse/fuseApp.cpp @@ -68,7 +68,7 @@ NetFS::FuseApp::~FuseApp() NetFS::Client::ConfigurationPtr NetFS::FuseApp::ReadConfiguration(const boost::filesystem::path & path) const { - auto s = Slicer::FileDeserializerFactory::createNew(path.extension().string(), path); + auto s = Slicer::DeserializerPtr(Slicer::FileDeserializerFactory::createNew(path.extension().string(), path)); return Slicer::DeserializeAnyWith<NetFS::Client::ConfigurationPtr>(s); } @@ -92,7 +92,7 @@ NetFS::FuseApp::configureFromUri(const std::string & uriString) const { AdHoc::Uri uri(uriString); - NetFS::Client::ResourcePtr r = new NetFS::Client::Resource(); + auto r = std::make_shared<NetFS::Client::Resource>(); r->ExportName = uri.path->string(); r->Endpoints.push_back(IceEndpointFmt::get(uri.scheme, uri.host, uri.port ? *uri.port : 4000)); if (uri.password) { @@ -135,11 +135,11 @@ NetFS::FuseApp::connectSession() { if (!sessionOpened && ic->getDefaultRouter()) { Lock(_lock); - auto router = Glacier2::RouterPrx::checkedCast(ic->getDefaultRouter()); + auto router = Ice::checkedCast<Glacier2::RouterPrx>(ic->getDefaultRouter()); session = router->createSession("", ""); if (int acmTimeout = router->getACMTimeout() > 0) { Ice::ConnectionPtr conn = router->ice_getCachedConnection(); - conn->setACM(acmTimeout, IceUtil::None, Ice::HeartbeatAlways); + conn->setACM(acmTimeout, IceUtil::None, Ice::ACMHeartbeat::HeartbeatAlways); } sessionOpened = true; } @@ -155,7 +155,7 @@ NetFS::FuseApp::connectToService() for (const auto & ep : fcr->Endpoints) { proxyAddr += ":" + ep; } - service = NetFS::ServicePrx::checkedCast(ic->stringToProxy(proxyAddr)); + service = Ice::checkedCast<NetFS::ServicePrx>(ic->stringToProxy(proxyAddr)); if (!service) { throw std::runtime_error("Invalid service proxy: " + proxyAddr); } diff --git a/netfs/fuse/fuseApp.h b/netfs/fuse/fuseApp.h index 41ff9ad..237e711 100644 --- a/netfs/fuse/fuseApp.h +++ b/netfs/fuse/fuseApp.h @@ -20,10 +20,10 @@ namespace NetFS { private: class OpenDir { public: - OpenDir(DirectoryPrx remote, const std::string & path); + OpenDir(DirectoryPrxPtr remote, const std::string & path); - DirectoryPrx remote; - DirectoryV2Prx remoteV2; + DirectoryPrxPtr remote; + DirectoryV2PrxPtr remoteV2; const std::string path; }; typedef std::shared_ptr<OpenDir> OpenDirPtr; @@ -31,15 +31,16 @@ namespace NetFS { class OpenFile { public: - OpenFile(FilePrx remote, const std::string & path, int flags); + OpenFile(FilePrxPtr remote, const std::string & path, int flags); void flush(); void wait() const; - FilePrx remote; + FilePrxPtr remote; const std::string path; const int flags; - typedef boost::icl::interval_map<Ice::Long, Ice::AsyncResultPtr> BGs; + class WriteState; + typedef boost::icl::interval_map<Ice::Long, std::shared_ptr<WriteState>> BGs; static BGs::interval_type range(off_t, size_t); BGs bg; mutable boost::shared_mutex _lock; @@ -125,9 +126,9 @@ namespace NetFS { Client::ResourcePtr fcr; mutable boost::shared_mutex _lock; - NetFS::VolumePrx volume; - NetFS::ServicePrx service; - Glacier2::SessionPrx session; + NetFS::VolumePrxPtr volume; + NetFS::ServicePrxPtr service; + Glacier2::SessionPrxPtr session; bool sessionOpened; std::string mountPoint; diff --git a/netfs/fuse/fuseDirs.cpp b/netfs/fuse/fuseDirs.cpp index 2b51a66..3d77101 100644 --- a/netfs/fuse/fuseDirs.cpp +++ b/netfs/fuse/fuseDirs.cpp @@ -3,9 +3,9 @@ #include <entCache.h> namespace NetFS { -FuseApp::OpenDir::OpenDir(DirectoryPrx r, const std::string & p) : +FuseApp::OpenDir::OpenDir(DirectoryPrxPtr r, const std::string & p) : remote(r), - remoteV2(r->ice_getFacet() >= "v02" ? DirectoryV2Prx::uncheckedCast(r) : nullptr), + remoteV2(r->ice_getFacet() >= "v02" ? Ice::uncheckedCast<DirectoryV2Prx>(r) : nullptr), path(p) { } diff --git a/netfs/fuse/fuseFiles.cpp b/netfs/fuse/fuseFiles.cpp index 222cab0..858a0a9 100644 --- a/netfs/fuse/fuseFiles.cpp +++ b/netfs/fuse/fuseFiles.cpp @@ -1,11 +1,17 @@ #include <string.h> #include "fuseApp.impl.h" +#include "fuseFiles.h" #include "lockHelpers.h" #include <entCache.h> #include <mutex> namespace NetFS { -FuseApp::OpenFile::OpenFile(FilePrx r, const std::string & p, int f) : +FuseApp::OpenFile::WriteState::WriteState() : + future(promise.get_future().share()) +{ +} + +FuseApp::OpenFile::OpenFile(FilePrxPtr r, const std::string & p, int f) : remote(r), path(p), flags(f) @@ -24,7 +30,7 @@ FuseApp::OpenFile::wait() const { SharedLock(_lock); for (const auto & w : bg) { - w.second->waitForCompleted(); + w.second->future.wait(); } } @@ -37,7 +43,7 @@ FuseApp::OpenFile::flush() }; while (auto w = first()) { // background operations are void, so no need to actually get the return value - w->throwLocalException(); + w->future.wait(); } } @@ -123,13 +129,13 @@ FuseApp::waitOnWriteRangeAndThen(size_t s, off_t o, const OpenFilePtr & of, cons else { // Wait for them whilst unlocked _l.release()->unlock(); - std::vector<Ice::AsyncResultPtr> overlap; + std::vector<std::shared_ptr<OpenFile::WriteState>> overlap; overlap.reserve(std::distance(R.first, R.second)); for (auto i = R.first; i != R.second; i++) { overlap.push_back(i->second); } for (const auto & r : overlap) { - r->waitForCompleted(); + r->future.wait(); } // Cause this thread to yield so the callback can acquire _lock usleep(0); @@ -163,12 +169,19 @@ FuseApp::write(const char *, const char * buf, size_t s, off_t o, struct fuse_fi auto remote = of->remote; if (fcr->Async) { waitOnWriteRangeAndThen<void>(s, o, of, [o, s, buf, &of, &remote](const auto & key){ - auto r = remote->begin_write(o, s, Buffer(buf, buf + s), [of,key](const Ice::AsyncResultPtr &) { + auto p = std::make_shared<OpenFile::WriteState>(); + remote->writeAsync(o, s, Buffer(buf, buf + s), [p,of,key]() { + p->promise.set_value(); + ScopeLock(of->_lock) { + of->bg.erase(key); + } + }, [p,of,key](auto e) { + p->promise.set_exception(e); ScopeLock(of->_lock) { of->bg.erase(key); } }); - of->bg.insert({key, r}); + of->bg.insert({key, p}); }); } else { diff --git a/netfs/fuse/fuseFiles.h b/netfs/fuse/fuseFiles.h new file mode 100644 index 0000000..5e05ad2 --- /dev/null +++ b/netfs/fuse/fuseFiles.h @@ -0,0 +1,17 @@ +#ifndef NETFS_FUSE_FILES_H +#define NETFS_FUSE_FILES_H + +#include "fuseApp.h" + +namespace NetFS { + class FuseApp::OpenFile::WriteState { + public: + WriteState(); + + std::promise<void> promise; + std::shared_future<void> future; + }; +} + +#endif + diff --git a/netfs/ice/Jamfile.jam b/netfs/ice/Jamfile.jam index e74b09e..0927965 100644 --- a/netfs/ice/Jamfile.jam +++ b/netfs/ice/Jamfile.jam @@ -1,21 +1,14 @@ import package ; -lib Ice ; -lib IceUtil ; -lib pthread ; - lib netfs-api : [ glob *.cpp *.ice ] : - <define>_FILE_OFFSET_BITS=64 - <library>Ice - <library>IceUtil - <library>pthread + <library>..//Ice + <library>..//pthread <library>..//adhocutil : : <include>. - <library>Ice - <library>IceUtil - <library>pthread + <library>..//Ice + <library>..//pthread ; alias install : install-lib install-slice ; diff --git a/netfs/lib/Jamfile.jam b/netfs/lib/Jamfile.jam index 4ece6b4..4ac7784 100644 --- a/netfs/lib/Jamfile.jam +++ b/netfs/lib/Jamfile.jam @@ -1,7 +1,6 @@ lib netfs-common : [ glob *.cpp ] : - <define>_FILE_OFFSET_BITS=64 <include>../ice <library>..//boost_system <library>..//boost_thread diff --git a/netfs/unittests/Jamfile.jam b/netfs/unittests/Jamfile.jam index dbbecda..5d2bfdc 100644 --- a/netfs/unittests/Jamfile.jam +++ b/netfs/unittests/Jamfile.jam @@ -3,16 +3,13 @@ import testing ; lib boost_utf : : <name>boost_unit_test_framework ; lib boost_system ; lib boost_filesystem ; -lib IceUtil ; -lib Ice ; path-constant me : . ; lib testMocks : [ glob mock*.cpp ] : - <library>IceUtil - <library>Ice + <library>..//Ice <library>boost_system <library>boost_filesystem <library>../daemon//netfsd @@ -55,7 +52,7 @@ run testGlacier.cpp : testGlacier ; run testEdgeCases.cpp - : : : + : --log_level=all : : <dependency>defaultDaemon.xml <dependency>defaultFuse.xml <define>BOOST_TEST_DYN_LINK diff --git a/netfs/unittests/mockDaemon.cpp b/netfs/unittests/mockDaemon.cpp index 9fa1f91..74d4dab 100644 --- a/netfs/unittests/mockDaemon.cpp +++ b/netfs/unittests/mockDaemon.cpp @@ -19,7 +19,7 @@ MockDaemon::ReadConfiguration(const boost::filesystem::path & path) const for(auto e : c->Exports) { e.second->RootPath = TestExportRoot.string(); } - c->Hosts.insert({ "unittest", new NetFS::Daemon::Host(testEndpoint) }); + c->Hosts.insert({ "unittest", std::make_shared<NetFS::Daemon::Host>(testEndpoint) }); return c; } diff --git a/netfs/unittests/testCore.cpp b/netfs/unittests/testCore.cpp index 34e2cec..395644c 100644 --- a/netfs/unittests/testCore.cpp +++ b/netfs/unittests/testCore.cpp @@ -7,6 +7,7 @@ #include <boost/filesystem/path.hpp> #include <ostream> #include <algorithm> +#include <fuseFiles.h> const auto testExport = UniqueExport::get(getpid()); const std::string testEndpoint("tcp -h localhost -p 12012"); @@ -89,7 +90,7 @@ BOOST_AUTO_TEST_CASE(fuse_operations_correct) BOOST_AUTO_TEST_CASE ( daemonInitialised ) { - auto service = NetFS::ServicePrx::checkedCast(ic->stringToProxy("Service")); + auto service = Ice::checkedCast<NetFS::ServicePrx>(ic->stringToProxy("Service")); BOOST_REQUIRE(service); service->ice_ping(); @@ -611,8 +612,6 @@ BOOST_AUTO_TEST_CASE( interval_map_works_how_i_think ) // Used as proof that setting and selecting ranges given an // attempt to write to [offset, offset + size) will find // any currently executing writes that overlap that range. - Ice::CommunicatorPtr ic = Ice::initialize({}); - NetFS::FilePrx fp = NetFS::FilePrx::uncheckedCast(ic->stringToProxy("x:default")); auto r = NetFS::FuseApp::OpenFile::range; NetFS::FuseApp::OpenFile::BGs map; @@ -627,9 +626,9 @@ BOOST_AUTO_TEST_CASE( interval_map_works_how_i_think ) BOOST_REQUIRE(map.empty()); // Pretend we have 3 writes in progress - map.insert({r(5, 10), fp->begin_write(0, 0, {}) }); // [5, 15) - map.insert({r(15, 15), fp->begin_write(0, 0, {}) }); // [15, 30) - map.insert({r(35, 10), fp->begin_write(0, 0, {}) }); // [35, 45) + map.insert({r(5, 10), std::make_shared<NetFS::FuseApp::OpenFile::WriteState>() }); // [5, 15) + map.insert({r(15, 15), std::make_shared<NetFS::FuseApp::OpenFile::WriteState>() }); // [15, 30) + map.insert({r(35, 10), std::make_shared<NetFS::FuseApp::OpenFile::WriteState>() }); // [35, 45) // Then the following writes to [O, O+S) should wait on N pending writes check(0, 1, 0); // Clear before check(100, 10, 0); // Clear after @@ -650,7 +649,5 @@ BOOST_AUTO_TEST_CASE( interval_map_works_how_i_think ) map.erase(r(10, 20)); map.erase(r(35, 10)); BOOST_REQUIRE(map.empty()); - - ic->destroy(); } |