From 62ef860e426d2e66dfa4b9aaf926b52eade5eec4 Mon Sep 17 00:00:00 2001 From: randomdan Date: Mon, 13 Oct 2014 18:30:38 +0000 Subject: Adds mknod support --- netfs/daemon/daemonVolume.cpp | 12 ++++++++++++ netfs/daemon/daemonVolume.h | 1 + netfs/fuse/fuse.h | 1 + netfs/fuse/fuseMisc.cpp | 12 ++++++++++++ netfs/ice/volume.ice | 1 + 5 files changed, 27 insertions(+) diff --git a/netfs/daemon/daemonVolume.cpp b/netfs/daemon/daemonVolume.cpp index c87b1b0..e21bdd0 100644 --- a/netfs/daemon/daemonVolume.cpp +++ b/netfs/daemon/daemonVolume.cpp @@ -72,6 +72,18 @@ VolumeServer::getattr(const NetFS::ReqEnv & re, const std::string & path, const return a; } +void +VolumeServer::mknod(const NetFS::ReqEnv & re, const std::string & path, Ice::Int mode, Ice::Int dev, const Ice::Current&) +{ + TempPrivs tp(re, root); + errno = 0; + boost::filesystem::path p(resolvePath(path)); + tp.AssertWrite(p.parent_path()); + if (::mknod(p.string().c_str(), mode, dev) != 0) { + throw NetFS::SystemError(errno); + } +} + void VolumeServer::symlink(const NetFS::ReqEnv & re, const std::string & path1, const std::string & path2, const Ice::Current &) { diff --git a/netfs/daemon/daemonVolume.h b/netfs/daemon/daemonVolume.h index e3ca40c..8faa5ff 100644 --- a/netfs/daemon/daemonVolume.h +++ b/netfs/daemon/daemonVolume.h @@ -26,6 +26,7 @@ class VolumeServer : public NetFS::Volume { 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; diff --git a/netfs/fuse/fuse.h b/netfs/fuse/fuse.h index 1f80686..3821285 100644 --- a/netfs/fuse/fuse.h +++ b/netfs/fuse/fuse.h @@ -58,6 +58,7 @@ namespace NetFS { int symlink(const char *, const char *); int unlink(const char *); int utimens(const char *, const struct timespec tv[2]); + int mknod(const char *, mode_t, dev_t); // dirs int opendir(const char * p, struct fuse_file_info * fi); int releasedir(const char *, struct fuse_file_info * fi); diff --git a/netfs/fuse/fuseMisc.cpp b/netfs/fuse/fuseMisc.cpp index d5064f3..0e366be 100644 --- a/netfs/fuse/fuseMisc.cpp +++ b/netfs/fuse/fuseMisc.cpp @@ -64,6 +64,18 @@ NetFS::FuseApp::link(const char * p1, const char * p2) } } +int +NetFS::FuseApp::mknod(const char * p, mode_t mode, dev_t dev) +{ + try { + volume->mknod(reqEnv(), p, mode, dev); + return 0; + } + catch (NetFS::SystemError & e) { + return -e.syserrno; + } +} + int NetFS::FuseApp::symlink(const char * p1, const char * p2) { diff --git a/netfs/ice/volume.ice b/netfs/ice/volume.ice index 7b0e3e0..34f46ba 100644 --- a/netfs/ice/volume.ice +++ b/netfs/ice/volume.ice @@ -29,6 +29,7 @@ module NetFS { void mkdir(ReqEnv env, string path, int mode) throws AuthError, SystemError; void rmdir(ReqEnv env, string path) throws AuthError, SystemError; + void mknod(ReqEnv env, string path, int mode, int dev) throws AuthError, SystemError; void symlink(ReqEnv env, string path1, string path2) throws AuthError, SystemError; void link(ReqEnv env, string path1, string path2) throws AuthError, SystemError; void rename(ReqEnv env, string from, string to) throws AuthError, SystemError; -- cgit v1.2.3