8 chattr-cow - try hard to enable Copy-on-Write attribute on files
10 chattr-nocow - try hard to disable Copy-on-Write attribute on files
20 .
/usr
/lib
/tool
/bash-utils
25 lsattr
-d "$1" | cut
-f1 -d' ' |
grep -qv 'C'
30 local onoff
file tmpf expected_cow current_dir_cow
31 local sigs
="ERR RETURN INT QUIT TERM"
38 [ $onoff = on
] && expected_cow
=-C || expected_cow
=+C
39 is_cow
"$dir" && current_dir_cow
=-C || current_dir_cow
=+C
41 if [ $expected_cow != $current_dir_cow ]
43 chattr $expected_cow "$dir"
44 trap 'trap - $sigs; chattr $current_dir_cow "$dir"' $sigs
47 cp -f --preserve=mode
,ownership
,timestamps
,xattr
--no-preserve=links
"$file" "$tmpf"
54 lsof
-Fp -- "$1" >/dev
/null
2>&1
68 errx
38 "bad invocation"
76 chattr $expected_cow "$file"
80 errx
16 "$file: is in use"