diff options
Diffstat (limited to 'netfs/daemon/daemonVolume.cpp')
-rw-r--r-- | netfs/daemon/daemonVolume.cpp | 53 |
1 files changed, 26 insertions, 27 deletions
diff --git a/netfs/daemon/daemonVolume.cpp b/netfs/daemon/daemonVolume.cpp index 8ddea5d..2a6cc09 100644 --- a/netfs/daemon/daemonVolume.cpp +++ b/netfs/daemon/daemonVolume.cpp @@ -9,15 +9,14 @@ #include "daemonFile.h" #include "daemonDirectory.h" #include "modeCheck.h" -#include <boost/filesystem/operations.hpp> #include <boost/algorithm/string/predicate.hpp> #include <entCache.h> #include "daemon.h" extern std::map<Ice::Int, int> files; -VolumeServer::VolumeServer(const boost::filesystem::path & r, const EntCache<User> & u, const EntCache<Group> & g) : - root(boost::filesystem::canonical(r)), +VolumeServer::VolumeServer(const std::filesystem::path & r, const EntCache<User> & u, const EntCache<Group> & g) : + root(std::filesystem::canonical(r)), userLookup(u), groupLookup(g), converter(u, g) @@ -39,7 +38,7 @@ VolumeServer::access(const NetFS::ReqEnv re, const std::string path, Ice::Int mo { ModeCheck mc(re, root, userLookup, groupLookup); struct stat s; - boost::filesystem::path p(resolvePath(path)); + std::filesystem::path p(resolvePath(path)); if (::stat(p.c_str(), &s) != 0) { return errno; } @@ -65,7 +64,7 @@ VolumeServer::getattr(const NetFS::ReqEnv re, const std::string path, const Ice: { ModeCheck mc(re, root, userLookup, groupLookup); struct stat s; - boost::filesystem::path p(resolvePath(path)); + std::filesystem::path p(resolvePath(path)); mc.AssertReadParent(p); if (::lstat(p.c_str(), &s) != 0) { throw NetFS::SystemError(errno); @@ -78,7 +77,7 @@ VolumeServer::mknod(const NetFS::ReqEnv re, const std::string path, Ice::Int mod { ModeCheck mc(re, root, userLookup, groupLookup); errno = 0; - boost::filesystem::path p(resolvePath(path)); + std::filesystem::path p(resolvePath(path)); mc.AssertWriteParent(p); if (::mknod(p.c_str(), mode, dev) != 0) { throw NetFS::SystemError(errno); @@ -90,7 +89,7 @@ VolumeServer::symlink(const NetFS::ReqEnv re, const std::string path1, const std { ModeCheck mc(re, root, userLookup, groupLookup); errno = 0; - boost::filesystem::path p(resolvePath(path2)); + std::filesystem::path p(resolvePath(path2)); mc.AssertWriteParent(p); if (::symlink(path1.c_str(), p.c_str()) != 0) { throw NetFS::SystemError(errno); @@ -106,8 +105,8 @@ VolumeServer::link(const NetFS::ReqEnv re, const std::string path1, const std::s { ModeCheck mc(re, root, userLookup, groupLookup); errno = 0; - boost::filesystem::path p1(resolvePath(path1)); - boost::filesystem::path p2(resolvePath(path2)); + std::filesystem::path p1(resolvePath(path1)); + std::filesystem::path p2(resolvePath(path2)); if (::link(p1.c_str(), p2.c_str()) != 0) { throw NetFS::SystemError(errno); } @@ -122,8 +121,8 @@ VolumeServer::rename(const NetFS::ReqEnv re, const std::string from, const std:: { ModeCheck mc(re, root, userLookup, groupLookup); errno = 0; - boost::filesystem::path f(resolvePath(from)); - boost::filesystem::path t(resolvePath(to)); + std::filesystem::path f(resolvePath(from)); + std::filesystem::path t(resolvePath(to)); mc.AssertWriteParent(f); mc.AssertWriteParent(t); if (::rename(f.c_str(), t.c_str()) != 0) { @@ -137,7 +136,7 @@ VolumeServer::readlink(const NetFS::ReqEnv re, const std::string path, const Ice ModeCheck mc(re, root, userLookup, groupLookup); errno = 0; char buf[PATH_MAX]; - boost::filesystem::path p(resolvePath(path)); + std::filesystem::path p(resolvePath(path)); mc.AssertRead(p); ssize_t rc = ::readlink(p.c_str(), buf, PATH_MAX); if (rc == -1) { @@ -151,7 +150,7 @@ VolumeServer::chmod(const NetFS::ReqEnv re, const std::string path, Ice::Int mod { ModeCheck mc(re, root, userLookup, groupLookup); errno = 0; - boost::filesystem::path p(resolvePath(path)); + std::filesystem::path p(resolvePath(path)); mc.AssertWritePerms(p); if (::chmod(p.c_str(), mode) != 0) { throw NetFS::SystemError(errno); @@ -163,7 +162,7 @@ VolumeServer::chown(const NetFS::ReqEnv re, const std::string path, Ice::Int uid { ModeCheck mc(re, root, userLookup, groupLookup); errno = 0; - boost::filesystem::path p(resolvePath(path)); + std::filesystem::path p(resolvePath(path)); mc.AssertWrite(p); if (::lchown(p.c_str(), uid, gid) != 0) { throw NetFS::SystemError(errno); @@ -181,7 +180,7 @@ VolumeServer::utimens(const NetFS::ReqEnv re, const std::string path, times[0].tv_nsec = ns0; times[1].tv_sec = s1; times[1].tv_nsec = ns1; - boost::filesystem::path p(resolvePath(path)); + std::filesystem::path p(resolvePath(path)); mc.AssertWrite(p); if (::utimensat(0, p.c_str(), times, AT_SYMLINK_NOFOLLOW) != 0) { throw NetFS::SystemError(errno); @@ -194,7 +193,7 @@ VolumeServer::statfs(const NetFS::ReqEnv re, const std::string path, const Ice:: ModeCheck mc(re, root, userLookup, groupLookup); errno = 0; struct statvfs s; - boost::filesystem::path p(resolvePath(path)); + std::filesystem::path p(resolvePath(path)); mc.AssertRead(p); if (::statvfs(p.c_str(), &s) != 0) { throw NetFS::SystemError(errno); @@ -207,7 +206,7 @@ VolumeServer::truncate(const NetFS::ReqEnv re, const std::string path, Ice::Long { ModeCheck mc(re, root, userLookup, groupLookup); errno = 0; - boost::filesystem::path p(resolvePath(path)); + std::filesystem::path p(resolvePath(path)); mc.AssertWrite(p); if (::truncate(p.c_str(), size) != 0) { throw NetFS::SystemError(errno); @@ -219,7 +218,7 @@ VolumeServer::unlink(const NetFS::ReqEnv re, const std::string path, const Ice:: { ModeCheck mc(re, root, userLookup, groupLookup); errno = 0; - boost::filesystem::path p(resolvePath(path)); + std::filesystem::path p(resolvePath(path)); mc.AssertWriteParent(p); if (::unlink(p.c_str()) != 0) { throw NetFS::SystemError(errno); @@ -231,7 +230,7 @@ VolumeServer::open(const NetFS::ReqEnv re, const std::string path, Ice::Int flag { ModeCheck mc(re, root, userLookup, groupLookup); errno = 0; - boost::filesystem::path p(resolvePath(path)); + std::filesystem::path p(resolvePath(path)); mc.AssertRead(p); if (flags & O_CREAT) { throw NetFS::SystemError(EINVAL); @@ -249,7 +248,7 @@ VolumeServer::create(const NetFS::ReqEnv re, const std::string path, Ice::Int fl { ModeCheck mc(re, root, userLookup, groupLookup); errno = 0; - boost::filesystem::path p(resolvePath(path)); + std::filesystem::path p(resolvePath(path)); mc.AssertWriteParent(p); int fd = ::open(p.c_str(), O_CREAT | O_EXCL | flags, mode); if (fd == -1) { @@ -269,7 +268,7 @@ VolumeServer::opendir(const NetFS::ReqEnv re, const std::string path, const Ice: { ModeCheck mc(re, root, userLookup, groupLookup); errno = 0; - boost::filesystem::path p(resolvePath(path)); + std::filesystem::path p(resolvePath(path)); mc.AssertRead(p); DIR * od = ::opendir(p.c_str()); if (!od) { @@ -284,7 +283,7 @@ VolumeServer::mkdir(const NetFS::ReqEnv re, const std::string path, Ice::Int mod { ModeCheck mc(re, root, userLookup, groupLookup); errno = 0; - boost::filesystem::path p(resolvePath(path)); + std::filesystem::path p(resolvePath(path)); mc.AssertWriteParent(p); if (::mkdir(p.c_str(), mode) != 0) { throw NetFS::SystemError(errno); @@ -300,15 +299,15 @@ VolumeServer::rmdir(const NetFS::ReqEnv re, const std::string path, const Ice::C { ModeCheck mc(re, root, userLookup, groupLookup); errno = 0; - boost::filesystem::path p(resolvePath(path)); + std::filesystem::path p(resolvePath(path)); mc.AssertWriteParent(p); if (::rmdir(p.c_str()) != 0) { throw NetFS::SystemError(errno); } } -boost::filesystem::path -normalizedAppend(boost::filesystem::path out, const boost::filesystem::path & in) +std::filesystem::path +normalizedAppend(std::filesystem::path out, const std::filesystem::path & in) { unsigned int depth = 0; for(auto e : in) { @@ -319,7 +318,7 @@ normalizedAppend(boost::filesystem::path out, const boost::filesystem::path & in if (depth == 0) { throw NetFS::SystemError(EPERM); } - out.remove_leaf(); + out.remove_filename(); depth -= 1; } else { @@ -330,7 +329,7 @@ normalizedAppend(boost::filesystem::path out, const boost::filesystem::path & in return out; } -boost::filesystem::path +std::filesystem::path VolumeServer::resolvePath(const std::string & path) const { return normalizedAppend(root, path); |