A Ruby gem that implements reflink copy (copy-on-write) for supported file systems on Linux.
- Ruby 72.2%
- C 27.8%
|
|
||
|---|---|---|
| ext/clonefile | Whitespace | |
| lib | Rescue more errors from man 2 ioctl_ficlone. | |
| LICENSES | Update LICENSE headers to REUSE 3.0 | |
| .gitignore | Rename to clonefile. Add macOS/APFS support. | |
| BUILDING.md | Rename to clonefile. Add macOS/APFS support. | |
| clonefile.gemspec | Set version to 0.5.3. | |
| Rakefile | Resolve RuboCop offenses. | |
| README.md | Add info link on file cloning | |
Clonefile is a Ruby gem for cloning files on supported copy-on-write (COW) file systems. Learn more about file cloning.
On Linux 5.7 and later, the gem performers the same operation as cp --reflink (using FICLONE). As of kernel 5.7, only Btrfs, OCFS2, and XFS supports ficlone.
This gem only supports creating reflinks to whole files and not ranges within a file.
However, it exports both the IOCTL ficlonerange and fideduprange constants.
On macOS 10.12.1, the gem performs the same operation as cp -c (using clonefile). As of macOS 11, only APFS supports clonefile.
Get started
You can find build and install instructions in BUILDING.md.
You probably want to install it via RubyGems:
gem install clonefile
Usage
require 'clonefile'
# Clone the file or fallback to make a regular copy.
Clonefile.auto(source_path, destination_path)
# Clone the file or raise an exception.
Clonefile.always(source_path, destination_path)