#!/bin/sh

# Use the Ram-disk as a pseudo-floppy

# Check if the file is compressed

ic=0
if [ -f ${1}.Z ]
then
  ic=1
fi

# Get the size of the file

chars=`wc -c $1 | cut -f1 -d" "`
blocks=`expr ${chars} / 4096`

# Find a free floppy-device

ramnr=`ramstat | egrep closed | awk 'NR == 1 { print $1 }'`

if [ -z "$ramnr" ]
then
  echo "No free RAM-devices"
  exit 1
fi

CRAM=/dev/rdsk/ram${ramnr}
BRAM=/dev/dsk/ram${ramnr}
MP=/floppy${ramnr}

# Create the RAM-area

ramstat -i ${blocks} $CRAM

# Copy the image of the floppy to the RAM-disk

if [ $ic -eq 1 ]
then	
  uncompress < $1 | dd of=$CRAM bs=4k
else
  dd if=$1 of=$CRAM bs=4k
fi

# Check that the mountpoint exists

if [ ! -d $MP ]
then
  mkdir $MP
fi

# Mount the pseudo-floppy

mount $BRAM $MP
echo $MP



