On Sat, Oct 07, 2006 at 12:38:53AM +0200, Roland Stigge wrote:
> Package: xen-tools
> Version: 2.6-1
> Severity: important
> Tags: patch
Try this patch?
Steve
--
diff --unified -r1.95 xen-create-image
--- bin/xen-create-image 11 Sep 2006 15:57:57 -0000 1.95
+++ bin/xen-create-image 7 Oct 2006 08:36:08 -0000
@@ -675,9 +675,13 @@
if ( $CONFIG{'boot'} )
{
#
- # Unmount.
+ # Unmount the image and any subsequent mounts.
+ #
+ unMountImage( $MOUNT_POINT );
+
+ #
+ # Mark us as unmounted.
#
- runCommand( "umount $MOUNT_POINT" );
$MOUNT_POINT = undef;
#
@@ -2126,6 +2130,62 @@
=begin doc
+ Unmount any mount-points which are below the given path.
+
+ The mountpoints are chosen by looking at /proc/mounts which
+ might not be portable, but works for me. (tm).
+
+=end doc
+
+=cut
+
+sub unMountImage
+{
+ my ( $point ) = ( @_ );
+
+ #
+ # Open /proc/mount and get a list of currently mounted paths
+ # which begin with our mount point.
+ #
+ my @points;
+
+ open( MOUNTED, "<", "/proc/mounts" )
+ or die "Failed to open mount list";
+ foreach my $line (<MOUNTED> )
+ {
+ #
+ # Split into the device and mountpoint.
+ #
+ my ( $device, $path ) = split( / /, $line );
+
+ if ( $path =~ /\Q$point\E/ )
+ {
+ push @points, $path;
+ }
+ }
+ close( MOUNTED );
+
+ #
+ # Now we have a list of mounts. We need to move the
+ # longest first, we can do this by sorting and reversing.
+ #
+ # (ie. We unmount the children, then the parent.)
+ #
+ @points = sort @points;
+ @points = reverse @points;
+
+ foreach my $path ( @points )
+ {
+ $CONFIG{'verbose'} && print "Unmounting : $path\n";
+ runCommand( "umount $path" );
+ }
+
+ $MOUNT_POINT = undef;
+}
+
+
+=begin doc
+
If we still have the temporary image mounted then make sure
it is unmounted before we terminate.
@@ -2137,14 +2197,10 @@
{
if ( defined( $MOUNT_POINT ) )
{
- #
- # Run mount to see if this is still mounted.
- #
- my $mount = `/bin/mount`;
- if ( $mount =~ /$MOUNT_POINT/)
- {
- runCommand( "umount $MOUNT_POINT" );
- }
+ #
+ # Unmount the image, taking care to remove any child mounts too.
+ #
+ unMountImage( $MOUNT_POINT );
}
if ( ( defined( $CONFIG{'hostname'} ) ) &&
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]