summaryrefslogtreecommitdiff
path: root/netfs/daemon
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2020-03-29 10:40:39 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2020-03-29 10:40:39 +0100
commit1fd518aac79d26a4cd40d7d0b99f7302c45a97c7 (patch)
treeacc8d137442436d1bb7832addd01315a9472fce4 /netfs/daemon
parentFix FUSE version number (diff)
downloadnetfs-1fd518aac79d26a4cd40d7d0b99f7302c45a97c7.tar.bz2
netfs-1fd518aac79d26a4cd40d7d0b99f7302c45a97c7.tar.xz
netfs-1fd518aac79d26a4cd40d7d0b99f7302c45a97c7.zip
Implement copy range
Diffstat (limited to 'netfs/daemon')
-rw-r--r--netfs/daemon/daemonFile.cpp20
-rw-r--r--netfs/daemon/daemonFile.h1
2 files changed, 21 insertions, 0 deletions
diff --git a/netfs/daemon/daemonFile.cpp b/netfs/daemon/daemonFile.cpp
index 48730bc..ec96bc3 100644
--- a/netfs/daemon/daemonFile.cpp
+++ b/netfs/daemon/daemonFile.cpp
@@ -6,6 +6,7 @@
#include <sys/stat.h>
#include "daemonFile.h"
#include <entCache.h>
+#include <unistd.h>
FileServer::FileServer(int f, EntryTypeConverter & t) :
EntryTypeConverter(t),
@@ -69,3 +70,22 @@ FileServer::write(Ice::Long offset, Ice::Long size, const NetFS::Buffer data, co
}
}
+Ice::Long
+FileServer::copyrange(NetFS::FilePrxPtr to, Ice::Long offsrc, Ice::Long offdst, Ice::Long size, Ice::Int flags, const Ice::Current& ice)
+{
+ if (auto obj = ice.adapter->findByProxy(to);
+ auto file = std::dynamic_pointer_cast<FileServer>(obj)) {
+ errno = 0;
+ off_t src = offsrc, dst = offdst;
+ if (auto rtn = copy_file_range(fd, &src, file->fd, &dst, size, flags);
+ rtn != -1) {
+ return rtn;
+ }
+ throw NetFS::SystemError(errno);
+ }
+ else {
+ to->write(offdst, size, read(offsrc, size, ice));
+ return size;
+ }
+}
+
diff --git a/netfs/daemon/daemonFile.h b/netfs/daemon/daemonFile.h
index ee4ae7d..d61e37d 100644
--- a/netfs/daemon/daemonFile.h
+++ b/netfs/daemon/daemonFile.h
@@ -14,6 +14,7 @@ class FileServer : public NetFS::File, EntryTypeConverter {
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 Ice::Long copyrange(NetFS::FilePrxPtr, Ice::Long, Ice::Long, Ice::Long, Ice::Int, const Ice::Current&) override;
private:
const int fd;