Bug 440961

Summary: /sbin/start_udev is calling /usr/bin/find before it may be available
Product: [Fedora] Fedora Reporter: Michal Jaegermann <michal>
Component: udevAssignee: Harald Hoyer <harald>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: low    
Version: rawhide   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2008-04-05 16:31:15 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Michal Jaegermann 2008-04-04 17:50:21 UTC
Description of problem:

There is the following (guarded by "modprobedebug") code in start_udev:

    259                 for i in $(find /sys -name modalias); do
    260                     modules=$(cat $i)
    261                     modprobe -a -v -q $modules
    262                     wait_for_queue $udevtimeout
    263                 done

As this runs before file systems are not mounted then 'find'
may be not there.  OTOH this is using a very limited subset of
find so the following shell code is enough instead:

findalias () {
    local n
    for n in "$1"/* ; do
	[ -h "$n" ] && continue
	[ -d "$n" ] && { findalias "$n" ; continue; }
	[ "${n##*/}" = modalias ] && echo "$n"
    done
}
findalias /sys

Actually we do not need names of those files but their content
so 'echo "$n"' could be replaced by 'cat "$n"'.  With such
modification the "for" loop in question could be rewritten in
such way:

    findalias /sys | while read modules ; do
	[ "$modules" ] && modprobe -a -v -q $modules
	modprobe -a -v -q $modules
	wait_for_queue $udevtimeout
    done

Yes, "$modules" may come out empty.  On my system this happens
for /sys/devices/pci0000:00/0000:00:11.0/i2c-adapter/i2c-0/0-0050/modalias
and /sys/devices/pci0000:00/0000:00:11.0/i2c-adapter/i2c-0/0-0051/modalias.

Version-Release number of selected component (if applicable):
udev-118-11.fc9

Comment 1 Michal Jaegermann 2008-04-04 17:53:16 UTC
"Copy-and-waste".  Again.  Modified loop should read

    findalias /sys | while read modules ; do
	[ "$modules" ] && modprobe -a -v -q $modules
	wait_for_queue $udevtimeout
    done

obviously enough.

Comment 2 Harald Hoyer 2008-04-05 11:32:38 UTC
thanks for the replacement :-)

Comment 3 Harald Hoyer 2008-04-05 16:09:17 UTC
findalias () {
    local n
    for n in "$1"/* ; do
        [ -h "$n" ] && continue
        [ -d "$n" ] && { findalias "$n" ; continue; }
        [ "${n##*/}" == "modalias" ] && echo $(cat $n)
    done
}

findalias /sys | while read modules ; do
    if [ -n "$modules" ]; then
        echo /sbin/modprobe -a -v -q $modules
	wait_for_queue $udevtimeout
    fi
done


Comment 4 Harald Hoyer 2008-04-05 16:28:02 UTC
without echo of course:

findalias /sys | while read modules ; do
    if [ -n "$modules" ]; then
        /sbin/modprobe -a -v -q $modules
	wait_for_queue $udevtimeout
    fi
done



Comment 5 Harald Hoyer 2008-04-05 16:30:41 UTC
udev-120-2