Perhaps my response is a little old, but I have a little script that
we use at work. We mount thumb drives as dos file systems for data
backup.
use mt.t to mount the thing
use mt.t -u to unmount it. (or umt.t if you link it to mt.t)
the -v option gives you verbosineity.
It will run io-usb if it is not already running,
It will run Fatfsys if it is not already running
It will autodetect upto 1 partition on the drive
It mounts the drive or the first partition as /dos/usb
I created a link to the same script called umt.t. The script detects
this and will un mount instead, or use the ‘-u’ option.
NC-17 WARNING!!!
This is my first script and probably REALLY sucks!!!
Use at your own RISK.
Also, if you know a better way, I am happy to learn.
here is the source
#! /bin/sh
#ifdef __USAGE
#%C [options]
#This script mounts a thumb drive as /dos/usb.
#Valid DOS partition types are 1, 4, 5, 6, 11, 12, 14, 15
#Partitions are searched for based on type in that order.
#If a drive has multiple partitions, only the first
#partition will be mounted.
#If the drive has no partitions the script will attempt to
#mount the raw device as a DOS drive…again as /dos/usb
#If the /bin/io-usb and /bin/Fatfsys processes are not
#already running, it will run them for you.
#Options:
-u : umount thumb drive and clean up the drivers
-v : verbose
#endif
#------------------------------------------------------------------
print_usage(){
echo “mt.t [options]”
echo
echo “Options:”
echo " -u : unmount thumb drive"
echo " -v : verbose"
exit 0
}
#------------------------------------------------------------------
unmount_clean(){
if test $verbose; then
printf “Unmount existing drive and stopping
drivers…\n”
printf “> umount /dos/usb: \n”
umount /dos/usb
printf “> umount /dev/hd_usb0: \n”
umount /dev/hd_usb0
printf “> slay -fQ Fsys.umass: \n”
slay -f Fsys.umass
printf “> rm /dev/hd_usb*: \n”
/bin/rm -v /dev/hd_usb*
echo
else
umount /dos/usb 2> /dev/null
umount /dev/hd_usb0 2> /dev/null
slay -fQ Fsys.umass 2> /dev/null
/bin/rm /dev/hd_usb* 2> /dev/null
fi
}
#------------------------------------------------------------------
mount_drive(){
if test $umount; then
if test $verbose; then
printf “OKAY TO REMOVE THUMB DRIVE.\n”
fi
exit 0
fi
########################################################33
run the Fsys.umass drivers
########################################################33
if test $verbose; then
printf “> Fsys.umass fsys -n0=hd_usb: \n”
Fsys.umass fsys -n0=hd_usb
else
Fsys.umass fsys -n0=hd_usb 2> /dev/null
fi
sleep 1
########################################################33
find the partitions
########################################################33
for tt in t1 t4 t5 t6 t11 t12 t14 t15
do
part=none;
fdisk /dev/hd_usb0 query $tt > junk
read myline < junk
if test $myline -gt 0
then
part=$tt
break;
fi
done
########################################################33
mount the partitions
########################################################33
if test $verbose; then
if test $part = “none”
then
mount -t dos /dev/hd_usb0 /dos/usb
echo
printf “USB MOUNTED AS /dos/usb\n” $part
else
mount -p /dev/hd_usb0
mount -t dos /dev/hd_usb0$part /dos/usb
echo
printf “USB PARTITION TYPE(%s) MOUNTED AS
/dos/usb\n” $part
fi
else
if test $part = “none”
then
mount -t dos /dev/hd_usb0 /dos/usb 2> /dev/null
else
mount -p /dev/hd_usb0
mount -t dos /dev/hd_usb0$part /dos/usb 2> /dev/null
fi
fi
}
#------------------------------------------------------------------
me=${0##*/}
###########################################################3333
CHECK TO MAKE SURE THE io-usb IS RUNNING
io-usb is the QNX driver for the usb ports
###########################################################3333
ps | grep ‘io-usb’ | wc -l > junk
read lines < junk
if test $lines -eq 1
then
echo Starting io-usb…
/bin/io-usb &
sleep 4
fi
###########################################################3333
CHECK TO MAKE SURE THE DOSFSYS IS !!! NOT !!! RUNNING
IF DOSFSYS IS RUNNING IT MUST BE STOPPED
###########################################################3333
ps | grep Dosfsys | wc -l > junk
read lines < junk
if test $lines -gt 1
then
echo “We Found Dosfsys Running, Dosfsys is OLD”
echo “slay dosfsys (Dosfsys -x), and try again.”
exit 0;
fi
###########################################################3333
CHECK TO MAKE SURE THE FATFSYS IS RUNNING
FATFSYS IS THE DRIVER FOR THE DOS/WIN FAT32 FILESYSTEM
###########################################################3333
ps | grep Fatfsys | wc -l > junk
read lines < junk
if test $lines -eq 1
then
echo Starting Fatfsys…
/bin/Fatfsys &
sleep 4
fi
while getopts vu opt $*
do
case $opt in
v) verbose=“yes”;;
u) umount=“yes”;;
esac
done
case $me in
umt.t) umount=“yes”;;
esac
unmount_clean
mount_drive
exit 0
[/code]