Commit graph

146 commits

Author SHA1 Message Date
harald@redhat.com a75e2c14f9 [PATCH] udev parse bug
There is a bug parsing PROGRAMs after apostrophes. Try PROGRAM="/bin/echo 'test test".
2005-04-26 21:37:00 -07:00
kay.sievers@vrfy.org 29a3cead40 [PATCH] fix udevstart badly broken in udev 031
On Mon, 2004-09-13 at 01:56 +0200, Marco d'Itri wrote:
> Starting from udev 031, the %-arguments passed to PROGRAMs are not
> correct when the new udevstart code is being used.
>
> KERNEL="event[0-9]*",   NAME="input/%k", PROGRAM="/etc/udev/inputdev.sh %k %n %M %m", RESULT="inputdev", MODE="0664", GROUP="video"
>
> generates this log (just echo $*):
>
> event0 0 13 64
> event0 0 13 64
> event0 0 13 64
>
> while the correct log (generated using the old shell script instead of
> udevstart) would be:
>
> event0 0 13 64
> event1 1 13 65
> event2 2 13 66

Yes, I can simulate this, please try the attached patch. I expect, that
it fixes it, cause we better not mangle the parsed config while matching
the rules.
2005-04-26 21:37:00 -07:00
david@fubar.dk 0a8dd7f37c [PATCH] compatibility symlinks for udev
On Mon, 2004-09-06 at 17:45 +0200, Kay Sievers wrote:
> On Mon, 2004-09-06 at 16:46 +0200, David Zeuthen wrote:
>
> Nice, I like it. It's a easy way to group device nodes of the same type,
> but coming from different kernel subsystems.
>

That's a good way of putting it, yeah.

> > Here's a patch against udev-030 that can help create compatibility
> > symlinks like /dev/cdrom, /dev/cdrom1 etc. The patch introduces a new
> > substitution type %C (for Compatibility) that can be used as follows
>
> I suggest using %e for enumeration here, cause "compatibility" can
> easily be misunderstood.
>

Good point, I've changed that.

> And we need a few lines added to the man page at udev.8.in :)
>

Done. I've also added an example.

Also, Kay pointed out offlist that the rules can be written to not
require a shell script; this actually works

        KERNEL="sr*", NAME="%k", SYMLINK="cdrom%e"
        KERNEL="scd*", NAME="%k", SYMLINK="cdrom%e"
        KERNEL="pcd*", NAME="%k", SYMLINK="cdrom%e"
        KERNEL="hd[a-z]", PROGRAM="/bin/cat /proc/ide/%k/media", RESULT="cdrom", NAME="\%k", SYMLINK="cdrom%e"
        KERNEL="fd[0-9]", NAME="%k", SYMLINK="floppy%e"
        KERNEL="hd[a-z]", PROGRAM="/bin/cat /proc/ide/%k/media", RESULT="floppy", NAME=\"%k", SYMLINK="floppy%e"

New patch is attached.

David
2005-04-26 21:37:00 -07:00
greg@kroah.com fcf3ce3417 [PATCH] clean up block whitelist search logic a bit. 2005-04-26 21:36:21 -07:00
ogasawara@osdl.org 9a52390cfe [PATCH] udevstart performance increase
I noticed a comment in namedev.c which stated

"Figure out where the device symlink is at.  For char devices this will
always be in the class_dev->path.  But for block devices, it's
different.  The main block device will have the device symlink in it's
path, but all partitions have the symlink in its parent directory.  But
we need to watch out for block devices that do not have parents, yet
look like a partition (fd0, loop0, etc.).  They all do not have a device
symlink yet.  We do a sit and spin on waiting for them right now, we
should possibly have a whitelist for these devices here..."

I went ahead and created a whitelist for the block devices that look
like partitions (mainly by using devices.txt) and tested for any
performance increase that we would see.  The whitelist only impacts
udevstart time depending on the state of UDEV_NO_SLEEP.  Since the list
was short, I just did a sequential search and ordered the list in such a
way that those block devices which have more /dev entires (ex. loop0,
loop1, loop2, etc) appear sooner in the list and will thus be found
quicker.  I've enclosed the patch and some of the performance results I
saw below.  Basically, as the number of block devices without device
symlinks increased, the use of the whitelist improved udevstart
performance compared to just sitting and spinning.  I just thought it
was interesting and thought I'd share.  If you feel the patch is
beneficial please consider for merging.  Also, if you'd be interested in
expanding the whitelist for other devices which are missing device
symlinks and seeing if there are added performance increases let me know
and I'll do what I can.  Thanks,

Leann

Note: ex. loop represents all the loop devices (i.e. loop0, loop1,
loop2, etc)

block devices present		with whitelist	time
2005-04-26 21:36:21 -07:00
kay.sievers@vrfy.org 84df02dd63 [PATCH] catchup with recent klibc
Our own implementation of the sysinfo system call is no longer
needed, cause it's merged it into klibc now.
2005-04-26 21:35:47 -07:00
kay.sievers@vrfy.org a36a3c3a44 [PATCH] fix test regressions
On Sat, Apr 17, 2004 at 03:30:29AM +0200, Kay Sievers wrote:
> On Sat, Apr 17, 2004 at 02:04:55AM +0200, Kay Sievers wrote:
> > On Fri, Apr 16, 2004 at 04:04:42PM -0700, Greg KH wrote:
> > > Oh, and if you run the latest udev_test.pl, we have a bunch more tests,
> > > including a few that fail, if you were looking for something to do :)
> >
> > Will do it. We need to change apply_format(). I tries to expand the '%%'
> > with the next iteration over the string and removes the '%'.

The tests are all successful now.
If this patch breaks something else, we simply have too few tests :)
2005-04-26 21:35:16 -07:00
kay.sievers@vrfy.org 1e799babb6 [PATCH] put config info in db for netdev
Small change, to put the config informations for handled network
interfaces into the database.
2005-04-26 21:35:14 -07:00
kay.sievers@vrfy.org bbbe503ec1 [PATCH] netdev - udevdb+dev.d changes
Here is a patch to change the netdev handling in the database and for
the dev.d/ calls. I applies on top of the udevd.patch, cause klibc has
no sysinfo().

 o netdev's are also put into our database now. I want this for the
   udevruler gui to get a list of all handled devices.
   All devices in the db are stamped with the system uptime value at
   the creation time. 'udevinfo -d' prints it.

 o the DEVPATH value is the key for udevdb, but if we rename
   a netdev, the name is replaced in the kernel, so we add
   the changed name to the db to match with the remove event.

   NOTE: The dev.d/ scripts still get the original name from the
   hotplug call. Should we replace DEVPATH with the new name too?

 o We now only add a device to the db, if we have successfully created
   the main node or successfully renamed a netdev. This is the main part
   of the patch, cause I needed to clean the retval passing trough all
   the functions used for node creation.

 o DEVNODE sounds a bit ugly for netdev's so I exported DEVNAME too.
   Can we change the name?

 o I've added a UDEV_NO_DEVD to possibly skip the script execution
   and used it in udev-test.pl.
   udevstart is the same horror now, if you have scripts with logging
   statements in dev.d/ it takes minutes to finish, can we skip the
   scripts here too?

 o The get_device_type() function is changed to be more strict, cause
   'udevinfo -a -p /block/' gets a class device for it and tries to
   print the major/minor values.

 o bugfix, the RESULT value has now a working newline removal and a test
   for this case.
2005-04-26 21:35:13 -07:00
kay.sievers@vrfy.org 949e32f224 [PATCH] apply all_partitions rule to main block device only
Rules with NAME{all_partitions}= are now applied only to the parent of a
block device. We no longer need to exclude the partitions or sg* devices.
2005-04-26 21:35:12 -07:00
kay.sievers@vrfy.org f61d732a02 [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 :)
2005-04-26 21:35:12 -07:00
greg@kroah.com 615ba3e82b [PATCH] fix build error in namedev.c caused by previous patch. 2005-04-26 21:35:11 -07:00
kay.sievers@vrfy.org ddd5b5dc48 [PATCH] correct apply_format() for symlink only rules
Patch from Andrey, which restores the ability to use RESULT values in a
"symlink only" rule. We need to call apply_format() directly after
the matching rule, otherwise the RESULT value may be lost.
2005-04-26 21:35:10 -07:00
olh@suse.de 4474484153 [PATCH] uninitialized variable for mknod and friend
mknod gets an uninitialized variable, which leads to interesting file
modes. the bug is in namedev, devices with no match must not use the
uninitialized stuff were dev points to.
2005-04-26 21:35:10 -07:00
kay.sievers@vrfy.org b608ade8e4 [PATCH] first stupid try for a rule compose gui
On Mon, Mar 15, 2004 at 09:28:17PM +0100, Kay Sievers wrote:
> Here is a first simple and pretty stupid try to make a simple tool for
> composing of a udev rule.
>
> It reads the udevdb to get all currently handled devices and presents a
> list, where you can choose the device to compose the rule for.
>
> The composed rule is just printed out in a window, nothing else by now.
>
> Do we want something like this?
> Nevermind, I always wanted to know, how this newt thing works :)

Here is the next step, I still can't sleep and there are to many patches
pending to make something useful :)
Cause nobody wanted to play with me, I've made a screenshot.
The device list is sorted in alphabetical order now and if there are only
a few recently discovered devices, they are placed on top of the list.

For those who want to have a look:

  http://vrfy.org/projects/udev/udevruler.png

The patch applies on top of today's mmap() patch. The db format is
changed to have the file and line number of the applied rule. So it
should be easy to edit the matching rule with this beast. It compiles
with "make all udevruler".
2005-04-26 21:35:10 -07:00
kay.sievers@vrfy.org c81b35c08b [PATCH] replace fgets() with mmap() and introduce udev_lib.[hc]
Here we replace the various fgets() with a mmap() call for the config
file reading, due to the reported performance problems with klibc.

Thanks to Patrick's testing, it makes a very small, close to nothing
speed gain for libc users, but a 6 times speed increase for klibc users
with a 1000 line config file.

I've created a udev_lib.[hc] for this and also moved all the generic
stuff from udev.h in there and uninlined the functions.
2005-04-26 21:35:10 -07:00
kay.sievers@vrfy.org 0a5417a0eb [PATCH] "symlink only" test
Here is a test for the "symlink only" rule.

Any reason to do the apply_format() inside the loop?
I've changed it.
2005-04-26 21:35:09 -07:00
kay.sievers@vrfy.org 558f80ba64 [PATCH] callout part selector tweak
Martin Schwenke <martin@meltin.net> asked for this feature and posted a
patch:

 The following patch almost let's me have the following configuration:

  PROGRAM="/sbin/aliaser %b %k %n %M %m", RESULT="?*", NAME="%c{1}", SYMLINK="%c{2+}"

 allowing me to specify an arbitrary number of symlinks by saying
 "giveme the second and later words"."


Here is the actual version with tests and a few words in the man page.
2005-04-26 21:35:09 -07:00
kay.sievers@vrfy.org 35b38379ba [PATCH] cleanup callout fork
Here I change the callout fork logic.
The current cersion is unable to read a pipe which is not flushed at once,
Now we read until it's closed.

The maximum argument count is calculated by the strlen now. We have 100
chars for our result buffer so we can't have more than 50 parameters.
So it's much more clear what will happen now and not some magic boundary
where we use shell behind it.

Parameter can be combined to one by using apostrophes.

this on works now:
  BUS="scsi", PROGRAM="/bin/sh -c 'echo foo3 foo4 foo5 foo6 foo7 foo8 foo9 | sed  s/foo9/bar9/'", KERNEL="sda3", NAME="%c{7}"

Two new test are also added.
2005-04-26 21:35:09 -07:00
kay.sievers@vrfy.org e41016d354 [PATCH] allow to specify node permissions in the rule
This allows to set the permissions along with the rule.

This is not a general replacement for the permissions config, but it
may be easier sometimes for the user to specify the permissions along
with the rule, cause the permissions config file wants the final node
name to match, which seems sometimes a bit difficult to guess, if
format % chars are used in the NAME field.

Any value not given in the rule is still be read from the permissions
file or set to the default. This one will also work:

  BUS="usb", KERNEL="video*", NAME="my-%k", OWNER="$local"

A few words to man page are also added and add_perm_dev() is moved into
namedev_parse.c where it belongs to.
2005-04-26 21:35:09 -07:00
kay.sievers@vrfy.org 17794d77b9 [PATCH] rename strn*() macros to strmax
Hey, I wrote the strn*() macros just 10 days ago and yesterday this trap
caught me with the %c{x} bug.
The names are misleading cause we all expect that the from field is limited by
the size argument, but we actually limit the overall size of the destination
string to prevent a overflow.

Here we rename all strn*() macros to str*max(). That should be
more self-explanatory.
2005-04-26 21:35:08 -07:00
kay.sievers@vrfy.org d5f91372dd [PATCH] conditional remove of trailing sysfs whitespace
Hey, it may never happen, that one wants to distinguish attributes by
trailing spaces, but we should not lose the control over it, just for
being lazy :)

Here we remove the trailing spaces of the sysfs attribute only if the
configured value to match doesn't have any trailing spaces by itself.
So if you put a attribute in a rule with spaces at the end, the sysfs
attribute _must_ match exactly.

Is that cool for everyone?

As usual, 2 tests are added for it with a artificial sysfs file and
a few words to the man page.
2005-04-26 21:35:08 -07:00
kay.sievers@vrfy.org ef672b3dc4 [PATCH] better fix for NAME="foo-%c{N}" gets a truncated name
On Wed, Mar 03, 2004 at 04:56:34PM -0800, Greg KH wrote:
> On Wed, Mar 03, 2004 at 03:57:04PM -0800, Patrick Mansfield wrote:
> >
> > Here is a patch for some new tests.
>
> Applied, thanks.

Here is a small improvement, which looks much better.

Hey Pat, thanks a lot for finding the recent bug, hope this one will
not break it again :)
2005-04-26 21:35:08 -07:00
kay.sievers@vrfy.org 27c3403dd8 [PATCH] fix NAME="foo-%c{N}" gets a truncated name
On Wed, Mar 03, 2004 at 02:43:34PM -0800, Patrick Mansfield wrote:
> Here is a fix and a new test for the problem Atul hit, where if we have a
> NAME based on a result of the form:
>
> 	NAME="foo-%c{7}"
>
> udev truncates the name. Without any prefix (the foo- in this example),
> the rule was working OK.

Here is a fix for the fix :)

Sorry, I broke it yesterday.
2005-04-26 21:35:08 -07:00
kay.sievers@vrfy.org 9fe3f9a938 [PATCH] cleanup mult field string handling
Here I try to cleanup our various multifield iteration over the strings.
Inspired by our nice list.h we now have a macro to iterate over the string
and process the parts of it:
It makes the code more readable and we don't change the string while we
process it like the former strsep() does.

Example:

  foreach_strpart(dev->symlink, " ", pos, len) {
  	if (strncmp(&dev->symlink[pos], find_name, len) != 0)
  		continue;

  	...
  }

For the callout part selector %c{2} we separate now not only by space but
also newline and return characters, cause some programs may give multiline
values back. A possible RESULT match must contain wildcards for these
characters.

Also a bug in the recent udevinfo symlink query feature is fixed.
2005-04-26 21:35:08 -07:00
kay.sievers@vrfy.org aebef544cb [PATCH] fix stroul endptr use
The endptr is never NULL, so here we hopefully do the right thing.
2005-04-26 21:35:06 -07:00
kay.sievers@vrfy.org bd5f8e7cd1 [PATCH] udev - fix debug info for multiple rule file config
On Sat, Feb 28, 2004 at 09:56:32PM +0100, Kay Sievers wrote:
> Andrey pointed out that we don't print the right filename in the debug
> output. Here is a fix for that. It applies on top of Andrey's symlink
> patch, cause we are touching the same part of the code.

The copy/paste devil catched me :)
Here is a fixed one.
2005-04-26 21:34:29 -07:00
kay.sievers@vrfy.org 63ead27c22 [PATCH] udev - activate formt length attribute
We carried the the old callout part selector syntax for two releases
now after it was replaced by the new %c{1} syntax. So here we remove
the old syntax and use the code to possibly specify the maximum count
of chars to insert into the string. It will work with all of our format
chars.
I don't know if somebody will use it, but the code is already there :)

's%3s{vendor}' returns "IBM" now, instead of "IBM-ESXS".

Also added is a test for it and a few words in the man page.
2005-04-26 21:34:29 -07:00
arvidjaar@mail.ru 97ed02eebe [PATCH] Add symlink only rules support 2005-04-26 21:34:28 -07:00
kay.sievers@vrfy.org c58e36c092 [PATCH] udev - safer sprintf() use
Here is for now my last patch to the string handling for a rather
theorethical case, where the node is very very very long. :)

We have accordant to strfieldcat(to, from) now a strintcat(to, i) macro,
which appends the ascii representation of a integer to a string in a
safe way.
2005-04-26 21:34:28 -07:00
greg@kroah.com dde05ccb8d [PATCH] remove limit of the number of args passed to PROGRAM
If we go over our internal limit of 7, then we call out to /bin/sh
otherwise we handle it ourself without relying on a shell.
2005-04-26 21:32:31 -07:00
kay.sievers@vrfy.org 3fe0734266 [PATCH] udev - safer string handling - part four
Mainly a cleanup of the earlier patches with a few missing pieces
and some cosmetical changes.

I've moved the udev_init_config() to very early init, otherwise we
don't get any logging for the processing of the input. What would I
do without gdb :)

Greg, it's the 7th patch in your box to apply. I will stop now and
wait for you :)
2005-04-26 21:32:30 -07:00
kay.sievers@vrfy.org e964c2c05d [PATCH] udev - safer string handling - part three
Here we truncate our input strings from the environment to our
defined limit. It's a bit theroretical but better check for it.

It cleans up some magic length definitions and removes the code
duplication in udev, udevtest and udevsend.

udevd needs to be killed after installation, cause the message size
is changed with this patch.
Should we do this with the 'make install', like we do with the '.udevdb'?
2005-04-26 21:32:30 -07:00
kay.sievers@vrfy.org 831f800da3 [PATCH] udev - safer string handling - part two
As promised, here is the next round. We provide in addition to the
already used macros:

  strfieldcpy(to, from)
  strfieldcat(to, from)

the corresponding friends, if the size of the target is not known and
must be provided by the caller:

  strnfieldcpy(to, from, maxsize)
  strnfieldcat(to, from, maxsize)

and switch nearly all possibly unsafe users of strcat(), strncat(),
strcpy() and strncpy() to these safer macros.

The last known remaining issue seems the use of sprintf() and
snprintf(). I will take on it later today or tomorrow.
2005-04-26 21:32:30 -07:00
kay.sievers@vrfy.org c472e3c89b [PATCH] udev - safer string handling all over the place
On Tue, Feb 24, 2004 at 11:50:52PM +0100, Kay Sievers wrote:
> Here is the first step towards a safer string handling.
> More will follow, but for now only the easy ones :)
>
> Thanks to all who pointed this out. strncat() isn't a nice function. We
> all should remember that the destination string is not terminated if the
> given lenght is shorter than the strlen of the source string.
>
> And shame on the various implementers of strfieldcat() I found in the
> unapplied patches on this list, it's not really better than strncpy()
> and hides the real problem.

Hmm, bk didn't checked in one file, maybe I edited it again as root.
Nevermind, here is the more complete version.
2005-04-26 21:32:30 -07:00
greg@kroah.com c80da5085f [PATCH] force udev to include the internal version of libsysfs and never the external one.
Should fix some more build bugs...
2005-04-26 21:32:29 -07:00
patmans@us.ibm.com 0bad3406c1 [PATCH] udev use new libsysfs header file location
Use the new location of libsysfs header files.
2005-04-26 21:32:29 -07:00
greg@kroah.com 961e47847c [PATCH] add support for UDEV_NO_SLEEP env variable so Gentoo people will be happy.
Actually, I'm happy to, startup time is much smaller...
2005-04-26 21:32:28 -07:00
kay.sievers@vrfy.org 88f09368b3 [PATCH] udev - switch callout part selector to {attribute}
Here we change the magic callout part number selector to the new
atribute syntax. The syntax to select the second part of the callout string:

 '%2c' is now '%c{2}'

I think it's more clear and we no longer misuse the length argument.

The old syntax is still supported, but we should remove it some
time in the future.
2005-04-26 21:32:28 -07:00
kay.sievers@vrfy.org 50e5de03d1 [PATCH] udev - create all partitions of blockdevice
Here is the first try to create all partitons of a blockdevice, since
removable media devices may need to acces the expected partition to
revalidate the media.

It uses the attribute syntax introduced with the last %s{file} patch.
I'm using this with my multi-slot-flash-card-reader:

  SYSFS{model}="USB Storage-SMC ", NAME{all_partitions}="smartmedia"
  SYSFS{model}="USB Storage-CFC ", NAME{all_partitions}="compactflash"
  SYSFS{model}="USB Storage-MSC ", NAME{all_partitions}="memorystick"
  SYSFS{model}="USB Storage-MMC ", NAME{all_partitions}="multimedia"

and I get:

  tree /udev/
  /udev/
  |-- memorystick
  |-- memorystick1
  |-- memorystick10
  |-- memorystick11
  |-- memorystick12
  |-- memorystick13
  |-- memorystick14
  |-- memorystick15
  |-- memorystick2
  |-- memorystick3
  |-- memorystick4
  |-- memorystick5
  |-- memorystick6
  |-- memorystick7
  |-- memorystick8
  |-- memorystick9
  |-- multimedia
  |-- multimedia1
  |-- multimedia10
  |-- multimedia11
  |-- multimedia12
  |-- multimedia13
  |-- multimedia14
  |-- multimedia15
  |-- multimedia2
  |-- multimedia3
  |-- multimedia4
  |-- multimedia5
  |-- multimedia6
  |-- multimedia7
  |-- multimedia8
  |-- multimedia9
  ...


If needed, we can make the number of partions to create
adjustable with the attribute?
2005-04-26 21:32:28 -07:00
kay.sievers@vrfy.org a27cd06c6d [PATCH] Adding '%s' format specifier to NAME and SYMLINK
On Thu, Feb 12, 2004 at 05:34:57PM -0800, Greg KH wrote:
> On Tue, Feb 10, 2004 at 09:14:20AM +0100, Hannes Reinecke wrote:
> > Hi all,
> >
> > this patch makes the format for NAME and SYMLINK a bit more flexible:
> > I've added a new format specifier '%s{<SYSFS_var>}', which allows for
> > the value of any sysfs entry found for this device to be inserted.
> > Example (for our S/390 fcp adapter):
> >
> > BUS="ccw", SYSFS_devtype="1732/03", NAME="%k" \
> > SYMLINK="zfcp-%s{hba_id}-%s{wwpn}:%s{fcp_lun}"
> >
> > I know this could also be done with an external program, but having this
> > incorporated into udev makes life easier, especially if run from
> > initramfs. Plus it makes the rules easier to follow, as the result is
> > directly visible and need not to be looked up in some external program.
> >
> > Comments etc. welcome.
>
> Oops, sorry I missed this for the 017 release.  I'll look at it tomorrow
> and get back to you.  At first glance it looks like a good thing.
>
> Oh, you forgot to update the documentation, that's important to do if
> you want this change to make it in :)

I took a part of the code and made a version that uses already implemented
attribute finding logic.

The parsing of the format length '%3x' and the '%x{attribute}' is a fuction now,
maybe there are more possible users in the future.

I've also added the test to udev-test.pl.
2005-04-26 21:32:28 -07:00
greg@kroah.com 7a4877bf6f [PATCH] Fix bug where we did not use the "converted" kernel name if we had no rule.
This fixes the bug with names that have a ! in them and no rule to match.
2005-04-26 21:32:27 -07:00
greg@kroah.com ba053b91e1 [PATCH] fix bug in permission handling. 2005-04-26 21:32:27 -07:00
greg@kroah.com bb051f6657 [PATCH] fix problem where usb devices can be either the main device or the interface
This fixes the bug of a long delay for mouse devices
2005-04-26 21:32:27 -07:00
patmans@us.ibm.com 3a8c51a771 [PATCH] udev add wild card compare for ID
Allow wild card comparison of the ID.

Using strcmp_pattern here also means we on longer match partial values,
for example, a scsi rule like this won't match anymore:

	BUS="scsi", ID=":0", NAME="sdfoo-short-bus_id-1"

But this now works:

	BUS="scsi", ID="*:0", NAME="sdfoo-bus_id-wild-card-1"
2005-04-26 21:32:26 -07:00
patmans@us.ibm.com 5a42932b9a [PATCH] udev kill extra bus_id compares in match_id
Kill the extra bus_id check in match_id. This is wrong, especially since
we check for rule matches with the parent devices on a given devices path.

For example, given a device path of:

	/sys/devices/pci0000:01/0000:01:0c.0/host5/5:0:2:0

With this patch, the following rule will no longer match:

	BUS="scsi", ID="host5", NAME="sd-bus_id-host5"
2005-04-26 21:32:26 -07:00
greg@kroah.com 1b9410278e [PATCH] Handle the '!' character that some block devices have. 2005-04-26 21:32:26 -07:00
kay.sievers@vrfy.org c5118442a1 [PATCH] udev - fix "ignore method"
On Sun, Feb 08, 2004 at 04:36:01PM +0100, Kay Sievers wrote:
> We don't handle NAME="" the right way. Thanks to Emil None <emil71se@yahoo.com>
> for pointing this out. Here is a fix for it and a trivial style cleanup.

Changed the ignore dbg() to info().
2005-04-26 21:32:26 -07:00
kay.sievers@vrfy.org 8a08e4b190 [PATCH] fix possible buffer overflow
On Tue, Jan 27, 2004 at 11:02:25AM -0800, Greg KH wrote:
> On Mon, Jan 26, 2004 at 07:28:03PM -0500, Adrian Drzewiecki wrote:
> > Looking over the code, I noticed something odd in
> > namedev.c:strcmp_pattern() --
> >
> > 	while (*p && (*p != ']'))
> > 		p ++;
> > 	return strcmp_pattern(p+1, s+1);
> >
> > If the pattern string is invalid, and is not terminated by a ']', then 'p'
> > will point at \0 and p+1 will be beyond the string.
>
> Yes, I think you are correct.
>
> Hm, Kay, any idea of the proper way to fix this?  I've attached a patch
> below, but I don't think it is correct.
>
>  					while (*p && (*p != ']'))
>  						p++;
> -					return strcmp_pattern(p+1, s+1);
> +					if (*p)
> +						return strcmp_pattern(p+1, s+1);
> +					else
> +						return 1;
>  				}
>  			}


Sure, it's perfectly correct. I'm wondering how Adrian found this.

We can use the return 1 at the end of the whole function, and asking
for the closing ']' is more descriptive, but it does the same.

-					return strcmp_pattern(p+1, s+1);
+					if (*p == ']')
+						return strcmp_pattern(p+1, s+1);

Patch is attached, that also replaces all the *s with s[0].
2005-04-26 21:13:20 -07:00
kay.sievers@vrfy.org 2a25816ff0 [PATCH] udev - trivial style cleanup
Trivial style cleanup, to be consistent.

And add chdir("/") to the daemon so one can umout its filesystem,
while we are running :)
2005-04-26 21:13:19 -07:00