add btrfs-functions
This commit is contained in:
parent
a575ab0e14
commit
3f4b655d1c
1 changed files with 24 additions and 1 deletions
25
functions.sh
25
functions.sh
|
@ -948,7 +948,30 @@ get_crtime() {
|
|||
|
||||
|
||||
is_btrfs_subvolume() {
|
||||
btrfs subvolume show "$1" >/dev/null 2>&1
|
||||
sudo btrfs subvolume show "$1" >/dev/null
|
||||
}
|
||||
|
||||
convert_to_subvolume () {
|
||||
local XSUDO
|
||||
local DIR
|
||||
case $1 in
|
||||
--sudo|-s)
|
||||
XSUDO=sudo
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
DIR="${1}"
|
||||
[ -d "${DIR}" ] || return 1
|
||||
is_btrfs_subvolume "${DIR}" && return 0
|
||||
set -x
|
||||
#btrfs subvolume create "${DIR}".new && \
|
||||
${XSUDO:+sudo} btrfs subvolume create "${DIR}.new" && \
|
||||
/bin/cp -Tr --reflink=always "${DIR}" "${DIR}".new && \
|
||||
mv "${DIR}" "${DIR}".orig && \
|
||||
mv "${DIR}".new "${DIR}" || return 2
|
||||
|
||||
set +x
|
||||
return 0
|
||||
|
||||
}
|
||||
#EOF
|
||||
|
|
Loading…
Reference in a new issue