Damenly1
2021-09-08 13:40:09 +08:00
而且必须是 cp -c $src $dst 。macos 应该也提供了像 linux FICLONERANGE 这样 syscall,只有调用这个就行。
比如:
$df -h
/dev/disk3s5s1 221Gi 14Gi 38Gi 28% 553781 2312235219 0% /
$ls -lh 01
-rw-r--r--@ 1 damenly staff 1.5G Sep 1 18:48 01.mp4
$cp 1 2
/dev/disk3s5s1 221Gi 14Gi 37Gi 29% 553781 2312235219 0% /
$cp -c 1 3
/dev/disk3s5s1 221Gi 14Gi 37Gi(76675184) 29% 553781 2312235219 0% /
$dd if=/dev/zero of=03 bs=4k count=131072 conv=sync
131072+0 records in
131072+0 records out
536870912 bytes transferred in 0.304234 secs (1764664248 bytes/sec)
$df
/dev/disk3s5s1 462557800 29943296 75626360 29% 553781 2312235219 0% /