aboutsummaryrefslogtreecommitdiff
path: root/src/zencore/include
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2026-03-16 10:16:46 +0100
committerGitHub Enterprise <[email protected]>2026-03-16 10:16:46 +0100
commite5b97e8e769108ba45d6a064a46f892b68f1e950 (patch)
treec0d9abb1191b0caf3d35fdaa1c1f267c17a0bf85 /src/zencore/include
parentadd buildid updates to oplog and builds test scripts (#838) (diff)
downloadzen-e5b97e8e769108ba45d6a064a46f892b68f1e950.tar.xz
zen-e5b97e8e769108ba45d6a064a46f892b68f1e950.zip
block/file cloning support for macOS / Linux (#786)
- Add block cloning (copy-on-write) support for Linux and macOS to complement the existing Windows (ReFS) implementation - **Linux**: `TryCloneFile` via `FICLONE` ioctl, `CloneQueryInterface` with range cloning via `FICLONERANGE` (Btrfs/XFS) - **macOS**: `TryCloneFile` via `clonefile()` syscall (APFS), `SupportsBlockRefCounting` via `VOL_CAP_INT_CLONE`. `CloneQueryInterface` is not implemented as macOS lacks a sub-file range clone API - Promote `ScopedFd` to file scope for broader use in filesystem code - Add test scripts for block cloning validation on Linux (Btrfs via loopback) and macOS (APFS) - Also added test script for testing on Windows (ReFS)
Diffstat (limited to 'src/zencore/include')
-rw-r--r--src/zencore/include/zencore/filesystem.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/zencore/include/zencore/filesystem.h b/src/zencore/include/zencore/filesystem.h
index 16e2b59f8..6dc159a83 100644
--- a/src/zencore/include/zencore/filesystem.h
+++ b/src/zencore/include/zencore/filesystem.h
@@ -187,6 +187,14 @@ void ScanFile(void* NativeHandle,
void WriteFile(void* NativeHandle, const void* Data, uint64_t Size, uint64_t FileOffset, uint64_t ChunkSize, std::error_code& Ec);
void ReadFile(void* NativeHandle, void* Data, uint64_t Size, uint64_t FileOffset, uint64_t ChunkSize, std::error_code& Ec);
+// Interface for sub-file range cloning on filesystems that support copy-on-write.
+// GetCloneQueryInterface() returns nullptr on platforms without range clone support.
+//
+// Platform capabilities:
+// Windows (ReFS) - True CoW range cloning via FSCTL_DUPLICATE_EXTENTS_TO_FILE.
+// Linux (Btrfs/XFS) - True CoW range cloning via FICLONERANGE ioctl.
+// macOS (APFS) - Not implemented. No sub-file range clone API exists.
+// Whole-file CoW cloning is available via TryCloneFile (clonefile syscall).
class CloneQueryInterface
{
public: