mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2026-08-28 11:56:03 +00:00
feat: Remove unused functions (#1276)
This commit is contained in:
@@ -415,74 +415,6 @@ cpu() {
|
||||
return 0
|
||||
}
|
||||
|
||||
getDisk() {
|
||||
|
||||
local name="${DISK_NAME:-data}" path
|
||||
enabled "${DISK_DISABLE:-}" && return 1
|
||||
|
||||
for path in "/disk" "/disk1" "/dev/disk1" "${DEVICE:-}"; do
|
||||
if [ -n "$path" ] && [ -b "$path" ]; then
|
||||
printf '%s\n' "$path"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
for path in "$STORAGE/$name.img" "$STORAGE/$name.qcow2"; do
|
||||
if [ -s "$path" ]; then
|
||||
printf '%s\n' "$path"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
hasDisk() {
|
||||
|
||||
getDisk >/dev/null
|
||||
return $?
|
||||
|
||||
}
|
||||
|
||||
hasData() {
|
||||
|
||||
local path
|
||||
local rc=0 tmp=""
|
||||
local bytes=102400
|
||||
|
||||
path=$(getDisk) || return 1
|
||||
local source="$path"
|
||||
|
||||
if [[ "${path,,}" == *.qcow2 ]]; then
|
||||
|
||||
tmp=$(mktemp) || {
|
||||
warn "failed to create a temporary file while inspecting \"$path\"."
|
||||
return 0
|
||||
}
|
||||
|
||||
if ! qemu-img dd -f qcow2 -O raw bs="$bytes" count=1 \
|
||||
"if=$path" "of=$tmp" >/dev/null 2>&1; then
|
||||
rm -f "$tmp"
|
||||
warn "failed to inspect disk \"$path\", assuming it contains data."
|
||||
return 0
|
||||
fi
|
||||
|
||||
source="$tmp"
|
||||
|
||||
fi
|
||||
|
||||
cmp -s -n "$bytes" "$source" /dev/zero || rc=$?
|
||||
[ -n "$tmp" ] && rm -f "$tmp"
|
||||
|
||||
case "$rc" in
|
||||
0) return 1 ;;
|
||||
1) return 0 ;;
|
||||
esac
|
||||
|
||||
warn "failed to inspect disk \"$path\", assuming it contains data."
|
||||
return 0
|
||||
}
|
||||
|
||||
getCountry() {
|
||||
|
||||
local url=$1
|
||||
|
||||
Reference in New Issue
Block a user