From: Huang Hao Date: Mon, 26 Nov 2012 04:02:15 +0000 (+0800) Subject: Warn user and try again if umount failed X-Git-Tag: 0.3~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=46f8487117260a38d9767443df2be7fd0996c0d1;p=tools%2Fdepanneur.git Warn user and try again if umount failed * use lazy umount to avoid "device is busy" problem * if umount failed, warn user and add -f to try again Change-Id: I44bab019d41124002aa191d3d85649f553f016ba --- diff --git a/depanneur b/depanneur index fd58441..d52f036 100755 --- a/depanneur +++ b/depanneur @@ -1024,6 +1024,21 @@ sub worker_thread { return $status; } +sub safe_umount { + my ($device) = @_; + return if (my_system("sudo umount -l $device") == 0); + + warning("!!!! umount device $device failed. It may cause files lost in ". + "some cases. Please stop the process which is using this device and ". + "press any key to umount again !!!!"); + + <>; + if (my_system("sudo umount -l -f $device") != 0) { + warning("!!!! IMPORTANT: umount failed again, please backup your ". + "source code and try to umount manually !!!!"); + } +} + sub build_package { my ($name, $thread, $index) = @_; use vars qw(@package_repos); @@ -1145,7 +1160,7 @@ sub build_package { if ($incremental == 1) { #FIXME: more safe way needed to remove this fake source tar my_system("rm -f $source_tar") if ($source_tar ne ""); - my_system("sudo umount $builddir"); + safe_umount($builddir) if ($incremental == 1); } # Save build config to build root for --noinit use