Commit graph

19 commits

Author SHA1 Message Date
greg@kroah.com 851cd18d81 [PATCH] Add some helpful messages if the user uses the older config file format
Also fail a rule that we can not parse, as we can easily create incorrect rules
if we do not do this.
2005-04-26 21:13:15 -07:00
kay.sievers@vrfy.org ac28b86d63 [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 "<METHOD>, " 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
2005-04-26 21:13:15 -07:00
christophe@saout.de f1db055ab2 [PATCH] add IGNORE rule type
On Wed, Dec 31, 2003 at 11:24:53AM -0800, Greg KH wrote:

> > There should be a possibility to tell udev not to create a device node.
> >
> > device-mapper: Usually set up by libdevmapper (or EVMS tools) which
> > creates the device node on its own under /dev/mapper/<name>.
> >
> > With udev a second device is created named /dev/dm-<minor> which is not
> > really needed.
>
> Good point.  Ok, I'll agree with you.  Care to make up a patch for this
> kind of feature?

Yes, I can try.

There was no way to tell not to do anything so I created one. Errors
are signalled via negative return values, so I thought that a positive,
non-zero one could mean to ignore the device. I don't like it but
perhaps you have a better solution.
2005-04-26 21:13:14 -07:00
christophe@saout.de c53735efc9 [PATCH] small cleanup
This one is nothing important, just add some quotes to be more consistent
with the rest and make sure that the return value is positive (since the
error return values are negative). Hmm?
2005-04-26 21:13:14 -07:00
greg@kroah.com 843d1a84b9 [PATCH] replace list_for_each with list_for_each_entry, saving a few lines of code. 2005-04-26 21:13:14 -07:00
kay.sievers@vrfy.org 13148857cb [PATCH] cleanup namedev_parse debug text
I missed a few spaces with my recent change.
2005-04-26 21:13:12 -07:00
kay.sievers@vrfy.org e15b5ed5de [PATCH] small trivial cleanup of latest changes
here is a patch for a typo in the man page, a whitespace cleanup
and a replace for the magic hex ASCII in char operations.
2005-04-26 21:13:11 -07:00
greg@kroah.com 2ae1a0c6f3 [PATCH] Don't require the BUS value for the LABEL rule. 2005-04-26 21:13:11 -07:00
greg@kroah.com 47b3f983da [PATCH] Don't require the BUS value for the CALLOUT rule. 2005-04-26 21:13:11 -07:00
greg@kroah.com bc64a25fd2 [PATCH] check for empty line a bit better in the parser.
Thanks to Mitch <mitch@0bits.com> for pointing this out.
2005-04-26 21:13:10 -07:00
greg@kroah.com a8b01705c6 [PATCH] add ability to have up to 5 SYSFS_ file/value pairs for the LABEL rule. 2005-04-26 21:13:10 -07:00
Roman.Kagan@itep.ru 093bf8f4d2 [PATCH] fix comment and whitespace handling in config files.
This chunk broke parsing of blank lines and comments with blanks before
'#'.  Please revert it with the patch below.

  Roman.
2005-04-26 21:13:09 -07:00
kay.sievers@vrfy.org 4868e8fba7 [PATCH] trivial cleanup parser changes
o use defines in debug strings
  o replace my 'xxx' debug :)
  o shorten line in man page example to not to exceed 80 chars when printed
2005-04-26 21:13:09 -07:00
kay.sievers@vrfy.org d94df23242 [PATCH] don't rely on field order in namedev_parse
o change the parsing to get a key from the rule and sort it
    into our list of known keys instead of expecting a special order
  o the key to match a sysfs file must be prependend by 'SYSFS_' now
    to match with the new parsing.
    (The config must be changed, but it's a bit more descriptive too.)
  o put names of fields in define's, like the name of the methods
  o update all tests and the man page
2005-04-26 21:13:08 -07:00
kay.sievers@vrfy.org 3d150dfb28 [PATCH] experimental (very simple) SYMLINK creation
> > here is a experimental symlink creation patch - for discussion,
> > in which direction we should go.
> > It is possible now to define SYMLINK= after the NAME= in udev.rules.
> > The link is relative to the node, but the path is not optimized now
> > if the node and the link are in the same nested directory.
> > Only one link is supported, cause i need to sleep now :)
> >
> > 06-simple-symlink-creation.diff
> >   simple symlink creation
> >   reorganized udev-remove to have access to the symlink field
> >   subdir creation/removal are functions now
> >   udev-test.pl tests for link creation/removal

Here is a new version with relative link target path optimization
an better tests in udev-test.pl:

LABEL, BUS="scsi", vendor="IBM-ESXS", NAME="1/2/a/b/node", SYMLINK="1/2/c/d/symlink"

  Dec  7 06:48:34 pim udev[13789]: create_node: symlink 'udev-root/1/2/c/d/symlink' to node '1/2/a/b/node' requested
  Dec  7 06:48:34 pim udev[13789]: create_path: created 'udev-root/1/2/c'
  Dec  7 06:48:34 pim udev[13789]: create_path: created 'udev-root/1/2/c/d'
  Dec  7 06:48:34 pim udev[13789]: create_node: symlink(../../a/b/node, udev-root/1/2/c/d/symlink)
2005-04-26 21:13:06 -07:00
greg@kroah.com 61219c756a [PATCH] fix permission handling logic
Now we can handle wildcards properly within the permission file.
2005-04-26 21:13:05 -07:00
greg@kroah.com 3836a3c49a [PATCH] get rid of the majority of the debug environment variables.
Now there are only 3 valid environment test variables.  The rest can be
specified with the config file.
2005-04-26 21:13:05 -07:00
greg@kroah.com e8bacccab2 [PATCH] add support for a main udev config file, udev.conf.
the older udev.config file is now called udev.rules.
This allows us to better control configuration values, and move away from 
the environment variables.
2005-04-26 21:13:05 -07:00
greg@kroah.com 19feb35100 [PATCH] split out the namedev config parsing logic to namedev_parse.c 2005-04-26 21:13:05 -07:00