From: Rainer Dorsch <rdorsch@web.de>
To: linux-hotplug@vger.kernel.org
Subject: hotplug and test and set
Date: Sat, 01 Jan 2005 23:03:46 +0000 [thread overview]
Message-ID: <200501020003.46376.rdorsch@web.de> (raw)
Hello,
I have an Epox DG02A usb dongle for bluetooth.
$ ls usbview
[...]
Bus 003 Device 002: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle
I added a script to start pand into my /etc/hotplug.d/usb directory on my
Debian system.
rd@topsi:~$ cat /etc/hotplug.d/usb/epox-bluetooth.hotplug
#!/bin/sh
pidfile=/var/run/pand.pid
lockfile=/var/lock/pand.lock
DAEMON=/usr/bin/pand
case `echo $PRODUCT|cut -d / -f 1-2` in
# a12/1/525 and a12/1/828 have been seen for the Epox BT DB02A
a12/1) break ;;
*) exit ;;
esac
case $TYPE in
224/1/1) break ;;
*) exit ;;
esac
case $ACTION in
add)
# poor man's locking
if [ ! -e $lockfile ]; then
touch $lockfile
echo entered locked area >> /tmp/epox.log
hcitool scan >> /tmp/epox.log
sleep 1
start-stop-daemon --start --exec $DAEMON -- --nodetach --role
PANU --search --encrypt --pidfile $pidfile
fi
;;
remove)
start-stop-daemon --stop --exec $DAEMON --pidfile $pidfile
rm $lockfile
ifdown bnep0
;;
esac
rd@topsi:~$
My problem is that this script is called four times when the dongle is plugged
in. I order to avoid to call pand four times, I added a poor test and set to
the script to add a lock when a pand is running. Does anybody know, what I
could do to get a better locking behaviour, e.g. an atomic test and set?
Many thanks,
Rainer
--
Rainer Dorsch
Alzentalstr. 28
D-71083 Herrenberg
07032-919495
Icq: 32550367
-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
next reply other threads:[~2005-01-01 23:03 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-01-01 23:03 Rainer Dorsch [this message]
2005-01-02 0:06 ` hotplug and test and set Kay Sievers
2005-01-02 1:27 ` Marco d'Itri
2005-01-02 13:30 ` Rainer Dorsch
2005-01-02 15:23 ` Kay Sievers
2005-01-02 17:07 ` Rainer Dorsch
2005-01-02 18:15 ` Kay Sievers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200501020003.46376.rdorsch@web.de \
--to=rdorsch@web.de \
--cc=linux-hotplug@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.