mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-12-04 22:00:15 -05:00
add copy_file_range support
This commit is contained in:
parent
c8e178bf71
commit
8cb7195c3e
9 changed files with 425 additions and 144 deletions
71
src/fuse_copy_file_range.cpp
Normal file
71
src/fuse_copy_file_range.cpp
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
Copyright (c) 2019, Antonio SJ Musumeci <trapexit@spawn.link>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "errno.hpp"
|
||||
#include "fileinfo.hpp"
|
||||
#include "fs_copy_file_range.hpp"
|
||||
|
||||
#include <fuse.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
namespace l
|
||||
{
|
||||
static
|
||||
ssize_t
|
||||
copy_file_range(const int fd_in_,
|
||||
off_t offset_in_,
|
||||
const int fd_out_,
|
||||
off_t offset_out_,
|
||||
size_t size_,
|
||||
int flags_)
|
||||
{
|
||||
ssize_t rv;
|
||||
|
||||
rv = fs::copy_file_range(fd_in_,
|
||||
&offset_in_,
|
||||
fd_out_,
|
||||
&offset_out_,
|
||||
size_,
|
||||
flags_);
|
||||
|
||||
return ((rv == -1) ? -errno : rv);
|
||||
}
|
||||
}
|
||||
|
||||
namespace FUSE
|
||||
{
|
||||
ssize_t
|
||||
copy_file_range(const char *path_in_,
|
||||
struct fuse_file_info *ffi_in_,
|
||||
off_t offset_in_,
|
||||
const char *path_out_,
|
||||
struct fuse_file_info *ffi_out_,
|
||||
off_t offset_out_,
|
||||
size_t size_,
|
||||
int flags_)
|
||||
{
|
||||
FileInfo *fi_in = reinterpret_cast<FileInfo*>(ffi_in_->fh);
|
||||
FileInfo *fi_out = reinterpret_cast<FileInfo*>(ffi_out_->fh);
|
||||
|
||||
return l::copy_file_range(fi_in->fd,
|
||||
offset_in_,
|
||||
fi_out->fd,
|
||||
offset_out_,
|
||||
size_,
|
||||
flags_);
|
||||
}
|
||||
}
|
||||
30
src/fuse_copy_file_range.hpp
Normal file
30
src/fuse_copy_file_range.hpp
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
Copyright (c) 2019, Antonio SJ Musumeci <trapexit@spawn.link>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace FUSE
|
||||
{
|
||||
ssize_t
|
||||
copy_file_range(const char *path_in,
|
||||
struct fuse_file_info *ffi_in,
|
||||
off_t offset_in,
|
||||
const char *path_out,
|
||||
struct fuse_file_info *ffi_out,
|
||||
off_t offset_out,
|
||||
size_t size,
|
||||
int flags);
|
||||
}
|
||||
109
src/mergerfs.cpp
109
src/mergerfs.cpp
|
|
@ -22,6 +22,7 @@
|
|||
#include "fuse_access.hpp"
|
||||
#include "fuse_chmod.hpp"
|
||||
#include "fuse_chown.hpp"
|
||||
#include "fuse_copy_file_range.hpp"
|
||||
#include "fuse_create.hpp"
|
||||
#include "fuse_destroy.hpp"
|
||||
#include "fuse_fallocate.hpp"
|
||||
|
|
@ -82,64 +83,56 @@ namespace l
|
|||
ops.flag_nopath = true;
|
||||
ops.flag_utime_omit_ok = true;
|
||||
|
||||
ops.prepare_hide = FUSE::prepare_hide;
|
||||
ops.free_hide = FUSE::free_hide;
|
||||
ops.fchown = FUSE::fchown;
|
||||
ops.fchmod = FUSE::fchmod;
|
||||
ops.futimens = FUSE::futimens;
|
||||
|
||||
ops.access = FUSE::access;
|
||||
ops.bmap = NULL;
|
||||
ops.chmod = FUSE::chmod;
|
||||
ops.chown = FUSE::chown;
|
||||
ops.create = FUSE::create;
|
||||
ops.destroy = FUSE::destroy;
|
||||
ops.fallocate = FUSE::fallocate;
|
||||
ops.fgetattr = FUSE::fgetattr;
|
||||
ops.flock = NULL; // FUSE::flock;
|
||||
ops.flush = FUSE::flush;
|
||||
ops.fsync = FUSE::fsync;
|
||||
ops.fsyncdir = FUSE::fsyncdir;
|
||||
ops.ftruncate = FUSE::ftruncate;
|
||||
ops.getattr = FUSE::getattr;
|
||||
ops.getdir = NULL; /* deprecated; use readdir */
|
||||
ops.getxattr = FUSE::getxattr;
|
||||
ops.init = FUSE::init;
|
||||
ops.ioctl = FUSE::ioctl;
|
||||
ops.link = FUSE::link;
|
||||
ops.listxattr = FUSE::listxattr;
|
||||
ops.lock = NULL;
|
||||
ops.mkdir = FUSE::mkdir;
|
||||
ops.mknod = FUSE::mknod;
|
||||
ops.open = FUSE::open;
|
||||
ops.opendir = FUSE::opendir;
|
||||
ops.poll = NULL;
|
||||
ops.read = (nullrw ?
|
||||
FUSE::read_null :
|
||||
FUSE::read);
|
||||
ops.read_buf = (nullrw ?
|
||||
NULL :
|
||||
FUSE::read_buf);
|
||||
ops.readdir = FUSE::readdir;
|
||||
ops.readlink = FUSE::readlink;
|
||||
ops.release = FUSE::release;
|
||||
ops.releasedir = FUSE::releasedir;
|
||||
ops.removexattr = FUSE::removexattr;
|
||||
ops.rename = FUSE::rename;
|
||||
ops.rmdir = FUSE::rmdir;
|
||||
ops.setxattr = FUSE::setxattr;
|
||||
ops.statfs = FUSE::statfs;
|
||||
ops.symlink = FUSE::symlink;
|
||||
ops.truncate = FUSE::truncate;
|
||||
ops.unlink = FUSE::unlink;
|
||||
ops.utime = NULL; /* deprecated; use utimens() */
|
||||
ops.utimens = FUSE::utimens;
|
||||
ops.write = (nullrw ?
|
||||
FUSE::write_null :
|
||||
FUSE::write);
|
||||
ops.write_buf = (nullrw ?
|
||||
FUSE::write_buf_null :
|
||||
FUSE::write_buf);
|
||||
ops.access = FUSE::access;
|
||||
ops.bmap = NULL;
|
||||
ops.chmod = FUSE::chmod;
|
||||
ops.chown = FUSE::chown;
|
||||
ops.copy_file_range = FUSE::copy_file_range;
|
||||
ops.create = FUSE::create;
|
||||
ops.destroy = FUSE::destroy;
|
||||
ops.fallocate = FUSE::fallocate;
|
||||
ops.fchmod = FUSE::fchmod;
|
||||
ops.fchown = FUSE::fchown;
|
||||
ops.fgetattr = FUSE::fgetattr;
|
||||
ops.flock = NULL; // FUSE::flock;
|
||||
ops.flush = FUSE::flush;
|
||||
ops.free_hide = FUSE::free_hide;
|
||||
ops.fsync = FUSE::fsync;
|
||||
ops.fsyncdir = FUSE::fsyncdir;
|
||||
ops.ftruncate = FUSE::ftruncate;
|
||||
ops.futimens = FUSE::futimens;
|
||||
ops.getattr = FUSE::getattr;
|
||||
ops.getdir = NULL; /* deprecated; use readdir */
|
||||
ops.getxattr = FUSE::getxattr;
|
||||
ops.init = FUSE::init;
|
||||
ops.ioctl = FUSE::ioctl;
|
||||
ops.link = FUSE::link;
|
||||
ops.listxattr = FUSE::listxattr;
|
||||
ops.lock = NULL;
|
||||
ops.mkdir = FUSE::mkdir;
|
||||
ops.mknod = FUSE::mknod;
|
||||
ops.open = FUSE::open;
|
||||
ops.opendir = FUSE::opendir;
|
||||
ops.poll = NULL;
|
||||
ops.prepare_hide = FUSE::prepare_hide;
|
||||
ops.read = (nullrw ? FUSE::read_null : FUSE::read);
|
||||
ops.read_buf = (nullrw ? NULL : FUSE::read_buf);
|
||||
ops.readdir = FUSE::readdir;
|
||||
ops.readlink = FUSE::readlink;
|
||||
ops.release = FUSE::release;
|
||||
ops.releasedir = FUSE::releasedir;
|
||||
ops.removexattr = FUSE::removexattr;
|
||||
ops.rename = FUSE::rename;
|
||||
ops.rmdir = FUSE::rmdir;
|
||||
ops.setxattr = FUSE::setxattr;
|
||||
ops.statfs = FUSE::statfs;
|
||||
ops.symlink = FUSE::symlink;
|
||||
ops.truncate = FUSE::truncate;
|
||||
ops.unlink = FUSE::unlink;
|
||||
ops.utime = NULL; /* deprecated; use utimens() */
|
||||
ops.utimens = FUSE::utimens;
|
||||
ops.write = (nullrw ? FUSE::write_null : FUSE::write);
|
||||
ops.write_buf = (nullrw ? FUSE::write_buf_null : FUSE::write_buf);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue