summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Garman <scott.a.garman@intel.com>2010-09-28 18:58:33 -0700
committerRichard Purdie <rpurdie@linux.intel.com>2010-10-07 19:52:32 +0100
commit62625d0ca006153169efc3378ad2d30c30e12612 (patch)
treed557f7fff2b59438544552a21c77eed7544cdc75
parentfcbd67c047f02052cc87f2d0dcbfde83a23921bd (diff)
downloadopenembedded-core-62625d0ca006153169efc3378ad2d30c30e12612.tar.gz
openembedded-core-62625d0ca006153169efc3378ad2d30c30e12612.tar.bz2
openembedded-core-62625d0ca006153169efc3378ad2d30c30e12612.tar.xz
openembedded-core-62625d0ca006153169efc3378ad2d30c30e12612.zip
poky-qemu-internal: use lockfile-progs for network interface locking
The 'lockfile' utility originally used comes from the procmail package, which users shouldn't have to install. This uses the more general lockfile-progs utilities to acheive the same end. This fixes [BUGID #389] Signed-off-by: Scott Garman <scott.a.garman@intel.com>
-rwxr-xr-xscripts/poky-qemu-internal25
1 files changed, 20 insertions, 5 deletions
diff --git a/scripts/poky-qemu-internal b/scripts/poky-qemu-internal
index c65e0f1de..c3720d9ce 100755
--- a/scripts/poky-qemu-internal
+++ b/scripts/poky-qemu-internal
@@ -55,6 +55,13 @@ QEMUIFDOWN=`which poky-qemu-ifdown`
NFSRUNNING="false"
+LOCKUTIL=`which lockfile-create`
+if [ -z "$LOCKUTIL" ]; then
+ echo "Error: Unable to find the lockfile-create utility"
+ echo "On Ubuntu systems this is included in the lockfile-progs package"
+ return
+fi
+
LOCKDIR="/tmp/qemu-tap-locks"
[ ! -d "$LOCKDIR" ] && mkdir $LOCKDIR
@@ -63,10 +70,14 @@ TAP=""
LOCKFILE=""
for tap in $POSSIBLE; do
LOCKFILE="$LOCKDIR/$tap"
- if lockfile -2 -r 1 $LOCKFILE; then
+ echo "Acquiring lockfile for $tap..."
+ if lockfile-create --use-pid -r 1 $LOCKFILE; then
+ # the --use-pid option to lockfile-create will give use
+ # the subshell's pid, so override it with the shell's pid:
+ echo $$ > $LOCKFILE.lock
TAP=$tap
- break;
- fi
+ break
+ fi
done
if [ "$TAP" = "" ]; then
@@ -79,7 +90,11 @@ if [ "$TAP" = "" ]; then
return
fi
LOCKFILE="$LOCKDIR/$tap"
- if lockfile $LOCKFILE; then
+ echo "Acquiring lockfile for $tap..."
+ if lockfile-create --use-pid -r 1 $LOCKFILE; then
+ # the --use-pid option to lockfile-create will give us
+ # the subshell's pid, so override it with the shell's pid:
+ echo $$ > $LOCKFILE.lock
TAP=$tap
fi
else
@@ -91,7 +106,7 @@ release_lock() {
$QEMUIFDOWN $TAP $POKY_NATIVE_SYSROOT
else
echo "Releasing lockfile of preconfigured tap device '$TAP'"
- rm -f $LOCKFILE
+ lockfile-remove $LOCKFILE
fi
if [ "$NFSRUNNING" = "true" ]; then