Make the gentoo initstyle work with baselayout-vserver.
[util-vserver.git] / scripts / vserver.functions
index ba07f33..7ddeb47 100644 (file)
@@ -306,21 +306,6 @@ function _generateInitOptions
            INITCMD_START=( /lib/rcscripts/sh/init-vserver.sh "$RUNLEVEL_START" )
            INITCMD_STOP=( /sbin/rc shutdown )
            INITCMD_PREPARE=( $_FAKE_RUNLEVEL 3 /var/run/utmp )
-
-           pushd "$vdir"/vdir &>/dev/null
-           basever=$($_CHROOT_SH cat /etc/gentoo-release | $_AWK '{print $5}')
-           popd &>/dev/null
-
-           basemaj=${basever/.*}
-           basemin=${basever#*.}
-           basemin=${basemin/.*}
-
-           test "$basemaj" -lt 1 -o "$basemin" -lt 13 && \
-           panic "\
-Using init-style 'gentoo' requires >=baselayout-1.13 inside the vserver!
-
-Your vserver ($(basename "$vdir")) seems to have baselayout-$basever,
-please use 'plain' init-style instead!"
            ;;
 
        (x) ;;
@@ -1201,7 +1186,7 @@ function _namespaceCleanup
 
     # these are things that have to be accessible post-cleanup
     for tmp in "$root" "$__SBINDIR" "$__PKGLIBDIR" "$vdir" \
-       "$__PKGSTATEDIR" "${skip[@]}"; do
+       "$__PKGSTATEDIR" "$__LOCKDIR" /usr/local /tmp "${skip[@]}"; do
        while test -n "$tmp"; do
            list=( "${list[@]}" "$tmp" )
            tmp="${tmp%/*}"
@@ -1226,3 +1211,28 @@ function _namespaceCleanup
     done
 }
 
+function loadDeviceMap
+{
+    local xid="$1"
+    local dir="$2"
+    local flags device target
+
+    test -d "$dir" || return 0
+
+    for i in "$dir"/*; do
+       test -d "$i" || continue
+
+       local -a vdevmap_opts=()
+       test -e "$i/create" && vdevmap_opts=( "${vdevmap_opts[@]}" --create )
+       test -e "$i/open"   && vdevmap_opts=( "${vdevmap_opts[@]}" --open )
+       test -e "$i/remap"  && vdevmap_opts=( "${vdevmap_opts[@]}" --remap )
+
+       getFileValue flags "$i/flags" || :
+       getFileValue device "$i/device" || :
+       getFileValue target "$i/target" || :
+       vdevmap_opts=(  "${vdevmap_opts[@]}" ${flags:+--flags "$flags"} \
+                       ${device:+--device "$device"} ${target:+--target "$target"} )
+
+       $_VDEVMAP --xid "$xid" "${vdevmap_opts[@]}" || return $?
+    done
+}