Bruce Dubbs wrote:
> Matthew Burgess wrote:
>> On Tue, 04 Oct 2011 21:45:13 -0700, Bryan Kadzban 
>> <br...@kadzban.is-a-geek.net> wrote:
>>> Longer term, we can remove the --type=failed invocation entirely,
>>> although maybe that's better done as part of this change?
>>
>> I'd prefer to do that in this change.  As you mention in the patch,
>> this won't work with the current version of Udev in the book, so we
>> may as well get rid.

Works for me; done.

> A review of the patch appears to be OK to me, but I think there are a
> couple of other issues to consider.
> 
> First, -type=failed does still work.  It's labeled as depreciated and
> gives a warning message (that is optionally removed with a sed in the
> build instructions).  Having both methods should work for now.

Well, it doesn't actually work.  It just sort of seems to.

No event in the udev database matches --type=failed right now, since
none of the RUN+= invocations in the rules use {fail_event_on_error}.
So the re-trigger will do exactly nothing, except warn the user (unless
the sed is in place).  It will not actually retry any events.  :-)

<digression into the source code>

See udev-rules.c, around line 1500, for where it parses it from the
rules files, then around line 1060 for where it creates the actual rule
struct instance... thing.  Then around line 2674 for where it looks at
whether .fail_on_error is set to true when applying the rule to an
event, and note that it does a udev_list_entry_set_num(..., true) on the
event.  Then see udev-event.c, around line 1082, where it does the
actual run call (*_spawn), and only signals failure to the caller if
udev_list_entry_get_num() returns a C true-ish value.

Finally, see udevd.c around line 307, where udev_event_execute_run() is
called from the child, and line 321, where the .failed field is set
before sending the result back to the parent.  Finally, see around line
159, where the .failed field is used to decide whether to call
udev_queue_export_device_failed() or _finished().  If the _failed
variant is not called, then --type=failed won't find the event.

</digression>

> Second, the behavior that this adds needs to be documented in the
> book, either in section 7.4 or a new section after 7.5.

Good point.  Did that as well.

However, I see that the udev bootscript has been changed to be far too
specific when copying device nodes out of /lib/udev/devices.  It
currently copies only /dev/null, but it needs to copy everything
(preserving permissions), since that's still the place to put device
nodes that udev can't handle.  There aren't any of those device nodes in
the current book, but there *are* some in the wild (mostly having to do
with crazy outside-the-kernel drivers).

> Let's also keep in mind here what we are trying to do.  This whole
> thing only occurs if /usr or /var are on separate partitions and most
> users don't do that.

Sure, but the current state is *completely* broken for those users, see
above.  We should have fixed this several udev upgrades ago, when the
requirement for {fail_event_on_error} was added.  :-)

> Right now, I think I'd prefer holding this to after 7.0.  What I'm 
> waiting for to do the -rc2 release is the availability of packages on
> kernel.org.

Yeah, I see there's no udev git (or -173 package) yet.  :-/
Index: chapter01/changelog.xml
===================================================================
--- chapter01/changelog.xml     (revision 9611)
+++ chapter01/changelog.xml     (working copy)
@@ -37,6 +37,16 @@
 
 -->
     <listitem>
+      <para>2011-10-04</para>
+      <itemizedlist>
+        <listitem>
+          <para>[bryan] - Fix the udev_retry script, and add an explanation
+          for how to configure it.</para>
+        </listitem>
+      </itemizedlist>
+    </listitem>
+
+    <listitem>
       <para>2011-10-02</para>
       <itemizedlist>
         <listitem>
Index: chapter07/udev.xml
===================================================================
--- chapter07/udev.xml  (revision 9611)
+++ chapter07/udev.xml  (working copy)
@@ -93,7 +93,7 @@
     </sect3>
 
     <sect3>
-      <title>Udev Bootscript</title>
+      <title>Udev Bootscripts</title>
 
       <para>The <command>/etc/rc.d/init.d/udev</command> initscript takes care 
of creating
       device nodes when Linux is booted. The script unsets the uevent handler
@@ -115,6 +115,17 @@
       any devices that have already been registered and then waits for
       <command>udevd</command> to handle them.</para>
 
+      <para>The <command>/etc/rc.d/init.d/udev_retry</command> initscript 
takes care of
+      re-triggering events for subsystems whose rules may rely on filesystems
+      that are not mounted until the <command>mountfs</command> script is run
+      (in particular, /usr and /var may cause this).  This script runs after 
the
+      <command>mountfs</command> script, so those rules (if re-triggered) 
should
+      succeed the second time around.  It is configured from the
+      <filename>/etc/sysconfig/udev_retry</filename> file; any words in this
+      file other than comments are considered subsystem names to trigger at
+      retry time.  (To find the subsystem of a device, use <command>udevadm
+      info --attribute-walk</command>.)</para>
+
     </sect3>
 
     <sect3>
Index: packages.ent
===================================================================
--- packages.ent        (revision 9611)
+++ packages.ent        (working copy)
@@ -298,7 +298,7 @@
 <!ENTITY less-ch6-du "3.5 MB">
 <!ENTITY less-ch6-sbu "less than 0.1 SBU">
 
-<!ENTITY lfs-bootscripts-version "20110926">                 <!-- Scripts 
depend on this format -->
+<!ENTITY lfs-bootscripts-version "20111004">                 <!-- Scripts 
depend on this format -->
 <!ENTITY lfs-bootscripts-size "BOOTSCRIPTS-SIZE KB">         <!-- Updated in 
Makefile -->
 <!ENTITY lfs-bootscripts-url 
"&downloads-root;lfs-bootscripts-&lfs-bootscripts-version;.tar.bz2">
 <!ENTITY lfs-bootscripts-md5 "BOOTSCRIPTS-MD5SUM">           <!-- Updated in 
Makefile -->
Index: bootscripts/lfs/sysconfig/udev_retry
===================================================================
--- bootscripts/lfs/sysconfig/udev_retry        (revision 0)
+++ bootscripts/lfs/sysconfig/udev_retry        (revision 0)
@@ -0,0 +1,19 @@
+########################################################################
+# Begin /etc/sysconfig/udev_retry
+#
+# Description : udev_retry script configuration
+#
+# Authors     :
+#
+# Version     : 00.00
+#
+# Notes       : Each subsystem that may need to be re-triggered after mountfs
+#               runs should be listed in this file.  Probable subsystems to be
+#               listed here are rtc (due to /var/lib/hwclock/adjtime) and sound
+#               (due to both /var/lib/alsa/asound.state and /usr/sbin/alsactl).
+#               Entries are whitespace-separated.
+########################################################################
+
+rtc
+
+# End /etc/sysconfig/udev_retry
Index: bootscripts/lfs/init.d/udev_retry
===================================================================
--- bootscripts/lfs/init.d/udev_retry   (revision 9611)
+++ bootscripts/lfs/init.d/udev_retry   (working copy)
@@ -44,8 +44,14 @@
          rm -f $file
       done
 
-      # Re-trigger the failed uevents in hope they will succeed now
-      /sbin/udevadm trigger --type=failed --action=add
+      # Re-trigger the uevents that may have failed, in hope they will succeed
+      # now
+      /bin/sed -e 's/#.*$//' /etc/sysconfig/udev_retry | /bin/grep -v '^$' | \
+      while read line ; do
+         for subsystem in $line ; do
+            /sbin/udevadm trigger --subsystem-match=$subsystem --action=add
+         done
+      done
 
       # Now wait for udevd to process the uevents we triggered
       /sbin/udevadm settle
Index: bootscripts/ChangeLog
===================================================================
--- bootscripts/ChangeLog       (revision 9611)
+++ bootscripts/ChangeLog       (working copy)
@@ -1,4 +1,10 @@
-2100-09-18
+2011-10-04  Bryan Kadzban <br...@linuxfromscratch.org>
+   * Add configuration for udev_retry, and remove --type=failed (which does
+     not work with recent udev versions anyway, since no events can possibly
+     trigger it).  Start with just the "rtc" subsystem.  BLFS should
+     eventually add "sound" to this file, and perhaps others.
+
+2011-09-18
    * Review and update of changes made in previous change.
    ** Rename /etc/sysconfig/init_params to /etc/sysconfig/rc.site.
    ** Move network services to /lib/services.
Index: bootscripts/Makefile
===================================================================
--- bootscripts/Makefile        (revision 9611)
+++ bootscripts/Makefile        (working copy)
@@ -60,6 +60,9 @@
        if [ ! -f ${EXTDIR}/sysconfig/modules     ]; then \
           install -m ${CONFMODE} lfs/sysconfig/modules     
${EXTDIR}/sysconfig/ ;\
         fi
+       if [ ! -f ${EXTDIR}/sysconfig/udev_retry  ]; then \
+          install -m ${CONFMODE} lfs/sysconfig/udev_retry  
${EXTDIR}/sysconfig/ ;\
+        fi
        if [ ! -f ${EXTDIR}/sysconfig/rc          ]; then \
           install -m ${CONFMODE} lfs/sysconfig/rc          
${EXTDIR}/sysconfig/ ;\
         fi

Attachment: signature.asc
Description: OpenPGP digital signature

-- 
http://linuxfromscratch.org/mailman/listinfo/lfs-dev
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page

Reply via email to