[EMAIL PROTECTED] wrote:
#!/usr/bin/bash
mkdir $2
lofiadm -a $1 /dev/lofi/1
mount -F hsfs -o ro /dev/lofi/1 $2 && echo -e "\n\t I have mounted $1 under the
folder $2\n\n"
You should realize that "lofiadm" actually outputs the device used, so
the script can be written so as not to require only /dev/lofi/1
I've attached my scripts which I use for mounting/unmounting lofi volumes.
It detects pcfs, ufs and hsfs filesystem and mounts them; it remembers
the mount and a single "lofiumount" without arguments will unmount all
you mounted.
I've written these a long time ago, shortly after lofiadm was added,
I think.
Usage is simple:
lofimount file.iso /mnt
lofiumount /mnt
lofimount file.ufs /mnt
etc.
That's cool Casper.
I know it needs polishing, but I've attached a script I wrote and placed
in /usr/lib/fs/lofi/mount, so that I could put entries like this in
/etc/vfstab:
/export/Solaris/ISOs/sol-nv-b74-x86-dvd.iso - /export/Solaris/sNV/b74_x
lofi - yes fstype=hsfs
Maybe I can extend it to detect the fstype automatically from your script.
-Kyle
#/bin/ksh
#
#
if [ "$1" = "-o" ]; then
OPTS="$2"
shift 2
fi
FILE="$1"
MTPT="$2"
if [ "${OPTS}" != "" ]; then
SAVE_IFS="${IFS}"
IFS=","
set - ${OPTS}
IFS="${SAVE_IFS}"
OPTS=""
while [ "${1}x" != "x" ]; do
case "$1" in
fstype=* )
# Use fancy shell pattern/regexp assignment operation.
TYPE=`echo $1 | sed "s/fstype=//"`;;
* )
# use new fancy assignment shell operation.
if [ "${OPTS}" = "" ]; then
OPTS="-o $1"
else
OPTS="${OPTS},$1"
fi;;
esac
shift
done
fi
LOFI=""
LOOP=0
if [ -r "${FILE}" ]; then
while [ "${LOFI}" = "" -a "${LOOP}" -lt "10" ]; do
LOFI=`lofiadm ${FILE} 2>/dev/null`
# LOFI=`lofiadm ${FILE}`
if [ "${LOFI}" = "" ]; then
LOFI=`lofiadm -a ${FILE} 2>/dev/null`
# LOFI=`lofiadm -a ${FILE}`
fi
if [ "${LOFI}" = "" ]; then
LOOP=`echo ${LOOP} + 1 | bc`
echo "Looping(${LOOP})" 1>&2
sleep 1
fi
done
else
echo "mount: open: ${FILE}: No such file or directory"
fi
#echo "FILE: ${FILE}" 1>&2
#echo "MTPT: ${MTPT}" 1>&2
#echo "TYPE: ${TYPE}" 1>&2
#echo "OPTS: ${OPTS}" 1>&2
#echo "LOFI: ${LOFI}" 1>&2
if [ "${LOFI}" = "" ]; then
echo Aborting! 1>&2
exit 1
fi
echo mount -F ${TYPE} ${OPTS} ${LOFI} ${MTPT} 1>&2
mount -F ${TYPE} ${OPTS} ${LOFI} ${MTPT}
exit $?
_______________________________________________
opensolaris-discuss mailing list
[email protected]