From ac28b86d631f23b5df74dbeb33e76a2b3f5d88bb Mon Sep 17 00:00:00 2001 From: "kay.sievers@vrfy.org" Date: Mon, 12 Jan 2004 21:39:05 -0800 Subject: [PATCH] udev - drop all methods :) > Hi, > as promised yesterday, here is a patch that drops the explicit methods > given in the udev config and implement only one type of rule. > > A rule now consists only of a number of keys to match. All known keys > are valid in any combination. The former configs should work with a few > changes: > > o the ", " at the beginning of the line should be removed > > o the result of the externel program is matched with RESULT= instead if ID= > the PROGRAM= key is only valid if the program exits with zero > (just exit with nozero in a script if the rule should not match) > > o rules are processed in order they appear in the file, no priority > > o if NAME="" is given, udev is instructed to ignore this device, > no node will be created > > > EXAMPLE: > > # combined BUS, SYSFS and KERNEL > BUS="usb", KERNEL="video*", SYSFS_model="Creative Labs WebCam*", NAME="test/webcam%n" > > # exec script only for the first ide drive (hda), all other will be skipped > BUS="ide", KERNEL="hda*", PROGRAM="/home/kay/src/udev.kay/extras/ide-devfs.sh %k %b %n", RESULT="hd*", NAME="%1c", SYMLINK="%2c %3c" > > > The udev-test.pl and test.block works fine here. > Please adapt your config and give it a try. > Here is a slightly better version of the patch. After a conversation with Patrick, we are now able to execute the PROGRAM and also match in all following rules with the RESULT value from this exec. EXAMPLE: We have 7 rules with RESULT and 2 with PROGRAM. Only the 5th rule matches with the callout result from the exec in the 4th rule. RULES: PROGRAM="/bin/echo abc", RESULT="no_match", NAME="web-no-2" KERNEL="video*", RESULT="123", NAME="web-no-3" KERNEL="video*", RESULT="123", NAME="web-no-4" PROGRAM="/bin/echo 123", RESULT="no_match", NAME="web-no-5" KERNEL="video*", RESULT="123", NAME="web-yes" RESULT: Jan 11 23:36:52 pim udev[26050]: namedev_name_device: process rule Jan 11 23:36:52 pim udev[26050]: namedev_name_device: check PROGRAM Jan 11 23:36:52 pim udev[26050]: execute_program: executing '/bin/echo abc' Jan 11 23:36:52 pim udev[26050]: execute_program: result is 'abc' Jan 11 23:36:52 pim udev[26050]: namedev_name_device: PROGRAM returned successful Jan 11 23:36:52 pim udev[26050]: namedev_name_device: check for RESULT dev->result='no_match', udev->program_result='abc' Jan 11 23:36:52 pim udev[26050]: namedev_name_device: RESULT is not matching Jan 11 23:36:52 pim udev[26050]: namedev_name_device: process rule Jan 11 23:36:52 pim udev[26050]: namedev_name_device: check for KERNEL dev->kernel='video*' class_dev->name='video0' Jan 11 23:36:52 pim udev[26050]: namedev_name_device: KERNEL matches Jan 11 23:36:52 pim udev[26050]: namedev_name_device: check for RESULT dev->result='123', udev->program_result='abc' Jan 11 23:36:52 pim udev[26050]: namedev_name_device: RESULT is not matching Jan 11 23:36:52 pim udev[26050]: namedev_name_device: process rule Jan 11 23:36:52 pim udev[26050]: namedev_name_device: check for KERNEL dev->kernel='video*' class_dev->name='video0' Jan 11 23:36:52 pim udev[26050]: namedev_name_device: KERNEL matches Jan 11 23:36:52 pim udev[26050]: namedev_name_device: check for RESULT dev->result='123', udev->program_result='abc' Jan 11 23:36:52 pim udev[26050]: namedev_name_device: RESULT is not matching Jan 11 23:36:52 pim udev[26050]: namedev_name_device: process rule Jan 11 23:36:52 pim udev[26050]: namedev_name_device: check PROGRAM Jan 11 23:36:52 pim udev[26050]: execute_program: executing '/bin/echo 123' Jan 11 23:36:52 pim udev[26050]: execute_program: result is '123' Jan 11 23:36:52 pim udev[26050]: namedev_name_device: PROGRAM returned successful Jan 11 23:36:52 pim udev[26050]: namedev_name_device: check for RESULT dev->result='no_match', udev->program_result='123' Jan 11 23:36:52 pim udev[26050]: namedev_name_device: RESULT is not matching Jan 11 23:36:52 pim udev[26050]: namedev_name_device: process rule Jan 11 23:36:52 pim udev[26050]: namedev_name_device: check for KERNEL dev->kernel='video*' class_dev->name='video0' Jan 11 23:36:52 pim udev[26050]: namedev_name_device: KERNEL matches Jan 11 23:36:52 pim udev[26050]: namedev_name_device: check for RESULT dev->result='123', udev->program_result='123' Jan 11 23:36:52 pim udev[26050]: namedev_name_device: RESULT matches Jan 11 23:36:52 pim udev[26050]: namedev_name_device: found matching rule, 'video*' becomes '' Jan 11 23:36:52 pim udev[26050]: namedev_name_device: name, 'web-yes' is going to have owner='', group='', mode = 0600 --- test/udev-test.pl | 117 ++++++++++++++++++++++++++---------------------------- 1 file changed, 57 insertions(+), 60 deletions(-) (limited to 'test') diff --git a/test/udev-test.pl b/test/udev-test.pl index 97c0094921..ab27c74c6a 100644 --- a/test/udev-test.pl +++ b/test/udev-test.pl @@ -38,8 +38,8 @@ my @tests = ( devpath => "block/sda", expected => "boot_disk" , conf => < "block/sda/sda1", expected => "boot_disk1" , conf => < "block/sda/sda1", expected => "boot_disk1" , conf => < "block/sda/sda1", expected => "boot_disk1" , conf => < "block/sda/sda1", expected => "boot_disk1" , conf => < "class/tty/ttyUSB0", expected => "visor/0" , conf => < "class/tty/ttyUSB0", expected => "visor/0" , conf => < "class/tty/ttyUSB0", expected => "visor/0" , conf => < "class/tty/ttyUSB0", expected => "visor" , conf => < "visor" , conf => < "visor" , conf => < "visor" , conf => < "class/tty/ttyUSB0", expected => "sub/direct/ory/visor" , conf => < "block/sda/sda3", expected => "first_disk3" , conf => < "block/sda/sda3", expected => "Major:8:minor:3:kernelnumber:3:bus:0:0:0:0" , conf => < "callout result substitution", + desc => "program result substitution", subsys => "block", devpath => "block/sda/sda3", expected => "special-device-3" , conf => < "callout program substitution", + desc => "program result substitution", subsys => "block", devpath => "block/sda/sda3", expected => "test-0:0:0:0" , conf => < "callout program substitution (numbered part of)", + desc => "program result substitution (numbered part of)", subsys => "block", devpath => "block/sda/sda3", expected => "link1" , conf => < "invalid callout for device with no bus", + desc => "invalid program for device with no bus", subsys => "tty", devpath => "class/tty/console", expected => "TTY" , conf => < "valid callout for device with no bus", + desc => "valid program for device with no bus", subsys => "tty", devpath => "class/tty/console", expected => "foo" , conf => < "class/tty/console", expected => "TTY" , conf => < "class/tty/console", expected => "foo" , conf => < "block/sda", expected => "lun0/disc" , conf => < "block/sda/sda2", expected => "lun0/part2" , conf => < "callout bus type", + desc => "program and bus type match", subsys => "block", devpath => "block/sda", expected => "scsi-0:0:0:0" , conf => < "class/tty/ttyUSB0", expected => "visor0" , conf => < "block/sda/sda2", expected => "1/2/a/b/symlink" , conf => < "block/sda/sda2", expected => "1/2/symlink" , conf => < "block/sda/sda2", expected => "1/2/c/d/symlink" , conf => < "class/tty/ttyUSB0", expected => "second-0" , conf => <{conf} =~ m/([A-Z]+)\s*,/; - my $method = $1; - print "TEST: $config->{desc}\n"; - print "method \'$method\' for \'$config->{devpath}\' expecting node \'$config->{expected}\'\n"; + print "device \'$config->{devpath}\' expecting node \'$config->{expected}\'\n"; udev("add", $config->{subsys}, $config->{devpath}, \$config->{conf}); if (-e "$PWD/$udev_root$config->{expected}") { -- cgit v1.2.3-54-g00ecf