#
# DESCRIPTION:
#
#    If the system image contains itself another system file. Mount it now
#    to provide a valid root filesystem in $IMAGE_MNT
#
# part of the LiveBackup project:  
#
#                     http://livebackup.sourceforge.net/
#
# Copyright 2006 by Wolfgang Rohrmoser <info@rohrmoser-engineering.de>
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
#

if [ ! $(is_mounted $IMAGE_MNT) ]; then
    msg -c "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
    msg -c "FATAL: $IMAGE_MNT not mounted ..."
    msg -c "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
    rescue_shell "this should not happen, please investigate ..";
fi

#
# check for proper mount command options
#
if [ -w /etc/mtab ]; then
    m_opt=""
else
    m_opt="-n"
fi

#
# currently only a nested ext2 image file is supported 
#
if [ -f $IMAGE_MNT/$SYSTEM.ext2 ]; then
    msg -i "mounting nested image file: $IMAGE_MNT/$SYSTEM.ext2"
    mount $m_opt -o ro,loop $IMAGE_MNT/$SYSTEM.ext2 $IMAGE_MNT/
fi


#
# Local Variables: 
# mode: shell-script
# End: 
#
