diff options
Diffstat (limited to 'netfs/fuse/fuseFiles.cpp')
-rw-r--r-- | netfs/fuse/fuseFiles.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/netfs/fuse/fuseFiles.cpp b/netfs/fuse/fuseFiles.cpp index 3ecb37f..a44f56e 100644 --- a/netfs/fuse/fuseFiles.cpp +++ b/netfs/fuse/fuseFiles.cpp @@ -210,6 +210,31 @@ namespace NetFS { } } + FuseApp::OpenFile::BlockSizes + FuseApp::OpenFile::blockSizes(size_t total, size_t max) noexcept + { + if (max >= total) { // Simple case, all in remainder block + return {total, 0, 0}; + } + else if (total % max == 0) { // Simplish case, multiples of max + return {0, max, total / max}; + } + else { + const auto blocks = (total / max); + const auto blockSize = (total / (blocks + 1)) + 1; + const auto batchTotal = blockSize * blocks; + const auto remainder = total - batchTotal; + + return {remainder, blockSize, blocks}; + } + } + + size_t + FuseApp::OpenFile::BlockSizes::total() const noexcept + { + return size1 + (sizeN * N); + } + ssize_t FuseApp::copy_file_range(const char *, struct fuse_file_info * fi_in, off_t offset_in, const char *, struct fuse_file_info * fi_out, off_t offset_out, size_t size, int flags) |