summaryrefslogtreecommitdiff
path: root/netfs/daemonMisc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'netfs/daemonMisc.cpp')
-rw-r--r--netfs/daemonMisc.cpp157
1 files changed, 0 insertions, 157 deletions
diff --git a/netfs/daemonMisc.cpp b/netfs/daemonMisc.cpp
deleted file mode 100644
index e548606..0000000
--- a/netfs/daemonMisc.cpp
+++ /dev/null
@@ -1,157 +0,0 @@
-#include "pchDaemon.hpp"
-#include <errno.h>
-#include <map>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <limits.h>
-#include <fcntl.h>
-#include "daemonFileSystem.h"
-
-extern std::map<Ice::Int, int> files;
-
-Ice::Int
-FileSystemServer::access(const NetFSComms::ReqEnv & re, const std::string & path, Ice::Int mode, const Ice::Current &)
-{
- SessionPtr sess(dgs->getSession(re.tok), true);
- TempPrivs tp(re, &uentries, &gentries);
- boost::filesystem::path p = sess->exportCfg->root / path;
- sess.unlock();
- return ::access(p.string().c_str(), mode);
-}
-
-NetFSComms::Attr
-FileSystemServer::getattr(const NetFSComms::ReqEnv & re, const std::string & path, const Ice::Current &)
-{
- SessionPtr sess(dgs->getSession(re.tok), true);
- TempPrivs tp(re, &uentries, &gentries);
- struct stat s;
- boost::filesystem::path p = sess->exportCfg->root / path;
- sess.unlock();
- if (::lstat(p.string().c_str(), &s) != 0) {
- throw NetFSComms::SystemError(errno);
- }
- NetFSComms::Attr a;
- a.dev = s.st_dev;
- a.inode = s.st_ino;
- a.mode = s.st_mode;
- a.links = s.st_nlink;
- a.uid = uentries.getName(s.st_uid);
- a.gid = gentries.getName(s.st_gid);
- a.rdev = s.st_rdev;
- a.size = s.st_size;
- a.blockSize = s.st_blksize;
- a.blocks = s.st_blocks;
- a.atime = s.st_atime;
- a.mtime = s.st_mtime;
- a.ctime = s.st_ctime;
- return a;
-}
-
-void
-FileSystemServer::symlink(const NetFSComms::ReqEnv & re, const std::string & path1, const std::string & path2, const Ice::Current &)
-{
- SessionPtr sess(dgs->getSession(re.tok), true);
- TempPrivs tp(re, &uentries, &gentries);
- errno = 0;
- boost::filesystem::path p = sess->exportCfg->root / path2;
- sess.unlock();
- if (::symlink(path1.c_str(), p.string().c_str()) != 0) {
- throw NetFSComms::SystemError(errno);
- }
- // s.replicatedRequest = true;
-}
-
-void
-FileSystemServer::link(const NetFSComms::ReqEnv & re, const std::string & path1, const std::string & path2, const Ice::Current &)
-{
- SessionPtr sess(dgs->getSession(re.tok), true);
- TempPrivs tp(re, &uentries, &gentries);
- errno = 0;
- boost::filesystem::path p1 = sess->exportCfg->root / path1;
- boost::filesystem::path p2 = sess->exportCfg->root / path2;
- sess.unlock();
- if (::link(p1.string().c_str(), p2.string().c_str()) != 0) {
- throw NetFSComms::SystemError(errno);
- }
- // s.replicatedRequest = true;
-}
-
-void
-FileSystemServer::rename(const NetFSComms::ReqEnv & re, const std::string & from, const std::string & to, const Ice::Current &)
-{
- SessionPtr sess(dgs->getSession(re.tok), true);
- TempPrivs tp(re, &uentries, &gentries);
- errno = 0;
- boost::filesystem::path f = sess->exportCfg->root / from;
- boost::filesystem::path t = sess->exportCfg->root / to;
- sess.unlock();
- if (::rename(f.string().c_str(), t.string().c_str()) != 0) {
- throw NetFSComms::SystemError(errno);
- }
- // s.replicatedRequest = true;
-}
-
-std::string
-FileSystemServer::readlink(const NetFSComms::ReqEnv & re, const std::string & path, const Ice::Current &)
-{
- SessionPtr sess(dgs->getSession(re.tok), true);
- TempPrivs tp(re, &uentries, &gentries);
- errno = 0;
- char buf[PATH_MAX];
- boost::filesystem::path p = sess->exportCfg->root / path;
- sess.unlock();
- ssize_t rc = ::readlink(p.string().c_str(), buf, PATH_MAX);
- if (rc == -1) {
- throw NetFSComms::SystemError(errno);
- }
- return std::string(buf, rc);
-}
-
-void
-FileSystemServer::chmod(const NetFSComms::ReqEnv & re, const std::string & path, Ice::Int mode, const Ice::Current &)
-{
- SessionPtr sess(dgs->getSession(re.tok), true);
- TempPrivs tp(re, &uentries, &gentries);
- errno = 0;
- boost::filesystem::path p = sess->exportCfg->root / path;
- sess.unlock();
- if (::chmod(p.string().c_str(), mode) != 0) {
- throw NetFSComms::SystemError(errno);
- }
- // s.replicatedRequest = true;
-}
-
-void
-FileSystemServer::chown(const NetFSComms::ReqEnv & re, const std::string & path, Ice::Int uid, Ice::Int gid, const Ice::Current &)
-{
- SessionPtr sess(dgs->getSession(re.tok), true);
- TempPrivs tp(re, &uentries, &gentries);
- errno = 0;
- boost::filesystem::path p = sess->exportCfg->root / path;
- sess.unlock();
- if (::lchown(p.string().c_str(), uid, gid) != 0) {
- throw NetFSComms::SystemError(errno);
- }
- // s.replicatedRequest = true;
-}
-
-void
-FileSystemServer::utimens(const NetFSComms::ReqEnv & re, const std::string & path,
- Ice::Long s0, Ice::Long ns0, Ice::Long s1, Ice::Long ns1, const Ice::Current&)
-{
- SessionPtr sess(dgs->getSession(re.tok), true);
- TempPrivs tp(re, &uentries, &gentries);
- errno = 0;
- struct timespec times[2];
- times[0].tv_sec = s0;
- times[0].tv_nsec = ns0;
- times[1].tv_sec = s1;
- times[1].tv_nsec = ns1;
- boost::filesystem::path p = sess->exportCfg->root / path;
- sess.unlock();
- if (::utimensat(0, p.string().c_str(), times, AT_SYMLINK_NOFOLLOW) != 0) {
- throw NetFSComms::SystemError(errno);
- }
- // s.replicatedRequest = true;
-}
-