mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2026-08-28 11:56:03 +00:00
fix: Do not fail if marker cannot be created (#1359)
This commit is contained in:
-16
@@ -200,22 +200,6 @@ normalizeSize() {
|
||||
return 0
|
||||
}
|
||||
|
||||
baseDir() {
|
||||
|
||||
local path="${1%/}"
|
||||
|
||||
[[ -z "$path" || "$path" == "/" ]] && {
|
||||
echo "/"
|
||||
return 0
|
||||
}
|
||||
|
||||
path="${path#/}"
|
||||
path="${path%%/*}"
|
||||
|
||||
echo "/$path"
|
||||
return 0
|
||||
}
|
||||
|
||||
freeSpace() {
|
||||
|
||||
local path="$1"
|
||||
|
||||
+1
-1
@@ -217,7 +217,7 @@ finish() {
|
||||
failed=1
|
||||
fi
|
||||
|
||||
touch "$QEMU_END"
|
||||
touch "$QEMU_END" || :
|
||||
|
||||
forceKillQemu "$reason"
|
||||
cleanupHelpers
|
||||
|
||||
+83
-67
@@ -123,32 +123,6 @@ disabled() {
|
||||
esac
|
||||
}
|
||||
|
||||
formatBytes() {
|
||||
|
||||
local result
|
||||
|
||||
if ! result=$(numfmt --to=iec --suffix=B "$1" | sed -r 's/([A-Z])/ \1/' | sed 's/ B/ bytes/g;'); then
|
||||
return 1
|
||||
fi
|
||||
|
||||
local unit="${result//[0-9. ]}"
|
||||
result="${result//[a-zA-Z ]/}"
|
||||
|
||||
if [[ "${2:-}" == "up" ]]; then
|
||||
if [[ "$result" == *"."* ]]; then
|
||||
result="${result%%.*}"
|
||||
result=$((result+1))
|
||||
fi
|
||||
else
|
||||
if [[ "${2:-}" == "down" ]]; then
|
||||
result="${result%%.*}"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "$result $unit"
|
||||
return 0
|
||||
}
|
||||
|
||||
isAlive() {
|
||||
|
||||
local pid="$1"
|
||||
@@ -272,47 +246,6 @@ mKill() {
|
||||
return 0
|
||||
}
|
||||
|
||||
setOwner() {
|
||||
|
||||
local file="$1"
|
||||
local dir uid gid
|
||||
|
||||
[ ! -f "$file" ] && return 1
|
||||
|
||||
# Match generated files to the owner of their bind-mounted parent directory
|
||||
# instead of assuming a fixed container or host UID.
|
||||
dir=$(dirname -- "$file")
|
||||
uid=$(stat -c '%u' "$dir") || return 1
|
||||
gid=$(stat -c '%g' "$dir") || return 1
|
||||
|
||||
chown "$uid:$gid" "$file" || return 1
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
makeDir() {
|
||||
|
||||
local path="$1"
|
||||
local dir uid gid
|
||||
|
||||
[ -d "$path" ] && return 0
|
||||
mkdir -p "$path" || return 1
|
||||
|
||||
dir=$(dirname -- "$path")
|
||||
|
||||
if ! uid=$(stat -c '%u' "$dir") || ! gid=$(stat -c '%g' "$dir"); then
|
||||
warn "failed to determine the owner for \"$path\"."
|
||||
return 0
|
||||
fi
|
||||
|
||||
if ! chown "$uid:$gid" "$path"; then
|
||||
warn "failed to set the owner for \"$path\"."
|
||||
return 0
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
finiteMemoryLimit() {
|
||||
|
||||
local limit="$1"
|
||||
@@ -371,6 +304,89 @@ getMemoryInfo() {
|
||||
return 0
|
||||
}
|
||||
|
||||
baseDir() {
|
||||
|
||||
local path="${1%/}"
|
||||
|
||||
[[ -z "$path" || "$path" == "/" ]] && {
|
||||
echo "/"
|
||||
return 0
|
||||
}
|
||||
|
||||
path="${path#/}"
|
||||
path="${path%%/*}"
|
||||
|
||||
echo "/$path"
|
||||
return 0
|
||||
}
|
||||
|
||||
formatBytes() {
|
||||
|
||||
local result
|
||||
|
||||
if ! result=$(numfmt --to=iec --suffix=B "$1" | sed -r 's/([A-Z])/ \1/' | sed 's/ B/ bytes/g;'); then
|
||||
return 1
|
||||
fi
|
||||
|
||||
local unit="${result//[0-9. ]}"
|
||||
result="${result//[a-zA-Z ]/}"
|
||||
|
||||
if [[ "${2:-}" == "up" ]]; then
|
||||
if [[ "$result" == *"."* ]]; then
|
||||
result="${result%%.*}"
|
||||
result=$((result+1))
|
||||
fi
|
||||
else
|
||||
if [[ "${2:-}" == "down" ]]; then
|
||||
result="${result%%.*}"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "$result $unit"
|
||||
return 0
|
||||
}
|
||||
|
||||
setOwner() {
|
||||
|
||||
local file="$1"
|
||||
local dir uid gid
|
||||
|
||||
[ ! -f "$file" ] && return 1
|
||||
|
||||
# Match generated files to the owner of their bind-mounted parent directory
|
||||
# instead of assuming a fixed container or host UID.
|
||||
dir=$(dirname -- "$file")
|
||||
uid=$(stat -c '%u' "$dir") || return 1
|
||||
gid=$(stat -c '%g' "$dir") || return 1
|
||||
|
||||
chown "$uid:$gid" "$file" || return 1
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
makeDir() {
|
||||
|
||||
local path="$1"
|
||||
local dir uid gid
|
||||
|
||||
[ -d "$path" ] && return 0
|
||||
mkdir -p "$path" || return 1
|
||||
|
||||
dir=$(dirname -- "$path")
|
||||
|
||||
if ! uid=$(stat -c '%u' "$dir") || ! gid=$(stat -c '%g' "$dir"); then
|
||||
warn "failed to determine the owner for \"$path\"."
|
||||
return 0
|
||||
fi
|
||||
|
||||
if ! chown "$uid:$gid" "$path"; then
|
||||
warn "failed to set the owner for \"$path\"."
|
||||
return 0
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
stateFile() {
|
||||
|
||||
local name="$1"
|
||||
|
||||
Reference in New Issue
Block a user