A Ruby gem that implements reflink copy (copy-on-write) for supported file systems on Linux.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
Daniel Aleksandersen da809d8ca4 Rescue more errors from man 2 ioctl_ficlone. 8 months ago
LICENSES Update LICENSE headers to REUSE 3.0 11 months ago
ext/clonefile Whitespace 10 months ago
lib Rescue more errors from man 2 ioctl_ficlone. 8 months ago
.gitignore Rename to clonefile. Add macOS/APFS support. 11 months ago
BUILDING.md Rename to clonefile. Add macOS/APFS support. 11 months ago
README.md Add info link on file cloning 10 months ago
Rakefile Resolve RuboCop offenses. 11 months ago
clonefile.gemspec Set version to 0.5.3. 8 months ago

README.md

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)