Add support for the OOM bias, and vmemctrl to control it.
[util-vserver.git] / scripts / vserver.functions
index 78d37e8..776e487 100644 (file)
@@ -611,7 +611,8 @@ function _generateTagOptions
     local vdir="$1"
     local tag
 
-    getFileValue tag "$vdir/tag" "$vdir/context" || return 0
+    getFileValue tag "$vdir/tag" "$vdir/context"
+    test -n "$tag" || return 0
 
     OPTS_VTAG_CREATE=( --tag "$tag" )
     OPTS_VTAG_ENTER=( --tag "$tag" )
@@ -892,6 +893,22 @@ function umountVserver
     test -n "$is_ok"
 }
 
+function fsckAllFS
+{
+    local cfgdir=$1
+    local fstab="$cfgdir"/fstab
+    local FSTAB_FILE
+    local fsck_exitcode
+
+    test -e "$fstab" || return 0
+
+    export FSTAB_FILE="$fstab"
+    $_FSCK -s -n -A -T
+    fsck_exitcode=$?
+    test "$fsck_exitcode" -eq 0 -o \
+         "$fsck_exitcode" -eq 1 || return $fsck_exitcode
+}
+
 ## Usage: waitForSync <vserver> <context> <vshelper-fifo-varname>
 function initSync
 {
@@ -1215,17 +1232,22 @@ function _namespaceCleanup
     local root=$($_VSERVER_INFO "$1" VDIR 1)
     local -a list
     local -a skip
-    local tmp
+    local i
+    local j
 
     getFileArray skip "$vdir"/namespace-cleanup-skip \
        "$__CONFDIR"/.defaults/namespace-cleanup-skip || :
 
     # these are things that have to be accessible post-cleanup
-    for tmp in "$root" "$__SBINDIR" "$__PKGLIBDIR" "$vdir" \
+    for i in "$root" "$__SBINDIR" "$__PKGLIBDIR" "$vdir" \
        "$__PKGSTATEDIR" "$__LOCKDIR" /usr/local /tmp "${skip[@]}"; do
-       while test -n "$tmp"; do
-           list=( "${list[@]}" "$tmp" )
-           tmp="${tmp%/*}"
+       local real=`readlink -f "$i"`
+       test "$i" != "$real" || real=
+       for j in "$i" "$real"; do
+           while test -n "$j"; do
+               list=( "${list[@]}" "$j" )
+               j="${j%/*}"
+           done
        done
     done
 
@@ -1269,6 +1291,6 @@ function loadDeviceMap
        vdevmap_opts=(  "${vdevmap_opts[@]}" ${flags:+--flags "$flags"} \
                        ${device:+--device "$device"} ${target:+--target "$target"} )
 
-       $_VDEVMAP --xid "$xid" "${vdevmap_opts[@]}" || return $?
+       $_VDEVMAP --xid "$xid" --set "${vdevmap_opts[@]}" || return $?
     done
 }