On Sun, Oct 10, 2010 at 09:52:19AM +1100, Zenaan Harkness wrote:

How about just using symlinks instead.

eg

# creation
UNIQUE_NAME=unique_login_name
MY_LOOP_DEV=/dev/loop/$UNIQUE_NAME

# Setup loop device and grab it's name
LOOP_DEV=`sudo losetup --show --find /home/$UNIQUE_NAME/source`

# Create symlink
ln -s $LOOP_DEV $MY_LOOP_DEV

mount $MY_LOOP_DEV /home/$UNIQUE_NAME/target


# tear down: Assuming different script
UNIQUE_NAME=unique_login_name
MY_LOOP_DEV=/dev/loop/$UNIQUE_NAME

umount /home/$UNIQUE_NAME/target
LOOP_DEV=`readlink $MY_LOOP_DEV`

losetup -d $LOOP_DEV
rm $MY_LOOP_DEV


This all works because adding --find to losetup will get it to find
the next available device and --show will print out what it found.

Note: The scripts above aren't tested.

Cheers,
John

-- 
John
Blog                             http://www.inodes.org
LCA2011                          http://www.lca2011.org.au
-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to