diff options
author | kay.sievers@vrfy.org <kay.sievers@vrfy.org> | 2004-03-24 23:19:39 -0800 |
---|---|---|
committer | Greg KH <gregkh@suse.de> | 2005-04-26 21:35:12 -0700 |
commit | f61d732a02c8a5e11c39651a70e3e3fd00529495 (patch) | |
tree | c0d5c08372c1efcb4e668075c796e5b6aa5edb65 /test | |
parent | 3e33961b4557f9b709c901b4aa77dfe0220222bd (diff) |
[PATCH] hmm, handle net devices with udev?
Hmm, Arndt Bergmann sent a patch like this one a few weeks ago and
I want to bring the question back, if we want to handle net device
naming with udev.
With this patch it is actually possible to specify something like this
in udev.rules:
KERNEL="dummy*", SYSFS{address}="00:00:00:00:00:00", SYSFS{features}="0x0", NAME="blind%n"
KERNEL="eth*", SYSFS{address}="00:0d:60:77:30:91", NAME="private"
and you will get:
[root@pim udev.kay]# cat /proc/net/dev
Inter-| Receive | Transmit
face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
lo: 1500 30 0 0 0 0 0 0 1500 30 0 0 0 0 0 0
private: 278393 1114 0 0 0 0 0 0 153204 1468 0 0 0 0 0 0
sit0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
blind0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
The udevinfo program is also working:
[root@pim udev.kay]# ./udevinfo -a -p /sys/class/net/private
looking at class device '/sys/class/net/private':
SYSFS{addr_len}="6"
SYSFS{address}="00:0d:60:77:30:91"
SYSFS{broadcast}="ff:ff:ff:ff:ff:ff"
SYSFS{features}="0x3a9"
SYSFS{flags}="0x1003"
SYSFS{ifindex}="2"
SYSFS{iflink}="2"
SYSFS{mtu}="1500"
SYSFS{tx_queue_len}="1000"
SYSFS{type}="1"
follow the class device's "device"
looking at the device chain at '/sys/devices/pci0000:00/0000:00:1e.0/0000:02:01.0':
BUS="pci"
ID="0000:02:01.0"
SYSFS{class}="0x020000"
SYSFS{detach_state}="0"
SYSFS{device}="0x101e"
SYSFS{irq}="11"
SYSFS{subsystem_device}="0x0549"
SYSFS{subsystem_vendor}="0x1014"
SYSFS{vendor}="0x8086"
The matching device will be renamed to the given name. The device name
will not be put into the udev database, cause the kernel renames the
device and the sysfs name disappears.
I like it, cause it plugs in nicely. We have all the naming features
and sysfs queries and walks inside of udev. The sysfs timing races
are already solved and the management tools are working for net devices
too. nameif can only match the MAC address now. udev can match any sysfs
value of the device tree the net device is connected to.
But right, net devices do not have device nodes :)
Diffstat (limited to 'test')
-rw-r--r-- | test/udev-test.pl | 110 |
1 files changed, 55 insertions, 55 deletions
diff --git a/test/udev-test.pl b/test/udev-test.pl index d93ebb9cc3..8ae01c31d4 100644 --- a/test/udev-test.pl +++ b/test/udev-test.pl @@ -35,7 +35,7 @@ my @tests = ( { desc => "label test of scsi disc", subsys => "block", - devpath => "block/sda", + devpath => "/block/sda", exp_name => "boot_disk" , conf => <<EOF BUS="scsi", SYSFS{vendor}="IBM-ESXS", NAME="boot_disk%n" @@ -45,7 +45,7 @@ EOF { desc => "label test of scsi partition", subsys => "block", - devpath => "block/sda/sda1", + devpath => "/block/sda/sda1", exp_name => "boot_disk1" , conf => <<EOF BUS="scsi", SYSFS{vendor}="IBM-ESXS", NAME="boot_disk%n" @@ -54,7 +54,7 @@ EOF { desc => "label test of pattern match", subsys => "block", - devpath => "block/sda/sda1", + devpath => "/block/sda/sda1", exp_name => "boot_disk1" , conf => <<EOF BUS="scsi", SYSFS{vendor}="?IBM-ESXS", NAME="boot_disk%n-1" @@ -66,7 +66,7 @@ EOF { desc => "label test of multiple sysfs files", subsys => "block", - devpath => "block/sda/sda1", + devpath => "/block/sda/sda1", exp_name => "boot_disk1" , conf => <<EOF BUS="scsi", SYSFS{vendor}="IBM-ESXS", SYSFS{model}="ST336605LW !#", NAME="boot_diskX%n" @@ -76,7 +76,7 @@ EOF { desc => "label test of max sysfs files", subsys => "block", - devpath => "block/sda/sda1", + devpath => "/block/sda/sda1", exp_name => "boot_disk1" , conf => <<EOF BUS="scsi", SYSFS{vendor}="IBM-ESXS", SYSFS{model}="ST336605LW !#", SYSFS{scsi_level}="4", SYSFS{rev}="B245", SYSFS{type}="2", SYSFS{queue_depth}="32", NAME="boot_diskXX%n" @@ -86,7 +86,7 @@ EOF { desc => "catch device by *", subsys => "tty", - devpath => "class/tty/ttyUSB0", + devpath => "/class/tty/ttyUSB0", exp_name => "visor/0" , conf => <<EOF KERNEL="ttyUSB*", NAME="visor/%n" @@ -95,7 +95,7 @@ EOF { desc => "catch device by * - take 2", subsys => "tty", - devpath => "class/tty/ttyUSB0", + devpath => "/class/tty/ttyUSB0", exp_name => "visor/0" , conf => <<EOF KERNEL="*USB1", NAME="bad" @@ -105,7 +105,7 @@ EOF { desc => "catch device by ?", subsys => "tty", - devpath => "class/tty/ttyUSB0", + devpath => "/class/tty/ttyUSB0", exp_name => "visor/0" , conf => <<EOF KERNEL="ttyUSB??*", NAME="visor/%n-1" @@ -116,7 +116,7 @@ EOF { desc => "catch device by character class", subsys => "tty", - devpath => "class/tty/ttyUSB0", + devpath => "/class/tty/ttyUSB0", exp_name => "visor/0" , conf => <<EOF KERNEL="ttyUSB[A-Z]*", NAME="visor/%n-1" @@ -127,7 +127,7 @@ EOF { desc => "replace kernel name", subsys => "tty", - devpath => "class/tty/ttyUSB0", + devpath => "/class/tty/ttyUSB0", exp_name => "visor" , conf => <<EOF KERNEL="ttyUSB0", NAME="visor" @@ -136,7 +136,7 @@ EOF { desc => "Handle comment lines in config file (and replace kernel name)", subsys => "tty", - devpath => "class/tty/ttyUSB0", + devpath => "/class/tty/ttyUSB0", exp_name => "visor" , conf => <<EOF # this is a comment @@ -147,7 +147,7 @@ EOF { desc => "Handle comment lines in config file with whitespace (and replace kernel name)", subsys => "tty", - devpath => "class/tty/ttyUSB0", + devpath => "/class/tty/ttyUSB0", exp_name => "visor" , conf => <<EOF # this is a comment with whitespace before the comment @@ -158,7 +158,7 @@ EOF { desc => "Handle empty lines in config file (and replace kernel name)", subsys => "tty", - devpath => "class/tty/ttyUSB0", + devpath => "/class/tty/ttyUSB0", exp_name => "visor" , conf => <<EOF @@ -169,7 +169,7 @@ EOF { desc => "subdirectory handling", subsys => "tty", - devpath => "class/tty/ttyUSB0", + devpath => "/class/tty/ttyUSB0", exp_name => "sub/direct/ory/visor" , conf => <<EOF KERNEL="ttyUSB0", NAME="sub/direct/ory/visor" @@ -178,7 +178,7 @@ EOF { desc => "place on bus of scsi partition", subsys => "block", - devpath => "block/sda/sda3", + devpath => "/block/sda/sda3", exp_name => "first_disk3" , conf => <<EOF BUS="scsi", PLACE="0:0:0:0", NAME="first_disk%n" @@ -187,7 +187,7 @@ EOF { desc => "test NAME substitution chars", subsys => "block", - devpath => "block/sda/sda3", + devpath => "/block/sda/sda3", exp_name => "Major:8:minor:3:kernelnumber:3:bus:0:0:0:0" , conf => <<EOF BUS="scsi", PLACE="0:0:0:0", NAME="Major:%M:minor:%m:kernelnumber:%n:bus:%b" @@ -196,7 +196,7 @@ EOF { desc => "test NAME substitution chars (with length limit)", subsys => "block", - devpath => "block/sda/sda3", + devpath => "/block/sda/sda3", exp_name => "M8-m3-n3-b0:0-sIBM" , conf => <<EOF BUS="scsi", PLACE="0:0:0:0", NAME="M%M-m%m-n%n-b%3b-s%3s{vendor}" @@ -205,7 +205,7 @@ EOF { desc => "old style SYSFS_ attribute", subsys => "block", - devpath => "block/sda", + devpath => "/block/sda", exp_name => "good" , conf => <<EOF BUS="scsi", SYSFS_vendor="IBM-ESXS", NAME="good" @@ -214,7 +214,7 @@ EOF { desc => "sustitution of sysfs value (%s{file})", subsys => "block", - devpath => "block/sda", + devpath => "/block/sda", exp_name => "disk-IBM-ESXS-sda" , conf => <<EOF BUS="scsi", SYSFS{vendor}="IBM-ESXS", NAME="disk-%s{vendor}-%k" @@ -224,7 +224,7 @@ EOF { desc => "program result substitution", subsys => "block", - devpath => "block/sda/sda3", + devpath => "/block/sda/sda3", exp_name => "special-device-3" , conf => <<EOF BUS="scsi", PROGRAM="/bin/echo -n special-device", RESULT="-special-*", NAME="%c-1-%n" @@ -237,7 +237,7 @@ EOF { desc => "program result substitution", subsys => "block", - devpath => "block/sda/sda3", + devpath => "/block/sda/sda3", exp_name => "test-0:0:0:0" , conf => <<EOF BUS="scsi", PROGRAM="/bin/echo -n test-%b", RESULT="test-0:0*", NAME="%c" @@ -246,7 +246,7 @@ EOF { desc => "program with escaped format char (tricky: callout returns format char!)", subsys => "block", - devpath => "block/sda/sda3", + devpath => "/block/sda/sda3", exp_name => "escape-3" , conf => <<EOF BUS="scsi", PROGRAM="/bin/echo -n escape-%%n", KERNEL="sda3", NAME="%c" @@ -255,7 +255,7 @@ EOF { desc => "program with lots of arguments", subsys => "block", - devpath => "block/sda/sda3", + devpath => "/block/sda/sda3", exp_name => "foo9" , conf => <<EOF BUS="scsi", PROGRAM="/bin/echo -n foo3 foo4 foo5 foo6 foo7 foo8 foo9", KERNEL="sda3", NAME="%c{7}" @@ -264,7 +264,7 @@ EOF { desc => "program with subshell", subsys => "block", - devpath => "block/sda/sda3", + devpath => "/block/sda/sda3", exp_name => "bar9" , conf => <<EOF BUS="scsi", PROGRAM="/bin/sh -c 'echo foo3 foo4 foo5 foo6 foo7 foo8 foo9 | sed s/foo9/bar9/'", KERNEL="sda3", NAME="%c{7}" @@ -273,7 +273,7 @@ EOF { desc => "program arguments combined with apostrophes", subsys => "block", - devpath => "block/sda/sda3", + devpath => "/block/sda/sda3", exp_name => "foo7" , conf => <<EOF BUS="scsi", PROGRAM="/bin/echo -n 'foo3 foo4' 'foo5 foo6 foo7 foo8'", KERNEL="sda3", NAME="%c{5}" @@ -282,7 +282,7 @@ EOF { desc => "characters before the %c{N} substitution", subsys => "block", - devpath => "block/sda/sda3", + devpath => "/block/sda/sda3", exp_name => "my-foo9" , conf => <<EOF BUS="scsi", PROGRAM="/bin/echo -n foo3 foo4 foo5 foo6 foo7 foo8 foo9", KERNEL="sda3", NAME="my-%c{7}" @@ -291,7 +291,7 @@ EOF { desc => "substitute the second to last argument", subsys => "block", - devpath => "block/sda/sda3", + devpath => "/block/sda/sda3", exp_name => "my-foo8" , conf => <<EOF BUS="scsi", PROGRAM="/bin/echo -n foo3 foo4 foo5 foo6 foo7 foo8 foo9", KERNEL="sda3", NAME="my-%c{6}" @@ -300,7 +300,7 @@ EOF { desc => "program result substitution (numbered part of)", subsys => "block", - devpath => "block/sda/sda3", + devpath => "/block/sda/sda3", exp_name => "link1" , conf => <<EOF BUS="scsi", PROGRAM="/bin/echo -n node link1 link2", RESULT="node *", NAME="%c{1}", SYMLINK="%c{2} %c{3}" @@ -309,7 +309,7 @@ EOF { desc => "program result substitution (numbered part of+)", subsys => "block", - devpath => "block/sda/sda3", + devpath => "/block/sda/sda3", exp_name => "link3" , conf => <<EOF BUS="scsi", PROGRAM="/bin/echo -n node link1 link2 link3 link4", RESULT="node *", NAME="%c{1}", SYMLINK="%c{2+}" @@ -318,7 +318,7 @@ EOF { desc => "invalid program for device with no bus", subsys => "tty", - devpath => "class/tty/console", + devpath => "/class/tty/console", exp_name => "TTY" , conf => <<EOF BUS="scsi", PROGRAM="/bin/echo -n foo", RESULT="foo", NAME="foo" @@ -328,7 +328,7 @@ EOF { desc => "valid program for device with no bus", subsys => "tty", - devpath => "class/tty/console", + devpath => "/class/tty/console", exp_name => "foo" , conf => <<EOF PROGRAM="/bin/echo -n foo", RESULT="foo", NAME="foo" @@ -338,7 +338,7 @@ EOF { desc => "invalid label for device with no bus", subsys => "tty", - devpath => "class/tty/console", + devpath => "/class/tty/console", exp_name => "TTY" , conf => <<EOF BUS="foo", SYSFS{dev}="5:1", NAME="foo" @@ -348,7 +348,7 @@ EOF { desc => "valid label for device with no bus", subsys => "tty", - devpath => "class/tty/console", + devpath => "/class/tty/console", exp_name => "foo" , conf => <<EOF SYSFS{dev}="5:1", NAME="foo" @@ -358,7 +358,7 @@ EOF { desc => "program and bus type match", subsys => "block", - devpath => "block/sda", + devpath => "/block/sda", exp_name => "scsi-0:0:0:0" , conf => <<EOF BUS="usb", PROGRAM="/bin/echo -n usb-%b", NAME="%c" @@ -369,7 +369,7 @@ EOF { desc => "symlink creation (same directory)", subsys => "tty", - devpath => "class/tty/ttyUSB0", + devpath => "/class/tty/ttyUSB0", exp_name => "visor0" , conf => <<EOF KERNEL="ttyUSB[0-9]*", NAME="ttyUSB%n", SYMLINK="visor%n" @@ -378,7 +378,7 @@ EOF { desc => "symlink creation (relative link back)", subsys => "block", - devpath => "block/sda/sda2", + devpath => "/block/sda/sda2", exp_name => "1/2/a/b/symlink" , conf => <<EOF BUS="scsi", SYSFS{vendor}="IBM-ESXS", NAME="1/2/node", SYMLINK="1/2/a/b/symlink" @@ -387,7 +387,7 @@ EOF { desc => "symlink creation (relative link forward)", subsys => "block", - devpath => "block/sda/sda2", + devpath => "/block/sda/sda2", exp_name => "1/2/symlink" , conf => <<EOF BUS="scsi", SYSFS{vendor}="IBM-ESXS", NAME="1/2/a/b/node", SYMLINK="1/2/symlink" @@ -396,7 +396,7 @@ EOF { desc => "symlink creation (relative link back and forward)", subsys => "block", - devpath => "block/sda/sda2", + devpath => "/block/sda/sda2", exp_name => "1/2/c/d/symlink" , conf => <<EOF BUS="scsi", SYSFS{vendor}="IBM-ESXS", NAME="1/2/a/b/node", SYMLINK="1/2/c/d/symlink" @@ -405,7 +405,7 @@ EOF { desc => "multiple symlinks", subsys => "tty", - devpath => "class/tty/ttyUSB0", + devpath => "/class/tty/ttyUSB0", exp_name => "second-0" , conf => <<EOF KERNEL="ttyUSB0", NAME="visor", SYMLINK="first-%n second-%n third-%n" @@ -414,7 +414,7 @@ EOF { desc => "create all possible partitions", subsys => "block", - devpath => "block/sda", + devpath => "/block/sda", exp_name => "boot_disk15" , conf => <<EOF BUS="scsi", SYSFS{vendor}="IBM-ESXS", NAME{all_partitions}="boot_disk" @@ -423,7 +423,7 @@ EOF { desc => "sysfs parent hierarchy", subsys => "tty", - devpath => "class/tty/ttyUSB0", + devpath => "/class/tty/ttyUSB0", exp_name => "visor" , conf => <<EOF SYSFS{idProduct}="2008", NAME="visor" @@ -432,7 +432,7 @@ EOF { desc => "name test with ! in the name", subsys => "block", - devpath => "block/rd!c0d0", + devpath => "/block/rd!c0d0", exp_name => "rd/c0d0" , conf => <<EOF BUS="scsi", NAME="%k" @@ -442,7 +442,7 @@ EOF { desc => "name test with ! in the name, but no matching rule", subsys => "block", - devpath => "block/rd!c0d0", + devpath => "/block/rd!c0d0", exp_name => "rd/c0d0" , conf => <<EOF KERNEL="ttyUSB0", NAME="visor" @@ -451,7 +451,7 @@ EOF { desc => "ID rule", subsys => "block", - devpath => "block/sda", + devpath => "/block/sda", exp_name => "scsi-0:0:0:0", conf => <<EOF BUS="usb", ID="0:0:0:0", NAME="not-scsi" @@ -464,7 +464,7 @@ EOF { desc => "ID wildcard all", subsys => "block", - devpath => "block/sda", + devpath => "/block/sda", exp_name => "scsi-0:0:0:0", conf => <<EOF BUS="scsi", ID="*:1", NAME="no-match" @@ -477,7 +477,7 @@ EOF { desc => "ID wildcard partial", subsys => "block", - devpath => "block/sda", + devpath => "/block/sda", exp_name => "scsi-0:0:0:0", conf => <<EOF BUS="scsi", ID="*:0", NAME="scsi-0:0:0:0" @@ -487,7 +487,7 @@ EOF { desc => "ID wildcard partial 2", subsys => "block", - devpath => "block/sda", + devpath => "/block/sda", exp_name => "scsi-0:0:0:0", conf => <<EOF BUS="scsi", ID="*:0:0:0", NAME="scsi-0:0:0:0" @@ -497,7 +497,7 @@ EOF { desc => "ignore SYSFS attribute whitespace", subsys => "block", - devpath => "block/sda", + devpath => "/block/sda", exp_name => "ignored", conf => <<EOF BUS="scsi", SYSFS{whitespace_test}="WHITE SPACE", NAME="ignored" @@ -506,7 +506,7 @@ EOF { desc => "do not ignore SYSFS attribute whitespace", subsys => "block", - devpath => "block/sda", + devpath => "/block/sda", exp_name => "matched-with-space", conf => <<EOF BUS="scsi", SYSFS{whitespace_test}="WHITE SPACE ", NAME="wrong-to-ignore" @@ -516,7 +516,7 @@ EOF { desc => "SYMLINK only rule", subsys => "block", - devpath => "block/sda", + devpath => "/block/sda", exp_name => "symlink-only2", conf => <<EOF BUS="scsi", KERNEL="sda", SYMLINK="symlink-only1" @@ -527,7 +527,7 @@ EOF { desc => "permissions test", subsys => "block", - devpath => "block/sda", + devpath => "/block/sda", exp_name => "node", exp_perms => "5000::0444", conf => <<EOF @@ -537,7 +537,7 @@ EOF { desc => "major/minor number test", subsys => "block", - devpath => "block/sda", + devpath => "/block/sda", exp_name => "node", exp_majorminor => "8:0", conf => <<EOF @@ -547,7 +547,7 @@ EOF { desc => "big minor number test", subsys => "i2c-dev", - devpath => "class/i2c-dev/i2c-300", + devpath => "/class/i2c-dev/i2c-300", exp_name => "node", exp_majorminor => "89:300", conf => <<EOF @@ -557,7 +557,7 @@ EOF { desc => "big major number test", subsys => "i2c-dev", - devpath => "class/i2c-dev/i2c-fake1", + devpath => "/class/i2c-dev/i2c-fake1", exp_name => "node", exp_majorminor => "4095:1", conf => <<EOF @@ -567,7 +567,7 @@ EOF { desc => "big major and big minor number test", subsys => "i2c-dev", - devpath => "class/i2c-dev/i2c-fake2", + devpath => "/class/i2c-dev/i2c-fake2", exp_name => "node", exp_majorminor => "4094:89999", conf => <<EOF |