--- /var/tmp/portage/hal-0.5.5.1/work/hal-0.5.5.1/tools/linux/hal_hotplug.c 2005-11-02 16:38:14.000000000 +0100 +++ hal_hotplug.c 2005-12-09 21:53:15.000000000 +0100 @@ -44,6 +44,9 @@ #include #include #include +#include +#include +#include #include "../../hald/linux2/hotplug_helper.h" @@ -108,7 +111,10 @@ char *seqnum_str; char *devname; int net_ifindex = -1; - unsigned long long seqnum; + unsigned long long seqnum = 0; + int shmfd, seqnum_wait = 0; + unsigned long long *lastseqnum = NULL; + struct timespec seqnum_sleep = { 0, 10000 }; // 10 msec wait between polls if (argc != 2) return 1; @@ -151,6 +157,14 @@ devname = getenv ("DEVNAME"); + if (fork()) exit(0); + shmfd = shm_open("/hal.hotplug",O_RDWR|O_CREAT,0600); + ftruncate(shmfd,sizeof(*lastseqnum)); + lastseqnum = mmap(NULL,sizeof(*lastseqnum),PROT_READ|PROT_WRITE,MAP_SHARED,shmfd,0); + if (lastseqnum) while (seqnum_wait++ < 50 && *lastseqnum < seqnum-1) nanosleep(&seqnum_sleep,NULL); + + /*syslog (LOG_INFO, "ACTION=%s SUBSYS=%s SEQNUM=%s DEVPATH=%s PHYSDEVPATH=%s wait=%i", + getenv ("ACTION"), argv[1], getenv ("SEQNUM"), getenv ("DEVPATH"), getenv ("PHYSDEVPATH"), seqnum_wait); */ /* pickup ifindex for net as nameif'ing the interface a * hotplug event handler will screw us otherwise */ @@ -198,5 +212,6 @@ } out: + if (lastseqnum) *lastseqnum = seqnum; return 0; } --- /var/tmp/portage/hal-0.5.5.1/work/hal-0.5.5.1/tools/linux/Makefile.am 2005-12-09 21:57:17.000000000 +0100 +++ Makefile.am 2005-12-09 21:57:12.000000000 +0100 @@ -18,6 +18,7 @@ endif hal_hotplug_SOURCES = hal_hotplug.c +hal_hotplug_LDADD = -lrt clean-local :