#!/bin/sh
#200225 sfs
run_hook() {
    [ "${aufs}" ] && return
    [ "${ofs}" ] && return
#    rootaufs="${changes}" ###sfs
#    if [ "x${rootaufs}" != "x" ]; then
    [ "x${rootaufs}${changes}" != "x" ] && return

    if [ ! "${root}" ]; then
        err " root= not defined"
        launch_interactive_shell
    fi

    if [ ! -z "$rootdir" ]; then
        mv /new_root /new_rootimg
        ln -s new_rootimg /new_root
        [ "${rootdelay}" ] && sleep ${rootdelay} && 
    	    echo -e "[1;33m"":: subdir2 Wait rootdelay=${rootdelay}...""[0m" 
    fi
}

run_latehook() {
    if [ "x${rootaufs}" != "x" ]; then
        return
    fi
    [ "x${aufs}" != "x" ] && return
    [ "${ofs}" ] && return

    local _rootpath _postfix _d
    if [ ! -z "$rootdir" -a -L /new_root ]; then
        _rootpath=/`readlink /new_root`
        rm /new_root
        mkdir /new_root
	##rootaufs
        mount --bind $_rootpath/"$rootdir" /new_root
	#[ "${roothide}" = "y" ] && 
	[ "${root}" ] &&
	    root2="/new_root/mnt/`basename ${root}`" &&
	    mkdir -p "${root2}" && 
    	    default_mount_handler "${root2}" &&
            msg "::: Mount ${root} in ${root2}"
    fi
}
