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.
 
 
Go to file
Daniel Aleksandersen da809d8ca4
Rescue more errors from man 2 ioctl_ficlone.
2 years ago
LICENSES Update LICENSE headers to REUSE 3.0 3 years ago
ext/clonefile Whitespace 3 years ago
lib Rescue more errors from man 2 ioctl_ficlone. 2 years ago
.gitignore Rename to clonefile. Add macOS/APFS support. 3 years ago
BUILDING.md Rename to clonefile. Add macOS/APFS support. 3 years ago
README.md Add info link on file cloning 3 years ago
Rakefile Resolve RuboCop offenses. 3 years ago
clonefile.gemspec Set version to 0.5.3. 2 years 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)