From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Adam J. Richter" Date: Wed, 07 Feb 2001 02:38:02 +0000 Subject: Re: Adding PCMCIA support to the kernel tree -- developers needed. Message-Id: List-Id: References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: linux-hotplug@vger.kernel.org >> = Andrew Morton > = Oliver Neukum >> You're right, it _can_ be done by synthesizing hotpluf >> events from the initscripts. In fact, that's how it >> must be done. > >I am afraid it cannot be simply done from the init scripts. >Simply parsing proc has an unavoidable race condition. >You need to lock it. > > HTH > Oliver I said, "scan the bus *after* initializing the hot plugging support and deal with devices that are already plugged in [...]" You may process a device twice this way, but user level software can detect this and synchronize when this is really necessary. In most cases, you just want to modprobe a module, which can safely be done multiple times, so it is not necessary to bother checking. Also, since the races are done once the init script completes (before any user logs in), you can safely do things like load the saved device settings without worrying about clobbering any work done before. In cases where you really need to avoid doing something twice (such as spawning a dhcp client on an ethernet port), you can do your synchronization at user level, by something like: # "insert" script netif=$1 # For example "eth0" # /var/run was previous cleared earlier in the boot process, so # we know that if this directory exists, we have been called # twice. if mkdir /var/run/$netif ; then dhclient -pf /var/run/$netif/pid $netif & fi # "remove" script netif=$1 # For example "eth0" kill $(cat /var/run/netif/$netif/pid) rm -rf /var/run/$netif Adam J. Richter __ ______________ 4880 Stevens Creek Blvd, Suite 104 adam@yggdrasil.com \ / San Jose, California 95129-1034 +1 408 261-6630 | g g d r a s i l United States of America fax +1 408 261-6631 "Free Software For The Rest Of Us." _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net http://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel