1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
# Args:
# $1: device to mount
# $rootmnt: where to try mounting it
# Returns 0 if able to mount, nonzero otherwise
canmount()
{
mount -n -t iso9660 -o ro $1 $rootmnt
}
# Args:
# $1: device to check
# $2: $rootmnt: where to try mounting
# Returns 0 if device mountable and DFS, nonzero otherwise
checkvalidity()
{
echo -n "Scanning $1: "
if canmount $1; then
if cmp /marker $rootmnt/opt/dfsruntime/marker; then
# LEAVE IT MOUNTED; later mount attempts will be weird.
echo "Found DFS CD."
return 0
else
umount $rootmnt
echo "Found a CD, but not the correct DFS one."
return 1
fi
else
echo "$1: Not mountable (empty drive, not a CD-ROM, or wrong device)"
return 1
fi
}
# Args: $rootmnt: where to mount the new item
# Returns 0 if a valid device was found, nonzero otherwise
# If a valid device was found, sets DFSDEVICE to that device and exports
# DFSDEVICE
scandevices()
{
OLDCWD=`pwd`
cat <<EOF
Scanning for DFS CD....
EOF
cd /sys/block
for DEVICE in *; do
if [ `cat $DEVICE/removable` = 1 ]; then
if checkvalidity /dev/$DEVICE; then
DFSDEVICE=/dev/$DEVICE
export DFSDEVICE
cd $OLDCWD
return 0
fi
fi
done
cd $OLDCWD
return 1
}
|