From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kay Sievers Date: Thu, 10 Feb 2005 11:19:51 +0000 Subject: udev: provide temporary device nodes for callouts Message-Id: <20050210111951.GA6920@vrfy.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: linux-hotplug@vger.kernel.org I've added some code to udev to solve the problem of accessing devices from a callout while no device node is created at that time, cause obviously the callout runs to return the name for the node to be created. Some programs need to access the device to read labels or serial numbers from, but can't know where to create a temporary node, cause udev_root may be at an unknown location or /tmp is read-only. %N - create a temporary node and substitute its name It will be created in udev_root as .tmp-- The node is removed after the namedev call. %p - substitute the DEVPATH of the device For scsi_id to be called from the command line. %P - substitute the name of the parent device The node name of the parent device is queried from the udevdb. This makes it easy to name partitions after the main device, especially if the main device gets its name from a callout or to get the disklabel of the main device to name a partition. %r - substitute udev_root Needed to pass the absolute name of the parent device node to a callout The following examples of disklabel reading apply with different commandline parameters also to scsi_id, that reads the serial number from the main device. Name partitions after disklabel of the parent: SUBSYSTEM="block", KERNEL="*[1-9]", PROGRAM="/sbin/udev_volume_id -l %r/%P" NAME="%c-part%n" Name main device after disklabel and let partitions follow the name of the main device. udevd serializes the events, so that we can be sure, that the node of the main device is created before the partition event tries to access it: SUBSYSTEM="block", KERNEL="*[a-z]", PROGRAM="/sbin/udev_volume_id -l %N, NAME="%c" SUBSYSTEM="block", KERNEL="*[1-9]", NAME="%P-part%n" Name partitions after filestem label: SUBSYSTEM="block", KERNEL="*[1-9]", PROGRAM="/sbin/udev_volume_id -l %N" udev_volume_id does not longer create any temporary device node or searches the parent device by itself. It expects the name of the node as illustrated in the examples. Thanks, Kay ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_ide95&alloc_id396&op=click _______________________________________________ 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