hal/tools/callouts fstab-update.sh,1.7,1.8

Joe Shaw joe at pdx.freedesktop.org
Sat May 8 12:00:34 PDT 2004


Update of /cvs/hal/hal/tools/callouts
In directory pdx:/tmp/cvs-serv18999/tools/callouts

Modified Files:
	fstab-update.sh 
Log Message:
2004-05-08  Joe Shaw  <joe at ximian.com>

	* tools/callouts/fstab-update.sh: Improve the locking loop.

Index: fstab-update.sh
===================================================================
RCS file: /cvs/hal/hal/tools/callouts/fstab-update.sh,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- a/fstab-update.sh	7 May 2004 17:41:33 -0000	1.7
+++ b/fstab-update.sh	8 May 2004 19:00:32 -0000	1.8
@@ -39,12 +39,23 @@
 MEDIAROOT="/mnt"
 MOUNTPOINT="$MEDIAROOT/hal/disk-$HAL_PROP_BLOCK_MAJOR-$HAL_PROP_BLOCK_MINOR-"
 
+have_lock=false
 max_loops=10
 loop_times=0
-while [ -e /etc/fstab-lock -a $loop_times -lt $max_loops ]; do
+
+while [ $have_lock = false -a $loop_times -lt $max_loops ]; do
     loop_times=$((loop_times+1))
-    echo "waiting for fstab lock... ($HAL_PROP_BLOCK_DEVICE: $loop_times of $max_loops)"
-    sleep 1
+
+    if [ -n /etc/fstab-lock ]; then
+	echo "$$" >> /etc/fstab-lock
+    fi
+
+    if [ "`head -n 1 /etc/fstab-lock`" = "$$" ]; then
+	have_lock=true
+    else
+	echo "waiting for fstab lock... ($HAL_PROP_BLOCK_DEVICE: $loop_times of $max_loops)"
+	sleep 1
+    fi
 done
 
 # Took too long!
@@ -53,8 +64,6 @@
     exit 1
 fi
 
-touch /etc/fstab-lock
-
 if test "$1" = "add"; then
 
     if [ ! -d $MOUNTPOINT ]; then
@@ -96,4 +105,4 @@
     echo "invalid action!"
 fi
 
-rm /etc/fstab-lock
\ No newline at end of file
+rm -f /etc/fstab-lock





More information about the hal-commit mailing list