Skip to content

Commit d4d383c

Browse files
committed
install: support reflink
1 parent 5a7774d commit d4d383c

6 files changed

Lines changed: 11 additions & 3 deletions

File tree

.vscode/cspell.dictionaries/workspace.wordlist.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,10 @@ uutests
360360
uutils
361361

362362
# * function names
363+
sendfile
363364
execfn
364365
fadvise
366+
ficlone
365367
fstatfs
366368
getcwd
367369
mkfifoat

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/uu/cp/src/cp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// For the full copyright and license information, please view the LICENSE
44
// file that was distributed with this source code.
5-
// spell-checker:ignore (ToDO) copydir ficlone fiemap ftruncate linkgs lstat nlink nlinks pathbuf pwrite reflink strs xattrs symlinked deduplicated advcpmv nushell IRWXG IRWXO IRWXU IRWXUGO IRWXU IRWXG IRWXO IRWXUGO sflag
5+
// spell-checker:ignore (ToDO) copydir fiemap ftruncate linkgs lstat nlink nlinks pathbuf pwrite reflink strs xattrs symlinked deduplicated advcpmv nushell IRWXG IRWXO IRWXU IRWXUGO IRWXU IRWXG IRWXO IRWXUGO sflag
66

77
use std::cmp::Ordering;
88
use std::collections::{HashMap, HashSet};

src/uu/cp/src/platform/linux.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// For the full copyright and license information, please view the LICENSE
44
// file that was distributed with this source code.
5-
// spell-checker:ignore ficlone reflink ftruncate pwrite fiemap lseek nofollow
5+
// spell-checker:ignore reflink ftruncate pwrite fiemap lseek nofollow
66

77
use rustix::fs::{SeekFrom, ftruncate, ioctl_ficlone, seek};
88
use std::io::Read;

src/uu/install/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ uucore = { workspace = true, default-features = true, features = [
3434
fluent = { workspace = true }
3535

3636
[target.'cfg(any(target_os = "linux", target_os = "android"))'.dependencies]
37+
rustix = { workspace = true }
3738
selinux = { workspace = true, optional = true }
3839

3940
[features]

src/uu/install/src/install.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1028,7 +1028,11 @@ fn copy_file(from: &Path, to: &Path) -> UResult<()> {
10281028
.create_new(true)
10291029
.mode(0o600)
10301030
.open(to)?;
1031-
1031+
#[cfg(any(target_os = "linux", target_os = "android"))]
1032+
if rustix::fs::ioctl_ficlone(&dest, &handle).is_ok() {
1033+
return Ok(());
1034+
}
1035+
// faster than io::copy's copy_file_range and sendfile
10321036
copy_stream(&mut handle, &mut dest).map_err(|err| {
10331037
InstallError::InstallFailed(from.to_path_buf(), to.to_path_buf(), err.to_string())
10341038
})?;

0 commit comments

Comments
 (0)