Commit graph

100 commits

Author SHA1 Message Date
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
greg@kroah.com 724257d97b [PATCH] add support for figuring out which device on the sysfs "chain" the rule applies to.
This should fix one of the more annoying things to me about udev, and
gets rid of a TODO item.
2005-04-26 21:13:17 -07:00
greg@kroah.com 267f534d1c [PATCH] misc code cleanups. 2005-04-26 21:13:17 -07:00
kay.sievers@vrfy.org 765cbd9759 [PATCH] set default owner/group in db - update
I've edited the man page today, so this is alreay included :)

Also a few more trivials:
  o added the defaults to udev.conf.in
  o removed class_dev from get_default_mode(), to match with Hanna's
  o changed size of mode_str to MODE_SIZE
  o changed a few char compares from from 0x00 to '\0'
2005-04-26 21:13:17 -07:00
hannal@us.ibm.com 74c73ef994 [PATCH] set default owner/group in db.
This patch fixes a bug where the udev database stored empty strings
for Owner and Group if they were default. This patch stores the default
value into the database if not set otherwise. See example output:


crw-------    1 root     root       4,  65 Jan 16 11:13 ttyS1

P: /class/tty/ttyS1
N: ttyS1
S:
O: root
G: root

This is a bit of a hack. However, until udev supports setting the
o/g values they will be root/root anyway so the database might as
well reflect the truth instead of empty strings.
2005-04-26 21:13:17 -07:00
kay.sievers@vrfy.org 54988802b7 [PATCH] add udev logging to info log
On Thu, Jan 15, 2004 at 05:14:16AM +0100, Kay Sievers wrote:
> On Wed, Jan 14, 2004 at 01:10:43PM -0800, Greg KH wrote:
> > On Wed, Jan 14, 2004 at 02:34:26PM -0600, Clay Haapala wrote:
> > > On Wed, 14 Jan 2004, Chris Friesen spake thusly:
> > > >
> > > > Maybe for ones with a matching rule, you could print something like:
> > > >
> > > >
> > > Is the act of printing/syslogging a rule in an of itself?
> >
> > No, as currently the only way stuff ends up in the syslog is if
> > DEBUG=true is used on the build line.
> >
> > But it's sounding like we might want to change that... :)
>
> How about this in the syslog after connect/disconnect?
>
>   Jan 15 05:07:45 pim udev[28007]: configured rule in '/etc/udev/udev.rules' at line 17 applied, 'video*' becomes 'video/webcam%n'
>   Jan 15 05:07:45 pim udev[28007]: creating device node '/udev/video/webcam0'
>   Jan 15 05:07:47 pim udev[28015]: removing device node '/udev/video/webcam0'

Here is a slightly better version. I've created a logging.h file and
moved the debug macros from udev.h in there.

If you type:

  'make'            - you will get a binary that prints one or two lines to syslog
                      if a device node is created or deleted

  'make LOG=false'  - you get a binary that prints asolutely nothing

  'make DEBUG=true' - the same as today, it will print all debug lines
2005-04-26 21:13:17 -07:00
greg@kroah.com 18f0045bc8 [PATCH] remove the %D modifier as it is not longer needed. 2005-04-26 21:13:16 -07:00
ananthmg@rediffmail.com 616a707807 [PATCH] libsysfs update for refresh + namedev.c changes
Please find inlined a patch which contains updates to libsysfs
(pre-release) for refresh and also changes to namedev.c to take
advantage of it.
2005-04-26 21:13:16 -07:00
kay.sievers@vrfy.org 8ffb636f01 [PATCH] udev - introduce format escape char
This patch adds a '%' to the format char list, so that a external
program may called with a non expanded '%' like:

  PROGRAM="/bin/date +%%s"

Olaf Hering asked for the feature.
A tricky test is also added :)
2005-04-26 21:13:16 -07:00
kay.sievers@vrfy.org 7e5f7397f9 [PATCH] udev - CALLOUT is PROGRAM now
replace CALLOUT by PROGRAM and fix old rule format
2005-04-26 21:13:16 -07:00
kay.sievers@vrfy.org a2505f4d1d [PATCH] udev - simple debug tweak
change the empty debug string:
  Jan 13 00:55:42 pim udev[2849]: namedev_name_device: found matching rule, 'video*' becomes ''

to something useful:
  Jan 13 01:00:23 pim udev[3234]: namedev_name_device: found matching rule, 'video*' becomes 'video/webcam%n'
2005-04-26 21:13:15 -07:00
greg@kroah.com 1f7148c7df [PATCH] fix a few stale comments in namedev.c 2005-04-26 21:13:15 -07:00
greg@kroah.com b7824727a0 [PATCH] add bus test for usb-serial bus. 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
kay.sievers@vrfy.org 41397661c6 [PATCH] udev - make exec_callout() reusable
Here is a patch that switches exec_callout() to be reusable.
I want it to be callable in a different context.
2005-04-26 21:13:15 -07:00
kay.sievers@vrfy.org 2794d24917 [PATCH] udev - exec status fix for klibc
Here is a patch to remove the ifdef's and fix klibc instead.
2005-04-26 21:13:14 -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
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
azarah@nosferatu.za.org 8ed89229bc [PATCH] Fix udev gcc-2.95.4 compat
Two liner to get gcc-2.95.4 to compile udev.
2005-04-26 21:13:12 -07:00
kay.sievers@vrfy.org 647c8fc43e [PATCH] fix for apply_format()
fix possible NULL pointer in '%c' callout substitution
and cleanup '%D' debug text
2005-04-26 21:13:12 -07:00
kay.sievers@vrfy.org 2441c20743 [PATCH] 'ide' missing in bus_files[]
my syslog want's to contact you :)

  Dec 25 20:37:48 pim udev[2274]: wait_for_device_to_initialize: Did not find bus type 'ide' on list of bus_id_files, contact greg@kroah.com

We need to put 'ide' to the bus_files array,
don't know which file to use...
2005-04-26 21:13:11 -07:00
greg@kroah.com a7402175da [PATCH] If a LABEL rule has a BUS id, then we must check to see if the device is on a bus. 2005-04-26 21:13:11 -07:00
greg@kroah.com 1d936fbca0 [PATCH] If a CALLOUT rule has a BUS id, then we must check to see if the device is on a bus.
Thanks to Martin Schlemmer <azarah@nosferatu.za.org> for pointing this out.
2005-04-26 21:13:11 -07:00
greg@kroah.com 480763324d [PATCH] add pci to the bus_files list. 2005-04-26 21:13:10 -07:00
greg@kroah.com 07562d6ecf [PATCH] fix long delay for all devices in namedev
Now we only sleep if we can't find the device file, and we have
a hack to sleep for 1 second if we are on a partition.  This will be
removed when the libsysfs change gets made...
2005-04-26 21:13:10 -07:00
greg@kroah.com ca593541e6 [PATCH] fix complier warning in namedev.c 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
kay.sievers@vrfy.org 958479a0de [PATCH] add any valid device 2005-04-26 21:13:09 -07:00
kay.sievers@vrfy.org 3e54036862 [PATCH] introduce format char 'k' for kernel-name
Attached is a patch that introduces the format char 'k' to be replaced with
the kernel name. I like to have it in a callout script.

I've moved the build_kernel_name() back to namedev_name_device() since
we don't expect it growing cause of 'sdaj' :)
2005-04-26 21:13:09 -07:00
greg@kroah.com 1edbb8d350 [PATCH] Just live with a sleep(1) in namedev for now until libsysfs is fixed up. 2005-04-26 21:13:09 -07:00
greg@kroah.com dac056aa30 [PATCH] try to wait until the proper device file shows up in sysfs.
this still isn't working correctly for partitions, so don't
think this is the final version...
2005-04-26 21:13:09 -07:00
greg@kroah.com 7ecb8d23f3 [PATCH] remove unneeded TODO and FIXME entry
Thanks to Kay for pointing it out to me.
2005-04-26 21:13:09 -07:00
kay.sievers@vrfy.org b1c5e3339d [PATCH] get part of callout return string
Try this patch if you like, to get special parts of the callout output.
This beast works now:
CALLOUT, BUS="scsi", PROGRAM="/bin/echo -n node link1 link2", ID="node *", NAME="%1c", SYMLINK="%2c %3c"

The callout returned string is separated by spaces and is
addressed by the "len" value of the 'c' format char.
Since we support symlinks, this my be useful for other uses of callout too.

  introduce 'len number' for format chars
  the first use is 'c'-the callout return to select a part of the output string like:
  CALLOUT, BUS="scsi", PROGRAM="/bin/echo -n node link1 link2", ID="node *", NAME="%1c", SYMLINK="%2c %3c"
  (note: first part is requested by len=1, len=0 will return the whole string)
  add a test to udev-test.pl
2005-04-26 21:13:07 -07:00
kay.sievers@vrfy.org 2052464275 [PATCH] remove '\n' from end of callout return
remove possible newline at end of callout output,
  for easier matching with ID=
2005-04-26 21:13:07 -07:00
dsteklof@us.ibm.com 5d4754f195 [PATCH] pre-libsysfs-0.4.0 patch
I am sending you a pre-release patch. It's everything that's in our
current CVS tree. It adds the functionality you've been looking for. Please
play with this before checking it into your tree, I'd like to know if
it's ok with you or if you find problems. I have tested this out with
test.all and the perl regression test. Let me know what you think.

Still need to do more testing for our work and add some more functions
related to the changes.

I've gone into namedev.c and udev-add.c to make the necessary changes
in line with the library. I have not gone and edited any of the "extras".


Changes:

1) Libsysfs object structures work more as handles now, their included
directories or devices are labeled private. If you need attributes
from a sysfs_class_device, call the available function and don't access
the directory directly. Same holds true for a sysfs_class_device
sysfs_device. Do not access the link directly but call the function
sysfs_get_classdev_device() instead. We only populate entries upon
request, makes things faster and uses less memory.

2) Added sysfs_get_classdev_parent() as requested.

3) Changed getpagesize to sysconf.

4) Added sysfs_refresh_attributes function for refreshing views of
attribute lists. We still need to add refresh for links and subdirs. All
udev needs to do is keep calling sysfs_get_classdev_attr() and that will
internally call the refresh routine.
2005-04-26 21:13:07 -07:00
greg@kroah.com 525d07e78e [PATCH] change devfs disk name rule from 'disk' to 'disc' 2005-04-26 21:13:07 -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
kay.sievers@vrfy.org 83be97ba21 [PATCH] pattern match for label method
switch LABEL search to pattern match
  add a test for pattern match in LABEL
  remove useless rule from udev.rules
2005-04-26 21:13:06 -07:00
kay.sievers@vrfy.org 28d6536a0f [PATCH] a bug in linefeed removal
While I was adding pattern match to the LABEL method i hit a bug.
We modify a string returned from libsysfs, so with every iteration is is
truncated by one char:

Dec  4 02:27:16 pim udev[23307]: do_label: dev->bus='scsi' sysfs_device->bus='scsi'
Dec  4 02:27:16 pim udev[23307]: do_label: look for device attribute 'vendor'
Dec  4 02:27:16 pim udev[23307]: do_label: xxx 'IBM-ESXS '
Dec  4 02:27:16 pim udev[23307]: do_label: compare attribute 'vendor' value 'IBM-ESX' with '?IBM-ESXS'
Dec  4 02:27:16 pim udev[23307]: do_label: dev->bus='scsi' sysfs_device->bus='scsi'
Dec  4 02:27:16 pim udev[23307]: do_label: look for device attribute 'vendor'
Dec  4 02:27:16 pim udev[23307]: do_label: xxx 'IBM-ESX'
Dec  4 02:27:16 pim udev[23307]: do_label: compare attribute 'vendor' value 'IBM-ES' with 'IBM-ESXS?'
Dec  4 02:27:16 pim udev[23307]: do_label: dev->bus='scsi' sysfs_device->bus='scsi'
Dec  4 02:27:16 pim udev[23307]: do_label: look for device attribute 'vendor'
Dec  4 02:27:16 pim udev[23307]: do_label: xxx 'IBM-ES'
Dec  4 02:27:16 pim udev[23307]: do_label: compare attribute 'vendor' value 'IBM-E' with 'IBM-ES??'
Dec  4 02:27:16 pim udev[23307]: do_label: dev->bus='scsi' sysfs_device->bus='scsi'
Dec  4 02:27:16 pim udev[23307]: do_label: look for device attribute 'vendor'
Dec  4 02:27:16 pim udev[23307]: do_label: xxx 'IBM-E'
Dec  4 02:27:16 pim udev[23307]: do_label: compare attribute 'vendor' value 'IBM-' with 'IBM-ESXSS'

I changed the behavior to remove only the line feed.

03-bug-in-linefeed-removal.diff
  remove only the line feed from string not every last char
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 8957102244 [PATCH] add support for the default_mode variable, as it is documented... 2005-04-26 21:13:05 -07:00
kay.sievers@vrfy.org 9f1da36138 [PATCH] pattern matching for namedev
As promised yesterday, here is a patch to implement a more advanced
pattern matching instead of the simple '*'.

We can remove the "tty"="tty" line from udev.rules now and
replace "tty*" by "tty[0-9]*" to catch only the vc's.


  implement pattern matching in namedev
  '*'  - to match zero or more chars
  '?'  - to match exactly one char
  '[]' - character classes with ranges '[0-9]'and negation [!A]
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
greg@kroah.com 5c6f0fb0dc [PATCH] rename namedev's get_attr() to be main namedev_name_device() as that's what it really is. 2005-04-26 21:13:05 -07:00
kay.sievers@vrfy.org 0db6d4cc61 [PATCH] catch replace device by wildcard
catch device name by wildcard to support a whole class of devices
  by just one config line like:
  REPLACE, KERNEL="tty*", NAME="vc/%n"
2005-04-26 21:13:05 -07:00
greg@kroah.com 8cf7ebe8cd [PATCH] operate on the rules in the order they are in the config file (within the rule type) 2005-04-26 21:13:04 -07:00