#!/bin/sh
#
# routines for mounting/unmounting blockdevices
#
# $Header: /home/kbackup/CVSROOT/KBackup/src/blockdev_src,v 1.11 1997/09/19 19:49:25 kbackup Exp $
# This file is Copyright (C) 1995-1997 by Karsten Ballder (Ballueder@usa.net)
#
# It is part of the KBackup package, see the file COPYING for details.
# KBackup and all files included in this package are licensed and protected
# under the terms and conditions of the GNU General Public License Version 2.
#
#	If you want to contact the current maintainer of this software, please
#	send e-mail to: KBackup@usa.net
#       Or visit the KBackup-Homepage at http://KBackup.home.ml.org/
#

Blockdev_src_loaded=YES

get_blockdev()
{
	if [ "$device_type" != "BLOCKDEV" ]
	then
		return 0
	fi
	real_device="$device"

	if [ "$1" != "READ" ]
	then
		InfoBox "Formatting $device..."

		last_command="$blockdev_mkfs"
		eval $blockdev_mkfs 2>$STDERR
		check_error 
	fi

	InfoBox "Mounting $device..."
	last_command="mount -t $blockdev_fs_type $device $MOUNTPOINT"
	mount -t "$blockdev_fs_type" "$device" $MOUNTPOINT 2>$STDERR
	check_error 
	return $?
}

release_blockdev()
{
	if [ "$device_type" != "BLOCKDEV" ]
	then
		return
	fi
	device="$real_device"
	InfoBox "Unmounting $device...\n(might take a while)"
	last_command="umount $MOUNTPOINT"
	umount $MOUNTPOINT 2>$STDERR
	check_error 
	if [ $? != 0 ] ; then return ;fi
}
