Skip to Content.
Sympa Menu

sm-discuss - Re: [SM-Discuss] udev module loading order

sm-discuss AT lists.ibiblio.org

Subject: Public SourceMage Discussion List

List archive

Chronological Thread  
  • From: Juuso Alasuutari <iuso AT sourcemage.org>
  • To: sm-discuss AT lists.ibiblio.org
  • Subject: Re: [SM-Discuss] udev module loading order
  • Date: Sat, 15 Apr 2006 14:52:12 +0300

On Saturday 15 April 2006 11:25, Arwed von Merkatz wrote:
> On Sat, Apr 15, 2006 at 03:51:41AM +0300, Juuso Alasuutari wrote:
<xxx>
> > How would an external program export a variable back to udev-space to be
> > used with NAME=? I'm still a bit skeptical, but interested.
>
> Pretty simple actually, I just looked it up in the udev man page as I
> haven't done it before:
> KERNEL=="eth0", PROGRAM=="/path/to/our/script", NAME="$result"
>
> $result contains the stdout output of PROGRAM. If PROGRAM returns false
> the whole rule is dropped.

You're right, it is possible. I had looked at the man page before, but
unfortunately my brain memory device handler hasn't been configured with
persistent rules. Sorry. :)

I thought about this, and first I believed there would still be need for
individual rules for each MAC address. But after some udevinfo runs, I can
see that we can do it all with just one line. This is how I think it will
look:

KERNEL=="eth*", SYSFS{address}=="?*", PROGRAM="/path/to/script
$sysfs{address}", NAME="$result"

The script should be like this:

#!/bin/bash
for a in /etc/sysconfig/network/*.dev; do
if [[ -n $(/usr/bin/grep "^\ *MAC='$1'\ *" $a) ]]; then
a=${a/%\.dev}
builtin echo ${a/#\/etc\/sysconfig\/network\/}
fi
done

Juuso




Archive powered by MHonArc 2.6.24.

Top of Page